Skip to content

includeDeclaration is no longer respected in textDocument/references #439

@krassowski

Description

@krassowski

From manual debugging it seems that includeDeclaration gets handled correctly here:

def m_text_document__references(
self, textDocument=None, position=None, context=None, **_kwargs
):
exclude_declaration = not context["includeDeclaration"]
return self.references(textDocument["uri"], position, exclude_declaration)

and here:

def references(self, doc_uri, position, exclude_declaration):
return flatten(
self._hook(
"pylsp_references",
doc_uri,
position=position,
exclude_declaration=exclude_declaration,
)
)

but when it is passed to pylsp_references here:

@hookimpl
def pylsp_references(document, position, exclude_declaration=False):
code_position = _utils.position_to_jedi_linecolumn(document, position)
usages = document.jedi_script().get_references(**code_position)
if exclude_declaration:
# Filter out if the usage is the actual declaration of the thing
usages = [d for d in usages if not d.is_definition()]

the default value is always used. It looks like the pluggy weirdness with it failing to pass arguments correctly. Reproduced in 1.8.0 with pluggy 1.2.0 and 1.3.0 on Python 3.11.

Removing the default value (exclude_declaration=Falseexclude_declaration) fixes the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions