vscode-code-outline icon indicating copy to clipboard operation
vscode-code-outline copied to clipboard

regression: java symbols no longer displayed as a tree

Open fbricon opened this issue 7 years ago • 3 comments

With vscode-java/jdt.ls, a textDocument/documentSymbol call returns something like:

[Trace - 12:48:07] Received response 'textDocument/documentSymbol - (33)' in 6ms.
Result: [
    {
        "name": "main(String[])",
        "kind": 6,
        "location": {
            "uri": "file:///Users/fbricon/Desktop/Standalone.java",
            "range": {
                "start": {
                    "line": 12,
                    "character": 20
                },
                "end": {
                    "line": 12,
                    "character": 24
                }
            }
        },
        "containerName": "Standalone"
    },
    {
        "name": "Standalone",
        "kind": 5,
        "location": {
            "uri": "file:///Users/fbricon/Desktop/Standalone.java",
            "range": {
                "start": {
                    "line": 10,
                    "character": 13
                },
                "end": {
                    "line": 10,
                    "character": 23
                }
            }
        },
        "containerName": "Standalone.java"
    }
]

vscode-code-outline displays the main method at the root of the tree, same level as Standalone, instead of nesting it under Standalone. My guess is the latest algorithm gets confused by the root node having a containerName (Standalone.java) instead of a blank value. This used to work a while ago: screen shot 2017-09-08 at 11 40 18 am

fbricon avatar Nov 21 '17 17:11 fbricon

This library relies on location rather than containerName as there was no way to have it work correctly based on container names (there can be multiple objects with the same name).

patrys avatar Dec 08 '17 12:12 patrys

@patrys Patryk, what's expected format of json to get working outline tree, please? It looks like we are facing the same flat structure in our language server output...

pvanek avatar Jan 03 '18 09:01 pvanek

@patrys can you explain how the location is used to build the tree? Looking at the output for an html content, it's definitely not obvious.

fbricon avatar Jan 16 '18 13:01 fbricon