-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: enable excluding refs search results in test #16441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6f303f4
1bd21e9
6181102
2b71aca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1055,6 +1055,7 @@ pub(crate) fn handle_references( | |
let position = from_proto::file_position(&snap, params.text_document_position)?; | ||
|
||
let exclude_imports = snap.config.find_all_refs_exclude_imports(); | ||
let exclude_tests = snap.config.find_all_refs_exclude_tests(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. exclude_tests should be pushed down as a parameter to find_all_refs. that way, a potentially more optimal implementation would be able to avoid even analyzing the test, which would be faster than filtering out results after the fact. I think the second parameter we are passing here, which is currently None, is something like a SearchScope. It exists exactly to narrow down search results, and I think could be extended to exclude tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good point, I had create an issue for this (sorry for the slow response, kind of busy recently) |
||
|
||
let refs = match snap.analysis.find_all_refs(position, None)? { | ||
None => return Ok(None), | ||
|
@@ -1078,7 +1079,8 @@ pub(crate) fn handle_references( | |
.flat_map(|(file_id, refs)| { | ||
refs.into_iter() | ||
.filter(|&(_, category)| { | ||
!exclude_imports || category != Some(ReferenceCategory::Import) | ||
(!exclude_imports || category != Some(ReferenceCategory::Import)) | ||
&& (!exclude_tests || category != Some(ReferenceCategory::Test)) | ||
}) | ||
.map(move |(range, _)| FileRange { file_id, range }) | ||
}) | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something can be a test and a read at the same time. So, the time has come to use a bitset here! This is precisely the situation the old comment just above this line talks about