1 /*******************************************************************************
2 * Copyright (c) 2000, 2002 IBM Corp. and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 * IBM Corporation - added the following constants
11 * NonStaticAccessToStaticField
12 * NonStaticAccessToStaticMethod
15 * IBM Corporation - added the following constants
16 * TooManySyntheticArgumentSlots
17 * TooManyArrayDimensions
18 * TooManyBytesForStringConstant
21 * NonBlankFinalLocalAssignment
22 * ObjectCannotHaveSuperTypes
24 * InvalidExpressionAsName
25 ****************************************************************************/
26 package net.sourceforge.phpdt.core.compiler;
28 import net.sourceforge.phpdt.internal.compiler.lookup.ProblemReasons;
31 * Description of a Java problem, as detected by the compiler or some of the underlying
32 * technology reusing the compiler.
33 * A problem provides access to:
35 * <li> its location (originating source file name, source position, line number), </li>
36 * <li> its message description and a predicate to check its severity (warning or error). </li>
37 * <li> its ID : an number identifying the very nature of this problem. All possible IDs are listed
38 * as constants on this interface. </li>
41 * Note: the compiler produces IProblems internally, which are turned into markers by the JavaBuilder
42 * so as to persist problem descriptions. This explains why there is no API allowing to reach IProblem detected
43 * when compiling. However, the Java problem markers carry equivalent information to IProblem, in particular
44 * their ID (attribute "id") is set to one of the IDs defined on this interface.
48 public interface IProblem {
51 * Answer back the original arguments recorded into the problem.
52 * @return the original arguments recorded into the problem
54 String[] getArguments();
57 * Returns the problem id
59 * @return the problem id
64 * Answer a localized, human-readable message string which describes the problem.
66 * @return a localized, human-readable message string which describes the problem
71 * Answer the file name in which the problem was found.
73 * @return the file name in which the problem was found
75 char[] getOriginatingFileName();
78 * Answer the end position of the problem (inclusive), or -1 if unknown.
80 * @return the end position of the problem (inclusive), or -1 if unknown
85 * Answer the line number in source where the problem begins.
87 * @return the line number in source where the problem begins
89 int getSourceLineNumber();
92 * Answer the start position of the problem (inclusive), or -1 if unknown.
94 * @return the start position of the problem (inclusive), or -1 if unknown
99 * Checks the severity to see if the Error bit is set.
101 * @return true if the Error bit is set for the severity, false otherwise
106 * Checks the severity to see if the Error bit is not set.
108 * @return true if the Error bit is not set for the severity, false otherwise
113 * Set the end position of the problem (inclusive), or -1 if unknown.
114 * Used for shifting problem positions.
116 * @param sourceEnd the given end position
118 void setSourceEnd(int sourceEnd);
121 * Set the line number in source where the problem begins.
123 * @param lineNumber the given line number
125 void setSourceLineNumber(int lineNumber);
128 * Set the start position of the problem (inclusive), or -1 if unknown.
129 * Used for shifting problem positions.
131 * @param the given start position
133 void setSourceStart(int sourceStart);
137 * The high bits of a problem ID contains information about the category of a problem.
138 * e.g. (problemID & TypeRelated) != 0, indicates that this problem is type related.
140 * A problem category can help to implement custom problem filters. Indeed, when numerous problems
141 * are listed, focusing on import related problems first might be relevant.
143 * When a problem is tagged as Internal, it means that no change other than a local source code change
144 * can fix the corresponding problem.
146 int TypeRelated = 0x01000000;
147 int FieldRelated = 0x02000000;
148 int MethodRelated = 0x04000000;
149 int ConstructorRelated = 0x08000000;
150 int ImportRelated = 0x10000000;
151 int Internal = 0x20000000;
152 int Syntax = 0x40000000;
155 * Mask to use in order to filter out the category portion of the problem ID.
157 int IgnoreCategoriesMask = 0xFFFFFF;
160 * Below are listed all available problem IDs. Note that this list could be augmented in the future,
161 * as new features are added to the Java core implementation.
165 * ID reserved for referencing an internal error inside the JavaCore implementation which
166 * may be surfaced as a problem associated with the compilation unit which caused it to occur.
168 int Unclassified = 0;
171 * Generic type related problems
173 int ObjectHasNoSuperclass = TypeRelated + 1;
174 int UndefinedType = TypeRelated + 2;
175 int NotVisibleType = TypeRelated + 3;
176 int AmbiguousType = TypeRelated + 4;
177 int UsingDeprecatedType = TypeRelated + 5;
178 int InternalTypeNameProvided = TypeRelated + 6;
180 int IncompatibleTypesInEqualityOperator = TypeRelated + 15;
181 int IncompatibleTypesInConditionalOperator = TypeRelated + 16;
182 int TypeMismatch = TypeRelated + 17;
185 * Inner types related problems
187 int MissingEnclosingInstanceForConstructorCall = TypeRelated + 20;
188 int MissingEnclosingInstance = TypeRelated + 21;
189 int IncorrectEnclosingInstanceReference = TypeRelated + 22;
190 int IllegalEnclosingInstanceSpecification = TypeRelated + 23;
191 int CannotDefineStaticInitializerInLocalType = Internal + 24;
192 int OuterLocalMustBeFinal = Internal + 25;
193 int CannotDefineInterfaceInLocalType = Internal + 26;
194 int IllegalPrimitiveOrArrayTypeForEnclosingInstance = TypeRelated + 27;
195 int AnonymousClassCannotExtendFinalClass = TypeRelated + 29;
198 int UndefinedName = 50;
199 int UninitializedLocalVariable = Internal + 51;
200 int VariableTypeCannotBeVoid = Internal + 52;
201 int VariableTypeCannotBeVoidArray = Internal + 53;
202 int CannotAllocateVoidArray = Internal + 54;
204 int RedefinedLocal = Internal + 55;
205 int RedefinedArgument = Internal + 56;
206 // final local variables
207 int DuplicateFinalLocalInitialization = Internal + 57;
209 int NonBlankFinalLocalAssignment = Internal + 58;
210 int FinalOuterLocalAssignment = Internal + 60;
211 int LocalVariableIsNeverUsed = Internal + 61;
212 int ArgumentIsNeverUsed = Internal + 62;
213 int BytecodeExceeds64KLimit = Internal + 63;
214 int BytecodeExceeds64KLimitForClinit = Internal + 64;
215 int TooManyArgumentSlots = Internal + 65;
216 int TooManyLocalVariableSlots = Internal + 66;
218 int TooManySyntheticArgumentSlots = Internal + 67;
220 int TooManyArrayDimensions = Internal + 68;
223 int UndefinedField = FieldRelated + 70;
224 int NotVisibleField = FieldRelated + 71;
225 int AmbiguousField = FieldRelated + 72;
226 int UsingDeprecatedField = FieldRelated + 73;
227 int NonStaticFieldFromStaticInvocation = FieldRelated + 74;
228 int ReferenceToForwardField = FieldRelated + Internal + 75;
230 int NonStaticAccessToStaticField = Internal + FieldRelated + 76;
232 // blank final fields
233 int FinalFieldAssignment = FieldRelated + 80;
234 int UninitializedBlankFinalField = FieldRelated + 81;
235 int DuplicateBlankFinalFieldInitialization = FieldRelated + 82;
238 int UndefinedMethod = MethodRelated + 100;
239 int NotVisibleMethod = MethodRelated + 101;
240 int AmbiguousMethod = MethodRelated + 102;
241 int UsingDeprecatedMethod = MethodRelated + 103;
242 int DirectInvocationOfAbstractMethod = MethodRelated + 104;
243 int VoidMethodReturnsValue = MethodRelated + 105;
244 int MethodReturnsVoid = MethodRelated + 106;
245 int MethodRequiresBody = Internal + MethodRelated + 107;
246 int ShouldReturnValue = Internal + MethodRelated + 108;
247 int MethodButWithConstructorName = MethodRelated + 110;
248 int MissingReturnType = TypeRelated + 111;
249 int BodyForNativeMethod = Internal + MethodRelated + 112;
250 int BodyForAbstractMethod = Internal + MethodRelated + 113;
251 int NoMessageSendOnBaseType = MethodRelated + 114;
252 int ParameterMismatch = MethodRelated + 115;
253 int NoMessageSendOnArrayType = MethodRelated + 116;
255 int NonStaticAccessToStaticMethod = Internal + MethodRelated + 117;
258 int UndefinedConstructor = ConstructorRelated + 130;
259 int NotVisibleConstructor = ConstructorRelated + 131;
260 int AmbiguousConstructor = ConstructorRelated + 132;
261 int UsingDeprecatedConstructor = ConstructorRelated + 133;
262 // explicit constructor calls
263 int InstanceFieldDuringConstructorInvocation = ConstructorRelated + 135;
264 int InstanceMethodDuringConstructorInvocation = ConstructorRelated + 136;
265 int RecursiveConstructorInvocation = ConstructorRelated + 137;
266 int ThisSuperDuringConstructorInvocation = ConstructorRelated + 138;
267 // implicit constructor calls
268 int UndefinedConstructorInDefaultConstructor = ConstructorRelated + 140;
269 int NotVisibleConstructorInDefaultConstructor = ConstructorRelated + 141;
270 int AmbiguousConstructorInDefaultConstructor = ConstructorRelated + 142;
271 int UndefinedConstructorInImplicitConstructorCall = ConstructorRelated + 143;
272 int NotVisibleConstructorInImplicitConstructorCall = ConstructorRelated + 144;
273 int AmbiguousConstructorInImplicitConstructorCall = ConstructorRelated + 145;
274 int UnhandledExceptionInDefaultConstructor = TypeRelated + 146;
275 int UnhandledExceptionInImplicitConstructorCall = TypeRelated + 147;
278 int ArrayReferenceRequired = Internal + 150;
279 int NoImplicitStringConversionForCharArrayExpression = Internal + 151;
280 // constant expressions
281 int StringConstantIsExceedingUtf8Limit = Internal + 152;
282 int NonConstantExpression = 153;
283 int NumericValueOutOfRange = Internal + 154;
285 int IllegalCast = TypeRelated + 156;
287 int InvalidClassInstantiation = TypeRelated + 157;
288 int CannotDefineDimensionExpressionsWithInit = Internal + 158;
289 int MustDefineEitherDimensionExpressionsOrInitializer = Internal + 159;
291 int InvalidOperator = Internal + 160;
293 int CodeCannotBeReached = Internal + 161;
294 int CannotReturnInInitializer = Internal + 162;
295 int InitializerMustCompleteNormally = Internal + 163;
298 int InvalidVoidExpression = Internal + 164;
300 int MaskedCatch = TypeRelated + 165;
301 int DuplicateDefaultCase = 166;
302 int UnreachableCatch = TypeRelated + MethodRelated + 167;
303 int UnhandledException = TypeRelated + 168;
305 int IncorrectSwitchType = TypeRelated + 169;
306 int DuplicateCase = FieldRelated + 170;
308 int DuplicateLabel = Internal + 171;
309 int InvalidBreak = Internal + 172;
310 int InvalidContinue = Internal + 173;
311 int UndefinedLabel = Internal + 174;
313 int InvalidTypeToSynchronized = Internal + 175;
314 int InvalidNullToSynchronized = Internal + 176;
316 int CannotThrowNull = Internal + 177;
319 int AssignmentHasNoEffect = Internal + 178;
322 int NeedToEmulateFieldReadAccess = FieldRelated + 190;
323 int NeedToEmulateFieldWriteAccess = FieldRelated + 191;
324 int NeedToEmulateMethodAccess = MethodRelated + 192;
325 int NeedToEmulateConstructorAccess = MethodRelated + 193;
327 //inherited name hides enclosing name (sort of ambiguous)
328 int InheritedMethodHidesEnclosingName = MethodRelated + 195;
329 int InheritedFieldHidesEnclosingName = FieldRelated + 196;
330 int InheritedTypeHidesEnclosingName = TypeRelated + 197;
333 int ThisInStaticContext = Internal + 200;
334 int StaticMethodRequested = Internal + MethodRelated + 201;
335 int IllegalDimension = Internal + 202;
336 int InvalidTypeExpression = Internal + 203;
337 int ParsingError = Syntax + Internal + 204;
338 int ParsingErrorNoSuggestion = Syntax + Internal + 205;
339 int InvalidUnaryExpression = Syntax + Internal + 206;
342 int InterfaceCannotHaveConstructors = Syntax + Internal + 207;
343 int ArrayConstantsOnlyInArrayInitializers = Syntax + Internal + 208;
344 int ParsingErrorOnKeyword = Syntax + Internal + 209;
345 int ParsingErrorOnKeywordNoSuggestion = Syntax + Internal + 210;
347 int UnmatchedBracket = Syntax + Internal + 220;
348 int NoFieldOnBaseType = FieldRelated + 221;
349 int InvalidExpressionAsStatement = Syntax + Internal + 222;
350 int ExpressionShouldBeAVariable = Syntax + Internal + 223;
351 int MissingSemiColon = Syntax + Internal + 224;
354 int EndOfSource = Syntax + Internal + 250;
355 int InvalidHexa = Syntax + Internal + 251;
356 int InvalidOctal = Syntax + Internal + 252;
357 int InvalidCharacterConstant = Syntax + Internal + 253;
358 int InvalidEscape = Syntax + Internal + 254;
359 int InvalidInput = Syntax + Internal + 255;
360 int InvalidUnicodeEscape = Syntax + Internal + 256;
361 int InvalidFloat = Syntax + Internal + 257;
362 int NullSourceString = Syntax + Internal + 258;
363 int UnterminatedString = Syntax + Internal + 259;
364 int UnterminatedComment = Syntax + Internal + 260;
366 // type related problems
367 int InterfaceCannotHaveInitializers = TypeRelated + 300;
368 int DuplicateModifierForType = TypeRelated + 301;
369 int IllegalModifierForClass = TypeRelated + 302;
370 int IllegalModifierForInterface = TypeRelated + 303;
371 int IllegalModifierForMemberClass = TypeRelated + 304;
372 int IllegalModifierForMemberInterface = TypeRelated + 305;
373 int IllegalModifierForLocalClass = TypeRelated + 306;
375 int IllegalModifierCombinationFinalAbstractForClass = TypeRelated + 308;
376 int IllegalVisibilityModifierForInterfaceMemberType = TypeRelated + 309;
377 int IllegalVisibilityModifierCombinationForMemberType = TypeRelated + 310;
378 int IllegalStaticModifierForMemberType = TypeRelated + 311;
379 int SuperclassMustBeAClass = TypeRelated + 312;
380 int ClassExtendFinalClass = TypeRelated + 313;
381 int DuplicateSuperInterface = TypeRelated + 314;
382 int SuperInterfaceMustBeAnInterface = TypeRelated + 315;
383 int HierarchyCircularitySelfReference = TypeRelated + 316;
384 int HierarchyCircularity = TypeRelated + 317;
385 int HidingEnclosingType = TypeRelated + 318;
386 int DuplicateNestedType = TypeRelated + 319;
387 int CannotThrowType = TypeRelated + 320;
388 int PackageCollidesWithType = TypeRelated + 321;
389 int TypeCollidesWithPackage = TypeRelated + 322;
390 int DuplicateTypes = TypeRelated + 323;
391 // int IsClassPathCorrect = TypeRelated + 324;
392 int PublicClassMustMatchFileName = TypeRelated + 325;
393 int MustSpecifyPackage = 326;
394 int HierarchyHasProblems = TypeRelated + 327;
395 int PackageIsNotExpectedPackage = 328;
396 int ObjectCannotHaveSuperTypes = 329;
398 // int InvalidSuperclassBase = TypeRelated + 329; // reserved to 334 included
399 int SuperclassNotFound = TypeRelated + 329 + ProblemReasons.NotFound; // TypeRelated + 330
400 int SuperclassNotVisible = TypeRelated + 329 + ProblemReasons.NotVisible; // TypeRelated + 331
401 int SuperclassAmbiguous = TypeRelated + 329 + ProblemReasons.Ambiguous; // TypeRelated + 332
402 int SuperclassInternalNameProvided = TypeRelated + 329 + ProblemReasons.InternalNameProvided; // TypeRelated + 333
403 int SuperclassInheritedNameHidesEnclosingName = TypeRelated + 329 + ProblemReasons.InheritedNameHidesEnclosingName; // TypeRelated + 334
405 // int InvalidInterfaceBase = TypeRelated + 334; // reserved to 339 included
406 int InterfaceNotFound = TypeRelated + 334 + ProblemReasons.NotFound; // TypeRelated + 335
407 int InterfaceNotVisible = TypeRelated + 334 + ProblemReasons.NotVisible; // TypeRelated + 336
408 int InterfaceAmbiguous = TypeRelated + 334 + ProblemReasons.Ambiguous; // TypeRelated + 337
409 int InterfaceInternalNameProvided = TypeRelated + 334 + ProblemReasons.InternalNameProvided; // TypeRelated + 338
410 int InterfaceInheritedNameHidesEnclosingName = TypeRelated + 334 + ProblemReasons.InheritedNameHidesEnclosingName; // TypeRelated + 339
412 // field related problems
413 int DuplicateField = FieldRelated + 340;
414 int DuplicateModifierForField = FieldRelated + 341;
415 int IllegalModifierForField = FieldRelated + 342;
416 int IllegalModifierForInterfaceField = FieldRelated + 343;
417 int IllegalVisibilityModifierCombinationForField = FieldRelated + 344;
418 int IllegalModifierCombinationFinalVolatileForField = FieldRelated + 345;
419 int UnexpectedStaticModifierForField = FieldRelated + 346;
421 // int FieldTypeProblemBase = FieldRelated + 349; //reserved to 354
422 int FieldTypeNotFound = FieldRelated + 349 + ProblemReasons.NotFound; // FieldRelated + 350
423 int FieldTypeNotVisible = FieldRelated + 349 + ProblemReasons.NotVisible; // FieldRelated + 351
424 int FieldTypeAmbiguous = FieldRelated + 349 + ProblemReasons.Ambiguous; // FieldRelated + 352
425 int FieldTypeInternalNameProvided = FieldRelated + 349 + ProblemReasons.InternalNameProvided; // FieldRelated + 353
426 int FieldTypeInheritedNameHidesEnclosingName = FieldRelated + 349 + ProblemReasons.InheritedNameHidesEnclosingName; // FieldRelated + 354
428 // method related problems
429 int DuplicateMethod = MethodRelated + 355;
430 int IllegalModifierForArgument = MethodRelated + 356;
431 int DuplicateModifierForMethod = MethodRelated + 357;
432 int IllegalModifierForMethod = MethodRelated + 358;
433 int IllegalModifierForInterfaceMethod = MethodRelated + 359;
434 int IllegalVisibilityModifierCombinationForMethod = MethodRelated + 360;
435 int UnexpectedStaticModifierForMethod = MethodRelated + 361;
436 int IllegalAbstractModifierCombinationForMethod = MethodRelated + 362;
437 int AbstractMethodInAbstractClass = MethodRelated + 363;
438 int ArgumentTypeCannotBeVoid = MethodRelated + 364;
439 int ArgumentTypeCannotBeVoidArray = MethodRelated + 365;
440 int ReturnTypeCannotBeVoidArray = MethodRelated + 366;
441 int NativeMethodsCannotBeStrictfp = MethodRelated + 367;
442 int DuplicateModifierForArgument = MethodRelated + 368;
444 // int ArgumentProblemBase = MethodRelated + 369; // reserved to 374 included.
445 int ArgumentTypeNotFound = MethodRelated + 369 + ProblemReasons.NotFound; // MethodRelated + 370
446 int ArgumentTypeNotVisible = MethodRelated + 369 + ProblemReasons.NotVisible; // MethodRelated + 371
447 int ArgumentTypeAmbiguous = MethodRelated + 369 + ProblemReasons.Ambiguous; // MethodRelated + 372
448 int ArgumentTypeInternalNameProvided = MethodRelated + 369 + ProblemReasons.InternalNameProvided; // MethodRelated + 373
449 int ArgumentTypeInheritedNameHidesEnclosingName = MethodRelated + 369 + ProblemReasons.InheritedNameHidesEnclosingName; // MethodRelated + 374
451 // int ExceptionTypeProblemBase = MethodRelated + 374; // reserved to 379 included.
452 int ExceptionTypeNotFound = MethodRelated + 374 + ProblemReasons.NotFound; // MethodRelated + 375
453 int ExceptionTypeNotVisible = MethodRelated + 374 + ProblemReasons.NotVisible; // MethodRelated + 376
454 int ExceptionTypeAmbiguous = MethodRelated + 374 + ProblemReasons.Ambiguous; // MethodRelated + 377
455 int ExceptionTypeInternalNameProvided = MethodRelated + 374 + ProblemReasons.InternalNameProvided; // MethodRelated + 378
456 int ExceptionTypeInheritedNameHidesEnclosingName = MethodRelated + 374 + ProblemReasons.InheritedNameHidesEnclosingName; // MethodRelated + 379
458 // int ReturnTypeProblemBase = MethodRelated + 379;
459 int ReturnTypeNotFound = MethodRelated + 379 + ProblemReasons.NotFound; // MethodRelated + 380
460 int ReturnTypeNotVisible = MethodRelated + 379 + ProblemReasons.NotVisible; // MethodRelated + 381
461 int ReturnTypeAmbiguous = MethodRelated + 379 + ProblemReasons.Ambiguous; // MethodRelated + 382
462 int ReturnTypeInternalNameProvided = MethodRelated + 379 + ProblemReasons.InternalNameProvided; // MethodRelated + 383
463 int ReturnTypeInheritedNameHidesEnclosingName = MethodRelated + 379 + ProblemReasons.InheritedNameHidesEnclosingName; // MethodRelated + 384
465 // import related problems
466 int ConflictingImport = ImportRelated + 385;
467 int DuplicateImport = ImportRelated + 386;
468 int CannotImportPackage = ImportRelated + 387;
469 int UnusedImport = ImportRelated + 388;
471 // int ImportProblemBase = ImportRelated + 389;
472 int ImportNotFound = ImportRelated + 389 + ProblemReasons.NotFound; // ImportRelated + 390
473 int ImportNotVisible = ImportRelated + 389 + ProblemReasons.NotVisible; // ImportRelated + 391
474 int ImportAmbiguous = ImportRelated + 389 + ProblemReasons.Ambiguous; // ImportRelated + 392
475 int ImportInternalNameProvided = ImportRelated + 389 + ProblemReasons.InternalNameProvided; // ImportRelated + 393
476 int ImportInheritedNameHidesEnclosingName = ImportRelated + 389 + ProblemReasons.InheritedNameHidesEnclosingName; // ImportRelated + 394
479 // local variable related problems
480 int DuplicateModifierForVariable = MethodRelated + 395;
481 int IllegalModifierForVariable = MethodRelated + 396;
483 // method verifier problems
484 int AbstractMethodMustBeImplemented = MethodRelated + 400;
485 int FinalMethodCannotBeOverridden = MethodRelated + 401;
486 int IncompatibleExceptionInThrowsClause = MethodRelated + 402;
487 int IncompatibleExceptionInInheritedMethodThrowsClause = MethodRelated + 403;
488 int IncompatibleReturnType = MethodRelated + 404;
489 int InheritedMethodReducesVisibility = MethodRelated + 405;
490 int CannotOverrideAStaticMethodWithAnInstanceMethod = MethodRelated + 406;
491 int CannotHideAnInstanceMethodWithAStaticMethod = MethodRelated + 407;
492 int StaticInheritedMethodConflicts = MethodRelated + 408;
493 int MethodReducesVisibility = MethodRelated + 409;
494 int OverridingNonVisibleMethod = MethodRelated + 410;
495 int AbstractMethodCannotBeOverridden = MethodRelated + 411;
496 int OverridingDeprecatedMethod = MethodRelated + 412;
498 // code snippet support
499 int CodeSnippetMissingClass = Internal + 420;
500 int CodeSnippetMissingMethod = Internal + 421;
501 int NonExternalizedStringLiteral = Internal + 261;
502 int CannotUseSuperInCodeSnippet = Internal + 422;
505 int TooManyConstantsInConstantPool = Internal + 430;
506 int TooManyBytesForStringConstant = Internal + 431;
508 // static constraints
509 int TooManyFields = Internal + 432;
510 int TooManyMethods = Internal + 433;
514 int UseAssertAsAnIdentifier = Internal + 440;
518 int Task = Internal + 450;