diff --git a/src/plugins/languageclient/client.cpp b/src/plugins/languageclient/client.cpp index 48cdc0a8378..a86b043bba5 100644 --- a/src/plugins/languageclient/client.cpp +++ b/src/plugins/languageclient/client.cpp @@ -339,8 +339,6 @@ bool Client::openDocument(Core::IDocument *document) } sendContent(DidOpenTextDocumentNotification(DidOpenTextDocumentParams(item))); - if (textDocument) - requestDocumentSymbols(textDocument); return true; } @@ -495,7 +493,6 @@ void Client::documentContentsChanged(TextEditor::TextDocument *document, for (BaseTextEditor *editor : BaseTextEditor::textEditorsForDocument(textDocument)) if (TextEditorWidget *widget = editor->editorWidget()) widget->setRefactorMarkers(RefactorMarker::filterOutType(widget->refactorMarkers(), id())); - requestDocumentSymbols(textDocument); } } @@ -557,99 +554,6 @@ TextEditor::HighlightingResult createHighlightingResult(const SymbolInformation info.kind()); } -void Client::requestDocumentSymbols(TextEditor::TextDocument *document) -{ - // TODO: Do not use this information for highlighting but the overview model - return; - const FilePath &filePath = document->filePath(); - bool sendMessage = m_dynamicCapabilities.isRegistered(DocumentSymbolsRequest::methodName).value_or(false); - if (sendMessage) { - const TextDocumentRegistrationOptions option(m_dynamicCapabilities.option(DocumentSymbolsRequest::methodName)); - if (option.isValid(nullptr)) - sendMessage = option.filterApplies(filePath, Utils::mimeTypeForName(document->mimeType())); - } else { - sendMessage = m_serverCapabilities.documentSymbolProvider().value_or(false); - } - if (!sendMessage) - return; - DocumentSymbolsRequest request( - DocumentSymbolParams(TextDocumentIdentifier(DocumentUri::fromFileName(filePath)))); - request.setResponseCallback( - [doc = QPointer(document)] - (DocumentSymbolsRequest::Response response){ - if (!doc) - return; - const DocumentSymbolsResult result = response.result().value_or(DocumentSymbolsResult()); - if (!holds_alternative>(result)) - return; - const auto &symbols = get>(result); - - QFutureInterface future; - for (const SymbolInformation &symbol : symbols) - future.reportResult(createHighlightingResult(symbol)); - - const TextEditor::FontSettings &fs = doc->fontSettings(); - QHash formatMap; - formatMap[static_cast(LanguageServerProtocol::SymbolKind::File )] - = fs.toTextCharFormat(TextEditor::C_STRING); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Module )] - = fs.toTextCharFormat(TextEditor::C_STRING); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Namespace )] - = fs.toTextCharFormat(TextEditor::C_STRING); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Package )] - = fs.toTextCharFormat(TextEditor::C_STRING); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Class )] - = fs.toTextCharFormat(TextEditor::C_TYPE); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Method )] - = fs.toTextCharFormat(TextEditor::C_FUNCTION); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Property )] - = fs.toTextCharFormat(TextEditor::C_FIELD); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Field )] - = fs.toTextCharFormat(TextEditor::C_FIELD); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Constructor )] - = fs.toTextCharFormat(TextEditor::C_FUNCTION); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Enum )] - = fs.toTextCharFormat(TextEditor::C_TYPE); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Interface )] - = fs.toTextCharFormat(TextEditor::C_TYPE); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Function )] - = fs.toTextCharFormat(TextEditor::C_FUNCTION); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Variable )] - = fs.toTextCharFormat(TextEditor::C_LOCAL); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Constant )] - = fs.toTextCharFormat(TextEditor::C_LOCAL); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::String )] - = fs.toTextCharFormat(TextEditor::C_STRING); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Number )] - = fs.toTextCharFormat(TextEditor::C_NUMBER); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Boolean )] - = fs.toTextCharFormat(TextEditor::C_KEYWORD); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Array )] - = fs.toTextCharFormat(TextEditor::C_STRING); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Object )] - = fs.toTextCharFormat(TextEditor::C_LOCAL); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Key )] - = fs.toTextCharFormat(TextEditor::C_LOCAL); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Null )] - = fs.toTextCharFormat(TextEditor::C_KEYWORD); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::EnumMember )] - = fs.toTextCharFormat(TextEditor::C_ENUMERATION); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Struct )] - = fs.toTextCharFormat(TextEditor::C_TYPE); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Event )] - = fs.toTextCharFormat(TextEditor::C_STRING); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::Operator )] - = fs.toTextCharFormat(TextEditor::C_OPERATOR); - formatMap[static_cast(LanguageServerProtocol::SymbolKind::TypeParameter)] - = fs.toTextCharFormat(TextEditor::C_LOCAL); - - TextEditor::SemanticHighlighter::incrementalApplyExtraAdditionalFormats( - doc->syntaxHighlighter(), future.future(), 0, future.resultCount() - 1, - formatMap); - }); - sendContent(request); -} - void Client::cursorPositionChanged(TextEditor::TextEditorWidget *widget) { const auto uri = DocumentUri::fromFileName(widget->textDocument()->filePath()); diff --git a/src/plugins/languageclient/client.h b/src/plugins/languageclient/client.h index 3441e63b981..fc7980ae1b9 100644 --- a/src/plugins/languageclient/client.h +++ b/src/plugins/languageclient/client.h @@ -108,7 +108,6 @@ public: void unregisterCapabilities(const QList &unregistrations); bool findLinkAt(LanguageServerProtocol::GotoDefinitionRequest &request); bool findUsages(LanguageServerProtocol::FindReferencesRequest &request); - void requestDocumentSymbols(TextEditor::TextDocument *document); void cursorPositionChanged(TextEditor::TextEditorWidget *widget); void requestCodeActions(const LanguageServerProtocol::DocumentUri &uri,