|
35 | 35 | Range,
|
36 | 36 | )
|
37 | 37 | from ...common.text_document import TextDocument
|
38 |
| -from ..utils.ast import Token, range_from_node, tokenize_variables |
| 38 | +from ..utils.ast import Token, range_from_node, range_from_token, tokenize_variables |
39 | 39 | from ..utils.async_ast import AsyncVisitor
|
40 | 40 | from .entities import (
|
41 | 41 | ArgumentDefinition,
|
@@ -203,19 +203,29 @@ async def visit_KeywordCall(self, node: ast.AST) -> None: # noqa: N802
|
203 | 203 | # TODO analyse "Set Local/Global/Suite Variable"
|
204 | 204 |
|
205 | 205 | n = cast(KeywordCall, node)
|
| 206 | + |
206 | 207 | for assign_token in n.get_tokens(RobotToken.ASSIGN):
|
207 | 208 | variable_token = self.get_variable_token(assign_token)
|
| 209 | + |
208 | 210 | try:
|
209 |
| - if variable_token is not None and variable_token.value not in self._results: |
210 |
| - self._results[variable_token.value] = LocalVariableDefinition( |
211 |
| - name=variable_token.value, |
212 |
| - name_token=variable_token, |
213 |
| - line_no=variable_token.lineno, |
214 |
| - col_offset=variable_token.col_offset, |
215 |
| - end_line_no=variable_token.lineno, |
216 |
| - end_col_offset=variable_token.end_col_offset, |
217 |
| - source=self.source, |
218 |
| - ) |
| 211 | + if variable_token is not None: |
| 212 | + if ( |
| 213 | + self.position is not None |
| 214 | + and self.position in range_from_node(n) |
| 215 | + and self.position > range_from_token(variable_token).end |
| 216 | + ): |
| 217 | + continue |
| 218 | + |
| 219 | + if variable_token.value not in self._results: |
| 220 | + self._results[variable_token.value] = LocalVariableDefinition( |
| 221 | + name=variable_token.value, |
| 222 | + name_token=variable_token, |
| 223 | + line_no=variable_token.lineno, |
| 224 | + col_offset=variable_token.col_offset, |
| 225 | + end_line_no=variable_token.lineno, |
| 226 | + end_col_offset=variable_token.end_col_offset, |
| 227 | + source=self.source, |
| 228 | + ) |
219 | 229 |
|
220 | 230 | except VariableError:
|
221 | 231 | pass
|
|
0 commit comments