Use findAncestor in more places (#17601)

This commit is contained in:
Andy
2017-08-03 16:33:04 -07:00
committed by GitHub
parent 1552761982
commit 86d0fa27a2

View File

@@ -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 {