mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
[in progress] project system work - fixes in tests
This commit is contained in:
parent
cefaa171eb
commit
4157655215
@ -35,10 +35,10 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
interface OpenConfigFileResult {
|
||||
success: boolean,
|
||||
errors?: Diagnostic[]
|
||||
success: boolean;
|
||||
errors?: Diagnostic[];
|
||||
|
||||
project?: ConfiguredProject,
|
||||
project?: ConfiguredProject;
|
||||
}
|
||||
|
||||
interface OpenConfiguredProjectResult {
|
||||
@ -304,23 +304,23 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
// TODO: delete if unused
|
||||
private releaseNonReferencedConfiguredProjects() {
|
||||
if (this.configuredProjects.every(p => p.openRefCount > 0)) {
|
||||
return;
|
||||
}
|
||||
// private releaseNonReferencedConfiguredProjects() {
|
||||
// if (this.configuredProjects.every(p => p.openRefCount > 0)) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
const configuredProjects: ConfiguredProject[] = [];
|
||||
for (const proj of this.configuredProjects) {
|
||||
if (proj.openRefCount > 0) {
|
||||
configuredProjects.push(proj);
|
||||
}
|
||||
else {
|
||||
proj.close();
|
||||
}
|
||||
}
|
||||
// const configuredProjects: ConfiguredProject[] = [];
|
||||
// for (const proj of this.configuredProjects) {
|
||||
// if (proj.openRefCount > 0) {
|
||||
// configuredProjects.push(proj);
|
||||
// }
|
||||
// else {
|
||||
// proj.close();
|
||||
// }
|
||||
// }
|
||||
|
||||
this.configuredProjects = configuredProjects;
|
||||
}
|
||||
// this.configuredProjects = configuredProjects;
|
||||
// }
|
||||
|
||||
private removeProject(project: Project) {
|
||||
this.log(`remove project: ${project.getRootFiles().toString()}`);
|
||||
@ -540,7 +540,7 @@ namespace ts.server {
|
||||
return;
|
||||
}
|
||||
this.logger.startGroup();
|
||||
|
||||
|
||||
let counter = 0;
|
||||
counter = printProjects(this.externalProjects, counter);
|
||||
counter = printProjects(this.configuredProjects, counter);
|
||||
@ -636,10 +636,10 @@ namespace ts.server {
|
||||
|
||||
private createAndAddExternalProject(projectFileName: string, files: string[], compilerOptions: CompilerOptions) {
|
||||
const project = new ExternalProject(
|
||||
projectFileName,
|
||||
this,
|
||||
this.documentRegistry,
|
||||
compilerOptions,
|
||||
projectFileName,
|
||||
this,
|
||||
this.documentRegistry,
|
||||
compilerOptions,
|
||||
/*languageServiceEnabled*/ !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files));
|
||||
|
||||
const errors = this.addFilesToProjectAndUpdateGraph(project, files, /*clientFileName*/ undefined);
|
||||
@ -648,7 +648,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private createAndAddConfiguredProject(configFileName: NormalizedPath, projectOptions: ProjectOptions, clientFileName?: string) {
|
||||
const sizeLimitExceeded = !this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files);
|
||||
const sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files);
|
||||
const project = new ConfiguredProject(
|
||||
configFileName,
|
||||
this,
|
||||
@ -665,7 +665,7 @@ namespace ts.server {
|
||||
this.watchConfigDirectoryForProject(project, projectOptions);
|
||||
}
|
||||
project.watchWildcards((project, path) => this.onSourceFileInDirectoryChangedForConfiguredProject(project, path));
|
||||
|
||||
|
||||
this.configuredProjects.push(project);
|
||||
return { project, errors };
|
||||
}
|
||||
@ -902,7 +902,7 @@ namespace ts.server {
|
||||
const openFileRootsConfigured: ScriptInfo[] = [];
|
||||
// collect all orphanted script infos that used to be roots of configured projects
|
||||
for (const info of this.openFileRootsConfigured) {
|
||||
if(info.containingProjects.length === 0) {
|
||||
if (info.containingProjects.length === 0) {
|
||||
unattachedOpenFiles.push(info);
|
||||
}
|
||||
else {
|
||||
@ -999,7 +999,6 @@ namespace ts.server {
|
||||
// const rootedProject = rootFile.defaultProject;
|
||||
// const referencingProjects = this.findReferencingProjects(rootFile, rootedProject);
|
||||
|
||||
|
||||
// if (rootFile.defaultProject && rootFile.defaultProject.projectKind !== ProjectKind.Inferred) {
|
||||
// // If the root file has already been added into a configured project,
|
||||
// // meaning the original inferred project is gone already.
|
||||
|
||||
@ -11,13 +11,13 @@ namespace ts.server {
|
||||
External
|
||||
}
|
||||
|
||||
function remove<T>(items: T[], item: T) {
|
||||
function remove<T>(items: T[], item: T) {
|
||||
const index = items.indexOf(item);
|
||||
if (index >= 0) {
|
||||
items.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export abstract class Project {
|
||||
private readonly rootFiles: ScriptInfo[] = [];
|
||||
private readonly rootFilesMap: FileMap<ScriptInfo> = createFileMap<ScriptInfo>();
|
||||
@ -153,12 +153,12 @@ namespace ts.server {
|
||||
this.rootFiles.push(info);
|
||||
this.rootFilesMap.set(info.path, info);
|
||||
info.attachToProject(this);
|
||||
|
||||
|
||||
this.markAsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
removeFile(info: ScriptInfo, detachFromProject: boolean = true) {
|
||||
removeFile(info: ScriptInfo, detachFromProject = true) {
|
||||
this.removeRootFileIfNecessary(info);
|
||||
this.lsHost.notifyFileRemoved(info);
|
||||
|
||||
@ -330,7 +330,8 @@ namespace ts.server {
|
||||
languageServiceEnabled,
|
||||
/*compilerOptions*/ undefined);
|
||||
|
||||
this.inferredProjectName = makeInferredProjectName(InferredProject.NextId++);
|
||||
this.inferredProjectName = makeInferredProjectName(InferredProject.NextId);
|
||||
InferredProject.NextId++;
|
||||
}
|
||||
|
||||
getProjectName() {
|
||||
|
||||
@ -15,9 +15,9 @@ namespace ts.server {
|
||||
|
||||
constructor(
|
||||
private readonly host: ServerHost,
|
||||
readonly fileName: NormalizedPath,
|
||||
readonly fileName: NormalizedPath,
|
||||
content: string,
|
||||
readonly scriptKind: ScriptKind,
|
||||
readonly scriptKind: ScriptKind,
|
||||
public isOpen = false) {
|
||||
|
||||
this.path = toPath(fileName, host.getCurrentDirectory(), createGetCanonicalFileName(host.useCaseSensitiveFileNames));
|
||||
|
||||
@ -436,7 +436,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private getTypeDefinition(args: protocol.FileLocationRequestArgs): protocol.FileSpan[] {
|
||||
const { file, project } = this.getFileAndProject(args)
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
const scriptInfo = project.getScriptInfoForNormalizedPath(file);
|
||||
const position = this.getPosition(args, scriptInfo);
|
||||
|
||||
@ -1443,7 +1443,7 @@ namespace ts.server {
|
||||
return this.requiredResponse(this.getNavigationBarItems(request.arguments, /*simplifiedResult*/ false));
|
||||
},
|
||||
[CommandNames.Occurrences]: (request: protocol.FileLocationRequest) => {
|
||||
return this.requiredResponse(this.getOccurrences(request.arguments));;
|
||||
return this.requiredResponse(this.getOccurrences(request.arguments));
|
||||
},
|
||||
[CommandNames.DocumentHighlights]: (request: protocol.DocumentHighlightsRequest) => {
|
||||
return this.requiredResponse(this.getDocumentHighlights(request.arguments, /*simplifiedResult*/ true));
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
/// <reference path="..\services\services.ts" />
|
||||
|
||||
/* tslint:disable:no-null-keyword */
|
||||
|
||||
namespace ts.server {
|
||||
export interface Logger {
|
||||
close(): void;
|
||||
@ -55,7 +57,6 @@ namespace ts.server {
|
||||
items[index] = items.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export type NormalizedPath = string & { __normalizedPathTag: any };
|
||||
|
||||
@ -91,9 +92,9 @@ namespace ts.server {
|
||||
return hasProperty(map, path);
|
||||
},
|
||||
remove(path) {
|
||||
delete map[path]
|
||||
delete map[path];
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
function throwLanguageServiceIsDisabledError() {;
|
||||
throw new Error("LanguageService is disabled");
|
||||
@ -169,5 +170,5 @@ namespace ts.server {
|
||||
|
||||
export function makeInferredProjectName(counter: number) {
|
||||
return `/dev/null/inferredProject${counter}*`;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user