diff --git a/CMakeLists.txt b/CMakeLists.txt index b35acd4a..cfabeb32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -220,32 +220,32 @@ target_sources(ccls PRIVATE target_sources(ccls PRIVATE src/messages/ccls_base.cc - src/messages/ccls_call_hierarchy.cc + src/messages/ccls_callHierarchy.cc src/messages/ccls_callers.cc - src/messages/ccls_file_info.cc - src/messages/ccls_freshen_index.cc - src/messages/ccls_inheritance_hierarchy.cc - src/messages/ccls_member_hierarchy.cc + src/messages/ccls_fileInfo.cc + src/messages/ccls_freshenIndex.cc + src/messages/ccls_inheritanceHierarchy.cc + src/messages/ccls_memberHierarchy.cc src/messages/ccls_vars.cc src/messages/exit.cc src/messages/initialize.cc src/messages/shutdown.cc - src/messages/text_document_code_lens.cc - src/messages/text_document_completion.cc - src/messages/text_document_definition.cc - src/messages/text_document_did_change.cc - src/messages/text_document_did_close.cc - src/messages/text_document_did_open.cc - src/messages/text_document_did_save.cc - src/messages/text_document_document_highlight.cc - src/messages/text_document_document_symbol.cc - src/messages/text_document_hover.cc - src/messages/text_document_implementation.cc - src/messages/text_document_references.cc - src/messages/text_document_rename.cc - src/messages/text_document_signature_help.cc - src/messages/text_document_type_definition.cc - src/messages/workspace_did_change_configuration.cc - src/messages/workspace_did_change_watched_files.cc + src/messages/textDocument_codeLens.cc + src/messages/textDocument_completion.cc + src/messages/textDocument_definition.cc + src/messages/textDocument_didChange.cc + src/messages/textDocument_didClose.cc + src/messages/textDocument_didOpen.cc + src/messages/textDocument_didSave.cc + src/messages/textDocument_documentHighlight.cc + src/messages/textDocument_documentSymbol.cc + src/messages/textDocument_hover.cc + src/messages/textDocument_implementation.cc + src/messages/textDocument_references.cc + src/messages/textDocument_rename.cc + src/messages/textDocument_signatureHelp.cc + src/messages/textDocument_typeDefinition.cc + src/messages/workspace_didChangeConfiguration.cc + src/messages/workspace_didChangeWatchedFiles.cc src/messages/workspace_symbol.cc ) diff --git a/src/messages/ccls_call_hierarchy.cc b/src/messages/ccls_callHierarchy.cc similarity index 100% rename from src/messages/ccls_call_hierarchy.cc rename to src/messages/ccls_callHierarchy.cc diff --git a/src/messages/ccls_file_info.cc b/src/messages/ccls_fileInfo.cc similarity index 100% rename from src/messages/ccls_file_info.cc rename to src/messages/ccls_fileInfo.cc diff --git a/src/messages/ccls_freshen_index.cc b/src/messages/ccls_freshenIndex.cc similarity index 100% rename from src/messages/ccls_freshen_index.cc rename to src/messages/ccls_freshenIndex.cc diff --git a/src/messages/ccls_inheritance_hierarchy.cc b/src/messages/ccls_inheritanceHierarchy.cc similarity index 100% rename from src/messages/ccls_inheritance_hierarchy.cc rename to src/messages/ccls_inheritanceHierarchy.cc diff --git a/src/messages/ccls_member_hierarchy.cc b/src/messages/ccls_memberHierarchy.cc similarity index 100% rename from src/messages/ccls_member_hierarchy.cc rename to src/messages/ccls_memberHierarchy.cc diff --git a/src/messages/text_document_code_lens.cc b/src/messages/textDocument_codeLens.cc similarity index 100% rename from src/messages/text_document_code_lens.cc rename to src/messages/textDocument_codeLens.cc diff --git a/src/messages/text_document_completion.cc b/src/messages/textDocument_completion.cc similarity index 100% rename from src/messages/text_document_completion.cc rename to src/messages/textDocument_completion.cc diff --git a/src/messages/text_document_definition.cc b/src/messages/textDocument_definition.cc similarity index 100% rename from src/messages/text_document_definition.cc rename to src/messages/textDocument_definition.cc diff --git a/src/messages/text_document_did_change.cc b/src/messages/textDocument_didChange.cc similarity index 100% rename from src/messages/text_document_did_change.cc rename to src/messages/textDocument_didChange.cc diff --git a/src/messages/text_document_did_close.cc b/src/messages/textDocument_didClose.cc similarity index 100% rename from src/messages/text_document_did_close.cc rename to src/messages/textDocument_didClose.cc diff --git a/src/messages/text_document_did_open.cc b/src/messages/textDocument_didOpen.cc similarity index 100% rename from src/messages/text_document_did_open.cc rename to src/messages/textDocument_didOpen.cc diff --git a/src/messages/text_document_did_save.cc b/src/messages/textDocument_didSave.cc similarity index 100% rename from src/messages/text_document_did_save.cc rename to src/messages/textDocument_didSave.cc diff --git a/src/messages/text_document_document_highlight.cc b/src/messages/textDocument_documentHighlight.cc similarity index 100% rename from src/messages/text_document_document_highlight.cc rename to src/messages/textDocument_documentHighlight.cc diff --git a/src/messages/text_document_document_symbol.cc b/src/messages/textDocument_documentSymbol.cc similarity index 70% rename from src/messages/text_document_document_symbol.cc rename to src/messages/textDocument_documentSymbol.cc index 450155e9..a66ffec2 100644 --- a/src/messages/text_document_document_symbol.cc +++ b/src/messages/textDocument_documentSymbol.cc @@ -20,6 +20,21 @@ struct In_TextDocumentDocumentSymbol : public RequestInMessage { MAKE_REFLECT_STRUCT(In_TextDocumentDocumentSymbol, id, params); REGISTER_IN_MESSAGE(In_TextDocumentDocumentSymbol); +struct lsSimpleLocation { + lsRange range; +}; +MAKE_REFLECT_STRUCT(lsSimpleLocation, range); +struct lsSimpleSymbolInformation { + lsSimpleLocation location; +}; +MAKE_REFLECT_STRUCT(lsSimpleSymbolInformation, location); +struct Out_SimpleDocumentSymbol + : public lsOutMessage { + lsRequestId id; + std::vector result; +}; +MAKE_REFLECT_STRUCT(Out_SimpleDocumentSymbol, jsonrpc, id, result); + struct Out_TextDocumentDocumentSymbol : public lsOutMessage { lsRequestId id; @@ -32,8 +47,6 @@ struct Handler_TextDocumentDocumentSymbol MethodType GetMethodType() const override { return kMethodType; } void Run(In_TextDocumentDocumentSymbol* request) override { auto& params = request->params; - Out_TextDocumentDocumentSymbol out; - out.id = request->id; QueryFile* file; int file_id; @@ -42,17 +55,17 @@ struct Handler_TextDocumentDocumentSymbol return; if (params.all) { + Out_SimpleDocumentSymbol out; + out.id = request->id; for (SymbolRef sym : file->def->all_symbols) - if (std::optional info = - GetSymbolInfo(db, working_files, sym, false)) { - if (std::optional location = GetLsLocation( - db, working_files, - Use{{sym.range, sym.usr, sym.kind, sym.role}, file_id})) { - info->location = *location; - out.result.push_back(*info); - } - } + if (std::optional location = GetLsLocation( + db, working_files, + Use{{sym.range, sym.usr, sym.kind, sym.role}, file_id})) + out.result.push_back({{location->range}}); + pipeline::WriteStdout(kMethodType, out); } else { + Out_TextDocumentDocumentSymbol out; + out.id = request->id; for (SymbolRef sym : file->def->outline) if (std::optional info = GetSymbolInfo(db, working_files, sym, false)) { @@ -69,9 +82,8 @@ struct Handler_TextDocumentDocumentSymbol out.result.push_back(*info); } } + pipeline::WriteStdout(kMethodType, out); } - - pipeline::WriteStdout(kMethodType, out); } }; REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDocumentSymbol); diff --git a/src/messages/text_document_hover.cc b/src/messages/textDocument_hover.cc similarity index 100% rename from src/messages/text_document_hover.cc rename to src/messages/textDocument_hover.cc diff --git a/src/messages/text_document_implementation.cc b/src/messages/textDocument_implementation.cc similarity index 100% rename from src/messages/text_document_implementation.cc rename to src/messages/textDocument_implementation.cc diff --git a/src/messages/text_document_references.cc b/src/messages/textDocument_references.cc similarity index 100% rename from src/messages/text_document_references.cc rename to src/messages/textDocument_references.cc diff --git a/src/messages/text_document_rename.cc b/src/messages/textDocument_rename.cc similarity index 100% rename from src/messages/text_document_rename.cc rename to src/messages/textDocument_rename.cc diff --git a/src/messages/text_document_signature_help.cc b/src/messages/textDocument_signatureHelp.cc similarity index 100% rename from src/messages/text_document_signature_help.cc rename to src/messages/textDocument_signatureHelp.cc diff --git a/src/messages/text_document_type_definition.cc b/src/messages/textDocument_typeDefinition.cc similarity index 100% rename from src/messages/text_document_type_definition.cc rename to src/messages/textDocument_typeDefinition.cc diff --git a/src/messages/workspace_did_change_configuration.cc b/src/messages/workspace_didChangeConfiguration.cc similarity index 100% rename from src/messages/workspace_did_change_configuration.cc rename to src/messages/workspace_didChangeConfiguration.cc diff --git a/src/messages/workspace_did_change_watched_files.cc b/src/messages/workspace_didChangeWatchedFiles.cc similarity index 100% rename from src/messages/workspace_did_change_watched_files.cc rename to src/messages/workspace_didChangeWatchedFiles.cc diff --git a/src/messages/workspace_execute_command.cc b/src/messages/workspace_executeCommand.cc similarity index 100% rename from src/messages/workspace_execute_command.cc rename to src/messages/workspace_executeCommand.cc