Skip to content

Commit 2dd418e

Browse files
committed
Implement diagnostics without ScopedValues
1 parent ce837d9 commit 2dd418e

File tree

3 files changed

+29
-39
lines changed

3 files changed

+29
-39
lines changed

src/LanguageServer.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ import Dates
1515

1616
export LanguageServerInstance, runserver
1717

18-
@static if VERSION >= v"1.11-"
19-
using Base.ScopedValues
20-
21-
const g_operationId = ScopedValue(string(uuid4()))
22-
end
18+
const g_operationId = Ref{String}()
2319

2420
JSON.lower(uri::URI) = string(uri)
2521

src/languageserverinstance.jl

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -413,28 +413,24 @@ function Base.run(server::LanguageServerInstance; timings = [])
413413

414414
add_timer_message!(did_show_timer, timings, msg)
415415

416-
@static if VERSION>=v"1.11-"
417-
with(g_operationId => string(uuid4())) do
418-
start_time = string(Dates.unix2datetime(time()), "Z")
419-
tic = time_ns()
420-
JSONRPC.dispatch_msg(server.jr_endpoint, msg_dispatcher, msg)
421-
toc = time_ns()
422-
duration = (toc - tic) / 1e+6
416+
g_operationId[] = string(uuid4())
423417

424-
JSONRPC.send(
425-
server.jr_endpoint,
426-
telemetry_event_notification_type,
427-
Dict(
428-
"command" => "request_metric",
429-
"operationId" => g_operationId[],
430-
"name" => msg["method"],
431-
"time" => start_time,
432-
"duration" => duration)
433-
)
434-
end
435-
else
436-
JSONRPC.dispatch_msg(server.jr_endpoint, msg_dispatcher, msg)
437-
end
418+
start_time = string(Dates.unix2datetime(time()), "Z")
419+
tic = time_ns()
420+
JSONRPC.dispatch_msg(server.jr_endpoint, msg_dispatcher, msg)
421+
toc = time_ns()
422+
duration = (toc - tic) / 1e+6
423+
424+
JSONRPC.send(
425+
server.jr_endpoint,
426+
telemetry_event_notification_type,
427+
Dict(
428+
"command" => "request_metric",
429+
"operationId" => g_operationId[],
430+
"name" => msg["method"],
431+
"time" => start_time,
432+
"duration" => duration)
433+
)
438434
elseif message.type == :symservmsg
439435
@debug "Received new data from Julia Symbol Server."
440436

src/requests/textdocument.jl

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,18 @@ function measure_sub_operation(f, request_name, server)
120120
toc = time_ns()
121121
duration = (toc - tic) / 1e+6
122122

123-
@static if VERSION >= v"1.11-"
124-
JSONRPC.send(
125-
server.jr_endpoint,
126-
telemetry_event_notification_type,
127-
Dict(
128-
"command" => "request_metric",
129-
"operationId" => string(uuid4()),
130-
"operationParentId" => g_operationId[],
131-
"name" => request_name,
132-
"duration" => duration,
133-
"time" => start_time
134-
)
123+
JSONRPC.send(
124+
server.jr_endpoint,
125+
telemetry_event_notification_type,
126+
Dict(
127+
"command" => "request_metric",
128+
"operationId" => string(uuid4()),
129+
"operationParentId" => g_operationId[],
130+
"name" => request_name,
131+
"duration" => duration,
132+
"time" => start_time
135133
)
136-
end
134+
)
137135
end
138136

139137
function textDocument_didChange_notification(params::DidChangeTextDocumentParams, server::LanguageServerInstance, conn)

0 commit comments

Comments
 (0)