Skip to content

Commit 83737bc

Browse files
committed
wip: Improve type stabilities in JETLS
1 parent cc6f373 commit 83737bc

File tree

7 files changed

+29
-17
lines changed

7 files changed

+29
-17
lines changed

.JETLSConfig.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ match_type = "regex"
1515
severity = "off"
1616
path = "LSP/src/LSP.jl"
1717

18+
[[diagnostic.patterns]]
19+
pattern = "no matching method found .*var\"AnonymousInterface.*"
20+
match_by = "message"
21+
match_type = "regex"
22+
severity = "off"
23+
path = "LSP/src/**/*.jl"
24+
1825
# TODO [JuliaLowering]
1926
# Temporarily downgrade some known JuliaLowering issues to information level
2027
[[diagnostic.patterns]]

src/analysis/full-analysis.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function collect_search_uris(server::Server, uri::URI)
3939
elseif analysis_info isa OutOfScope && @isdefined(Revise)
4040
# TODO: This implementation should be revisited when Revise is integrated into full-analysis
4141
out_of_scope = analysis_info
42-
pkgid = Base.PkgId(something(out_of_scope.module_context, Main))
42+
pkgid = Base.PkgId(@something(out_of_scope.module_context, Main))
4343
if haskey(Revise.pkgdatas, pkgid)
4444
pkgdata = Revise.pkgdatas[pkgid]
4545
for file in Revise.srcfiles(pkgdata)
@@ -702,7 +702,7 @@ function analyze_package_with_revise(
702702
show_error_message(server, "Failed to load package $(pkgid.name): $(sprint(Base.showerror, e))")
703703
error(lazy"Package $(pkgid.name) is not loadable") # TODO
704704
finally
705-
notify(activation_done)
705+
isnothing(activation_done) || notify(activation_done)
706706
end
707707
end
708708

src/app.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function (@main)(args::Vector{String})::Cint
128128
return Cint(1)
129129
end
130130
elseif (m = match(r"^--socket=(\d+)$", arg); !isnothing(m))
131-
socket_port = tryparse(Int, m.captures[1])
131+
socket_port = tryparse(Int, m.captures[1]::AbstractString)
132132
@label check_socket_port
133133
if isnothing(socket_port)
134134
@error "Invalid port number for --socket (must be a valid integer)"
@@ -144,7 +144,7 @@ function (@main)(args::Vector{String})::Cint
144144
return Cint(1)
145145
end
146146
elseif (m = match(r"^--clientProcessId=(\d+)$", arg); !isnothing(m))
147-
client_process_id = tryparse(Int, m.captures[1])
147+
client_process_id = tryparse(Int, m.captures[1]::AbstractString)
148148
@label check_client_process_id
149149
if isnothing(client_process_id)
150150
@error "Invalid process ID for --clientProcessId (must be a valid integer)"

src/cli-check.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function render_spinner(p::SpinnerProgress)
5454
return
5555
end
5656
frame = SPINNER_FRAMES[p.spinner_idx]
57-
prefix = "$(frame) $(p.current_file)"
57+
prefix::String = "$(frame) $(p.current_file)"
5858
term_width = displaysize(p.io)[2]
5959
if isempty(p.current_message)
6060
if length(prefix) > term_width - 1
@@ -64,7 +64,7 @@ function render_spinner(p::SpinnerProgress)
6464
p.last_line_length = length(prefix)
6565
else
6666
separator = ": "
67-
message = p.current_message
67+
message::String = p.current_message
6868
total_len = length(prefix) + length(separator) + length(message)
6969
if total_len > term_width - 1
7070
available = term_width - 1 - length(prefix) - length(separator) - 1
@@ -98,8 +98,9 @@ end
9898

9999
function stop_spinner!(p::SpinnerProgress)
100100
p.active = false
101-
if p.spinner_task !== nothing
102-
wait(p.spinner_task)
101+
spinner_task = p.spinner_task
102+
if spinner_task !== nothing
103+
wait(spinner_task)
103104
p.spinner_task = nothing
104105
end
105106
@lock p.lock clear_line(p)

src/completions.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -490,11 +490,11 @@ function extract_param_text(p::JS.SyntaxTree)
490490
elseif k === JS.K"::"
491491
n = JS.numchildren(p)
492492
if n == 1
493-
typ = JS.sourcetext(p[1])
493+
typ = JS.sourcetext(p[1])::AbstractString
494494
return String("::" * typ)
495495
elseif n == 2
496496
name = @something extract_param_text(p[1]) return nothing
497-
typ = JS.sourcetext(p[2])
497+
typ = JS.sourcetext(p[2])::AbstractString
498498
return String(name * "::" * typ)
499499
else
500500
return nothing
@@ -575,18 +575,19 @@ function should_insert_spaces_around_equal(fi::FileInfo, ca::CallArgs)
575575
JS.kind(kwnode) === JS.K"kw" || continue
576576
has_equals += 1
577577
pos = offset_to_xy(fi, JS.first_byte(kwnode))
578-
tok = token_at_offset(fi, pos)
578+
tok = @something token_at_offset(fi, pos) continue
579579
while JS.is_whitespace(this(tok))
580-
tok = next_tok(tok)
580+
tok = @something next_tok(tok) @goto next
581581
end
582582
JS.kind(this(tok)) === JS.K"Identifier" || continue
583-
tok = next_tok(tok)
583+
tok = @something next_tok(tok) continue
584584
JS.is_whitespace(this(tok)) || continue
585-
tok = next_tok(tok)
585+
tok = @something next_tok(tok) continue
586586
JS.is_plain_equals(this(tok)) || continue
587-
tok = next_tok(tok)
587+
tok = @something next_tok(tok) continue
588588
JS.is_whitespace(this(tok)) || continue
589589
has_whitespaces += 1
590+
@label next
590591
end
591592
return has_whitespaces has_equals - has_whitespaces
592593
end

src/utils/binding.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ function jl_lower_for_scope_resolution(
7070
return _jl_lower_for_scope_resolution(ctx1, st0, st1; convert_closures)
7171
end
7272

73-
function _jl_lower_for_scope_resolution(ctx1, st0, st1; convert_closures::Bool = false)
73+
function _jl_lower_for_scope_resolution(
74+
ctx1::JL.MacroExpansionContext, st0::JS.SyntaxTree, st1::JS.SyntaxTree;
75+
convert_closures::Bool = false
76+
)
7477
ctx2, st2 = JL.expand_forms_2(ctx1, st1)
7578
ctx3, st3 = JL.resolve_scopes(ctx2, st2)
7679
convert_closures || return (; st0, st1, st2, st3, ctx3)

src/utils/server.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ function get_context_info(state::ServerState, uri::URI, pos::Position; lookup_fu
304304
end
305305

306306
get_context_module(::Nothing, ::URI, ::Position) = Main
307-
get_context_module(oos::OutOfScope, ::URI, ::Position) = something(oos.module_context, Main)
307+
get_context_module(oos::OutOfScope, ::URI, ::Position) = @something(oos.module_context, Main)
308308
function get_context_module(analysis_result::AnalysisResult, uri::URI, pos::Position)
309309
safi = @something analyzed_file_info(analysis_result, uri) return Main
310310
curline = Int(pos.line) + 1

0 commit comments

Comments
 (0)