@@ -59,6 +59,9 @@ module ts {
5959 }
6060
6161 export interface SourceFile {
62+ isOpen : boolean ;
63+ version : string ;
64+
6265 getScriptSnapshot ( ) : IScriptSnapshot ;
6366 getNamedDeclarations ( ) : Declaration [ ] ;
6467 update ( scriptSnapshot : IScriptSnapshot , version : string , isOpen : boolean , textChangeRange : TextChangeRange ) : SourceFile ;
@@ -866,7 +869,9 @@ module ts {
866869 }
867870
868871 public static createSourceFileObject ( filename : string , scriptSnapshot : IScriptSnapshot , languageVersion : ScriptTarget , version : string , isOpen : boolean ) {
869- var newSourceFile = < SourceFileObject > < any > createSourceFile ( filename , scriptSnapshot . getText ( 0 , scriptSnapshot . getLength ( ) ) , languageVersion , version , isOpen ) ;
872+ var newSourceFile = < SourceFileObject > < any > createSourceFile ( filename , scriptSnapshot . getText ( 0 , scriptSnapshot . getLength ( ) ) , languageVersion , /*setParentNodes:*/ true ) ;
873+ newSourceFile . version = version ;
874+ newSourceFile . isOpen = isOpen ;
870875 newSourceFile . scriptSnapshot = scriptSnapshot ;
871876 return newSourceFile ;
872877 }
@@ -1678,7 +1683,6 @@ module ts {
16781683 this . host . log ( "SyntaxTreeCache.Initialize: createSourceFile: " + ( new Date ( ) . getTime ( ) - start ) ) ;
16791684
16801685 var start = new Date ( ) . getTime ( ) ;
1681- fixupParentReferences ( sourceFile ) ;
16821686 this . host . log ( "SyntaxTreeCache.Initialize: fixupParentRefs : " + ( new Date ( ) . getTime ( ) - start ) ) ;
16831687 }
16841688 else if ( this . currentFileVersion !== version ) {
@@ -1693,7 +1697,6 @@ module ts {
16931697 this . host . log ( "SyntaxTreeCache.Initialize: updateSourceFile: " + ( new Date ( ) . getTime ( ) - start ) ) ;
16941698
16951699 var start = new Date ( ) . getTime ( ) ;
1696- fixupParentReferences ( sourceFile ) ;
16971700 this . host . log ( "SyntaxTreeCache.Initialize: fixupParentRefs : " + ( new Date ( ) . getTime ( ) - start ) ) ;
16981701 }
16991702
@@ -1703,22 +1706,6 @@ module ts {
17031706 this . currentFilename = filename ;
17041707 this . currentSourceFile = sourceFile ;
17051708 }
1706-
1707- function fixupParentReferences ( sourceFile : SourceFile ) {
1708- // normally parent references are set during binding.
1709- // however here SourceFile data is used only for syntactic features so running the whole binding process is an overhead.
1710- // walk over the nodes and set parent references
1711- var parent : Node = sourceFile ;
1712- function walk ( n : Node ) : void {
1713- n . parent = parent ;
1714-
1715- var saveParent = parent ;
1716- parent = n ;
1717- forEachChild ( n , walk ) ;
1718- parent = saveParent ;
1719- }
1720- forEachChild ( sourceFile , walk ) ;
1721- }
17221709 }
17231710
17241711 public getCurrentSourceFile ( filename : string ) : SourceFile {
0 commit comments