10
10
from ...common .decorators import language_id
11
11
from ...common .text_document import TextDocument
12
12
from ..utils .ast_utils import Token , range_from_node , range_from_token , tokenize_variables
13
- from ..utils .async_ast import AsyncVisitor
13
+ from ..utils .async_ast import Visitor
14
14
from .protocol_part import RobotLanguageServerProtocolPart
15
15
16
16
if TYPE_CHECKING :
17
17
from ..protocol import RobotLanguageServerProtocol
18
18
19
19
20
- class _Visitor (AsyncVisitor ):
20
+ class _Visitor (Visitor ):
21
21
def __init__ (self , parent : RobotDocumentSymbolsProtocolPart ) -> None :
22
22
super ().__init__ ()
23
23
self .parent = parent
24
24
25
25
self .result : List [DocumentSymbol ] = []
26
26
self .current_symbol : Optional [DocumentSymbol ] = None
27
27
28
- async def generic_visit_current_symbol (self , node : ast .AST , symbol : DocumentSymbol ) -> None :
28
+ def generic_visit_current_symbol (self , node : ast .AST , symbol : DocumentSymbol ) -> None :
29
29
old = self .current_symbol
30
30
self .current_symbol = symbol
31
31
try :
32
- await self .generic_visit (node )
32
+ self .generic_visit (node )
33
33
finally :
34
34
self .current_symbol = old
35
35
36
36
@classmethod
37
- async def find_from (
38
- cls , model : ast .AST , parent : RobotDocumentSymbolsProtocolPart
39
- ) -> Optional [List [DocumentSymbol ]]:
37
+ def find_from (cls , model : ast .AST , parent : RobotDocumentSymbolsProtocolPart ) -> Optional [List [DocumentSymbol ]]:
40
38
finder = cls (parent )
41
39
42
- await finder .visit (model )
40
+ finder .visit (model )
43
41
44
42
return finder .result if finder .result else None
45
43
46
- async def visit_Section (self , node : ast .AST ) -> None : # noqa: N802
44
+ def visit_Section (self , node : ast .AST ) -> None : # noqa: N802
47
45
from robot .parsing .model .blocks import Section
48
46
from robot .parsing .model .statements import SectionHeader
49
47
@@ -66,9 +64,9 @@ async def visit_Section(self, node: ast.AST) -> None: # noqa: N802
66
64
67
65
self .result .append (symbol )
68
66
69
- await self .generic_visit_current_symbol (node , symbol )
67
+ self .generic_visit_current_symbol (node , symbol )
70
68
71
- async def visit_TestCase (self , node : ast .AST ) -> None : # noqa: N802
69
+ def visit_TestCase (self , node : ast .AST ) -> None : # noqa: N802
72
70
from robot .parsing .model .blocks import TestCase
73
71
74
72
testcase = cast (TestCase , node )
@@ -80,9 +78,9 @@ async def visit_TestCase(self, node: ast.AST) -> None: # noqa: N802
80
78
symbol = DocumentSymbol (name = testcase .name , kind = SymbolKind .METHOD , range = r , selection_range = r , children = [])
81
79
self .current_symbol .children .append (symbol )
82
80
83
- await self .generic_visit_current_symbol (node , symbol )
81
+ self .generic_visit_current_symbol (node , symbol )
84
82
85
- async def visit_Keyword (self , node : ast .AST ) -> None : # noqa: N802
83
+ def visit_Keyword (self , node : ast .AST ) -> None : # noqa: N802
86
84
from robot .parsing .model .blocks import Keyword
87
85
88
86
keyword = cast (Keyword , node )
@@ -96,9 +94,9 @@ async def visit_Keyword(self, node: ast.AST) -> None: # noqa: N802
96
94
)
97
95
self .current_symbol .children .append (symbol )
98
96
99
- await self .generic_visit_current_symbol (node , symbol )
97
+ self .generic_visit_current_symbol (node , symbol )
100
98
101
- async def visit_Arguments (self , node : ast .AST ) -> None : # noqa: N802
99
+ def visit_Arguments (self , node : ast .AST ) -> None : # noqa: N802
102
100
from robot .parsing .lexer .tokens import Token as RobotToken
103
101
from robot .parsing .model .statements import Arguments
104
102
@@ -134,7 +132,7 @@ def get_variable_token(self, token: Token) -> Optional[Token]:
134
132
None ,
135
133
)
136
134
137
- async def visit_KeywordCall (self , node : ast .AST ) -> None : # noqa: N802
135
+ def visit_KeywordCall (self , node : ast .AST ) -> None : # noqa: N802
138
136
from robot .errors import VariableError
139
137
from robot .parsing .lexer .tokens import Token as RobotToken
140
138
from robot .parsing .model .statements import KeywordCall
@@ -162,7 +160,7 @@ async def visit_KeywordCall(self, node: ast.AST) -> None: # noqa: N802
162
160
except VariableError :
163
161
pass
164
162
165
- async def visit_ForHeader (self , node : ast .AST ) -> None : # noqa: N802
163
+ def visit_ForHeader (self , node : ast .AST ) -> None : # noqa: N802
166
164
from robot .parsing .lexer .tokens import Token as RobotToken
167
165
from robot .parsing .model .statements import ForHeader
168
166
@@ -180,7 +178,7 @@ async def visit_ForHeader(self, node: ast.AST) -> None: # noqa: N802
180
178
if symbol .name not in map (lambda v : v .name , self .current_symbol .children ):
181
179
self .current_symbol .children .append (symbol )
182
180
183
- async def visit_KeywordName (self , node : ast .AST ) -> None : # noqa: N802
181
+ def visit_KeywordName (self , node : ast .AST ) -> None : # noqa: N802
184
182
from robot .parsing .lexer .tokens import Token as RobotToken
185
183
from robot .parsing .model .statements import KeywordName
186
184
@@ -205,7 +203,7 @@ async def visit_KeywordName(self, node: ast.AST) -> None: # noqa: N802
205
203
if symbol .name not in map (lambda v : v .name , self .current_symbol .children ):
206
204
self .current_symbol .children .append (symbol )
207
205
208
- async def visit_Variable (self , node : ast .AST ) -> None : # noqa: N802
206
+ def visit_Variable (self , node : ast .AST ) -> None : # noqa: N802
209
207
from robot .api .parsing import Token as RobotToken
210
208
from robot .parsing .model .statements import Variable
211
209
from robot .variables import search_variable
@@ -242,4 +240,4 @@ def __init__(self, parent: RobotLanguageServerProtocol) -> None:
242
240
async def collect (
243
241
self , sender : Any , document : TextDocument
244
242
) -> Optional [Union [List [DocumentSymbol ], List [SymbolInformation ], None ]]:
245
- return await _Visitor .find_from (self .parent .documents_cache .get_model (document ), self )
243
+ return _Visitor .find_from (self .parent .documents_cache .get_model (document ), self )
0 commit comments