OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 package com.google.dart.compiler.resolver; |
| 5 |
| 6 import com.google.dart.compiler.ErrorCode; |
| 7 import com.google.dart.compiler.ErrorSeverity; |
| 8 import com.google.dart.compiler.SubSystem; |
| 9 |
| 10 /** |
| 11 * {@link ErrorCode}s for resolver. |
| 12 */ |
| 13 public enum ResolverErrorCode implements ErrorCode { |
| 14 CANNOT_ACCESS_OUTER_LABEL("Cannot access label %s declared in an outer functio
n"), |
| 15 CANNOT_ACCESS_FIELD_IN_INIT("Cannot access an instance field in an initializer
expression"), |
| 16 CANNOT_ASSIGN_TO_FINAL("cannot assign value to final variable \"%s\"."), |
| 17 CANNOT_BE_RESOLVED("cannot resolve %s"), |
| 18 CANNOT_BE_RESOLVED_LIBRARY("cannot resolve %s in library %s"), |
| 19 CANNOT_BE_INITIALIZED("cannot be initialized"), |
| 20 CANNOT_CALL_LABEL("Labels cannot be called"), |
| 21 CANNOT_DECLARE_NON_FACTORY_CONSTRUCTOR( |
| 22 "Cannot declare a non-factory named constructor of another class."), |
| 23 CANNOT_INIT_FIELD_FROM_SUPERCLASS("Cannot initialize a field from a super clas
s"), |
| 24 CANNOT_INIT_STATIC_FIELD_IN_INITIALIZER("Cannot initialize a static field in a
n initializer list"), |
| 25 CANNOT_OVERRIDE_INSTANCE_MEMBER("static member cannot override instance member
%s of %s"), |
| 26 CANNOT_OVERRIDE_STATIC_MEMBER("cannot override static member %s of %s"), |
| 27 CANNOT_RESOLVE_CONSTRUCTOR("cannot resolve constructor %s"), |
| 28 CANNOT_RESOLVE_FIELD("cannot resolve field %s"), |
| 29 CANNOT_RESOLVE_LABEL("cannot resolve label %s"), |
| 30 CANNOT_RESOLVE_METHOD("cannot resolve method %s"), |
| 31 CANNOT_RESOLVE_SUPER_CONSTRUCTOR("cannot resolve method %s"), |
| 32 CANNOT_RESOLVE_IMPLICIT_CALL_TO_SUPER_CONSTRUCTOR( |
| 33 "super type %s does not have a default constructor"), |
| 34 CONSTRUCTOR_CANNOT_BE_ABSTRACT("A constructor cannot be asbstract"), |
| 35 CONSTRUCTOR_CANNOT_BE_STATIC("A constructor cannot be static"), |
| 36 CONST_CONSTRUCTOR_CANNOT_HAVE_BODY("A const constructor cannot have a body"), |
| 37 CONST_CONSTRUCTOR_MUST_CALL_CONST_SUPER("const constructor must call const sup
er constructor"), |
| 38 CONSTANTS_MUST_BE_INITIALIZED("constants must be initialized"), |
| 39 CYCLIC_CLASS("%s causes a cycle in the supertype graph"), |
| 40 DID_YOU_MEAN_NEW("%1$s is a %2$s. Did you mean (new %1$s)?"), |
| 41 DUPLICATE_DEFINITION("duplicate definition of %s"), |
| 42 DUPLICATED_INTERFACE("%s and %s are duplicated in the supertype graph"), |
| 43 EXPECTED_AN_INSTANCE_FIELD_IN_SUPER_CLASS( |
| 44 "expected an instance field in the super class, but got %s"), |
| 45 EXPECTED_CONSTANT_EXPRESSION("Expected constant expression"), |
| 46 EXPECTED_CONSTANT_EXPRESSION_BOOLEAN("Expected constant expression of type boo
l, got %s"), |
| 47 EXPECTED_CONSTANT_EXPRESSION_INT("Expected constant expression of type int, go
t %s"), |
| 48 EXPECTED_CONSTANT_EXPRESSION_NUMBER("Expected constant expression of type num,
got %s"), |
| 49 EXPECTED_CONSTANT_EXPRESSION_STRING_NUMBER_BOOL( |
| 50 "Expected constant expression of type String, num or bool, got %s"), |
| 51 EXPECTED_FIELD_NOT_CLASS("%s is a class, expected a local field"), |
| 52 EXPECTED_FIELD_NOT_METHOD("%s is a method, expected a local field"), |
| 53 EXPECTED_FIELD_NOT_PARAMETER("%s is a parameter, expected a local field"), |
| 54 EXPECTED_FIELD_NOT_TYPE_VAR("%s is a type variable, expected a local field"), |
| 55 EXPECTED_ONE_ARGUMENT("Expected one argument"), |
| 56 EXPECTED_STATIC_FIELD("expected a static field, but got %s"), |
| 57 EXTRA_TYPE_ARGUMENT("Type variables may not have type arguments"), |
| 58 FACTORY_ACCESS_SUPER("Cannot use 'super' in a factory constructor"), |
| 59 FACTORY_CANNOT_BE_ABSTRACT("A factory cannot be abstract"), |
| 60 FACTORY_CANNOT_BE_CONST("A factory cannot be const"), |
| 61 FACTORY_CANNOT_BE_STATIC("A factory cannot be static"), |
| 62 FIELD_CONFLICTS("%s conflicts with previously defined %s at line %d column %d"
), |
| 63 ILLEGAL_ACCESS_TO_PRIVATE_MEMBER("\"%s\" refers to \"%s\" which is in a differ
ent library"), |
| 64 ILLEGAL_FIELD_ACCESS_FROM_STATIC("Illegal access of instance field %s from sta
tic scope"), |
| 65 ILLEGAL_METHOD_ACCESS_FROM_STATIC("Illegal access of instance method %s from s
tatic scope"), |
| 66 INSTANCE_METHOD_FROM_STATIC("Instance methods cannot be referenced from static
methods"), |
| 67 INTERNAL_ERROR("internal error: %s"), |
| 68 INVALID_TYPE_NAME_IN_CONSTRUCTOR("Invalid type in constructor name"), |
| 69 IS_A_CLASS("%s is a class and cannot be used as an expression"), |
| 70 IS_A_CONSTRUCTOR("%s.%s is a constructor, expected a method"), |
| 71 IS_AN_INSTANCE_METHOD("%s.%s is an instance method, not a static method"), |
| 72 METHOD_MUST_HAVE_BODY("A non-abstract method must have a body"), |
| 73 NAME_CLASHES_EXISTING_MEMBER( |
| 74 "name clashes with a previously defined member at %sline %d column %d"), |
| 75 NEW_EXPRESSION_NOT_CONSTRUCTOR("New expression does not resolve to a construct
or"), |
| 76 NEW_EXPRESSION_CANT_USE_TYPE_VAR("New expression cannot be invoked on type var
iable"), |
| 77 NO_SUCH_TYPE("no such type \"%s\""), |
| 78 NOT_A_CLASS("\"%s\" is not a class"), |
| 79 NOT_A_CLASS_OR_INTERFACE("\"%s\" is not a class or interface"), |
| 80 NOT_A_LABEL("\"%s\" is not a label"), |
| 81 NOT_A_STATIC_FIELD("\"%s\" is not a static field"), |
| 82 NOT_A_STATIC_METHOD("\"%s\" is not a static method"), |
| 83 NOT_AN_INSTANCE_FIELD("%s is not an instance field"), |
| 84 REDIRECTED_CONSTRUCTOR_CYCLE("Redirected constructor call has a cycle."), |
| 85 PARAMETER_INIT_OUTSIDE_CONSTRUCTOR("Parameter initializers can only be used in
constructors"), |
| 86 PARAMETER_INIT_STATIC_FIELD( |
| 87 "Parameter initializer cannot be use to initialize a static field '%s'"), |
| 88 PARAMETER_INIT_WITH_REDIR_CONSTRUCTOR( |
| 89 "Parameter initializers cannot be used with redirected constructors"), |
| 90 PARAMETER_NOT_MATCH_FIELD("Could not match parameter initializer '%s' with any
field"), |
| 91 RETHROW_NOT_IN_CATCH("Re-throw not in a catch block"), |
| 92 STATIC_FINAL_REQUIRES_VALUE("Static final fields must have an initial value"), |
| 93 STATIC_METHOD_ACCESS_SUPER("Cannot use 'super' in a static method"), |
| 94 STATIC_METHOD_ACCESS_THIS("Cannot use 'this' in a static method"), |
| 95 SUPER_OUTSIDE_OF_METHOD("Cannot use 'super' outside of a method"), |
| 96 TOP_LEVEL_METHOD_ACCESS_SUPER("Cannot use 'super' in a top-level method"), |
| 97 TOP_LEVEL_METHOD_ACCESS_THIS("Cannot use 'this' in a top-level method"), |
| 98 TYPE_NOT_ASSIGNMENT_COMPATIBLE("%s is not assignable to %s"), |
| 99 TYPE_VARIABLE_IN_STATIC_CONTEXT("cannot access type variable %s in static cont
ext"); |
| 100 private final ErrorSeverity severity; |
| 101 private final String message; |
| 102 |
| 103 /** |
| 104 * Initialize a newly created error code to have the given message and ERROR s
everity. |
| 105 */ |
| 106 private ResolverErrorCode(String message) { |
| 107 this(ErrorSeverity.ERROR, message); |
| 108 } |
| 109 |
| 110 /** |
| 111 * Initialize a newly created error code to have the given severity and messag
e. |
| 112 */ |
| 113 private ResolverErrorCode(ErrorSeverity severity, String message) { |
| 114 this.severity = severity; |
| 115 this.message = message; |
| 116 } |
| 117 |
| 118 public String getMessage() { |
| 119 return message; |
| 120 } |
| 121 |
| 122 public ErrorSeverity getErrorSeverity() { |
| 123 return severity; |
| 124 } |
| 125 |
| 126 public SubSystem getSubSystem() { |
| 127 return SubSystem.RESOLVER; |
| 128 } |
| 129 } |
OLD | NEW |