Allow to find all references for constructors#10540
Conversation
| // For that to work, the jsdoc comments should still be the leading trivia of the first child. | ||
| // Restoring the scanner position ensures that. | ||
| // For that to work, the jsdoc comments should still be the leading trivia of the first child. | ||
| // Restoring the scanner position ensures that. |
There was a problem hiding this comment.
(this comment block is gone in master)
1ccabe4 to
65023a2
Compare
65023a2 to
3f126a5
Compare
| } | ||
|
|
||
| /** Get `C` given `N` if `N` is in the position `class C extends N` */ | ||
| function tryGetClassExtendingNode(node: Node): ClassLikeDeclaration | undefined { |
There was a problem hiding this comment.
is there something like this inside compiler/ ? I remember using something very similar that uses symbols to follow declarations, but there may also be a function that operates solely on nodes. #Closed
Fixes a bug when constructor overloads are improper and no signatures can be found.
| : isConstructor | ||
| // For constructor, get type of the class. | ||
| ? typeChecker.getTypeOfSymbolAtLocation(symbol.parent, location) | ||
| : typeChecker.getTypeOfSymbolAtLocation(symbol, location); |
There was a problem hiding this comment.
what was the old behaviour without the isConstructor case?
There was a problem hiding this comment.
When I hover over constructor in a class named K I get a display like "constructor K(n: number): K", but when I hover over K, I get "class K". Is that the old behaviour?
| return isCallOrNewExpressionTarget(node, SyntaxKind.NewExpression); | ||
| } | ||
|
|
||
| function isCallOrNewExpressionTarget(node: Node, kind: SyntaxKind) { |
There was a problem hiding this comment.
kind: SyntaxKind.CallExpression | SyntaxKind.NewExpression
There was a problem hiding this comment.
I think this would require us to do a new LKG to get that feature.
… into constructor_references
Fixes #2114
We accomplish this by looking for the symbol of the constructor but the name of the class.
We also need new code to find constructor calls by
super()andnew this().