@@ -7,7 +7,7 @@ module Harness.LanguageService {
77 public editRanges : { length : number ; textChangeRange : ts . TextChangeRange ; } [ ] = [ ] ;
88 public lineMap : number [ ] = null ;
99
10- constructor ( public fileName : string , public content : string , public isOpen = true ) {
10+ constructor ( public fileName : string , public content : string ) {
1111 this . setContent ( content ) ;
1212 }
1313
@@ -72,14 +72,6 @@ module Harness.LanguageService {
7272 return this . textSnapshot . length ;
7373 }
7474
75- public getLineStartPositions ( ) : string {
76- if ( this . lineMap === null ) {
77- this . lineMap = ts . computeLineStarts ( this . textSnapshot ) ;
78- }
79-
80- return JSON . stringify ( this . lineMap ) ;
81- }
82-
8375 public getChangeRange ( oldScript : ts . ScriptSnapshotShim ) : string {
8476 var oldShim = < ScriptSnapshotShim > oldScript ;
8577 var range = this . scriptInfo . getTextChangeRangeBetweenVersions ( oldShim . version , this . version ) ;
@@ -109,11 +101,9 @@ module Harness.LanguageService {
109101 fileName : string ,
110102 compilationSettings : ts . CompilerOptions ,
111103 scriptSnapshot : ts . IScriptSnapshot ,
112- version : string ,
113- isOpen : boolean ) : ts . SourceFile {
104+ version : string ) : ts . SourceFile {
114105 var sourceFile = ts . createSourceFile ( fileName , scriptSnapshot . getText ( 0 , scriptSnapshot . getLength ( ) ) , compilationSettings . target ) ;
115106 sourceFile . version = version ;
116- sourceFile . isOpen = isOpen ;
117107 return sourceFile ;
118108 }
119109
@@ -123,10 +113,9 @@ module Harness.LanguageService {
123113 compilationSettings : ts . CompilerOptions ,
124114 scriptSnapshot : ts . IScriptSnapshot ,
125115 version : string ,
126- isOpen : boolean ,
127116 textChangeRange : ts . TextChangeRange
128117 ) : ts . SourceFile {
129- return ts . updateLanguageServiceSourceFile ( document , scriptSnapshot , version , isOpen , textChangeRange ) ;
118+ return ts . updateLanguageServiceSourceFile ( document , scriptSnapshot , version , textChangeRange ) ;
130119 }
131120
132121 public releaseDocument ( fileName : string , compilationSettings : ts . CompilerOptions ) : void {
@@ -159,13 +148,17 @@ module Harness.LanguageService {
159148 }
160149
161150 private getScriptInfo ( fileName : string ) : ScriptInfo {
162- return this . fileNameToScript [ fileName ] ;
151+ return ts . lookUp ( this . fileNameToScript , fileName ) ;
163152 }
164153
165154 public addScript ( fileName : string , content : string ) {
166155 this . fileNameToScript [ fileName ] = new ScriptInfo ( fileName , content ) ;
167156 }
168157
158+ private contains ( fileName : string ) : boolean {
159+ return ts . hasProperty ( this . fileNameToScript , fileName ) ;
160+ }
161+
169162 public updateScript ( fileName : string , content : string ) {
170163 var script = this . getScriptInfo ( fileName ) ;
171164 if ( script !== null ) {
@@ -223,20 +216,22 @@ module Harness.LanguageService {
223216
224217 public getScriptFileNames ( ) : string {
225218 var fileNames : string [ ] = [ ] ;
226- ts . forEachKey ( this . fileNameToScript , ( fileName ) => { fileNames . push ( fileName ) ; } ) ;
219+ ts . forEachKey ( this . fileNameToScript , ( fileName ) => { fileNames . push ( fileName ) ; } ) ;
227220 return JSON . stringify ( fileNames ) ;
228221 }
229222
230223 public getScriptSnapshot ( fileName : string ) : ts . ScriptSnapshotShim {
231- return new ScriptSnapshotShim ( this . getScriptInfo ( fileName ) ) ;
224+ if ( this . contains ( fileName ) ) {
225+ return new ScriptSnapshotShim ( this . getScriptInfo ( fileName ) ) ;
226+ }
227+ return undefined ;
232228 }
233229
234230 public getScriptVersion ( fileName : string ) : string {
235- return this . getScriptInfo ( fileName ) . version . toString ( ) ;
236- }
237-
238- public getScriptIsOpen ( fileName : string ) : boolean {
239- return this . getScriptInfo ( fileName ) . isOpen ;
231+ if ( this . contains ( fileName ) ) {
232+ return this . getScriptInfo ( fileName ) . version . toString ( ) ;
233+ }
234+ return undefined ;
240235 }
241236
242237 public getLocalizedDiagnosticMessages ( ) : string {
@@ -272,7 +267,6 @@ module Harness.LanguageService {
272267 public parseSourceText ( fileName : string , sourceText : ts . IScriptSnapshot ) : ts . SourceFile {
273268 var result = ts . createSourceFile ( fileName , sourceText . getText ( 0 , sourceText . getLength ( ) ) , ts . ScriptTarget . Latest ) ;
274269 result . version = "1" ;
275- result . isOpen = true ;
276270 return result ;
277271 }
278272
0 commit comments