mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
release cached tree in compilation settings change
This commit is contained in:
@@ -1346,5 +1346,21 @@ namespace ts {
|
||||
projectService.setCompilerOptionsForInferredProjects({ moduleResolution: ModuleResolutionKind.Classic });
|
||||
checkNumberOfProjects(projectService, { inferredProjects: 1 });
|
||||
});
|
||||
|
||||
it("syntax tree cache handles changes in project settings", () => {
|
||||
const file1 = {
|
||||
path: "/a/b/app.ts",
|
||||
content: "{x: 1}"
|
||||
};
|
||||
const host = createServerHost([file1]);
|
||||
const projectService = new server.ProjectService(host, nullLogger, nullCancellationToken, /*useSingleInferredProject*/ true);
|
||||
projectService.setCompilerOptionsForInferredProjects({ target: ScriptTarget.ES5, allowJs: false });
|
||||
projectService.openClientFile(file1.path);
|
||||
projectService.inferredProjects[0].getLanguageService(/*ensureSynchronized*/ false).getOutliningSpans(file1.path);
|
||||
projectService.setCompilerOptionsForInferredProjects({ target: ScriptTarget.ES5, allowJs: true });
|
||||
projectService.getScriptInfo(file1.path).editContent(0, 0, " ");
|
||||
projectService.inferredProjects[0].getLanguageService(/*ensureSynchronized*/ false).getOutliningSpans(file1.path);
|
||||
projectService.closeClientFile(file1.path);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -81,6 +81,9 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getDefaultProject() {
|
||||
if (this.containingProjects.length === 0) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
Debug.assert(this.containingProjects.length !== 0);
|
||||
return this.containingProjects[0];
|
||||
}
|
||||
|
||||
@@ -146,11 +146,6 @@ namespace ts.server {
|
||||
export const CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects";
|
||||
}
|
||||
|
||||
namespace Errors {
|
||||
export const NoProject = new Error("No Project.");
|
||||
export const ProjectLanguageServiceDisabled = new Error("The project's language service is disabled.");
|
||||
}
|
||||
|
||||
export class Session {
|
||||
protected projectService: ProjectService;
|
||||
private errorTimer: any; /*NodeJS.Timer | number*/
|
||||
|
||||
@@ -29,6 +29,11 @@ namespace ts.server {
|
||||
export type Types = Err | Info | Perf;
|
||||
}
|
||||
|
||||
export namespace Errors {
|
||||
export const NoProject = new Error("No Project.");
|
||||
export const ProjectLanguageServiceDisabled = new Error("The project's language service is disabled.");
|
||||
}
|
||||
|
||||
export function getDefaultFormatCodeSettings(host: ServerHost): FormatCodeSettings {
|
||||
return {
|
||||
indentSize: 4,
|
||||
|
||||
@@ -3284,7 +3284,7 @@ namespace ts {
|
||||
const scriptKind = ts.getScriptKind(fileName, host);
|
||||
const compilerOptions = host.getCompilationSettings();
|
||||
let sourceFile: SourceFile;
|
||||
if (currentFileName !== fileName) {
|
||||
if (currentFileName !== fileName || (currentCompilerOptions && !mapIsEqualTo(compilerOptions, currentCompilerOptions))) {
|
||||
// Release the current document
|
||||
if (currentFileName) {
|
||||
documentRegistry.releaseDocument(currentFileName, currentCompilerOptions);
|
||||
|
||||
Reference in New Issue
Block a user