-
Notifications
You must be signed in to change notification settings - Fork 92
Split Roblox-specific functionality into dedicated interface #505
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
Merged
JohnnyMorganz
merged 19 commits into
JohnnyMorganz:main
from
voidedWarranties:platform-specific-split
May 19, 2024
Merged
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
10c2a63
Split Roblox-specific functionality into dedicated interface
voidedWarranties 76e7aff
Merge branch 'main' of https://github.com/JohnnyMorganz/luau-lsp into…
JohnnyMorganz d3e5402
Fix frontend reference
JohnnyMorganz de6591f
Merge branch 'main' of https://github.com/JohnnyMorganz/luau-lsp into…
voidedWarranties 901d216
Address initial review items
voidedWarranties a5319d2
Split RobloxPlatform into multiple files
voidedWarranties fbce308
Move some WorkspaceFileResolver functions into LSPPlatform
voidedWarranties 9d762b7
Merge branch 'main' of https://github.com/JohnnyMorganz/luau-lsp into…
voidedWarranties 77526ed
Fix MSVC build
voidedWarranties aff460b
Address review items
voidedWarranties 9e72f06
Merge branch 'main' of https://github.com/JohnnyMorganz/luau-lsp into…
voidedWarranties 63fdaf9
Initial extension split
voidedWarranties 2a58485
Update extension config and config usage
voidedWarranties cfb8ba6
Merge branch 'main' of https://github.com/JohnnyMorganz/luau-lsp into…
voidedWarranties 02ecb58
Resolve some issues
voidedWarranties 7e16b8d
Merge branch 'main' of https://github.com/JohnnyMorganz/luau-lsp into…
JohnnyMorganz a60b248
Remove unused client config changes
JohnnyMorganz 6b63e9a
Simplify readSourceCode
JohnnyMorganz de52f22
Merge branch 'main' into platform-specific-split
JohnnyMorganz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,9 +12,6 @@ | |
| if (!params) \ | ||
| throw json_rpc::JsonRpcException(lsp::ErrorCode::InvalidParams, "params not provided for " method); | ||
|
|
||
| #define REQUIRED_PARAMS(params, method) \ | ||
| (!(params) ? throw json_rpc::JsonRpcException(lsp::ErrorCode::InvalidParams, "params not provided for " method) : (params).value()) | ||
|
|
||
| /// Finds the workspace which the file belongs to. | ||
| /// If no workspace is found, the file is attached to the null workspace | ||
| WorkspaceFolderPtr LanguageServer::findWorkspace(const lsp::DocumentUri& file) | ||
|
|
@@ -123,71 +120,71 @@ void LanguageServer::onRequest(const id_type& id, const std::string& method, std | |
|
|
||
| if (method == "initialize") | ||
| { | ||
| response = onInitialize(REQUIRED_PARAMS(baseParams, "initialize")); | ||
| response = onInitialize(JSON_REQUIRED_PARAMS(baseParams, "initialize")); | ||
| } | ||
| else if (method == "shutdown") | ||
| { | ||
| response = onShutdown(id); | ||
| } | ||
| else if (method == "textDocument/completion") | ||
| { | ||
| response = completion(REQUIRED_PARAMS(baseParams, "textDocument/completion")); | ||
| response = completion(JSON_REQUIRED_PARAMS(baseParams, "textDocument/completion")); | ||
| } | ||
| else if (method == "textDocument/documentLink") | ||
| { | ||
| response = documentLink(REQUIRED_PARAMS(baseParams, "textDocument/documentLink")); | ||
| response = documentLink(JSON_REQUIRED_PARAMS(baseParams, "textDocument/documentLink")); | ||
| } | ||
| else if (method == "textDocument/hover") | ||
| { | ||
| response = hover(REQUIRED_PARAMS(baseParams, "textDocument/hover")); | ||
| response = hover(JSON_REQUIRED_PARAMS(baseParams, "textDocument/hover")); | ||
| } | ||
| else if (method == "textDocument/signatureHelp") | ||
| { | ||
| response = signatureHelp(REQUIRED_PARAMS(baseParams, "textDocument/signatureHelp")); | ||
| response = signatureHelp(JSON_REQUIRED_PARAMS(baseParams, "textDocument/signatureHelp")); | ||
| } | ||
| else if (method == "textDocument/definition") | ||
| { | ||
| response = gotoDefinition(REQUIRED_PARAMS(baseParams, "textDocument/definition")); | ||
| response = gotoDefinition(JSON_REQUIRED_PARAMS(baseParams, "textDocument/definition")); | ||
| } | ||
| else if (method == "textDocument/typeDefinition") | ||
| { | ||
| response = gotoTypeDefinition(REQUIRED_PARAMS(baseParams, "textDocument/typeDefinition")); | ||
| response = gotoTypeDefinition(JSON_REQUIRED_PARAMS(baseParams, "textDocument/typeDefinition")); | ||
| } | ||
| else if (method == "textDocument/references") | ||
| { | ||
| response = references(REQUIRED_PARAMS(baseParams, "textDocument/references")); | ||
| response = references(JSON_REQUIRED_PARAMS(baseParams, "textDocument/references")); | ||
| } | ||
| else if (method == "textDocument/rename") | ||
| { | ||
| response = rename(REQUIRED_PARAMS(baseParams, "textDocument/rename")); | ||
| response = rename(JSON_REQUIRED_PARAMS(baseParams, "textDocument/rename")); | ||
| } | ||
| else if (method == "textDocument/documentSymbol") | ||
| { | ||
| response = documentSymbol(REQUIRED_PARAMS(baseParams, "textDocument/documentSymbol")); | ||
| response = documentSymbol(JSON_REQUIRED_PARAMS(baseParams, "textDocument/documentSymbol")); | ||
| } | ||
| else if (method == "textDocument/codeAction") | ||
| { | ||
| response = codeAction(REQUIRED_PARAMS(baseParams, "textDocument/codeAction")); | ||
| response = codeAction(JSON_REQUIRED_PARAMS(baseParams, "textDocument/codeAction")); | ||
| } | ||
| // else if (method == "codeAction/resolve") | ||
| // { | ||
| // response = codeActionResolve(REQUIRED_PARAMS(params, "codeAction/resolve")); | ||
| // response = codeActionResolve(JSON_REQUIRED_PARAMS(params, "codeAction/resolve")); | ||
| // } | ||
| else if (method == "textDocument/semanticTokens/full") | ||
| { | ||
| response = semanticTokens(REQUIRED_PARAMS(baseParams, "textDocument/semanticTokens/full")); | ||
| response = semanticTokens(JSON_REQUIRED_PARAMS(baseParams, "textDocument/semanticTokens/full")); | ||
| } | ||
| else if (method == "textDocument/inlayHint") | ||
| { | ||
| response = inlayHint(REQUIRED_PARAMS(baseParams, "textDocument/inlayHint")); | ||
| response = inlayHint(JSON_REQUIRED_PARAMS(baseParams, "textDocument/inlayHint")); | ||
| } | ||
| else if (method == "textDocument/documentColor") | ||
| { | ||
| response = documentColor(REQUIRED_PARAMS(baseParams, "textDocument/documentColor")); | ||
| response = documentColor(JSON_REQUIRED_PARAMS(baseParams, "textDocument/documentColor")); | ||
| } | ||
| else if (method == "textDocument/colorPresentation") | ||
| { | ||
| response = colorPresentation(REQUIRED_PARAMS(baseParams, "textDocument/colorPresentation")); | ||
| response = colorPresentation(JSON_REQUIRED_PARAMS(baseParams, "textDocument/colorPresentation")); | ||
| } | ||
| else if (method == "textDocument/prepareCallHierarchy") | ||
| { | ||
|
|
@@ -219,13 +216,13 @@ void LanguageServer::onRequest(const id_type& id, const std::string& method, std | |
| } | ||
| else if (method == "textDocument/diagnostic") | ||
| { | ||
| response = documentDiagnostic(REQUIRED_PARAMS(baseParams, "textDocument/diagnostic")); | ||
| response = documentDiagnostic(JSON_REQUIRED_PARAMS(baseParams, "textDocument/diagnostic")); | ||
| } | ||
| else if (method == "workspace/diagnostic") | ||
| { | ||
| // This request has partial request support. | ||
| // If workspaceDiagnostic returns nothing, then we don't signal a response (as data will be sent as progress notifications) | ||
| if (auto report = workspaceDiagnostic(REQUIRED_PARAMS(baseParams, "workspace/diagnostic"))) | ||
| if (auto report = workspaceDiagnostic(JSON_REQUIRED_PARAMS(baseParams, "workspace/diagnostic"))) | ||
| { | ||
| response = report; | ||
| } | ||
|
|
@@ -287,11 +284,11 @@ void LanguageServer::onNotification(const std::string& method, std::optional<jso | |
| } | ||
| else if (method == "initialized") | ||
| { | ||
| onInitialized(REQUIRED_PARAMS(params, "initialized")); | ||
| onInitialized(JSON_REQUIRED_PARAMS(params, "initialized")); | ||
| } | ||
| else if (method == "$/setTrace") | ||
| { | ||
| client->setTrace(REQUIRED_PARAMS(params, "$/setTrace")); | ||
| client->setTrace(JSON_REQUIRED_PARAMS(params, "$/setTrace")); | ||
| } | ||
| else if (method == "$/cancelRequest") | ||
| { | ||
|
|
@@ -300,42 +297,40 @@ void LanguageServer::onNotification(const std::string& method, std::optional<jso | |
| } | ||
| else if (method == "textDocument/didOpen") | ||
| { | ||
| onDidOpenTextDocument(REQUIRED_PARAMS(params, "textDocument/didOpen")); | ||
| onDidOpenTextDocument(JSON_REQUIRED_PARAMS(params, "textDocument/didOpen")); | ||
| } | ||
| else if (method == "textDocument/didChange") | ||
| { | ||
| onDidChangeTextDocument(REQUIRED_PARAMS(params, "textDocument/didChange")); | ||
| onDidChangeTextDocument(JSON_REQUIRED_PARAMS(params, "textDocument/didChange")); | ||
| } | ||
| else if (method == "textDocument/didSave") | ||
| { | ||
| // NO-OP | ||
| } | ||
| else if (method == "textDocument/didClose") | ||
| { | ||
| onDidCloseTextDocument(REQUIRED_PARAMS(params, "textDocument/didClose")); | ||
| onDidCloseTextDocument(JSON_REQUIRED_PARAMS(params, "textDocument/didClose")); | ||
| } | ||
| else if (method == "workspace/didChangeConfiguration") | ||
| { | ||
| onDidChangeConfiguration(REQUIRED_PARAMS(params, "workspace/didChangeConfiguration")); | ||
| onDidChangeConfiguration(JSON_REQUIRED_PARAMS(params, "workspace/didChangeConfiguration")); | ||
| } | ||
| else if (method == "workspace/didChangeWorkspaceFolders") | ||
| { | ||
| onDidChangeWorkspaceFolders(REQUIRED_PARAMS(params, "workspace/didChangeWorkspaceFolders")); | ||
| onDidChangeWorkspaceFolders(JSON_REQUIRED_PARAMS(params, "workspace/didChangeWorkspaceFolders")); | ||
| } | ||
| else if (method == "workspace/didChangeWatchedFiles") | ||
| { | ||
| onDidChangeWatchedFiles(REQUIRED_PARAMS(params, "workspace/didChangeWatchedFiles")); | ||
| } | ||
| else if (method == "$/plugin/full") | ||
| { | ||
| onStudioPluginFullChange(REQUIRED_PARAMS(params, "$/plugin/full")); | ||
| } | ||
| else if (method == "$/plugin/clear") | ||
| { | ||
| onStudioPluginClear(); | ||
| onDidChangeWatchedFiles(JSON_REQUIRED_PARAMS(params, "workspace/didChangeWatchedFiles")); | ||
| } | ||
| else | ||
| { | ||
| for (auto& workspace : workspaceFolders) | ||
| { | ||
| if (workspace->platform && workspace->platform->handleNotification(method, params)) | ||
| return; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if returning for the first workspace that matches is fine or if we should be sending the notification to all registered workspaces. More of a note to self, I can check this. |
||
| } | ||
|
|
||
| client->sendLogMessage(lsp::MessageType::Warning, "unknown notification method: " + method); | ||
| } | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.