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

Outline doesn't display Java Elements hierarchically #560

Closed
fbricon opened this issue Jun 12, 2018 · 3 comments
Closed

Outline doesn't display Java Elements hierarchically #560

fbricon opened this issue Jun 12, 2018 · 3 comments

Comments

@fbricon
Copy link
Collaborator

fbricon commented Jun 12, 2018

Now that vscode embeds the outline view , with the following code:

package io.swagger.v3.core.util;

/**
 * Toto
 */
public class Toto {

    /**
     * InnerToto
     */
    public interface InnerToto {
    
        public void name();
    }
}

document/documentSymbol yields:

[Info  - 14:33:47] Jun 12, 2018, 9:30:47 AM >> document/documentSymbol
[Trace - 14:33:47] Received response 'textDocument/documentSymbol - (105)' in 3ms.
Result: [
    {
        "name": "name()",
        "kind": 6,
        "location": {
            "uri": "file:///Users/fbricon/Dev/souk/swagger-core/modules/swagger-core/src/main/java/io/swagger/v3/core/util/Toto.java",
            "range": {
                "start": {
                    "line": 12,
                    "character": 20
                },
                "end": {
                    "line": 12,
                    "character": 24
                }
            }
        },
        "containerName": "InnerToto"
    },
    {
        "name": "InnerToto",
        "kind": 11,
        "location": {
            "uri": "file:///Users/fbricon/Dev/souk/swagger-core/modules/swagger-core/src/main/java/io/swagger/v3/core/util/Toto.java",
            "range": {
                "start": {
                    "line": 10,
                    "character": 21
                },
                "end": {
                    "line": 10,
                    "character": 30
                }
            }
        },
        "containerName": "Toto"
    },
    {
        "name": "Toto",
        "kind": 5,
        "location": {
            "uri": "file:///Users/fbricon/Dev/souk/swagger-core/modules/swagger-core/src/main/java/io/swagger/v3/core/util/Toto.java",
            "range": {
                "start": {
                    "line": 5,
                    "character": 13
                },
                "end": {
                    "line": 5,
                    "character": 17
                }
            }
        },
        "containerName": "Toto.java"
    }
]

Which results in a flat hierarchy:
screen shot 2018-06-12 at 2 41 26 pm

The top container name should be the Type name, to be consistent (hopefully that would be enough, but there might be some other issues with duplicate containers)

@fbricon
Copy link
Collaborator Author

fbricon commented Jun 18, 2018

After setting the container name of the root type to an empty string, and putting it in 1st position, yielding the following response:

Result: [
    {
        "name": "head",
        "kind": 8,
        "location": {
            "uri": "file:///Users/fbricon/Dev/souk/cloudee-duke/src/main/java/eu/agilejava/cloudeeduke/rest/head.java",
            "range": {
                "start": {
                    "line": 5,
                    "character": 13
                },
                "end": {
                    "line": 5,
                    "character": 17
                }
            }
        },
        "containerName": ""
    },
    {
        "name": "title",
        "kind": 8,
        "location": {
            "uri": "file:///Users/fbricon/Dev/souk/cloudee-duke/src/main/java/eu/agilejava/cloudeeduke/rest/head.java",
            "range": {
                "start": {
                    "line": 10,
                    "character": 17
                },
                "end": {
                    "line": 10,
                    "character": 22
                }
            }
        },
        "containerName": "head"
    }
]

the outline view still displays elements flatly. I compared to the output of the html server, and noticed the symbol locations covered the entire blocks. So After manually editing the response to:

Result: [
    {
        "name": "head",
        "kind": 8,
        "location": {
            "uri": "file:///Users/fbricon/Dev/souk/cloudee-duke/src/main/java/eu/agilejava/cloudeeduke/rest/head.java",
            "range": {
                "start": {
                    "line": 5,
                    "character": 13
                },
                "end": {
                    "line": 13,
                    "character": 0
                }
            }
        },
        "containerName": ""
    },
    {
        "name": "title",
        "kind": 8,
        "location": {
            "uri": "file:///Users/fbricon/Dev/souk/cloudee-duke/src/main/java/eu/agilejava/cloudeeduke/rest/head.java",
            "range": {
                "start": {
                    "line": 10,
                    "character": 17
                },
                "end": {
                    "line": 12,
                    "character": 4
                }
            }
        },
        "containerName": "head"
    }
]

it finally produced the expected hierarchical output.

@aeschli @jrieken so is the document/documentSymbol protocol actually expecting each symbol's location to cover the actual blocks, or is vscode using a hack to generate the outline view?

@jrieken
Copy link

jrieken commented Jun 18, 2018

@aeschli @jrieken so is the document/documentSymbol protocol actually expecting each symbol's location to cover the actual blocks,

We never specified what the range should cover and to properly support the outline tree new API is needed. We have just finalised that and will ship with the next release, see: microsoft/vscode#34968.

or is vscode using a hack to generate the outline view?

I wouldn't call it a hack, but there is logic to build a tree based on range containment. This works go enough for some extensions but doesn't replace the need for adoption of the new API.

@fbricon
Copy link
Collaborator Author

fbricon commented Sep 26, 2018

Closing as duplicate of #586, which has already been released

@fbricon fbricon closed this as completed Sep 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants