From 535f9d8972c1ac0384ae22984928bc4294de545d Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 16 Dec 2014 16:36:49 -0800 Subject: [PATCH] Rename method to be clearer, and add comments to explain the semantics. --- src/compiler/parser.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 0caaf414e94..56366c9d2f4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -487,7 +487,7 @@ module ts { // If we don't have a node, or the node we have isn't in the right position, // then try to find a viable node at the position requested. if (!current || current.pos !== position) { - findHighestNodeAtPosition(position); + findHighestListElementThatStartsAtPosition(position); } } @@ -503,8 +503,11 @@ module ts { return current; } }; - - function findHighestNodeAtPosition(position: number) { + + // Finds the highest element in the tree we can find that starts at the provided position. + // The element must be a direct child of some node list in the tree. This way after we + // return it, we can easily return its next sibling in the list. + function findHighestListElementThatStartsAtPosition(position: number) { // Clear out any cached state about the last node we found. currentArray = undefined; currentArrayIndex = -1;