Skip to content

Commit 89c8a3f

Browse files
committed
semantic highlighting of new WHILE and EXCEPT options for RF 5.0
1 parent 8f9b7c5 commit 89c8a3f

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ All notable changes to the "robotcode" extension will be documented in this file
88
- see [README](https://github.com/d-biehl/robotcode#using-pre-release-version)
99
- rework handling VSCode test items to ensure all defined tests can be executed, also when they are ambiguous
1010
- see [#37](https://github.com/d-biehl/robotcode/issues/37)
11+
- semantic highlighting of new WHILE and EXCEPT options for RF 5.0
12+
-
1113

1214

1315
## 0.7.0

robotcode/language_server/robotframework/parts/semantic_tokens.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,26 @@ async def generate_sem_sub_tokens(
366366
yield SemTokenInfo.from_token(token, sem_type, sem_mod, col_offset + kw_index, len(kw))
367367
elif token.type == RobotToken.NAME and isinstance(node, (LibraryImport, ResourceImport, VariablesImport)):
368368
yield SemTokenInfo.from_token(token, RobotSemTokenTypes.NAMESPACE, sem_mod, col_offset, length)
369+
elif get_robot_version() >= (5, 0) and token.type == RobotToken.OPTION:
370+
from robot.parsing.model.statements import ExceptHeader, WhileHeader
371+
372+
if (
373+
isinstance(node, ExceptHeader)
374+
and token.value.startswith("type=")
375+
or isinstance(node, WhileHeader)
376+
and token.value.startswith("limit=")
377+
):
378+
if col_offset is None:
379+
col_offset = token.col_offset
380+
381+
name, value = token.value.split("=", 1)
382+
yield SemTokenInfo.from_token(token, RobotSemTokenTypes.VARIABLE, sem_mod, col_offset, len(name))
383+
yield SemTokenInfo.from_token(
384+
token, SemanticTokenTypes.OPERATOR, sem_mod, col_offset + len(name), 1
385+
)
386+
yield SemTokenInfo.from_token(token, sem_type, sem_mod, col_offset + len(name) + 1, len(value))
387+
else:
388+
yield SemTokenInfo.from_token(token, sem_type, sem_mod, col_offset, length)
369389
elif (
370390
token.type in RobotToken.SETTING_TOKENS
371391
and token.value

0 commit comments

Comments
 (0)