mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
Separate severity for context messages
Change-Id: I8c0f9f0eae141e38e1f57afce4a30b6f95e8e412 Reviewed-on: https://dart-review.googlesource.com/43721 Reviewed-by: Peter von der Ahé <ahe@google.com> Commit-Queue: Aske Simon Christensen <askesc@google.com>
This commit is contained in:
parent
af527dd769
commit
bb088347f0
|
@ -99,6 +99,9 @@ void reportFrontEndMessage(
|
||||||
case fe.Severity.nit:
|
case fe.Severity.nit:
|
||||||
reporter.reportHintMessage(span, kind, {'text': message.message});
|
reporter.reportHintMessage(span, kind, {'text': message.message});
|
||||||
break;
|
break;
|
||||||
|
case fe.Severity.context:
|
||||||
|
reporter.reportInfo(span, kind, {'text': message.message});
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new UnimplementedError('unhandled severity ${message.severity}');
|
throw new UnimplementedError('unhandled severity ${message.severity}');
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import 'dart:io' show exitCode;
|
||||||
|
|
||||||
import 'package:kernel/ast.dart' show Location;
|
import 'package:kernel/ast.dart' show Location;
|
||||||
|
|
||||||
import 'colors.dart' show cyan, magenta, red;
|
import 'colors.dart' show cyan, green, magenta, red;
|
||||||
|
|
||||||
import 'compiler_context.dart' show CompilerContext;
|
import 'compiler_context.dart' show CompilerContext;
|
||||||
|
|
||||||
|
@ -68,6 +68,10 @@ String formatInternal(
|
||||||
text = magenta(text);
|
text = magenta(text);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Severity.context:
|
||||||
|
text = green(text);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return unexpected("$severity", "formatInternal", -1, null);
|
return unexpected("$severity", "formatInternal", -1, null);
|
||||||
}
|
}
|
||||||
|
@ -115,6 +119,7 @@ bool isHidden(Severity severity) {
|
||||||
switch (severity) {
|
switch (severity) {
|
||||||
case Severity.error:
|
case Severity.error:
|
||||||
case Severity.internalProblem:
|
case Severity.internalProblem:
|
||||||
|
case Severity.context:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case Severity.nit:
|
case Severity.nit:
|
||||||
|
@ -144,6 +149,9 @@ bool shouldThrowOn(Severity severity) {
|
||||||
case Severity.warning:
|
case Severity.warning:
|
||||||
return CompilerContext.current.options.throwOnWarningsForDebugging;
|
return CompilerContext.current.options.throwOnWarningsForDebugging;
|
||||||
|
|
||||||
|
case Severity.context:
|
||||||
|
return false;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return unexpected("$severity", "shouldThrowOn", -1, null);
|
return unexpected("$severity", "shouldThrowOn", -1, null);
|
||||||
}
|
}
|
||||||
|
@ -164,6 +172,9 @@ String severityName(Severity severity, {bool capitalized: false}) {
|
||||||
case Severity.warning:
|
case Severity.warning:
|
||||||
return capitalized ? "Warning" : "warning";
|
return capitalized ? "Warning" : "warning";
|
||||||
|
|
||||||
|
case Severity.context:
|
||||||
|
return capitalized ? "Context" : "context";
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return unexpected("$severity", "severityName", -1, null);
|
return unexpected("$severity", "severityName", -1, null);
|
||||||
}
|
}
|
||||||
|
@ -204,6 +215,7 @@ bool isCompileTimeError(Severity severity) {
|
||||||
|
|
||||||
case Severity.nit:
|
case Severity.nit:
|
||||||
case Severity.warning:
|
case Severity.warning:
|
||||||
|
case Severity.context:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return unexpected("$severity", "isCompileTimeError", -1, null);
|
return unexpected("$severity", "isCompileTimeError", -1, null);
|
||||||
|
|
|
@ -288,6 +288,7 @@ const Code<Null> codeCandidateFound = messageCandidateFound;
|
||||||
|
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
const MessageCode messageCandidateFound = const MessageCode("CandidateFound",
|
const MessageCode messageCandidateFound = const MessageCode("CandidateFound",
|
||||||
|
severity: Severity.context,
|
||||||
message: r"""Found this candidate, but the arguments don't match.""");
|
message: r"""Found this candidate, but the arguments don't match.""");
|
||||||
|
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
|
@ -304,7 +305,7 @@ const Code<Message Function(String name)>
|
||||||
const Code<Message Function(String name)>(
|
const Code<Message Function(String name)>(
|
||||||
"CandidateFoundIsDefaultConstructor",
|
"CandidateFoundIsDefaultConstructor",
|
||||||
templateCandidateFoundIsDefaultConstructor,
|
templateCandidateFoundIsDefaultConstructor,
|
||||||
);
|
severity: Severity.context);
|
||||||
|
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
Message _withArgumentsCandidateFoundIsDefaultConstructor(String name) {
|
Message _withArgumentsCandidateFoundIsDefaultConstructor(String name) {
|
||||||
|
@ -635,7 +636,7 @@ const Code<Null> codeConflictsWithTypeVariableCause =
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
const MessageCode messageConflictsWithTypeVariableCause = const MessageCode(
|
const MessageCode messageConflictsWithTypeVariableCause = const MessageCode(
|
||||||
"ConflictsWithTypeVariableCause",
|
"ConflictsWithTypeVariableCause",
|
||||||
severity: Severity.error,
|
severity: Severity.context,
|
||||||
message: r"""This is the type variable.""");
|
message: r"""This is the type variable.""");
|
||||||
|
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
|
@ -709,6 +710,7 @@ const Code<Null> codeConstConstructorNonFinalFieldCause =
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
const MessageCode messageConstConstructorNonFinalFieldCause = const MessageCode(
|
const MessageCode messageConstConstructorNonFinalFieldCause = const MessageCode(
|
||||||
"ConstConstructorNonFinalFieldCause",
|
"ConstConstructorNonFinalFieldCause",
|
||||||
|
severity: Severity.context,
|
||||||
message: r"""Field isn't final, but constructor is 'const'.""");
|
message: r"""Field isn't final, but constructor is 'const'.""");
|
||||||
|
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
|
@ -984,9 +986,8 @@ const Template<Message Function(String name)>
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
const Code<Message Function(String name)> codeDeferredPrefixDuplicatedCause =
|
const Code<Message Function(String name)> codeDeferredPrefixDuplicatedCause =
|
||||||
const Code<Message Function(String name)>(
|
const Code<Message Function(String name)>(
|
||||||
"DeferredPrefixDuplicatedCause",
|
"DeferredPrefixDuplicatedCause", templateDeferredPrefixDuplicatedCause,
|
||||||
templateDeferredPrefixDuplicatedCause,
|
severity: Severity.context);
|
||||||
);
|
|
||||||
|
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
Message _withArgumentsDeferredPrefixDuplicatedCause(String name) {
|
Message _withArgumentsDeferredPrefixDuplicatedCause(String name) {
|
||||||
|
@ -1292,9 +1293,8 @@ const Template<Message Function(String name)>
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
const Code<Message Function(String name)> codeDuplicatedParameterNameCause =
|
const Code<Message Function(String name)> codeDuplicatedParameterNameCause =
|
||||||
const Code<Message Function(String name)>(
|
const Code<Message Function(String name)>(
|
||||||
"DuplicatedParameterNameCause",
|
"DuplicatedParameterNameCause", templateDuplicatedParameterNameCause,
|
||||||
templateDuplicatedParameterNameCause,
|
severity: Severity.context);
|
||||||
);
|
|
||||||
|
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
Message _withArgumentsDuplicatedParameterNameCause(String name) {
|
Message _withArgumentsDuplicatedParameterNameCause(String name) {
|
||||||
|
@ -2083,7 +2083,7 @@ const Code<Message Function(String name)>
|
||||||
const Code<Message Function(String name)>(
|
const Code<Message Function(String name)>(
|
||||||
"FinalInstanceVariableAlreadyInitializedCause",
|
"FinalInstanceVariableAlreadyInitializedCause",
|
||||||
templateFinalInstanceVariableAlreadyInitializedCause,
|
templateFinalInstanceVariableAlreadyInitializedCause,
|
||||||
severity: Severity.errorLegacyWarning);
|
severity: Severity.context);
|
||||||
|
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
Message _withArgumentsFinalInstanceVariableAlreadyInitializedCause(
|
Message _withArgumentsFinalInstanceVariableAlreadyInitializedCause(
|
||||||
|
@ -2265,7 +2265,7 @@ const Code<Message Function(String name)>
|
||||||
const Code<Message Function(String name)>(
|
const Code<Message Function(String name)>(
|
||||||
"IllegalMixinDueToConstructorsCause",
|
"IllegalMixinDueToConstructorsCause",
|
||||||
templateIllegalMixinDueToConstructorsCause,
|
templateIllegalMixinDueToConstructorsCause,
|
||||||
);
|
severity: Severity.context);
|
||||||
|
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
Message _withArgumentsIllegalMixinDueToConstructorsCause(String name) {
|
Message _withArgumentsIllegalMixinDueToConstructorsCause(String name) {
|
||||||
|
@ -3867,9 +3867,8 @@ const Template<Message Function(String name)> templateOverriddenMethodCause =
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
const Code<Message Function(String name)> codeOverriddenMethodCause =
|
const Code<Message Function(String name)> codeOverriddenMethodCause =
|
||||||
const Code<Message Function(String name)>(
|
const Code<Message Function(String name)>(
|
||||||
"OverriddenMethodCause",
|
"OverriddenMethodCause", templateOverriddenMethodCause,
|
||||||
templateOverriddenMethodCause,
|
severity: Severity.context);
|
||||||
);
|
|
||||||
|
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
Message _withArgumentsOverriddenMethodCause(String name) {
|
Message _withArgumentsOverriddenMethodCause(String name) {
|
||||||
|
@ -4262,6 +4261,7 @@ const Code<Null> codePatchClassOrigin = messagePatchClassOrigin;
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
const MessageCode messagePatchClassOrigin = const MessageCode(
|
const MessageCode messagePatchClassOrigin = const MessageCode(
|
||||||
"PatchClassOrigin",
|
"PatchClassOrigin",
|
||||||
|
severity: Severity.context,
|
||||||
message: r"""This is the origin class.""");
|
message: r"""This is the origin class.""");
|
||||||
|
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
|
@ -4288,6 +4288,7 @@ const Code<Null> codePatchDeclarationOrigin = messagePatchDeclarationOrigin;
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
const MessageCode messagePatchDeclarationOrigin = const MessageCode(
|
const MessageCode messagePatchDeclarationOrigin = const MessageCode(
|
||||||
"PatchDeclarationOrigin",
|
"PatchDeclarationOrigin",
|
||||||
|
severity: Severity.context,
|
||||||
message: r"""This is the origin declaration.""");
|
message: r"""This is the origin declaration.""");
|
||||||
|
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
|
@ -5239,10 +5240,9 @@ const Template<Message Function(String name)>
|
||||||
|
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
const Code<Message Function(String name)> codeTypeVariableDuplicatedNameCause =
|
const Code<Message Function(String name)> codeTypeVariableDuplicatedNameCause =
|
||||||
const Code<Message Function(String name)>(
|
const Code<Message Function(String name)>("TypeVariableDuplicatedNameCause",
|
||||||
"TypeVariableDuplicatedNameCause",
|
|
||||||
templateTypeVariableDuplicatedNameCause,
|
templateTypeVariableDuplicatedNameCause,
|
||||||
);
|
severity: Severity.context);
|
||||||
|
|
||||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||||
Message _withArgumentsTypeVariableDuplicatedNameCause(String name) {
|
Message _withArgumentsTypeVariableDuplicatedNameCause(String name) {
|
||||||
|
|
|
@ -3613,12 +3613,10 @@ class BodyBuilder<Arguments> extends ScopeListener<JumpTarget>
|
||||||
fasta.templateFinalInstanceVariableAlreadyInitialized
|
fasta.templateFinalInstanceVariableAlreadyInitialized
|
||||||
.withArguments(name),
|
.withArguments(name),
|
||||||
offset,
|
offset,
|
||||||
noLength);
|
noLength,
|
||||||
addProblem(
|
context: fasta.templateFinalInstanceVariableAlreadyInitializedCause
|
||||||
fasta.templateFinalInstanceVariableAlreadyInitializedCause
|
.withArguments(name)
|
||||||
.withArguments(name),
|
.withLocation(uri, builder.charOffset, noLength));
|
||||||
builder.charOffset,
|
|
||||||
noLength);
|
|
||||||
Builder constructor =
|
Builder constructor =
|
||||||
library.loader.getDuplicatedFieldInitializerError();
|
library.loader.getDuplicatedFieldInitializerError();
|
||||||
return buildInvalidInitializer(
|
return buildInvalidInitializer(
|
||||||
|
@ -3814,13 +3812,16 @@ class BodyBuilder<Arguments> extends ScopeListener<JumpTarget>
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void addCompileTimeError(Message message, int charOffset, int length) {
|
void addCompileTimeError(Message message, int charOffset, int length,
|
||||||
library.addCompileTimeError(message, charOffset, length, uri);
|
{LocatedMessage context}) {
|
||||||
|
library.addCompileTimeError(message, charOffset, length, uri,
|
||||||
|
context: context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void addProblem(Message message, int charOffset, int length) {
|
void addProblem(Message message, int charOffset, int length,
|
||||||
library.addProblem(message, charOffset, length, uri);
|
{LocatedMessage context}) {
|
||||||
|
library.addProblem(message, charOffset, length, uri, context: context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -3830,7 +3831,7 @@ class BodyBuilder<Arguments> extends ScopeListener<JumpTarget>
|
||||||
// take two messages: one to use when a constant expression is
|
// take two messages: one to use when a constant expression is
|
||||||
// required and one to use otherwise.
|
// required and one to use otherwise.
|
||||||
if (constantExpressionRequired) {
|
if (constantExpressionRequired) {
|
||||||
addCompileTimeError(message, charOffset, length);
|
addCompileTimeError(message, charOffset, length, context: context);
|
||||||
} else {
|
} else {
|
||||||
library.addProblem(message, charOffset, length, uri, context: context);
|
library.addProblem(message, charOffset, length, uri, context: context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,12 +233,11 @@ class KernelLibraryBuilder
|
||||||
TypeVariableBuilder existing = typeVariablesByName[tv.name];
|
TypeVariableBuilder existing = typeVariablesByName[tv.name];
|
||||||
if (existing != null) {
|
if (existing != null) {
|
||||||
addCompileTimeError(messageTypeVariableDuplicatedName, tv.charOffset,
|
addCompileTimeError(messageTypeVariableDuplicatedName, tv.charOffset,
|
||||||
tv.name.length, fileUri);
|
tv.name.length, fileUri,
|
||||||
addCompileTimeError(
|
context: templateTypeVariableDuplicatedNameCause
|
||||||
templateTypeVariableDuplicatedNameCause.withArguments(tv.name),
|
.withArguments(tv.name)
|
||||||
existing.charOffset,
|
.withLocation(
|
||||||
existing.name.length,
|
fileUri, existing.charOffset, existing.name.length));
|
||||||
fileUri);
|
|
||||||
} else {
|
} else {
|
||||||
typeVariablesByName[tv.name] = tv;
|
typeVariablesByName[tv.name] = tv;
|
||||||
if (owner is ClassBuilder) {
|
if (owner is ClassBuilder) {
|
||||||
|
|
|
@ -643,6 +643,8 @@ class KernelTarget extends TargetImplementation {
|
||||||
if (constructor.isConst && nonFinalFields.isNotEmpty) {
|
if (constructor.isConst && nonFinalFields.isNotEmpty) {
|
||||||
builder.addCompileTimeError(messageConstConstructorNonFinalField,
|
builder.addCompileTimeError(messageConstConstructorNonFinalField,
|
||||||
constructor.fileOffset, noLength);
|
constructor.fileOffset, noLength);
|
||||||
|
// TODO(askesc): Put as context argument when multiple contexts
|
||||||
|
// are supported.
|
||||||
for (Field field in nonFinalFields) {
|
for (Field field in nonFinalFields) {
|
||||||
builder.addCompileTimeError(
|
builder.addCompileTimeError(
|
||||||
messageConstConstructorNonFinalFieldCause,
|
messageConstConstructorNonFinalFieldCause,
|
||||||
|
|
|
@ -248,7 +248,7 @@ severity: $severity
|
||||||
target.context
|
target.context
|
||||||
.report(message.withLocation(fileUri, charOffset, length), severity);
|
.report(message.withLocation(fileUri, charOffset, length), severity);
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
target.context.report(context, severity);
|
target.context.report(context, Severity.context);
|
||||||
}
|
}
|
||||||
recordMessage(severity, message, charOffset, length, fileUri,
|
recordMessage(severity, message, charOffset, length, fileUri,
|
||||||
context: context);
|
context: context);
|
||||||
|
|
|
@ -5,9 +5,10 @@
|
||||||
library fasta.severity;
|
library fasta.severity;
|
||||||
|
|
||||||
enum Severity {
|
enum Severity {
|
||||||
|
context,
|
||||||
error,
|
error,
|
||||||
|
errorLegacyWarning,
|
||||||
internalProblem,
|
internalProblem,
|
||||||
nit,
|
nit,
|
||||||
warning,
|
warning,
|
||||||
errorLegacyWarning,
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import '../combinator.dart' show Combinator;
|
||||||
import '../fasta_codes.dart'
|
import '../fasta_codes.dart'
|
||||||
show
|
show
|
||||||
Message,
|
Message,
|
||||||
|
LocatedMessage,
|
||||||
messageExpectedBlockToSkip,
|
messageExpectedBlockToSkip,
|
||||||
messageInterpolationInUri,
|
messageInterpolationInUri,
|
||||||
messageOperatorWithOptionalFormals,
|
messageOperatorWithOptionalFormals,
|
||||||
|
@ -786,12 +787,11 @@ class OutlineBuilder extends UnhandledListener {
|
||||||
addCompileTimeError(
|
addCompileTimeError(
|
||||||
templateDuplicatedParameterName.withArguments(formals[1].name),
|
templateDuplicatedParameterName.withArguments(formals[1].name),
|
||||||
formals[1].charOffset,
|
formals[1].charOffset,
|
||||||
formals[1].name.length);
|
formals[1].name.length,
|
||||||
addCompileTimeError(
|
context: templateDuplicatedParameterNameCause
|
||||||
templateDuplicatedParameterNameCause
|
.withArguments(formals[1].name)
|
||||||
.withArguments(formals[1].name),
|
.withLocation(
|
||||||
formals[0].charOffset,
|
uri, formals[0].charOffset, formals[0].name.length));
|
||||||
formals[0].name.length);
|
|
||||||
}
|
}
|
||||||
} else if (formals.length > 2) {
|
} else if (formals.length > 2) {
|
||||||
Map<String, FormalParameterBuilder> seenNames =
|
Map<String, FormalParameterBuilder> seenNames =
|
||||||
|
@ -1102,12 +1102,15 @@ class OutlineBuilder extends UnhandledListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void addCompileTimeError(Message message, int charOffset, int length) {
|
void addCompileTimeError(Message message, int charOffset, int length,
|
||||||
library.addCompileTimeError(message, charOffset, length, uri);
|
{LocatedMessage context}) {
|
||||||
|
library.addCompileTimeError(message, charOffset, length, uri,
|
||||||
|
context: context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addProblem(Message message, int charOffset, int length) {
|
void addProblem(Message message, int charOffset, int length,
|
||||||
library.addProblem(message, charOffset, length, uri);
|
{LocatedMessage context}) {
|
||||||
|
library.addProblem(message, charOffset, length, uri, context: context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the documentation comment for the entity that starts at the
|
/// Return the documentation comment for the entity that starts at the
|
||||||
|
|
|
@ -444,12 +444,10 @@ abstract class SourceLibraryBuilder<T extends TypeBuilder, R>
|
||||||
templateDeferredPrefixDuplicated.withArguments(name),
|
templateDeferredPrefixDuplicated.withArguments(name),
|
||||||
deferred.charOffset,
|
deferred.charOffset,
|
||||||
noLength,
|
noLength,
|
||||||
fileUri);
|
fileUri,
|
||||||
addCompileTimeError(
|
context: templateDeferredPrefixDuplicatedCause
|
||||||
templateDeferredPrefixDuplicatedCause.withArguments(name),
|
.withArguments(name)
|
||||||
other.charOffset,
|
.withLocation(fileUri, other.charOffset, noLength));
|
||||||
noLength,
|
|
||||||
fileUri);
|
|
||||||
}
|
}
|
||||||
return existing
|
return existing
|
||||||
..exportScope.merge(builder.exportScope,
|
..exportScope.merge(builder.exportScope,
|
||||||
|
|
|
@ -521,12 +521,11 @@ class SourceLoader<L> extends Loader<L> {
|
||||||
templateIllegalMixinDueToConstructors
|
templateIllegalMixinDueToConstructors
|
||||||
.withArguments(builder.fullNameForErrors),
|
.withArguments(builder.fullNameForErrors),
|
||||||
cls.charOffset,
|
cls.charOffset,
|
||||||
noLength);
|
noLength,
|
||||||
builder.addCompileTimeError(
|
context: templateIllegalMixinDueToConstructorsCause
|
||||||
templateIllegalMixinDueToConstructorsCause
|
.withArguments(builder.fullNameForErrors)
|
||||||
.withArguments(builder.fullNameForErrors),
|
.withLocation(constructory.fileUri,
|
||||||
constructory.charOffset,
|
constructory.charOffset, noLength));
|
||||||
noLength);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -782,6 +781,10 @@ class SourceLoader<L> extends Loader<L> {
|
||||||
// Use a property name expressing that, in case it slips through.
|
// Use a property name expressing that, in case it slips through.
|
||||||
severityString = "unresolved severity";
|
severityString = "unresolved severity";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Severity.context:
|
||||||
|
severityString = "context";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
instrumentation.record(
|
instrumentation.record(
|
||||||
fileUri,
|
fileUri,
|
||||||
|
|
|
@ -946,9 +946,11 @@ MethodNotFound:
|
||||||
|
|
||||||
CandidateFound:
|
CandidateFound:
|
||||||
template: "Found this candidate, but the arguments don't match."
|
template: "Found this candidate, but the arguments don't match."
|
||||||
|
severity: CONTEXT
|
||||||
|
|
||||||
CandidateFoundIsDefaultConstructor:
|
CandidateFoundIsDefaultConstructor:
|
||||||
template: "The class '#name' has a constructor that takes no arguments."
|
template: "The class '#name' has a constructor that takes no arguments."
|
||||||
|
severity: CONTEXT
|
||||||
|
|
||||||
TooFewArgumentsToFunction:
|
TooFewArgumentsToFunction:
|
||||||
template: "Too few positional arguments to function: #count required, #count2 given."
|
template: "Too few positional arguments to function: #count required, #count2 given."
|
||||||
|
@ -1283,6 +1285,7 @@ IllegalMixinDueToConstructors:
|
||||||
|
|
||||||
IllegalMixinDueToConstructorsCause:
|
IllegalMixinDueToConstructorsCause:
|
||||||
template: "This constructor prevents using '#name' as a mixin."
|
template: "This constructor prevents using '#name' as a mixin."
|
||||||
|
severity: CONTEXT
|
||||||
|
|
||||||
ConflictsWithConstructor:
|
ConflictsWithConstructor:
|
||||||
template: "Conflicts with constructor '#name'."
|
template: "Conflicts with constructor '#name'."
|
||||||
|
@ -1314,7 +1317,7 @@ ConflictsWithTypeVariable:
|
||||||
|
|
||||||
ConflictsWithTypeVariableCause:
|
ConflictsWithTypeVariableCause:
|
||||||
template: "This is the type variable."
|
template: "This is the type variable."
|
||||||
severity: ERROR
|
severity: CONTEXT
|
||||||
|
|
||||||
IllegalMixin:
|
IllegalMixin:
|
||||||
template: "The type '#name' can't be mixed in."
|
template: "The type '#name' can't be mixed in."
|
||||||
|
@ -1325,6 +1328,7 @@ OverrideTypeVariablesMismatch:
|
||||||
|
|
||||||
OverriddenMethodCause:
|
OverriddenMethodCause:
|
||||||
template: "This is the overriden method ('#name')."
|
template: "This is the overriden method ('#name')."
|
||||||
|
severity: CONTEXT
|
||||||
|
|
||||||
OverrideMismatchNamedParameter:
|
OverrideMismatchNamedParameter:
|
||||||
template: "The method '#name' doesn't have the named parameter '#name2' of overriden method '#name3'."
|
template: "The method '#name' doesn't have the named parameter '#name2' of overriden method '#name3'."
|
||||||
|
@ -1369,6 +1373,7 @@ TypeVariableDuplicatedName:
|
||||||
|
|
||||||
TypeVariableDuplicatedNameCause:
|
TypeVariableDuplicatedNameCause:
|
||||||
template: "The other type variable named '#name'."
|
template: "The other type variable named '#name'."
|
||||||
|
severity: CONTEXT
|
||||||
|
|
||||||
TypeVariableSameNameAsEnclosing:
|
TypeVariableSameNameAsEnclosing:
|
||||||
template: "A type variable can't have the same name as its enclosing declaration."
|
template: "A type variable can't have the same name as its enclosing declaration."
|
||||||
|
@ -1538,6 +1543,7 @@ DeferredPrefixDuplicated:
|
||||||
|
|
||||||
DeferredPrefixDuplicatedCause:
|
DeferredPrefixDuplicatedCause:
|
||||||
template: "'#name' is used here."
|
template: "'#name' is used here."
|
||||||
|
severity: CONTEXT
|
||||||
|
|
||||||
TypeArgumentsOnTypeVariable:
|
TypeArgumentsOnTypeVariable:
|
||||||
template: "Can't use type arguments with type variable '#name'."
|
template: "Can't use type arguments with type variable '#name'."
|
||||||
|
@ -1559,6 +1565,7 @@ DuplicatedParameterName:
|
||||||
|
|
||||||
DuplicatedParameterNameCause:
|
DuplicatedParameterNameCause:
|
||||||
template: "Other parameter named '#name'."
|
template: "Other parameter named '#name'."
|
||||||
|
severity: CONTEXT
|
||||||
|
|
||||||
MemberWithSameNameAsClass:
|
MemberWithSameNameAsClass:
|
||||||
template: "A class member can't have the same name as the enclosing class."
|
template: "A class member can't have the same name as the enclosing class."
|
||||||
|
@ -1675,7 +1682,7 @@ FinalInstanceVariableAlreadyInitialized:
|
||||||
|
|
||||||
FinalInstanceVariableAlreadyInitializedCause:
|
FinalInstanceVariableAlreadyInitializedCause:
|
||||||
template: "'#name' was initialized here."
|
template: "'#name' was initialized here."
|
||||||
severity: ERROR_LEGACY_WARNING
|
severity: CONTEXT
|
||||||
|
|
||||||
TypeVariableInStaticContext:
|
TypeVariableInStaticContext:
|
||||||
template: "Type variables can't be used in static members."
|
template: "Type variables can't be used in static members."
|
||||||
|
@ -1709,6 +1716,7 @@ ConstConstructorNonFinalField:
|
||||||
|
|
||||||
ConstConstructorNonFinalFieldCause:
|
ConstConstructorNonFinalFieldCause:
|
||||||
template: "Field isn't final, but constructor is 'const'."
|
template: "Field isn't final, but constructor is 'const'."
|
||||||
|
severity: CONTEXT
|
||||||
|
|
||||||
AccessError:
|
AccessError:
|
||||||
template: "Access error: '#name'."
|
template: "Access error: '#name'."
|
||||||
|
@ -1829,12 +1837,14 @@ PatchClassTypeVariablesMismatch:
|
||||||
|
|
||||||
PatchClassOrigin:
|
PatchClassOrigin:
|
||||||
template: "This is the origin class."
|
template: "This is the origin class."
|
||||||
|
severity: CONTEXT
|
||||||
|
|
||||||
PatchDeclarationMismatch:
|
PatchDeclarationMismatch:
|
||||||
template: "This patch doesn't match origin declaration."
|
template: "This patch doesn't match origin declaration."
|
||||||
|
|
||||||
PatchDeclarationOrigin:
|
PatchDeclarationOrigin:
|
||||||
template: "This is the origin declaration."
|
template: "This is the origin declaration."
|
||||||
|
severity: CONTEXT
|
||||||
|
|
||||||
PatchInjectionFailed:
|
PatchInjectionFailed:
|
||||||
template: "Can't inject '#name' into '#uri'."
|
template: "Can't inject '#name' into '#uri'."
|
||||||
|
|
|
@ -16,6 +16,7 @@ Map<String, String> severityEnumNames = <String, String>{
|
||||||
'ERROR': 'error',
|
'ERROR': 'error',
|
||||||
'ERROR_LEGACY_WARNING': 'errorLegacyWarning',
|
'ERROR_LEGACY_WARNING': 'errorLegacyWarning',
|
||||||
'INTERNAL_PROBLEM': 'internalProblem',
|
'INTERNAL_PROBLEM': 'internalProblem',
|
||||||
|
'CONTEXT': 'context',
|
||||||
};
|
};
|
||||||
|
|
||||||
main(List<String> arguments) async {
|
main(List<String> arguments) async {
|
||||||
|
|
|
@ -102,6 +102,9 @@ abstract class Compiler {
|
||||||
case Severity.warning:
|
case Severity.warning:
|
||||||
if (!suppressWarnings) stderr.writeln(formatted);
|
if (!suppressWarnings) stderr.writeln(formatted);
|
||||||
break;
|
break;
|
||||||
|
case Severity.context:
|
||||||
|
stderr.writeln(formatted);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue