Simplify findContainingList (#22128)

This commit is contained in:
Andy
2018-02-22 15:52:43 -08:00
committed by GitHub
parent 73947b6ca7
commit 75fa945f00

View File

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