@@ -30,6 +30,17 @@ def main(x):
3030
3131"""
3232
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+
3344
3445def helper_check_symbols_all_scope (symbols ):
3546 # All eight symbols (import sys, a, B, __init__, x, y, main, y)
@@ -73,6 +84,24 @@ def sym(name):
7384 assert sym ("main" )["location" ]["range" ]["end" ] == {"line" : 12 , "character" : 0 }
7485
7586
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 (
101+ s ["name" ] == "main" and s ["kind" ] == SymbolKind .Function for s in symbols
102+ )
103+
104+
76105def test_symbols_all_scopes (config , workspace ) -> None :
77106 doc = Document (DOC_URI , workspace , DOC )
78107 symbols = pylsp_document_symbols (config , doc )
0 commit comments