Merge pull request #28607 from Microsoft/extendedDiagnostics
Enable statistics reporting per program through temporary build api
This commit is contained in:
commit
07769483e7
3 changed files with 35 additions and 17 deletions
|
@ -119,6 +119,18 @@ namespace ts {
|
||||||
category: Diagnostics.Advanced_Options,
|
category: Diagnostics.Advanced_Options,
|
||||||
description: Diagnostics.Enable_tracing_of_the_name_resolution_process
|
description: Diagnostics.Enable_tracing_of_the_name_resolution_process
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "diagnostics",
|
||||||
|
type: "boolean",
|
||||||
|
category: Diagnostics.Advanced_Options,
|
||||||
|
description: Diagnostics.Show_diagnostic_information
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "extendedDiagnostics",
|
||||||
|
type: "boolean",
|
||||||
|
category: Diagnostics.Advanced_Options,
|
||||||
|
description: Diagnostics.Show_verbose_diagnostic_information
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
/* @internal */
|
/* @internal */
|
||||||
|
@ -592,18 +604,6 @@ namespace ts {
|
||||||
category: Diagnostics.Advanced_Options,
|
category: Diagnostics.Advanced_Options,
|
||||||
description: Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h
|
description: Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "diagnostics",
|
|
||||||
type: "boolean",
|
|
||||||
category: Diagnostics.Advanced_Options,
|
|
||||||
description: Diagnostics.Show_diagnostic_information
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "extendedDiagnostics",
|
|
||||||
type: "boolean",
|
|
||||||
category: Diagnostics.Advanced_Options,
|
|
||||||
description: Diagnostics.Show_verbose_diagnostic_information
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "resolveJsonModule",
|
name: "resolveJsonModule",
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
|
|
|
@ -32,6 +32,8 @@ namespace ts {
|
||||||
pretty?: boolean;
|
pretty?: boolean;
|
||||||
|
|
||||||
traceResolution?: boolean;
|
traceResolution?: boolean;
|
||||||
|
/* @internal */ diagnostics?: boolean;
|
||||||
|
/* @internal */ extendedDiagnostics?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum BuildResultFlags {
|
enum BuildResultFlags {
|
||||||
|
@ -326,6 +328,11 @@ namespace ts {
|
||||||
|
|
||||||
reportDiagnostic: DiagnosticReporter; // Technically we want to move it out and allow steps of actions on Solution, but for now just merge stuff in build host here
|
reportDiagnostic: DiagnosticReporter; // Technically we want to move it out and allow steps of actions on Solution, but for now just merge stuff in build host here
|
||||||
reportSolutionBuilderStatus: DiagnosticReporter;
|
reportSolutionBuilderStatus: DiagnosticReporter;
|
||||||
|
|
||||||
|
// TODO: To do better with watch mode and normal build mode api that creates program and emits files
|
||||||
|
// This currently helps enable --diagnostics and --extendedDiagnostics
|
||||||
|
beforeCreateProgram?(options: CompilerOptions): void;
|
||||||
|
afterProgramEmitAndDiagnostics?(program: Program): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SolutionBuilderHost extends SolutionBuilderHostBase {
|
export interface SolutionBuilderHost extends SolutionBuilderHostBase {
|
||||||
|
@ -997,7 +1004,6 @@ namespace ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function buildSingleProject(proj: ResolvedConfigFileName): BuildResultFlags {
|
function buildSingleProject(proj: ResolvedConfigFileName): BuildResultFlags {
|
||||||
if (options.dry) {
|
if (options.dry) {
|
||||||
reportStatus(Diagnostics.A_non_dry_build_would_build_project_0, proj);
|
reportStatus(Diagnostics.A_non_dry_build_would_build_project_0, proj);
|
||||||
|
@ -1030,6 +1036,9 @@ namespace ts {
|
||||||
options: configFile.options,
|
options: configFile.options,
|
||||||
configFileParsingDiagnostics: configFile.errors
|
configFileParsingDiagnostics: configFile.errors
|
||||||
};
|
};
|
||||||
|
if (host.beforeCreateProgram) {
|
||||||
|
host.beforeCreateProgram(options);
|
||||||
|
}
|
||||||
const program = createProgram(programOptions);
|
const program = createProgram(programOptions);
|
||||||
|
|
||||||
// Don't emit anything in the presence of syntactic errors or options diagnostics
|
// Don't emit anything in the presence of syntactic errors or options diagnostics
|
||||||
|
@ -1089,12 +1098,18 @@ namespace ts {
|
||||||
};
|
};
|
||||||
diagnostics.removeKey(proj);
|
diagnostics.removeKey(proj);
|
||||||
projectStatus.setValue(proj, status);
|
projectStatus.setValue(proj, status);
|
||||||
|
if (host.afterProgramEmitAndDiagnostics) {
|
||||||
|
host.afterProgramEmitAndDiagnostics(program);
|
||||||
|
}
|
||||||
return resultFlags;
|
return resultFlags;
|
||||||
|
|
||||||
function buildErrors(diagnostics: ReadonlyArray<Diagnostic>, errorFlags: BuildResultFlags, errorType: string) {
|
function buildErrors(diagnostics: ReadonlyArray<Diagnostic>, errorFlags: BuildResultFlags, errorType: string) {
|
||||||
resultFlags |= errorFlags;
|
resultFlags |= errorFlags;
|
||||||
reportAndStoreErrors(proj, diagnostics);
|
reportAndStoreErrors(proj, diagnostics);
|
||||||
projectStatus.setValue(proj, { type: UpToDateStatusType.Unbuildable, reason: `${errorType} errors` });
|
projectStatus.setValue(proj, { type: UpToDateStatusType.Unbuildable, reason: `${errorType} errors` });
|
||||||
|
if (host.afterProgramEmitAndDiagnostics) {
|
||||||
|
host.afterProgramEmitAndDiagnostics(program);
|
||||||
|
}
|
||||||
return resultFlags;
|
return resultFlags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,11 +199,14 @@ namespace ts {
|
||||||
reportWatchModeWithoutSysSupport();
|
reportWatchModeWithoutSysSupport();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: change this to host if watch => watchHost otherwiue without wathc
|
// TODO: change this to host if watch => watchHost otherwiue without watch
|
||||||
const builder = createSolutionBuilder(buildOptions.watch ?
|
const buildHost = buildOptions.watch ?
|
||||||
createSolutionBuilderWithWatchHost(sys, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createWatchStatusReporter()) :
|
createSolutionBuilderWithWatchHost(sys, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createWatchStatusReporter()) :
|
||||||
createSolutionBuilderHost(sys, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createReportErrorSummary(buildOptions)),
|
createSolutionBuilderHost(sys, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createReportErrorSummary(buildOptions));
|
||||||
projects, buildOptions);
|
buildHost.beforeCreateProgram = enableStatistics;
|
||||||
|
buildHost.afterProgramEmitAndDiagnostics = reportStatistics;
|
||||||
|
|
||||||
|
const builder = createSolutionBuilder(buildHost, projects, buildOptions);
|
||||||
if (buildOptions.clean) {
|
if (buildOptions.clean) {
|
||||||
return sys.exit(builder.cleanAllProjects());
|
return sys.exit(builder.cleanAllProjects());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue