| 1 11 package org.eclipse.jdt.internal.compiler.problem; 12 13 import java.io.CharConversionException ; 14 import java.io.PrintWriter ; 15 import java.io.StringWriter ; 16 import java.text.MessageFormat ; 17 18 import org.eclipse.jdt.core.compiler.CategorizedProblem; 19 import org.eclipse.jdt.core.compiler.CharOperation; 20 import org.eclipse.jdt.core.compiler.IProblem; 21 import org.eclipse.jdt.core.compiler.InvalidInputException; 22 import org.eclipse.jdt.internal.compiler.*; 23 import org.eclipse.jdt.internal.compiler.ast.*; 24 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; 25 import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; 26 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; 27 import org.eclipse.jdt.internal.compiler.impl.ReferenceContext; 28 import org.eclipse.jdt.internal.compiler.lookup.*; 29 import org.eclipse.jdt.internal.compiler.parser.*; 30 import org.eclipse.jdt.internal.compiler.util.Messages; 31 32 public class ProblemReporter extends ProblemHandler { 33 34 public ReferenceContext referenceContext; 35 private Scanner positionScanner; 36 37 public static long getIrritant(int problemID) { 38 switch(problemID){ 39 40 case IProblem.MaskedCatch : 41 return CompilerOptions.MaskedCatchBlock; 42 43 case IProblem.UnusedImport : 44 return CompilerOptions.UnusedImport; 45 46 case IProblem.MethodButWithConstructorName : 47 return CompilerOptions.MethodWithConstructorName; 48 49 case IProblem.OverridingNonVisibleMethod : 50 return CompilerOptions.OverriddenPackageDefaultMethod; 51 52 case IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod : 53 case IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod : 54 return CompilerOptions.IncompatibleNonInheritedInterfaceMethod; 55 56 case IProblem.OverridingDeprecatedMethod : 57 case IProblem.UsingDeprecatedType : 58 case IProblem.UsingDeprecatedMethod : 59 case IProblem.UsingDeprecatedConstructor : 60 case IProblem.UsingDeprecatedField : 61 return CompilerOptions.UsingDeprecatedAPI; 62 63 case IProblem.LocalVariableIsNeverUsed : 64 return CompilerOptions.UnusedLocalVariable; 65 66 case IProblem.ArgumentIsNeverUsed : 67 return CompilerOptions.UnusedArgument; 68 69 case IProblem.NoImplicitStringConversionForCharArrayExpression : 70 return CompilerOptions.NoImplicitStringConversion; 71 72 case IProblem.NeedToEmulateFieldReadAccess : 73 case IProblem.NeedToEmulateFieldWriteAccess : 74 case IProblem.NeedToEmulateMethodAccess : 75 case IProblem.NeedToEmulateConstructorAccess : 76 return CompilerOptions.AccessEmulation; 77 78 case IProblem.NonExternalizedStringLiteral : 79 case IProblem.UnnecessaryNLSTag : 80 return CompilerOptions.NonExternalizedString; 81 82 case IProblem.UseAssertAsAnIdentifier : 83 return CompilerOptions.AssertUsedAsAnIdentifier; 84 85 case IProblem.UseEnumAsAnIdentifier : 86 return CompilerOptions.EnumUsedAsAnIdentifier; 87 88 case IProblem.NonStaticAccessToStaticMethod : 89 case IProblem.NonStaticAccessToStaticField : 90 return CompilerOptions.NonStaticAccessToStatic; 91 92 case IProblem.IndirectAccessToStaticMethod : 93 case IProblem.IndirectAccessToStaticField : 94 case IProblem.IndirectAccessToStaticType : 95 return CompilerOptions.IndirectStaticAccess; 96 97 case IProblem.AssignmentHasNoEffect: 98 return CompilerOptions.NoEffectAssignment; 99 100 case IProblem.UnusedPrivateConstructor: 101 case IProblem.UnusedPrivateMethod: 102 case IProblem.UnusedPrivateField: 103 case IProblem.UnusedPrivateType: 104 return CompilerOptions.UnusedPrivateMember; 105 106 case IProblem.LocalVariableHidingLocalVariable: 107 case IProblem.LocalVariableHidingField: 108 case IProblem.ArgumentHidingLocalVariable: 109 case IProblem.ArgumentHidingField: 110 return CompilerOptions.LocalVariableHiding; 111 112 case IProblem.FieldHidingLocalVariable: 113 case IProblem.FieldHidingField: 114 return CompilerOptions.FieldHiding; 115 116 case IProblem.TypeParameterHidingType: 117 case IProblem.TypeHidingTypeParameterFromType: 118 case IProblem.TypeHidingTypeParameterFromMethod: 119 case IProblem.TypeHidingType: 120 return CompilerOptions.TypeHiding; 121 122 case IProblem.PossibleAccidentalBooleanAssignment: 123 return CompilerOptions.AccidentalBooleanAssign; 124 125 case IProblem.SuperfluousSemicolon: 126 case IProblem.EmptyControlFlowStatement: 127 return CompilerOptions.EmptyStatement; 128 129 case IProblem.UndocumentedEmptyBlock: 130 return CompilerOptions.UndocumentedEmptyBlock; 131 132 case IProblem.UnnecessaryCast: 133 case IProblem.UnnecessaryInstanceof: 134 return CompilerOptions.UnnecessaryTypeCheck; 135 136 case IProblem.FinallyMustCompleteNormally: 137 return CompilerOptions.FinallyBlockNotCompleting; 138 139 case IProblem.UnusedMethodDeclaredThrownException: 140 case IProblem.UnusedConstructorDeclaredThrownException: 141 return CompilerOptions.UnusedDeclaredThrownException; 142 143 case IProblem.UnqualifiedFieldAccess: 144 return CompilerOptions.UnqualifiedFieldAccess; 145 146 case IProblem.UnnecessaryElse: 147 return CompilerOptions.UnnecessaryElse; 148 149 case IProblem.UnsafeRawConstructorInvocation: 150 case IProblem.UnsafeRawMethodInvocation: 151 case IProblem.UnsafeTypeConversion: 152 case IProblem.UnsafeRawFieldAssignment: 153 case IProblem.UnsafeGenericCast: 154 case IProblem.UnsafeReturnTypeOverride: 155 case IProblem.UnsafeRawGenericMethodInvocation: 156 case IProblem.UnsafeRawGenericConstructorInvocation: 157 case IProblem.UnsafeGenericArrayForVarargs: 158 return CompilerOptions.UncheckedTypeOperation; 159 160 case IProblem.RawTypeReference: 161 return CompilerOptions.RawTypeReference; 162 163 case IProblem.MissingOverrideAnnotation: 164 return CompilerOptions.MissingOverrideAnnotation; 165 166 case IProblem.FieldMissingDeprecatedAnnotation: 167 case IProblem.MethodMissingDeprecatedAnnotation: 168 case IProblem.TypeMissingDeprecatedAnnotation: 169 return CompilerOptions.MissingDeprecatedAnnotation; 170 171 case IProblem.FinalBoundForTypeVariable: 172 return CompilerOptions.FinalParameterBound; 173 174 case IProblem.MissingSerialVersion: 175 return CompilerOptions.MissingSerialVersion; 176 177 case IProblem.ForbiddenReference: 178 return CompilerOptions.ForbiddenReference; 179 180 case IProblem.DiscouragedReference: 181 return CompilerOptions.DiscouragedReference; 182 183 case IProblem.MethodVarargsArgumentNeedCast : 184 case IProblem.ConstructorVarargsArgumentNeedCast : 185 return CompilerOptions.VarargsArgumentNeedCast; 186 187 case IProblem.NullLocalVariableReference: 188 return CompilerOptions.NullReference; 189 190 case IProblem.PotentialNullLocalVariableReference: 191 return CompilerOptions.PotentialNullReference; 192 193 case IProblem.RedundantLocalVariableNullAssignment: 194 case IProblem.RedundantNullCheckOnNonNullLocalVariable: 195 case IProblem.RedundantNullCheckOnNullLocalVariable: 196 case IProblem.NonNullLocalVariableComparisonYieldsFalse: 197 case IProblem.NullLocalVariableComparisonYieldsFalse: 198 case IProblem.NullLocalVariableInstanceofYieldsFalse: 199 return CompilerOptions.RedundantNullCheck; 200 201 case IProblem.BoxingConversion : 202 case IProblem.UnboxingConversion : 203 return CompilerOptions.AutoBoxing; 204 205 case IProblem.MissingEnumConstantCase : 206 return CompilerOptions.IncompleteEnumSwitch; 207 208 case IProblem.AnnotationTypeUsedAsSuperInterface : 209 return CompilerOptions.AnnotationSuperInterface; 210 211 case IProblem.UnhandledWarningToken : 212 return CompilerOptions.UnhandledWarningToken; 213 214 case IProblem.UnusedLabel : 215 return CompilerOptions.UnusedLabel; 216 217 case IProblem.JavadocUnexpectedTag: 218 case IProblem.JavadocDuplicateTag: 219 case IProblem.JavadocDuplicateReturnTag: 220 case IProblem.JavadocInvalidThrowsClass: 221 case IProblem.JavadocInvalidSeeReference: 222 case IProblem.JavadocInvalidParamTagName: 223 case IProblem.JavadocInvalidParamTagTypeParameter: 224 case IProblem.JavadocMalformedSeeReference: 225 case IProblem.JavadocInvalidSeeHref: 226 case IProblem.JavadocInvalidSeeArgs: 227 case IProblem.JavadocInvalidTag: 228 case IProblem.JavadocUnterminatedInlineTag: 229 case IProblem.JavadocMissingHashCharacter: 230 case IProblem.JavadocEmptyReturnTag: 231 case IProblem.JavadocUnexpectedText: 232 case IProblem.JavadocInvalidParamName: 233 case IProblem.JavadocDuplicateParamName: 234 case IProblem.JavadocMissingParamName: 235 case IProblem.JavadocMissingIdentifier: 236 case IProblem.JavadocInvalidMemberTypeQualification: 237 case IProblem.JavadocInvalidThrowsClassName: 238 case IProblem.JavadocDuplicateThrowsClassName: 239 case IProblem.JavadocMissingThrowsClassName: 240 case IProblem.JavadocMissingSeeReference: 241 case IProblem.JavadocInvalidValueReference: 242 case IProblem.JavadocUndefinedField: 243 case IProblem.JavadocAmbiguousField: 244 case IProblem.JavadocUndefinedConstructor: 245 case IProblem.JavadocAmbiguousConstructor: 246 case IProblem.JavadocUndefinedMethod: 247 case IProblem.JavadocAmbiguousMethod: 248 case IProblem.JavadocAmbiguousMethodReference: 249 case IProblem.JavadocParameterMismatch: 250 case IProblem.JavadocUndefinedType: 251 case IProblem.JavadocAmbiguousType: 252 case IProblem.JavadocInternalTypeNameProvided: 253 case IProblem.JavadocNoMessageSendOnArrayType: 254 case IProblem.JavadocNoMessageSendOnBaseType: 255 case IProblem.JavadocInheritedMethodHidesEnclosingName: 256 case IProblem.JavadocInheritedFieldHidesEnclosingName: 257 case IProblem.JavadocInheritedNameHidesEnclosingTypeName: 258 case IProblem.JavadocNonStaticTypeFromStaticInvocation: 259 case IProblem.JavadocGenericMethodTypeArgumentMismatch: 260 case IProblem.JavadocNonGenericMethod: 261 case IProblem.JavadocIncorrectArityForParameterizedMethod: 262 case IProblem.JavadocParameterizedMethodArgumentTypeMismatch: 263 case IProblem.JavadocTypeArgumentsForRawGenericMethod: 264 case IProblem.JavadocGenericConstructorTypeArgumentMismatch: 265 case IProblem.JavadocNonGenericConstructor: 266 case IProblem.JavadocIncorrectArityForParameterizedConstructor: 267 case IProblem.JavadocParameterizedConstructorArgumentTypeMismatch: 268 case IProblem.JavadocTypeArgumentsForRawGenericConstructor: 269 case IProblem.JavadocNotVisibleField: 270 case IProblem.JavadocNotVisibleConstructor: 271 case IProblem.JavadocNotVisibleMethod: 272 case IProblem.JavadocNotVisibleType: 273 case IProblem.JavadocUsingDeprecatedField: 274 case IProblem.JavadocUsingDeprecatedConstructor: 275 case IProblem.JavadocUsingDeprecatedMethod: 276 case IProblem.JavadocUsingDeprecatedType: 277 case IProblem.JavadocHiddenReference: 278 return CompilerOptions.InvalidJavadoc; 279 280 case IProblem.JavadocMissingParamTag: 281 case IProblem.JavadocMissingReturnTag: 282 case IProblem.JavadocMissingThrowsTag: 283 return CompilerOptions.MissingJavadocTags; 284 285 case IProblem.JavadocMissing: 286 return CompilerOptions.MissingJavadocComments; 287 288 case IProblem.ParameterAssignment: 289 return CompilerOptions.ParameterAssignment; 290 291 case IProblem.FallthroughCase: 292 return CompilerOptions.FallthroughCase; 293 294 case IProblem.OverridingMethodWithoutSuperInvocation: 295 return CompilerOptions.OverridingMethodWithoutSuperInvocation; 296 } 297 return 0; 298 } 299 305 public static int getProblemCategory(int severity, int problemID) { 306 categorizeOnIrritant: { 307 if ((severity & ProblemSeverities.Fatal) != 0) 309 break categorizeOnIrritant; 310 long irritant = getIrritant(problemID); 311 int irritantInt = (int) irritant; 312 if (irritantInt == irritant) { 313 switch (irritantInt) { 314 case (int)CompilerOptions.MethodWithConstructorName: 315 case (int)CompilerOptions.AccessEmulation: 316 case (int)CompilerOptions.AssertUsedAsAnIdentifier: 317 case (int)CompilerOptions.NonStaticAccessToStatic: 318 case (int)CompilerOptions.UnqualifiedFieldAccess: 319 case (int)CompilerOptions.UndocumentedEmptyBlock: 320 case (int)CompilerOptions.IndirectStaticAccess: 321 return CategorizedProblem.CAT_CODE_STYLE; 322 323 case (int)CompilerOptions.MaskedCatchBlock: 324 case (int)CompilerOptions.NoImplicitStringConversion: 325 case (int)CompilerOptions.NoEffectAssignment: 326 case (int)CompilerOptions.AccidentalBooleanAssign: 327 case (int)CompilerOptions.EmptyStatement: 328 case (int)CompilerOptions.FinallyBlockNotCompleting: 329 return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM; 330 331 case (int)CompilerOptions.OverriddenPackageDefaultMethod: 332 case (int)CompilerOptions.IncompatibleNonInheritedInterfaceMethod: 333 case (int)CompilerOptions.LocalVariableHiding: 334 case (int)CompilerOptions.FieldHiding: 335 return CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT; 336 337 case (int)CompilerOptions.UnusedLocalVariable: 338 case (int)CompilerOptions.UnusedArgument: 339 case (int)CompilerOptions.UnusedImport: 340 case (int)CompilerOptions.UnusedPrivateMember: 341 case (int)CompilerOptions.UnusedDeclaredThrownException: 342 case (int)CompilerOptions.UnnecessaryTypeCheck: 343 case (int)CompilerOptions.UnnecessaryElse: 344 return CategorizedProblem.CAT_UNNECESSARY_CODE; 345 346 case (int)CompilerOptions.UsingDeprecatedAPI: 347 return CategorizedProblem.CAT_DEPRECATION; 348 349 case (int)CompilerOptions.NonExternalizedString: 350 return CategorizedProblem.CAT_NLS; 351 352 case (int)CompilerOptions.Task: 353 return CategorizedProblem.CAT_UNSPECIFIED; 355 case (int)CompilerOptions.MissingJavadocComments: 356 case (int)CompilerOptions.MissingJavadocTags: 357 case (int)CompilerOptions.InvalidJavadoc: 358 case (int)(CompilerOptions.InvalidJavadoc | CompilerOptions.UsingDeprecatedAPI): 359 return CategorizedProblem.CAT_JAVADOC; 360 361 case (int)CompilerOptions.UncheckedTypeOperation: 362 return CategorizedProblem.CAT_UNCHECKED_RAW; 363 364 default: 365 break categorizeOnIrritant; 366 } 367 } else { 368 irritantInt = (int)(irritant >>> 32); 369 switch (irritantInt) { 370 case (int)(CompilerOptions.FinalParameterBound >>> 32): 371 case (int)(CompilerOptions.EnumUsedAsAnIdentifier >>> 32): 372 case (int)(CompilerOptions.AnnotationSuperInterface >>> 32): 373 case (int)(CompilerOptions.AutoBoxing >>> 32): 374 case (int)(CompilerOptions.MissingOverrideAnnotation >>> 32): 375 case (int)(CompilerOptions.MissingDeprecatedAnnotation >>> 32): 376 case (int)(CompilerOptions.ParameterAssignment >>> 32): 377 return CategorizedProblem.CAT_CODE_STYLE; 378 379 case (int)(CompilerOptions.MissingSerialVersion >>> 32): 380 case (int)(CompilerOptions.VarargsArgumentNeedCast >>> 32): 381 case (int)(CompilerOptions.NullReference >>> 32): 382 case (int)(CompilerOptions.PotentialNullReference >>> 32): 383 case (int)(CompilerOptions.RedundantNullCheck >>> 32): 384 case (int)(CompilerOptions.IncompleteEnumSwitch >>> 32): 385 case (int)(CompilerOptions.FallthroughCase >>> 32): 386 case (int)(CompilerOptions.OverridingMethodWithoutSuperInvocation >>> 32): 387 return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM; 388 389 case (int)(CompilerOptions.TypeHiding >>> 32): 390 return CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT; 391 392 case (int)(CompilerOptions.UnhandledWarningToken >>> 32): 393 case (int)(CompilerOptions.UnusedLabel >>> 32): 394 return CategorizedProblem.CAT_UNNECESSARY_CODE; 395 396 case (int)(CompilerOptions.ForbiddenReference >>> 32): 397 case (int)(CompilerOptions.DiscouragedReference >>> 32): 398 return CategorizedProblem.CAT_RESTRICTION; 399 400 case (int)(CompilerOptions.RawTypeReference >>> 32): 401 return CategorizedProblem.CAT_UNCHECKED_RAW; 402 403 default: 404 break categorizeOnIrritant; 405 } 406 } 407 } 408 switch (problemID) { 410 case IProblem.IsClassPathCorrect : 411 case IProblem.CorruptedSignature : 412 return CategorizedProblem.CAT_BUILDPATH; 413 414 default : 415 if ((problemID & IProblem.Syntax) != 0) 416 return CategorizedProblem.CAT_SYNTAX; 417 if ((problemID & IProblem.ImportRelated) != 0) 418 return CategorizedProblem.CAT_IMPORT; 419 if ((problemID & IProblem.TypeRelated) != 0) 420 return CategorizedProblem.CAT_TYPE; 421 if ((problemID & (IProblem.FieldRelated|IProblem.MethodRelated|IProblem.ConstructorRelated)) != 0) 422 return CategorizedProblem.CAT_MEMBER; 423 } 424 return CategorizedProblem.CAT_INTERNAL; 425 } 426 public ProblemReporter(IErrorHandlingPolicy policy, CompilerOptions options, IProblemFactory problemFactory) { 427 super(policy, options, problemFactory); 428 } 429 public void abortDueToInternalError(String errorMessage) { 430 this.abortDueToInternalError(errorMessage, null); 431 } 432 public void abortDueToInternalError(String errorMessage, ASTNode location) { 433 String [] arguments = new String [] {errorMessage}; 434 this.handle( 435 IProblem.Unclassified, 436 arguments, 437 arguments, 438 ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal, 439 location == null ? 0 : location.sourceStart, 440 location == null ? 0 : location.sourceEnd); 441 } 442 public void abstractMethodCannotBeOverridden(SourceTypeBinding type, MethodBinding concreteMethod) { 443 444 this.handle( 445 IProblem.AbstractMethodCannotBeOverridden, 447 new String [] { 448 new String (type.sourceName()), 449 new String ( 450 CharOperation.concat( 451 concreteMethod.declaringClass.readableName(), 452 concreteMethod.readableName(), 453 '.'))}, 454 new String [] { 455 new String (type.sourceName()), 456 new String ( 457 CharOperation.concat( 458 concreteMethod.declaringClass.shortReadableName(), 459 concreteMethod.shortReadableName(), 460 '.'))}, 461 type.sourceStart(), 462 type.sourceEnd()); 463 } 464 public void abstractMethodInAbstractClass(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) { 465 466 String [] arguments = new String [] {new String (type.sourceName()), new String (methodDecl.selector)}; 467 this.handle( 468 IProblem.AbstractMethodInAbstractClass, 469 arguments, 470 arguments, 471 methodDecl.sourceStart, 472 methodDecl.sourceEnd); 473 } 474 public void abstractMethodMustBeImplemented(SourceTypeBinding type, MethodBinding abstractMethod) { 475 this.handle( 476 IProblem.AbstractMethodMustBeImplemented, 479 new String [] { 480 new String (abstractMethod.selector), 481 typesAsString(abstractMethod.isVarargs(), abstractMethod.parameters, false), 482 new String (abstractMethod.declaringClass.readableName()), 483 new String (type.readableName()), 484 }, 485 new String [] { 486 new String (abstractMethod.selector), 487 typesAsString(abstractMethod.isVarargs(), abstractMethod.parameters, true), 488 new String (abstractMethod.declaringClass.shortReadableName()), 489 new String (type.shortReadableName()), 490 }, 491 type.sourceStart(), 492 type.sourceEnd()); 493 } 494 public void abstractMethodNeedingNoBody(AbstractMethodDeclaration method) { 495 this.handle( 496 IProblem.BodyForAbstractMethod, 497 NoArgument, 498 NoArgument, 499 method.sourceStart, 500 method.sourceEnd, 501 method, 502 method.compilationResult()); 503 } 504 public void alreadyDefinedLabel(char[] labelName, ASTNode location) { 505 String [] arguments = new String [] {new String (labelName)}; 506 this.handle( 507 IProblem.DuplicateLabel, 508 arguments, 509 arguments, 510 location.sourceStart, 511 location.sourceEnd); 512 } 513 public void annotationCannotOverrideMethod(MethodBinding overrideMethod, MethodBinding inheritedMethod) { 514 ASTNode location = overrideMethod.sourceMethod(); 515 this.handle( 516 IProblem.AnnotationCannotOverrideMethod, 517 new String [] { 518 new String (overrideMethod.declaringClass.readableName()), 519 new String (inheritedMethod.declaringClass.readableName()), 520 new String (inheritedMethod.selector), 521 typesAsString(inheritedMethod.isVarargs(), inheritedMethod.parameters, false)}, 522 new String [] { 523 new String (overrideMethod.declaringClass.shortReadableName()), 524 new String (inheritedMethod.declaringClass.shortReadableName()), 525 new String (inheritedMethod.selector), 526 typesAsString(inheritedMethod.isVarargs(), inheritedMethod.parameters, true)}, 527 location.sourceStart, 528 location.sourceEnd); 529 } 530 public void annotationCircularity(TypeBinding sourceType, TypeBinding otherType, TypeReference reference) { 531 if (sourceType == otherType) 532 this.handle( 533 IProblem.AnnotationCircularitySelfReference, 534 new String [] {new String (sourceType.readableName())}, 535 new String [] {new String (sourceType.shortReadableName())}, 536 reference.sourceStart, 537 reference.sourceEnd); 538 else 539 this.handle( 540 IProblem.AnnotationCircularity, 541 new String [] {new String (sourceType.readableName()), new String (otherType.readableName())}, 542 new String [] {new String (sourceType.shortReadableName()), new String (otherType.shortReadableName())}, 543 reference.sourceStart, 544 reference.sourceEnd); 545 } 546 public void annotationMembersCannotHaveParameters(AnnotationMethodDeclaration annotationMethodDeclaration) { 547 this.handle( 548 IProblem.AnnotationMembersCannotHaveParameters, 549 NoArgument, 550 NoArgument, 551 annotationMethodDeclaration.sourceStart, 552 annotationMethodDeclaration.sourceEnd); 553 } 554 public void annotationMembersCannotHaveTypeParameters(AnnotationMethodDeclaration annotationMethodDeclaration) { 555 this.handle( 556 IProblem.AnnotationMembersCannotHaveTypeParameters, 557 NoArgument, 558 NoArgument, 559 annotationMethodDeclaration.sourceStart, 560 annotationMethodDeclaration.sourceEnd); 561 } 562 public void annotationTypeDeclarationCannotHaveConstructor(ConstructorDeclaration constructorDeclaration) { 563 this.handle( 564 IProblem.AnnotationTypeDeclarationCannotHaveConstructor, 565 NoArgument, 566 NoArgument, 567 constructorDeclaration.sourceStart, 568 constructorDeclaration.sourceEnd); 569 } 570 public void annotationTypeDeclarationCannotHaveSuperclass(TypeDeclaration typeDeclaration) { 571 this.handle( 572 IProblem.AnnotationTypeDeclarationCannotHaveSuperclass, 573 NoArgument, 574 NoArgument, 575 typeDeclaration.sourceStart, 576 typeDeclaration.sourceEnd); 577 } 578 public void annotationTypeDeclarationCannotHaveSuperinterfaces(TypeDeclaration typeDeclaration) { 579 this.handle( 580 IProblem.AnnotationTypeDeclarationCannotHaveSuperinterfaces, 581 NoArgument, 582 NoArgument, 583 typeDeclaration.sourceStart, 584 typeDeclaration.sourceEnd); 585 } 586 public void annotationTypeUsedAsSuperinterface(SourceTypeBinding type, TypeReference superInterfaceRef, ReferenceBinding superType) { 587 this.handle( 588 IProblem.AnnotationTypeUsedAsSuperInterface, 589 new String [] {new String (superType.readableName()), new String (type.sourceName())}, 590 new String [] {new String (superType.shortReadableName()), new String (type.sourceName())}, 591 superInterfaceRef.sourceStart, 592 superInterfaceRef.sourceEnd); 593 } 594 public void annotationValueMustBeAnnotation(TypeBinding annotationType, char[] name, Expression value, TypeBinding expectedType) { 595 String str = new String (name); 596 this.handle( 597 IProblem.AnnotationValueMustBeAnnotation, 598 new String [] { new String (annotationType.readableName()), str, new String (expectedType.readableName()), }, 599 new String [] { new String (annotationType.shortReadableName()), str, new String (expectedType.readableName()), }, 600 value.sourceStart, 601 value.sourceEnd); 602 } 603 public void annotationValueMustBeArrayInitializer(TypeBinding annotationType, char[] name, Expression value) { 604 String str = new String (name); 605 this.handle( 606 IProblem.AnnotationValueMustBeArrayInitializer, 607 new String [] { new String (annotationType.readableName()), str }, 608 new String [] { new String (annotationType.shortReadableName()), str}, 609 value.sourceStart, 610 value.sourceEnd); 611 } 612 public void annotationValueMustBeClassLiteral(TypeBinding annotationType, char[] name, Expression value) { 613 String str = new String (name); 614 this.handle( 615 IProblem.AnnotationValueMustBeClassLiteral, 616 new String [] { new String (annotationType.readableName()), str }, 617 new String [] { new String (annotationType.shortReadableName()), str}, 618 value.sourceStart, 619 value.sourceEnd); 620 } 621 public void annotationValueMustBeConstant(TypeBinding annotationType, char[] name, Expression value, boolean isEnum) { 622 String str = new String (name); 623 if (isEnum) { 624 this.handle( 625 IProblem.AnnotationValueMustBeAnEnumConstant, 626 new String [] { new String (annotationType.readableName()), str }, 627 new String [] { new String (annotationType.shortReadableName()), str}, 628 value.sourceStart, 629 value.sourceEnd); 630 } else { 631 this.handle( 632 IProblem.AnnotationValueMustBeConstant, 633 new String [] { new String (annotationType.readableName()), str }, 634 new String [] { new String (annotationType.shortReadableName()), str}, 635 value.sourceStart, 636 value.sourceEnd); 637 } 638 } 639 public void anonymousClassCannotExtendFinalClass(Expression expression, TypeBinding type) { 640 this.handle( 641 IProblem.AnonymousClassCannotExtendFinalClass, 642 new String [] {new String (type.readableName())}, 643 new String [] {new String (type.shortReadableName())}, 644 expression.sourceStart, 645 expression.sourceEnd); 646 } 647 public void argumentTypeCannotBeVoid(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, Argument arg) { 648 String [] arguments = new String [] {new String (methodDecl.selector), new String (arg.name)}; 649 this.handle( 650 IProblem.ArgumentTypeCannotBeVoid, 651 arguments, 652 arguments, 653 methodDecl.sourceStart, 654 methodDecl.sourceEnd); 655 } 656 public void argumentTypeCannotBeVoidArray(Argument arg) { 657 this.handle( 658 IProblem.CannotAllocateVoidArray, 659 NoArgument, 660 NoArgument, 661 arg.type.sourceStart, 662 arg.type.sourceEnd); 663 } 664 public void arrayConstantsOnlyInArrayInitializers(int sourceStart, int sourceEnd) { 665 this.handle( 666 IProblem.ArrayConstantsOnlyInArrayInitializers, 667 NoArgument, 668 NoArgument, 669 sourceStart, 670 sourceEnd); 671 } 672 public void assignmentHasNoEffect(AbstractVariableDeclaration location, char[] name){ 673 int severity = computeSeverity(IProblem.AssignmentHasNoEffect); 674 if (severity == ProblemSeverities.Ignore) return; 675 String [] arguments = new String [] { new String (name) }; 676 int start = location.sourceStart; 677 int end = location.sourceEnd; 678 if (location.initialization != null) { 679 end = location.initialization.sourceEnd; 680 } 681 this.handle( 682 IProblem.AssignmentHasNoEffect, 683 arguments, 684 arguments, 685 severity, 686 start, 687 end); 688 } 689 public void assignmentHasNoEffect(Assignment location, char[] name){ 690 int severity = computeSeverity(IProblem.AssignmentHasNoEffect); 691 if (severity == ProblemSeverities.Ignore) return; 692 String [] arguments = new String [] { new String (name) }; 693 this.handle( 694 IProblem.AssignmentHasNoEffect, 695 arguments, 696 arguments, 697 severity, 698 location.sourceStart, 699 location.sourceEnd); 700 } 701 public void attemptToReturnNonVoidExpression(ReturnStatement returnStatement, TypeBinding expectedType) { 702 this.handle( 703 IProblem.VoidMethodReturnsValue, 704 new String [] {new String (expectedType.readableName())}, 705 new String [] {new String (expectedType.shortReadableName())}, 706 returnStatement.sourceStart, 707 returnStatement.sourceEnd); 708 } 709 public void attemptToReturnVoidValue(ReturnStatement returnStatement) { 710 this.handle( 711 IProblem.MethodReturnsVoid, 712 NoArgument, 713 NoArgument, 714 returnStatement.sourceStart, 715 returnStatement.sourceEnd); 716 } 717 public void autoboxing(Expression expression, TypeBinding originalType, TypeBinding convertedType) { 718 if (this.options.getSeverity(CompilerOptions.AutoBoxing) == ProblemSeverities.Ignore) return; 719 this.handle( 720 originalType.isBaseType() ? IProblem.BoxingConversion : IProblem.UnboxingConversion, 721 new String [] { new String (originalType.readableName()), new String (convertedType.readableName()), }, 722 new String [] { new String (originalType.shortReadableName()), new String (convertedType.shortReadableName()), }, 723 expression.sourceStart, 724 expression.sourceEnd); 725 } 726 public void boundCannotBeArray(ASTNode location, TypeBinding type) { 727 this.handle( 728 IProblem.BoundCannotBeArray, 729 new String [] {new String (type.readableName())}, 730 new String [] {new String (type.shortReadableName())}, 731 location.sourceStart, 732 location.sourceEnd); 733 } 734 public void boundMustBeAnInterface(ASTNode location, TypeBinding type) { 735 this.handle( 736 IProblem.BoundMustBeAnInterface, 737 new String [] {new String (type.readableName())}, 738 new String [] {new String (type.shortReadableName())}, 739 location.sourceStart, 740 location.sourceEnd); 741 } 742 public void bytecodeExceeds64KLimit(AbstractMethodDeclaration location) { 743 MethodBinding method = location.binding; 744 if (location.isConstructor()) { 745 this.handle( 746 IProblem.BytecodeExceeds64KLimitForConstructor, 747 new String [] {new String (location.selector), typesAsString(method.isVarargs(), method.parameters, false)}, 748 new String [] {new String (location.selector), typesAsString(method.isVarargs(), method.parameters, true)}, 749 ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal, 750 location.sourceStart, 751 location.sourceEnd); 752 } else { 753 this.handle( 754 IProblem.BytecodeExceeds64KLimit, 755 new String [] {new String (location.selector), typesAsString(method.isVarargs(), method.parameters, false)}, 756 new String [] {new String (location.selector), typesAsString(method.isVarargs(), method.parameters, true)}, 757 ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal, 758 location.sourceStart, 759 location.sourceEnd); 760 } 761 } 762 public void bytecodeExceeds64KLimit(TypeDeclaration location) { 763 this.handle( 764 IProblem.BytecodeExceeds64KLimitForClinit, 765 NoArgument, 766 NoArgument, 767 ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal, 768 location.sourceStart, 769 location.sourceEnd); 770 } 771 public void cannotAllocateVoidArray(Expression expression) { 772 this.handle( 773 IProblem.CannotAllocateVoidArray, 774 NoArgument, 775 NoArgument, 776 expression.sourceStart, 777 expression.sourceEnd); 778 } 779 public void cannotAssignToFinalField(FieldBinding field, ASTNode location) { 780 this.handle( 781 IProblem.FinalFieldAssignment, 782 new String [] { 783 (field.declaringClass == null ? "array" : new String (field.declaringClass.readableName())), new String (field.readableName())}, 785 new String [] { 786 (field.declaringClass == null ? "array" : new String (field.declaringClass.shortReadableName())), new String (field.shortReadableName())}, 788 nodeSourceStart(field, location), 789 nodeSourceEnd(field, location)); 790 } 791 public void cannotAssignToFinalLocal(LocalVariableBinding local, ASTNode location) { 792 String [] arguments = new String [] { new String (local.readableName())}; 793 this.handle( 794 IProblem.NonBlankFinalLocalAssignment, 795 arguments, 796 arguments, 797 nodeSourceStart(local, location), 798 nodeSourceEnd(local, location)); 799 } 800 public void cannotAssignToFinalOuterLocal(LocalVariableBinding local, ASTNode location) { 801 String [] arguments = new String [] {new String (local.readableName())}; 802 this.handle( 803 IProblem.FinalOuterLocalAssignment, 804 arguments, 805 arguments, 806 nodeSourceStart(local, location), 807 nodeSourceEnd(local, location)); 808 } 809 public void cannotDefineDimensionsAndInitializer(ArrayAllocationExpression expresssion) { 810 this.handle( 811 IProblem.CannotDefineDimensionExpressionsWithInit, 812 NoArgument, 813 NoArgument, 814 expresssion.sourceStart, 815 expresssion.sourceEnd); 816 } 817 public void cannotDireclyInvokeAbstractMethod(MessageSend messageSend, MethodBinding method) { 818 this.handle( 819 IProblem.DirectInvocationOfAbstractMethod, 820 new String [] {new String (method.declaringClass.readableName()), new String (method.selector), typesAsString(method.isVarargs(), method.parameters, false)}, 821 new String [] {new String (method.declaringClass.shortReadableName()), new String (method.selector), typesAsString(method.isVarargs(), method.parameters, true)}, 822 messageSend.sourceStart, 823 messageSend.sourceEnd); 824 } 825 public void cannotExtendEnum(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) { 826 String name = new String (type.sourceName()); 827 String superTypeFullName = new String (superTypeBinding.readableName()); 828 String superTypeShortName = new String (superTypeBinding.shortReadableName()); 829 if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName; 830 this.handle( 831 IProblem.CannotExtendEnum, 832 new String [] {superTypeFullName, name}, 833 new String [] {superTypeShortName, name}, 834 superclass.sourceStart, 835 superclass.sourceEnd); 836 } 837 public void cannotImportPackage(ImportReference importRef) { 838 String [] arguments = new String [] {CharOperation.toString(importRef.tokens)}; 839 this.handle( 840 IProblem.CannotImportPackage, 841 arguments, 842 arguments, 843 importRef.sourceStart, 844 importRef.sourceEnd); 845 } 846 public void cannotInstantiate(TypeReference typeRef, TypeBinding type) { 847 this.handle( 848 IProblem.InvalidClassInstantiation, 849 new String [] {new String (type.readableName())}, 850 new String [] {new String (type.shortReadableName())}, 851 typeRef.sourceStart, 852 typeRef.sourceEnd); 853 } 854 public void cannotInvokeSuperConstructorInEnum(ExplicitConstructorCall constructorCall, MethodBinding enumConstructor) { 855 this.handle( 856 IProblem.CannotInvokeSuperConstructorInEnum, 857 new String [] { 858 new String (enumConstructor.declaringClass.sourceName()), 859 typesAsString(enumConstructor.isVarargs(), enumConstructor.parameters, false), 860 }, 861 new String [] { 862 new String (enumConstructor.declaringClass.sourceName()), 863 typesAsString(enumConstructor.isVarargs(), enumConstructor.parameters, true), 864 }, 865 constructorCall.sourceStart, 866 constructorCall.sourceEnd); 867 } 868 public void cannotReadSource(CompilationUnitDeclaration unit, AbortCompilationUnit abortException, boolean verbose) { 869 String fileName = new String (unit.compilationResult.fileName); 870 if (abortException.exception instanceof CharConversionException ) { 871 String encoding = abortException.encoding; 873 if (encoding == null) { 874 encoding = System.getProperty("file.encoding"); } 876 String [] arguments = new String []{ fileName, encoding, }; 877 this.handle( 878 IProblem.InvalidEncoding, 879 arguments, 880 arguments, 881 0, 882 0); 883 return; 884 } 885 StringWriter stringWriter = new StringWriter (); 886 PrintWriter writer = new PrintWriter (stringWriter); 887 if (verbose) { 888 abortException.exception.printStackTrace(writer); 889 } else { 890 writer.print(abortException.exception.getClass().getName()); 891 writer.print(':'); 892 writer.print(abortException.exception.getMessage()); 893 } 894 String exceptionTrace = stringWriter.toString(); 895 String [] arguments = new String []{ fileName, exceptionTrace, }; 896 this.handle( 897 IProblem.CannotReadSource, 898 arguments, 899 arguments, 900 0, 901 0); 902 } 903 public void cannotReferToNonFinalOuterLocal(LocalVariableBinding local, ASTNode location) { 904 String [] arguments =new String []{ new String (local.readableName())}; 905 this.handle( 906 IProblem.OuterLocalMustBeFinal, 907 arguments, 908 arguments, 909 nodeSourceStart(local, location), 910 nodeSourceEnd(local, location)); 911 } 912 public void cannotReturnInInitializer(ASTNode location) { 913 this.handle( 914 IProblem.CannotReturnInInitializer, 915 NoArgument, 916 NoArgument, 917 location.sourceStart, 918 location.sourceEnd); 919 } 920 public void cannotThrowNull(ASTNode expression) { 921 this.handle( 922 IProblem.CannotThrowNull, 923 NoArgument, 924 NoArgument, 925 expression.sourceStart, 926 expression.sourceEnd); 927 } 928 public void cannotThrowType(ASTNode exception, TypeBinding expectedType) { 929 this.handle( 930 IProblem.CannotThrowType, 931 new String [] {new String (expectedType.readableName())}, 932 new String [] {new String (expectedType.shortReadableName())}, 933 exception.sourceStart, 934 exception.sourceEnd); 935 } 936 public void cannotUseQualifiedEnumConstantInCaseLabel(Reference location, FieldBinding field) { 937 this.handle( 938 IProblem.IllegalQualifiedEnumConstantLabel, 939 new String []{ String.valueOf(field.declaringClass.readableName()), String.valueOf(field.name) }, 940 new String []{ String.valueOf(field.declaringClass.shortReadableName()), String.valueOf(field.name) }, 941 nodeSourceStart(field, location), 942 nodeSourceEnd(field, location)); 943 } 944 public void cannotUseSuperInCodeSnippet(int start, int end) { 945 this.handle( 946 IProblem.CannotUseSuperInCodeSnippet, 947 NoArgument, 948 NoArgument, 949 ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal, 950 start, 951 end); 952 } 953 public void cannotUseSuperInJavaLangObject(ASTNode reference) { 954 this.handle( 955 IProblem.ObjectHasNoSuperclass, 956 NoArgument, 957 NoArgument, 958 reference.sourceStart, 959 reference.sourceEnd); 960 } 961 public void caseExpressionMustBeConstant(Expression expression) { 962 this.handle( 963 IProblem.NonConstantExpression, 964 NoArgument, 965 NoArgument, 966 expression.sourceStart, 967 expression.sourceEnd); 968 } 969 public void classExtendFinalClass(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) { 970 String name = new String (type.sourceName()); 971 String superTypeFullName = new String (superTypeBinding.readableName()); 972 String superTypeShortName = new String (superTypeBinding.shortReadableName()); 973 if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName; 974 this.handle( 975 IProblem.ClassExtendFinalClass, 976 new String [] {superTypeFullName, name}, 977 new String [] {superTypeShortName, name}, 978 superclass.sourceStart, 979 superclass.sourceEnd); 980 } 981 public void codeSnippetMissingClass(String missing, int start, int end) { 982 String [] arguments = new String []{missing}; 983 this.handle( 984 IProblem.CodeSnippetMissingClass, 985 arguments, 986 arguments, 987 ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal, 988 start, 989 end); 990 } 991 public void codeSnippetMissingMethod(String className, String missingMethod, String argumentTypes, int start, int end) { 992 String [] arguments = new String []{ className, missingMethod, argumentTypes }; 993 this.handle( 994 IProblem.CodeSnippetMissingMethod, 995 arguments, 996 arguments, 997 ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal, 998 start, 999 end); 1000} 1001 1008public int computeSeverity(int problemID){ 1009 1010 switch (problemID) { 1011 case IProblem.Task : 1012 return ProblemSeverities.Warning; 1013 case IProblem.VarargsConflict : 1014 return ProblemSeverities.Warning; 1015 case IProblem.TypeCollidesWithPackage : 1016 return ProblemSeverities.Warning; 1017 1018 1021 case IProblem.JavadocInvalidParamName: 1022 case IProblem.JavadocDuplicateParamName: 1023 case IProblem.JavadocMissingParamName: 1024 case IProblem.JavadocMissingIdentifier: 1025 case IProblem.JavadocInvalidMemberTypeQualification: 1026 case IProblem.JavadocInvalidThrowsClassName: 1027 case IProblem.JavadocDuplicateThrowsClassName: 1028 case IProblem.JavadocMissingThrowsClassName: 1029 case IProblem.JavadocMissingSeeReference: 1030 case IProblem.JavadocInvalidValueReference: 1031 case IProblem.JavadocUndefinedField: 1032 case IProblem.JavadocAmbiguousField: 1033 case IProblem.JavadocUndefinedConstructor: 1034 case IProblem.JavadocAmbiguousConstructor: 1035 case IProblem.JavadocUndefinedMethod: 1036 case IProblem.JavadocAmbiguousMethod: 1037 case IProblem.JavadocAmbiguousMethodReference: 1038 case IProblem.JavadocParameterMismatch: 1039 case IProblem.JavadocUndefinedType: 1040 case IProblem.JavadocAmbiguousType: 1041 case IProblem.JavadocInternalTypeNameProvided: 1042 case IProblem.JavadocNoMessageSendOnArrayType: 1043 case IProblem.JavadocNoMessageSendOnBaseType: 1044 case IProblem.JavadocInheritedMethodHidesEnclosingName: 1045 case IProblem.JavadocInheritedFieldHidesEnclosingName: 1046 case IProblem.JavadocInheritedNameHidesEnclosingTypeName: 1047 case IProblem.JavadocNonStaticTypeFromStaticInvocation: 1048 case IProblem.JavadocGenericMethodTypeArgumentMismatch: 1049 case IProblem.JavadocNonGenericMethod: 1050 case IProblem.JavadocIncorrectArityForParameterizedMethod: 1051 case IProblem.JavadocParameterizedMethodArgumentTypeMismatch: 1052 case IProblem.JavadocTypeArgumentsForRawGenericMethod: 1053 case IProblem.JavadocGenericConstructorTypeArgumentMismatch: 1054 case IProblem.JavadocNonGenericConstructor: 1055 case IProblem.JavadocIncorrectArityForParameterizedConstructor: 1056 case IProblem.JavadocParameterizedConstructorArgumentTypeMismatch: 1057 case IProblem.JavadocTypeArgumentsForRawGenericConstructor: 1058 case IProblem.JavadocEmptyReturnTag: 1059 if (!this.options.reportInvalidJavadocTags) { 1060 return ProblemSeverities.Ignore; 1061 } 1062 break; 1063 1066 case IProblem.JavadocUsingDeprecatedField: 1067 case IProblem.JavadocUsingDeprecatedConstructor: 1068 case IProblem.JavadocUsingDeprecatedMethod: 1069 case IProblem.JavadocUsingDeprecatedType: 1070 if (!(this.options.reportInvalidJavadocTags && this.options.reportInvalidJavadocTagsDeprecatedRef)) { 1071 return ProblemSeverities.Ignore; 1072 } 1073 break; 1074 1077 case IProblem.JavadocNotVisibleField: 1078 case IProblem.JavadocNotVisibleConstructor: 1079 case IProblem.JavadocNotVisibleMethod: 1080 case IProblem.JavadocNotVisibleType: 1081 case IProblem.JavadocHiddenReference: 1082 if (!(this.options.reportInvalidJavadocTags && this.options.reportInvalidJavadocTagsNotVisibleRef)) { 1083 return ProblemSeverities.Ignore; 1084 } 1085 break; 1086 } 1087 long irritant = getIrritant(problemID); 1088 if (irritant != 0) { 1089 if ((problemID & IProblem.Javadoc) != 0 && !this.options.docCommentSupport) 1090 return ProblemSeverities.Ignore; 1091 return this.options.getSeverity(irritant); 1092 } 1093 return ProblemSeverities.Error | ProblemSeverities.Fatal; 1094} 1095public void conditionalArgumentsIncompatibleTypes(ConditionalExpression expression, TypeBinding trueType, TypeBinding falseType) { 1096 this.handle( 1097 IProblem.IncompatibleTypesInConditionalOperator, 1098 new String [] {new String (trueType.readableName()), new String (falseType.readableName())}, 1099 new String [] {new String (trueType.sourceName()), new String (falseType.sourceName())}, 1100 expression.sourceStart, 1101 expression.sourceEnd); 1102} 1103public void conflictingImport(ImportReference importRef) { 1104 String [] arguments = new String [] {CharOperation.toString(importRef.tokens)}; 1105 this.handle( 1106 IProblem.ConflictingImport, 1107 arguments, 1108 arguments, 1109 importRef.sourceStart, 1110 importRef.sourceEnd); 1111} 1112public void constantOutOfFormat(NumberLiteral literal) { 1113 1117 if ((literal instanceof LongLiteral) || (literal instanceof IntLiteral)) { 1118 char[] source = literal.source(); 1119 try { 1120 final String Radix; 1121 final int radix; 1122 if ((source[1] == 'x') || (source[1] == 'X')) { 1123 radix = 16; 1124 Radix = "Hex"; } else { 1126 radix = 8; 1127 Radix = "Octal"; } 1129 int place = -1; 1131 label : for (int i = radix == 8 ? 1 : 2; i < source.length; i++) { 1132 if (ScannerHelper.digit(source[i], radix) == -1) { 1133 place = i; 1134 break label; 1135 } 1136 } 1137 String [] arguments = new String [] { 1138 new String (literal.literalType(null).readableName()), Radix + " " + new String (source) + " (digit " + new String (new char[] {source[place]}) + ")"}; 1141 this.handle( 1142 IProblem.NumericValueOutOfRange, 1143 arguments, 1144 arguments, 1145 literal.sourceStart, 1146 literal.sourceEnd); 1147 return; 1148 } catch (IndexOutOfBoundsException ex) { 1149 } 1151 1152 this.constantOutOfRange(literal, literal.literalType(null)); } 1156} 1157public void constantOutOfRange(Literal literal, TypeBinding literalType) { 1158 String [] arguments = new String [] {new String (literalType.readableName()), new String (literal.source())}; 1159 this.handle( 1160 IProblem.NumericValueOutOfRange, 1161 arguments, 1162 arguments, 1163 literal.sourceStart, 1164 literal.sourceEnd); 1165} 1166public void corruptedSignature(TypeBinding enclosingType, char[] signature, int position) { 1167 this.handle( 1168 IProblem.CorruptedSignature, 1169 new String [] { new String (enclosingType.readableName()), new String (signature), String.valueOf(position) }, 1170 new String [] { new String (enclosingType.shortReadableName()), new String (signature), String.valueOf(position) }, 1171 ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal, 1172 0, 1173 0); 1174} 1175public void deprecatedField(FieldBinding field, ASTNode location) { 1176 int severity = computeSeverity(IProblem.UsingDeprecatedField); 1177 if (severity == ProblemSeverities.Ignore) return; 1178 this.handle( 1179 IProblem.UsingDeprecatedField, 1180 new String [] {new String (field.declaringClass.readableName()), new String (field.name)}, 1181 new String [] {new String (field.declaringClass.shortReadableName()), new String (field.name)}, 1182 severity, 1183 nodeSourceStart(field, location), 1184 nodeSourceEnd(field, location)); 1185} 1186public void deprecatedMethod(MethodBinding method, ASTNode location) { 1187 boolean isConstructor = method.isConstructor(); 1188 int severity = computeSeverity(isConstructor ? IProblem.UsingDeprecatedConstructor : IProblem.UsingDeprecatedMethod); 1189 if (severity == ProblemSeverities.Ignore) return; 1190 if (isConstructor) { 1191 this.handle( 1192 IProblem.UsingDeprecatedConstructor, 1193 new String [] {new String (method.declaringClass.readableName()), typesAsString(method.isVarargs(), method.parameters, false)}, 1194 new String [] {new String (method.declaringClass.shortReadableName()), typesAsString(method.isVarargs(), method.parameters, true)}, 1195 severity, 1196 location.sourceStart, 1197 location.sourceEnd); 1198 } else { 1199 this.handle( 1200 IProblem.UsingDeprecatedMethod, 1201 new String [] {new String (method.declaringClass.readableName()), new String (method.selector), typesAsString(method.isVarargs(), method.parameters, false)}, 1202 new String [] {new String (method.declaringClass.shortReadableName()), new String (method.selector), typesAsString(method.isVarargs(), method.parameters, true)}, 1203 severity, 1204 location.sourceStart, 1205 location.sourceEnd); 1206 } 1207} 1208public void deprecatedType(TypeBinding type, ASTNode location) { 1209 if (location == null) return; int severity = computeSeverity(IProblem.UsingDeprecatedType); 1211 if (severity == ProblemSeverities.Ignore) return; 1212 type = type.leafComponentType(); 1213 this.handle( 1214 IProblem.UsingDeprecatedType, 1215 new String [] {new String (type.readableName())}, 1216 new String [] {new String (type.shortReadableName())}, 1217 severity, 1218 location.sourceStart, 1219 nodeSourceEnd(null, location)); 1220} 1221public void disallowedTargetForAnnotation(Annotation annotation) { 1222 this.handle( 1223 IProblem.DisallowedTargetForAnnotation, 1224 new String [] {new String (annotation.resolvedType.readableName())}, 1225 new String [] {new String (annotation.resolvedType.shortReadableName())}, 1226 annotation.sourceStart, 1227 annotation.sourceEnd); 1228} 1229public void duplicateAnnotation(Annotation annotation) { 1230 this.handle( 1231 IProblem.DuplicateAnnotation, 1232 new String [] {new String (annotation.resolvedType.readableName())}, 1233 new String [] {new String (annotation.resolvedType.shortReadableName())}, 1234 annotation.sourceStart, 1235 annotation.sourceEnd); 1236} 1237public void duplicateAnnotationValue(TypeBinding annotationType, MemberValuePair memberValuePair) { 1238 String name = new String (memberValuePair.name); 1239 this.handle( 1240 IProblem.DuplicateAnnotationMember, 1241 new String [] { name, new String (annotationType.readableName())}, 1242 new String [] { name, new String (annotationType.shortReadableName())}, 1243 memberValuePair.sourceStart, 1244 memberValuePair.sourceEnd); 1245} 1246public void duplicateBounds(ASTNode location, TypeBinding type) { 1247 this.handle( 1248 IProblem.DuplicateBounds, 1249 new String [] {new String (type.readableName())}, 1250 new String [] {new String (type.shortReadableName())}, 1251 location.sourceStart, 1252 location.sourceEnd); 1253} 1254public void duplicateCase(CaseStatement caseStatement) { 1255 this.handle( 1256 IProblem.DuplicateCase, 1257 NoArgument, 1258 NoArgument, 1259 caseStatement.sourceStart, 1260 caseStatement.sourceEnd); 1261} 1262public void duplicateDefaultCase(ASTNode statement) { 1263 this.handle( 1264 IProblem.DuplicateDefaultCase, 1265 NoArgument, 1266 NoArgument, 1267 statement.sourceStart, 1268 statement.sourceEnd); 1269} 1270 1271public void duplicateEnumSpecialMethod(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) { 1272 MethodBinding method = methodDecl.binding; 1273 this.handle( 1274 IProblem.CannotDeclareEnumSpecialMethod, 1275 new String [] { 1276 new String (methodDecl.selector), 1277 new String (method.declaringClass.readableName()), 1278 typesAsString(method.isVarargs(), method.parameters, false)}, 1279 new String [] { 1280 new String (methodDecl.selector), 1281 new String (method.declaringClass.shortReadableName()), 1282 typesAsString(method.isVarargs(), method.parameters, true)}, 1283 methodDecl.sourceStart, 1284 methodDecl.sourceEnd); 1285} 1286public void duplicateFieldInType(SourceTypeBinding type, FieldDeclaration fieldDecl) { 1287 this.handle( 1288 IProblem.DuplicateField, 1289 new String [] {new String (type.sourceName()), new String (fieldDecl.name)}, 1290 new String [] {new String (type.shortReadableName()), new String (fieldDecl.name)}, 1291 fieldDecl.sourceStart, 1292 fieldDecl.sourceEnd); 1293} 1294 1295public void duplicateImport(ImportReference importRef) { 1296 String [] arguments = new String [] {CharOperation.toString(importRef.tokens)}; 1297 this.handle( 1298 IProblem.DuplicateImport, 1299 arguments, 1300 arguments, 1301 importRef.sourceStart, 1302 importRef.sourceEnd); 1303} 1304public void duplicateInheritedMethods(SourceTypeBinding type, MethodBinding inheritedMethod1, MethodBinding inheritedMethod2) { 1305 this.handle( 1306 IProblem.DuplicateParameterizedMethods, 1307 new String [] { 1308 new String (inheritedMethod1.selector), 1309 new String (inheritedMethod1.declaringClass.readableName()), 1310 typesAsString(inheritedMethod1.isVarargs(), inheritedMethod1.original().parameters, false), 1311 typesAsString(inheritedMethod2.isVarargs(), inheritedMethod2.original().parameters, false)}, 1312 new String [] { 1313 new String (inheritedMethod1.selector), 1314 new String (inheritedMethod1.declaringClass.shortReadableName()), 1315 typesAsString(inheritedMethod1.isVarargs(), inheritedMethod1.original().parameters, true), 1316 typesAsString(inheritedMethod2.isVarargs(), inheritedMethod2.original().parameters, true)}, 1317 type.sourceStart(), 1318 type.sourceEnd()); 1319} 1320public void duplicateInitializationOfBlankFinalField(FieldBinding field, Reference reference) { 1321 String [] arguments = new String []{ new String (field.readableName())}; 1322 this.handle( 1323 IProblem.DuplicateBlankFinalFieldInitialization, 1324 arguments, 1325 arguments, 1326 nodeSourceStart(field, reference), 1327 nodeSourceEnd(field, reference)); 1328} 1329public void duplicateInitializationOfFinalLocal(LocalVariableBinding local, ASTNode location) { 1330 String [] arguments = new String [] { new String (local.readableName())}; 1331 this.handle( 1332 IProblem.DuplicateFinalLocalInitialization, 1333 arguments, 1334 arguments, 1335 nodeSourceStart(local, location), 1336 nodeSourceEnd(local, location)); 1337} 1338 1339public void duplicateMethodInType(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) { 1340 MethodBinding method = methodDecl.binding; 1341 boolean duplicateErasure = false; 1342 if ((method.modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0) { 1343 for (int i = 0, length = method.parameters.length; i < length; i++) { 1345 if ((method.parameters[i].tagBits & TagBits.HasTypeVariable) != 0) { 1346 duplicateErasure = true; 1347 break; 1348 } 1349 } 1350 } 1351 if (duplicateErasure) { 1352 int length = method.parameters.length; 1353 TypeBinding[] erasures = new TypeBinding[length]; 1354 for (int i = 0; i < length; i++) { 1355 erasures[i] = method.parameters[i].erasure(); 1356 } 1357 this.handle( 1358 IProblem.DuplicateMethodErasure, 1359 new String [] { 1360 new String (methodDecl.selector), 1361 new String (method.declaringClass.readableName()), 1362 typesAsString(method.isVarargs(), method.parameters, false), 1363 typesAsString(method.isVarargs(), erasures, false) } , 1364 new String [] { 1365 new String (methodDecl.selector), 1366 new String (method.declaringClass.shortReadableName()), 1367 typesAsString(method.isVarargs(), method.parameters, true), 1368 typesAsString(method.isVarargs(), erasures, true) }, 1369 methodDecl.sourceStart, 1370 methodDecl.sourceEnd); 1371 } else { 1372 this.handle( 1373 IProblem.DuplicateMethod, 1374 new String [] { 1375 new String (methodDecl.selector), 1376 new String (method.declaringClass.readableName()), 1377 typesAsString(method.isVarargs(), method.parameters, false)}, 1378 new String [] { 1379 new String (methodDecl.selector), 1380 new String (method.declaringClass.shortReadableName()), 1381 typesAsString(method.isVarargs(), method.parameters, true)}, 1382 methodDecl.sourceStart, 1383 methodDecl.sourceEnd); 1384 } 1385} 1386public void duplicateModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl) { 1387 1395 String [] arguments = new String [] {new String (fieldDecl.name)}; 1396 this.handle( 1397 IProblem.DuplicateModifierForField, 1398 arguments, 1399 arguments, 1400 fieldDecl.sourceStart, 1401 fieldDecl.sourceEnd); 1402} 1403public void duplicateModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) { 1404 this.handle( 1405 IProblem.DuplicateModifierForMethod, 1406 new String [] {new String (type.sourceName()), new String (methodDecl.selector)}, 1407 new String [] {new String (type.shortReadableName()), new String (methodDecl.selector)}, 1408 methodDecl.sourceStart, 1409 methodDecl.sourceEnd); 1410} 1411public void duplicateModifierForType(SourceTypeBinding type) { 1412 String [] arguments = new String [] {new String (type.sourceName())}; 1413 this.handle( 1414 IProblem.DuplicateModifierForType, 1415 arguments, 1416 arguments, 1417 type.sourceStart(), 1418 type.sourceEnd()); 1419} 1420public void duplicateModifierForVariable(LocalDeclaration localDecl, boolean complainForArgument) { 1421 String [] arguments = new String [] {new String (localDecl.name)}; 1422 this.handle( 1423 complainForArgument 1424 ? IProblem.DuplicateModifierForArgument 1425 : IProblem.DuplicateModifierForVariable, 1426 arguments, 1427 arguments, 1428 localDecl.sourceStart, 1429 localDecl.sourceEnd); 1430} 1431public void duplicateNestedType(TypeDeclaration typeDecl) { 1432 String [] arguments = new String [] {new String (typeDecl.name)}; 1433 this.handle( 1434 IProblem.DuplicateNestedType, 1435 arguments, 1436 arguments, 1437 typeDecl.sourceStart, 1438 typeDecl.sourceEnd); 1439} 1440public void duplicateSuperinterface(SourceTypeBinding type, TypeReference reference, ReferenceBinding superType) { 1441 this.handle( 1442 IProblem.DuplicateSuperInterface, 1443 new String [] { 1444 new String (superType.readableName()), 1445 new String (type.sourceName())}, 1446 new String [] { 1447 new String (superType.shortReadableName()), 1448 new String (type.sourceName())}, 1449 reference.sourceStart, 1450 reference.sourceEnd); 1451} 1452public void duplicateTargetInTargetAnnotation(TypeBinding annotationType, NameReference reference) { 1453 FieldBinding field = reference.fieldBinding(); 1454 String name = new String (field.name); 1455 this.handle( 1456 IProblem.DuplicateTargetInTargetAnnotation, 1457 new String [] { name, new String (annotationType.readableName())}, 1458 new String [] { name, new String (annotationType.shortReadableName())}, 1459 nodeSourceStart(field, reference), 1460 nodeSourceEnd(field, reference)); 1461} 1462public void duplicateTypeParameterInType(TypeParameter typeParameter) { 1463 this.handle( 1464 IProblem.DuplicateTypeVariable, 1465 new String [] { new String (typeParameter.name)}, 1466 new String [] { new String (typeParameter.name)}, 1467 typeParameter.sourceStart, 1468 typeParameter.sourceEnd); 1469} 1470public void duplicateTypes(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) { 1471 String [] arguments = new String [] {new String (compUnitDecl.getFileName()), new String (typeDecl.name)}; 1472 this.referenceContext = typeDecl; this.handle( 1474 IProblem.DuplicateTypes, 1475 arguments, 1476 arguments, 1477 typeDecl.sourceStart, 1478 typeDecl.sourceEnd, 1479 compUnitDecl.compilationResult); 1480} 1481public void emptyControlFlowStatement(int sourceStart, int sourceEnd) { 1482 this.handle( 1483 IProblem.EmptyControlFlowStatement, 1484 NoArgument, 1485 NoArgument, 1486 sourceStart, 1487 sourceEnd); 1488} 1489public void enumAbstractMethodMustBeImplemented(AbstractMethodDeclaration method) { 1490 MethodBinding abstractMethod = method.binding; 1491 this.handle( 1492 IProblem.EnumAbstractMethodMustBeImplemented, 1495 new String [] { 1496 new String (abstractMethod.selector), 1497 typesAsString(abstractMethod.isVarargs(), abstractMethod.parameters, false), 1498 new String (abstractMethod.declaringClass.readableName()), 1499 }, 1500 new String [] { 1501 new String (abstractMethod.selector), 1502 typesAsString(abstractMethod.isVarargs(), abstractMethod.parameters, true), 1503 new String (abstractMethod.declaringClass.shortReadableName()), 1504 }, 1505 method.sourceStart(), 1506 method.sourceEnd()); 1507} 1508public void enumConstantsCannotBeSurroundedByParenthesis(Expression expression) { 1509 this.handle( 1510 IProblem.EnumConstantsCannotBeSurroundedByParenthesis, 1511 NoArgument, 1512 NoArgument, 1513 expression.sourceStart, 1514 expression.sourceEnd); 1515} 1516public void enumStaticFieldUsedDuringInitialization(FieldBinding field, ASTNode location) { 1517 this.handle( 1518 IProblem.EnumStaticFieldInInInitializerContext, 1519 new String [] {new String (field.declaringClass.readableName()), new String (field.name)}, 1520 new String [] {new String (field.declaringClass.shortReadableName()), new String (field.name)}, 1521 nodeSourceStart(field, location), 1522 nodeSourceEnd(field, location)); 1523} 1524public void enumSwitchCannotTargetField(Reference reference, FieldBinding field) { 1525 this.handle( 1526 IProblem.EnumSwitchCannotTargetField, 1527 new String []{ String.valueOf(field.declaringClass.readableName()), String.valueOf(field.name) }, 1528 new String []{ String.valueOf(field.declaringClass.shortReadableName()), String.valueOf(field.name) }, 1529 nodeSourceStart(field, reference), 1530 nodeSourceEnd(field, reference)); 1531} 1532public void errorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params) { 1533 StringBuffer buffer = new StringBuffer (); 1534 StringBuffer shortBuffer = new StringBuffer (); 1535 for (int i = 0, length = params.length; i < length; i++) { 1536 if (i != 0){ 1537 buffer.append(", "); shortBuffer.append(", "); } 1540 buffer.append(new String (params[i].readableName())); 1541 shortBuffer.append(new String (params[i].shortReadableName())); 1542 } 1543 1544 int id = recType.isArrayType() ? IProblem.NoMessageSendOnArrayType : IProblem.NoMessageSendOnBaseType; 1545 this.handle( 1546 id, 1547 new String [] {new String (recType.readableName()), new String (messageSend.selector), buffer.toString()}, 1548 new String [] {new String (recType.shortReadableName()), new String (messageSend.selector), shortBuffer.toString()}, 1549 messageSend.sourceStart, 1550 messageSend.sourceEnd); 1551} 1552public void errorThisSuperInStatic(ASTNode reference) { 1553 String [] arguments = new String [] {reference.isSuper() ? "super" : "this"}; this.handle( 1555 IProblem.ThisInStaticContext, 1556 arguments, 1557 arguments, 1558 reference.sourceStart, 1559 reference.sourceEnd); 1560} 1561public void expressionShouldBeAVariable(Expression expression) { 1562 this.handle( 1563 IProblem.ExpressionShouldBeAVariable, 1564 NoArgument, 1565 NoArgument, 1566 expression.sourceStart, 1567 expression.sourceEnd); 1568} 1569public void fieldHiding(FieldDeclaration fieldDecl, Binding hiddenVariable) { 1570 FieldBinding field = fieldDecl.binding; 1571 if (CharOperation.equals(TypeConstants.SERIALVERSIONUID, field.name) 1572 && field.isStatic() 1573 && field.isFinal() 1574 && TypeBinding.LONG == field.type) { 1575 return; } 1577 if (CharOperation.equals(TypeConstants.SERIALPERSISTENTFIELDS, field.name) 1578 && field.isStatic() 1579 && field.isFinal() 1580 && field.type.dimensions() == 1 1581 && CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTSTREAMFIELD, field.type.leafComponentType().readableName())) { 1582 return; } 1584 boolean isLocal = hiddenVariable instanceof LocalVariableBinding; 1585 int severity = computeSeverity(isLocal ? IProblem.FieldHidingLocalVariable : IProblem.FieldHidingField); 1586 if (severity == ProblemSeverities.Ignore) return; 1587 if (isLocal) { 1588 this.handle( 1589 IProblem.FieldHidingLocalVariable, 1590 new String [] {new String (field.declaringClass.readableName()), new String (field.name) }, 1591 new String [] {new String (field.declaringClass.shortReadableName()), new String (field.name) }, 1592 severity, 1593 nodeSourceStart(hiddenVariable, fieldDecl), 1594 nodeSourceEnd(hiddenVariable, fieldDecl)); 1595 } else if (hiddenVariable instanceof FieldBinding) { 1596 FieldBinding hiddenField = (FieldBinding) hiddenVariable; 1597 this.handle( 1598 IProblem.FieldHidingField, 1599 new String [] {new String (field.declaringClass.readableName()), new String (field.name) , new String (hiddenField.declaringClass.readableName()) }, 1600 new String [] {new String (field.declaringClass.shortReadableName()), new String (field.name) , new String (hiddenField.declaringClass.shortReadableName()) }, 1601 severity, 1602 nodeSourceStart(hiddenField, fieldDecl), 1603 nodeSourceEnd(hiddenField, fieldDecl)); 1604 } 1605} 1606public void fieldsOrThisBeforeConstructorInvocation(ThisReference reference) { 1607 this.handle( 1608 IProblem.ThisSuperDuringConstructorInvocation, 1609 NoArgument, 1610 NoArgument, 1611 reference.sourceStart, 1612 reference.sourceEnd); 1613} 1614public void finallyMustCompleteNormally(Block finallyBlock) { 1615 this.handle( 1616 IProblem.FinallyMustCompleteNormally, 1617 NoArgument, 1618 NoArgument, 1619 finallyBlock.sourceStart, 1620 finallyBlock.sourceEnd); 1621} 1622public void finalMethodCannotBeOverridden(MethodBinding currentMethod, MethodBinding inheritedMethod) { 1623 this.handle( 1624 IProblem.FinalMethodCannotBeOverridden, 1627 new String [] {new String (inheritedMethod.declaringClass.readableName())}, 1628 new String [] {new String (inheritedMethod.declaringClass.shortReadableName())}, 1629 currentMethod.sourceStart(), 1630 currentMethod.sourceEnd()); 1631} 1632public void finalVariableBound(TypeVariableBinding typeVariable, TypeReference typeRef) { 1633 int severity = computeSeverity(IProblem.FinalBoundForTypeVariable); 1634 if (severity == ProblemSeverities.Ignore) return; 1635 this.handle( 1636 IProblem.FinalBoundForTypeVariable, 1637 new String [] { new String (typeVariable.sourceName), new String (typeRef.resolvedType.readableName())}, 1638 new String [] { new String (typeVariable.sourceName), new String (typeRef.resolvedType.shortReadableName())}, 1639 severity, 1640 typeRef.sourceStart, 1641 typeRef.sourceEnd); 1642} 1643public void forbiddenReference(FieldBinding field, ASTNode location, 1644 String messageTemplate, int problemId) { 1645 this.handle( 1646 problemId, 1647 new String [] { new String (field.readableName()) }, new String [] { 1649 MessageFormat.format(messageTemplate, 1650 new String []{ 1651 new String (field.shortReadableName()), 1652 new String (field.declaringClass.shortReadableName())})}, 1653 nodeSourceStart(field, location), 1654 nodeSourceEnd(field, location)); 1655} 1656public void forbiddenReference(MethodBinding method, ASTNode location, 1657 String messageTemplate, int problemId) { 1658 if (method.isConstructor()) 1659 this.handle( 1660 problemId, 1661 new String [] { new String (method.readableName()) }, new String [] { 1663 MessageFormat.format(messageTemplate, 1664 new String []{new String (method.shortReadableName())})}, 1665 location.sourceStart, 1666 location.sourceEnd); 1667 else 1668 this.handle( 1669 problemId, 1670 new String [] { new String (method.readableName()) }, new String [] { 1672 MessageFormat.format(messageTemplate, 1673 new String []{ 1674 new String (method.shortReadableName()), 1675 new String (method.declaringClass.shortReadableName())})}, 1676 location.sourceStart, 1677 location.sourceEnd); 1678} 1679public void forbiddenReference(TypeBinding type, ASTNode location, String messageTemplate, int problemId) { 1680 if (location == null) return; 1681 int severity = computeSeverity(problemId); 1682 if (severity == ProblemSeverities.Ignore) return; 1683 this.handle( 1685 problemId, 1686 new String [] { new String (type.readableName()) }, new String [] { MessageFormat.format(messageTemplate, new String []{ new String (type.shortReadableName())})}, 1688 severity, 1689 location.sourceStart, 1690 location.sourceEnd); 1691} 1692public void forwardReference(Reference reference, int indexInQualification, TypeBinding type) { 1693 this.handle( 1694 IProblem.ReferenceToForwardField, 1695 NoArgument, 1696 NoArgument, 1697 reference.sourceStart, 1698 reference.sourceEnd); 1699} 1700public void forwardTypeVariableReference(ASTNode location, TypeVariableBinding type) { 1701 this.handle( 1702 IProblem.ReferenceToForwardTypeVariable, 1703 new String [] {new String (type.readableName())}, 1704 new String [] {new String (type.shortReadableName())}, 1705 location.sourceStart, 1706 location.sourceEnd); 1707} 1708public void genericTypeCannotExtendThrowable(TypeDeclaration typeDecl) { 1709 ASTNode location = typeDecl.binding.isAnonymousType() ? typeDecl.allocation.type : typeDecl.superclass; 1710 this.handle( 1711 IProblem.GenericTypeCannotExtendThrowable, 1712 new String []{ new String (typeDecl.binding.readableName()) }, 1713 new String []{ new String (typeDecl.binding.shortReadableName()) }, 1714 location.sourceStart, 1715 location.sourceEnd); 1716} 1717private void handle( 1721 int problemId, 1722 String [] problemArguments, 1723 String [] messageArguments, 1724 int problemStartPosition, 1725 int problemEndPosition){ 1726 1727 this.handle( 1728 problemId, 1729 problemArguments, 1730 messageArguments, 1731 problemStartPosition, 1732 problemEndPosition, 1733 this.referenceContext, 1734 this.referenceContext == null ? null : this.referenceContext.compilationResult()); 1735 this.referenceContext = null; 1736} 1737private void handle( 1740 int problemId, 1741 String [] problemArguments, 1742 String [] messageArguments, 1743 int problemStartPosition, 1744 int problemEndPosition, 1745 CompilationResult unitResult){ 1746 1747 this.handle( 1748 problemId, 1749 problemArguments, 1750 messageArguments, 1751 problemStartPosition, 1752 problemEndPosition, 1753 this.referenceContext, 1754 unitResult); 1755 this.referenceContext = null; 1756} 1757private void handle( 1761 int problemId, 1762 String [] problemArguments, 1763 String [] messageArguments, 1764 int severity, 1765 int problemStartPosition, 1766 int problemEndPosition){ 1767 1768 this.handle( 1769 problemId, 1770 problemArguments, 1771 messageArguments, 1772 severity, 1773 problemStartPosition, 1774 problemEndPosition, 1775 this.referenceContext, 1776 this.referenceContext == null ? null : this.referenceContext.compilationResult()); 1777 this.referenceContext = null; 1778} 1779 1780public void hiddenCatchBlock(ReferenceBinding exceptionType, ASTNode location) { 1781 this.handle( 1782 IProblem.MaskedCatch, 1783 new String [] { 1784 new String (exceptionType.readableName()), 1785 }, 1786 new String [] { 1787 new String (exceptionType.shortReadableName()), 1788 }, 1789 location.sourceStart, 1790 location.sourceEnd); 1791} 1792 1793public void hierarchyCircularity(SourceTypeBinding sourceType, ReferenceBinding superType, TypeReference reference) { 1794 int start = 0; 1795 int end = 0; 1796 1797 if (reference == null) { start = sourceType.sourceStart(); 1799 end = sourceType.sourceEnd(); 1800 } else { 1801 start = reference.sourceStart; 1802 end = reference.sourceEnd; 1803 } 1804 1805 if (sourceType == superType) 1806 this.handle( 1807 IProblem.HierarchyCircularitySelfReference, 1808 new String [] {new String (sourceType.readableName()) }, 1809 new String [] {new String (sourceType.shortReadableName()) }, 1810 start, 1811 end); 1812 else 1813 this.handle( 1814 IProblem.HierarchyCircularity, 1815 new String [] {new String (sourceType.readableName()), new String (superType.readableName())}, 1816 new String [] {new String (sourceType.shortReadableName()), new String (superType.shortReadableName())}, 1817 start, 1818 end); 1819} 1820 1821public void hierarchyHasProblems(SourceTypeBinding type) { 1822 String [] arguments = new String [] {new String (type.sourceName())}; 1823 this.handle( 1824 IProblem.HierarchyHasProblems, 1825 arguments, 1826 arguments, 1827 type.sourceStart(), 1828 type.sourceEnd()); 1829} 1830public void illegalAbstractModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) { 1831 String [] arguments = new String [] {new String (type.sourceName()), new String (methodDecl.selector)}; 1832 this.handle( 1833 IProblem.IllegalAbstractModifierCombinationForMethod, 1834 arguments, 1835 arguments, 1836 methodDecl.sourceStart, 1837 methodDecl.sourceEnd); 1838} 1839public void illegalAccessFromTypeVariable(TypeVariableBinding variable, ASTNode location) { 1840 String [] arguments = new String [] { new String (variable.sourceName) }; 1841 this.handle( 1842 IProblem.IllegalAccessFromTypeVariable, 1843 arguments, 1844 arguments, 1845 location.sourceStart, 1846 location.sourceEnd); 1847} 1848public void illegalClassLiteralForTypeVariable(TypeVariableBinding variable, ASTNode location) { 1849 String [] arguments = new String [] { new String (variable.sourceName) }; 1850 this.handle( 1851 IProblem.IllegalClassLiteralForTypeVariable, 1852 arguments, 1853 arguments, 1854 location.sourceStart, 1855 location.sourceEnd); 1856} 1857public void illegalExtendedDimensions(AnnotationMethodDeclaration annotationTypeMemberDeclaration) { 1858 this.handle( 1859 IProblem.IllegalExtendedDimensions, 1860 NoArgument, 1861 NoArgument, 1862 annotationTypeMemberDeclaration.sourceStart, 1863 annotationTypeMemberDeclaration.sourceEnd); 1864} 1865public void illegalExtendedDimensions(Argument argument) { 1866 this.handle( 1867 IProblem.IllegalExtendedDimensionsForVarArgs, 1868 NoArgument, 1869 NoArgument, 1870 argument.sourceStart, 1871 argument.sourceEnd); 1872} 1873public void illegalGenericArray(TypeBinding leafComponentType, ASTNode location) { 1874 this.handle( 1875 IProblem.IllegalGenericArray, 1876 new String []{ new String (leafComponentType.readableName())}, 1877 new String []{ new String (leafComponentType.shortReadableName())}, 1878 location.sourceStart, 1879 location.sourceEnd); 1880} 1881public void illegalInstanceOfGenericType(TypeBinding checkedType, ASTNode location) { 1882 if (checkedType.isTypeVariable()) { 1883 this.handle( 1884 IProblem.IllegalInstanceofTypeParameter, 1885 new String [] { new String (checkedType.readableName()), new String (checkedType.erasure().readableName())}, 1886 new String [] { new String (checkedType.shortReadableName()), new String (checkedType.erasure().shortReadableName())}, 1887 location.sourceStart, 1888 location.sourceEnd); 1889 return; 1890 } 1891 this.handle( 1892 IProblem.IllegalInstanceofParameterizedType, 1893 new String [] { new String (checkedType.readableName()), new String (checkedType.erasure().sourceName())}, 1894 new String [] { new String (checkedType.shortReadableName()), new String (checkedType.erasure().sourceName())}, 1895 location.sourceStart, 1896 location.sourceEnd); 1897} 1898public void illegalLocalTypeDeclaration(TypeDeclaration typeDeclaration) { 1899 if (isRecoveredName(typeDeclaration.name)) return; 1900 1901 int problemID = 0; 1902 if ((typeDeclaration.modifiers & ClassFileConstants.AccEnum) != 0) { 1903 problemID = IProblem.CannotDefineEnumInLocalType; 1904 } else if ((typeDeclaration.modifiers & ClassFileConstants.AccAnnotation) != 0) { 1905 problemID = IProblem.CannotDefineAnnotationInLocalType; 1906 } else if ((typeDeclaration.modifiers & ClassFileConstants.AccInterface) != 0) { 1907 problemID = IProblem.CannotDefineInterfaceInLocalType; 1908 } 1909 if (problemID != 0) { 1910 String [] arguments = new String [] {new String (typeDeclaration.name)}; 1911 this.handle( 1912 problemID, 1913 arguments, 1914 arguments, 1915 typeDeclaration.sourceStart, 1916 typeDeclaration.sourceEnd); 1917 } 1918} 1919public void illegalModifierCombinationFinalAbstractForClass(SourceTypeBinding type) { 1920 String [] arguments = new String [] {new String (type.sourceName())}; 1921 this.handle( 1922 IProblem.IllegalModifierCombinationFinalAbstractForClass, 1923 arguments, 1924 arguments, 1925 type.sourceStart(), 1926 type.sourceEnd()); 1927} 1928public void illegalModifierCombinationFinalVolatileForField(ReferenceBinding type, FieldDeclaration fieldDecl) { 1929 String [] arguments = new String [] {new String (fieldDecl.name)}; 1930 1931 this.handle( 1932 IProblem.IllegalModifierCombinationFinalVolatileForField, 1933 arguments, 1934 arguments, 1935 fieldDecl.sourceStart, 1936 fieldDecl.sourceEnd); 1937} 1938public void illegalModifierForAnnotationField(FieldDeclaration fieldDecl) { 1939 String name = new String (fieldDecl.name); 1940 this.handle( 1941 IProblem.IllegalModifierForAnnotationField, 1942 new String [] { 1943 new String (fieldDecl.binding.declaringClass.readableName()), 1944 name, 1945 }, 1946 new String [] { 1947 new String (fieldDecl.binding.declaringClass.shortReadableName()), 1948 name, 1949 }, 1950 fieldDecl.sourceStart, 1951 fieldDecl.sourceEnd); 1952} 1953public void illegalModifierForAnnotationMember(AbstractMethodDeclaration methodDecl) { 1954 this.handle( 1955 IProblem.IllegalModifierForAnnotationMethod, 1956 new String [] { 1957 new String (methodDecl.binding.declaringClass.readableName()), 1958 new String (methodDecl.selector), 1959 }, 1960 new String [] { 1961 new String (methodDecl.binding.declaringClass.shortReadableName()), 1962 new String (methodDecl.selector), 1963 }, 1964 methodDecl.sourceStart, 1965 methodDecl.sourceEnd); 1966} 1967public void illegalModifierForAnnotationMemberType(SourceTypeBinding type) { 1968 String [] arguments = new String [] {new String (type.sourceName())}; 1969 this.handle( 1970 IProblem.IllegalModifierForAnnotationMemberType, 1971 arguments, 1972 arguments, 1973 type.sourceStart(), 1974 type.sourceEnd()); 1975} 1976public void illegalModifierForAnnotationType(SourceTypeBinding type) { 1977 String [] arguments = new String [] {new String (type.sourceName())}; 1978 this.handle( 1979 IProblem.IllegalModifierForAnnotationType, 1980 arguments, 1981 arguments, 1982 type.sourceStart(), 1983 type.sourceEnd()); 1984} 1985public void illegalModifierForClass(SourceTypeBinding type) { 1986 String [] arguments = new String [] {new String (type.sourceName())}; 1987 this.handle( 1988 IProblem.IllegalModifierForClass, 1989 arguments, 1990 arguments, 1991 type.sourceStart(), 1992 type.sourceEnd()); 1993} 1994public void illegalModifierForEnum(SourceTypeBinding type) { 1995 String [] arguments = new String [] {new String (type.sourceName())}; 1996 this.handle( 1997 IProblem.IllegalModifierForEnum, 1998 arguments, 1999 arguments, 2000 type.sourceStart(), 2001 type.sourceEnd()); 2002} 2003public void illegalModifierForEnumConstant(ReferenceBinding type, FieldDeclaration fieldDecl) { 2004 String [] arguments = new String [] {new String (fieldDecl.name)}; 2005 this.handle( 2006 IProblem.IllegalModifierForEnumConstant, 2007 arguments, 2008 arguments, 2009 fieldDecl.sourceStart, 2010 fieldDecl.sourceEnd); 2011} 2012 2013public void illegalModifierForEnumConstructor(AbstractMethodDeclaration constructor) { 2014 this.handle( 2015 IProblem.IllegalModifierForEnumConstructor, 2016 NoArgument, 2017 NoArgument, 2018 constructor.sourceStart, 2019 constructor.sourceEnd); 2020} 2021public void illegalModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl) { 2022 String [] arguments = new String [] {new String (fieldDecl.name)}; 2023 this.handle( 2024 IProblem.IllegalModifierForField, 2025 arguments, 2026 arguments, 2027 fieldDecl.sourceStart, 2028 fieldDecl.sourceEnd); 2029} 2030public void illegalModifierForInterface(SourceTypeBinding type) { 2031 String [] arguments = new String [] {new String (type.sourceName())}; 2032 this.handle( 2033 IProblem.IllegalModifierForInterface, 2034 arguments, 2035 arguments, 2036 type.sourceStart(), 2037 type.sourceEnd()); 2038} 2039 2040public void illegalModifierForInterfaceField(FieldDeclaration fieldDecl) { 2041 String name = new String (fieldDecl.name); 2042 this.handle( 2043 IProblem.IllegalModifierForInterfaceField, 2044 new String [] { 2045 new String (fieldDecl.binding.declaringClass.readableName()), 2046 name, 2047 }, 2048 new String [] { 2049 new String (fieldDecl.binding.declaringClass.shortReadableName()), 2050 name, 2051 }, 2052 fieldDecl.sourceStart, 2053 fieldDecl.sourceEnd); 2054} 2055public void illegalModifierForInterfaceMethod(AbstractMethodDeclaration methodDecl) { 2056 this.handle( 2057 IProblem.IllegalModifierForInterfaceMethod, 2058 new String [] { 2059 new String (methodDecl.binding.declaringClass.readableName()), 2060 new String (methodDecl.selector), 2061 typesAsString(methodDecl.binding.isVarargs(), methodDecl.binding.parameters, false), 2062 }, 2063 new String [] { 2064 new String (methodDecl.binding.declaringClass.shortReadableName()), 2065 new String (methodDecl.selector), 2066 typesAsString(methodDecl.binding.isVarargs(), methodDecl.binding.parameters, true), 2067 }, 2068 methodDecl.sourceStart, 2069 methodDecl.sourceEnd); 2070} 2071public void illegalModifierForLocalClass(SourceTypeBinding type) { 2072 String [] arguments = new String [] {new String (type.sourceName())}; 2073 this.handle( 2074 IProblem.IllegalModifierForLocalClass, 2075 arguments, 2076 arguments, 2077 type.sourceStart(), 2078 type.sourceEnd()); 2079} 2080public void illegalModifierForLocalEnum(SourceTypeBinding type) { 2081 String [] arguments = new String [] {new String (type.sourceName())}; 2082 this.handle( 2083 IProblem.IllegalModifierForLocalEnum, 2084 arguments, 2085 arguments, 2086 type.sourceStart(), 2087 type.sourceEnd()); 2088} 2089public void illegalModifierForMemberClass(SourceTypeBinding type) { 2090 String [] arguments = new String [] {new String (type.sourceName())}; 2091 this.handle( 2092 IProblem.IllegalModifierForMemberClass, 2093 arguments, 2094 arguments, 2095 type.sourceStart(), 2096 type.sourceEnd()); 2097} 2098public void illegalModifierForMemberEnum(SourceTypeBinding type) { 2099 String [] arguments = new String [] {new String (type.sourceName())}; 2100 this.handle( 2101 IProblem.IllegalModifierForMemberEnum, 2102 arguments, 2103 arguments, 2104 type.sourceStart(), 2105 type.sourceEnd()); 2106} 2107public void illegalModifierForMemberInterface(SourceTypeBinding type) { 2108 String [] arguments = new String [] {new String (type.sourceName())}; 2109 this.handle( 2110 IProblem.IllegalModifierForMemberInterface, 2111 arguments, 2112 arguments, 2113 type.sourceStart(), 2114 type.sourceEnd()); 2115} 2116public void illegalModifierForMethod(AbstractMethodDeclaration methodDecl) { 2117 this.handle( 2118 IProblem.IllegalModifierForMethod, 2119 new String [] { 2120 new String (methodDecl.selector), 2121 typesAsString(methodDecl.binding.isVarargs(), methodDecl.binding.parameters, false), 2122 new String (methodDecl.binding.declaringClass.readableName()), 2123 }, 2124 new String [] { 2125 new String (methodDecl.selector), 2126 typesAsString(methodDecl.binding.isVarargs(), methodDecl.binding.parameters, true), 2127 new String (methodDecl.binding.declaringClass.shortReadableName()), 2128 }, 2129 methodDecl.sourceStart, 2130 methodDecl.sourceEnd); 2131} 2132public void illegalModifierForVariable(LocalDeclaration localDecl, boolean complainAsArgument) { 2133 String [] arguments = new String [] {new String (localDecl.name)}; 2134 this.handle( 2135 complainAsArgument 2136 ? IProblem.IllegalModifierForArgument 2137 : IProblem.IllegalModifierForVariable, 2138 arguments, 2139 arguments, 2140 localDecl.sourceStart, 2141 localDecl.sourceEnd); 2142} 2143public void illegalPrimitiveOrArrayTypeForEnclosingInstance(TypeBinding enclosingType, ASTNode location) { 2144 this.handle( 2145 IProblem.IllegalPrimitiveOrArrayTypeForEnclosingInstance, 2146 new String [] {new String (enclosingType.readableName())}, 2147 new String [] {new String (enclosingType.shortReadableName())}, 2148 location.sourceStart, 2149 location.sourceEnd); 2150} 2151public void illegalQualifiedParameterizedTypeAllocation(TypeReference qualifiedTypeReference, TypeBinding allocatedType) { 2152 this.handle( 2153 IProblem.IllegalQualifiedParameterizedTypeAllocation, 2154 new String [] { new String (allocatedType.readableName()), new String (allocatedType.enclosingType().readableName()), }, 2155 new String [] { new String (allocatedType.shortReadableName()), new String (allocatedType.enclosingType().shortReadableName()), }, 2156 qualifiedTypeReference.sourceStart, 2157 qualifiedTypeReference.sourceEnd); 2158} 2159public void illegalStaticModifierForMemberType(SourceTypeBinding type) { 2160 String [] arguments = new String [] {new String (type.sourceName())}; 2161 this.handle( 2162 IProblem.IllegalStaticModifierForMemberType, 2163 arguments, 2164 arguments, 2165 type.sourceStart(), 2166 type.sourceEnd()); 2167} 2168public void illegalUsageOfQualifiedTypeReference(QualifiedTypeReference qualifiedTypeReference) { 2169 StringBuffer buffer = new StringBuffer (); 2170 char[][] tokens = qualifiedTypeReference.tokens; 2171 for (int i = 0; i < tokens.length; i++) { 2172 if (i > 0) buffer.append('.'); 2173 buffer.append(tokens[i]); 2174 } 2175 String [] arguments = new String [] { String.valueOf(buffer)}; 2176 this.handle( 2177 IProblem.IllegalUsageOfQualifiedTypeReference, 2178 arguments, 2179 arguments, 2180 qualifiedTypeReference.sourceStart, 2181 qualifiedTypeReference.sourceEnd); 2182} 2183public void illegalVararg(Argument argType, AbstractMethodDeclaration methodDecl) { 2184 String [] arguments = new String [] {CharOperation.toString(argType.type.getTypeName()), new String (methodDecl.selector)}; 2185 this.handle( 2186 IProblem.IllegalVararg, 2187 arguments, 2188 arguments, 2189 argType.sourceStart, 2190 argType.sourceEnd); 2191} 2192public void illegalVisibilityModifierCombinationForField(ReferenceBinding type, FieldDeclaration fieldDecl) { 2193 String [] arguments = new String [] {new String (fieldDecl.name)}; 2194 this.handle( 2195 IProblem.IllegalVisibilityModifierCombinationForField, 2196 arguments, 2197 arguments, 2198 fieldDecl.sourceStart, 2199 fieldDecl.sourceEnd); 2200} 2201public void illegalVisibilityModifierCombinationForMemberType(SourceTypeBinding type) { 2202 String [] arguments = new String [] {new String (type.sourceName())}; 2203 this.handle( 2204 IProblem.IllegalVisibilityModifierCombinationForMemberType, 2205 arguments, 2206 arguments, 2207 type.sourceStart(), 2208 type.sourceEnd()); 2209} 2210public void illegalVisibilityModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) { 2211 String [] arguments = new String [] {new String (type.sourceName()), new String (methodDecl.selector)}; 2212 this.handle( 2213 IProblem.IllegalVisibilityModifierCombinationForMethod, 2214 arguments, 2215 arguments, 2216 methodDecl.sourceStart, 2217 methodDecl.sourceEnd); 2218} 2219public void illegalVisibilityModifierForInterfaceMemberType(SourceTypeBinding type) { 2220 String [] arguments = new String [] {new String (type.sourceName())}; 2221 this.handle( 2222 IProblem.IllegalVisibilityModifierForInterfaceMemberType, 2223 arguments, 2224 arguments, 2225 type.sourceStart(), 2226 type.sourceEnd()); 2227} 2228public void illegalVoidExpression(ASTNode location) { 2229 this.handle( 2230 IProblem.InvalidVoidExpression, 2231 NoArgument, 2232 NoArgument, 2233 location.sourceStart, 2234 location.sourceEnd); 2235} 2236public void importProblem(ImportReference importRef, Binding expectedImport) { 2237 if (expectedImport instanceof FieldBinding) { 2238 int id = IProblem.UndefinedField; 2239 FieldBinding field = (FieldBinding) expectedImport; 2240 String [] readableArguments = null; 2241 String [] shortArguments = null; 2242 switch (expectedImport.problemId()) { 2243 case ProblemReasons.NotVisible : 2244 id = IProblem.NotVisibleField; 2245 readableArguments = new String [] {CharOperation.toString(importRef.tokens), new String (field.declaringClass.readableName())}; 2246 shortArguments = new String [] {CharOperation.toString(importRef.tokens), new String (field.declaringClass.shortReadableName())}; 2247 break; 2248 case ProblemReasons.Ambiguous : 2249 id = IProblem.AmbiguousField; 2250 readableArguments = new String [] {new String (field.readableName())}; 2251 shortArguments = new String [] {new String (field.readableName())}; 2252 break; 2253 case ProblemReasons.ReceiverTypeNotVisible : 2254 id = IProblem.NotVisibleType; 2255 readableArguments = new String [] {new String (field.declaringClass.leafComponentType().readableName())}; 2256 shortArguments = new String [] {new String (field.declaringClass.leafComponentType().shortReadableName())}; 2257 break; 2258 } 2259 this.handle( 2260 id, 2261 readableArguments, 2262 shortArguments, 2263 nodeSourceStart(field, importRef), 2264 nodeSourceEnd(field, importRef)); 2265 return; 2266 } 2267 2268 if (expectedImport.problemId() == ProblemReasons.NotFound) { 2269 char[][] tokens = expectedImport instanceof ProblemReferenceBinding 2270 ? ((ProblemReferenceBinding) expectedImport).compoundName 2271 : importRef.tokens; 2272 String [] arguments = new String []{CharOperation.toString(tokens)}; 2273 this.handle( 2274 IProblem.ImportNotFound, 2275 arguments, 2276 arguments, 2277 importRef.sourceStart, 2278 (int) importRef.sourcePositions[tokens.length - 1]); 2279 return; 2280 } 2281 if (expectedImport.problemId() == ProblemReasons.InvalidTypeForStaticImport) { 2282 char[][] tokens = importRef.tokens; 2283 String [] arguments = new String []{CharOperation.toString(tokens)}; 2284 this.handle( 2285 IProblem.InvalidTypeForStaticImport, 2286 arguments, 2287 arguments, 2288 importRef.sourceStart, 2289 (int) importRef.sourcePositions[tokens.length - 1]); 2290 return; 2291 } 2292 invalidType(importRef, (TypeBinding)expectedImport); 2293} 2294public void incompatibleExceptionInThrowsClause(SourceTypeBinding type, MethodBinding currentMethod, MethodBinding inheritedMethod, ReferenceBinding exceptionType) { 2295 if (type == currentMethod.declaringClass) { 2296 int id; 2297 if (currentMethod.declaringClass.isInterface() 2298 && !inheritedMethod.isPublic()){ id = IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod; 2300 } else { 2301 id = IProblem.IncompatibleExceptionInThrowsClause; 2302 } 2303 this.handle( 2304 id, 2307 new String [] { 2308 new String (exceptionType.sourceName()), 2309 new String ( 2310 CharOperation.concat( 2311 inheritedMethod.declaringClass.readableName(), 2312 inheritedMethod.readableName(), 2313 '.'))}, 2314 new String [] { 2315 new String (exceptionType.sourceName()), 2316 new String ( 2317 CharOperation.concat( 2318 inheritedMethod.declaringClass.shortReadableName(), 2319 inheritedMethod.shortReadableName(), 2320 '.'))}, 2321 currentMethod.sourceStart(), 2322 currentMethod.sourceEnd()); 2323 } else 2324 this.handle( 2325 IProblem.IncompatibleExceptionInInheritedMethodThrowsClause, 2328 new String [] { 2329 new String (exceptionType.sourceName()), 2330 new String ( 2331 CharOperation.concat( 2332 currentMethod.declaringClass.sourceName(), 2333 currentMethod.readableName(), 2334 '.')), 2335 new String ( 2336 CharOperation.concat( 2337 inheritedMethod.declaringClass.readableName(), 2338 inheritedMethod.readableName(), 2339 '.'))}, 2340 new String [] { 2341 new String (exceptionType.sourceName()), 2342 new String ( 2343 CharOperation.concat( 2344 currentMethod.declaringClass.sourceName(), 2345 currentMethod.shortReadableName(), 2346 '.')), 2347 new String ( 2348 CharOperation.concat( 2349 inheritedMethod.declaringClass.shortReadableName(), 2350 inheritedMethod.shortReadableName(), 2351 '.'))}, 2352 type.sourceStart(), 2353 type.sourceEnd()); 2354} 2355public void incompatibleReturnType(MethodBinding currentMethod, MethodBinding inheritedMethod) { 2356 StringBuffer methodSignature = new StringBuffer (); 2357 methodSignature 2358 .append(inheritedMethod.declaringClass.readableName()) 2359 .append('.') 2360 .append(inheritedMethod.readableName()); 2361 2362 StringBuffer shortSignature = new StringBuffer (); 2363 shortSignature 2364 .append(inheritedMethod.declaringClass.shortReadableName()) 2365 .append('.') 2366 .append(inheritedMethod.shortReadableName()); 2367 2368 int id; 2369 final ReferenceBinding declaringClass = currentMethod.declaringClass; 2370 if (declaringClass.isInterface() 2371 && !inheritedMethod.isPublic()){ id = IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod; 2373 } else { 2374 id = IProblem.IncompatibleReturnType; 2375 } 2376 AbstractMethodDeclaration method = currentMethod.sourceMethod(); 2377 int sourceStart = 0; 2378 int sourceEnd = 0; 2379 if (method == null) { 2380 if (declaringClass instanceof SourceTypeBinding) { 2381 SourceTypeBinding sourceTypeBinding = (SourceTypeBinding) declaringClass; 2382 sourceStart = sourceTypeBinding.sourceStart(); 2383 sourceEnd = sourceTypeBinding.sourceEnd(); 2384 } 2385 } else if (method.isConstructor()){ 2386 sourceStart = method.sourceStart; 2387 sourceEnd = method.sourceEnd; 2388 } else { 2389 TypeReference returnType = ((MethodDeclaration) method).returnType; 2390 sourceStart = returnType.sourceStart; 2391 if (returnType instanceof ParameterizedSingleTypeReference) { 2392 ParameterizedSingleTypeReference typeReference = (ParameterizedSingleTypeReference) returnType; 2393 TypeReference[] typeArguments = typeReference.typeArguments; 2394 if (typeArguments[typeArguments.length - 1].sourceEnd > typeReference.sourceEnd) { 2395 sourceEnd = retrieveClosingAngleBracketPosition(typeReference.sourceEnd); 2396 } else { 2397 sourceEnd = returnType.sourceEnd; 2398 } 2399 } else if (returnType instanceof ParameterizedQualifiedTypeReference) { 2400 ParameterizedQualifiedTypeReference typeReference = (ParameterizedQualifiedTypeReference) returnType; 2401 sourceEnd = retrieveClosingAngleBracketPosition(typeReference.sourceEnd); 2402 } else { 2403 sourceEnd = returnType.sourceEnd; 2404 } 2405 } 2406 this.handle( 2407 id, 2408 new String [] {methodSignature.toString()}, 2409 new String [] {shortSignature.toString()}, 2410 sourceStart, 2411 sourceEnd); 2412} 2413public void incorrectArityForParameterizedType(ASTNode location, TypeBinding type, TypeBinding[] argumentTypes) { 2414 if (location == null) { 2415 this.handle( 2416 IProblem.IncorrectArityForParameterizedType, 2417 new String [] {new String (type.readableName()), typesAsString(false, argumentTypes, false)}, 2418 new String [] {new String (type.shortReadableName()), typesAsString(false, argumentTypes, true)}, 2419 ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal, 2420 0, 2421 0); 2422 return; } 2424 this.handle( 2425 IProblem.IncorrectArityForParameterizedType, 2426 new String [] {new String (type.readableName()), typesAsString(false, argumentTypes, false)}, 2427 new String [] {new String (type.shortReadableName()), typesAsString(false, argumentTypes, true)}, 2428 location.sourceStart, 2429 location.sourceEnd); 2430} 2431public void incorrectLocationForNonEmptyDimension(ArrayAllocationExpression expression, int index) { 2432 this.handle( 2433 IProblem.IllegalDimension, 2434 NoArgument, 2435 NoArgument, 2436 expression.dimensions[index].sourceStart, 2437 expression.dimensions[index].sourceEnd); 2438} 2439public void incorrectSwitchType(Expression expression, TypeBinding testType) { 2440 this.handle( 2441 IProblem.IncorrectSwitchType, 2442 new String [] {new String (testType.readableName())}, 2443 new String [] {new String (testType.shortReadableName())}, 2444 expression.sourceStart, 2445 expression.sourceEnd); 2446} 2447public void indirectAccessToStaticField(ASTNode location, FieldBinding field){ 2448 int severity = computeSeverity(IProblem.IndirectAccessToStaticField); 2449 if (severity == ProblemSeverities.Ignore) return; 2450 this.handle( 2451 IProblem.IndirectAccessToStaticField, 2452 new String [] {new String (field.declaringClass.readableName()), new String (field.name)}, 2453 new String [] {new String (field.declaringClass.shortReadableName()), new String (field.name)}, 2454 severity, 2455 nodeSourceStart(field, location), 2456 nodeSourceEnd(field, location)); 2457} 2458public void indirectAccessToStaticMethod(ASTNode location, MethodBinding method) { 2459 int severity = computeSeverity(IProblem.IndirectAccessToStaticMethod); 2460 if (severity == ProblemSeverities.Ignore) return; 2461 this.handle( 2462 IProblem.IndirectAccessToStaticMethod, 2463 new String [] {new String (method.declaringClass.readableName()), new String (method.selector), typesAsString(method.isVarargs(), method.parameters, false)}, 2464 new String [] {new String (method.declaringClass.shortReadableName()), new String (method.selector), typesAsString(method.isVarargs(), method.parameters, true)}, 2465 severity, 2466 location.sourceStart, 2467 location.sourceEnd); 2468} 2469public void inheritedMethodReducesVisibility(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods) { 2470 StringBuffer concreteSignature = new StringBuffer (); 2471 concreteSignature 2472 .append(concreteMethod.declaringClass.readableName()) 2473 .append('.') 2474 .append(concreteMethod.readableName()); 2475 StringBuffer shortSignature = new StringBuffer (); 2476 shortSignature 2477 .append(concreteMethod.declaringClass.shortReadableName()) 2478 .append('.') 2479 .append(concreteMethod.shortReadableName()); 2480 this.handle( 2481 IProblem.InheritedMethodReducesVisibility, 2483 new String [] { 2484 concreteSignature.toString(), 2485 new String (abstractMethods[0].declaringClass.readableName())}, 2486 new String [] { 2487 new String (shortSignature.toString()), 2488 new String (abstractMethods[0].declaringClass.shortReadableName())}, 2489 type.sourceStart(), 2490 type.sourceEnd()); 2491} 2492public void inheritedMethodsHaveIncompatibleReturnTypes(ASTNode location, MethodBinding[] inheritedMethods, int length) { 2493 StringBuffer methodSignatures = new StringBuffer (); 2494 StringBuffer shortSignatures = new StringBuffer (); 2495 for (int i = length; --i >= 0;) { 2496 methodSignatures 2497 .append(inheritedMethods[i].declaringClass.readableName()) 2498 .append('.') 2499 .append(inheritedMethods[i].readableName()); 2500 shortSignatures 2501 .append(inheritedMethods[i].declaringClass.shortReadableName()) 2502 .append('.') 2503 .append(inheritedMethods[i].shortReadableName()); 2504 if (i != 0){ 2505 methodSignatures.append(", "); shortSignatures.append(", "); } 2508 } 2509 2510 this.handle( 2511 IProblem.IncompatibleReturnType, 2514 new String [] {methodSignatures.toString()}, 2515 new String [] {shortSignatures.toString()}, 2516 location.sourceStart, 2517 location.sourceEnd); 2518} 2519public void inheritedMethodsHaveIncompatibleReturnTypes(SourceTypeBinding type, MethodBinding[] inheritedMethods, int length) { 2520 StringBuffer methodSignatures = new StringBuffer (); 2521 StringBuffer shortSignatures = new StringBuffer (); 2522 for (int i = length; --i >= 0;) { 2523 methodSignatures 2524 .append(inheritedMethods[i].declaringClass.readableName()) 2525 .append('.') 2526 .append(inheritedMethods[i].readableName()); 2527 shortSignatures 2528 .append(inheritedMethods[i].declaringClass.shortReadableName()) 2529 .append('.') 2530 .append(inheritedMethods[i].shortReadableName()); 2531 if (i != 0){ 2532 methodSignatures.append(", "); shortSignatures.append(", "); } 2535 } 2536 2537 this.handle( 2538 IProblem.IncompatibleReturnType, 2541 new String [] {methodSignatures.toString()}, 2542 new String [] {shortSignatures.toString()}, 2543 type.sourceStart(), 2544 type.sourceEnd()); 2545} 2546public void inheritedMethodsHaveNameClash(SourceTypeBinding type, MethodBinding oneMethod, MethodBinding twoMethod) { 2547 this.handle( 2548 IProblem.MethodNameClash, 2549 new String [] { 2550 new String (oneMethod.selector), 2551 typesAsString(oneMethod.original().isVarargs(), oneMethod.original().parameters, false), 2552 new String (oneMethod.declaringClass.readableName()), 2553 typesAsString(twoMethod.original().isVarargs(), twoMethod.original().parameters, false), 2554 new String (twoMethod.declaringClass.readableName()), 2555 }, 2556 new String [] { 2557 new String (oneMethod.selector), 2558 typesAsString(oneMethod.original().isVarargs(), oneMethod.original().parameters, true), 2559 new String (oneMethod.declaringClass.shortReadableName()), 2560 typesAsString(twoMethod.original().isVarargs(), twoMethod.original().parameters, true), 2561 new String (twoMethod.declaringClass.shortReadableName()), 2562 }, 2563 type.sourceStart(), 2564 type.sourceEnd()); 2565} 2566public void initializerMustCompleteNormally(FieldDeclaration fieldDecl) { 2567 this.handle( 2568 IProblem.InitializerMustCompleteNormally, 2569 NoArgument, 2570 NoArgument, 2571 fieldDecl.sourceStart, 2572 fieldDecl.sourceEnd); 2573} 2574public void innerTypesCannotDeclareStaticInitializers(ReferenceBinding innerType, Initializer initializer) { 2575 this.handle( 2576 IProblem.CannotDefineStaticInitializerInLocalType, 2577 new String [] {new String (innerType.readableName())}, 2578 new String [] {new String (innerType.shortReadableName())}, 2579 initializer.sourceStart, 2580 initializer.sourceStart); 2581} 2582public void interfaceCannotHaveConstructors(ConstructorDeclaration constructor) { 2583 this.handle( 2584 IProblem.InterfaceCannotHaveConstructors, 2585 NoArgument, 2586 NoArgument, 2587 constructor.sourceStart, 2588 constructor.sourceEnd, 2589 constructor, 2590 constructor.compilationResult()); 2591} 2592public void interfaceCannotHaveInitializers(SourceTypeBinding type, FieldDeclaration fieldDecl) { 2593 String [] arguments = new String [] {new String (type.sourceName())}; 2594 2595 this.handle( 2596 IProblem.InterfaceCannotHaveInitializers, 2597 arguments, 2598 arguments, 2599 fieldDecl.sourceStart, 2600 fieldDecl.sourceEnd); 2601} 2602public void invalidAnnotationMemberType(MethodDeclaration methodDecl) { 2603 this.handle( 2604 IProblem.InvalidAnnotationMemberType, 2605 new String [] { 2606 new String (methodDecl.binding.returnType.readableName()), 2607 new String (methodDecl.selector), 2608 new String (methodDecl.binding.declaringClass.readableName()), 2609 }, 2610 new String [] { 2611 new String (methodDecl.binding.returnType.shortReadableName()), 2612 new String (methodDecl.selector), 2613 new String (methodDecl.binding.declaringClass.shortReadableName()), 2614 }, 2615 methodDecl.returnType.sourceStart, 2616 methodDecl.returnType.sourceEnd); 2617 2618} 2619public void invalidBreak(ASTNode location) { 2620 this.handle( 2621 IProblem.InvalidBreak, 2622 NoArgument, 2623 NoArgument, 2624 location.sourceStart, 2625 location.sourceEnd); 2626} 2627public void invalidConstructor(Statement statement, MethodBinding targetConstructor) { 2628 boolean insideDefaultConstructor = 2629 (this.referenceContext instanceof ConstructorDeclaration) 2630 && ((ConstructorDeclaration)this.referenceContext).isDefaultConstructor(); 2631 boolean insideImplicitConstructorCall = 2632 (statement instanceof ExplicitConstructorCall) 2633 && (((ExplicitConstructorCall) statement).accessMode == ExplicitConstructorCall.ImplicitSuper); 2634 2635 int sourceStart = statement.sourceStart; 2636 int sourceEnd = statement.sourceEnd; 2637 if (statement instanceof AllocationExpression) { 2638 AllocationExpression allocation = (AllocationExpression)statement; 2639 if (allocation.enumConstant != null) { 2640 sourceStart = allocation.enumConstant.sourceStart; 2641 sourceEnd = allocation.enumConstant.sourceEnd; 2642 } 2643 } 2644 2645 int id = IProblem.UndefinedConstructor; MethodBinding shownConstructor = targetConstructor; 2647 switch (targetConstructor.problemId()) { 2648 case ProblemReasons.NotFound : 2649 if (insideDefaultConstructor){ 2650 id = IProblem.UndefinedConstructorInDefaultConstructor; 2651 } else if (insideImplicitConstructorCall){ 2652 id = IProblem.UndefinedConstructorInImplicitConstructorCall; 2653 } else { 2654 id = IProblem.UndefinedConstructor; 2655 } 2656 break; 2657 case ProblemReasons.NotVisible : 2658 if (insideDefaultConstructor){ 2659 id = IProblem.NotVisibleConstructorInDefaultConstructor; 2660 } else if (insideImplicitConstructorCall){ 2661 id = IProblem.NotVisibleConstructorInImplicitConstructorCall; 2662 } else { 2663 id = IProblem.NotVisibleConstructor; 2664 } 2665 ProblemMethodBinding problemConstructor = (ProblemMethodBinding) targetConstructor; 2666 if (problemConstructor.closestMatch != null) { 2667 shownConstructor = problemConstructor.closestMatch.original(); 2668 } 2669 break; 2670 case ProblemReasons.Ambiguous : 2671 if (insideDefaultConstructor){ 2672 id = IProblem.AmbiguousConstructorInDefaultConstructor; 2673 } else if (insideImplicitConstructorCall){ 2674 id = IProblem.AmbiguousConstructorInImplicitConstructorCall; 2675 } else { 2676 id = IProblem.AmbiguousConstructor; 2677 } 2678 break; 2679 case ProblemReasons.ParameterBoundMismatch : 2680 problemConstructor = (ProblemMethodBinding) targetConstructor; 2681 ParameterizedGenericMethodBinding substitutedConstructor = (ParameterizedGenericMethodBinding) problemConstructor.closestMatch; 2682 shownConstructor = substitutedConstructor.original(); 2683 int augmentedLength = problemConstructor.parameters.length; 2684 TypeBinding inferredTypeArgument = problemConstructor.parameters[augmentedLength-2]; 2685 TypeVariableBinding typeParameter = (TypeVariableBinding) problemConstructor.parameters[augmentedLength-1]; 2686 TypeBinding[] invocationArguments = new TypeBinding[augmentedLength-2]; System.arraycopy(problemConstructor.parameters, 0, invocationArguments, 0, augmentedLength-2); 2688 this.handle( 2689 IProblem.GenericConstructorTypeArgumentMismatch, 2690 new String [] { 2691 new String (shownConstructor.declaringClass.sourceName()), 2692 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false), 2693 new String (shownConstructor.declaringClass.readableName()), 2694 typesAsString(false, invocationArguments, false), 2695 new String (inferredTypeArgument.readableName()), 2696 new String (typeParameter.sourceName), 2697 parameterBoundAsString(typeParameter, false) }, 2698 new String [] { 2699 new String (shownConstructor.declaringClass.sourceName()), 2700 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true), 2701 new String (shownConstructor.declaringClass.shortReadableName()), 2702 typesAsString(false, invocationArguments, true), 2703 new String (inferredTypeArgument.shortReadableName()), 2704 new String (typeParameter.sourceName), 2705 parameterBoundAsString(typeParameter, true) }, 2706 sourceStart, 2707 sourceEnd); 2708 return; 2709 2710 case ProblemReasons.TypeParameterArityMismatch : 2711 problemConstructor = (ProblemMethodBinding) targetConstructor; 2712 shownConstructor = problemConstructor.closestMatch; 2713 if (shownConstructor.typeVariables == Binding.NO_TYPE_VARIABLES) { 2714 this.handle( 2715 IProblem.NonGenericConstructor, 2716 new String [] { 2717 new String (shownConstructor.declaringClass.sourceName()), 2718 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false), 2719 new String (shownConstructor.declaringClass.readableName()), 2720 typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false) }, 2721 new String [] { 2722 new String (shownConstructor.declaringClass.sourceName()), 2723 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true), 2724 new String (shownConstructor.declaringClass.shortReadableName()), 2725 typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true) }, 2726 sourceStart, 2727 sourceEnd); 2728 } else { 2729 this.handle( 2730 IProblem.IncorrectArityForParameterizedConstructor , 2731 new String [] { 2732 new String (shownConstructor.declaringClass.sourceName()), 2733 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false), 2734 new String (shownConstructor.declaringClass.readableName()), 2735 typesAsString(false, shownConstructor.typeVariables, false), 2736 typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false) }, 2737 new String [] { 2738 new String (shownConstructor.declaringClass.sourceName()), 2739 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true), 2740 new String (shownConstructor.declaringClass.shortReadableName()), 2741 typesAsString(false, shownConstructor.typeVariables, true), 2742 typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true) }, 2743 sourceStart, 2744 sourceEnd); 2745 } 2746 return; 2747 case ProblemReasons.ParameterizedMethodTypeMismatch : 2748 problemConstructor = (ProblemMethodBinding) targetConstructor; 2749 shownConstructor = problemConstructor.closestMatch; 2750 this.handle( 2751 IProblem.ParameterizedConstructorArgumentTypeMismatch, 2752 new String [] { 2753 new String (shownConstructor.declaringClass.sourceName()), 2754 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false), 2755 new String  |