Skip to content

Commit 8d8f4aa

Browse files
committed
Mark using reserved keywords like "Break", "While",... as errors
1 parent aab5c7d commit 8d8f4aa

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ All notable changes to the "robotcode" extension will be documented in this file
77
- Add `dryRun` property to launch configuration
88
- Add "Dry Run" and "Dry Debug" profile to test explorer
99
- You can select it via Run/Debug dropdown or Right Click on the "green arrow" before the test case/suite or in test explorer and then "Execute Using Profile"
10+
- Mark using reserved keywords like "Break", "While",... as errors
1011

1112
## 0.6.0
1213

robotcode/language_server/robotframework/diagnostics/analyzer.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,13 @@ async def _analyze_keyword_call(
177177
severity=DiagnosticSeverity.ERROR,
178178
source=DIAGNOSTICS_SOURCE_NAME,
179179
)
180+
if result.is_reserved():
181+
await self.append_diagnostics(
182+
range=range_from_node_or_token(node, self.strip_bdd_prefix(keyword_token)),
183+
message=f"'{result.name}' is a reserved keyword.",
184+
severity=DiagnosticSeverity.ERROR,
185+
source=DIAGNOSTICS_SOURCE_NAME,
186+
)
180187

181188
if not isinstance(node, (Template, TestTemplate)):
182189
try:

robotcode/language_server/robotframework/diagnostics/library_doc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,9 @@ def signature(self) -> str:
421421
def parameter_signature(self) -> str:
422422
return f"({', '.join(str(a) for a in self.args)})"
423423

424+
def is_reserved(self) -> bool:
425+
return self.libname == RESERVED_LIBRARY_NAME
426+
424427
def is_any_run_keyword(self) -> bool:
425428
return self.libname == BUILTIN_LIBRARY_NAME and self.name in ALL_RUN_KEYWORDS
426429

0 commit comments

Comments
 (0)