Skip to content

Commit f23e5d0

Browse files
committed
feat: show deprecation information if using Force Tags and Default Tags
Closes #82
1 parent 483b9ac commit f23e5d0

File tree

1 file changed

+30
-1
lines changed
  • packages/language_server/src/robotcode/language_server/robotframework/diagnostics

1 file changed

+30
-1
lines changed

packages/language_server/src/robotcode/language_server/robotframework/diagnostics/analyzer.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,35 @@ async def visit_TemplateArguments(self, node: ast.AST) -> None: # noqa: N802
883883

884884
await self.generic_visit(node)
885885

886+
async def visit_ForceTags(self, node: ast.AST) -> None: # noqa: N802
887+
from robot.parsing.lexer.tokens import Token as RobotToken
888+
from robot.parsing.model.statements import ForceTags
889+
890+
if get_robot_version() >= (6, 0):
891+
tag = cast(ForceTags, node).get_token(RobotToken.FORCE_TAGS)
892+
if tag.value.upper() == "FORCE TAGS":
893+
self.append_diagnostics(
894+
range=range_from_node_or_token(node, tag),
895+
message="`Force Tags` is deprecated in favour of new `Test Tags` setting.",
896+
severity=DiagnosticSeverity.INFORMATION,
897+
tags=[DiagnosticTag.DEPRECATED],
898+
code="DeprecatedHyphenTag",
899+
)
900+
901+
async def visit_DefaultTags(self, node: ast.AST) -> None: # noqa: N802
902+
from robot.parsing.lexer.tokens import Token as RobotToken
903+
from robot.parsing.model.statements import ForceTags
904+
905+
if get_robot_version() >= (6, 0):
906+
tag = cast(ForceTags, node).get_token(RobotToken.DEFAULT_TAGS)
907+
self.append_diagnostics(
908+
range=range_from_node_or_token(node, tag),
909+
message="`Force Tags` is deprecated in favour of new `Test Tags` setting.",
910+
severity=DiagnosticSeverity.INFORMATION,
911+
tags=[DiagnosticTag.DEPRECATED],
912+
code="DeprecatedHyphenTag",
913+
)
914+
886915
async def visit_Tags(self, node: ast.AST) -> None: # noqa: N802
887916
from robot.parsing.lexer.tokens import Token as RobotToken
888917
from robot.parsing.model.statements import Tags
@@ -895,7 +924,7 @@ async def visit_Tags(self, node: ast.AST) -> None: # noqa: N802
895924
self.append_diagnostics(
896925
range=range_from_node_or_token(node, tag),
897926
message=f"Settings tags starting with a hyphen using the '[Tags]' setting "
898-
f"is deprecated. In Robot Framework 5.2 this syntax will be used "
927+
f"is deprecated. In Robot Framework 7.0 this syntax will be used "
899928
f"for removing tags. Escape '{tag.value}' like '\\{tag.value}' to use the "
900929
f"literal value and to avoid this warning.",
901930
severity=DiagnosticSeverity.WARNING,

0 commit comments

Comments
 (0)