| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| * Go to implementation request; value of command field is | ||
| * "implementation". Return response giving the file locations that | ||
| * implement the symbol found in file at location line, col. | ||
| */ |
There was a problem hiding this comment.
question: why you make this empty interface?
Sorry, something went wrong.
There was a problem hiding this comment.
I was following what TypeDefinitionRequest and DefinitionRequest did (see above).
Sorry, something went wrong.
| } | ||
|
|
||
| const referenceParentDeclarations = referenceSymbol.parent.getDeclarations(); | ||
| if (referenceParentDeclarations.length) { |
There was a problem hiding this comment.
you should be able to check referenceSymbol.parent.valueDeclaration here instead of length and first declaration
Sorry, something went wrong.
There was a problem hiding this comment.
nevermind, you could just get the type for the getTypeOfSymbolAtLocation
Sorry, something went wrong.
|
Updated the PR to remove the filtering and instead filter the search set for find all references |
Sorry, something went wrong.
| return true; | ||
| } | ||
|
|
||
| if (node.parent.kind === SyntaxKind.PropertyAccessExpression || node.parent.kind === SyntaxKind.ElementAccessExpression) { |
There was a problem hiding this comment.
why not:
if (node.parent.kind === SyntaxKind.PropertyAccessExpression || node.parent.kind === SyntaxKind.ElementAccessExpression) {
return definitionIsImplementation((<ElementAccessExpression | PropertyAccessExpression>node.parent).expression, typeChecker);
}
Sorry, something went wrong.
There was a problem hiding this comment.
forget about this.
Sorry, something went wrong.
|
Mohamed Hegazy (@mhegazy) I've updated the branch with your last round of feedback |
Sorry, something went wrong.
| } | ||
| } | ||
|
|
||
| function isClassOrInterfaceReference(toCheck: Symbol) { |
There was a problem hiding this comment.
this is used in only one place. consider in lining it.
Sorry, something went wrong.
| // symbol of the local type of the symbol the property is being accessed on. This is because our search | ||
| // symbol may have a different parent symbol if the local type's symbol does not declare the property | ||
| // being accessed (i.e. it is declared in some parent class or interface) | ||
| let parents: Symbol[]; |
There was a problem hiding this comment.
The compiler doesn't check this yet, but this is Symbol[] | undefined since it's only used if implementations is true, and so is its use in getRelatedSymbol, where it should be documented that it's only set for implementations.
Sorry, something went wrong.
|
Other than comments from Andy (Andrewkraft) (@Andy-MS), no comments on my side. |
Sorry, something went wrong.
|
👍 |
Sorry, something went wrong.
|
Now that review is through, I'm going to close this PR and open two new ones: One that merges into release-2.0.5 and one that merges into master. Both of those will probably require some rebasing/git wizardry. |
Sorry, something went wrong.
…n_pr Refactored goToImplementation out of services
|
Okay, strike that. I'm leaving this PR open and have merged in master. This feature is not going to be merged into release-2.0.5. I factored the "go to implementation" stuff into its own file like we've done with the rest of the features, but I wonder if perhaps it should just be part of "find all references" since the majority of the implementation is in that file. |
Sorry, something went wrong.
There was a problem hiding this comment.
👍
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes #6209
This PR adds "Go To Implementation" functionality to the typescript language service.
The code works as follows:
First, if a symbol's definition is the same as its implementation, then "Go to Definition" is invoked. This covers most symbols, but not classes, interfaces, or unions/intersections and their members.
For symbols where the implementation is not the same as the definition, it performs "Find all References" and then filters the results down to those that are implementations. If anything is not caught by "Find all References", it won't show up in the results.
For example:
Both Bar and Baz implement Foo, but only Bar will show up in the results of "Go to Implementation" when invoked on Foo. You'll get the same results if you use "Go to Implementation" on Foo.hello.
"Find all References" is based on a text search, so if something implements a given interface but does not do so explicitly (i.e. using the name of the thing being referenced), it won't show up in the results. In general, it's more useful to invoke "Go to Implementation" on a member of the interface instead of the interface itself, since the names of members always show up in the implementation.
Here are some examples that illustrate that:
Still, I tried to capture most the usual patterns for creating instances of an interface. All of the following will work if invoked on Foo:
Another point of interest is the members of classes. If "Go to Implementation" is invoked on the member of a class, the results will also contain implementations in sub-classes. For example, if "Go to Implementation" was invoked on the reference x.hello below:
And there it is! I'm sure I missed some edge cases somewhere along the way, but they'll hopefully be caught once people start trying out the code. I tried the current implementation out on the TypeScript code base, and it seems to work pretty well. Implementations in JS files are not supported.