mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
dispose script snapshots from the old source file
This commit is contained in:
parent
32a040b487
commit
ba3d2dbd14
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user