mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-02 14:48:32 -05:00
In project, instead of iterating over program files to determine if file needs to be detached, do it through existing mechanism of releasing oldSourceFile (#59181)
This commit is contained in:
@@ -1866,17 +1866,22 @@ export function createLanguageService(
|
||||
host.onReleaseParsedCommandLine?.(configFileName, oldResolvedRef, oldOptions);
|
||||
}
|
||||
else if (oldResolvedRef) {
|
||||
onReleaseOldSourceFile(oldResolvedRef.sourceFile, oldOptions);
|
||||
releaseOldSourceFile(oldResolvedRef.sourceFile, oldOptions);
|
||||
}
|
||||
}
|
||||
|
||||
// Release any files we have acquired in the old program but are
|
||||
// not part of the new program.
|
||||
function onReleaseOldSourceFile(oldSourceFile: SourceFile, oldOptions: CompilerOptions) {
|
||||
function releaseOldSourceFile(oldSourceFile: SourceFile, oldOptions: CompilerOptions) {
|
||||
const oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions);
|
||||
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
|
||||
}
|
||||
|
||||
function onReleaseOldSourceFile(oldSourceFile: SourceFile, oldOptions: CompilerOptions, hasSourceFileByPath: boolean, newSourceFileByResolvedPath: SourceFile | undefined) {
|
||||
releaseOldSourceFile(oldSourceFile, oldOptions);
|
||||
host.onReleaseOldSourceFile?.(oldSourceFile, oldOptions, hasSourceFileByPath, newSourceFileByResolvedPath);
|
||||
}
|
||||
|
||||
function getOrCreateSourceFile(fileName: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined {
|
||||
return getOrCreateSourceFileByPath(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), languageVersionOrOptions, onError, shouldCreateNewSourceFile);
|
||||
}
|
||||
|
||||
@@ -430,6 +430,7 @@ export interface LanguageServiceHost extends GetEffectiveTypeRootsHost, MinimalR
|
||||
/** @internal */ sendPerformanceEvent?(kind: PerformanceEvent["kind"], durationMs: number): void;
|
||||
getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
|
||||
/** @internal */ onReleaseParsedCommandLine?(configFileName: string, oldResolvedRef: ResolvedProjectReference | undefined, optionOptions: CompilerOptions): void;
|
||||
/** @internal */ onReleaseOldSourceFile?(oldSourceFile: SourceFile, oldOptions: CompilerOptions, hasSourceFileByPath: boolean, newSourceFileByResolvedPath: SourceFile | undefined): void;
|
||||
/** @internal */ getIncompleteCompletionsCache?(): IncompleteCompletionsCache;
|
||||
/** @internal */ runWithTemporaryFileUpdate?(rootFile: string, updatedText: string, cb: (updatedProgram: Program, originalProgram: Program | undefined, updatedPastedText: SourceFile) => void): void;
|
||||
jsDocParsingMode?: JSDocParsingMode | undefined;
|
||||
|
||||
Reference in New Issue
Block a user