Skip to content

Commit 94cdc54

Browse files
committed
feat(analyzer): Improve 'keyword not found' messages for old FOR: syntax
1 parent 10d981f commit 94cdc54

File tree

59 files changed

+1338
-49
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1338
-49
lines changed

packages/robot/src/robotcode/robot/diagnostics/keyword_finder.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,25 @@ def find_keyword(
8787
try:
8888
result = self._find_keyword(name, handle_bdd_style)
8989
if result is None:
90+
error_message = "No keyword with found."
91+
92+
if name and name.strip(": ").upper() == "FOR":
93+
error_message = (
94+
f"Support for the old FOR loop syntax has been removed. "
95+
f"Replace '{name}' with 'FOR', end the loop with 'END', and "
96+
f"remove escaping backslashes."
97+
)
98+
elif name and name == "\\":
99+
error_message = (
100+
"No keyword with name '\\' found. If it is used inside a for "
101+
"loop, remove escaping backslashes and end the loop with 'END'."
102+
)
103+
else:
104+
error_message = f"No keyword with name '{name}' found."
105+
90106
self.diagnostics.append(
91107
DiagnosticsEntry(
92-
f"No keyword with name '{name}' found.",
108+
error_message,
93109
DiagnosticSeverity.ERROR,
94110
Error.KEYWORD_NOT_FOUND,
95111
)

tests/robotcode/language_server/robotframework/parts/_regtest_outputs/rf41/test_references.test[references.robot-036-004-simple_keyword_call].out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,10 @@ result:
394394
range:
395395
end:
396396
character: 7
397-
line: 80
397+
line: 81
398398
start:
399399
character: 4
400-
line: 80
400+
line: 81
401401
uri: rf73/variable_conversion.robot
402402
- !Location
403403
range:

tests/robotcode/language_server/robotframework/parts/_regtest_outputs/rf41/test_references.test[references.robot-036-005-simple_keyword_call].out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,10 @@ result:
394394
range:
395395
end:
396396
character: 7
397-
line: 80
397+
line: 81
398398
start:
399399
character: 4
400-
line: 80
400+
line: 81
401401
uri: rf73/variable_conversion.robot
402402
- !Location
403403
range:

tests/robotcode/language_server/robotframework/parts/_regtest_outputs/rf41/test_references.test[references.robot-036-006-simple_keyword_call].out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,10 @@ result:
394394
range:
395395
end:
396396
character: 7
397-
line: 80
397+
line: 81
398398
start:
399399
character: 4
400-
line: 80
400+
line: 81
401401
uri: rf73/variable_conversion.robot
402402
- !Location
403403
range:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
result: !SemanticTokens
2+
data:
3+
- 0
4+
- 0
5+
- 18
6+
- 29
7+
- 0
8+
- 1
9+
- 0
10+
- 5
11+
- 33
12+
- 1
13+
- 1
14+
- 4
15+
- 4
16+
- 39
17+
- 0
18+
- 1
19+
- 8
20+
- 1
21+
- 39
22+
- 0
23+
- 1
24+
- 8
25+
- 1
26+
- 39
27+
- 0
28+
- 2
29+
- 0
30+
- 6
31+
- 33
32+
- 1
33+
- 1
34+
- 4
35+
- 2
36+
- 35
37+
- 0
38+
- 2
39+
- 0
40+
- 5
41+
- 33
42+
- 1
43+
- 1
44+
- 4
45+
- 3
46+
- 35
47+
- 0
48+
- 0
49+
- 15
50+
- 8
51+
- 46
52+
- 0
53+
- 1
54+
- 8
55+
- 14
56+
- 39
57+
- 1024
58+
- 1
59+
- 4
60+
- 3
61+
- 35
62+
- 0
63+
result_id: null

tests/robotcode/language_server/robotframework/parts/_regtest_outputs/rf41/test_semantic_tokens.test[versions-rf73-variable_conversion.robot].out

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,21 @@ result: !SemanticTokens
342342
- 1
343343
- 1
344344
- 4
345+
- 1
346+
- 21
347+
- 256
348+
- 0
349+
- 1
350+
- 13
351+
- 25
352+
- 256
353+
- 0
354+
- 13
355+
- 1
356+
- 21
357+
- 256
358+
- 1
359+
- 4
345360
- 3
346361
- 39
347362
- 1024

tests/robotcode/language_server/robotframework/parts/_regtest_outputs/rf41/test_workspace_symbols.test[].out

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3480,6 +3480,66 @@ result:
34803480
uri: jsonvariables.robot
34813481
name: first
34823482
tags: null
3483+
- !WorkspaceSymbol
3484+
container_name: old_for
3485+
data: null
3486+
kind: 13
3487+
location:
3488+
range:
3489+
end:
3490+
character: 14
3491+
line: 10
3492+
start:
3493+
character: 13
3494+
line: 10
3495+
uri: old_for.robot
3496+
name: ${i}
3497+
tags: null
3498+
- !WorkspaceSymbol
3499+
container_name: old_for
3500+
data: null
3501+
kind: 5
3502+
location:
3503+
range:
3504+
end:
3505+
character: 5
3506+
line: 1
3507+
start:
3508+
character: 0
3509+
line: 1
3510+
uri: old_for.robot
3511+
name: first
3512+
tags: null
3513+
- !WorkspaceSymbol
3514+
container_name: old_for
3515+
data: null
3516+
kind: 5
3517+
location:
3518+
range:
3519+
end:
3520+
character: 6
3521+
line: 6
3522+
start:
3523+
character: 0
3524+
line: 6
3525+
uri: old_for.robot
3526+
name: second
3527+
tags: null
3528+
- !WorkspaceSymbol
3529+
container_name: old_for
3530+
data: null
3531+
kind: 5
3532+
location:
3533+
range:
3534+
end:
3535+
character: 5
3536+
line: 9
3537+
start:
3538+
character: 0
3539+
line: 9
3540+
uri: old_for.robot
3541+
name: third
3542+
tags: null
34833543
- !WorkspaceSymbol
34843544
container_name: part1__suite
34853545
data: null

tests/robotcode/language_server/robotframework/parts/_regtest_outputs/rf41/test_workspace_symbols.test[first].out

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,21 @@ result:
299299
uri: jsonvariables.robot
300300
name: first
301301
tags: null
302+
- !WorkspaceSymbol
303+
container_name: old_for
304+
data: null
305+
kind: 5
306+
location:
307+
range:
308+
end:
309+
character: 5
310+
line: 1
311+
start:
312+
character: 0
313+
line: 1
314+
uri: old_for.robot
315+
name: first
316+
tags: null
302317
- !WorkspaceSymbol
303318
container_name: part1__suite
304319
data: null

tests/robotcode/language_server/robotframework/parts/_regtest_outputs/rf50/test_references.test[references.robot-036-004-simple_keyword_call].out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,10 @@ result:
394394
range:
395395
end:
396396
character: 7
397-
line: 80
397+
line: 81
398398
start:
399399
character: 4
400-
line: 80
400+
line: 81
401401
uri: rf73/variable_conversion.robot
402402
- !Location
403403
range:

tests/robotcode/language_server/robotframework/parts/_regtest_outputs/rf50/test_references.test[references.robot-036-005-simple_keyword_call].out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,10 @@ result:
394394
range:
395395
end:
396396
character: 7
397-
line: 80
397+
line: 81
398398
start:
399399
character: 4
400-
line: 80
400+
line: 81
401401
uri: rf73/variable_conversion.robot
402402
- !Location
403403
range:

tests/robotcode/language_server/robotframework/parts/_regtest_outputs/rf50/test_references.test[references.robot-036-006-simple_keyword_call].out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,10 @@ result:
394394
range:
395395
end:
396396
character: 7
397-
line: 80
397+
line: 81
398398
start:
399399
character: 4
400-
line: 80
400+
line: 81
401401
uri: rf73/variable_conversion.robot
402402
- !Location
403403
range:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
result: !SemanticTokens
2+
data:
3+
- 0
4+
- 0
5+
- 18
6+
- 29
7+
- 0
8+
- 1
9+
- 0
10+
- 5
11+
- 33
12+
- 1
13+
- 1
14+
- 4
15+
- 4
16+
- 39
17+
- 0
18+
- 1
19+
- 8
20+
- 1
21+
- 39
22+
- 0
23+
- 1
24+
- 8
25+
- 1
26+
- 39
27+
- 0
28+
- 2
29+
- 0
30+
- 6
31+
- 33
32+
- 1
33+
- 1
34+
- 4
35+
- 2
36+
- 35
37+
- 0
38+
- 0
39+
- 14
40+
- 3
41+
- 39
42+
- 0
43+
- 2
44+
- 0
45+
- 5
46+
- 33
47+
- 1
48+
- 1
49+
- 4
50+
- 3
51+
- 35
52+
- 0
53+
- 0
54+
- 15
55+
- 8
56+
- 46
57+
- 0
58+
- 1
59+
- 8
60+
- 14
61+
- 39
62+
- 1024
63+
- 1
64+
- 4
65+
- 3
66+
- 35
67+
- 0
68+
result_id: null

tests/robotcode/language_server/robotframework/parts/_regtest_outputs/rf50/test_semantic_tokens.test[versions-rf73-variable_conversion.robot].out

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,21 @@ result: !SemanticTokens
357357
- 1
358358
- 1
359359
- 4
360+
- 1
361+
- 21
362+
- 256
363+
- 0
364+
- 1
365+
- 13
366+
- 25
367+
- 256
368+
- 0
369+
- 13
370+
- 1
371+
- 21
372+
- 256
373+
- 1
374+
- 4
360375
- 3
361376
- 39
362377
- 1024

0 commit comments

Comments
 (0)