Skip to content

Take includeDeclaration into account#2427

Closed
DanielNoord wants to merge 2 commits intofacebook:mainfrom
DanielNoord:include-declaration
Closed

Take includeDeclaration into account#2427
DanielNoord wants to merge 2 commits intofacebook:mainfrom
DanielNoord:include-declaration

Conversation

@DanielNoord
Copy link
Copy Markdown
Contributor

Summary

Closes #2126

Not sure if just passing the bool around is the best, but I guess it works? 😄

The logic for references might also not be fully idiomatic. So very open to feedback and suggestions.

Test Plan

I copied test_references_cross_file_no_config from the test file as it seems to use a module that is pretty simple. From the expected test output I removed the declaration, and that test now passes.

@meta-cla meta-cla bot added the cla signed label Feb 14, 2026
@github-actions
Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Copy link
Copy Markdown
Contributor

@kinto0 kinto0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great! now we just need to let people set this

Comment thread pyrefly/lib/lsp/non_wasm/server.rs Outdated
handle,
uri,
params.text_document_position.position,
true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably need to allow this to be configured via the lsp config workspace_configuration_response

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late response. I haven't touched the configuration code before.

I think you mean to add it to so it can be set:

struct LspConfig {
/// Settings we share with the Pylance extension for backwards compatibility
/// See LspAnalysisConfig's docstring for more details
#[serde(default, deserialize_with = "deserialize_analysis")]
analysis: Option<LspAnalysisConfig>,
python_path: Option<String>,
/// Settings we've added that are specific to Pyrefly
pyrefly: Option<PyreflyClientConfig>,
}

But I'm not quite sure in which section it should be?
Or should it be in Workspace?

Happy to make the change, just don't really know where I should make it 😅

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we put it in the PyreflyClientConfig, it'll be accessible by LSP via configuration and initializationOptions. see the tip in our wiki here (we probably should make this info easier to understand and find)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kinto0 Added it, but I'm not 100% confident in the change 😅

Not sure where the config belongs to, and I think with the current change it will default to false whereas main uses true considering it doesn't even look at the argument.

Any pointers are welcome! :)

Copy link
Copy Markdown
Contributor

@kinto0 kinto0 Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, I misunderstood this part! includeDeclaration is only part of references params, so the question is what to do with rename. I think the old behavior is the only correct behavior, since renaming must include declarations otherwise the references would reference the wrong thing

@DanielNoord DanielNoord requested a review from kinto0 February 22, 2026 22:36
Copy link
Copy Markdown
Contributor

@kinto0 kinto0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approving the first commit before I suggested changes. let me try importing + resolving merge conflicts

@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync bot commented Feb 24, 2026

@kinto0 has imported this pull request. If you are a Meta employee, you can view this in D94171245.

@kinto0
Copy link
Copy Markdown
Contributor

kinto0 commented Feb 24, 2026

now that i'm looking at it more directly to resolve conflicts, I'm noticing a few other things:

  • local references still include declarations (I added tests for this + fixed it by adding the bool to local references function)
  • global references calls local references. we only need this logic in local references functionality. and we don't even have to filter, we just need to avoid explicitly adding the declaration here

i'm just fixing these up since they're quick and i've already resolved the conflicts

Copy link
Copy Markdown
Contributor

@stroxler stroxler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@DanielNoord
Copy link
Copy Markdown
Contributor Author

Thanks @kinto0

Still getting used to the codebase. Happy to see they trigger further improvements :)

@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync bot commented Feb 24, 2026

@kinto0 merged this pull request in df10434.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

includeDeclaration is not respected when enumerating references

4 participants