@@ -30,6 +30,17 @@ def main(x):
30
30
31
31
"""
32
32
33
+ DOC_IMPORTS = """from . import something
34
+ from ..module import something
35
+ from module import (a, b)
36
+
37
+ def main():
38
+ # import ignored
39
+ print("from module import x") # string with import
40
+ return something
41
+
42
+ """
43
+
33
44
34
45
def helper_check_symbols_all_scope (symbols ):
35
46
# All eight symbols (import sys, a, B, __init__, x, y, main, y)
@@ -73,6 +84,22 @@ def sym(name):
73
84
assert sym ("main" )["location" ]["range" ]["end" ] == {"line" : 12 , "character" : 0 }
74
85
75
86
87
+ def test_symbols_complex_imports (config , workspace ):
88
+ doc = Document (DOC_URI , workspace , DOC_IMPORTS )
89
+ config .update ({"plugins" : {"jedi_symbols" : {"all_scopes" : False }}})
90
+ symbols = pylsp_document_symbols (config , doc )
91
+
92
+ import_symbols = [s for s in symbols if s ["kind" ] == SymbolKind .Module ]
93
+
94
+ assert len (import_symbols ) == 4
95
+
96
+ names = [s ["name" ] for s in import_symbols ]
97
+ assert "something" in names
98
+ assert "a" in names or "b" in names
99
+
100
+ assert any (s ["name" ] == "main" and s ["kind" ] == SymbolKind .Function for s in symbols )
101
+
102
+
76
103
def test_symbols_all_scopes (config , workspace ) -> None :
77
104
doc = Document (DOC_URI , workspace , DOC )
78
105
symbols = pylsp_document_symbols (config , doc )
0 commit comments