Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use static dispatch #1318

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
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
98 changes: 49 additions & 49 deletions src/languageserverinstance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,53 @@
end
end

JSONRPC.@message_dispatcher dispatch_msg begin
textDocument_codeAction_request_type => (conn, params, server) -> textDocument_codeAction_request(params, server, conn)
workspace_executeCommand_request_type => (conn, params, server) -> workspace_executeCommand_request(params, server, conn)

Check warning on line 290 in src/languageserverinstance.jl

View check run for this annotation

Codecov / codecov/patch

src/languageserverinstance.jl#L290

Added line #L290 was not covered by tests
textDocument_completion_request_type => (conn, params, server) -> textDocument_completion_request(params, server, conn)
textDocument_signatureHelp_request_type => (conn, params, server) -> textDocument_signatureHelp_request(params, server, conn)
textDocument_definition_request_type => (conn, params, server) -> textDocument_definition_request(params, server, conn)
textDocument_formatting_request_type => (conn, params, server) -> textDocument_formatting_request(params, server, conn)
textDocument_range_formatting_request_type => (conn, params, server) -> textDocument_range_formatting_request(params, server, conn)
textDocument_references_request_type => (conn, params, server) -> textDocument_references_request(params, server, conn)
textDocument_rename_request_type => (conn, params, server) -> textDocument_rename_request(params, server, conn)
textDocument_prepareRename_request_type => (conn, params, server) -> textDocument_prepareRename_request(params, server, conn)

Check warning on line 298 in src/languageserverinstance.jl

View check run for this annotation

Codecov / codecov/patch

src/languageserverinstance.jl#L296-L298

Added lines #L296 - L298 were not covered by tests
textDocument_documentSymbol_request_type => (conn, params, server) -> textDocument_documentSymbol_request(params, server, conn)
textDocument_documentHighlight_request_type => (conn, params, server) -> textDocument_documentHighlight_request(params, server, conn)

Check warning on line 300 in src/languageserverinstance.jl

View check run for this annotation

Codecov / codecov/patch

src/languageserverinstance.jl#L300

Added line #L300 was not covered by tests
julia_getModuleAt_request_type => (conn, params, server) -> julia_getModuleAt_request(params, server, conn)
julia_getDocAt_request_type => (conn, params, server) -> julia_getDocAt_request(params, server, conn)

Check warning on line 302 in src/languageserverinstance.jl

View check run for this annotation

Codecov / codecov/patch

src/languageserverinstance.jl#L302

Added line #L302 was not covered by tests
textDocument_hover_request_type => (conn, params, server) -> textDocument_hover_request(params, server, conn)
initialize_request_type => (conn, params, server) -> initialize_request(params, server, conn)

Check warning on line 304 in src/languageserverinstance.jl

View check run for this annotation

Codecov / codecov/patch

src/languageserverinstance.jl#L304

Added line #L304 was not covered by tests
initialized_notification_type => (conn, params, server) -> initialized_notification(params, server, conn)
shutdown_request_type => (conn, params, server) -> shutdown_request(params, server, conn)
cancel_notification_type => (conn, params, server) -> cancel_notification(params, server, conn)
setTrace_notification_type => (conn, params, server) -> setTrace_notification(params, server, conn)
setTraceNotification_notification_type => (conn, params, server) -> setTraceNotification_notification(params, server, conn)
julia_getCurrentBlockRange_request_type => (conn, params, server) -> julia_getCurrentBlockRange_request(params, server, conn)
julia_activateenvironment_notification_type => (conn, params, server) -> julia_activateenvironment_notification(params, server, conn)
textDocument_didOpen_notification_type => (conn, params, server) -> textDocument_didOpen_notification(params, server, conn)
textDocument_didClose_notification_type => (conn, params, server) -> textDocument_didClose_notification(params, server, conn)
textDocument_didSave_notification_type => (conn, params, server) -> textDocument_didSave_notification(params, server, conn)
textDocument_willSave_notification_type => (conn, params, server) -> textDocument_willSave_notification(params, server, conn)
textDocument_willSaveWaitUntil_request_type => (conn, params, server) -> textDocument_willSaveWaitUntil_request(params, server, conn)
textDocument_didChange_notification_type => (conn, params, server) -> textDocument_didChange_notification(params, server, conn)
workspace_didChangeWatchedFiles_notification_type => (conn, params, server) -> workspace_didChangeWatchedFiles_notification(params, server, conn)
workspace_didChangeConfiguration_notification_type => (conn, params, server) -> workspace_didChangeConfiguration_notification(params, server, conn)
workspace_didChangeWorkspaceFolders_notification_type => (conn, params, server) -> workspace_didChangeWorkspaceFolders_notification(params, server, conn)
workspace_symbol_request_type => (conn, params, server) -> workspace_symbol_request(params, server, conn)
julia_refreshLanguageServer_notification_type => (conn, params, server) -> julia_refreshLanguageServer_notification(params, server, conn)
julia_getDocFromWord_request_type => (conn, params, server) -> julia_getDocFromWord_request(params, server, conn)
textDocument_selectionRange_request_type => (conn, params, server) -> textDocument_selectionRange_request(params, server, conn)

Check warning on line 324 in src/languageserverinstance.jl

View check run for this annotation

Codecov / codecov/patch

src/languageserverinstance.jl#L310-L324

Added lines #L310 - L324 were not covered by tests
textDocument_documentLink_request_type => (conn, params, server) -> textDocument_documentLink_request(params, server, conn)
textDocument_inlayHint_request_type => (conn, params, server) -> textDocument_inlayHint_request(params, server, conn)
julia_get_test_env_request_type => (conn, params, server) -> julia_get_test_env_request(params, server, conn)

# The exit notification message should not be wrapped in request_wrapper (which checks
# if the server have been requested to be shut down). Instead, this message needs to be
# handled directly.
exit_notification_type => (conn, params, server) -> exit_notification(params, server, conn)
end

Check warning on line 334 in src/languageserverinstance.jl

View check run for this annotation

Codecov / codecov/patch

src/languageserverinstance.jl#L326-L334

Added lines #L326 - L334 were not covered by tests
"""
run(server::LanguageServerInstance)

Expand Down Expand Up @@ -350,54 +397,7 @@
end
yield()

@debug "async tasks started at $(round(Int, time()))"

msg_dispatcher = JSONRPC.MsgDispatcher()

msg_dispatcher[textDocument_codeAction_request_type] = request_wrapper(textDocument_codeAction_request, server)
msg_dispatcher[workspace_executeCommand_request_type] = request_wrapper(workspace_executeCommand_request, server)
msg_dispatcher[textDocument_completion_request_type] = request_wrapper(textDocument_completion_request, server)
msg_dispatcher[textDocument_signatureHelp_request_type] = request_wrapper(textDocument_signatureHelp_request, server)
msg_dispatcher[textDocument_definition_request_type] = request_wrapper(textDocument_definition_request, server)
msg_dispatcher[textDocument_formatting_request_type] = request_wrapper(textDocument_formatting_request, server)
msg_dispatcher[textDocument_range_formatting_request_type] = request_wrapper(textDocument_range_formatting_request, server)
msg_dispatcher[textDocument_references_request_type] = request_wrapper(textDocument_references_request, server)
msg_dispatcher[textDocument_rename_request_type] = request_wrapper(textDocument_rename_request, server)
msg_dispatcher[textDocument_prepareRename_request_type] = request_wrapper(textDocument_prepareRename_request, server)
msg_dispatcher[textDocument_documentSymbol_request_type] = request_wrapper(textDocument_documentSymbol_request, server)
msg_dispatcher[textDocument_documentHighlight_request_type] = request_wrapper(textDocument_documentHighlight_request, server)
msg_dispatcher[julia_getModuleAt_request_type] = request_wrapper(julia_getModuleAt_request, server)
msg_dispatcher[julia_getDocAt_request_type] = request_wrapper(julia_getDocAt_request, server)
msg_dispatcher[textDocument_hover_request_type] = request_wrapper(textDocument_hover_request, server)
msg_dispatcher[initialize_request_type] = request_wrapper(initialize_request, server)
msg_dispatcher[initialized_notification_type] = request_wrapper(initialized_notification, server)
msg_dispatcher[shutdown_request_type] = request_wrapper(shutdown_request, server)
msg_dispatcher[cancel_notification_type] = request_wrapper(cancel_notification, server)
msg_dispatcher[setTrace_notification_type] = request_wrapper(setTrace_notification, server)
msg_dispatcher[setTraceNotification_notification_type] = request_wrapper(setTraceNotification_notification, server)
msg_dispatcher[julia_getCurrentBlockRange_request_type] = request_wrapper(julia_getCurrentBlockRange_request, server)
msg_dispatcher[julia_activateenvironment_notification_type] = request_wrapper(julia_activateenvironment_notification, server)
msg_dispatcher[textDocument_didOpen_notification_type] = request_wrapper(textDocument_didOpen_notification, server)
msg_dispatcher[textDocument_didClose_notification_type] = request_wrapper(textDocument_didClose_notification, server)
msg_dispatcher[textDocument_didSave_notification_type] = request_wrapper(textDocument_didSave_notification, server)
msg_dispatcher[textDocument_willSave_notification_type] = request_wrapper(textDocument_willSave_notification, server)
msg_dispatcher[textDocument_willSaveWaitUntil_request_type] = request_wrapper(textDocument_willSaveWaitUntil_request, server)
msg_dispatcher[textDocument_didChange_notification_type] = request_wrapper(textDocument_didChange_notification, server)
msg_dispatcher[workspace_didChangeWatchedFiles_notification_type] = request_wrapper(workspace_didChangeWatchedFiles_notification, server)
msg_dispatcher[workspace_didChangeConfiguration_notification_type] = request_wrapper(workspace_didChangeConfiguration_notification, server)
msg_dispatcher[workspace_didChangeWorkspaceFolders_notification_type] = request_wrapper(workspace_didChangeWorkspaceFolders_notification, server)
msg_dispatcher[workspace_symbol_request_type] = request_wrapper(workspace_symbol_request, server)
msg_dispatcher[julia_refreshLanguageServer_notification_type] = request_wrapper(julia_refreshLanguageServer_notification, server)
msg_dispatcher[julia_getDocFromWord_request_type] = request_wrapper(julia_getDocFromWord_request, server)
msg_dispatcher[textDocument_selectionRange_request_type] = request_wrapper(textDocument_selectionRange_request, server)
msg_dispatcher[textDocument_documentLink_request_type] = request_wrapper(textDocument_documentLink_request, server)
msg_dispatcher[textDocument_inlayHint_request_type] = request_wrapper(textDocument_inlayHint_request, server)
msg_dispatcher[julia_get_test_env_request_type] = request_wrapper(julia_get_test_env_request, server)

# The exit notification message should not be wrapped in request_wrapper (which checks
# if the server have been requested to be shut down). Instead, this message needs to be
# handled directly.
msg_dispatcher[exit_notification_type] = (conn, params) -> exit_notification(params, server, conn)
@debug "async tasks started at $(round(Int, time()))"

@debug "Starting event listener loop at $(round(Int, time()))"
add_timer_message!(did_show_timer, timings, "starting combined listener")
Expand All @@ -417,7 +417,7 @@

start_time = string(Dates.unix2datetime(time()), "Z")
tic = time_ns()
JSONRPC.dispatch_msg(server.jr_endpoint, msg_dispatcher, msg)
dispatch_msg(server.jr_endpoint, msg, server)
toc = time_ns()
duration = (toc - tic) / 1e+6

Expand Down
Loading