File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,9 @@ namespace 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 {
@@ -1863,6 +1866,16 @@ namespace ts {
1863
1866
// after incremental parsing nameTable might not be up-to-date
1864
1867
// drop it so it can be lazily recreated later
1865
1868
newSourceFile . nameTable = undefined ;
1869
+
1870
+ // dispose all resources held by old script snapshot
1871
+ if ( sourceFile !== newSourceFile && sourceFile . scriptSnapshot ) {
1872
+ if ( sourceFile . scriptSnapshot . dispose ) {
1873
+ sourceFile . scriptSnapshot . dispose ( ) ;
1874
+ }
1875
+
1876
+ sourceFile . scriptSnapshot = undefined ;
1877
+ }
1878
+
1866
1879
return newSourceFile ;
1867
1880
}
1868
1881
}
Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ namespace 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 {
@@ -243,6 +246,14 @@ namespace ts {
243
246
return createTextChangeRange (
244
247
createTextSpan ( decoded . span . start , decoded . span . length ) , decoded . newLength ) ;
245
248
}
249
+
250
+ public dispose ( ) : void {
251
+ // if scriptSnapshotShim is a COM object then property check becomes method call with no arguments
252
+ // 'in' does not have this effect
253
+ if ( "dispose" in this . scriptSnapshotShim ) {
254
+ this . scriptSnapshotShim . dispose ( ) ;
255
+ }
256
+ }
246
257
}
247
258
248
259
export class LanguageServiceShimHostAdapter implements LanguageServiceHost {
You can’t perform that action at this time.
0 commit comments