Skip to content

Commit 78fc0ea

Browse files
committed
correct handling of NONE in templates/fixtures
1 parent e03564f commit 78fc0ea

File tree

11 files changed

+97
-59
lines changed

11 files changed

+97
-59
lines changed

robotcode/language_server/robotframework/diagnostics/analyzer.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,11 @@ async def visit_TestTemplate(self, node: ast.AST) -> None: # noqa: N802
389389

390390
# TODO: calculate possible variables in NAME
391391

392-
if keyword_token is not None and is_not_variable_token(keyword_token):
392+
if (
393+
keyword_token is not None
394+
and is_not_variable_token(keyword_token)
395+
and keyword_token.value.upper() not in ("", "NONE")
396+
):
393397
await self._analyze_keyword_call(value.value, value, keyword_token, [])
394398

395399
self.test_template = value
@@ -404,7 +408,11 @@ async def visit_Template(self, node: ast.AST) -> None: # noqa: N802
404408

405409
# TODO: calculate possible variables in NAME
406410

407-
if keyword_token is not None and is_not_variable_token(keyword_token):
411+
if (
412+
keyword_token is not None
413+
and is_not_variable_token(keyword_token)
414+
and keyword_token.value.upper() not in ("", "NONE")
415+
):
408416
await self._analyze_keyword_call(value.value, value, keyword_token, [])
409417

410418
await self.generic_visit(node)

