@@ -1850,13 +1850,6 @@ async def complete_arguments() -> Optional[List[CompletionItem]]:
1850
1850
):
1851
1851
return None
1852
1852
1853
- with_name_token = next ((v for v in import_node .tokens if v .value == "WITH NAME" ), None )
1854
- if with_name_token is not None and position >= range_from_token (with_name_token ).start :
1855
- return None
1856
-
1857
- if context is None or context .trigger_kind != CompletionTriggerKind .INVOKED :
1858
- return []
1859
-
1860
1853
kw_node = cast (Statement , node )
1861
1854
1862
1855
tokens_at_position = get_tokens_at_position (kw_node , position )
@@ -1866,87 +1859,27 @@ async def complete_arguments() -> Optional[List[CompletionItem]]:
1866
1859
1867
1860
token_at_position = tokens_at_position [- 1 ]
1868
1861
1869
- if token_at_position .type not in [RobotToken .ARGUMENT , RobotToken .EOL , RobotToken .SEPARATOR ]:
1870
- return None
1871
-
1872
- if (
1873
- token_at_position .type == RobotToken .EOL
1874
- and len (tokens_at_position ) > 1
1875
- and tokens_at_position [- 2 ].type == RobotToken .KEYWORD
1876
- ):
1877
- return None
1878
-
1879
- token_at_position_index = kw_node .tokens .index (token_at_position )
1880
-
1881
- argument_token_index = token_at_position_index
1882
- while argument_token_index >= 0 and kw_node .tokens [argument_token_index ].type != RobotToken .ARGUMENT :
1883
- argument_token_index -= 1
1884
-
1885
- argument_token : Optional [RobotToken ] = None
1886
- if argument_token_index >= 0 :
1887
- argument_token = kw_node .tokens [argument_token_index ]
1888
-
1889
- completion_range = range_from_token (argument_token or token_at_position )
1890
- completion_range .end = range_from_token (token_at_position ).end
1891
- if (w := whitespace_at_begin_of_token (token_at_position )) > 0 :
1892
- if w > 1 and range_from_token (token_at_position ).start .character + 1 < position .character :
1893
- completion_range .start = position
1894
- elif completion_range .start != position :
1895
- return None
1896
- else :
1897
- if "=" in (argument_token or token_at_position ).value :
1898
- equal_index = (argument_token or token_at_position ).value .index ("=" )
1899
- if completion_range .start .character + equal_index < position .character :
1900
- return None
1901
-
1902
- completion_range .end .character = completion_range .start .character + equal_index + 1
1903
- else :
1904
- completion_range .end = position
1905
-
1906
1862
try :
1907
1863
libdoc = await self .namespace .get_imported_variables_libdoc (import_node .name , import_node .args )
1864
+ if libdoc is not None :
1865
+ init = next ((v for v in libdoc .inits .values ()), None )
1866
+ if init :
1867
+ return self ._complete_keyword_arguments_at_position (
1868
+ init , kw_node .tokens , token_at_position , position
1869
+ )
1908
1870
1909
1871
except (SystemExit , KeyboardInterrupt , asyncio .CancelledError ):
1910
1872
raise
1911
1873
except BaseException as e :
1912
1874
self ._logger .exception (e )
1913
- return None
1914
-
1915
- if libdoc is not None :
1916
- init = next ((v for v in libdoc .inits .values ()), None )
1917
-
1918
- if init :
1919
- return [
1920
- CompletionItem (
1921
- label = f"{ e .name } =" ,
1922
- kind = CompletionItemKind .VARIABLE ,
1923
- sort_text = f"010{ i } _{ e .name } " ,
1924
- filter_text = e .name ,
1925
- insert_text_format = InsertTextFormat .PLAIN_TEXT ,
1926
- text_edit = TextEdit (range = completion_range , new_text = f"{ e .name } =" ),
1927
- data = CompletionItemData (
1928
- document_uri = str (self .document .uri ),
1929
- type = "Argument" ,
1930
- name = e .name ,
1931
- ),
1932
- )
1933
- for i , e in enumerate (init .arguments )
1934
- if e .kind
1935
- not in [
1936
- KeywordArgumentKind .VAR_POSITIONAL ,
1937
- KeywordArgumentKind .VAR_NAMED ,
1938
- KeywordArgumentKind .NAMED_ONLY_MARKER ,
1939
- KeywordArgumentKind .POSITIONAL_ONLY_MARKER ,
1940
- ]
1941
- ]
1942
1875
1943
1876
return None
1944
1877
1945
1878
result = await complete_import () or []
1946
1879
# TODO this is not supported in robotframework, but it would be nice to have
1947
- # result.extend(await complete_arguments() or [])
1880
+ result .extend (await complete_arguments () or [])
1948
1881
1949
- return result # noqa: RET504
1882
+ return result
1950
1883
1951
1884
async def _complete_KeywordCall_or_Fixture ( # noqa: N802
1952
1885
self ,
0 commit comments