Merge pull request #28607 from Microsoft/extendedDiagnostics

Enable statistics reporting per program through temporary build api
This commit is contained in:
Sheetal Nandi 2018-11-19 14:25:50 -08:00 committed by GitHub
commit 07769483e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 17 deletions

View file

@ -119,6 +119,18 @@ namespace ts {
category: Diagnostics.Advanced_Options,
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 */
@ -592,18 +604,6 @@ namespace ts {
category: Diagnostics.Advanced_Options,
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",
type: "boolean",

View file

@ -32,6 +32,8 @@ namespace ts {
pretty?: boolean;
traceResolution?: boolean;
/* @internal */ diagnostics?: boolean;
/* @internal */ extendedDiagnostics?: boolean;
}
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
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 {
@ -997,7 +1004,6 @@ namespace ts {
}
}
function buildSingleProject(proj: ResolvedConfigFileName): BuildResultFlags {
if (options.dry) {
reportStatus(Diagnostics.A_non_dry_build_would_build_project_0, proj);
@ -1030,6 +1036,9 @@ namespace ts {
options: configFile.options,
configFileParsingDiagnostics: configFile.errors
};
if (host.beforeCreateProgram) {
host.beforeCreateProgram(options);
}
const program = createProgram(programOptions);
// Don't emit anything in the presence of syntactic errors or options diagnostics
@ -1089,12 +1098,18 @@ namespace ts {
};
diagnostics.removeKey(proj);
projectStatus.setValue(proj, status);
if (host.afterProgramEmitAndDiagnostics) {
host.afterProgramEmitAndDiagnostics(program);
}
return resultFlags;
function buildErrors(diagnostics: ReadonlyArray<Diagnostic>, errorFlags: BuildResultFlags, errorType: string) {
resultFlags |= errorFlags;
reportAndStoreErrors(proj, diagnostics);
projectStatus.setValue(proj, { type: UpToDateStatusType.Unbuildable, reason: `${errorType} errors` });
if (host.afterProgramEmitAndDiagnostics) {
host.afterProgramEmitAndDiagnostics(program);
}
return resultFlags;
}
}

View file

@ -199,11 +199,14 @@ namespace ts {
reportWatchModeWithoutSysSupport();
}
// TODO: change this to host if watch => watchHost otherwiue without wathc
const builder = createSolutionBuilder(buildOptions.watch ?
// TODO: change this to host if watch => watchHost otherwiue without watch
const buildHost = buildOptions.watch ?
createSolutionBuilderWithWatchHost(sys, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createWatchStatusReporter()) :
createSolutionBuilderHost(sys, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createReportErrorSummary(buildOptions)),
projects, buildOptions);
createSolutionBuilderHost(sys, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createReportErrorSummary(buildOptions));
buildHost.beforeCreateProgram = enableStatistics;
buildHost.afterProgramEmitAndDiagnostics = reportStatistics;
const builder = createSolutionBuilder(buildHost, projects, buildOptions);
if (buildOptions.clean) {
return sys.exit(builder.cleanAllProjects());
}