8000 Rename a few members and clean up comments. · prmdeveloper/TypeScript@9d6b6b4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9d6b6b4

Browse files
Rename a few members and clean up comments.
1 parent ad7c77e commit 9d6b6b4

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/compiler/parser.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,16 @@ module ts {
336336
}
337337

338338
function fixupParentReferences(sourceFile: SourceFile) {
339-
// normally parent references are set during binding.
340-
// however here SourceFile data is used only for syntactic features so running the whole binding process is an overhead.
341-
// walk over the nodes and set parent references
339+
// normally parent references are set during binding. However, for clients that only need
340+
// a syntax tree, and no semantic features, then the binding process is an unnecessary
341+
// overhead. This functions allows us to set all the parents, without all the expense of
342+
// binding.
343+
342344
var parent: Node = sourceFile;
343-
function walk(n: Node): void {
345+
forEachChild(sourceFile, visitNode);
346+
return;
347+
348+
function visitNode(n: Node): void {
344349
// walk down setting parents that differ from the parent we think it should be. This
345350
// allows us to quickly bail out of setting parents for subtrees during incremental
346351
// parsing
@@ -349,12 +354,10 @@ module ts {
349354

350355
var saveParent = parent;
351356
parent = n;
352-
forEachChild(n, walk);
357+
forEachChild(n, visitNode);
353358
parent = saveParent;
354359
}
355360
}
356-
357-
forEachChild(sourceFile, walk);
358361
}
359362

360363
function shouldCheckNode(node: Node) {
@@ -721,7 +724,7 @@ module ts {
721724
if (sourceFile.statements.length === 0) {
722725
// If we don't have any statements in the current source file, then there's no real
723726
// way to incrementally parse. So just do a full parse instead.
724-
return parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion,/*syntaxCursor*/ undefined, /*setNodeParents*/ true)
727+
return parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setNodeParents*/ true)
725728
}
726729

727730
var oldText = sourceFile.text;
@@ -744,8 +747,8 @@ module ts {
744747
var delta = textChangeRangeNewSpan(changeRange).length - changeRange.span.length;
745748

746749
// If we added or removed characters during the edit, then we need to go and adjust all
747-
// the nodes after the edit. Those nodes may move forward down (if we inserted chars)
748-
// or they may move backward (if we deleted chars).
750+
// the nodes after the edit. Those nodes may move forward (if we inserted chars) or they
751+
// may move backward (if we deleted chars).
749752
//
750753
// Doing this helps us out in two ways. First, it means that any nodes/tokens we want
751754
// to reuse are already at the appropriate position in the new text. That way when we
@@ -1045,6 +1048,7 @@ module ts {
10451048
fixupParentReferences(sourceFile);
10461049
}
10471050

1051+
syntaxCursor = undefined;
10481052
return sourceFile;
10491053

10501054
function setContextFlag(val: Boolean, flag: ParserContextFlags) {

0 commit comments

Comments
 (0)
0