-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Support 'find references' on most declaration-related keywords #36490
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
Conversation
|
I've moved the logic out of checker and into services in a |
|
@sheetalkamat do you have any further feedback? |
This seems needlessly inconsistent. I don’t like this as it means if I delete X from the second import, the behavior of Find References suddenly changes. Either both cases should find refs for |
|
@fatcerberus that's an interesting point. @DanielRosenwasser do you have any preference here? |
|
I think it's often nice to have something just do the only possible successful action. We can change this later if people do find it confusing. |
|
I'll create a PR for this change shortly. |
|
I've put up a PR with the following changes:
|
This change lets "find references" requests to the server find references to a declaration when the cursor is on certain keywords:
public,private,protected,static,readonly,abstract,declare,export, andconst(enums)) will find references to the declaration they modify.class,interface,type(type aliases),enum,module,namespace,function,get(get accessors), andset(set accessors)) will find references to the declaration they declare.extends,implements) in aclass/interfacedeclaration will find references to the type in the heritage clause, as long as that clause has only one type (as more than one type would be ambiguous).const,let,var) will find references to the variable declared if declaration list contains a single declaration.importimport "module"will find references tomoduleimport X from "module"will find references toX(if there are no named bindings)import * as X from "module"will find references toXimport { X } from "module"will find references toX(if there is no default binding and only one named binding)import { X, Y } from "module"will find references tomodule(since it would be ambiguous betweenXandY).import X = Ywill find references toXimport X = require("module")will find references toXexportexport * from "module"will find references tomoduleexport * as X from "module"will find references toXexport { X } from "module"will find references toX(if there is only one named binding)export { X }will find references toX(if there is only one named binding)export = Xwill find references toXexport default Xwill find references toXasimport * as X from "module"will find references toXimport { Y as X } from "module"will find references toXexport * as X from "module"will find references toXexport { Y as X } from "module"will find references toXexport { Y as X }will find references toXfromimport ... from "module"will find references tomoduleexport ... from "module"will find references tomodulerequire(in animport=declaration)import X = require("module")will find references tomoduletype(in animport/exportdeclaration) has the same behavior asimportorexport(above), where applicable.new,void,typeof,delete,yield,await) will find references to the declaration referenced in the operand (as long as the operand is an identifier or property access).in,instanceof,as) will find references to the declaration on the right.extendsin<T extends U>(type parameter list) will find references toUextendsinT extends U ? A : B(conditional type) will find references toUinferinT extends infer U ? A : B(conditional type) will find references toUinin{ [P in K]: T }(mapped type) will find references toPkeyofinkeyof Twill find references toTreadonlyinreadonly T[]will find references toT(not supported on tuple types)I've also updated
runCodein our fourslash tests so that errors are reported at the source location in the test file (using source maps), and so that you can step through the ts file when debugging.Fixes #13309
Fixes #28268