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

Side by Side Diff: dart/compiler/java/com/google/dart/compiler/resolver/ResolverErrorCode.java

Issue 20722006: Removed compiler/ directory from repository (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012, 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 BLACK_LISTED_EXTENDS("'%s' can not be used as superclass"),
15 BLACK_LISTED_IMPLEMENTS("'%s' can not be used as superinterface"),
16 BLACK_LISTED_MIXINS("'%s' can not be used as mixin"),
17 BREAK_LABEL_RESOLVES_TO_CASE_OR_DEFAULT("break label resolves to case or defau lt statement"),
18 BUILT_IN_IDENTIFIER_AS_TYPE("Built-in identifier '%s' cannot be used as a type annotation"),
19 CANNOT_ACCESS_FIELD_IN_INIT("Cannot access an instance field in an initializer expression"),
20 CANNOT_ACCESS_METHOD(ErrorSeverity.WARNING, "Cannot access private method '%s' "),
21 CANNOT_ACCESS_OUTER_LABEL("Cannot access label %s declared in an outer functio n"),
22 CANNOT_ASSIGN_TO_FINAL(ErrorSeverity.WARNING, "cannot assign value to final va riable \"%s\"."),
23 CANNOT_ASSIGN_TO_FINAL_ERROR("cannot assign value to final variable \"%s\"."),
24 CANNOT_ASSIGN_TO_METHOD(ErrorSeverity.WARNING, "cannot assign value to method '%s'."),
25 CANNOT_BE_RESOLVED("cannot resolve %s"),
26 // TODO(zundel): error message needs JUnit test - how to test #imports in juni t?
27 CANNOT_BE_RESOLVED_LIBRARY(ErrorSeverity.WARNING, "cannot resolve %s in librar y %s"),
28 CANNOT_CALL_FUNCTION_TYPE_ALIAS("Function type aliases cannot be called"),
29 // TODO(zundel): error message needs JUnit test - how to test #imports in juni t?
30 CANNOT_CALL_LIBRARY_PREFIX("Library prefixes cannot be called"),
31 CANNOT_DECLARE_NON_FACTORY_CONSTRUCTOR(ErrorSeverity.WARNING,
32 "Cannot declare a non-factory named constructor of another class."),
33 CANNOT_HIDE_IMPORT_PREFIX("Cannot hide import prefix '%s'"),
34 CANNOT_INIT_STATIC_FIELD_IN_INITIALIZER("Cannot initialize a static field in a n initializer list"),
35 CANNOT_MIXIN_CLASS_WITH_CONSTRUCTOR("Cannot use class with constructor as a mi xin."),
36 CANNOT_MIXIN_CLASS_WITH_MIXINS("Cannot use class with mixins as a mixin."),
37 CANNOT_MIXIN_CLASS_WITH_SUPER("Cannot use class with super invocation as a mix in."),
38 CANNOT_OVERRIDE_INSTANCE_MEMBER("static member cannot override instance member %s of %s"),
39 CANNOT_OVERRIDE_METHOD_NUM_REQUIRED_PARAMS(
40 "cannot override method %s from %s, wrong number of required parameters"),
41 CANNOT_OVERRIDE_METHOD_NAMED_PARAMS("cannot override method %s, named paramete rs don't match"),
42 CANNOT_OVERRIDE_METHOD_OPTIONAL_PARAMS("cannot override method %s, optional po sitional parameters don't match"),
43 CANNOT_RESOLVE_CONSTRUCTOR("cannot resolve constructor %s"),
44 CANNOT_RESOLVE_FIELD("cannot resolve field %s"),
45 CANNOT_RESOLVE_LABEL("cannot resolve label %s"),
46 CANNOT_RESOLVE_METHOD("cannot resolve method '%s'"),
47 CANNOT_RESOLVE_METHOD_IN_CLASS(ErrorSeverity.WARNING, "cannot resolve method ' %s' in class '%s'"),
48 // TODO(zundel): error message needs JUnit test - how to test #imports in juni t?
49 CANNOT_RESOLVE_METHOD_IN_LIBRARY("cannot resolve method '%s' in library '%s'") ,
50 // TODO(zundel): To exercise this requires simulating a corrupted SDK?
51 CANNOT_RESOLVE_SDK_TYPE("cannot resolve SDK type %s"),
52 CANNOT_RESOLVE_SUPER_CONSTRUCTOR("cannot resolve super constructor '%s'"),
53 CANNOT_RESOLVE_IMPLICIT_CALL_TO_SUPER_CONSTRUCTOR(
54 "super type %s does not have a default constructor"),
55 CANNOT_USE_INSTANCE_FIELD_IN_INSTANCE_FIELD_INITIALIZER(
56 "Cannot use instance field in instance field initializer"),
57 CANNOT_USE_THIS_IN_INSTANCE_FIELD_INITIALIZER("Cannot use 'this' in instance f ield initializer"),
58 CANNOT_USE_TYPE("Cannot reference the type '%s' in this context"),
59 // TODO(zundel): error message needs JUnit test (reachable code?)
60 CANNOT_USE_TYPE_VARIABLE("Cannot reference the type variable '%s' in this cont ext"),
61 CIRCULAR_REFERENCE(
62 "Circular reference detected: compile-time constants cannot reference the mselves."),
63 CONST_REQUIRES_VALUE("Constant fields must have an initial value"),
64 CONSTRUCTOR_CANNOT_BE_ABSTRACT("A constructor cannot be abstract"),
65 CONSTRUCTOR_CANNOT_BE_STATIC("A constructor cannot be static"),
66 CONSTRUCTOR_CANNOT_HAVE_RETURN_TYPE("Generative constructors cannot have retur n type"),
67 CONST_AND_NONCONST_CONSTRUCTOR("Cannot reference to non-const constructor."),
68 CONST_ARRAY_WITH_TYPE_VARIABLE("Const array literals cannot have a type variab le as a type argument"),
69 CONST_CLASS_WITH_INHERITED_NONFINAL_FIELDS(
70 "Const class %s cannot have non-final, inherited field %s from class %s"),
71 CONST_CLASS_WITH_NONFINAL_FIELDS("Const class %s cannot have non-final field % s"),
72 CONST_CONSTRUCTOR_CANNOT_HAVE_BODY("A const constructor cannot have a body"),
73 CONST_CONSTRUCTOR_MUST_CALL_CONST_SUPER("const constructor must call const sup er constructor"),
74 CONST_EXPRESSION_CANT_USE_TYPE_VAR("Const expression cannot be invoked on type variable"),
75 CONST_MAP_WITH_TYPE_VARIABLE("Const map literals cannot have a type variable a s a type argument"),
76 CONST_WITH_TYPE_VARIABLE("Const constructor cannot be invoked with a type vari able as a type argument"),
77 CONSTANTS_EVALUATION_EXCEPTION("Exception during constant evaluation"),
78 CONSTANTS_MUST_BE_INITIALIZED("constants must be initialized"),
79 CONTINUE_LABEL_RESOLVES_TO_SWITCH("continue label resolves to switch, must be loop or switch member"),
80 CYCLIC_CLASS("%s causes a cycle in the supertype graph"),
81 DEFAULT_CLASS_MUST_HAVE_SAME_TYPE_PARAMS(
82 "default class must have the same type parameters as declared in the inter face"),
83 DEFAULT_CONSTRUCTOR_UNRESOLVED("Cannot resolve constructor with name '%s' in d efault class '%s'"),
84 DEFAULT_CONSTRUCTOR_NUMBER_OF_REQUIRED_PARAMETERS(
85 "Constructor '%s' in '%s' has %s required parameters, doesn't match '%s' i n '%s' with %s"),
86 DEFAULT_CONSTRUCTOR_OPTIONAL_POSITIONAL_PARAMETERS(
87 "Constructor '%s' in '%s' has %s optional positional parameters, doesn't m atch '%s' in '%s' with %s"),
88 DEFAULT_CONSTRUCTOR_NAMED_PARAMETERS(
89 "Constructor '%s' in '%s' has named parameters %s, doesn't match '%s' in ' %s' with %s"),
90 DEFAULT_MUST_SPECIFY_CLASS("default must indicate a class, not an interface"),
91 DEPRECATED_MAP_LITERAL_SYNTAX(ErrorSeverity.WARNING,
92 "Deprecated Map literal syntax. Both String (as key) and value type argume nts required."),
93 DID_YOU_MEAN_NEW("%1$s is a %2$s. Did you mean (new %1$s)?"),
94 DUPLICATE_EXPORTED_NAME("%s already exported from '%s'"),
95 DUPLICATE_IMPLEMENTS_TYPE("Duplicate type in the implements clause"),
96 DUPLICATE_IMPORTED_NAME("Element '%s' is introduced by %s imports: %s"),
97 DUPLICATE_IMPORTED_NAME_TYPE(ErrorSeverity.WARNING, "Element '%s' is introduce d by %s imports: %s"),
98 DUPLICATE_INITIALIZATION("Duplicate initialization of '%s'"),
99 DUPLICATE_FUNCTION_EXPRESSION("Duplicate function expression '%s'"),
100 DUPLICATE_LABEL_IN_SWITCH_STATEMENT("Duplicate label in switch statement"),
101 DUPLICATE_LOCAL_VARIABLE_ERROR("Duplicate local variable '%s'"),
102 DUPLICATE_MEMBER("Duplicate member '%s'"),
103 DUPLICATE_NAMED_ARGUMENT("Duplicate named parameter argument"),
104 DUPLICATE_PARAMETER("Duplicate parameter '%s'"),
105 DUPLICATE_TOP_LEVEL_DECLARATION("duplicate top-level declaration %s at %s"),
106 DUPLICATE_TYPE_VARIABLE("Duplicate type variable '%s'"),
107 DUPLICATE_WITH_TYPE("Duplicate type in the with clause"),
108 // TODO(zundel): error message needs JUnit test, (reachable code?)
109 EXPECTED_AN_INSTANCE_FIELD_IN_SUPER_CLASS(
110 "expected an instance field in the super class, but got %s"),
111 EXPECTED_CONSTANT_EXPRESSION("Expected constant expression"),
112 EXPECTED_CONSTANT_EXPRESSION_BOOLEAN("Expected constant expression of type boo l, got %s"),
113 EXPECTED_CONSTANT_EXPRESSION_INT("Expected constant expression of type int, go t %s"),
114 EXPECTED_CONSTANT_EXPRESSION_STRING("Expected constant expression of type Stri ng, got %s"),
115 EXPECTED_CONSTANT_EXPRESSION_NUMBER("Expected constant expression of type num, got %s"),
116 EXPECTED_CONSTANT_EXPRESSION_STRING_NUMBER_BOOL(
117 "Expected constant expression of type String, num or bool, got %s"),
118 EXPECTED_FIELD_NOT_CLASS("%s is a class, expected a local field"),
119 EXPECTED_FIELD_NOT_METHOD("%s is a method, expected a local field"),
120 EXPECTED_FIELD_NOT_PARAMETER("%s is a parameter, expected a local field"),
121 EXPECTED_FIELD_NOT_TYPE_VAR("%s is a type variable, expected a local field"),
122 // TODO(zundel): error message needs JUnit test (reachable code?)
123 EXPECTED_STATIC_FIELD("expected a static field, but got %s"),
124 // TODO(zundel): error message needs JUnit test, (reachable code?)
125 EXTRA_TYPE_ARGUMENT(ErrorSeverity.WARNING, "Type variables may not have type a rguments"),
126 FACTORY_CANNOT_BE_CONST("A factory cannot be const"),
127 FIELD_DOES_NOT_HAVE_A_GETTER(ErrorSeverity.WARNING, "Field does not have a get ter"),
128 FIELD_DOES_NOT_HAVE_A_SETTER(ErrorSeverity.WARNING, "Field does not have a set ter"),
129 FINAL_FIELD_MUST_BE_INITIALIZED("The final field %s must be initialized"),
130 FORMAL_PARAMETER_NAME_EXPECTED("Formal parameter name expected"),
131 // TODO(zundel): error message needs JUnit test - how to test #imports in juni t?
132 ILLEGAL_ACCESS_TO_PRIVATE(ErrorSeverity.WARNING, "'%s' is private and not defi ned in this library"),
133 // TODO(zundel): error message needs JUnit test - how to test #imports in juni t?
134 ILLEGAL_ACCESS_TO_PRIVATE_MEMBER("ErrorSeverity.WARNING, \"%s\" refers to \"%s \" which is in a different library"),
135 ILLEGAL_FIELD_ACCESS_FROM_FACTORY("Illegal access of instance field %s from fa ctory"),
136 ILLEGAL_FIELD_ACCESS_FROM_STATIC("Illegal access of instance field %s from sta tic scope"),
137 ILLEGAL_METHOD_ACCESS_FROM_STATIC("Illegal access of instance method %s from s tatic scope"),
138 INITIALIZER_ONLY_IN_GENERATIVE_CONSTRUCTOR("Initializers are allowed only in n on-redirecting generative constructors"),
139 INIT_FIELD_ONLY_IMMEDIATELY_SURROUNDING_CLASS(
140 "Only fields of immediately surrounding class can be initialized"),
141 INSTANCE_METHOD_FROM_INITIALIZER("Instance methods cannot be referenced from c onstructor initializer"),
142 INSTANCE_METHOD_FROM_REDIRECT("Instance methods cannot be referenced from cons tructor redirects"),
143 INSTANCE_METHOD_FROM_STATIC("Instance methods cannot be referenced from static methods"),
144 INTERNAL_ERROR("internal error: %s"),
145 INVALID_OVERRIDE_METADATA(ErrorSeverity.WARNING, "Method marked with @override , but does not override any superclass element"),
146 INVALID_RETURN_IN_CONSTRUCTOR("Generative constructors cannot return arbitrary expressions"),
147 // TODO(zundel): error message needs JUnit test (reachable code?)
148 INVALID_TYPE_NAME_IN_CONSTRUCTOR("Invalid type in constructor name"),
149 // TODO(zundel): error message needs JUnit test (reachable code?)
150 IS_A_CONSTRUCTOR("%s.%s is a constructor, expected a method"),
151 IS_AN_INSTANCE_FIELD(ErrorSeverity.WARNING, "%s.%s is an instance field, not a static method"),
152 IS_AN_INSTANCE_METHOD(ErrorSeverity.WARNING, "%s.%s is an instance method, not a static method"),
153 // TODO(zundel): error message needs JUnit test (requires development mode che cks)
154 LIST_LITERAL_ELEMENT_TYPE(
155 "List literal element type must match declaration '%s' when type checks ar e on."),
156 MAIN_FUNCTION_PARAMETERS(
157 ErrorSeverity.WARNING, "Top-level function 'main' should not have paramete rs."),
158 // TODO(zundel): error message needs JUnit test (requires development mode che cks)
159 MAP_LITERAL_ELEMENT_TYPE(
160 "Map literal element type must match declaration '%s' when type checks are on."),
161 MEMBER_WITH_NAME_OF_CLASS("Class member should not have the same name as the e nclosing class"),
162 CONSTRUCTOR_WITH_NAME_OF_MEMBER(
163 "Constructor cannot have the same name as the name of a member declared in the enclosing class"),
164 CONSTRUCTOR_NAME_NOT_ENCLOSING_CLASS("Name of the immediately enclosing class expected"),
165 CONSTRUCTOR_NAME_NOT_ENCLOSING_CLASS_ID(ErrorSeverity.WARNING, "Not a valid co nstructor name"),
166 METHOD_MUST_HAVE_BODY(ErrorSeverity.WARNING, "Method must have a body in a non -abstract class"),
167 NAMED_PARAMETERS_CANNOT_START_WITH_UNDER("Named parameters cannot start with a n '_' character"),
168 NEW_EXPRESSION_CANT_USE_TYPE_VAR(ErrorSeverity.WARNING, "New expression cannot be invoked on type variable"),
169 NEW_EXPRESSION_NOT_CONST_CONSTRUCTOR("New expression does not resolve to a con st constructor"),
170 NO_SUCH_TYPE("no such type \"%s\""),
171 NO_SUCH_TYPE_CONSTRUCTOR("no such type \"%s\" in constructor"),
172 NO_SUCH_TYPE_CONST("no such type \"%s\" in constant constructor"),
173 NOT_A_CLASS("\"%s\" is not a class"),
174 NOT_A_CLASS_OR_INTERFACE("\"%s\" is not a class or interface"),
175 // TODO(zundel): error message needs JUnit test (reachable code?)
176 NOT_A_LABEL("\"%s\" is not a label"),
177 NOT_A_STATIC_FIELD(ErrorSeverity.WARNING, "\"%s\" is not a static field"),
178 NOT_A_STATIC_METHOD("\"%s\" is not a static method"),
179 NOT_A_TYPE("type \"%s\" expected, but \"%s\" found"),
180 // TODO(zundel): error message needs JUnit test (reachable code?)
181 NOT_AN_INSTANCE_FIELD("%s is not an instance field"),
182 NOT_GENERATIVE_SUPER_CONSTRUCTOR("Constructor '%s' in class '%s' is not genera tive."),
183 ONLY_OBJECT_MIXIN_SUPERCLASS("Only Object is allowed to be a superclass of a m ixin."),
184 OPTIONAL_PARAMETERS_CANNOT_START_WITH_UNDER("Optional parameters cannot start with an '_' character"),
185 PARAMETER_INIT_OUTSIDE_CONSTRUCTOR("Parameter initializers can only be used in constructors"),
186 SUPER_METHOD_INVOCATION_IN_CONSTRUCTOR_INITIALIZER(
187 "Super method invocation is not allowed in constructor initializer"),
188 PARAMETER_INIT_STATIC_FIELD(
189 "Parameter initializer cannot be use to initialize a static field '%s'"),
190 // TODO(zundel): error message needs JUnit test (reachable code?)
191 PARAMETER_INIT_WITH_REDIR_CONSTRUCTOR(
192 "Parameter initializers cannot be used with redirected constructors"),
193 // TODO(zundel): error message needs JUnit test
194 PARAMETER_NOT_MATCH_FIELD("Could not match parameter initializer '%s' with any field"),
195 REDIRECTED_CONSTRUCTOR_CYCLE("Redirected constructor call has a cycle."),
196 REDIRECTION_CONSTRUCTOR_TARGET_TYPE(
197 "Target of redirecting factory constructor is not a type"),
198 REDIRECTION_CONSTRUCTOR_TARGET_MUST_BE_CONST(
199 "Target of constant redirecting factory constructor also should be constan t"),
200 REDIRECTION_CONSTRUCTOR_CYCLE("Cycle in redirecting constructors"),
201 RETHROW_NOT_IN_CATCH("Re-throw not in a catch block"),
202 STATIC_FINAL_REQUIRES_VALUE("Static final fields must have an initial value"),
203 STATIC_METHOD_MUST_HAVE_BODY("Static method must have a body"),
204 SUPER_CLASS_IN_IMPLEMENTS("Superclass in implements clause"),
205 SUPER_CLASS_IN_WITH("Superclass in with clause"),
206 SUPER_IN_FACTORY_CONSTRUCTOR("Cannot use 'super' in a factory constructor"),
207 SUPER_IN_STATIC_METHOD("Cannot use 'super' in a static method"),
208 SUPER_OUTSIDE_OF_CONSTRUCTOR("Cannot use 'super' constructor outside of a cons tructor"),
209 SUPER_OUTSIDE_OF_METHOD("Cannot use 'super' outside of a method"),
210 SUPER_ON_TOP_LEVEL("Cannot use 'super' in a top-level element"),
211 SWITCH_CASE_FALL_THROUGH(ErrorSeverity.WARNING, "Switch case should end with b reak, continue, return or throw"),
212 THIS_IN_STATIC_METHOD("Cannot use 'this' in a static method"),
213 THIS_IN_INITIALIZER_AS_EXPRESSION("Cannot reference 'this' as expression in in itializer list"),
214 THIS_ON_TOP_LEVEL("Cannot use 'this' in a top-level element"),
215 THIS_OUTSIDE_OF_METHOD("Cannot use 'this' outside of a method"),
216 THIS_IN_FACTORY_CONSTRUCTOR("Cannot use 'this' in a factory constructor"),
217 TOO_FEW_ARGUMENTS_IN_IMPLICIT_SUPER("Too few arguments in implicit super() con structor invocation in '%s'"),
218 TOO_MANY_QUALIFIERS_FOR_METHOD("Too many qualifiers for method or constructor" ),
219 TOPLEVEL_FINAL_REQUIRES_VALUE("Top-level final fields must have an initial val ue"),
220 TYPE_VARIABLE_DOES_NOT_MATCH("Type variable %s does not match %s in default cl ass %s."),
221 TYPE_PARAMETERS_MUST_MATCH_EXACTLY(
222 "Type parameters in default declaration must match referenced class exactl y"),
223 TYPE_VARIABLE_IN_STATIC_CONTEXT(ErrorSeverity.WARNING, "cannot access type var iable %s in static context"),
224 TYPE_VARIABLE_IN_STATIC_CONTEXT_ERROR("cannot access type variable %s in stati c context"),
225 TYPE_VARIABLE_NOT_ALLOWED_IN_IDENTIFIER(
226 "type variables are not allowed in identifier expressions"),
227 USE_ASSIGNMENT_ON_SETTER("Use assignment to set field '%s'"),
228 USING_LOCAL_VARIABLE_BEFORE_DECLARATION(ErrorSeverity.WARNING, "Using local va riable '%s' before its declaration in lexical scope"),
229 VARIABLE_REFERENCES_SAME_NAME_IN_INITIALIZER("Initializer of variable \"%s\" c annot refer to the name \"%s\""),
230 WRONG_NUMBER_OF_TYPE_ARGUMENTS("%s: wrong number of type arguments (%d). Expe cted %d");
231
232 private final ErrorSeverity severity;
233 private final String message;
234
235 /**
236 * Initialize a newly created error code to have the given message and ERROR s everity.
237 */
238 private ResolverErrorCode(String message) {
239 this(ErrorSeverity.ERROR, message);
240 }
241
242 /**
243 * Initialize a newly created error code to have the given severity and messag e.
244 */
245 private ResolverErrorCode(ErrorSeverity severity, String message) {
246 this.severity = severity;
247 this.message = message;
248 }
249
250 @Override
251 public String getMessage() {
252 return message;
253 }
254
255 @Override
256 public ErrorSeverity getErrorSeverity() {
257 return severity;
258 }
259
260 @Override
261 public SubSystem getSubSystem() {
262 return SubSystem.RESOLVER;
263 }
264
265 @Override
266 public boolean needsRecompilation() {
267 return true;
268 }
269 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698