@@ -23,10 +23,16 @@ def main(x):
23
23
24
24
def test_symbols (config ):
25
25
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
+
26
32
config .update ({'plugins' : {'jedi_symbols' : {'all_scopes' : False , 'hide_imports' : False }}})
27
33
symbols = pyls_document_symbols (config , doc )
28
34
29
- # All four symbols (import sys, a, B, main, y)
35
+ # All five symbols (import sys, a, B, main, y)
30
36
assert len (symbols ) == 5
31
37
32
38
def sym (name ):
@@ -47,6 +53,14 @@ def sym(name):
47
53
48
54
def test_symbols_all_scopes (config ):
49
55
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 }}})
50
64
symbols = pyls_document_symbols (config , doc )
51
65
52
66
# All eight symbols (import sys, a, B, __init__, x, y, main, y)
@@ -63,3 +77,33 @@ def sym(name):
63
77
64
78
# Not going to get too in-depth here else we're just testing Jedi
65
79
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