Merge pull request #3797 from Microsoft/disposeSnapshot-1.5

Port PR 3689 into release 1.5
This commit is contained in:
Mohamed Hegazy
2015-07-14 23:28:13 -07:00
2 changed files with 24 additions and 0 deletions
+13
View File
@@ -91,6 +91,9 @@ module 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 {
@@ -1873,6 +1876,16 @@ module 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 !== newSourceFile && sourceFile.scriptSnapshot) {
if (sourceFile.scriptSnapshot.dispose) {
sourceFile.scriptSnapshot.dispose();
}
sourceFile.scriptSnapshot = undefined;
}
return newSourceFile;
}
}
+11
View File
@@ -34,6 +34,9 @@ module 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 {
@@ -242,6 +245,14 @@ module ts {
return createTextChangeRange(
createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength);
}
public dispose(): void {
// if scriptSnapshotShim is a COM object then property check becomes method call with no arguments
// 'in' does not have this effect
if ("dispose" in this.scriptSnapshotShim) {
this.scriptSnapshotShim.dispose();
}
}
}
export class LanguageServiceShimHostAdapter implements LanguageServiceHost {