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 @@ module ts {
9191 * not happen and the entire document will be re - parsed.
9292 */
9393 getChangeRange ( oldSnapshot : IScriptSnapshot ) : TextChangeRange ;
94+
95+ /** Releases all resources held by this script snapshot */
96+ dispose ?( ) : void ;
9497 }
9598
9699 export module ScriptSnapshot {
@@ -1873,6 +1876,16 @@ module ts {
18731876 // after incremental parsing nameTable might not be up-to-date
18741877 // drop it so it can be lazily recreated later
18751878 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+
18761889 return newSourceFile ;
18771890 }
18781891 }
Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ module ts {
3434 * Or undefined value if there was no change.
3535 */
3636 getChangeRange ( oldSnapshot : ScriptSnapshotShim ) : string ;
37+
38+ /** Releases all resources held by this script snapshot */
39+ dispose ?( ) : void ;
3740 }
3841
3942 export interface Logger {
@@ -242,6 +245,14 @@ module ts {
242245 return createTextChangeRange (
243246 createTextSpan ( decoded . span . start , decoded . span . length ) , decoded . newLength ) ;
244247 }
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+ }
245256 }
246257
247258 export class LanguageServiceShimHostAdapter implements LanguageServiceHost {
You can’t perform that action at this time.
0 commit comments