dispose script snapshots from the old source file

This commit is contained in:
Vladimir Matveev 2015-06-30 16:11:09 -07:00
parent 32a040b487
commit ba3d2dbd14
2 changed files with 22 additions and 0 deletions

View File

@ -91,6 +91,9 @@ namespace ts {
* not happen and the entire document will be re - parsed.
*/
getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange;
/** Releases all resources held by this script snapshot */
dispose?(): void;
}
export module ScriptSnapshot {
@ -1863,6 +1866,16 @@ namespace ts {
// after incremental parsing nameTable might not be up-to-date
// drop it so it can be lazily recreated later
newSourceFile.nameTable = undefined;
// dispose all resources held by old script snapshot
if (sourceFile.scriptSnapshot) {
if (sourceFile.scriptSnapshot.dispose) {
sourceFile.scriptSnapshot.dispose();
}
sourceFile.scriptSnapshot = undefined;
}
return newSourceFile;
}
}

View File

@ -34,6 +34,9 @@ namespace ts {
* Or undefined value if there was no change.
*/
getChangeRange(oldSnapshot: ScriptSnapshotShim): string;
/** Releases all resources held by this script snapshot */
dispose?(): void;
}
export interface Logger {
@ -243,6 +246,12 @@ namespace ts {
return createTextChangeRange(
createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength);
}
public dispose(): void {
if ("dispose" in this.scriptSnapshotShim) {
this.scriptSnapshotShim.dispose();
}
}
}
export class LanguageServiceShimHostAdapter implements LanguageServiceHost {