@@ -23,10 +23,16 @@ def main(x):
2323
2424def test_symbols (config ):
2525 doc = Document (DOC_URI , DOC )
26+ config .update ({'plugins' : {'jedi_symbols' : {'all_scopes' : False , 'hide_imports' : True }}})
27+ symbols = pyls_document_symbols (config , doc )
28+
29+ # Only local symbols (a, B, main, y)
30+ assert len (symbols ) == 4
31+
2632 config .update ({'plugins' : {'jedi_symbols' : {'all_scopes' : False , 'hide_imports' : False }}})
2733 symbols = pyls_document_symbols (config , doc )
2834
29- # All four symbols (import sys, a, B, main, y)
35+ # All five symbols (import sys, a, B, main, y)
3036 assert len (symbols ) == 5
3137
3238 def sym (name ):
@@ -47,6 +53,14 @@ def sym(name):
4753
4854def test_symbols_all_scopes (config ):
4955 doc = Document (DOC_URI , DOC )
56+
57+ config .update ({'plugins' : {'jedi_symbols' : {'all_scopes' : True , 'hide_imports' : True }}})
58+ symbols = pyls_document_symbols (config , doc )
59+
60+ # Only local symbols (a, B, __init__, x, y, main, y)
61+ assert len (symbols ) == 7
62+
63+ config .update ({'plugins' : {'jedi_symbols' : {'all_scopes' : True , 'hide_imports' : False }}})
5064 symbols = pyls_document_symbols (config , doc )
5165
5266 # All eight symbols (import sys, a, B, __init__, x, y, main, y)
@@ -63,3 +77,33 @@ def sym(name):
6377
6478 # Not going to get too in-depth here else we're just testing Jedi
6579 assert sym ('a' )['location' ]['range' ]['start' ] == {'line' : 2 , 'character' : 0 }
80+
81+ def test_symbols_hierarchical (config ):
82+ doc = Document (DOC_URI , DOC )
83+
84+ config .update ({'plugins' : {'jedi_symbols' : {'hierarchical_symbols' : True , 'hide_imports' : True }}})
85+ symbols = pyls_document_symbols (config , doc )
86+
87+ # Only local symbols (a, B, main, y)
88+ assert len (symbols ) == 4
89+
90+ config .update ({'plugins' : {'jedi_symbols' : {'hierarchical_symbols' : True , 'hide_imports' : False }}})
91+ symbols = pyls_document_symbols (config , doc )
92+
93+ # All five symbols (import sys, a, B, main, y)
94+ assert len (symbols ) == 5
95+
96+ def sym (name ):
97+ return [s for s in symbols if s ['name' ] == name ][0 ]
98+ def child_sym (sym , name ):
99+ if not sym ['children' ]:
100+ return None
101+ return [s for s in sym ['children' ] if s ['name' ] == name ][0 ]
102+
103+ # Check we have some sane mappings to VSCode constants
104+ assert sym ('a' )['kind' ] == SymbolKind .Variable
105+ assert sym ('B' )['kind' ] == SymbolKind .Class
106+ assert len (sym ('B' )['children' ]) == 1
107+ assert child_sym (sym ('B' ), '__init__' )['kind' ] == SymbolKind .Function
108+ assert child_sym (sym ('B' ), '__init__' )['detail' ] == 'B.__init__'
109+ assert sym ('main' )['kind' ] == SymbolKind .Function
0 commit comments