Skip to content

Commit 98a3a3f

Browse files
authored
Merge pull request #160 from julia-vscode/misc
turn checks on by default, add missingref options
2 parents f057f3c + d081293 commit 98a3a3f

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/linting/checks.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ function check_farg_unused(x::EXPR)
442442
end
443443
end
444444

445-
const default_options = (false, true, false, true, true, false, true, true, true, true)
445+
const default_options = (true, true, true, true, true, true, true, true, true, true)
446446

447447
struct LintOptions
448448
call::Bool
@@ -483,7 +483,13 @@ function check_all(x::EXPR, opts::LintOptions, server)
483483
end
484484

485485

486-
function collect_hints(x::EXPR, server, missing = true, isquoted = false, errs = Tuple{Int,EXPR}[], pos = 0)
486+
"""
487+
collect_hints(x::EXPR, server, missingrefs = :all, isquoted = false, errs = Tuple{Int,EXPR}[], pos = 0)
488+
489+
Collect hints and errors from an expression. `missingrefs` = (:none, :id, :all) determines whether unresolved
490+
identifiers are marked, the :all option will mark identifiers used in getfield calls."
491+
"""
492+
function collect_hints(x::EXPR, server, missingrefs = :all, isquoted = false, errs = Tuple{Int,EXPR}[], pos = 0)
487493
if quoted(x)
488494
isquoted = true
489495
elseif isquoted && unquoted(x)
@@ -493,20 +499,20 @@ function collect_hints(x::EXPR, server, missing = true, isquoted = false, errs =
493499
# collect parse errors
494500
push!(errs, (pos, x))
495501
elseif !isquoted
496-
if missing && CSTParser.isidentifier(x) && !hasref(x) &&
502+
if missingrefs != :none && CSTParser.isidentifier(x) && !hasref(x) &&
497503
!(valof(x) == "var" && parentof(x) isa EXPR && typof(parentof(x)) === CSTParser.NONSTDIDENTIFIER) &&
498504
!((valof(x) == "stdcall" || valof(x) == "cdecl" || valof(x) == "fastcall" || valof(x) == "thiscall" || valof(x) == "llvmcall") && is_in_fexpr(x, x->typof(x) === CSTParser.Call && isidentifier(x[1]) && valof(x[1]) == "ccall"))
499505
push!(errs, (pos, x))
500506
elseif haserror(x) && errorof(x) isa StaticLint.LintCodes
501507
# collect lint hints
502508
push!(errs, (pos, x))
503509
end
504-
elseif isquoted && should_mark_missing_getfield_ref(x, server)
510+
elseif isquoted && missingrefs == :all && should_mark_missing_getfield_ref(x, server)
505511
push!(errs, (pos, x))
506512
end
507513

508514
for i in 1:length(x)
509-
collect_hints(x[i], server, missing, isquoted, errs, pos)
515+
collect_hints(x[i], server, missingrefs, isquoted, errs, pos)
510516
pos += x[i].fullspan
511517
end
512518

src/references.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,9 @@ function resolve_getfield(x::EXPR, parent::SymbolServer.DataTypeStore, state::St
237237
fi = findfirst(f->Symbol(valof(x)) == f, parent.fieldnames)
238238
ft = parent.types[fi]
239239
val = SymbolServer._lookup(ft, getsymbolserver(state.server))
240-
if val !== nothing
241-
setref!(x, Binding(noname, nothing, val, [], nothing, nothing))
242-
resolved = true
243-
end
240+
# TODO: Need to handle the case where we get back a FakeUnion, etc.
241+
setref!(x, Binding(noname, nothing, val, [], nothing, nothing))
242+
resolved = true
244243
end
245244
return resolved
246245
end

0 commit comments

Comments
 (0)