robotcode/language_server/robotframework/parts/completion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ async def complete_Fixture( # noqa: N802
17481748
from robot.parsing.model.statements import Fixture
17491749

17501750
name_token = cast(Fixture, node).get_token(RobotToken.NAME)
1751-
if name_token is None or name_token.value is None or name_token.value in ("", "NONE"):
1751+
if name_token is None or name_token.value is None or name_token.value.upper() in ("", "NONE"):
17521752
return None
17531753

17541754
return await self._complete_KeywordCall_or_Fixture(RobotToken.NAME, node, nodes_at_position, position, context)

robotcode/language_server/robotframework/parts/document_highlight.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ async def highlight_Fixture( # noqa: N802
257257
fixture_node = cast(Fixture, node)
258258

259259
name_token = cast(Token, fixture_node.get_token(RobotToken.NAME))
260-
if name_token is None or name_token.value is None or name_token.value in ("", "NONE"):
260+
if name_token is None or name_token.value is None or name_token.value.upper() in ("", "NONE"):
261261
return None
262262

263263
result = await self.get_keyworddoc_and_token_from_position(
@@ -312,7 +312,7 @@ async def _highlight_Template_or_TestTemplate( # noqa: N802
312312
if template_node.value:
313313

314314
keyword_token = cast(RobotToken, template_node.get_token(RobotToken.NAME))
315-
if keyword_token is None:
315+
if keyword_token is None or keyword_token.value is None or keyword_token.value.upper() in ("", "NONE"):
316316
return None
317317

318318
keyword_token = self.strip_bdd_prefix(keyword_token)

robotcode/language_server/robotframework/parts/goto.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ async def definition_Fixture( # noqa: N802
348348
fixture_node = cast(Fixture, node)
349349

350350
name_token = cast(Token, fixture_node.get_token(RobotToken.NAME))
351-
if name_token is None or name_token.value is None or name_token.value in ("", "NONE"):
351+
if name_token is None or name_token.value is None or name_token.value.upper() in ("", "NONE"):
352352
return None
353353

354354
result = await self.get_keyworddoc_and_token_from_position(
@@ -421,7 +421,7 @@ async def _definition_Template_or_TestTemplate( # noqa: N802
421421
if template_node.value:
422422

423423
keyword_token = cast(RobotToken, template_node.get_token(RobotToken.NAME))
424-
if keyword_token is None:
424+
if keyword_token is None or keyword_token.value is None or keyword_token.value.upper() in ("", "NONE"):
425425
return None
426426

427427
keyword_token = self.strip_bdd_prefix(keyword_token)

robotcode/language_server/robotframework/parts/hover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ async def hover_Fixture( # noqa: N802
302302
fixture_node = cast(Fixture, node)
303303

304304
name_token = cast(Token, fixture_node.get_token(RobotToken.NAME))
305-
if name_token is None or name_token.value is None or name_token.value in ("", "NONE"):
305+
if name_token is None or name_token.value is None or name_token.value.upper() in ("", "NONE"):
306306
return None
307307

308308
result = await self.get_keyworddoc_and_token_from_position(

robotcode/language_server/robotframework/parts/references.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ async def references_Fixture( # noqa: N802
398398
fixture_node = cast(Fixture, node)
399399

400400
name_token = cast(Token, fixture_node.get_token(RobotToken.NAME))
401-
if name_token is None or name_token.value is None or name_token.value in ("", "NONE"):
401+
if name_token is None or name_token.value is None or name_token.value.upper() in ("", "NONE"):
402402
return None
403403

404404
result = await self.get_keyworddoc_and_token_from_position(
@@ -448,7 +448,7 @@ async def _references_Template_or_TestTemplate( # noqa: N802
448448
if node.value:
449449

450450
keyword_token = cast(RobotToken, node.get_token(RobotToken.NAME, RobotToken.ARGUMENT))
451-
if keyword_token is None:
451+
if keyword_token is None or keyword_token.value is None or keyword_token.value.upper() in ("", "NONE"):
452452
return None
453453

454454
keyword_token = self.strip_bdd_prefix(keyword_token)

robotcode/language_server/robotframework/parts/signature_help.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ async def signature_help_Fixture( # noqa: N802
204204
from robot.parsing.model.statements import Fixture
205205

206206
name_token = cast(Fixture, node).get_token(RobotToken.NAME)
207-
if name_token is None or name_token.value is None or name_token.value in ("", "NONE"):
207+
if name_token is None or name_token.value is None or name_token.value.upper() in ("", "NONE"):
208208
return None
209209

210210
return await self._signature_help_KeywordCall_or_Fixture(RobotToken.NAME, node, document, position, context)

tests/robotcode/language_server/robotframework/parts/data/tests/templates.robot

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ second
1616
3 5 6 2
1717
a=1 2 4
1818

19+
third
20+
[Template] NONE
21+
Log hello
1922

2023
*** Keywords ***
2124
suite template keyword

tests/robotcode/language_server/robotframework/parts/test_references/test_references_robot_034_004_simple_keyword_call_.yml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -970,73 +970,82 @@ result:
970970
range:
971971
end:
972972
character: 7
973-
line: 22
973+
line: 20
974974
start:
975975
character: 4
976-
line: 22
976+
line: 20
977977
uri: tests/templates.robot
978978
- !Location
979979
range:
980980
end:
981981
character: 7
982-
line: 23
982+
line: 25
983983
start:
984984
character: 4
985-
line: 23
985+
line: 25
986986
uri: tests/templates.robot
987987
- !Location
988988
range:
989989
end:
990990
character: 7
991-
line: 24
991+
line: 26
992992
start:
993993
character: 4
994-
line: 24
994+
line: 26
995995
uri: tests/templates.robot
996996
- !Location
997997
range:
998998
end:
999999
character: 7
1000-
line: 25
1000+
line: 27
10011001
start:
10021002
character: 4
1003-
line: 25
1003+
line: 27
10041004
uri: tests/templates.robot
10051005
- !Location
10061006
range:
10071007
end:
10081008
character: 7
1009-
line: 29
1009+
line: 28
10101010
start:
10111011
character: 4
1012-
line: 29
1012+
line: 28
10131013
uri: tests/templates.robot
10141014
- !Location
10151015
range:
10161016
end:
10171017
character: 7
1018-
line: 30
1018+
line: 32
10191019
start:
10201020
character: 4
1021-
line: 30
1021+
line: 32
10221022
uri: tests/templates.robot
10231023
- !Location
10241024
range:
10251025
end:
10261026
character: 7
1027-
line: 31
1027+
line: 33
10281028
start:
10291029
character: 4
1030-
line: 31
1030+
line: 33
10311031
uri: tests/templates.robot
10321032
- !Location
10331033
range:
10341034
end:
10351035
character: 7
1036-
line: 32
1036+
line: 34
10371037
start:
10381038
character: 4
1039-
line: 32
1039+
line: 34
1040+
uri: tests/templates.robot
1041+
- !Location
1042+
range:
1043+
end:
1044+
character: 7
1045+
line: 35
1046+
start:
1047+
character: 4
1048+
line: 35
10401049
uri: tests/templates.robot
10411050
- !Location
10421051
range:

tests/robotcode/language_server/robotframework/parts/test_references/test_references_robot_034_005_simple_keyword_call_.yml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -970,73 +970,82 @@ result:
970970
range:
971971
end:
972972
character: 7
973-
line: 22
973+
line: 20
974974
start:
975975
character: 4
976-
line: 22
976+
line: 20
977977
uri: tests/templates.robot
978978
- !Location
979979
range:
980980
end:
981981
character: 7
982-
line: 23
982+
line: 25
983983
start:
984984
character: 4
985-
line: 23
985+
line: 25
986986
uri: tests/templates.robot
987987
- !Location
988988
range:
989989
end:
990990
character: 7
991-
line: 24
991+
line: 26
992992
start:
993993
character: 4
994-
line: 24
994+
line: 26
995995
uri: tests/templates.robot
996996
- !Location
997997
range:
998998
end:
999999
character: 7
1000-
line: 25
1000+
line: 27
10011001
start:
10021002
character: 4
1003-
line: 25
1003+
line: 27
10041004
uri: tests/templates.robot
10051005
- !Location
10061006
range:
10071007
end:
10081008
character: 7
1009-
line: 29
1009+
line: 28
10101010
start:
10111011
character: 4
1012-
line: 29
1012+
line: 28
10131013
uri: tests/templates.robot
10141014
- !Location
10151015
range:
10161016
end:
10171017
character: 7
1018-
line: 30
1018+
line: 32
10191019
start:
10201020
character: 4
1021-
line: 30
1021+
line: 32
10221022
uri: tests/templates.robot
10231023
- !Location
10241024
range:
10251025
end:
10261026
character: 7
1027-
line: 31
1027+
line: 33
10281028
start:
10291029
character: 4
1030-
line: 31
1030+
line: 33
10311031
uri: tests/templates.robot
10321032
- !Location
10331033
range:
10341034
end:
10351035
character: 7
1036-
line: 32
1036+
line: 34
10371037
start:
10381038
character: 4
1039-
line: 32
1039+
line: 34
1040+
uri: tests/templates.robot
1041+
- !Location
1042+
range:
1043+
end:
1044+
character: 7
1045+
line: 35
1046+
start:
1047+
character: 4
1048+
line: 35
10401049
uri: tests/templates.robot
10411050
- !Location
10421051
range:

0 commit comments

Comments
 (0)