diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index bc645cb9f8e..623fdddfacb 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -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. diff --git a/src/server/project.ts b/src/server/project.ts index a3be7358b30..ff3ec6a0f45 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -11,13 +11,13 @@ namespace ts.server { External } - function remove(items: T[], item: T) { + function remove(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 = createFileMap(); @@ -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() { diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index 95023a93b74..d5c01f609dd 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -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)); diff --git a/src/server/session.ts b/src/server/session.ts index c866ec178cc..10cf03e96da 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -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)); diff --git a/src/server/utilities.ts b/src/server/utilities.ts index ef877362281..18970f578b3 100644 --- a/src/server/utilities.ts +++ b/src/server/utilities.ts @@ -1,5 +1,7 @@ /// +/* 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}*`; - } + } } \ No newline at end of file