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

Add "type" to textDocument/references results #763

Open
sean-mcmanus opened this issue May 28, 2019 · 2 comments
Open

Add "type" to textDocument/references results #763

sean-mcmanus opened this issue May 28, 2019 · 2 comments
Labels
feature-request Request for new features or functionality references
Milestone

Comments

@sean-mcmanus
Copy link

VS Code issue (UI) is at microsoft/vscode#74237

The C/C++ extension wants to be able to send back references of different types that users can determine what "type" of reference it is and filter out unwanted types -- in order to provide functionality equivalent to Visual Studio 2019. The types we want are below. Feel free to change the naming of the example types.

  1. Confirmed reference (i.e. passes semantic checking): e.g. Type.ConfirmedReference
  2. Not a reference (i.e. has the same name, but fails semantic checking -- these non-references might be desired in some cases), e.g. e.g. Type.NotAReference
  3. Reference in a comment, e.g. e.g. Type.CommentReference
  4. Reference in a string, e.g. Type.StringReference
  5. Reference in an inactive (preprocessor) region, e.g. Type.InactiveReference (Note: Comment/String references take precedence, so this only applies to identifiers).
  6. Confirmation in progress, e.g. Type.PendingReference
  7. Cannot confirm reference (due to some bug or "by design" limitation), e.g. Type.UnknownReference

It's possible other reference types might be desirable as well for other languages or scenarios.

This is the screenshot from VS:

image

Our current "workaround" is to either send back multiple "types" merged together (ambiguously) or allow users to filter out types via a setting or a progress UI button, e.g. "show confirmed references", "show unconfirmed references" (i.e. 6 and 7).

The relevant LSP that would need to be changed is at
https://microsoft.github.io/language-server-protocol/specification#textDocument_references

@sean-mcmanus
Copy link
Author

We also want a similar "type" to be returnable with textDocument/rename to allow users to filter out the rename results by type (I could file a separate issue if you want), but we don't plan to add Rename till July:
image

@dbaeumer dbaeumer added the feature-request Request for new features or functionality label Jun 3, 2019
@dbaeumer dbaeumer added this to the On Deck milestone Jun 3, 2019
@dbaeumer dbaeumer modified the milestones: On Deck, Backlog Oct 31, 2019
@DanTup
Copy link
Contributor

DanTup commented Mar 10, 2022

I have a similar use case where there are some things that are not direct references but would be useful to include in results. For example, when using a Builder pattern:

export interface User {
	name: string; // Do find references on `name` here
}

const builder = new UserBuilder();
builder.name = "Danny"; // This is not a direct reference
const user = builder.build();

If the user does Find References on User.name they're likely looking for places that read or set that field. But since writes to it are done via a builder, none of them would show up (only the implementation in the builder that produces the User).

image

(See microsoft/vscode#144699).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality references
Projects
None yet
Development

No branches or pull requests

3 participants