Skip to content

Commit 4157655

Browse files
committed
[in progress] project system work - fixes in tests
1 parent cefaa17 commit 4157655

5 files changed

Lines changed: 43 additions & 42 deletions

File tree

src/server/editorServices.ts

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ namespace ts.server {
3535
}
3636

3737
interface OpenConfigFileResult {
38-
success: boolean,
39-
errors?: Diagnostic[]
38+
success: boolean;
39+
errors?: Diagnostic[];
4040

41-
project?: ConfiguredProject,
41+
project?: ConfiguredProject;
4242
}
4343

4444
interface OpenConfiguredProjectResult {
@@ -304,23 +304,23 @@ namespace ts.server {
304304
}
305305

306306
// TODO: delete if unused
307-
private releaseNonReferencedConfiguredProjects() {
308-
if (this.configuredProjects.every(p => p.openRefCount > 0)) {
309-
return;
310-
}
311-
312-
const configuredProjects: ConfiguredProject[] = [];
313-
for (const proj of this.configuredProjects) {
314-
if (proj.openRefCount > 0) {
315-
configuredProjects.push(proj);
316-
}
317-
else {
318-
proj.close();
319-
}
320-
}
321-
322-
this.configuredProjects = configuredProjects;
323-
}
307+
// private releaseNonReferencedConfiguredProjects() {
308+
// if (this.configuredProjects.every(p => p.openRefCount > 0)) {
309+
// return;
310+
// }
311+
312+
// const configuredProjects: ConfiguredProject[] = [];
313+
// for (const proj of this.configuredProjects) {
314+
// if (proj.openRefCount > 0) {
315+
// configuredProjects.push(proj);
316+
// }
317+
// else {
318+
// proj.close();
319+
// }
320+
// }
321+
322+
// this.configuredProjects = configuredProjects;
323+
// }
324324

325325
private removeProject(project: Project) {
326326
this.log(`remove project: ${project.getRootFiles().toString()}`);
@@ -540,7 +540,7 @@ namespace ts.server {
540540
return;
541541
}
542542
this.logger.startGroup();
543-
543+
544544
let counter = 0;
545545
counter = printProjects(this.externalProjects, counter);
546546
counter = printProjects(this.configuredProjects, counter);
@@ -636,10 +636,10 @@ namespace ts.server {
636636

637637
private createAndAddExternalProject(projectFileName: string, files: string[], compilerOptions: CompilerOptions) {
638638
const project = new ExternalProject(
639-
projectFileName,
640-
this,
641-
this.documentRegistry,
642-
compilerOptions,
639+
projectFileName,
640+
this,
641+
this.documentRegistry,
642+
compilerOptions,
643643
/*languageServiceEnabled*/ !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files));
644644

645645
const errors = this.addFilesToProjectAndUpdateGraph(project, files, /*clientFileName*/ undefined);
@@ -648,7 +648,7 @@ namespace ts.server {
648648
}
649649

650650
private createAndAddConfiguredProject(configFileName: NormalizedPath, projectOptions: ProjectOptions, clientFileName?: string) {
651-
const sizeLimitExceeded = !this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files);
651+
const sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files);
652652
const project = new ConfiguredProject(
653653
configFileName,
654654
this,
@@ -665,7 +665,7 @@ namespace ts.server {
665665
this.watchConfigDirectoryForProject(project, projectOptions);
666666
}
667667
project.watchWildcards((project, path) => this.onSourceFileInDirectoryChangedForConfiguredProject(project, path));
668-
668+
669669
this.configuredProjects.push(project);
670670
return { project, errors };
671671
}
@@ -902,7 +902,7 @@ namespace ts.server {
902902
const openFileRootsConfigured: ScriptInfo[] = [];
903903
// collect all orphanted script infos that used to be roots of configured projects
904904
for (const info of this.openFileRootsConfigured) {
905-
if(info.containingProjects.length === 0) {
905+
if (info.containingProjects.length === 0) {
906906
unattachedOpenFiles.push(info);
907907
}
908908
else {
@@ -999,7 +999,6 @@ namespace ts.server {
999999
// const rootedProject = rootFile.defaultProject;
10001000
// const referencingProjects = this.findReferencingProjects(rootFile, rootedProject);
10011001

1002-
10031002
// if (rootFile.defaultProject && rootFile.defaultProject.projectKind !== ProjectKind.Inferred) {
10041003
// // If the root file has already been added into a configured project,
10051004
// // meaning the original inferred project is gone already.

src/server/project.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ namespace ts.server {
1111
External
1212
}
1313

14-
function remove<T>(items: T[], item: T) {
14+
function remove<T>(items: T[], item: T) {
1515
const index = items.indexOf(item);
1616
if (index >= 0) {
1717
items.splice(index, 1);
1818
}
1919
}
20-
20+
2121
export abstract class Project {
2222
private readonly rootFiles: ScriptInfo[] = [];
2323
private readonly rootFilesMap: FileMap<ScriptInfo> = createFileMap<ScriptInfo>();
@@ -153,12 +153,12 @@ namespace ts.server {
153153
this.rootFiles.push(info);
154154
this.rootFilesMap.set(info.path, info);
155155
info.attachToProject(this);
156-
156+
157157
this.markAsDirty();
158158
}
159159
}
160160

161-
removeFile(info: ScriptInfo, detachFromProject: boolean = true) {
161+
removeFile(info: ScriptInfo, detachFromProject = true) {
162162
this.removeRootFileIfNecessary(info);
163163
this.lsHost.notifyFileRemoved(info);
164164

@@ -330,7 +330,8 @@ namespace ts.server {
330330
languageServiceEnabled,
331331
/*compilerOptions*/ undefined);
332332

333-
this.inferredProjectName = makeInferredProjectName(InferredProject.NextId++);
333+
this.inferredProjectName = makeInferredProjectName(InferredProject.NextId);
334+
InferredProject.NextId++;
334335
}
335336

336337
getProjectName() {

src/server/scriptInfo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ namespace ts.server {
1515

1616
constructor(
1717
private readonly host: ServerHost,
18-
readonly fileName: NormalizedPath,
18+
readonly fileName: NormalizedPath,
1919
content: string,
20-
readonly scriptKind: ScriptKind,
20+
readonly scriptKind: ScriptKind,
2121
public isOpen = false) {
2222

2323
this.path = toPath(fileName, host.getCurrentDirectory(), createGetCanonicalFileName(host.useCaseSensitiveFileNames));

src/server/session.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ namespace ts.server {
436436
}
437437

438438
private getTypeDefinition(args: protocol.FileLocationRequestArgs): protocol.FileSpan[] {
439-
const { file, project } = this.getFileAndProject(args)
439+
const { file, project } = this.getFileAndProject(args);
440440
const scriptInfo = project.getScriptInfoForNormalizedPath(file);
441441
const position = this.getPosition(args, scriptInfo);
442442

@@ -1443,7 +1443,7 @@ namespace ts.server {
14431443
return this.requiredResponse(this.getNavigationBarItems(request.arguments, /*simplifiedResult*/ false));
14441444
},
14451445
[CommandNames.Occurrences]: (request: protocol.FileLocationRequest) => {
1446-
return this.requiredResponse(this.getOccurrences(request.arguments));;
1446+
return this.requiredResponse(this.getOccurrences(request.arguments));
14471447
},
14481448
[CommandNames.DocumentHighlights]: (request: protocol.DocumentHighlightsRequest) => {
14491449
return this.requiredResponse(this.getDocumentHighlights(request.arguments, /*simplifiedResult*/ true));

src/server/utilities.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/// <reference path="..\services\services.ts" />
22

3+
/* tslint:disable:no-null-keyword */
4+
35
namespace ts.server {
46
export interface Logger {
57
close(): void;
@@ -55,7 +57,6 @@ namespace ts.server {
5557
items[index] = items.pop();
5658
}
5759
}
58-
5960

6061
export type NormalizedPath = string & { __normalizedPathTag: any };
6162

@@ -91,9 +92,9 @@ namespace ts.server {
9192
return hasProperty(map, path);
9293
},
9394
remove(path) {
94-
delete map[path]
95+
delete map[path];
9596
}
96-
}
97+
};
9798
}
9899
function throwLanguageServiceIsDisabledError() {;
99100
throw new Error("LanguageService is disabled");
@@ -169,5 +170,5 @@ namespace ts.server {
169170

170171
export function makeInferredProjectName(counter: number) {
171172
return `/dev/null/inferredProject${counter}*`;
172-
}
173+
}
173174
}

0 commit comments

Comments
 (0)