Use findAncestor in more places (#17601)
This commit is contained in:
parent
1552761982
commit
86d0fa27a2
|
@ -922,21 +922,11 @@ namespace ts {
|
|||
}
|
||||
|
||||
export function getContainingFunction(node: Node): FunctionLike {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node || isFunctionLike(node)) {
|
||||
return <FunctionLike>node;
|
||||
}
|
||||
}
|
||||
return findAncestor(node.parent, isFunctionLike);
|
||||
}
|
||||
|
||||
export function getContainingClass(node: Node): ClassLikeDeclaration {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node || isClassLike(node)) {
|
||||
return <ClassLikeDeclaration>node;
|
||||
}
|
||||
}
|
||||
return findAncestor(node.parent, isClassLike);
|
||||
}
|
||||
|
||||
export function getThisContainer(node: Node, includeArrowFunctions: boolean): Node {
|
||||
|
|
Loading…
Reference in a new issue