Replace Severity.nit by Severity.ignored

Change-Id: Ib249c2e383c25173bd25b965bdb0d67c9a487cb4
Reviewed-on: https://dart-review.googlesource.com/59085
Reviewed-by: Aske Simon Christensen <askesc@google.com>
This commit is contained in:
Peter von der Ahé
2018-06-13 08:12:34 +00:00
committed by commit-bot@chromium.org
parent f3ce474673
commit 3d98cce456
20 changed files with 47 additions and 83 deletions
@@ -96,9 +96,6 @@ void reportFrontEndMessage(
case fe.Severity.warning:
reporter.reportWarningMessage(span, kind, {'text': message.message});
break;
case fe.Severity.nit:
reporter.reportHintMessage(span, kind, {'text': message.message});
break;
case fe.Severity.context:
reporter.reportInfo(span, kind, {'text': message.message});
break;
@@ -212,10 +212,4 @@ class CompilerOptions {
///
/// Typically used by developers to debug internals of the compiler.
bool throwOnWarningsForDebugging = false;
/// Whether the compiler should throw as soon as it encounters a
/// compilation nit.
///
/// Typically used by developers to debug internals of the compiler.
bool throwOnNitsForDebugging = false;
}
@@ -170,8 +170,6 @@ class ProcessedOptions {
bool get throwOnWarningsForDebugging => _raw.throwOnWarningsForDebugging;
bool get throwOnNitsForDebugging => _raw.throwOnNitsForDebugging;
/// The entry-points provided to the compiler.
final List<Uri> inputs;
@@ -630,7 +628,6 @@ class ProcessedOptions {
sb.writeln('throwOnErrorsForDebugging: ${throwOnErrorsForDebugging}');
sb.writeln('throwOnWarningsForDebugging: ${throwOnWarningsForDebugging}');
sb.writeln('throwOnNitsForDebugging: ${throwOnNitsForDebugging}');
sb.writeln('exit on problem: ${setExitCodeOnProblem}');
sb.writeln('Embed sources: ${embedSourceText}');
sb.writeln('debugDump: ${debugDump}');
@@ -12,7 +12,7 @@ import 'dart:io' show exitCode;
import 'package:kernel/ast.dart' show Location;
import 'colors.dart' show cyan, green, magenta, red;
import 'colors.dart' show green, magenta, red;
import 'compiler_context.dart' show CompilerContext;
@@ -23,7 +23,7 @@ import 'fasta_codes.dart' show LocatedMessage;
import 'messages.dart' show getLocation, getSourceLine, isVerbose;
import 'problems.dart' show unexpected;
import 'problems.dart' show unhandled;
import 'severity.dart' show Severity;
@@ -54,10 +54,6 @@ String format(LocatedMessage message, Severity severity, {Location location}) {
text = red(text);
break;
case Severity.nit:
text = cyan(text);
break;
case Severity.warning:
text = magenta(text);
break;
@@ -67,7 +63,7 @@ String format(LocatedMessage message, Severity severity, {Location location}) {
break;
default:
return unexpected("$severity", "format", -1, null);
return unhandled("$severity", "format", -1, null);
}
}
@@ -95,7 +91,7 @@ String format(LocatedMessage message, Severity severity, {Location location}) {
sourceLine = "\n$sourceLine\n$pointer";
}
String position =
location == null ? "" : ":${location.line}:${location.column}";
location == null ? ":1" : ":${location.line}:${location.column}";
return "$path$position: $text$sourceLine";
} else {
return text;
@@ -117,14 +113,11 @@ bool isHidden(Severity severity) {
case Severity.context:
return false;
case Severity.nit:
return !isVerbose;
case Severity.warning:
return hideWarnings;
default:
return unexpected("$severity", "isHidden", -1, null);
return unhandled("$severity", "isHidden", -1, null);
}
}
@@ -138,9 +131,6 @@ bool shouldThrowOn(Severity severity) {
case Severity.internalProblem:
return true;
case Severity.nit:
return CompilerContext.current.options.throwOnNitsForDebugging;
case Severity.warning:
return CompilerContext.current.options.throwOnWarningsForDebugging;
@@ -148,7 +138,7 @@ bool shouldThrowOn(Severity severity) {
return false;
default:
return unexpected("$severity", "shouldThrowOn", -1, null);
return unhandled("$severity", "shouldThrowOn", -1, null);
}
}
@@ -161,9 +151,6 @@ String severityName(Severity severity, {bool capitalized: false}) {
case Severity.internalProblem:
return capitalized ? "Internal problem" : "internal problem";
case Severity.nit:
return capitalized ? "Nit" : "nit";
case Severity.warning:
return capitalized ? "Warning" : "warning";
@@ -171,7 +158,7 @@ String severityName(Severity severity, {bool capitalized: false}) {
return capitalized ? "Context" : "context";
default:
return unexpected("$severity", "severityName", -1, null);
return unhandled("$severity", "severityName", -1, null);
}
}
@@ -208,12 +195,14 @@ bool isCompileTimeError(Severity severity) {
case Severity.errorLegacyWarning:
return CompilerContext.current.options.strongMode;
case Severity.nit:
case Severity.warning:
case Severity.context:
return false;
case Severity.ignored:
break; // Fall-through to unhandled below.
}
return unexpected("$severity", "isCompileTimeError", -1, null);
return unhandled("$severity", "isCompileTimeError", -1, null);
}
/// Report [message] unless [severity] is suppressed (see [isHidden]). Throws
@@ -1477,7 +1477,7 @@ const Code<Message Function(String name, Uri uri_, Uri uri2_)>
"DuplicatedExport", templateDuplicatedExport,
analyzerCode: "AMBIGUOUS_EXPORT",
dart2jsCode: "*ignored*",
severity: Severity.nit);
severity: Severity.ignored);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsDuplicatedExport(String name, Uri uri_, Uri uri2_) {
@@ -1525,7 +1525,7 @@ const Code<Message Function(String name, Uri uri_, Uri uri2_)>
codeDuplicatedImport =
const Code<Message Function(String name, Uri uri_, Uri uri2_)>(
"DuplicatedImport", templateDuplicatedImport,
severity: Severity.nit);
severity: Severity.ignored);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsDuplicatedImport(String name, Uri uri_, Uri uri2_) {
@@ -2133,7 +2133,7 @@ const Code<Message Function(String name, Uri uri_, Uri uri2_)>
codeExportHidesExport =
const Code<Message Function(String name, Uri uri_, Uri uri2_)>(
"ExportHidesExport", templateExportHidesExport,
severity: Severity.nit);
severity: Severity.ignored);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsExportHidesExport(String name, Uri uri_, Uri uri2_) {
@@ -2433,7 +2433,6 @@ const MessageCode messageFastaUsageLong =
--fatal=errors
--fatal=warnings
--fatal=nits
Makes messages of the given kinds fatal, that is, immediately stop the
compiler with a non-zero exit-code. In --verbose mode, also display an
internal stack trace from the compiler. Multiple kinds can be separated by
@@ -2792,7 +2791,7 @@ const Code<Message Function(String name, Uri uri_, Uri uri2_)>
codeImportHidesImport =
const Code<Message Function(String name, Uri uri_, Uri uri2_)>(
"ImportHidesImport", templateImportHidesImport,
severity: Severity.nit);
severity: Severity.ignored);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsImportHidesImport(String name, Uri uri_, Uri uri2_) {
@@ -3815,7 +3814,7 @@ const Template<
const Code<Message Function(Uri uri_)> codeLoadLibraryHidesMember =
const Code<Message Function(Uri uri_)>(
"LoadLibraryHidesMember", templateLoadLibraryHidesMember,
severity: Severity.nit);
severity: Severity.ignored);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsLoadLibraryHidesMember(Uri uri_) {
@@ -3850,7 +3849,7 @@ const Code<Message Function(String name, Uri uri_)>
codeLocalDefinitionHidesExport =
const Code<Message Function(String name, Uri uri_)>(
"LocalDefinitionHidesExport", templateLocalDefinitionHidesExport,
severity: Severity.nit);
severity: Severity.ignored);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsLocalDefinitionHidesExport(String name, Uri uri_) {
@@ -3873,7 +3872,7 @@ const Code<Message Function(String name, Uri uri_)>
codeLocalDefinitionHidesImport =
const Code<Message Function(String name, Uri uri_)>(
"LocalDefinitionHidesImport", templateLocalDefinitionHidesImport,
severity: Severity.nit);
severity: Severity.ignored);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsLocalDefinitionHidesImport(String name, Uri uri_) {
+1
View File
@@ -237,6 +237,7 @@ abstract class Loader<L> {
bool addMessage(Message message, int charOffset, int length, Uri fileUri,
Severity severity,
{bool wasHandled: false, List<LocatedMessage> context}) {
if (severity == Severity.ignored) return false;
String trace = """
message: ${message.message}
charOffset: $charOffset
+3 -3
View File
@@ -8,8 +8,8 @@ enum Severity {
context,
error,
errorLegacyWarning,
ignored,
internalProblem,
nit,
warning,
}
@@ -17,8 +17,8 @@ const Map<String, String> severityEnumNames = const <String, String>{
'CONTEXT': 'context',
'ERROR': 'error',
'ERROR_LEGACY_WARNING': 'errorLegacyWarning',
'IGNORED': 'ignored',
'INTERNAL_PROBLEM': 'internalProblem',
'NIT': 'nit',
'WARNING': 'warning',
};
@@ -26,7 +26,7 @@ const Map<String, Severity> severityEnumValues = const <String, Severity>{
'CONTEXT': Severity.context,
'ERROR': Severity.error,
'ERROR_LEGACY_WARNING': Severity.errorLegacyWarning,
'IGNORED': Severity.ignored,
'INTERNAL_PROBLEM': Severity.internalProblem,
'NIT': Severity.nit,
'WARNING': Severity.warning,
};
@@ -80,7 +80,7 @@ import '../parser/class_member_parser.dart' show ClassMemberParser;
import '../parser.dart' show Parser, lengthForToken, offsetForToken;
import '../problems.dart' show internalProblem;
import '../problems.dart' show internalProblem, unhandled;
import '../scanner.dart' show ErrorToken, ScannerResult, Token, scan;
@@ -862,8 +862,7 @@ class SourceLoader<L> extends Loader<L> {
if (instrumentation == null) return;
if (charOffset == -1 &&
(severity == Severity.nit ||
message.code == fasta_codes.codeConstConstructorWithBody ||
(message.code == fasta_codes.codeConstConstructorWithBody ||
message.code == fasta_codes.codeConstructorNotFound ||
message.code == fasta_codes.codeSuperclassHasNoDefaultConstructor ||
message.code == fasta_codes.codeTypeArgumentsOnTypeVariable ||
@@ -883,10 +882,6 @@ class SourceLoader<L> extends Loader<L> {
severityString = "internal problem";
break;
case Severity.nit:
severityString = "nit";
break;
case Severity.warning:
severityString = "warning";
break;
@@ -900,6 +895,10 @@ class SourceLoader<L> extends Loader<L> {
case Severity.context:
severityString = "context";
break;
case Severity.ignored:
unhandled("IGNORED", "recordMessage", charOffset, fileUri);
return;
}
instrumentation.record(
fileUri,
+7 -8
View File
@@ -1149,7 +1149,7 @@ LoadLibraryTakesNoArguments:
LoadLibraryHidesMember:
template: "The library '#uri' defines a top-level member named 'loadLibrary'. This member is hidden by the special member 'loadLibrary' that the language adds to support deferred loading."
tip: "Try to rename or hide the member."
severity: NIT
severity: IGNORED
TypeArgumentMismatch:
template: "'#name' expects #count type arguments."
@@ -1229,7 +1229,6 @@ FastaUsageLong:
--fatal=errors
--fatal=warnings
--fatal=nits
Makes messages of the given kinds fatal, that is, immediately stop the
compiler with a non-zero exit-code. In --verbose mode, also display an
internal stack trace from the compiler. Multiple kinds can be separated by
@@ -1343,19 +1342,19 @@ InternalVisitorUnsupportedDefault:
LocalDefinitionHidesExport:
template: "Local definition of '#name' hides export from '#uri'."
severity: NIT
severity: IGNORED
LocalDefinitionHidesImport:
template: "Local definition of '#name' hides import from '#uri'."
severity: NIT
severity: IGNORED
ExportHidesExport:
template: "Export of '#name' (from '#uri') hides export from '#uri2'."
severity: NIT
severity: IGNORED
ImportHidesImport:
template: "Import of '#name' (from '#uri') hides import from '#uri2'."
severity: NIT
severity: IGNORED
MissingPrefixInDeferredImport:
template: "Deferred imports should have a prefix."
@@ -1396,7 +1395,7 @@ PrefixAfterCombinator:
DuplicatedExport:
template: "'#name' is exported from both '#uri' and '#uri2'."
severity: NIT
severity: IGNORED
analyzerCode: AMBIGUOUS_EXPORT
dart2jsCode: "*ignored*"
@@ -1406,7 +1405,7 @@ DuplicatedExportInType:
DuplicatedImport:
template: "'#name' is imported from both '#uri' and '#uri2'."
severity: NIT
severity: IGNORED
DuplicatedImportInType:
template: "'#name' is imported from both '#uri' and '#uri2'."
@@ -220,8 +220,7 @@ Future<Context> createContext(
..fileSystem = fs
..sdkSummary = sdkSummary
..onError = (CompilationMessage message) {
if (message.severity != Severity.nit &&
message.severity != Severity.warning) {
if (message.severity != Severity.warning) {
errors.add(message);
}
};
@@ -19,7 +19,7 @@ class Fisk extends core::Object {
for (final dynamic #t3 = let dynamic _ = null in invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:17:10: Error: Can't assign to this, so it can't be used in a for-in loop.
for (collection in x) {
^^^^^^^^^^" in x) {
core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart: Error: A library can't be used as an expression.");
core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:1: Error: A library can't be used as an expression.");
}
for (final dynamic #t4 in x) {
let dynamic _ = null in throw new core::NoSuchMethodError::withInvocation(null, new core::_InvocationMirror::_withType(#VoidFunction, 34, const <core::Type>[], core::List::unmodifiable<dynamic>(<dynamic>[#t4]), core::Map::unmodifiable<core::Symbol, dynamic>(const <core::Symbol, dynamic>{})));
@@ -50,7 +50,7 @@ static method main(dynamic arguments) → dynamic {
for (final dynamic #t8 = let dynamic _ = null in invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:37:8: Error: Can't assign to this, so it can't be used in a for-in loop.
for (collection in arguments) {
^^^^^^^^^^" in arguments) {
core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart: Error: A library can't be used as an expression.");
core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:1: Error: A library can't be used as an expression.");
}
for (final dynamic #t9 in arguments) {
let dynamic _ = null in throw new core::NoSuchMethodError::withInvocation(null, new core::_InvocationMirror::_withType(#VoidFunction, 34, const <core::Type>[], core::List::unmodifiable<dynamic>(<dynamic>[#t9]), core::Map::unmodifiable<core::Symbol, dynamic>(const <core::Symbol, dynamic>{})));
@@ -19,7 +19,7 @@ class Fisk extends core::Object {
for (final dynamic #t3 = let dynamic _ = null in invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:17:10: Error: Can't assign to this, so it can't be used in a for-in loop.
for (collection in x) {
^^^^^^^^^^" in x) {
core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart: Error: A library can't be used as an expression.");
core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:1: Error: A library can't be used as an expression.");
}
for (final dynamic #t4 in x) {
let dynamic _ = null in throw new core::NoSuchMethodError::withInvocation(null, new core::_InvocationMirror::_withType(#VoidFunction, 34, const <core::Type>[], core::List::unmodifiable<dynamic>(<dynamic>[#t4]), core::Map::unmodifiable<core::Symbol, dynamic>(const <core::Symbol, dynamic>{})));
@@ -50,7 +50,7 @@ static method main(dynamic arguments) → dynamic {
for (final dynamic #t8 = let dynamic _ = null in invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:37:8: Error: Can't assign to this, so it can't be used in a for-in loop.
for (collection in arguments) {
^^^^^^^^^^" in arguments) {
core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart: Error: A library can't be used as an expression.");
core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:1: Error: A library can't be used as an expression.");
}
for (final dynamic #t9 in arguments) {
let dynamic _ = null in throw new core::NoSuchMethodError::withInvocation(null, new core::_InvocationMirror::_withType(#VoidFunction, 34, const <core::Type>[], core::List::unmodifiable<dynamic>(<dynamic>[#t9]), core::Map::unmodifiable<core::Symbol, dynamic>(const <core::Symbol, dynamic>{})));
@@ -2,5 +2,5 @@ library;
import self as self;
static method #main() → dynamic {
throw "dart:html: Error: Not found: dart:html.";
throw "dart:html:1: Error: Not found: dart:html.";
}
@@ -2,5 +2,5 @@ library;
import self as self;
static method #main() → dynamic {
throw "dart:html: Error: Not found: dart:html.";
throw "dart:html:1: Error: Not found: dart:html.";
}
@@ -8,7 +8,7 @@ class Typed<T extends core::Object = dynamic> extends core::Object {
: super core::Object::•()
;
}
static const field dynamic #errors = const <dynamic>["pkg/front_end/testcases/regress/issue_31190.dart: Error: Can't use type arguments with type variable 'T'.
static const field dynamic #errors = const <dynamic>["pkg/front_end/testcases/regress/issue_31190.dart:1: Error: Can't use type arguments with type variable 'T'.
Try removing the type arguments.", "pkg/front_end/testcases/regress/issue_31190.dart:6:5: Error: 'U' isn't a type.
T<U> v;
^", "pkg/front_end/testcases/regress/issue_31190.dart:6:3: Error: 'T' expects 0 type arguments.
@@ -8,7 +8,7 @@ class Typed<T extends core::Object = dynamic> extends core::Object {
: super core::Object::•()
;
}
static const field dynamic #errors = const <dynamic>["pkg/front_end/testcases/regress/issue_31190.dart: Error: Can't use type arguments with type variable 'T'.
static const field dynamic #errors = const <dynamic>["pkg/front_end/testcases/regress/issue_31190.dart:1: Error: Can't use type arguments with type variable 'T'.
Try removing the type arguments.", "pkg/front_end/testcases/regress/issue_31190.dart:6:5: Error: 'U' isn't a type.
T<U> v;
^", "pkg/front_end/testcases/regress/issue_31190.dart:6:3: Error: 'T' expects 0 type arguments.
@@ -277,8 +277,6 @@ ProcessedOptions analyzeCommandLine(
final bool warningsAreFatal = fatal.contains("warnings");
final bool nitsAreFatal = fatal.contains("nits");
final bool compileSdk = options.containsKey("--compile-sdk");
if (programName == "compile_platform") {
@@ -305,7 +303,6 @@ ProcessedOptions analyzeCommandLine(
..target = target
..throwOnErrorsForDebugging = errorsAreFatal
..throwOnWarningsForDebugging = warningsAreFatal
..throwOnNitsForDebugging = nitsAreFatal
..embedSourceText = !excludeSource
..debugDump = dumpIr
..verbose = verbose
@@ -336,7 +333,6 @@ ProcessedOptions analyzeCommandLine(
..target = target
..throwOnErrorsForDebugging = errorsAreFatal
..throwOnWarningsForDebugging = warningsAreFatal
..throwOnNitsForDebugging = nitsAreFatal
..embedSourceText = !excludeSource
..debugDump = dumpIr
..verbose = verbose
+1 -3
View File
@@ -109,14 +109,12 @@ abstract class Compiler {
printMessage = false; // errors are printed by VM
errors.add(message.formatted);
break;
case Severity.nit:
printMessage = false;
break;
case Severity.warning:
printMessage = !suppressWarnings;
break;
case Severity.errorLegacyWarning:
case Severity.context:
case Severity.ignored:
throw "Unexpected severity: $severity";
}
if (printMessage) {
+1 -3
View File
@@ -263,14 +263,12 @@ class FrontendCompiler implements CompilerInterface {
printMessage = true;
errors.add(message.formatted);
break;
case Severity.nit:
printMessage = false;
break;
case Severity.warning:
printMessage = true;
break;
case Severity.errorLegacyWarning:
case Severity.context:
case Severity.ignored:
throw 'Unexpected severity: $severity';
}
if (printMessage) {
+1 -3
View File
@@ -138,9 +138,7 @@ Future<bool> computeSummary(List<String> args,
for (fe.FormattedMessage message in context) {
out.println(message.formatted);
}
if (severity != fe.Severity.nit) {
succeeded = false;
}
succeeded = false;
}
var summary = await fe.compile(state, sources, onProblem);