Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Symbols returned with wrong kind. #1

Copy link
Copy link
@ericsnowcurrently

Description

@ericsnowcurrently
Issue body actions

In the VS Code Python extension we are sending a textDocument/documentSymbol request and using the result to position code lenses. The data we get back is mostly correct. However, the "kind" (i.e. VS Code's SymbolKind) is consistently off by one. For example, using the following Python code:

import unittest

class SpamTests(unittest.TestCase):
    def test_all(self):
        self.assertTrue(False)

I got the following JSON response from the language server (formatted for clarity):

[{
    "name":"SpamTests",
    "detail":"SpamTests",
    "kind":5,
    "deprecated":false,
    "range":{
        "start":{"line":2,"character":6},
        "end":{"line":2,"character":15}
    },
    "selectionRange":{
        "start":{"line":2,"character":6},
        "end":{"line":2,"character":15}
    },
    "children":[{
        "name":"test_all",
        "detail":"test_all",
        "kind":12,
        "deprecated":false,
        "range":{
            "start":{"line":3,"character":4},
            "end":{"line":4,"character":30}
         },
         "selectionRange":{
             "start":{"line":3,"character":4},
             "end":{"line":4,"character":30}
         },
         "children":[{
             "name":"self",
             "detail":"self",
             "kind":13,
             "deprecated":false,
             "range":{
                 "start":{"line":3,"character":17},
                 "end":{"line":3,"character":21}
             },
             "selectionRange":{
                 "start":{"line":3,"character":17},
                 "end":{"line":3,"character":21}
             },
            "children":[],
            "_functionKind":""
        }],
        "_functionKind":"function"
    },
    {
        "name":"assertTrue",
        "detail":"assertTrue",
        "kind":13,
        "deprecated":false,
        "range":{
            "start":{"line":0,"character":0},
            "end":{"line":0,"character":0}
        },
        "selectionRange":{
            "start":{"line":0,"character":0},
            "end":{"line":0,"character":0}
        },
        "children":[],
        "_functionKind":""
    }],
    "_functionKind":"class"
}]

Each of the "kind" fields is 1 more than it should be:

SpamTests -> 5; should be 4 (SymbolKind.Class)
test_all -> 12; should be 11 (SymbolKind.Function)
self -> 13; should be 12 (SymbolKind.Variable)
assertTrue -> 13; should be 12 (SymbolKind.Variable)

FWIW, the Jedi-related code in the Python extension gets it right.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.