Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Unified Diff: pkg/analyzer_experimental/lib/src/error_formatter.dart

Issue 24669002: Support for --no-hints in analyzer_experimental. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix hint check; print hints in Dart verison. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer_experimental/lib/src/error_formatter.dart
diff --git a/pkg/analyzer_experimental/lib/src/error_formatter.dart b/pkg/analyzer_experimental/lib/src/error_formatter.dart
index 47d718db1cd39b3dd61afe61fa329e2bb8bd36ea..c26aaa4a5ab7a42b67c21ba906d7cfaec7a9406a 100644
--- a/pkg/analyzer_experimental/lib/src/error_formatter.dart
+++ b/pkg/analyzer_experimental/lib/src/error_formatter.dart
@@ -46,41 +46,62 @@ class ErrorFormatter {
// format errors
int errorCount = 0;
int warnCount = 0;
+ int hintCount = 0;
for (AnalysisError error in errors) {
- if (error.errorCode.errorSeverity == ErrorSeverity.ERROR) {
+ var severity = error.errorCode.errorSeverity;
+ if (severity == ErrorSeverity.ERROR) {
errorCount++;
- } else if (error.errorCode.errorSeverity == ErrorSeverity.WARNING) {
+ } else if (severity == ErrorSeverity.WARNING) {
if (options.warningsAreFatal) {
errorCount++;
} else {
- warnCount++;
+ if (error.errorCode.type == ErrorType.HINT) {
+ hintCount++;
+ } else {
+ warnCount++;
+ }
}
}
formatError(errorToLine, error);
}
// print statistics
if (!options.machineFormat) {
- if (errorCount != 0 && warnCount != 0) {
+ var hasErrors = errorCount != 0;
+ var hasWarns = warnCount != 0;
+ var hasHints = hintCount != 0;
+ bool hasContent = false;
+ if (hasErrors) {
out.write(errorCount);
out.write(' ');
out.write(pluralize("error", errorCount));
- out.write(' and ');
+ hasContent = true;
+ }
+ if (hasWarns) {
+ if (hasContent) {
+ if (!hasHints) {
+ out.write(' and ');
+ } else {
+ out.write(", ");
+ }
+ }
out.write(warnCount);
out.write(' ');
out.write(pluralize("warning", warnCount));
- out.writeln(' found.');
- } else if (errorCount != 0) {
- out.write(errorCount);
- out.write(' ');
- out.write(pluralize("error", errorCount));
- out.writeln(' found.');
- } else if (warnCount != 0) {
- out.write(warnCount);
+ hasContent = true;
+ }
+ if (hasHints) {
+ if (hasContent) {
+ out.write(" and ");
+ }
+ out.write(hintCount);
out.write(' ');
- out.write(pluralize("warning", warnCount));
- out.writeln(' found.');
+ out.write(pluralize("hint", hintCount));
+ hasContent = true;
+ }
+ if (hasContent) {
+ out.writeln(" found.");
} else {
- out.writeln("No issues found.");
+ out.writeln("No issues found");
}
}
}
@@ -110,8 +131,12 @@ class ErrorFormatter {
out.write('|');
out.write(escapePipe(error.message));
} else {
+ String errorType = error.errorCode.errorSeverity.displayName;
+ if (error.errorCode.type == ErrorType.HINT) {
+ errorType = error.errorCode.type.displayName;
+ }
// [warning] 'foo' is not a... (/Users/.../tmp/foo.dart, line 1, col 2)
- out.write('[${severity.displayName}] ${error.message} ');
+ out.write('[$errorType] ${error.message} ');
out.write('(${source.fullName}');
out.write(', line ${location.lineNumber}, col ${location.columnNumber})');
}
« no previous file with comments | « pkg/analyzer_experimental/lib/src/analyzer_impl.dart ('k') | pkg/analyzer_experimental/lib/src/generated/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698