Skip to content

Commit d139ff1

Browse files
committed
fix: corrected highlightning invalid sections for RF7
1 parent 567ac72 commit d139ff1

File tree

1 file changed

+13
-1
lines changed
  • packages/language_server/src/robotcode/language_server/robotframework/parts

1 file changed

+13
-1
lines changed

packages/language_server/src/robotcode/language_server/robotframework/parts/semantic_tokens.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
)
2222

2323
from robot.parsing.lexer.tokens import Token
24+
from robot.parsing.model.blocks import Section
2425
from robot.parsing.model.statements import (
2526
Arguments,
2627
Documentation,
@@ -74,6 +75,9 @@
7475
if get_robot_version() >= (5, 0):
7576
from robot.parsing.model.statements import ExceptHeader, WhileHeader
7677

78+
if get_robot_version() >= (7, 0):
79+
from robot.parsing.model.blocks import InvalidSection
80+
7781
if TYPE_CHECKING:
7882
from ..protocol import RobotLanguageServerProtocol
7983

@@ -981,7 +985,15 @@ def _collect_internal(
981985
last_col = 0
982986

983987
def get_tokens() -> Iterator[Tuple[Token, ast.AST]]:
988+
current_section: Optional[Section] = None
989+
in_invalid_section = False
990+
984991
for node in iter_nodes(model):
992+
if cached_isinstance(node, Section):
993+
current_section = node
994+
if get_robot_version() >= (7, 0):
995+
in_invalid_section = cached_isinstance(current_section, InvalidSection)
996+
985997
check_current_task_canceled()
986998

987999
if cached_isinstance(node, Statement):
@@ -1145,7 +1157,7 @@ def get_tokens() -> Iterator[Tuple[Token, ast.AST]]:
11451157
continue
11461158

11471159
for token in node.tokens:
1148-
if token.type == Token.COMMENT:
1160+
if not in_invalid_section and token.type == Token.COMMENT:
11491161
continue
11501162
yield token, node
11511163

0 commit comments

Comments
 (0)