mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 20:37:00 -05:00
Use findAncestor in more places (#17601)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user