Skip to content
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.

Document symbols should include imported modules #2

@ericsnowcurrently

Description

@ericsnowcurrently

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, some symbols are missing.

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"
}]

The symbol for the "unittest" module is missing.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions