|
34 | 34 | from robot.parsing.model.statements import LibraryImport as RobotLibraryImport |
35 | 35 | from robot.parsing.model.statements import ResourceImport as RobotResourceImport |
36 | 36 | from robot.parsing.model.statements import VariablesImport as RobotVariablesImport |
37 | | -from robot.variables.search import is_scalar_assign, search_variable |
| 37 | +from robot.variables.search import is_scalar_assign, is_variable, search_variable |
38 | 38 | from robotcode.core.async_tools import Lock, async_event |
39 | 39 | from robotcode.core.logging import LoggingDescriptor |
40 | 40 | from robotcode.core.lsp.types import ( |
@@ -227,7 +227,7 @@ def get_variable_token(self, token: Token) -> Optional[Token]: |
227 | 227 | v |
228 | 228 | for v in itertools.dropwhile( |
229 | 229 | lambda t: t.type in Token.NON_DATA_TOKENS, |
230 | | - tokenize_variables(token, ignore_errors=True), |
| 230 | + tokenize_variables(token, ignore_errors=True, extra_types={Token.VARIABLE}), |
231 | 231 | ) |
232 | 232 | if v.type == Token.VARIABLE |
233 | 233 | ), |
@@ -360,6 +360,27 @@ def visit_ForHeader(self, node: Statement) -> None: # noqa: N802 |
360 | 360 | source=self.source, |
361 | 361 | ) |
362 | 362 |
|
| 363 | + def visit_Var(self, node: Statement) -> None: # noqa: N802 |
| 364 | + variable = node.get_token(Token.VARIABLE) |
| 365 | + if variable is None: |
| 366 | + return |
| 367 | + try: |
| 368 | + if not is_variable(variable.value): |
| 369 | + return |
| 370 | + |
| 371 | + self._results[variable.value] = LocalVariableDefinition( |
| 372 | + name=variable.value, |
| 373 | + name_token=strip_variable_token(variable), |
| 374 | + line_no=variable.lineno, |
| 375 | + col_offset=variable.col_offset, |
| 376 | + end_line_no=variable.lineno, |
| 377 | + end_col_offset=variable.end_col_offset, |
| 378 | + source=self.source, |
| 379 | + ) |
| 380 | + |
| 381 | + except VariableError: |
| 382 | + pass |
| 383 | + |
363 | 384 |
|
364 | 385 | class ImportVisitor(Visitor): |
365 | 386 | def get(self, source: str, model: ast.AST) -> List[Import]: |
|
0 commit comments