Skip to content

Commit 8bd03d2

Browse files
committed
Correct handling of keyword only arguments
1 parent 70a264f commit 8bd03d2

File tree

10 files changed

+651
-615
lines changed

10 files changed

+651
-615
lines changed

CHANGELOG.md

Lines changed: 608 additions & 604 deletions
Large diffs are not rendered by default.

robotcode/language_server/robotframework/diagnostics/analyzer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ async def run(self) -> List[Diagnostic]:
5757
async def visit(self, node: ast.AST) -> None:
5858
from robot.parsing.lexer.tokens import Token as RobotToken
5959
from robot.parsing.model.statements import (
60+
Arguments,
6061
DocumentationOrMetadata,
6162
KeywordCall,
6263
Template,
@@ -72,6 +73,9 @@ async def visit(self, node: ast.AST) -> None:
7273
for t in node.tokens
7374
if t.type != RobotToken.VARIABLE and t.error is None and contains_variable(t.value, "$@&%")
7475
):
76+
if isinstance(node, Arguments) and token.value == "@{}":
77+
continue
78+
7579
async for var_token, var in self.iter_variables_from_token(
7680
token,
7781
self.namespace,

robotcode/language_server/robotframework/diagnostics/namespace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ async def visit_Arguments(self, node: ast.AST) -> None: # noqa: N802
236236
try:
237237
argument = self.get_variable_token(argument_token)
238238

239-
if argument is not None:
239+
if argument is not None and argument.value != "@{}":
240240
if (
241241
self.in_args
242242
and self.position is not None

robotcode/language_server/robotframework/parts/document_symbols.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ async def visit_Arguments(self, node: ast.AST) -> None: # noqa: N802
131131

132132
if self.current_symbol is not None and self.current_symbol.children is not None:
133133
for argument_token in (cast(RobotToken, e) for e in arguments):
134+
if argument_token.value == "@{}":
135+
continue
136+
134137
argument = self.get_variable_token(argument_token)
135138

136139
if argument is not None:

robotcode/language_server/robotframework/parts/goto.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,10 @@ async def definition_LibraryImport( # noqa: N802
510510

511511
if libdoc is None or libdoc.errors:
512512
libdoc = await namespace.imports_manager.get_libdoc_for_library_import(
513-
str(library_node.name), (), str(document.uri.to_path().parent)
513+
str(library_node.name),
514+
(),
515+
str(document.uri.to_path().parent),
516+
variables=await namespace.get_resolvable_variables(),
514517
)
515518

516519
if libdoc is None:
@@ -555,7 +558,9 @@ async def definition_ResourceImport( # noqa: N802
555558

556559
if libdoc is None or libdoc.errors:
557560
libdoc = await namespace.imports_manager.get_libdoc_for_resource_import(
558-
str(resource_node.name), str(document.uri.to_path().parent)
561+
str(resource_node.name),
562+
str(document.uri.to_path().parent),
563+
variables=await namespace.get_resolvable_variables(),
559564
)
560565

561566
if libdoc is None:
@@ -600,7 +605,10 @@ async def definition_VariablesImport( # noqa: N802
600605

601606
if libdoc is None or libdoc.errors:
602607
libdoc = await namespace.imports_manager.get_libdoc_for_variables_import(
603-
str(variables_node.name), (), str(document.uri.to_path().parent)
608+
str(variables_node.name),
609+
(),
610+
str(document.uri.to_path().parent),
611+
variables=await namespace.get_resolvable_variables(),
604612
)
605613

606614
if libdoc is None:

robotcode/language_server/robotframework/parts/hover.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,10 @@ async def hover_LibraryImport( # noqa: N802
421421

422422
if libdoc is None or libdoc.errors:
423423
libdoc = await namespace.imports_manager.get_libdoc_for_library_import(
424-
str(library_node.name), (), str(document.uri.to_path().parent)
424+
str(library_node.name),
425+
(),
426+
str(document.uri.to_path().parent),
427+
variables=await namespace.get_resolvable_variables(),
425428
)
426429

427430
if libdoc is None or libdoc.errors:
@@ -464,7 +467,9 @@ async def hover_ResourceImport( # noqa: N802
464467

465468
if libdoc is None or libdoc.errors:
466469
libdoc = await namespace.imports_manager.get_libdoc_for_resource_import(
467-
str(resource_node.name), str(document.uri.to_path().parent)
470+
str(resource_node.name),
471+
str(document.uri.to_path().parent),
472+
variables=await namespace.get_resolvable_variables(),
468473
)
469474

470475
if libdoc is None or libdoc.errors:
@@ -507,7 +512,10 @@ async def hover_VariablesImport( # noqa: N802
507512

508513
if libdoc is None or libdoc.errors:
509514
libdoc = await namespace.imports_manager.get_libdoc_for_variables_import(
510-
str(variables_node.name), (), str(document.uri.to_path().parent)
515+
str(variables_node.name),
516+
(),
517+
str(document.uri.to_path().parent),
518+
variables=await namespace.get_resolvable_variables(),
511519
)
512520

513521
if libdoc is None or libdoc.errors:

robotcode/language_server/robotframework/parts/signature_help.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,10 @@ async def signature_help_LibraryImport( # noqa: N802
241241

242242
if lib_doc is None or lib_doc.errors:
243243
lib_doc = await namespace.imports_manager.get_libdoc_for_library_import(
244-
str(library_node.name), (), str(document.uri.to_path().parent)
244+
str(library_node.name),
245+
(),
246+
str(document.uri.to_path().parent),
247+
variables=await namespace.get_resolvable_variables(),
245248
)
246249

247250
if lib_doc is None:

robotcode/utils/async_tools.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,14 +604,13 @@ async def acquire(self) -> bool:
604604
finally:
605605
async with self.__inner_lock():
606606
self._waiters.remove(fut)
607+
self._locked = True
607608
except asyncio.CancelledError:
608609
async with self.__inner_lock():
609610
if self._locked:
610611
await self._wake_up_first()
611612
raise
612613

613-
async with self.__inner_lock():
614-
self._locked = True
615614
return True
616615

617616
async def release(self) -> None:

tests/robotcode/language_server/robotframework/parts/data/.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@
3030
// "robotcode.debug.outputMessages": true
3131
//"python.analysis.diagnosticMode": "workspace"
3232
//"robotcode.robot.paths": ["./tests", "./tests1"]
33-
"robotcode.analysis.diagnosticMode": "openFilesOnly"
33+
"robotcode.analysis.diagnosticMode": "workspace"
3434
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,10 @@ check that ${a:[0-9\ ]*} plus ${b} is ${expected}
174174
templated kw
175175
[Arguments] ${a} ${b} ${expected}
176176
log ${a} ${b} ${expected}
177+
178+
a keyword with kwonly separator
179+
[Arguments] ${name} @{} ${version}=<unknown> ${scope} ${keywords} ${listener}=False
180+
No Operation
181+
182+
dummy
183+
a keyword with kwonly separator a scope=1 keywords=1

0 commit comments

Comments
 (0)