Skip to content

Commit

Permalink
dont use interpreter for references
Browse files Browse the repository at this point in the history
  • Loading branch information
seeM committed Jan 28, 2025
1 parent 0edf174 commit 77cf8cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,18 @@ def positron_hover(
def positron_references(
server: PositronJediLanguageServer, params: TextDocumentPositionParams
) -> Optional[List[Location]]:
return references(server, params)
document = server.workspace.get_text_document(params.text_document.uri)
# TODO: Don't use an Interpreter until we debug the corresponding test on Python <= 3.9.
# Not missing out on much since references don't use namespace information anyway.
jedi_script = Script(code=document.source, path=document.path, project=server.project)
jedi_lines = jedi_utils.line_column(params.position)
names = jedi_script.get_references(*jedi_lines)
locations = [
location
for location in (jedi_utils.lsp_location(name) for name in names)
if location is not None
]
return locations if locations else None


@POSITRON.feature(TEXT_DOCUMENT_DOCUMENT_SYMBOL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -822,13 +822,6 @@ def test_positron_hover(source: str, namespace: Dict[str, Any], expected_fullnam
Location(TEST_DOCUMENT_URI, Range(Position(0, 0), Position(0, 4))),
],
id="from_namespace",
marks=pytest.mark.skipif(
sys.version_info <= (3, 9),
reason=(
"Fails due to a missing Parso cache entry. "
"Probably not worth debugging at this point."
),
),
),
],
)
Expand Down

0 comments on commit 77cf8cb

Please sign in to comment.