File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,9 @@ module ts {
91
91
* not happen and the entire document will be re - parsed.
92
92
*/
93
93
getChangeRange ( oldSnapshot : IScriptSnapshot ) : TextChangeRange ;
94
+
95
+ /** Releases all resources held by this script snapshot */
96
+ dispose ?( ) : void ;
94
97
}
95
98
96
99
export module ScriptSnapshot {
@@ -1873,6 +1876,16 @@ module ts {
1873
1876
// after incremental parsing nameTable might not be up-to-date
1874
1877
// drop it so it can be lazily recreated later
1875
1878
newSourceFile . nameTable = undefined ;
1879
+
1880
+ // dispose all resources held by old script snapshot
1881
+ if ( sourceFile !== newSourceFile && sourceFile . scriptSnapshot ) {
1882
+ if ( sourceFile . scriptSnapshot . dispose ) {
1883
+ sourceFile . scriptSnapshot . dispose ( ) ;
1884
+ }
1885
+
1886
+ sourceFile . scriptSnapshot = undefined ;
1887
+ }
1888
+
1876
1889
return newSourceFile ;
1877
1890
}
1878
1891
}
Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ module ts {
34
34
* Or undefined value if there was no change.
35
35
*/
36
36
getChangeRange ( oldSnapshot : ScriptSnapshotShim ) : string ;
37
+
38
+ /** Releases all resources held by this script snapshot */
39
+ dispose ?( ) : void ;
37
40
}
38
41
39
42
export interface Logger {
@@ -242,6 +245,14 @@ module ts {
242
245
return createTextChangeRange (
243
246
createTextSpan ( decoded . span . start , decoded . span . length ) , decoded . newLength ) ;
244
247
}
248
+
249
+ public dispose ( ) : void {
250
+ // if scriptSnapshotShim is a COM object then property check becomes method call with no arguments
251
+ // 'in' does not have this effect
252
+ if ( "dispose" in this . scriptSnapshotShim ) {
253
+ this . scriptSnapshotShim . dispose ( ) ;
254
+ }
255
+ }
245
256
}
246
257
247
258
export class LanguageServiceShimHostAdapter implements LanguageServiceHost {
You can’t perform that action at this time.
0 commit comments