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

textDocument/documentSymbol does not respect client capabilities #2633

Open
bstaletic opened this issue Aug 17, 2024 · 0 comments
Open

textDocument/documentSymbol does not respect client capabilities #2633

bstaletic opened this issue Aug 17, 2024 · 0 comments

Comments

@bstaletic
Copy link

Seems like the response to textDocument/documentSymbol is always hierarchical and that Omnisharp is not taking into account textDocument.documentSymbol.hierarchicalDocumentSymbolSupport client capability.

Here are the messages exchanged between my client and this server:

https://gist.github.com/bstaletic/e47462e95dcc4294048cd3ecefd3c9b6

And here's the same thing, but without O#, publishDiagnostics and logMessage:

2024-08-17 21:26:13,983 - DEBUG - TX: Sending message: b'Content-Length: 2101\r\n\r\n{"id":1,"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports","source.fixAll"]}},"dataSupport":true,"resolveSupport":{"properties":["edit","command"]}},"completion":{"completionItem":{"documentationFormat":["plaintext","markdown"],"resolveSupport":{"properties":["documentation","detail"]}},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"documentSymbol":{"hierarchicalDocumentSymbolSupport":false,"labelSupport":false,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"hover":{"contentFormat":["plaintext","markdown"]},"inlay_hint":{},"semanticTokens":{"augmentSyntaxTokens":true,"formats":["relative"],"requests":{"full":{"delta":false},"range":true},"tokenModifiers":[],"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","member","macro","keyword","modifier","comment","string","number","regexp","operator"]},"signatureHelp":{"signatureInformation":{"documentationFormat":["plaintext","markdown"],"parameterInformation":{"labelOffsetSupport":true}}},"synchronization":{"didSave":true}},"workspace":{"applyEdit":true,"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"workspaceEdit":{"documentChanges":true},"workspaceFolders":true}},"initializationOptions":{},"processId":13056,"rootPath":"/home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/cs/testdata/testy","rootUri":"file:///home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/cs/testdata/testy","workspaceFolders":[{"name":"testy","uri":"file:///home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/cs/testdata/testy"}]}}'
2024-08-17 21:26:21,052 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","id":1,"result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":1,"save":{"includeText":true}},"hoverProvider":{},"completionProvider":{"resolveProvider":true,"triggerCharacters":["."," "]},"signatureHelpProvider":{"triggerCharacters":["(",",","<","{","["]},"definitionProvider":{},"referencesProvider":{},"documentHighlightProvider":{},"documentSymbolProvider":{},"workspaceSymbolProvider":{},"codeActionProvider":{"codeActionKinds":["source.organizeImports","refactor","refactor.extract","refactor.inline"],"resolveProvider":true},"codeLensProvider":{"resolveProvider":true},"documentFormattingProvider":{},"documentRangeFormattingProvider":{},"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"}","moreTriggerCharacter":[";","\\n"]},"renameProvider":{},"experimental":{},"typeDefinitionProvider":{},"implementationProvider":{},"semanticTokensProvider":{"legend":{"tokenTypes":["comment","excludedCode","identifier","keyword","controlKeyword","number","operator","operatorOverloaded","macro","string","whiteSpace","text","staticSymbol","preprocessorText","punctuation","verbatimStringLiteral","stringEscapeCharacter","class","delegateName","enum","interface","moduleName","struct","typeParameter","fieldName","enumMember","constantName","variable","parameter","method","extensionMethodName","property","event","namespace","label","xmlDocCommentAttributeName","xmlDocCommentAttributeQuotes","xmlDocCommentAttributeValue","xmlDocCommentCDataSection","xmlDocCommentComment","xmlDocCommentDelimiter","xmlDocCommentEntityReference","xmlDocCommentName","xmlDocCommentProcessingInstruction","xmlDocCommentText","xmlLiteralAttributeName","xmlLiteralAttributeQuotes","xmlLiteralAttributeValue","xmlLiteralCDataSection","xmlLiteralComment","xmlLiteralDelimiter","xmlLiteralEmbeddedExpression","xmlLiteralEntityReference","xmlLiteralName","xmlLiteralProcessingInstruction","xmlLiteralText","regexComment","regexCharacterClass","regexAnchor","regexQuantifier","regexGrouping","regexAlternation","regexText","regexSelfEscapedCharacter","regexOtherEscape"],"tokenModifiers":["static"]},"range":true,"full":{}},"foldingRangeProvider":{},"inlayHintProvider":{"resolveProvider":true},"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":true},"fileOperations":{}}},"serverInfo":{"name":"OmniSharp","version":"1.39.12"}}}'
2024-08-17 21:26:21,055 - DEBUG - TX: Sending notification: b'Content-Length: 52\r\n\r\n{"jsonrpc":"2.0","method":"initialized","params":{}}'
2024-08-17 21:26:21,055 - DEBUG - TX: Sending notification: b'Content-Length: 86\r\n\r\n{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}'
2024-08-17 21:26:21,057 - DEBUG - TX: Sending notification: b'Content-Length: 409\r\n\r\n{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"cs","text":"using System;\\n\\nnamespace testy\\n{\\n\\tclass MainClass\\n\\t{\\n\\t\\tpublic static void Main (string[] args)\\n\\t\\t{\\n\\t\\t\\tint \\u4e5d = 9;\\n\\t\\t\\tConsole.\\n\\t\\t}\\n\\t}\\n}\\n","uri":"file:///home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/cs/testdata/testy/Program.cs","version":1}}}'
2024-08-17 21:26:21,162 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","id":1,"method":"client/registerCapability","params":{"registrations":[{"id":"169f6065-a2f8-4f79-9958-fb30b0fcb862","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"**/*.*","kind":7}]}}]}}'
2024-08-17 21:26:21,164 - DEBUG - TX: Sending response: b'Content-Length: 38\r\n\r\n{"id":1,"jsonrpc":"2.0","result":null}'
2024-08-17 21:26:21,165 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","id":2,"method":"client/registerCapability","params":{"registrations":[{"id":"169f6065-a2f8-4f79-9958-fb30b0fcb862","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"**/*.*","kind":7}]}}]}}'
2024-08-17 21:26:21,174 - DEBUG - TX: Sending response: b'Content-Length: 38\r\n\r\n{"id":2,"jsonrpc":"2.0","result":null}'
2024-08-17 21:26:30,425 - DEBUG - TX: Sending message: b'Content-Length: 216\r\n\r\n{"id":2,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd/ycmd/tests/cs/testdata/testy/Program.cs"}}}'
2024-08-17 21:26:30,525 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","id":2,"result":[{"name":"testy","kind":3,"range":{"start":{"line":2,"character":0},"end":{"line":12,"character":1}},"selectionRange":{"start":{"line":2,"character":10},"end":{"line":2,"character":15}},"children":[{"name":"MainClass","kind":5,"range":{"start":{"line":4,"character":1},"end":{"line":11,"character":2}},"selectionRange":{"start":{"line":4,"character":7},"end":{"line":4,"character":16}},"children":[{"name":"Main","kind":6,"range":{"start":{"line":6,"character":2},"end":{"line":10,"character":3}},"selectionRange":{"start":{"line":6,"character":21},"end":{"line":6,"character":25}},"children":[]}]}]}]}'

As you can see, the client sent "documentSymbol":{"hierarchicalDocumentSymbolSupport":false... in the initialize request.
However, omnisharp has still responded with a hierarchical document symbol:

[
  {
    "name": "testy",
    "kind": 3,
    "range": {
      "start": {
        "line": 2,
        "character": 0
      },
      "end": {
        "line": 12,
        "character": 1
      }
    },
    "selectionRange": {
      "start": {
        "line": 2,
        "character": 10
      },
      "end": {
        "line": 2,
        "character": 15
      }
    },
    "children": [
      {
        "name": "MainClass",
        "kind": 5,
        "range": {
          "start": {
            "line": 4,
            "character": 1
          },
          "end": {
            "line": 11,
            "character": 2
          }
        },
        "selectionRange": {
          "start": {
            "line": 4,
            "character": 7
          },
          "end": {
            "line": 4,
            "character": 16
          }
        },
        "children": [
          {
            "name": "Main",
            "kind": 6,
            "range": {
              "start": {
                "line": 6,
                "character": 2
              },
              "end": {
                "line": 10,
                "character": 3
              }
            },
            "selectionRange": {
              "start": {
                "line": 6,
                "character": 21
              },
              "end": {
                "line": 6,
                "character": 25
              }
            },
            "children": []
          }
        ]
      }
    ]
  }
]

Here's the link to the specification: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_documentSymbol
It says that DocumentSymbol[] is hierarchical, unlike SymbolInfo[].
As for the capability:

	/**
	 * The client supports hierarchical document symbols.
	 */
	hierarchicalDocumentSymbolSupport?: boolean;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant