32
32
CompletionItem ,
33
33
CompletionItemKind ,
34
34
CompletionList ,
35
- CompletionTriggerKind ,
36
35
InsertTextFormat ,
37
36
MarkupContent ,
38
37
MarkupKind ,
@@ -262,7 +261,7 @@ async def _find_methods(self, cls: Type[Any]) -> AsyncIterator[_CompleteMethod]:
262
261
async def collect (
263
262
self , position : Position , context : Optional [CompletionContext ]
264
263
) -> Union [List [CompletionItem ], CompletionList , None ]:
265
- result_nodes = await get_nodes_at_position (self .model , position )
264
+ result_nodes = await get_nodes_at_position (self .model , position , include_end = True )
266
265
267
266
result_nodes .reverse ()
268
267
@@ -980,7 +979,7 @@ async def complete_default(
980
979
if len (nodes_at_position ) > 1 and isinstance (nodes_at_position [0 ], HasTokens ):
981
980
node = nodes_at_position [0 ]
982
981
983
- tokens_at_position = get_tokens_at_position (node , position )
982
+ tokens_at_position = get_tokens_at_position (node , position , True )
984
983
if not tokens_at_position :
985
984
return None
986
985
@@ -1051,14 +1050,6 @@ async def complete_SettingSection( # noqa: N802
1051
1050
) -> Union [List [CompletionItem ], CompletionList , None ]:
1052
1051
from robot .parsing .model .statements import SectionHeader , Statement
1053
1052
1054
- # TODO should this be configurable?
1055
- if (
1056
- context is not None
1057
- and context .trigger_kind == CompletionTriggerKind .TRIGGER_CHARACTER
1058
- and context .trigger_character in [" " , "\t " ]
1059
- ):
1060
- return None
1061
-
1062
1053
if nodes_at_position .index (node ) > 0 and not isinstance (nodes_at_position [0 ], SectionHeader ):
1063
1054
node_at_pos = nodes_at_position [0 ]
1064
1055
if (
@@ -1094,14 +1085,6 @@ async def _complete_TestCase_or_Keyword( # noqa: N802
1094
1085
from robot .parsing .lexer .tokens import Token as RobotToken
1095
1086
from robot .parsing .model .statements import KeywordName , Statement , TestCaseName
1096
1087
1097
- # TODO should this be configurable?
1098
- if (
1099
- context is not None
1100
- and context .trigger_kind == CompletionTriggerKind .TRIGGER_CHARACTER
1101
- and context .trigger_character in [" " , "\t " ]
1102
- ):
1103
- return None
1104
-
1105
1088
index = 0
1106
1089
in_assign = False
1107
1090
@@ -1262,14 +1245,6 @@ async def _complete_SuiteSetup_or_SuiteTeardown_or_TestTemplate( # noqa: N802
1262
1245
) -> Union [List [CompletionItem ], CompletionList , None ]:
1263
1246
from robot .parsing .model .statements import Statement , TestTemplate
1264
1247
1265
- # TODO should this be configurable?
1266
- if (
1267
- context is not None
1268
- and context .trigger_kind == CompletionTriggerKind .TRIGGER_CHARACTER
1269
- and context .trigger_character in [" " , "\t " ]
1270
- ):
1271
- return None
1272
-
1273
1248
statement_node = cast (Statement , node )
1274
1249
if len (statement_node .tokens ) > 1 :
1275
1250
token = cast (Token , statement_node .tokens [1 ])
@@ -1387,14 +1362,6 @@ async def complete_Setup_or_Teardown_or_Template( # noqa: N802
1387
1362
) -> Union [List [CompletionItem ], CompletionList , None ]:
1388
1363
from robot .parsing .model .statements import Statement , Template
1389
1364
1390
- # TODO should this be configurable?
1391
- if (
1392
- context is not None
1393
- and context .trigger_kind == CompletionTriggerKind .TRIGGER_CHARACTER
1394
- and context .trigger_character in [" " , "\t " ]
1395
- ):
1396
- return None
1397
-
1398
1365
statement_node = cast (Statement , node )
1399
1366
if len (statement_node .tokens ) > 2 :
1400
1367
token = cast (Token , statement_node .tokens [2 ])
@@ -1589,7 +1556,7 @@ async def complete_arguments() -> Optional[List[CompletionItem]]:
1589
1556
1590
1557
kw_node = cast (Statement , node )
1591
1558
1592
- tokens_at_position = get_tokens_at_position (kw_node , position )
1559
+ tokens_at_position = get_tokens_at_position (kw_node , position , True )
1593
1560
1594
1561
if not tokens_at_position :
1595
1562
return None
@@ -1853,7 +1820,7 @@ async def complete_arguments() -> Optional[List[CompletionItem]]:
1853
1820
1854
1821
kw_node = cast (Statement , node )
1855
1822
1856
- tokens_at_position = get_tokens_at_position (kw_node , position )
1823
+ tokens_at_position = get_tokens_at_position (kw_node , position , True )
1857
1824
1858
1825
if not tokens_at_position :
1859
1826
return None
@@ -1893,16 +1860,13 @@ async def _complete_KeywordCall_or_Fixture( # noqa: N802
1893
1860
from robot .parsing .lexer .tokens import Token as RobotToken
1894
1861
from robot .parsing .model .statements import Statement
1895
1862
1896
- # if context is None or context.trigger_kind != CompletionTriggerKind.INVOKED:
1897
- # return []
1898
-
1899
1863
kw_node = cast (Statement , node )
1900
1864
1901
1865
keyword_token = kw_node .get_token (keyword_name_token_type )
1902
1866
if keyword_token is None :
1903
1867
return None
1904
1868
1905
- tokens_at_position = get_tokens_at_position (kw_node , position )
1869
+ tokens_at_position = get_tokens_at_position (kw_node , position , include_end = True )
1906
1870
1907
1871
if not tokens_at_position :
1908
1872
return None
@@ -1912,6 +1876,9 @@ async def _complete_KeywordCall_or_Fixture( # noqa: N802
1912
1876
if token_at_position .type not in [RobotToken .ARGUMENT , RobotToken .EOL , RobotToken .SEPARATOR ]:
1913
1877
return None
1914
1878
1879
+ if len (tokens_at_position ) > 1 and tokens_at_position [- 2 ].type == RobotToken .KEYWORD :
1880
+ return None
1881
+
1915
1882
keyword_doc_and_token : Optional [Tuple [Optional [KeywordDoc ], Token ]] = None
1916
1883
1917
1884
keyword_token = kw_node .get_token (keyword_name_token_type )
@@ -2258,7 +2225,7 @@ async def _complete_ForceTags_or_KeywordTags_or_DefaultTags_Tags( # noqa: N802
2258
2225
from robot .parsing .model .statements import Statement
2259
2226
2260
2227
statement = cast (Statement , node )
2261
- tokens = get_tokens_at_position (statement , position )
2228
+ tokens = get_tokens_at_position (statement , position , True )
2262
2229
2263
2230
if not tokens :
2264
2231
return None
0 commit comments