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

Unified Diff: pkg/compiler/lib/src/resolution/constructors.dart

Issue 1383483006: Extract DiagnosticReporter implementation from Compiler. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fixes after rebase. Created 5 years, 2 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/compiler/lib/src/resolution/constructors.dart
diff --git a/pkg/compiler/lib/src/resolution/constructors.dart b/pkg/compiler/lib/src/resolution/constructors.dart
index 7612b0db259867231400fe14743efd08b0f27a15..256be2d3419f99c8432d3db5f17d342ccd54c71e 100644
--- a/pkg/compiler/lib/src/resolution/constructors.dart
+++ b/pkg/compiler/lib/src/resolution/constructors.dart
@@ -11,7 +11,7 @@ import '../constants/constructors.dart' show
import '../constants/expressions.dart';
import '../dart_types.dart';
import '../diagnostics/diagnostic_listener.dart' show
- DiagnosticListener,
+ DiagnosticReporter,
DiagnosticMessage;
import '../diagnostics/invariant.dart' show
invariant;
@@ -62,7 +62,7 @@ class InitializerResolver {
ResolutionRegistry get registry => visitor.registry;
- DiagnosticListener get listener => visitor.compiler;
+ DiagnosticReporter get reporter => visitor.reporter;
bool isFieldInitializer(SendSet node) {
if (node.selector.asIdentifier() == null) return false;
@@ -72,13 +72,13 @@ class InitializerResolver {
}
reportDuplicateInitializerError(Element field, Node init, Node existing) {
- listener.reportError(
- listener.createMessage(
+ reporter.reportError(
+ reporter.createMessage(
init,
MessageKind.DUPLICATE_INITIALIZER,
{'fieldName': field.name}),
<DiagnosticMessage>[
- listener.createMessage(
+ reporter.createMessage(
existing,
MessageKind.ALREADY_INITIALIZED,
{'fieldName': field.name}),
@@ -111,23 +111,23 @@ class InitializerResolver {
if (isFieldInitializer(init)) {
target = constructor.enclosingClass.lookupLocalMember(name);
if (target == null) {
- listener.reportErrorMessage(
+ reporter.reportErrorMessage(
selector, MessageKind.CANNOT_RESOLVE, {'name': name});
target = new ErroneousFieldElementX(
selector.asIdentifier(), constructor.enclosingClass);
} else if (target.kind != ElementKind.FIELD) {
- listener.reportErrorMessage(
+ reporter.reportErrorMessage(
selector, MessageKind.NOT_A_FIELD, {'fieldName': name});
target = new ErroneousFieldElementX(
selector.asIdentifier(), constructor.enclosingClass);
} else if (!target.isInstanceMember) {
- listener.reportErrorMessage(
+ reporter.reportErrorMessage(
selector, MessageKind.INIT_STATIC_FIELD, {'fieldName': name});
} else {
field = target;
}
} else {
- listener.reportErrorMessage(
+ reporter.reportErrorMessage(
init, MessageKind.INVALID_RECEIVER_IN_INITIALIZER);
}
registry.useElement(init, target);
@@ -152,7 +152,7 @@ class InitializerResolver {
if (isSuperCall) {
// Calculate correct lookup target and constructor name.
if (identical(constructor.enclosingClass, visitor.compiler.objectClass)) {
- listener.reportErrorMessage(
+ reporter.reportErrorMessage(
diagnosticNode, MessageKind.SUPER_INITIALIZER_IN_OBJECT);
isValidAsConstant = false;
} else {
@@ -264,7 +264,7 @@ class InitializerResolver {
MessageKind kind = isImplicitSuperCall
? MessageKind.CANNOT_RESOLVE_CONSTRUCTOR_FOR_IMPLICIT
: MessageKind.CANNOT_RESOLVE_CONSTRUCTOR;
- listener.reportErrorMessage(
+ reporter.reportErrorMessage(
diagnosticNode, kind, {'constructorName': fullConstructorName});
isValidAsConstant = false;
} else {
@@ -273,14 +273,14 @@ class InitializerResolver {
MessageKind kind = isImplicitSuperCall
? MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT
: MessageKind.NO_MATCHING_CONSTRUCTOR;
- listener.reportErrorMessage(diagnosticNode, kind);
+ reporter.reportErrorMessage(diagnosticNode, kind);
isValidAsConstant = false;
} else if (constructor.isConst
&& !lookedupConstructor.isConst) {
MessageKind kind = isImplicitSuperCall
? MessageKind.CONST_CALLS_NON_CONST_FOR_IMPLICIT
: MessageKind.CONST_CALLS_NON_CONST;
- listener.reportErrorMessage(diagnosticNode, kind);
+ reporter.reportErrorMessage(diagnosticNode, kind);
isValidAsConstant = false;
}
}
@@ -350,13 +350,13 @@ class InitializerResolver {
} else if (link.head.asSend() != null) {
final Send call = link.head.asSend();
if (call.argumentsNode == null) {
- listener.reportErrorMessage(
+ reporter.reportErrorMessage(
link.head, MessageKind.INVALID_INITIALIZER);
continue;
}
if (Initializers.isSuperConstructorCall(call)) {
if (resolvedSuper) {
- listener.reportErrorMessage(
+ reporter.reportErrorMessage(
call, MessageKind.DUPLICATE_SUPER_INITIALIZER);
}
ResolutionResult result = resolveSuperOrThisForSend(call);
@@ -373,12 +373,12 @@ class InitializerResolver {
// constructor is also const, we already reported an error in
// [resolveMethodElement].
if (functionNode.hasBody() && !constructor.isConst) {
- listener.reportErrorMessage(
+ reporter.reportErrorMessage(
functionNode, MessageKind.REDIRECTING_CONSTRUCTOR_HAS_BODY);
}
// Check that there are no other initializers.
if (!initializers.tail.isEmpty) {
- listener.reportErrorMessage(
+ reporter.reportErrorMessage(
call, MessageKind.REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER);
} else {
constructor.isRedirectingGenerative = true;
@@ -388,7 +388,7 @@ class InitializerResolver {
signature.forEachParameter((ParameterElement parameter) {
if (parameter.isInitializingFormal) {
Node node = parameter.node;
- listener.reportErrorMessage(
+ reporter.reportErrorMessage(
node, MessageKind.INITIALIZING_FORMAL_NOT_ALLOWED);
isValidAsConstant = false;
}
@@ -409,12 +409,12 @@ class InitializerResolver {
}
return result.element;
} else {
- listener.reportErrorMessage(
+ reporter.reportErrorMessage(
call, MessageKind.CONSTRUCTOR_CALL_EXPECTED);
return null;
}
} else {
- listener.reportErrorMessage(
+ reporter.reportErrorMessage(
link.head, MessageKind.INVALID_INITIALIZER);
}
}
@@ -462,10 +462,10 @@ class ConstructorResolver extends CommonResolverVisitor<ConstructorResult> {
registry.registerThrowRuntimeError();
}
if (isError || inConstContext) {
- compiler.reportErrorMessage(
+ reporter.reportErrorMessage(
diagnosticNode, kind, arguments);
} else {
- compiler.reportWarningMessage(
+ reporter.reportWarningMessage(
diagnosticNode, kind, arguments);
}
ErroneousElement error = new ErroneousConstructorElementX(
@@ -495,14 +495,14 @@ class ConstructorResolver extends CommonResolverVisitor<ConstructorResult> {
{'constructorName': fullConstructorName},
missingConstructor: true);
} else if (inConstContext && !constructor.isConst) {
- compiler.reportErrorMessage(
+ reporter.reportErrorMessage(
diagnosticNode, MessageKind.CONSTRUCTOR_IS_NOT_CONST);
return new ConstructorResult(
ConstructorResultKind.NON_CONSTANT, constructor, type);
} else {
if (constructor.isGenerativeConstructor) {
if (cls.isAbstract) {
- compiler.reportWarningMessage(
+ reporter.reportWarningMessage(
diagnosticNode, MessageKind.ABSTRACT_CLASS_INSTANTIATION);
registry.registerAbstractClassInstantiation();
return new ConstructorResult(
@@ -587,7 +587,7 @@ class ConstructorResolver extends CommonResolverVisitor<ConstructorResult> {
Identifier name = node.selector.asIdentifier();
if (name == null) {
- compiler.internalError(node.selector, 'unexpected node');
+ reporter.internalError(node.selector, 'unexpected node');
}
if (receiver.type != null) {
@@ -606,7 +606,7 @@ class ConstructorResolver extends CommonResolverVisitor<ConstructorResult> {
Element member = prefix.lookupLocalMember(name.source);
return constructorResultForElement(node, name.source, member);
} else {
- return compiler.internalError(
+ return reporter.internalError(
node.receiver, 'unexpected receiver $receiver');
}
}
@@ -614,7 +614,7 @@ class ConstructorResolver extends CommonResolverVisitor<ConstructorResult> {
ConstructorResult visitIdentifier(Identifier node) {
String name = node.source;
Element element = resolver.reportLookupErrorIfAny(
- lookupInScope(compiler, node, resolver.scope, name), node, name);
+ lookupInScope(reporter, node, resolver.scope, name), node, name);
registry.useElement(node, element);
// TODO(johnniwinther): Change errors to warnings, cf. 11.11.1.
return constructorResultForElement(node, name, element);
@@ -629,7 +629,7 @@ class ConstructorResolver extends CommonResolverVisitor<ConstructorResult> {
ConstructorResult constructorResultForElement(
Node node, String name, Element element) {
- element = Elements.unwrap(element, compiler, node);
+ element = Elements.unwrap(element, reporter, node);
if (element == null) {
return reportAndCreateErroneousConstructorElement(
node,
@@ -699,7 +699,7 @@ class ConstructorResolver extends CommonResolverVisitor<ConstructorResult> {
MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE,
{'typeVariableName': name});
}
- return compiler.internalError(node, "Unexpected constructor type $type");
+ return reporter.internalError(node, "Unexpected constructor type $type");
}
}
« no previous file with comments | « pkg/compiler/lib/src/resolution/class_members.dart ('k') | pkg/compiler/lib/src/resolution/enum_creator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698