Skip to content
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

[symbols-view] Allow project-wide symbol searches to consider multiple providers #1133

Conversation

savetheclocktower
Copy link
Contributor

Fixes #1117.

Identify the Bug

Described in #1117. You should be able to get project-wide symbol search results no matter which sort of file is open in your active editor. For instance, you should be able to get JavaScript results even if you're currently editing a package.json file.

Description of the Change

We usually pick a single winner among providers (unless they mark themselves as “non-exclusive” so that they can supplement the result set) in an effort to reduce duplication of effort. When we ask providers for project-wide results, though, we won't enforce exclusivity; there are lots of polyglot projects and we're interested in all possible results.

This removes the artificial narrowing of the result set on our end. But half of this needs to be done in the providers. For instance, pulsar-ide-typescript should sometimes consider metadata about the active editor, but sometimes shouldn't. If the metadata indicates that we're trying to resolve a “go to declaration” command, then it should decline to act as a provider unless the user is in a TS or JS file; but if we're doing project-wide symbol search, then the active editor is far less relevant, and it should be willing to contribute TS/JS symbols to the full result set along with other providers.

I'll be making this change in @savetheclocktower/atom-languageclient so that IDE provider packages do the right thing out of the box.

Alternate Designs

This is the only solution that works here; even some other design would've needed us to explicitly remove this constraint on the symbol result set.

Possible Drawbacks

We're lucky that neither of the built-in providers is able to resolve project-wide symbol searches, or else this change could potentially introduce lots more noise to the result set. It's rare, but possible, that the user would have two different IDE packages installed that are able to supply symbol information for the same language — and if both are active, then both will end up in the result set.

The workaround for the user would theoretically be to configure one of those packages not to try to provide symbols; this may or may not be present in that package's settings, but we could handle these situations when they occur in real life instead of just existing as theoreticals.

Verification Process

Specs should pass.

Release Notes

  • [symbols-view] Allow project-wide symbol search to consider results from more than one provider.

…multiple providers instead of enforcing exclusivity.
@savetheclocktower
Copy link
Contributor Author

savetheclocktower commented Nov 11, 2024

Once again, the one failing editor test is the known-flaky one, so I won't make a machine in a data center do any unnecessary work.

This is the corresponding fix on the @savetheclocktower/atom-languageclient side, but it's not yet released. Putting out a new version and explicitly bumping it on all my IDE packages is on my to-do list.

Copy link
Member

@DeeDeeG DeeDeeG left a comment

Choose a reason for hiding this comment

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

I wish I were more deeply familiar with providers and symbols, of course.

But at a quick look, the updated JavaScript logic in packages/symbols-view/lib/provider-broker.js looks sound and like it would activate under the intended scenario based on whether the param {enforceExclusivity: true/false} has been passed, and furthermore will safely default to true as intended if said param is unset when calling select().

I tested equivalent syntax in Node REPL to confirm.

And this PR has added specs, which is always appreciated. (Can confirm this PR's one test failure is indeed the known issue affecting multiple unrelated PR's, so not this PR's fault.)

I leave the desirability of the change to those who know more about symbols and providers of same, but I note a 👍 reaction from a community member on the corresponding issue, who has been fairly engaged in Pulsar things, so I can only hope that means this is moving in the correct direction.

I'm comfortable enough with this moving forward in that the code looks likely to behave as intended and seemingly has support from at least two people and no dissents yet. At this rate, good enough!

Having explained myself possibly at too much length, here is my approving review. 👍

@DeeDeeG
Copy link
Member

DeeDeeG commented Nov 20, 2024

Merging now! Thanks.

@DeeDeeG DeeDeeG merged commit c6b4fdb into pulsar-edit:master Nov 20, 2024
102 of 103 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[symbols-view] Should handle project-wide symbol search better with multiple provider candidates
2 participants