mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Simplify findContainingList (#22128)
This commit is contained in:
@@ -619,13 +619,7 @@ namespace ts {
|
||||
// be parented by the container of the SyntaxList, not the SyntaxList itself.
|
||||
// In order to find the list item index, we first need to locate SyntaxList itself and then search
|
||||
// for the position of the relevant node (or comma).
|
||||
const syntaxList = forEach(node.parent.getChildren(), c => {
|
||||
// find syntax list that covers the span of the node
|
||||
if (isSyntaxList(c) && c.pos <= node.pos && c.end >= node.end) {
|
||||
return c;
|
||||
}
|
||||
});
|
||||
|
||||
const syntaxList = find(node.parent.getChildren(), (c): c is SyntaxList => isSyntaxList(c) && rangeContainsRange(c, node));
|
||||
// Either we didn't find an appropriate list, or the list must contain us.
|
||||
Debug.assert(!syntaxList || contains(syntaxList.getChildren(), node));
|
||||
return syntaxList;
|
||||
|
||||
Reference in New Issue
Block a user