Misc. improvements to addImplementationReferences#23507
Merged
4 commits merged intoApr 18, 2018
Merged
Conversation
b9b21d7 to
c3e7350
Compare
| const containingTypeReference = getContainingTypeReference(refNode); | ||
| if (containingTypeReference && state.markSeenContainingTypeReference(containingTypeReference)) { | ||
| const parent = containingTypeReference.parent; | ||
| if (hasType(parent) && parent.type === containingTypeReference && hasInitializer(parent) && isImplementationExpression(parent.initializer)) { |
Member
There was a problem hiding this comment.
Dont you still need some kind of equivalent for parent.type === containingTypeReference otherwise doing this on anything eg node is initializer but parent has type would pass through this? (May be its some form of assert?)
| if (hasType(parent) && parent.type === containingTypeReference && hasInitializer(parent) && isImplementationExpression(parent.initializer)) { | ||
| addReference(parent.initializer); | ||
| // Find the first node whose parent isn't a type node -- i.e., the highest type node. | ||
| const typeNode = findAncestor(refNode.parent, a => !isQualifiedName(a.parent) && !isTypeNode(a.parent) && !isTypeElement(a.parent)); |
Member
There was a problem hiding this comment.
`It should be findAncestor(refNode since you are looking at parents now
sheetalkamat
approved these changes
Apr 18, 2018
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
getContainingClassIfInHeritageClause: AnExpressionWithTypeArgumentscan only appear in aHeritageClause, and every node must have aparentif it's not aSourceFile, so remove some unnecessary checks.getContainingTypeReference: Previously this would climb all the way to the root and keep track of the last thing that was a type. We only need to climb to the first thing that's not in a type. This is a one-liner usingfindAncestor.addIfImplementationhelper since all uses ofisImplementationExpressionwere immediately followed byaddReference.