Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
disable lints for docs dir
  • Loading branch information
aviatesk committed Jul 3, 2020
commit 4ce9b9bcadd728eb37448bbc4ecf795431e21a79
14 changes: 8 additions & 6 deletions src/requests/textdocument.jl
Original file line number Diff line number Diff line change
Expand Up @@ -309,21 +309,23 @@ function is_diag_dependent_on_env(diag::Diagnostic)
startswith(diag.message, "An imported")
end

const LINT_IGNORED_DIRS = ["test", "docs"] # TODO?: make this configurable ?

function publish_diagnostics(doc::Document, server, conn)
if server.runlinter && server.symbol_store_ready && (is_workspace_file(doc) || isunsavedfile(doc))
if is_in_test_dir_of_package(getpath(doc))
publishDiagnosticsParams = if server.runlinter && server.symbol_store_ready && (is_workspace_file(doc) || isunsavedfile(doc))
pkgpath = getpath(doc)
if any(is_in_target_dir_of_package.(Ref(pkgpath), LINT_IGNORED_DIRS))
filter!(!is_diag_dependent_on_env, doc.diagnostics)
publishDiagnosticsParams = PublishDiagnosticsParams(doc._uri, doc._version, doc.diagnostics)
PublishDiagnosticsParams(doc._uri, doc._version, doc.diagnostics)
else
publishDiagnosticsParams = PublishDiagnosticsParams(doc._uri, doc._version, doc.diagnostics)
PublishDiagnosticsParams(doc._uri, doc._version, doc.diagnostics)
end
else
publishDiagnosticsParams = PublishDiagnosticsParams(doc._uri, doc._version, Diagnostic[])
PublishDiagnosticsParams(doc._uri, doc._version, Diagnostic[])
end
JSONRPC.send(conn, textDocument_publishDiagnostics_notification_type, publishDiagnosticsParams)
end


function clear_diagnostics(uri::URI2, server, conn)
doc = getdocument(server, uri)
empty!(doc.diagnostics)
Expand Down
7 changes: 3 additions & 4 deletions src/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,10 @@ end

maybe_lookup(x, server) = x isa SymbolServer.VarRef ? SymbolServer._lookup(x, getsymbolserver(server), true) : x # TODO: needs to go to SymbolServer

function is_in_test_dir_of_package(path::String)
function is_in_target_dir_of_package(pkgpath, target)
try # Safe failure - attempts to read disc.
spaths = splitpath(path)
if (i = findfirst(==("test"), spaths)) !== nothing && "src" in readdir(joinpath(spaths[1:i - 1]...))
spaths = splitpath(pkgpath)
if (i = findfirst(==(target), spaths)) !== nothing && "src" in readdir(joinpath(spaths[1:i - 1]...))
return true
end
return false
Expand All @@ -362,7 +362,6 @@ function is_in_test_dir_of_package(path::String)
end
end


if VERSION < v"1.1"
_splitdir_nodrive(path::String) = _splitdir_nodrive("", path)
function _splitdir_nodrive(a::String, b::String)
Expand Down