Skip to content

Commit b508533

Browse files
natebiggsCommit Queue
authored andcommitted
[dart2js] Add 'CONTEXT' diagnostic level option.
Metrics are using 'INFO' level diagnostics but these do not match the stated usage for INFO. This level was originally supposed to be used for contextual info about a previous warning/hint: https://github.com/dart-lang/sdk/blob/main/pkg/compiler/lib/compiler_api.dart#L44 These is logic that is preventing these metrics from being printed when they are logged following a hint and hints are turned off: https://github.com/dart-lang/sdk/blob/main/pkg/compiler/lib/src/source_file_provider.dart#L259. Instead we introduce a 'CONTEXT' for those contextual info messages and use 'INFO' as its own level of logging. Change-Id: Ie845f30dfd7d04fa9fe1d0a866e07c834dc64b32 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297280 Reviewed-by: Sigmund Cherem <[email protected]> Commit-Queue: Nate Biggs <[email protected]>
1 parent 82cffbb commit b508533

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

pkg/compiler/lib/compiler_api.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,7 @@ class Diagnostic {
3535
/// Any other warning that is not covered by [WARNING].
3636
static const Diagnostic HINT = const Diagnostic(4, 'hint');
3737

38-
/// Additional information about the preceding non-info diagnostic from the
39-
/// compiler.
40-
///
41-
/// For example, consider a duplicated definition. The compiler first emits a
42-
/// message about the duplicated definition, then emits an info message about
43-
/// the location of the existing definition.
38+
/// Informational message about the compiler.
4439
static const Diagnostic INFO = const Diagnostic(8, 'info');
4540

4641
/// Informational messages that shouldn't be printed unless
@@ -50,6 +45,14 @@ class Diagnostic {
5045
/// An internal error in the compiler.
5146
static const Diagnostic CRASH = const Diagnostic(32, 'crash');
5247

48+
/// Additional information about the preceding non-info diagnostic from the
49+
/// compiler.
50+
///
51+
/// For example, consider a duplicated definition. The compiler first emits a
52+
/// message about the duplicated definition, then emits an info message about
53+
/// the location of the existing definition.
54+
static const Diagnostic CONTEXT = const Diagnostic(64, 'context');
55+
5356
/// An [int] representation of this kind. The ordinals are designed
5457
/// to be used as bitsets.
5558
final int ordinal;

pkg/compiler/lib/src/compiler.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ class Compiler {
879879
List<DiagnosticMessage> infos, api.Diagnostic kind) {
880880
_reportDiagnosticMessage(message, kind);
881881
for (DiagnosticMessage info in infos) {
882-
_reportDiagnosticMessage(info, api.Diagnostic.INFO);
882+
_reportDiagnosticMessage(info, api.Diagnostic.CONTEXT);
883883
}
884884
}
885885

pkg/compiler/lib/src/source_file_provider.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ class FormattingDiagnosticHandler implements api.CompilerDiagnostics {
216216
return 'Hint: $message';
217217
case api.Diagnostic.CRASH:
218218
return 'Internal Error: $message';
219+
case api.Diagnostic.CONTEXT:
219220
case api.Diagnostic.INFO:
220221
case api.Diagnostic.VERBOSE_INFO:
221222
return 'Info: $message';
@@ -256,6 +257,8 @@ class FormattingDiagnosticHandler implements api.CompilerDiagnostics {
256257
} else if (kind == api.Diagnostic.CRASH) {
257258
color = colors.red;
258259
} else if (kind == api.Diagnostic.INFO) {
260+
color = colors.green;
261+
} else if (kind == api.Diagnostic.CONTEXT) {
259262
if (lastKind == api.Diagnostic.WARNING && !showWarnings) return;
260263
if (lastKind == api.Diagnostic.HINT && !showHints) return;
261264
color = colors.green;

0 commit comments

Comments
 (0)