Skip to content

Commit 96997af

Browse files
committed
find reference include declaration if kw is library kw
1 parent 6db83ac commit 96997af

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

robotcode/language_server/robotframework/diagnostics/imports_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,7 @@ def _create_handler(self, kw: Any) -> Any:
883883
source=kw[0].source,
884884
line_no=kw[0].lineno,
885885
libname=libdoc.name,
886+
libtype=libdoc.type,
886887
is_embedded=is_embedded_keyword(kw[0].name),
887888
errors=getattr(kw[1], "errors") if hasattr(kw[1], "errors") else None,
888889
is_error_handler=isinstance(kw[1], UserErrorHandler),

robotcode/language_server/robotframework/diagnostics/library_doc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ class KeywordDoc:
294294
end_line_no: int = -1
295295
type: str = "keyword"
296296
libname: Optional[str] = None
297+
libtype: Optional[str] = None
297298
longname: Optional[str] = None
298299
is_embedded: bool = False
299300
errors: Optional[List[Error]] = None
@@ -1221,6 +1222,7 @@ def get_test_library(
12211222
# libname=kw[1].libname,
12221223
# longname=kw[1].longname,
12231224
libname=libdoc.name,
1225+
libtype=libdoc.type,
12241226
longname=f"{libdoc.name}.{kw[0].name}",
12251227
doc_format=str(lib.doc_format) or DEFAULT_DOC_FORMAT,
12261228
is_initializer=True,
@@ -1258,6 +1260,7 @@ def get_test_library(
12581260
source=kw[0].source,
12591261
line_no=kw[0].lineno,
12601262
libname=libdoc.name,
1263+
libtype=libdoc.type,
12611264
longname=f"{libdoc.name}.{kw[0].name}",
12621265
is_embedded=is_embedded_keyword(kw[0].name),
12631266
doc_format=str(lib.doc_format) or DEFAULT_DOC_FORMAT,

robotcode/language_server/robotframework/parts/references.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -735,9 +735,16 @@ async def find_keyword_references(
735735
or await namespace.get_library_doc()
736736
)
737737

738-
return await self._find_references(
739-
document, self.find_keyword_references_in_file, kw_doc, lib_doc, include_declaration
740-
)
738+
return [
739+
*(
740+
[Location(str(Uri.from_path(kw_doc.source)), kw_doc.range)]
741+
if include_declaration and kw_doc.libtype == "LIBRARY" and kw_doc.source
742+
else []
743+
),
744+
*await self._find_references(
745+
document, self.find_keyword_references_in_file, kw_doc, lib_doc, include_declaration
746+
),
747+
]
741748

742749
@_logger.call
743750
async def _find_library_import_references_in_file(

robotcode/language_server/robotframework/parts/robot_workspace.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ async def get_or_open_document(
4848

4949
@_logger.call
5050
async def _on_initialized(self, sender: Any) -> None:
51-
self.parent.workspace.did_change_configuration.add(self._on_change_configuration)
51+
# self.parent.workspace.did_change_configuration.add(self._on_change_configuration)
52+
pass
5253

5354
@_logger.call
5455
@threaded()

0 commit comments

Comments
 (0)