From 9c0e4211bc29de5ba6b1154366277e1a456fa022 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 12 Dec 2014 02:34:53 -0800 Subject: [PATCH] Properly adjust nodes while walking down the tree. --- src/compiler/parser.ts | 4 ++-- tests/cases/unittests/incrementalParser.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index a3d9fb51fca..d60a5415577 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -801,7 +801,7 @@ module ts { // Adjust the pos or end (or both) of the intersecting array accordingly. adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); for (var i = 0, n = array.length; i < n; i++) { - forEachChild(array[i], visitNode, visitArray); + visitNode(array[i]); } } // else { @@ -908,7 +908,7 @@ module ts { array.end += delta; for (var i = 0, n = array.length; i < n; i++) { - forEachChild(array[i], visitNode, visitArray); + visitNode(array[i]); } } } diff --git a/tests/cases/unittests/incrementalParser.ts b/tests/cases/unittests/incrementalParser.ts index ddbd8acfc02..fd4d31197d7 100644 --- a/tests/cases/unittests/incrementalParser.ts +++ b/tests/cases/unittests/incrementalParser.ts @@ -55,7 +55,7 @@ module ts { Utils.assertInvariants(newTree, /*parent:*/ undefined); // Create a tree for the new text, in an incremental fashion. - var incrementalNewTree = updateLanguageServiceSourceFile(oldTree, newText, oldTree.version + ".", /*isOpen:*/ true, textChangeRange, /*useIncremental:*/ false); + var incrementalNewTree = updateLanguageServiceSourceFile(oldTree, newText, oldTree.version + ".", /*isOpen:*/ true, textChangeRange, /*useIncremental:*/ true); Utils.assertInvariants(incrementalNewTree, /*parent:*/ undefined); // We should get the same tree when doign a full or incremental parse. @@ -177,7 +177,9 @@ module ts { } describe('Incremental',() => { + debugger; it('Inserting into method',() => { + debugger; var source = "class C {\r\n" + " public foo1() { }\r\n" + " public foo2() {\r\n" +