|
18 | 18 | from ..utils.ast import ( |
19 | 19 | Token, |
20 | 20 | is_not_variable_token, |
21 | | - range_from_node, |
22 | 21 | range_from_node_or_token, |
23 | 22 | range_from_token, |
24 | 23 | ) |
@@ -144,7 +143,12 @@ async def _analyze_keyword_call( |
144 | 143 | except BaseException as e: |
145 | 144 | self._results.append( |
146 | 145 | Diagnostic( |
147 | | - range=range_from_node(node, True), |
| 146 | + range=Range( |
| 147 | + start=range_from_token(keyword_token).start, |
| 148 | + end=range_from_token(argument_tokens[-1]).end |
| 149 | + if argument_tokens |
| 150 | + else range_from_token(keyword_token).end, |
| 151 | + ), |
148 | 152 | message=str(e), |
149 | 153 | severity=DiagnosticSeverity.ERROR, |
150 | 154 | source=DIAGNOSTICS_SOURCE_NAME, |
@@ -232,32 +236,38 @@ async def _analyse_run_keyword( |
232 | 236 |
|
233 | 237 | elif keyword_doc.is_run_keyword_if() and len(argument_tokens) > 1: |
234 | 238 |
|
235 | | - def skip_args() -> None: |
| 239 | + def skip_args() -> List[Token]: |
236 | 240 | nonlocal argument_tokens |
237 | | - |
| 241 | + result = [] |
238 | 242 | while argument_tokens: |
239 | 243 | if argument_tokens[0].value in ["ELSE", "ELSE IF"]: |
240 | 244 | break |
| 245 | + if argument_tokens: |
| 246 | + result.append(argument_tokens[0]) |
241 | 247 | argument_tokens = argument_tokens[1:] |
242 | 248 |
|
243 | | - result = ( |
244 | | - await self._analyze_keyword_call( |
245 | | - unescape(argument_tokens[1].value), |
246 | | - node, |
247 | | - argument_tokens[1], |
248 | | - argument_tokens[2:], |
249 | | - analyse_run_keywords=False, |
250 | | - ) |
251 | | - if is_not_variable_token(argument_tokens[1]) |
252 | | - else None |
253 | | - ) |
| 249 | + return result |
254 | 250 |
|
255 | | - argument_tokens = argument_tokens[2:] |
| 251 | + result = await self.finder.find_keyword(argument_tokens[1].value) |
256 | 252 |
|
257 | 253 | if result is not None and result.is_any_run_keyword(): |
| 254 | + argument_tokens = argument_tokens[2:] |
| 255 | + |
258 | 256 | argument_tokens = await self._analyse_run_keyword(result, node, argument_tokens) |
| 257 | + else: |
| 258 | + kwt = argument_tokens[1] |
| 259 | + argument_tokens = argument_tokens[2:] |
259 | 260 |
|
260 | | - skip_args() |
| 261 | + args = skip_args() |
| 262 | + |
| 263 | + if is_not_variable_token(kwt): |
| 264 | + await self._analyze_keyword_call( |
| 265 | + unescape(kwt.value), |
| 266 | + node, |
| 267 | + kwt, |
| 268 | + args, |
| 269 | + analyse_run_keywords=False, |
| 270 | + ) |
261 | 271 |
|
262 | 272 | while argument_tokens: |
263 | 273 | if argument_tokens[0].value == "ELSE" and len(argument_tokens) > 1: |
|
0 commit comments