From 05160cae8ecde10fd7e2f7948ac4d9069aa56325 Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Fri, 9 Dec 2016 13:36:43 -0800 Subject: [PATCH] Rename fileExtensionMap: fileExtensionMapItem[] to extraFileExtensions: FileExtensionInfo[] --- src/compiler/commandLineParser.ts | 8 +++---- src/compiler/core.ts | 12 +++++----- src/compiler/types.ts | 2 +- .../unittests/tsserverProjectSystem.ts | 4 ++-- src/server/editorServices.ts | 22 +++++++++---------- src/server/protocol.ts | 6 ++--- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 9c7b6f48b3a..251eeb58b15 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -841,7 +841,7 @@ namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], fileExtensionMap: FileExtensionMapItem[] = []): ParsedCommandLine { + export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: FileExtensionInfo[] = []): ParsedCommandLine { const errors: Diagnostic[] = []; const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames); const resolvedPath = toPath(configFileName || "", basePath, getCanonicalFileName); @@ -981,7 +981,7 @@ namespace ts { includeSpecs = ["**/*"]; } - const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, fileExtensionMap); + const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions); if (result.fileNames.length === 0 && !hasProperty(json, "files") && resolutionStack.length === 0) { errors.push( @@ -1185,7 +1185,7 @@ namespace ts { * @param host The host used to resolve files and directories. * @param errors An array for diagnostic reporting. */ - function matchFileNames(fileNames: string[], include: string[], exclude: string[], basePath: string, options: CompilerOptions, host: ParseConfigHost, errors: Diagnostic[], fileExtensionMap: FileExtensionMapItem[]): ExpandResult { + function matchFileNames(fileNames: string[], include: string[], exclude: string[], basePath: string, options: CompilerOptions, host: ParseConfigHost, errors: Diagnostic[], extraFileExtensions: FileExtensionInfo[]): ExpandResult { basePath = normalizePath(basePath); // The exclude spec list is converted into a regular expression, which allows us to quickly @@ -1219,7 +1219,7 @@ namespace ts { // Rather than requery this for each file and filespec, we query the supported extensions // once and store it on the expansion context. - const supportedExtensions = getSupportedExtensions(options, fileExtensionMap); + const supportedExtensions = getSupportedExtensions(options, extraFileExtensions); // Literal files are always included verbatim. An "include" or "exclude" specification cannot // remove a literal file. diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 01cb80725ef..f35bfd28f74 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1924,12 +1924,12 @@ namespace ts { export const supportedJavascriptExtensions = [".js", ".jsx"]; const allSupportedExtensions = supportedTypeScriptExtensions.concat(supportedJavascriptExtensions); - export function getSupportedExtensions(options?: CompilerOptions, fileExtensionMap?: FileExtensionMapItem[]): string[] { + export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: FileExtensionInfo[]): string[] { let typeScriptHostExtensions: string[] = []; let allHostExtensions: string[] = []; - if (fileExtensionMap) { - allHostExtensions = ts.map(fileExtensionMap, item => item.extension); - typeScriptHostExtensions = ts.map(ts.filter(fileExtensionMap, item => item.scriptKind === ScriptKind.TS), item => item.extension); + if (extraFileExtensions) { + allHostExtensions = ts.map(extraFileExtensions, item => item.extension); + typeScriptHostExtensions = ts.map(ts.filter(extraFileExtensions, item => item.scriptKind === ScriptKind.TS), item => item.extension); } const allTypeScriptExtensions = concatenate(supportedTypeScriptExtensions, typeScriptHostExtensions); const allExtensions = concatenate(allSupportedExtensions, allHostExtensions); @@ -1944,10 +1944,10 @@ namespace ts { return forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension)); } - export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, fileExtensionMap?: FileExtensionMapItem[]) { + export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: FileExtensionInfo[]) { if (!fileName) { return false; } - for (const extension of getSupportedExtensions(compilerOptions, fileExtensionMap)) { + for (const extension of getSupportedExtensions(compilerOptions, extraFileExtensions)) { if (fileExtensionIs(fileName, extension)) { return true; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 3f1a5465c87..da9d91e2acf 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3086,7 +3086,7 @@ namespace ts { ThisProperty } - export interface FileExtensionMapItem { + export interface FileExtensionInfo { extension: string; scriptKind: ScriptKind; isMixedContent: boolean; diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 6ad525299fb..bc0d6662b9a 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -1552,8 +1552,8 @@ namespace ts.projectSystem { checkProjectActualFiles(projectService.configuredProjects[0], [file1.path]); // Specify .html extension as mixed content - const fileExtensionMap = [{ extension: ".html", scriptKind: ScriptKind.JS, isMixedContent: true }]; - const configureHostRequest = makeSessionRequest(CommandNames.Configure, { fileExtensionMap }); + const extraFileExtensions = [{ extension: ".html", scriptKind: ScriptKind.JS, isMixedContent: true }]; + const configureHostRequest = makeSessionRequest(CommandNames.Configure, { extraFileExtensions }); session.executeCommand(configureHostRequest).response; // HTML file still not included in the project as it is closed diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index ded9f786dba..a70b16a5b1e 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -108,7 +108,7 @@ namespace ts.server { export interface HostConfiguration { formatCodeOptions: FormatCodeSettings; hostInfo: string; - fileExtensionMap?: FileExtensionMapItem[]; + extraFileExtensions?: FileExtensionInfo[]; } interface ConfigFileConversionResult { @@ -133,14 +133,14 @@ namespace ts.server { interface FilePropertyReader { getFileName(f: T): string; getScriptKind(f: T): ScriptKind; - hasMixedContent(f: T, fileExtensionMap: FileExtensionMapItem[]): boolean; + hasMixedContent(f: T, extraFileExtensions: FileExtensionInfo[]): boolean; } const fileNamePropertyReader: FilePropertyReader = { getFileName: x => x, getScriptKind: _ => undefined, - hasMixedContent: (fileName, fileExtensionMap) => { - const mixedContentExtensions = ts.map(ts.filter(fileExtensionMap, item => item.isMixedContent), item => item.extension); + hasMixedContent: (fileName, extraFileExtensions) => { + const mixedContentExtensions = ts.map(ts.filter(extraFileExtensions, item => item.isMixedContent), item => item.extension); return forEach(mixedContentExtensions, extension => fileExtensionIs(fileName, extension)) } }; @@ -287,7 +287,7 @@ namespace ts.server { this.hostConfiguration = { formatCodeOptions: getDefaultFormatCodeSettings(this.host), hostInfo: "Unknown host", - fileExtensionMap: [] + extraFileExtensions: [] }; this.documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory()); @@ -491,7 +491,7 @@ namespace ts.server { // If a change was made inside "folder/file", node will trigger the callback twice: // one with the fileName being "folder/file", and the other one with "folder". // We don't respond to the second one. - if (fileName && !ts.isSupportedSourceFileName(fileName, project.getCompilerOptions(), this.hostConfiguration.fileExtensionMap)) { + if (fileName && !ts.isSupportedSourceFileName(fileName, project.getCompilerOptions(), this.hostConfiguration.extraFileExtensions)) { return; } @@ -820,7 +820,7 @@ namespace ts.server { /*existingOptions*/ {}, configFilename, /*resolutionStack*/ [], - this.hostConfiguration.fileExtensionMap); + this.hostConfiguration.extraFileExtensions); if (parsedCommandLine.errors.length) { errors = concatenate(errors, parsedCommandLine.errors); @@ -924,7 +924,7 @@ namespace ts.server { for (const f of files) { const rootFilename = propertyReader.getFileName(f); const scriptKind = propertyReader.getScriptKind(f); - const hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.fileExtensionMap); + const hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); if (this.host.fileExists(rootFilename)) { const info = this.getOrCreateScriptInfoForNormalizedPath(toNormalizedPath(rootFilename), /*openedByClient*/ clientFileName == rootFilename, /*fileContent*/ undefined, scriptKind, hasMixedContent); project.addRoot(info); @@ -970,7 +970,7 @@ namespace ts.server { rootFilesChanged = true; if (!scriptInfo) { const scriptKind = propertyReader.getScriptKind(f); - const hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.fileExtensionMap); + const hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, /*openedByClient*/ false, /*fileContent*/ undefined, scriptKind, hasMixedContent); } } @@ -1157,8 +1157,8 @@ namespace ts.server { mergeMaps(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); this.logger.info("Format host information updated"); } - if (args.fileExtensionMap) { - this.hostConfiguration.fileExtensionMap = args.fileExtensionMap; + if (args.extraFileExtensions) { + this.hostConfiguration.extraFileExtensions = args.extraFileExtensions; this.logger.info("Host file extension mappings updated"); } } diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 6df390344cc..27faf417282 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -1,4 +1,4 @@ -/** +/** * Declaration module describing the TypeScript Server protocol */ namespace ts.server.protocol { @@ -996,9 +996,9 @@ namespace ts.server.protocol { formatOptions?: FormatCodeSettings; /** - * The host's supported file extension mappings + * The host's additional supported file extensions */ - fileExtensionMap?: FileExtensionMapItem[]; + extraFileExtensions?: FileExtensionInfo[]; } /**