Skip to content

Commit 772ab39

Browse files
authored
Merge pull request #999 from julia-vscode/sp/symbolserver-upstream-url
allow setting symbol server URL
2 parents fe924da + 335a637 commit 772ab39

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ JSON = "0.20, 0.21"
2222
JSONRPC = "1.1"
2323
JuliaFormatter = "0.18.1"
2424
StaticLint = "8.0"
25-
SymbolServer = "6, 7.0"
25+
SymbolServer = "7.1"
2626
Tokenize = "0.5.10"
2727
URIParser = "0.4.1"
2828
julia = "1"

src/languageserverinstance.jl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ mutable struct LanguageServerInstance
6363

6464
shutdown_requested::Bool
6565

66-
function LanguageServerInstance(pipe_in, pipe_out, env_path="", depot_path="", err_handler=nothing, symserver_store_path=nothing, download=true)
66+
function LanguageServerInstance(pipe_in, pipe_out, env_path="", depot_path="", err_handler=nothing, symserver_store_path=nothing, download=true, symbolcache_upstream = nothing)
6767
new(
6868
JSONRPC.JSONRPCEndpoint(pipe_in, pipe_out, err_handler),
6969
Set{String}(),
7070
Dict{URI2,Document}(),
7171
env_path,
7272
depot_path,
73-
SymbolServer.SymbolServerInstance(depot_path, symserver_store_path),
73+
SymbolServer.SymbolServerInstance(depot_path, symserver_store_path; symbolcache_upstream = symbolcache_upstream),
7474
Channel(Inf),
7575
StaticLint.ExternalEnv(deepcopy(SymbolServer.stdlibs), SymbolServer.collect_extended_methods(SymbolServer.stdlibs), collect(keys(SymbolServer.stdlibs))),
7676
Dict(),
@@ -147,7 +147,7 @@ function create_symserver_progress_ui(server)
147147
JSONRPC.send(
148148
server.jr_endpoint,
149149
progress_notification_type,
150-
ProgressParams(token, WorkDoneProgressBegin("Julia", missing, "Starting async tasks...", 0))
150+
ProgressParams(token, WorkDoneProgressBegin("Julia", missing, "Starting async tasks...", missing))
151151
)
152152
end
153153
end
@@ -185,11 +185,11 @@ function trigger_symbolstore_reload(server::LanguageServerInstance)
185185
JSONRPC.send(
186186
server.jr_endpoint,
187187
progress_notification_type,
188-
ProgressParams(server.current_symserver_progress_token, WorkDoneProgressReport(missing, msg, percentage))
188+
ProgressParams(server.current_symserver_progress_token, WorkDoneProgressReport(missing, msg, missing))
189189
)
190-
@info msg percentage
190+
@info msg
191191
else
192-
@info msg percentage
192+
@info msg
193193
end
194194
end,
195195
server.err_handler,
@@ -261,6 +261,7 @@ function Base.run(server::LanguageServerInstance)
261261
server.status = :started
262262

263263
run(server.jr_endpoint)
264+
@debug "Connected at $(round(Int, time()))"
264265

265266
trigger_symbolstore_reload(server)
266267

@@ -310,6 +311,8 @@ function Base.run(server::LanguageServerInstance)
310311
@debug "LS: Symbol server listener task done."
311312
end
312313

314+
@debug "Symbol Server started at $(round(Int, time()))"
315+
313316
msg_dispatcher = JSONRPC.MsgDispatcher()
314317

315318
msg_dispatcher[textDocument_codeAction_request_type] = request_wrapper(textDocument_codeAction_request, server)
@@ -351,6 +354,7 @@ function Base.run(server::LanguageServerInstance)
351354
msg_dispatcher[textDocument_selectionRange_request_type] = request_wrapper(textDocument_selectionRange_request, server)
352355

353356
@debug "starting main loop"
357+
@debug "Starting event listener loop at $(round(Int, time()))"
354358
while true
355359
message = take!(server.combined_msg_queue)
356360
if message.type == :close
@@ -380,6 +384,7 @@ function Base.run(server::LanguageServerInstance)
380384
@debug "starting re-lint of everything"
381385
relintserver(server)
382386
@debug "re-lint done"
387+
@debug "Linting finished at $(round(Int, time()))"
383388
end
384389
end
385390
end

src/requests/hover.jl

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,39 +161,45 @@ end
161161

162162
get_fcall_position(x, documentation, visited=nothing) = documentation
163163

164-
function get_fcall_position(x::EXPR, documentation, visited=EXPR[])
164+
function get_fcall_position(x::EXPR, documentation, visited=Set{EXPR}())
165165
if x in visited # TODO: remove
166166
throw(LSInfiniteLoop("Possible infinite loop.")) # TODO: remove
167167
else # TODO: remove
168168
push!(visited, x) # TODO: remove
169169
end # TODO: remove
170170
if parentof(x) isa EXPR
171171
if CSTParser.iscall(parentof(x))
172-
call_counts = StaticLint.call_nargs(parentof(x))
173-
call_counts[1] < 5 && return documentation
172+
minargs, _, _ = StaticLint.call_nargs(parentof(x))
174173
arg_i = 0
175-
for (i, arg) = enumerate(parentof(x))
174+
for (i, arg) in enumerate(parentof(x))
176175
if arg == x
177176
arg_i = div(i - 1, 2)
178177
break
179178
end
180179
end
181-
arg_i == 0 && return documentation
180+
181+
# hovering over the function name, so we might as well check the parent
182+
if arg_i == 0
183+
return get_fcall_position(parentof(x), documentation, visited)
184+
end
185+
186+
minargs < 4 && return documentation
187+
182188
fname = CSTParser.get_name(parentof(x))
183189
if StaticLint.hasref(fname) &&
184-
(refof(fname) isa StaticLint.Binding && refof(fname).val isa EXPR && CSTParser.defines_struct(refof(fname).val) && StaticLint.struct_nargs(refof(fname).val)[1] == call_counts[1])
190+
(refof(fname) isa StaticLint.Binding && refof(fname).val isa EXPR && CSTParser.defines_struct(refof(fname).val) && StaticLint.struct_nargs(refof(fname).val)[1] == minargs)
185191
dt_ex = refof(fname).val
186192
args = dt_ex.args[3]
187193
args.args === nothing || arg_i > length(args.args) && return documentation
188194
_fieldname = CSTParser.str_value(CSTParser.get_arg_name(args.args[arg_i]))
189195
documentation = string("Datatype field `$_fieldname` of $(CSTParser.str_value(CSTParser.get_name(dt_ex)))", "\n", documentation)
190196
elseif StaticLint.hasref(fname) && (refof(fname) isa SymbolServer.DataTypeStore || refof(fname) isa StaticLint.Binding && refof(fname).val isa SymbolServer.DataTypeStore)
191197
dts = refof(fname) isa StaticLint.Binding ? refof(fname).val : refof(fname)
192-
if length(dts.fieldnames) == call_counts[1] && arg_i <= length(dts.fieldnames)
198+
if length(dts.fieldnames) == minargs && arg_i <= length(dts.fieldnames)
193199
documentation = string("Datatype field `$(dts.fieldnames[arg_i])`", "\n", documentation)
194200
end
195201
else
196-
documentation = string("Argument $arg_i of $(call_counts[1]) in call to `", CSTParser.str_value(fname), "`\n", documentation)
202+
documentation = string("Argument $arg_i of $(minargs) in call to `", CSTParser.str_value(fname), "`\n", documentation)
197203
end
198204
return documentation
199205
else

0 commit comments

Comments
 (0)