Skip to content

Commit 4003c0f

Browse files
committed
Correct some diagnostics messages
1 parent 8bd03d2 commit 4003c0f

File tree

1 file changed

+14
-7
lines changed
  • robotcode/language_server/robotframework/diagnostics

1 file changed

+14
-7
lines changed

robotcode/language_server/robotframework/diagnostics/analyzer.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ async def visit(self, node: ast.AST) -> None:
6767

6868
self.node_stack.append(node)
6969
try:
70+
severity = (
71+
DiagnosticSeverity.HINT if isinstance(node, DocumentationOrMetadata) else DiagnosticSeverity.ERROR
72+
)
73+
74+
if isinstance(node, Statement) and isinstance(node, KeywordCall) and node.keyword:
75+
kw_doc = await self.namespace.find_keyword(node.keyword)
76+
if kw_doc is not None and kw_doc.longname in ["BuiltIn.Comment"]:
77+
severity = DiagnosticSeverity.HINT
78+
7079
if isinstance(node, HasTokens) and not isinstance(node, (TestTemplate, Template)):
7180
for token in (
7281
t
@@ -87,10 +96,8 @@ async def visit(self, node: ast.AST) -> None:
8796
if isinstance(var, VariableNotFoundDefinition):
8897
await self.append_diagnostics(
8998
range=range_from_token(var_token),
90-
message=f"Variable '{var.name}' not found",
91-
severity=DiagnosticSeverity.HINT
92-
if isinstance(node, DocumentationOrMetadata)
93-
else DiagnosticSeverity.ERROR,
99+
message=f"Variable '{var.name}' not found.",
100+
severity=severity,
94101
source=DIAGNOSTICS_SOURCE_NAME,
95102
)
96103
if (
@@ -109,7 +116,7 @@ async def visit(self, node: ast.AST) -> None:
109116
if isinstance(var, VariableNotFoundDefinition):
110117
await self.append_diagnostics(
111118
range=range_from_token(var_token),
112-
message=f"Variable '{var.name}' not found",
119+
message=f"Variable '{var.name}' not found.",
113120
severity=DiagnosticSeverity.ERROR,
114121
source=DIAGNOSTICS_SOURCE_NAME,
115122
)
@@ -141,7 +148,7 @@ async def visit(self, node: ast.AST) -> None:
141148
if isinstance(var, VariableNotFoundDefinition):
142149
await self.append_diagnostics(
143150
range=range_from_token(var_token),
144-
message=f"Variable '{var.name}' not found",
151+
message=f"Variable '{var.name}' not found.",
145152
severity=DiagnosticSeverity.ERROR,
146153
source=DIAGNOSTICS_SOURCE_NAME,
147154
)
@@ -360,7 +367,7 @@ async def _analyse_run_keyword(
360367
if t.value == "AND":
361368
await self.append_diagnostics(
362369
range=range_from_token(t),
363-
message=f"Incorrect use of {t.value}",
370+
message=f"Incorrect use of {t.value}.",
364371
severity=DiagnosticSeverity.ERROR,
365372
source=DIAGNOSTICS_SOURCE_NAME,
366373
)

0 commit comments

Comments
 (0)