Skip to content

Commit 1c68f73

Browse files
committed
Rename diagnostics imported namespace to diagnosticFactories
1 parent cbf05eb commit 1c68f73

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

src/CommandLineParser.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as path from "path";
22
import * as ts from "typescript";
33
import { CompilerOptions, LuaLibImportKind, LuaTarget } from "./CompilerOptions";
4-
import * as diagnostics from "./diagnostics";
4+
import * as diagnosticFactories from "./diagnostics";
55

66
export interface ParsedCommandLine extends ts.ParsedCommandLine {
77
options: CompilerOptions;
@@ -117,14 +117,14 @@ export function updateParsedConfigFile(parsedConfigFile: ts.ParsedCommandLine):
117117
if (parsedConfigFile.raw.tstl) {
118118
if (hasRootLevelOptions) {
119119
parsedConfigFile.errors.push(
120-
diagnostics.tstlOptionsAreMovingToTheTstlObject(parsedConfigFile.raw.tstl)
120+
diagnosticFactories.tstlOptionsAreMovingToTheTstlObject(parsedConfigFile.raw.tstl)
121121
);
122122
}
123123

124124
for (const key in parsedConfigFile.raw.tstl) {
125125
const option = optionDeclarations.find(option => option.name === key);
126126
if (!option) {
127-
parsedConfigFile.errors.push(diagnostics.unknownCompilerOption(key));
127+
parsedConfigFile.errors.push(diagnosticFactories.unknownCompilerOption(key));
128128
continue;
129129
}
130130

@@ -187,7 +187,7 @@ function readCommandLineArgument(option: CommandLineOption, value: any): Command
187187
if (option.isTSConfigOnly) {
188188
return {
189189
value: undefined,
190-
error: diagnostics.optionCanOnlyBeSpecifiedInTsconfigJsonFile(option.name),
190+
error: diagnosticFactories.optionCanOnlyBeSpecifiedInTsconfigJsonFile(option.name),
191191
increment: 0,
192192
};
193193
}
@@ -203,7 +203,7 @@ function readCommandLineArgument(option: CommandLineOption, value: any): Command
203203

204204
if (value === undefined) {
205205
return {
206-
error: diagnostics.compilerOptionExpectsAnArgument(option.name),
206+
error: diagnosticFactories.compilerOptionExpectsAnArgument(option.name),
207207
value: undefined,
208208
increment: 0,
209209
};
@@ -225,7 +225,10 @@ function readValue(option: CommandLineOption, value: unknown): ReadValueResult {
225225
if (typeof value !== "boolean") {
226226
return {
227227
value: undefined,
228-
error: diagnostics.compilerOptionRequiresAValueOfType(option.name, "boolean"),
228+
error: diagnosticFactories.compilerOptionRequiresAValueOfType(
229+
option.name,
230+
"boolean"
231+
),
229232
};
230233
}
231234

@@ -236,7 +239,10 @@ function readValue(option: CommandLineOption, value: unknown): ReadValueResult {
236239
if (typeof value !== "string") {
237240
return {
238241
value: undefined,
239-
error: diagnostics.compilerOptionRequiresAValueOfType(option.name, "string"),
242+
error: diagnosticFactories.compilerOptionRequiresAValueOfType(
243+
option.name,
244+
"string"
245+
),
240246
};
241247
}
242248

@@ -245,7 +251,10 @@ function readValue(option: CommandLineOption, value: unknown): ReadValueResult {
245251
const optionChoices = option.choices.join(", ");
246252
return {
247253
value: undefined,
248-
error: diagnostics.argumentForOptionMustBe(`--${option.name}`, optionChoices),
254+
error: diagnosticFactories.argumentForOptionMustBe(
255+
`--${option.name}`,
256+
optionChoices
257+
),
249258
};
250259
}
251260

@@ -256,7 +265,10 @@ function readValue(option: CommandLineOption, value: unknown): ReadValueResult {
256265
if (!Array.isArray(value)) {
257266
return {
258267
value: undefined,
259-
error: diagnostics.compilerOptionRequiresAValueOfType(option.name, "Array"),
268+
error: diagnosticFactories.compilerOptionRequiresAValueOfType(
269+
option.name,
270+
"Array"
271+
),
260272
};
261273
}
262274

src/Transpile.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as path from "path";
22
import * as resolve from "resolve";
33
import * as ts from "typescript";
44
import { CompilerOptions } from "./CompilerOptions";
5-
import * as diags from "./diagnostics";
5+
import * as diagnosticFactories from "./diagnostics";
66
import { Block } from "./LuaAST";
77
import { LuaPrinter } from "./LuaPrinter";
88
import { LuaTransformer } from "./LuaTransformer";
@@ -36,7 +36,9 @@ function loadTransformersFromOptions(program: ts.Program): ts.CustomTransformers
3636
tsNode.register({ transpileOnly: true });
3737
} catch (err) {
3838
if (err.code === "MODULE_NOT_FOUND") {
39-
diagnostics.push(diags.toLoadTransformerItShouldBeTranspiled(transform));
39+
diagnostics.push(
40+
diagnosticFactories.toLoadTransformerItShouldBeTranspiled(transform)
41+
);
4042
}
4143

4244
continue;
@@ -47,7 +49,7 @@ function loadTransformersFromOptions(program: ts.Program): ts.CustomTransformers
4749
if (result !== undefined) {
4850
customTransformers[when].push(result(program, transformerOptions));
4951
} else {
50-
diagnostics.push(diags.transformerShouldHaveADefaultExport(transform));
52+
diagnostics.push(diagnosticFactories.transformerShouldHaveADefaultExport(transform));
5153
}
5254
}
5355

@@ -170,7 +172,7 @@ export function transpile({
170172
} catch (err) {
171173
if (!(err instanceof TranspileError)) throw err;
172174

173-
diagnostics.push(diags.transpileError(err));
175+
diagnostics.push(diagnosticFactories.transpileError(err));
174176

175177
updateTranspiledFile(sourceFile.fileName, {
176178
lua: `error(${JSON.stringify(err.message)})\n`,

src/tstl.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as path from "path";
33
import * as ts from "typescript";
44
import * as tstl from ".";
55
import * as CommandLineParser from "./CommandLineParser";
6-
import * as cliDiagnostics from "./diagnostics";
6+
import * as diagnosticFactories from "./diagnostics";
77

88
function createDiagnosticReporter(pretty: boolean): ts.DiagnosticReporter {
99
const reporter: ts.DiagnosticReporter = (ts as any).createDiagnosticReporter(ts.sys, pretty);
@@ -42,7 +42,7 @@ function locateConfigFile(commandLine: tstl.ParsedCommandLine): string | undefin
4242
}
4343

4444
if (commandLine.fileNames.length !== 0) {
45-
reportDiagnostic(cliDiagnostics.optionProjectCannotBeMixedWithSourceFilesOnACommandLine());
45+
reportDiagnostic(diagnosticFactories.optionProjectCannotBeMixedWithSourceFilesOnACommandLine());
4646
ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
4747
return;
4848
}
@@ -58,15 +58,15 @@ function locateConfigFile(commandLine: tstl.ParsedCommandLine): string | undefin
5858
return configFileName;
5959
} else {
6060
reportDiagnostic(
61-
cliDiagnostics.cannotFindATsconfigJsonAtTheSpecifiedDirectory(project)
61+
diagnosticFactories.cannotFindATsconfigJsonAtTheSpecifiedDirectory(project)
6262
);
6363
ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
6464
}
6565
} else {
6666
if (ts.sys.fileExists(fileOrDirectory)) {
6767
return fileOrDirectory;
6868
} else {
69-
reportDiagnostic(cliDiagnostics.theSpecifiedPathDoesNotExist(project));
69+
reportDiagnostic(diagnosticFactories.theSpecifiedPathDoesNotExist(project));
7070
ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
7171
}
7272
}
@@ -83,7 +83,7 @@ function executeCommandLine(args: string[]): void {
8383
const commandLine = CommandLineParser.parseCommandLine(args);
8484

8585
if (commandLine.options.build) {
86-
reportDiagnostic(cliDiagnostics.optionBuildMustBeFirstCommandLineArgument());
86+
reportDiagnostic(diagnosticFactories.optionBuildMustBeFirstCommandLineArgument());
8787
return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
8888
}
8989

@@ -284,7 +284,7 @@ function updateWatchCompilationHost(
284284
fullRecompile = errors.length > 0;
285285

286286
host.onWatchStatusChange!(
287-
cliDiagnostics.watchErrorSummary(errors.length),
287+
diagnosticFactories.watchErrorSummary(errors.length),
288288
host.getNewLine(),
289289
options
290290
);

0 commit comments

Comments
 (0)