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

Allow extensions to report "additional"/groups of references via ReferenceProvider #144699

Closed
DanTup opened this issue Mar 8, 2022 · 3 comments
Closed
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) editor-symbols definitions, declarations, references

Comments

@DanTup
Copy link
Contributor

DanTup commented Mar 8, 2022

Find References/ReferenceProvider can return multiple results, but they all appear in a flat list and are treated equally. In some cases, a language server might want to return some additional references that are of interest, but are not strictly references to what was requested.

For example, let's say you have code using a Builder pattern. The Builder may be code-gen'd and in a different file:

// user_builder.generated.ts
export class UserBuilder {
	private readonly _user: User = {
		name: "",
	};

	public set name(name: string) {
		this._user.name = name;
	}

	build(): User {
		return this._user;
	}
}

Code that defines the User class and uses the builder may look like this:

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 name in the User interface, it will not include the setting of builder.name near the end, because it's not a direct reference. However, in this case it's possible the user would be very interested in this reference because if they're doing Find References on name, they might be looking for all places that set names for Users.

It would be nice if a language server/extension could provide additional references like this, that are visually separated in the UI, for example:

Screenshot 2022-03-08 at 17 57 00

Note: Although I've used TypeScript as an example here for familiarity, I'm not necessarily asking for TypeScript to support the scenario above, I'm interested in VS Code having the API for other extensions/language servers to be able to use where they might have this sort of data.

@jrieken jrieken added the editor-symbols definitions, declarations, references label Mar 9, 2022
@jrieken
Copy link
Member

jrieken commented Mar 9, 2022

folding this issue into #74237

@jrieken jrieken closed this as completed Mar 9, 2022
@jrieken jrieken added the *duplicate Issue identified as a duplicate of another issue(s) label Mar 9, 2022
@jrieken
Copy link
Member

jrieken commented Mar 9, 2022

This is a duplicate. Unfortunately, I don't recall the exact issue number nor its title 😳 Anyways, searching for issues with the same labels will likely help you 👉
https://github.com/microsoft/vscode/issues?utf8=✓&q=is%3Aopen+label%3A"editor-symbols"

@DanTup
Copy link
Contributor Author

DanTup commented Mar 9, 2022

Do you mean a different issue to #74237 you linked above, or that one? That does seem the same to me (sorry I missed it while searching... the GH search isn't amazing 🙃). Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) editor-symbols definitions, declarations, references
Projects
None yet
Development

No branches or pull requests

2 participants