Skip to content

Commit 05160ca

Browse files
committed
Rename fileExtensionMap: fileExtensionMapItem[] to extraFileExtensions: FileExtensionInfo[]
1 parent 5f46e48 commit 05160ca

File tree

6 files changed

+27
-27
lines changed

6 files changed

+27
-27
lines changed

src/compiler/commandLineParser.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ namespace ts {
841841
* @param basePath A root directory to resolve relative path entries in the config
842842
* file to. e.g. outDir
843843
*/
844-
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], fileExtensionMap: FileExtensionMapItem[] = []): ParsedCommandLine {
844+
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: FileExtensionInfo[] = []): ParsedCommandLine {
845845
const errors: Diagnostic[] = [];
846846
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames);
847847
const resolvedPath = toPath(configFileName || "", basePath, getCanonicalFileName);
@@ -981,7 +981,7 @@ namespace ts {
981981
includeSpecs = ["**/*"];
982982
}
983983

984-
const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, fileExtensionMap);
984+
const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions);
985985

986986
if (result.fileNames.length === 0 && !hasProperty(json, "files") && resolutionStack.length === 0) {
987987
errors.push(
@@ -1185,7 +1185,7 @@ namespace ts {
11851185
* @param host The host used to resolve files and directories.
11861186
* @param errors An array for diagnostic reporting.
11871187
*/
1188-
function matchFileNames(fileNames: string[], include: string[], exclude: string[], basePath: string, options: CompilerOptions, host: ParseConfigHost, errors: Diagnostic[], fileExtensionMap: FileExtensionMapItem[]): ExpandResult {
1188+
function matchFileNames(fileNames: string[], include: string[], exclude: string[], basePath: string, options: CompilerOptions, host: ParseConfigHost, errors: Diagnostic[], extraFileExtensions: FileExtensionInfo[]): ExpandResult {
11891189
basePath = normalizePath(basePath);
11901190

11911191
// The exclude spec list is converted into a regular expression, which allows us to quickly
@@ -1219,7 +1219,7 @@ namespace ts {
12191219

12201220
// Rather than requery this for each file and filespec, we query the supported extensions
12211221
// once and store it on the expansion context.
1222-
const supportedExtensions = getSupportedExtensions(options, fileExtensionMap);
1222+
const supportedExtensions = getSupportedExtensions(options, extraFileExtensions);
12231223

12241224
// Literal files are always included verbatim. An "include" or "exclude" specification cannot
12251225
// remove a literal file.

src/compiler/core.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,12 +1924,12 @@ namespace ts {
19241924
export const supportedJavascriptExtensions = [".js", ".jsx"];
19251925
const allSupportedExtensions = supportedTypeScriptExtensions.concat(supportedJavascriptExtensions);
19261926

1927-
export function getSupportedExtensions(options?: CompilerOptions, fileExtensionMap?: FileExtensionMapItem[]): string[] {
1927+
export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: FileExtensionInfo[]): string[] {
19281928
let typeScriptHostExtensions: string[] = [];
19291929
let allHostExtensions: string[] = [];
1930-
if (fileExtensionMap) {
1931-
allHostExtensions = ts.map(fileExtensionMap, item => item.extension);
1932-
typeScriptHostExtensions = ts.map(ts.filter(fileExtensionMap, item => item.scriptKind === ScriptKind.TS), item => item.extension);
1930+
if (extraFileExtensions) {
1931+
allHostExtensions = ts.map(extraFileExtensions, item => item.extension);
1932+
typeScriptHostExtensions = ts.map(ts.filter(extraFileExtensions, item => item.scriptKind === ScriptKind.TS), item => item.extension);
19331933
}
19341934
const allTypeScriptExtensions = concatenate(supportedTypeScriptExtensions, typeScriptHostExtensions);
19351935
const allExtensions = concatenate(allSupportedExtensions, allHostExtensions);
@@ -1944,10 +1944,10 @@ namespace ts {
19441944
return forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension));
19451945
}
19461946

1947-
export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, fileExtensionMap?: FileExtensionMapItem[]) {
1947+
export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: FileExtensionInfo[]) {
19481948
if (!fileName) { return false; }
19491949

1950-
for (const extension of getSupportedExtensions(compilerOptions, fileExtensionMap)) {
1950+
for (const extension of getSupportedExtensions(compilerOptions, extraFileExtensions)) {
19511951
if (fileExtensionIs(fileName, extension)) {
19521952
return true;
19531953
}

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3086,7 +3086,7 @@ namespace ts {
30863086
ThisProperty
30873087
}
30883088

3089-
export interface FileExtensionMapItem {
3089+
export interface FileExtensionInfo {
30903090
extension: string;
30913091
scriptKind: ScriptKind;
30923092
isMixedContent: boolean;

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,8 +1552,8 @@ namespace ts.projectSystem {
15521552
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path]);
15531553

15541554
// Specify .html extension as mixed content
1555-
const fileExtensionMap = [{ extension: ".html", scriptKind: ScriptKind.JS, isMixedContent: true }];
1556-
const configureHostRequest = makeSessionRequest<protocol.ConfigureRequestArguments>(CommandNames.Configure, { fileExtensionMap });
1555+
const extraFileExtensions = [{ extension: ".html", scriptKind: ScriptKind.JS, isMixedContent: true }];
1556+
const configureHostRequest = makeSessionRequest<protocol.ConfigureRequestArguments>(CommandNames.Configure, { extraFileExtensions });
15571557
session.executeCommand(configureHostRequest).response;
15581558

15591559
// HTML file still not included in the project as it is closed

src/server/editorServices.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ namespace ts.server {
108108
export interface HostConfiguration {
109109
formatCodeOptions: FormatCodeSettings;
110110
hostInfo: string;
111-
fileExtensionMap?: FileExtensionMapItem[];
111+
extraFileExtensions?: FileExtensionInfo[];
112112
}
113113

114114
interface ConfigFileConversionResult {
@@ -133,14 +133,14 @@ namespace ts.server {
133133
interface FilePropertyReader<T> {
134134
getFileName(f: T): string;
135135
getScriptKind(f: T): ScriptKind;
136-
hasMixedContent(f: T, fileExtensionMap: FileExtensionMapItem[]): boolean;
136+
hasMixedContent(f: T, extraFileExtensions: FileExtensionInfo[]): boolean;
137137
}
138138

139139
const fileNamePropertyReader: FilePropertyReader<string> = {
140140
getFileName: x => x,
141141
getScriptKind: _ => undefined,
142-
hasMixedContent: (fileName, fileExtensionMap) => {
143-
const mixedContentExtensions = ts.map(ts.filter(fileExtensionMap, item => item.isMixedContent), item => item.extension);
142+
hasMixedContent: (fileName, extraFileExtensions) => {
143+
const mixedContentExtensions = ts.map(ts.filter(extraFileExtensions, item => item.isMixedContent), item => item.extension);
144144
return forEach(mixedContentExtensions, extension => fileExtensionIs(fileName, extension))
145145
}
146146
};
@@ -287,7 +287,7 @@ namespace ts.server {
287287
this.hostConfiguration = {
288288
formatCodeOptions: getDefaultFormatCodeSettings(this.host),
289289
hostInfo: "Unknown host",
290-
fileExtensionMap: []
290+
extraFileExtensions: []
291291
};
292292

293293
this.documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory());
@@ -491,7 +491,7 @@ namespace ts.server {
491491
// If a change was made inside "folder/file", node will trigger the callback twice:
492492
// one with the fileName being "folder/file", and the other one with "folder".
493493
// We don't respond to the second one.
494-
if (fileName && !ts.isSupportedSourceFileName(fileName, project.getCompilerOptions(), this.hostConfiguration.fileExtensionMap)) {
494+
if (fileName && !ts.isSupportedSourceFileName(fileName, project.getCompilerOptions(), this.hostConfiguration.extraFileExtensions)) {
495495
return;
496496
}
497497

@@ -820,7 +820,7 @@ namespace ts.server {
820820
/*existingOptions*/ {},
821821
configFilename,
822822
/*resolutionStack*/ [],
823-
this.hostConfiguration.fileExtensionMap);
823+
this.hostConfiguration.extraFileExtensions);
824824

825825
if (parsedCommandLine.errors.length) {
826826
errors = concatenate(errors, parsedCommandLine.errors);
@@ -924,7 +924,7 @@ namespace ts.server {
924924
for (const f of files) {
925925
const rootFilename = propertyReader.getFileName(f);
926926
const scriptKind = propertyReader.getScriptKind(f);
927-
const hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.fileExtensionMap);
927+
const hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions);
928928
if (this.host.fileExists(rootFilename)) {
929929
const info = this.getOrCreateScriptInfoForNormalizedPath(toNormalizedPath(rootFilename), /*openedByClient*/ clientFileName == rootFilename, /*fileContent*/ undefined, scriptKind, hasMixedContent);
930930
project.addRoot(info);
@@ -970,7 +970,7 @@ namespace ts.server {
970970
rootFilesChanged = true;
971971
if (!scriptInfo) {
972972
const scriptKind = propertyReader.getScriptKind(f);
973-
const hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.fileExtensionMap);
973+
const hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions);
974974
scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, /*openedByClient*/ false, /*fileContent*/ undefined, scriptKind, hasMixedContent);
975975
}
976976
}
@@ -1157,8 +1157,8 @@ namespace ts.server {
11571157
mergeMaps(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions));
11581158
this.logger.info("Format host information updated");
11591159
}
1160-
if (args.fileExtensionMap) {
1161-
this.hostConfiguration.fileExtensionMap = args.fileExtensionMap;
1160+
if (args.extraFileExtensions) {
1161+
this.hostConfiguration.extraFileExtensions = args.extraFileExtensions;
11621162
this.logger.info("Host file extension mappings updated");
11631163
}
11641164
}

src/server/protocol.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/**
22
* Declaration module describing the TypeScript Server protocol
33
*/
44
namespace ts.server.protocol {
@@ -996,9 +996,9 @@ namespace ts.server.protocol {
996996
formatOptions?: FormatCodeSettings;
997997

998998
/**
999-
* The host's supported file extension mappings
999+
* The host's additional supported file extensions
10001000
*/
1001-
fileExtensionMap?: FileExtensionMapItem[];
1001+
extraFileExtensions?: FileExtensionInfo[];
10021002
}
10031003

10041004
/**

0 commit comments

Comments
 (0)