1 /*********************************************************************************************************************************** 2 * Copyright (c) 2000, 2003 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made 3 * available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at 4 * http://www.eclipse.org/legal/cpl-v10.html 5 * 6 * Contributors: IBM Corporation - initial API and implementation 7 **********************************************************************************************************************************/ 8 package net.sourceforge.phpdt.internal.compiler.problem; 9 10 import net.sourceforge.phpdt.core.compiler.CharOperation; 11 import net.sourceforge.phpdt.core.compiler.IProblem; 12 import net.sourceforge.phpdt.core.compiler.InvalidInputException; 13 import net.sourceforge.phpdt.internal.compiler.CompilationResult; 14 import net.sourceforge.phpdt.internal.compiler.IErrorHandlingPolicy; 15 import net.sourceforge.phpdt.internal.compiler.IProblemFactory; 16 import net.sourceforge.phpdt.internal.compiler.ast.ASTNode; 17 import net.sourceforge.phpdt.internal.compiler.ast.AbstractMethodDeclaration; 18 import net.sourceforge.phpdt.internal.compiler.ast.AbstractVariableDeclaration; 19 import net.sourceforge.phpdt.internal.compiler.ast.AllocationExpression; 20 import net.sourceforge.phpdt.internal.compiler.ast.Argument; 21 import net.sourceforge.phpdt.internal.compiler.ast.ArrayAllocationExpression; 22 import net.sourceforge.phpdt.internal.compiler.ast.ArrayReference; 23 import net.sourceforge.phpdt.internal.compiler.ast.Assignment; 24 import net.sourceforge.phpdt.internal.compiler.ast.BinaryExpression; 25 import net.sourceforge.phpdt.internal.compiler.ast.CaseStatement; 26 import net.sourceforge.phpdt.internal.compiler.ast.CastExpression; 27 import net.sourceforge.phpdt.internal.compiler.ast.CompilationUnitDeclaration; 28 import net.sourceforge.phpdt.internal.compiler.ast.CompoundAssignment; 29 import net.sourceforge.phpdt.internal.compiler.ast.ConstructorDeclaration; 30 import net.sourceforge.phpdt.internal.compiler.ast.DefaultCase; 31 import net.sourceforge.phpdt.internal.compiler.ast.EqualExpression; 32 import net.sourceforge.phpdt.internal.compiler.ast.ExplicitConstructorCall; 33 import net.sourceforge.phpdt.internal.compiler.ast.Expression; 34 import net.sourceforge.phpdt.internal.compiler.ast.FieldDeclaration; 35 import net.sourceforge.phpdt.internal.compiler.ast.FieldReference; 36 import net.sourceforge.phpdt.internal.compiler.ast.InstanceOfExpression; 37 import net.sourceforge.phpdt.internal.compiler.ast.IntLiteral; 38 import net.sourceforge.phpdt.internal.compiler.ast.Literal; 39 import net.sourceforge.phpdt.internal.compiler.ast.LocalDeclaration; 40 import net.sourceforge.phpdt.internal.compiler.ast.LongLiteral; 41 import net.sourceforge.phpdt.internal.compiler.ast.MessageSend; 42 import net.sourceforge.phpdt.internal.compiler.ast.MethodDeclaration; 43 import net.sourceforge.phpdt.internal.compiler.ast.NameReference; 44 import net.sourceforge.phpdt.internal.compiler.ast.NumberLiteral; 45 import net.sourceforge.phpdt.internal.compiler.ast.QualifiedNameReference; 46 import net.sourceforge.phpdt.internal.compiler.ast.Reference; 47 import net.sourceforge.phpdt.internal.compiler.ast.ReturnStatement; 48 import net.sourceforge.phpdt.internal.compiler.ast.SingleNameReference; 49 import net.sourceforge.phpdt.internal.compiler.ast.Statement; 50 import net.sourceforge.phpdt.internal.compiler.ast.ThisReference; 51 import net.sourceforge.phpdt.internal.compiler.ast.ThrowStatement; 52 import net.sourceforge.phpdt.internal.compiler.ast.TryStatement; 53 import net.sourceforge.phpdt.internal.compiler.ast.TypeDeclaration; 54 import net.sourceforge.phpdt.internal.compiler.ast.TypeReference; 55 import net.sourceforge.phpdt.internal.compiler.ast.UnaryExpression; 56 import net.sourceforge.phpdt.internal.compiler.env.IConstants; 57 import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions; 58 import net.sourceforge.phpdt.internal.compiler.impl.Constant; 59 import net.sourceforge.phpdt.internal.compiler.impl.ReferenceContext; 60 import net.sourceforge.phpdt.internal.compiler.lookup.Binding; 61 import net.sourceforge.phpdt.internal.compiler.lookup.CompilerModifiers; 62 import net.sourceforge.phpdt.internal.compiler.lookup.FieldBinding; 63 import net.sourceforge.phpdt.internal.compiler.lookup.LocalVariableBinding; 64 import net.sourceforge.phpdt.internal.compiler.lookup.MethodBinding; 65 import net.sourceforge.phpdt.internal.compiler.lookup.ProblemMethodBinding; 66 import net.sourceforge.phpdt.internal.compiler.lookup.ProblemReasons; 67 import net.sourceforge.phpdt.internal.compiler.lookup.ReferenceBinding; 68 import net.sourceforge.phpdt.internal.compiler.lookup.SourceTypeBinding; 69 import net.sourceforge.phpdt.internal.compiler.lookup.SyntheticArgumentBinding; 70 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding; 71 import net.sourceforge.phpdt.internal.compiler.lookup.TypeConstants; 72 import net.sourceforge.phpdt.internal.compiler.parser.Parser; 73 import net.sourceforge.phpdt.internal.compiler.parser.Scanner; 74 import net.sourceforge.phpdt.internal.compiler.util.Util; 75 76 public class ProblemReporter extends ProblemHandler implements ProblemReasons { 77 public ReferenceContext referenceContext; 78 ProblemReporter(IErrorHandlingPolicy policy, CompilerOptions options, IProblemFactory problemFactory)79 public ProblemReporter(IErrorHandlingPolicy policy, 80 CompilerOptions options, IProblemFactory problemFactory) { 81 82 // IProblemFactory problemFactory) { 83 super(policy, options, problemFactory); // ), problemFactory); 84 } 85 abortDueToInternalError(String errorMessage)86 public void abortDueToInternalError(String errorMessage) { 87 String[] arguments = new String[] { errorMessage }; 88 this.handle(IProblem.Unclassified, arguments, arguments, Error | Abort, 89 0, 0); 90 } 91 abortDueToInternalError(String errorMessage, ASTNode location)92 public void abortDueToInternalError(String errorMessage, ASTNode location) { 93 String[] arguments = new String[] { errorMessage }; 94 this.handle(IProblem.Unclassified, arguments, arguments, Error | Abort, 95 location.sourceStart, location.sourceEnd); 96 } 97 abstractMethodCannotBeOverridden(SourceTypeBinding type, MethodBinding concreteMethod)98 public void abstractMethodCannotBeOverridden(SourceTypeBinding type, 99 MethodBinding concreteMethod) { 100 this.handle( 101 // %1 must be abstract since it cannot override the inherited 102 // package-private abstract method %2 103 IProblem.AbstractMethodCannotBeOverridden, new String[] { 104 new String(type.sourceName()), 105 new String(CharOperation.concat( 106 concreteMethod.declaringClass.readableName(), 107 concreteMethod.readableName(), '.')) }, 108 new String[] { 109 new String(type.sourceName()), 110 new String(CharOperation.concat( 111 concreteMethod.declaringClass 112 .shortReadableName(), concreteMethod 113 .shortReadableName(), '.')) }, type 114 .sourceStart(), type.sourceEnd()); 115 } 116 abstractMethodInAbstractClass(SourceTypeBinding type, AbstractMethodDeclaration methodDecl)117 public void abstractMethodInAbstractClass(SourceTypeBinding type, 118 AbstractMethodDeclaration methodDecl) { 119 String[] arguments = new String[] { new String(type.sourceName()), 120 new String(methodDecl.selector) }; 121 this.handle(IProblem.AbstractMethodInAbstractClass, arguments, 122 arguments, methodDecl.sourceStart, methodDecl.sourceEnd); 123 } 124 abstractMethodMustBeImplemented(SourceTypeBinding type, MethodBinding abstractMethod)125 public void abstractMethodMustBeImplemented(SourceTypeBinding type, 126 MethodBinding abstractMethod) { 127 this.handle( 128 // Must implement the inherited abstract method %1 129 // 8.4.3 - Every non-abstract subclass of an abstract type, A, 130 // must provide a concrete implementation of all of A's 131 // methods. 132 IProblem.AbstractMethodMustBeImplemented, 133 new String[] { new String(CharOperation.concat( 134 abstractMethod.declaringClass.readableName(), 135 abstractMethod.readableName(), '.')) }, 136 new String[] { new String(CharOperation.concat( 137 abstractMethod.declaringClass.shortReadableName(), 138 abstractMethod.shortReadableName(), '.')) }, type 139 .sourceStart(), type.sourceEnd()); 140 } 141 abstractMethodNeedingNoBody(AbstractMethodDeclaration method)142 public void abstractMethodNeedingNoBody(AbstractMethodDeclaration method) { 143 this.handle(IProblem.BodyForAbstractMethod, NoArgument, NoArgument, 144 method.sourceStart, method.sourceEnd, method, method 145 .compilationResult()); 146 } 147 alreadyDefinedLabel(char[] labelName, ASTNode location)148 public void alreadyDefinedLabel(char[] labelName, ASTNode location) { 149 String[] arguments = new String[] { new String(labelName) }; 150 this.handle(IProblem.DuplicateLabel, arguments, arguments, 151 location.sourceStart, location.sourceEnd); 152 } 153 anonymousClassCannotExtendFinalClass(Expression expression, TypeBinding type)154 public void anonymousClassCannotExtendFinalClass(Expression expression, 155 TypeBinding type) { 156 this.handle(IProblem.AnonymousClassCannotExtendFinalClass, 157 new String[] { new String(type.readableName()) }, 158 new String[] { new String(type.shortReadableName()) }, 159 expression.sourceStart, expression.sourceEnd); 160 } 161 argumentTypeCannotBeVoid(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, Argument arg)162 public void argumentTypeCannotBeVoid(SourceTypeBinding type, 163 AbstractMethodDeclaration methodDecl, Argument arg) { 164 String[] arguments = new String[] { new String(methodDecl.selector), 165 new String(arg.name) }; 166 this.handle(IProblem.ArgumentTypeCannotBeVoid, arguments, arguments, 167 methodDecl.sourceStart, methodDecl.sourceEnd); 168 } 169 argumentTypeCannotBeVoidArray(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, Argument arg)170 public void argumentTypeCannotBeVoidArray(SourceTypeBinding type, 171 AbstractMethodDeclaration methodDecl, Argument arg) { 172 String[] arguments = new String[] { new String(methodDecl.selector), 173 new String(arg.name) }; 174 this.handle(IProblem.ArgumentTypeCannotBeVoidArray, arguments, 175 arguments, methodDecl.sourceStart, methodDecl.sourceEnd); 176 } 177 argumentTypeProblem(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, Argument arg, TypeBinding expectedType)178 public void argumentTypeProblem(SourceTypeBinding type, 179 AbstractMethodDeclaration methodDecl, Argument arg, 180 TypeBinding expectedType) { 181 int problemId = expectedType.problemId(); 182 int id; 183 switch (problemId) { 184 case NotFound: 185 // 1 186 id = IProblem.ArgumentTypeNotFound; 187 break; 188 case NotVisible: 189 // 2 190 id = IProblem.ArgumentTypeNotVisible; 191 break; 192 case Ambiguous: 193 // 3 194 id = IProblem.ArgumentTypeAmbiguous; 195 break; 196 case InternalNameProvided: 197 // 4 198 id = IProblem.ArgumentTypeInternalNameProvided; 199 break; 200 case InheritedNameHidesEnclosingName: 201 // 5 202 id = IProblem.ArgumentTypeInheritedNameHidesEnclosingName; 203 break; 204 case NoError: 205 // 0 206 default: 207 needImplementation(); // want to fail to see why we were 208 // here... 209 return; 210 } 211 this.handle(id, new String[] { new String(methodDecl.selector), 212 arg.name(), new String(expectedType.readableName()) }, 213 new String[] { new String(methodDecl.selector), arg.name(), 214 new String(expectedType.shortReadableName()) }, 215 arg.type.sourceStart, arg.type.sourceEnd); 216 } 217 arrayConstantsOnlyInArrayInitializers(int sourceStart, int sourceEnd)218 public void arrayConstantsOnlyInArrayInitializers(int sourceStart, 219 int sourceEnd) { 220 this.handle(IProblem.ArrayConstantsOnlyInArrayInitializers, NoArgument, 221 NoArgument, sourceStart, sourceEnd); 222 } 223 assignmentHasNoEffect(Assignment assignment, char[] name)224 public void assignmentHasNoEffect(Assignment assignment, char[] name) { 225 String[] arguments = new String[] { new String(name) }; 226 this.handle(IProblem.AssignmentHasNoEffect, arguments, arguments, 227 assignment.sourceStart, assignment.sourceEnd); 228 } 229 attemptToReturnNonVoidExpression( ReturnStatement returnStatement, TypeBinding expectedType)230 public void attemptToReturnNonVoidExpression( 231 ReturnStatement returnStatement, TypeBinding expectedType) { 232 this.handle(IProblem.VoidMethodReturnsValue, new String[] { new String( 233 expectedType.readableName()) }, new String[] { new String( 234 expectedType.shortReadableName()) }, 235 returnStatement.sourceStart, returnStatement.sourceEnd); 236 } 237 attemptToReturnVoidValue(ReturnStatement returnStatement)238 public void attemptToReturnVoidValue(ReturnStatement returnStatement) { 239 this.handle(IProblem.MethodReturnsVoid, NoArgument, NoArgument, 240 returnStatement.sourceStart, returnStatement.sourceEnd); 241 } 242 243 // public void bytecodeExceeds64KLimit(AbstractMethodDeclaration location) 244 // { 245 // String[] arguments = new String[] {new String(location.selector), 246 // parametersAsString(location.binding)}; 247 // if (location.isConstructor()) { 248 // this.handle( 249 // IProblem.BytecodeExceeds64KLimitForConstructor, 250 // arguments, 251 // arguments, 252 // Error | Abort, 253 // location.sourceStart, 254 // location.sourceEnd); 255 // } else { 256 // this.handle( 257 // IProblem.BytecodeExceeds64KLimit, 258 // arguments, 259 // arguments, 260 // Error | Abort, 261 // location.sourceStart, 262 // location.sourceEnd); 263 // } 264 // } bytecodeExceeds64KLimit(TypeDeclaration location)265 public void bytecodeExceeds64KLimit(TypeDeclaration location) { 266 this.handle(IProblem.BytecodeExceeds64KLimitForClinit, NoArgument, 267 NoArgument, Error | Abort, location.sourceStart, 268 location.sourceEnd); 269 } 270 cannotAllocateVoidArray(Expression expression)271 public void cannotAllocateVoidArray(Expression expression) { 272 this.handle(IProblem.CannotAllocateVoidArray, NoArgument, NoArgument, 273 expression.sourceStart, expression.sourceEnd); 274 } 275 cannotAssignToFinalField(FieldBinding field, ASTNode location)276 public void cannotAssignToFinalField(FieldBinding field, ASTNode location) { 277 this 278 .handle( 279 IProblem.FinalFieldAssignment, 280 new String[] { 281 (field.declaringClass == null ? "array" : new String(field.declaringClass.readableName())), //$NON-NLS-1$ 282 new String(field.readableName()) }, 283 new String[] { 284 (field.declaringClass == null ? "array" : new String(field.declaringClass.shortReadableName())), //$NON-NLS-1$ 285 new String(field.shortReadableName()) }, 286 location.sourceStart, location.sourceEnd); 287 } 288 cannotAssignToFinalLocal(LocalVariableBinding local, ASTNode location)289 public void cannotAssignToFinalLocal(LocalVariableBinding local, 290 ASTNode location) { 291 String[] arguments = new String[] { new String(local.readableName()) }; 292 this.handle(IProblem.NonBlankFinalLocalAssignment, arguments, 293 arguments, location.sourceStart, location.sourceEnd); 294 } 295 cannotAssignToFinalOuterLocal(LocalVariableBinding local, ASTNode location)296 public void cannotAssignToFinalOuterLocal(LocalVariableBinding local, 297 ASTNode location) { 298 String[] arguments = new String[] { new String(local.readableName()) }; 299 this.handle(IProblem.FinalOuterLocalAssignment, arguments, arguments, 300 location.sourceStart, location.sourceEnd); 301 } 302 cannotDeclareLocalInterface(char[] interfaceName, int sourceStart, int sourceEnd)303 public void cannotDeclareLocalInterface(char[] interfaceName, 304 int sourceStart, int sourceEnd) { 305 String[] arguments = new String[] { new String(interfaceName) }; 306 this.handle(IProblem.CannotDefineInterfaceInLocalType, arguments, 307 arguments, sourceStart, sourceEnd); 308 } 309 cannotDefineDimensionsAndInitializer( ArrayAllocationExpression expresssion)310 public void cannotDefineDimensionsAndInitializer( 311 ArrayAllocationExpression expresssion) { 312 this.handle(IProblem.CannotDefineDimensionExpressionsWithInit, 313 NoArgument, NoArgument, expresssion.sourceStart, 314 expresssion.sourceEnd); 315 } 316 cannotDireclyInvokeAbstractMethod(MessageSend messageSend, MethodBinding method)317 public void cannotDireclyInvokeAbstractMethod(MessageSend messageSend, 318 MethodBinding method) { 319 this.handle(IProblem.DirectInvocationOfAbstractMethod, new String[] { 320 new String(method.declaringClass.readableName()), 321 new String(method.selector), parametersAsString(method) }, 322 new String[] { 323 new String(method.declaringClass.shortReadableName()), 324 new String(method.selector), 325 parametersAsShortString(method) }, 326 messageSend.sourceStart, messageSend.sourceEnd); 327 } 328 329 // public void cannotImportPackage(ImportReference importRef) { 330 // String[] arguments = new 331 // String[]{CharOperation.toString(importRef.tokens)}; 332 // this.handle(IProblem.CannotImportPackage, arguments, arguments, 333 // importRef.sourceStart, importRef.sourceEnd); 334 // } cannotInstantiate(TypeReference typeRef, TypeBinding type)335 public void cannotInstantiate(TypeReference typeRef, TypeBinding type) { 336 this.handle(IProblem.InvalidClassInstantiation, 337 new String[] { new String(type.readableName()) }, 338 new String[] { new String(type.shortReadableName()) }, 339 typeRef.sourceStart, typeRef.sourceEnd); 340 } 341 cannotReferToNonFinalOuterLocal(LocalVariableBinding local, ASTNode location)342 public void cannotReferToNonFinalOuterLocal(LocalVariableBinding local, 343 ASTNode location) { 344 String[] arguments = new String[] { new String(local.readableName()) }; 345 this.handle(IProblem.OuterLocalMustBeFinal, arguments, arguments, 346 location.sourceStart, location.sourceEnd); 347 } 348 cannotReturnInInitializer(ASTNode location)349 public void cannotReturnInInitializer(ASTNode location) { 350 this.handle(IProblem.CannotReturnInInitializer, NoArgument, NoArgument, 351 location.sourceStart, location.sourceEnd); 352 } 353 cannotThrowNull(ThrowStatement statement)354 public void cannotThrowNull(ThrowStatement statement) { 355 this.handle(IProblem.CannotThrowNull, NoArgument, NoArgument, 356 statement.sourceStart, statement.sourceEnd); 357 } 358 cannotThrowType(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, TypeReference exceptionType, TypeBinding expectedType)359 public void cannotThrowType(SourceTypeBinding type, 360 AbstractMethodDeclaration methodDecl, TypeReference exceptionType, 361 TypeBinding expectedType) { 362 this.handle(IProblem.CannotThrowType, new String[] { new String( 363 expectedType.readableName()) }, new String[] { new String( 364 expectedType.shortReadableName()) }, exceptionType.sourceStart, 365 exceptionType.sourceEnd); 366 } 367 cannotUseSuperInJavaLangObject(ASTNode reference)368 public void cannotUseSuperInJavaLangObject(ASTNode reference) { 369 this.handle(IProblem.ObjectHasNoSuperclass, NoArgument, NoArgument, 370 reference.sourceStart, reference.sourceEnd); 371 } 372 cannotUseSuperInCodeSnippet(int start, int end)373 public void cannotUseSuperInCodeSnippet(int start, int end) { 374 this.handle(IProblem.CannotUseSuperInCodeSnippet, NoArgument, 375 NoArgument, Error | Abort, start, end); 376 } 377 caseExpressionMustBeConstant(Expression expression)378 public void caseExpressionMustBeConstant(Expression expression) { 379 this.handle(IProblem.NonConstantExpression, NoArgument, NoArgument, 380 expression.sourceStart, expression.sourceEnd); 381 } 382 classExtendFinalClass(SourceTypeBinding type, TypeReference superclass, TypeBinding expectedType)383 public void classExtendFinalClass(SourceTypeBinding type, 384 TypeReference superclass, TypeBinding expectedType) { 385 String name = new String(type.sourceName()); 386 String expectedFullName = new String(expectedType.readableName()); 387 String expectedShortName = new String(expectedType.shortReadableName()); 388 if (expectedShortName.equals(name)) 389 expectedShortName = expectedFullName; 390 this.handle(IProblem.ClassExtendFinalClass, new String[] { 391 expectedFullName, name }, new String[] { expectedShortName, 392 name }, superclass.sourceStart, superclass.sourceEnd); 393 } 394 codeSnippetMissingClass(String missing, int start, int end)395 public void codeSnippetMissingClass(String missing, int start, int end) { 396 String[] arguments = new String[] { missing }; 397 this.handle(IProblem.CodeSnippetMissingClass, arguments, arguments, 398 Error | Abort, start, end); 399 } 400 codeSnippetMissingMethod(String className, String missingMethod, String argumentTypes, int start, int end)401 public void codeSnippetMissingMethod(String className, 402 String missingMethod, String argumentTypes, int start, int end) { 403 String[] arguments = new String[] { className, missingMethod, 404 argumentTypes }; 405 this.handle(IProblem.CodeSnippetMissingMethod, arguments, arguments, 406 Error | Abort, start, end); 407 } 408 409 /* 410 * Given the current configuration, answers which category the problem falls 411 * into: Error | Warning | Ignore 412 */ computeSeverity(int problemId)413 public int computeSeverity(int problemId) { 414 415 // severity can have been preset on the problem 416 // if ((problem.severity & Fatal) != 0){ 417 // return Error; 418 // } 419 420 // if not then check whether it is a configurable problem 421 switch (problemId) { 422 case IProblem.PHPIncludeNotExistWarning: 423 return this.options 424 .getSeverity(CompilerOptions.PHPIncludeNotExistWarning); 425 case IProblem.PHPVarDeprecatedWarning: 426 return this.options 427 .getSeverity(CompilerOptions.PHPVarDeprecatedWarning); 428 case IProblem.PHPBadStyleKeywordWarning: 429 return this.options 430 .getSeverity(CompilerOptions.PHPBadStyleKeywordWarning); 431 case IProblem.PHPBadStyleUppercaseIdentifierWarning: 432 return this.options 433 .getSeverity(CompilerOptions.PHPBadStyleUppercaseIdentifierWarning); 434 435 case IProblem.UninitializedLocalVariable: 436 return this.options 437 .getSeverity(CompilerOptions.UninitializedLocalVariableWarning); 438 case IProblem.CodeCannotBeReached: 439 return this.options 440 .getSeverity(CompilerOptions.CodeCannotBeReachedWarning); 441 442 case IProblem.MaskedCatch: 443 return this.options.getSeverity(CompilerOptions.MaskedCatchBlock); 444 445 case IProblem.UnusedImport: 446 return this.options.getSeverity(CompilerOptions.UnusedImport); 447 448 case IProblem.MethodButWithConstructorName: 449 return this.options 450 .getSeverity(CompilerOptions.MethodWithConstructorName); 451 452 case IProblem.OverridingNonVisibleMethod: 453 return this.options 454 .getSeverity(CompilerOptions.OverriddenPackageDefaultMethod); 455 456 case IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod: 457 case IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod: 458 return this.options 459 .getSeverity(CompilerOptions.IncompatibleNonInheritedInterfaceMethod); 460 461 case IProblem.OverridingDeprecatedMethod: 462 case IProblem.UsingDeprecatedType: 463 case IProblem.UsingDeprecatedMethod: 464 case IProblem.UsingDeprecatedConstructor: 465 case IProblem.UsingDeprecatedField: 466 return this.options.getSeverity(CompilerOptions.UsingDeprecatedAPI); 467 468 case IProblem.LocalVariableIsNeverUsed: 469 return this.options 470 .getSeverity(CompilerOptions.UnusedLocalVariable); 471 472 case IProblem.ArgumentIsNeverUsed: 473 return this.options.getSeverity(CompilerOptions.UnusedArgument); 474 475 case IProblem.NoImplicitStringConversionForCharArrayExpression: 476 return this.options 477 .getSeverity(CompilerOptions.NoImplicitStringConversion); 478 479 case IProblem.NeedToEmulateFieldReadAccess: 480 case IProblem.NeedToEmulateFieldWriteAccess: 481 case IProblem.NeedToEmulateMethodAccess: 482 case IProblem.NeedToEmulateConstructorAccess: 483 return this.options.getSeverity(CompilerOptions.AccessEmulation); 484 485 case IProblem.NonExternalizedStringLiteral: 486 return this.options 487 .getSeverity(CompilerOptions.NonExternalizedString); 488 489 case IProblem.UseAssertAsAnIdentifier: 490 return this.options 491 .getSeverity(CompilerOptions.AssertUsedAsAnIdentifier); 492 493 case IProblem.NonStaticAccessToStaticMethod: 494 case IProblem.NonStaticAccessToStaticField: 495 return this.options 496 .getSeverity(CompilerOptions.NonStaticAccessToStatic); 497 498 // case IProblem.IndirectAccessToStaticMethod : 499 // case IProblem.IndirectAccessToStaticField : 500 // case IProblem.IndirectAccessToStaticType : 501 // return 502 // this.options.getSeverity(CompilerOptions.IndirectStaticAccess); 503 504 case IProblem.AssignmentHasNoEffect: 505 return this.options.getSeverity(CompilerOptions.NoEffectAssignment); 506 507 case IProblem.UnusedPrivateConstructor: 508 case IProblem.UnusedPrivateMethod: 509 case IProblem.UnusedPrivateField: 510 case IProblem.UnusedPrivateType: 511 return this.options 512 .getSeverity(CompilerOptions.UnusedPrivateMember); 513 514 case IProblem.Task: 515 return Warning; 516 517 // case IProblem.LocalVariableHidingLocalVariable: 518 // case IProblem.LocalVariableHidingField: 519 // case IProblem.ArgumentHidingLocalVariable: 520 // case IProblem.ArgumentHidingField: 521 // return 522 // this.options.getSeverity(CompilerOptions.LocalVariableHiding); 523 524 // case IProblem.FieldHidingLocalVariable: 525 // case IProblem.FieldHidingField: 526 // return this.options.getSeverity(CompilerOptions.FieldHiding); 527 528 // case IProblem.PossibleAccidentalBooleanAssignment: 529 // return 530 // this.options.getSeverity(CompilerOptions.AccidentalBooleanAssign); 531 532 // case IProblem.SuperfluousSemicolon: 533 // return 534 // this.options.getSeverity(CompilerOptions.SuperfluousSemicolon); 535 // 536 // case IProblem.UndocumentedEmptyBlock: 537 // return 538 // this.options.getSeverity(CompilerOptions.UndocumentedEmptyBlock); 539 // 540 // case IProblem.UnnecessaryCast: 541 // case IProblem.UnnecessaryArgumentCast: 542 // case IProblem.UnnecessaryInstanceof: 543 // return 544 // this.options.getSeverity(CompilerOptions.UnnecessaryTypeCheck); 545 // 546 // case IProblem.FinallyMustCompleteNormally: 547 // return 548 // this.options.getSeverity(CompilerOptions.FinallyBlockNotCompleting); 549 // 550 // case IProblem.UnusedMethodDeclaredThrownException: 551 // case IProblem.UnusedConstructorDeclaredThrownException: 552 // return 553 // this.options.getSeverity(CompilerOptions.UnusedDeclaredThrownException); 554 // 555 // case IProblem.UnqualifiedFieldAccess: 556 // return 557 // this.options.getSeverity(CompilerOptions.UnqualifiedFieldAccess); 558 559 /* 560 * Javadoc syntax errors 561 */ 562 // Javadoc explicit IDs 563 // case IProblem.JavadocUnexpectedTag: 564 // case IProblem.JavadocDuplicateReturnTag: 565 // case IProblem.JavadocInvalidThrowsClass: 566 // case IProblem.JavadocInvalidSeeReference: 567 // case IProblem.JavadocInvalidSeeHref: 568 // case IProblem.JavadocInvalidSeeArgs: 569 // case IProblem.JavadocInvalidTag: 570 // return this.options.getSeverity(CompilerOptions.InvalidJavadoc); 571 /* 572 * Javadoc tags resolved references errors 573 */ 574 // case IProblem.JavadocInvalidParamName: 575 // case IProblem.JavadocDuplicateParamName: 576 // case IProblem.JavadocMissingParamName: 577 // case IProblem.JavadocInvalidThrowsClassName: 578 // case IProblem.JavadocDuplicateThrowsClassName: 579 // case IProblem.JavadocMissingThrowsClassName: 580 // case IProblem.JavadocMissingSeeReference: 581 // case IProblem.JavadocUsingDeprecatedField: 582 // case IProblem.JavadocUsingDeprecatedConstructor: 583 // case IProblem.JavadocUsingDeprecatedMethod: 584 // case IProblem.JavadocUsingDeprecatedType: 585 // case IProblem.JavadocUndefinedField: 586 // case IProblem.JavadocNotVisibleField: 587 // case IProblem.JavadocAmbiguousField: 588 // case IProblem.JavadocUndefinedConstructor: 589 // case IProblem.JavadocNotVisibleConstructor: 590 // case IProblem.JavadocAmbiguousConstructor: 591 // case IProblem.JavadocUndefinedMethod: 592 // case IProblem.JavadocNotVisibleMethod: 593 // case IProblem.JavadocAmbiguousMethod: 594 // case IProblem.JavadocParameterMismatch: 595 // case IProblem.JavadocUndefinedType: 596 // case IProblem.JavadocNotVisibleType: 597 // case IProblem.JavadocAmbiguousType: 598 // case IProblem.JavadocInternalTypeNameProvided: 599 // case IProblem.JavadocNoMessageSendOnArrayType: 600 // case IProblem.JavadocNoMessageSendOnBaseType: 601 // if (!this.options.reportInvalidJavadocTags) 602 // return ProblemSeverities.Ignore; 603 // else 604 // return this.options.getSeverity(CompilerOptions.InvalidJavadoc); 605 /* 606 * Javadoc missing tags errors 607 */ 608 // case IProblem.JavadocMissingParamTag: 609 // case IProblem.JavadocMissingReturnTag: 610 // case IProblem.JavadocMissingThrowsTag: 611 // return 612 // this.options.getSeverity(CompilerOptions.MissingJavadocTags); 613 /* 614 * Missing Javadoc errors 615 */ 616 // case IProblem.JavadocMissing: 617 // return 618 // this.options.getSeverity(CompilerOptions.MissingJavadocComments); 619 // by default problems are errors. 620 default: 621 return Error; 622 } 623 } 624 625 // public void conditionalArgumentsIncompatibleTypes(ConditionalExpression 626 // expression, TypeBinding trueType, TypeBinding falseType) { 627 // this.handle( 628 // IProblem.IncompatibleTypesInConditionalOperator, 629 // new String[] {new String(trueType.readableName()), new 630 // String(falseType.readableName())}, 631 // new String[] {new String(trueType.sourceName()), new 632 // String(falseType.sourceName())}, 633 // expression.sourceStart, 634 // expression.sourceEnd); 635 // } 636 // public void conflictingImport(ImportReference importRef) { 637 // String[] arguments = new 638 // String[]{CharOperation.toString(importRef.tokens)}; 639 // this.handle(IProblem.ConflictingImport, arguments, arguments, 640 // importRef.sourceStart, importRef.sourceEnd); 641 // } constantOutOfFormat(NumberLiteral lit)642 public void constantOutOfFormat(NumberLiteral lit) { 643 // the literal is not in a correct format 644 // this code is called on IntLiteral and LongLiteral 645 // example 000811 ...the 8 is uncorrect. 646 if ((lit instanceof LongLiteral) || (lit instanceof IntLiteral)) { 647 char[] source = lit.source(); 648 try { 649 final String Radix; 650 final int radix; 651 if ((source[1] == 'x') || (source[1] == 'X')) { 652 radix = 16; 653 Radix = "Hexa"; //$NON-NLS-1$ 654 } else { 655 radix = 8; 656 Radix = "Octal"; //$NON-NLS-1$ 657 } 658 // look for the first digit that is incorrect 659 int place = -1; 660 label: for (int i = radix == 8 ? 1 : 2; i < source.length; i++) { 661 if (Character.digit(source[i], radix) == -1) { 662 place = i; 663 break label; 664 } 665 } 666 String[] arguments = new String[] { Radix 667 + " " 668 + new String(source) 669 + " (digit " + new String(new char[] { source[place] }) + ")" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 670 this.handle(IProblem.NumericValueOutOfRange, arguments, 671 arguments, lit.sourceStart, lit.sourceEnd); 672 return; 673 } catch (IndexOutOfBoundsException ex) { 674 } 675 // just in case .... use a predefined error.. 676 // we should never come here...(except if the code changes !) 677 this.constantOutOfRange(lit); 678 } 679 } 680 constantOutOfRange(Literal lit)681 public void constantOutOfRange(Literal lit) { 682 // lit is some how out of range of it declared type 683 // example 684 // 9999999999999999999999999999999999999999999999999999999999999999999 685 String[] arguments = new String[] { new String(lit.source()) }; 686 this.handle(IProblem.NumericValueOutOfRange, arguments, arguments, 687 lit.sourceStart, lit.sourceEnd); 688 } 689 deprecatedField(FieldBinding field, ASTNode location)690 public void deprecatedField(FieldBinding field, ASTNode location) { 691 this.handle(IProblem.UsingDeprecatedField, new String[] { 692 new String(field.declaringClass.readableName()), 693 new String(field.name) }, new String[] { 694 new String(field.declaringClass.shortReadableName()), 695 new String(field.name) }, location.sourceStart, 696 location.sourceEnd); 697 } 698 deprecatedMethod(MethodBinding method, ASTNode location)699 public void deprecatedMethod(MethodBinding method, ASTNode location) { 700 if (method.isConstructor()) 701 this.handle(IProblem.UsingDeprecatedConstructor, new String[] { 702 new String(method.declaringClass.readableName()), 703 parametersAsString(method) }, new String[] { 704 new String(method.declaringClass.shortReadableName()), 705 parametersAsShortString(method) }, location.sourceStart, 706 location.sourceEnd); 707 else 708 this.handle(IProblem.UsingDeprecatedMethod, new String[] { 709 new String(method.declaringClass.readableName()), 710 new String(method.selector), parametersAsString(method) }, 711 new String[] { 712 new String(method.declaringClass 713 .shortReadableName()), 714 new String(method.selector), 715 parametersAsShortString(method) }, 716 location.sourceStart, location.sourceEnd); 717 } 718 deprecatedType(TypeBinding type, ASTNode location)719 public void deprecatedType(TypeBinding type, ASTNode location) { 720 if (location == null) 721 return; // 1G828DN - no type ref for synthetic arguments 722 this.handle(IProblem.UsingDeprecatedType, new String[] { new String( 723 type.readableName()) }, new String[] { new String(type 724 .shortReadableName()) }, location.sourceStart, 725 location.sourceEnd); 726 } 727 duplicateCase(CaseStatement statement, Constant constant)728 public void duplicateCase(CaseStatement statement, Constant constant) { 729 String[] arguments = new String[] { String.valueOf(constant.intValue()) }; 730 this.handle(IProblem.DuplicateCase, arguments, arguments, 731 statement.sourceStart, statement.sourceEnd); 732 } 733 duplicateDefaultCase(DefaultCase statement)734 public void duplicateDefaultCase(DefaultCase statement) { 735 this.handle(IProblem.DuplicateDefaultCase, NoArgument, NoArgument, 736 statement.sourceStart, statement.sourceEnd); 737 } 738 duplicateFieldInType(SourceTypeBinding type, FieldDeclaration fieldDecl)739 public void duplicateFieldInType(SourceTypeBinding type, 740 FieldDeclaration fieldDecl) { 741 this.handle(IProblem.DuplicateField, new String[] { 742 new String(type.sourceName()), fieldDecl.name() }, 743 new String[] { new String(type.shortReadableName()), 744 fieldDecl.name() }, fieldDecl.sourceStart, 745 fieldDecl.sourceEnd); 746 } 747 748 // public void duplicateImport(ImportReference importRef) { 749 // String[] arguments = new 750 // String[]{CharOperation.toString(importRef.tokens)}; 751 // this.handle(IProblem.DuplicateImport, arguments, arguments, 752 // importRef.sourceStart, importRef.sourceEnd); 753 // } duplicateInitializationOfBlankFinalField(FieldBinding field, Reference reference)754 public void duplicateInitializationOfBlankFinalField(FieldBinding field, 755 Reference reference) { 756 String[] arguments = new String[] { new String(field.readableName()) }; 757 this.handle(IProblem.DuplicateBlankFinalFieldInitialization, arguments, 758 arguments, reference.sourceStart, reference.sourceEnd); 759 } 760 duplicateInitializationOfFinalLocal(LocalVariableBinding local, ASTNode location)761 public void duplicateInitializationOfFinalLocal(LocalVariableBinding local, 762 ASTNode location) { 763 String[] arguments = new String[] { new String(local.readableName()) }; 764 this.handle(IProblem.DuplicateFinalLocalInitialization, arguments, 765 arguments, location.sourceStart, location.sourceEnd); 766 } 767 duplicateMethodInType(SourceTypeBinding type, AbstractMethodDeclaration methodDecl)768 public void duplicateMethodInType(SourceTypeBinding type, 769 AbstractMethodDeclaration methodDecl) { 770 String[] arguments = new String[] { new String(methodDecl.selector), 771 new String(type.sourceName()) }; 772 this.handle(IProblem.DuplicateMethod, arguments, arguments, 773 methodDecl.sourceStart, methodDecl.sourceEnd); 774 } 775 duplicateModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl)776 public void duplicateModifierForField(ReferenceBinding type, 777 FieldDeclaration fieldDecl) { 778 /* 779 * to highlight modifiers use: this.handle( new Problem( 780 * DuplicateModifierForField, new String[] {fieldDecl.name()}, 781 * fieldDecl.modifiers.sourceStart, fieldDecl.modifiers.sourceEnd)); 782 */ 783 String[] arguments = new String[] { fieldDecl.name() }; 784 this.handle(IProblem.DuplicateModifierForField, arguments, arguments, 785 fieldDecl.sourceStart, fieldDecl.sourceEnd); 786 } 787 duplicateModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl)788 public void duplicateModifierForMethod(ReferenceBinding type, 789 AbstractMethodDeclaration methodDecl) { 790 this.handle(IProblem.DuplicateModifierForMethod, 791 new String[] { new String(type.sourceName()), 792 new String(methodDecl.selector) }, new String[] { 793 new String(type.shortReadableName()), 794 new String(methodDecl.selector) }, 795 methodDecl.sourceStart, methodDecl.sourceEnd); 796 } 797 duplicateModifierForType(SourceTypeBinding type)798 public void duplicateModifierForType(SourceTypeBinding type) { 799 String[] arguments = new String[] { new String(type.sourceName()) }; 800 this.handle(IProblem.DuplicateModifierForType, arguments, arguments, 801 type.sourceStart(), type.sourceEnd()); 802 } 803 duplicateModifierForVariable(LocalDeclaration localDecl, boolean complainForArgument)804 public void duplicateModifierForVariable(LocalDeclaration localDecl, 805 boolean complainForArgument) { 806 String[] arguments = new String[] { localDecl.name() }; 807 this.handle(complainForArgument ? IProblem.DuplicateModifierForArgument 808 : IProblem.DuplicateModifierForVariable, arguments, arguments, 809 localDecl.sourceStart, localDecl.sourceEnd); 810 } 811 duplicateNestedType(TypeDeclaration typeDecl)812 public void duplicateNestedType(TypeDeclaration typeDecl) { 813 String[] arguments = new String[] { new String(typeDecl.name) }; 814 this.handle(IProblem.DuplicateNestedType, arguments, arguments, 815 typeDecl.sourceStart, typeDecl.sourceEnd); 816 } 817 duplicateSuperinterface(SourceTypeBinding type, TypeDeclaration typeDecl, ReferenceBinding superType)818 public void duplicateSuperinterface(SourceTypeBinding type, 819 TypeDeclaration typeDecl, ReferenceBinding superType) { 820 this.handle(IProblem.DuplicateSuperInterface, new String[] { 821 new String(superType.readableName()), 822 new String(type.sourceName()) }, new String[] { 823 new String(superType.shortReadableName()), 824 new String(type.sourceName()) }, typeDecl.sourceStart, 825 typeDecl.sourceEnd); 826 } 827 duplicateTypes(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl)828 public void duplicateTypes(CompilationUnitDeclaration compUnitDecl, 829 TypeDeclaration typeDecl) { 830 String[] arguments = new String[] { 831 new String(compUnitDecl.getFileName()), 832 new String(typeDecl.name) }; 833 this.referenceContext = typeDecl; // report the problem against the 834 // type not the entire compilation 835 // unit 836 this.handle(IProblem.DuplicateTypes, arguments, arguments, 837 typeDecl.sourceStart, typeDecl.sourceEnd, 838 compUnitDecl.compilationResult); 839 } 840 errorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params)841 public void errorNoMethodFor(MessageSend messageSend, TypeBinding recType, 842 TypeBinding[] params) { 843 StringBuffer buffer = new StringBuffer(); 844 StringBuffer shortBuffer = new StringBuffer(); 845 for (int i = 0, length = params.length; i < length; i++) { 846 if (i != 0) { 847 buffer.append(", "); //$NON-NLS-1$ 848 shortBuffer.append(", "); //$NON-NLS-1$ 849 } 850 buffer.append(new String(params[i].readableName())); 851 shortBuffer.append(new String(params[i].shortReadableName())); 852 } 853 this.handle(recType.isArrayType() ? IProblem.NoMessageSendOnArrayType 854 : IProblem.NoMessageSendOnBaseType, new String[] { 855 new String(recType.readableName()), 856 new String(messageSend.selector), buffer.toString() }, 857 new String[] { new String(recType.shortReadableName()), 858 new String(messageSend.selector), 859 shortBuffer.toString() }, messageSend.sourceStart, 860 messageSend.sourceEnd); 861 } 862 errorThisSuperInStatic(ASTNode reference)863 public void errorThisSuperInStatic(ASTNode reference) { 864 String[] arguments = new String[] { reference.isSuper() ? "super" : "this" }; //$NON-NLS-2$ //$NON-NLS-1$ 865 this.handle(IProblem.ThisInStaticContext, arguments, arguments, 866 reference.sourceStart, reference.sourceEnd); 867 } 868 exceptionTypeProblem(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, TypeReference exceptionType, TypeBinding expectedType)869 public void exceptionTypeProblem(SourceTypeBinding type, 870 AbstractMethodDeclaration methodDecl, TypeReference exceptionType, 871 TypeBinding expectedType) { 872 int problemId = expectedType.problemId(); 873 int id; 874 switch (problemId) { 875 case NotFound: 876 // 1 877 id = IProblem.ExceptionTypeNotFound; 878 break; 879 case NotVisible: 880 // 2 881 id = IProblem.ExceptionTypeNotVisible; 882 break; 883 case Ambiguous: 884 // 3 885 id = IProblem.ExceptionTypeAmbiguous; 886 break; 887 case InternalNameProvided: 888 // 4 889 id = IProblem.ExceptionTypeInternalNameProvided; 890 break; 891 case InheritedNameHidesEnclosingName: 892 // 5 893 id = IProblem.ExceptionTypeInheritedNameHidesEnclosingName; 894 break; 895 case NoError: 896 // 0 897 default: 898 needImplementation(); // want to fail to see why we were 899 // here... 900 return; 901 } 902 this.handle(id, new String[] { new String(methodDecl.selector), 903 new String(expectedType.readableName()) }, new String[] { 904 new String(methodDecl.selector), 905 new String(expectedType.shortReadableName()) }, 906 exceptionType.sourceStart, exceptionType.sourceEnd); 907 } 908 expressionShouldBeAVariable(Expression expression)909 public void expressionShouldBeAVariable(Expression expression) { 910 this.handle(IProblem.ExpressionShouldBeAVariable, NoArgument, 911 NoArgument, expression.sourceStart, expression.sourceEnd); 912 } 913 fieldsOrThisBeforeConstructorInvocation(ThisReference reference)914 public void fieldsOrThisBeforeConstructorInvocation(ThisReference reference) { 915 this.handle(IProblem.ThisSuperDuringConstructorInvocation, NoArgument, 916 NoArgument, reference.sourceStart, reference.sourceEnd); 917 } 918 fieldTypeProblem(SourceTypeBinding type, FieldDeclaration fieldDecl, TypeBinding expectedType)919 public void fieldTypeProblem(SourceTypeBinding type, 920 FieldDeclaration fieldDecl, TypeBinding expectedType) { 921 int problemId = expectedType.problemId(); 922 int id; 923 switch (problemId) { 924 case NotFound: 925 // 1 926 id = IProblem.FieldTypeNotFound; 927 break; 928 case NotVisible: 929 // 2 930 id = IProblem.FieldTypeNotVisible; 931 break; 932 case Ambiguous: 933 // 3 934 id = IProblem.FieldTypeAmbiguous; 935 break; 936 case InternalNameProvided: 937 // 4 938 id = IProblem.FieldTypeInternalNameProvided; 939 break; 940 case InheritedNameHidesEnclosingName: 941 // 5 942 id = IProblem.FieldTypeInheritedNameHidesEnclosingName; 943 break; 944 case NoError: 945 // 0 946 default: 947 needImplementation(); // want to fail to see why we were 948 // here... 949 return; 950 } 951 this.handle(id, new String[] { fieldDecl.name(), 952 new String(type.sourceName()), 953 new String(expectedType.readableName()) }, new String[] { 954 fieldDecl.name(), new String(type.sourceName()), 955 new String(expectedType.shortReadableName()) }, 956 fieldDecl.type.sourceStart, fieldDecl.type.sourceEnd); 957 } 958 finalMethodCannotBeOverridden(MethodBinding currentMethod, MethodBinding inheritedMethod)959 public void finalMethodCannotBeOverridden(MethodBinding currentMethod, 960 MethodBinding inheritedMethod) { 961 this.handle( 962 // Cannot override the final method from %1 963 // 8.4.3.3 - Final methods cannot be overridden or hidden. 964 IProblem.FinalMethodCannotBeOverridden, 965 new String[] { new String(inheritedMethod.declaringClass 966 .readableName()) }, new String[] { new String( 967 inheritedMethod.declaringClass.shortReadableName()) }, 968 currentMethod.sourceStart(), currentMethod.sourceEnd()); 969 } 970 forwardReference(Reference reference, int indexInQualification, TypeBinding type)971 public void forwardReference(Reference reference, int indexInQualification, 972 TypeBinding type) { 973 this.handle(IProblem.ReferenceToForwardField, NoArgument, NoArgument, 974 reference.sourceStart, reference.sourceEnd); 975 } 976 977 // use this private API when the compilation unit result can be found 978 // through the 979 // reference context. Otherwise, use the other API taking a problem and a 980 // compilation result 981 // as arguments handle(int problemId, String[] problemArguments, String[] messageArguments, int problemStartPosition, int problemEndPosition)982 private void handle(int problemId, String[] problemArguments, 983 String[] messageArguments, int problemStartPosition, 984 int problemEndPosition) { 985 this.handle(problemId, problemArguments, messageArguments, 986 problemStartPosition, problemEndPosition, referenceContext, 987 referenceContext == null ? null : referenceContext 988 .compilationResult()); 989 referenceContext = null; 990 } 991 992 // use this private API when the compilation unit result can be found 993 // through the 994 // reference context. Otherwise, use the other API taking a problem and a 995 // compilation result 996 // as arguments handle(int problemId, String[] problemArguments, String[] messageArguments, int severity, int problemStartPosition, int problemEndPosition)997 private void handle(int problemId, String[] problemArguments, 998 String[] messageArguments, int severity, int problemStartPosition, 999 int problemEndPosition) { 1000 this.handle(problemId, problemArguments, messageArguments, severity, 1001 problemStartPosition, problemEndPosition, referenceContext, 1002 referenceContext == null ? null : referenceContext 1003 .compilationResult()); 1004 referenceContext = null; 1005 } 1006 1007 // use this private API when the compilation unit result cannot be found 1008 // through the 1009 // reference context. handle(int problemId, String[] problemArguments, String[] messageArguments, int problemStartPosition, int problemEndPosition, CompilationResult unitResult)1010 private void handle(int problemId, String[] problemArguments, 1011 String[] messageArguments, int problemStartPosition, 1012 int problemEndPosition, CompilationResult unitResult) { 1013 this.handle(problemId, problemArguments, messageArguments, 1014 problemStartPosition, problemEndPosition, referenceContext, 1015 unitResult); 1016 referenceContext = null; 1017 } 1018 hidingEnclosingType(TypeDeclaration typeDecl)1019 public void hidingEnclosingType(TypeDeclaration typeDecl) { 1020 String[] arguments = new String[] { new String(typeDecl.name) }; 1021 this.handle(IProblem.HidingEnclosingType, arguments, arguments, 1022 typeDecl.sourceStart, typeDecl.sourceEnd); 1023 } 1024 hierarchyCircularity(SourceTypeBinding sourceType, ReferenceBinding superType, TypeReference reference)1025 public void hierarchyCircularity(SourceTypeBinding sourceType, 1026 ReferenceBinding superType, TypeReference reference) { 1027 int start = 0; 1028 int end = 0; 1029 String typeName = ""; //$NON-NLS-1$ 1030 String shortTypeName = ""; //$NON-NLS-1$ 1031 if (reference == null) { // can only happen when java.lang.Object is 1032 // busted 1033 start = sourceType.sourceStart(); 1034 end = sourceType.sourceEnd(); 1035 typeName = new String(superType.readableName()); 1036 shortTypeName = new String(superType.sourceName()); 1037 } else { 1038 start = reference.sourceStart; 1039 end = reference.sourceEnd; 1040 char[][] qName = reference.getTypeName(); 1041 typeName = CharOperation.toString(qName); 1042 shortTypeName = new String(qName[qName.length - 1]); 1043 } 1044 if (sourceType == superType) 1045 this.handle(IProblem.HierarchyCircularitySelfReference, 1046 new String[] { new String(sourceType.sourceName()), 1047 typeName }, 1048 new String[] { new String(sourceType.sourceName()), 1049 shortTypeName }, start, end); 1050 else 1051 this.handle(IProblem.HierarchyCircularity, new String[] { 1052 new String(sourceType.sourceName()), typeName }, 1053 new String[] { new String(sourceType.sourceName()), 1054 shortTypeName }, start, end); 1055 } 1056 hierarchyHasProblems(SourceTypeBinding type)1057 public void hierarchyHasProblems(SourceTypeBinding type) { 1058 String[] arguments = new String[] { new String(type.sourceName()) }; 1059 this.handle(IProblem.HierarchyHasProblems, arguments, arguments, type 1060 .sourceStart(), type.sourceEnd()); 1061 } 1062 illegalAbstractModifierCombinationForMethod( ReferenceBinding type, AbstractMethodDeclaration methodDecl)1063 public void illegalAbstractModifierCombinationForMethod( 1064 ReferenceBinding type, AbstractMethodDeclaration methodDecl) { 1065 String[] arguments = new String[] { new String(type.sourceName()), 1066 new String(methodDecl.selector) }; 1067 this.handle(IProblem.IllegalAbstractModifierCombinationForMethod, 1068 arguments, arguments, methodDecl.sourceStart, 1069 methodDecl.sourceEnd); 1070 } 1071 illegalModifierCombinationFinalAbstractForClass( SourceTypeBinding type)1072 public void illegalModifierCombinationFinalAbstractForClass( 1073 SourceTypeBinding type) { 1074 String[] arguments = new String[] { new String(type.sourceName()) }; 1075 this.handle(IProblem.IllegalModifierCombinationFinalAbstractForClass, 1076 arguments, arguments, type.sourceStart(), type.sourceEnd()); 1077 } 1078 illegalModifierCombinationFinalVolatileForField( ReferenceBinding type, FieldDeclaration fieldDecl)1079 public void illegalModifierCombinationFinalVolatileForField( 1080 ReferenceBinding type, FieldDeclaration fieldDecl) { 1081 String[] arguments = new String[] { fieldDecl.name() }; 1082 this.handle(IProblem.IllegalModifierCombinationFinalVolatileForField, 1083 arguments, arguments, fieldDecl.sourceStart, 1084 fieldDecl.sourceEnd); 1085 } 1086 illegalModifierForClass(SourceTypeBinding type)1087 public void illegalModifierForClass(SourceTypeBinding type) { 1088 String[] arguments = new String[] { new String(type.sourceName()) }; 1089 this.handle(IProblem.IllegalModifierForClass, arguments, arguments, 1090 type.sourceStart(), type.sourceEnd()); 1091 } 1092 illegalModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl)1093 public void illegalModifierForField(ReferenceBinding type, 1094 FieldDeclaration fieldDecl) { 1095 String[] arguments = new String[] { fieldDecl.name() }; 1096 this.handle(IProblem.IllegalModifierForField, arguments, arguments, 1097 fieldDecl.sourceStart, fieldDecl.sourceEnd); 1098 } 1099 illegalModifierForInterface(SourceTypeBinding type)1100 public void illegalModifierForInterface(SourceTypeBinding type) { 1101 String[] arguments = new String[] { new String(type.sourceName()) }; 1102 this.handle(IProblem.IllegalModifierForInterface, arguments, arguments, 1103 type.sourceStart(), type.sourceEnd()); 1104 } 1105 illegalModifierForInterfaceField(ReferenceBinding type, FieldDeclaration fieldDecl)1106 public void illegalModifierForInterfaceField(ReferenceBinding type, 1107 FieldDeclaration fieldDecl) { 1108 String[] arguments = new String[] { fieldDecl.name() }; 1109 this.handle(IProblem.IllegalModifierForInterfaceField, arguments, 1110 arguments, fieldDecl.sourceStart, fieldDecl.sourceEnd); 1111 } 1112 illegalModifierForInterfaceMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl)1113 public void illegalModifierForInterfaceMethod(ReferenceBinding type, 1114 AbstractMethodDeclaration methodDecl) { 1115 String[] arguments = new String[] { new String(type.sourceName()), 1116 new String(methodDecl.selector) }; 1117 this.handle(IProblem.IllegalModifierForInterfaceMethod, arguments, 1118 arguments, methodDecl.sourceStart, methodDecl.sourceEnd); 1119 } 1120 illegalModifierForLocalClass(SourceTypeBinding type)1121 public void illegalModifierForLocalClass(SourceTypeBinding type) { 1122 String[] arguments = new String[] { new String(type.sourceName()) }; 1123 this.handle(IProblem.IllegalModifierForLocalClass, arguments, 1124 arguments, type.sourceStart(), type.sourceEnd()); 1125 } 1126 illegalModifierForMemberClass(SourceTypeBinding type)1127 public void illegalModifierForMemberClass(SourceTypeBinding type) { 1128 String[] arguments = new String[] { new String(type.sourceName()) }; 1129 this.handle(IProblem.IllegalModifierForMemberClass, arguments, 1130 arguments, type.sourceStart(), type.sourceEnd()); 1131 } 1132 illegalModifierForMemberInterface(SourceTypeBinding type)1133 public void illegalModifierForMemberInterface(SourceTypeBinding type) { 1134 String[] arguments = new String[] { new String(type.sourceName()) }; 1135 this.handle(IProblem.IllegalModifierForMemberInterface, arguments, 1136 arguments, type.sourceStart(), type.sourceEnd()); 1137 } 1138 illegalModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl)1139 public void illegalModifierForMethod(ReferenceBinding type, 1140 AbstractMethodDeclaration methodDecl) { 1141 String[] arguments = new String[] { new String(type.sourceName()), 1142 new String(methodDecl.selector) }; 1143 this.handle(IProblem.IllegalModifierForMethod, arguments, arguments, 1144 methodDecl.sourceStart, methodDecl.sourceEnd); 1145 } 1146 illegalModifierForVariable(LocalDeclaration localDecl, boolean complainAsArgument)1147 public void illegalModifierForVariable(LocalDeclaration localDecl, 1148 boolean complainAsArgument) { 1149 String[] arguments = new String[] { localDecl.name() }; 1150 this.handle(complainAsArgument ? IProblem.IllegalModifierForArgument 1151 : IProblem.IllegalModifierForVariable, arguments, arguments, 1152 localDecl.sourceStart, localDecl.sourceEnd); 1153 } 1154 illegalPrimitiveOrArrayTypeForEnclosingInstance( TypeBinding enclosingType, ASTNode location)1155 public void illegalPrimitiveOrArrayTypeForEnclosingInstance( 1156 TypeBinding enclosingType, ASTNode location) { 1157 this.handle(IProblem.IllegalPrimitiveOrArrayTypeForEnclosingInstance, 1158 new String[] { new String(enclosingType.readableName()) }, 1159 new String[] { new String(enclosingType.shortReadableName()) }, 1160 location.sourceStart, location.sourceEnd); 1161 } 1162 illegalStaticModifierForMemberType(SourceTypeBinding type)1163 public void illegalStaticModifierForMemberType(SourceTypeBinding type) { 1164 String[] arguments = new String[] { new String(type.sourceName()) }; 1165 this.handle(IProblem.IllegalStaticModifierForMemberType, arguments, 1166 arguments, type.sourceStart(), type.sourceEnd()); 1167 } 1168 illegalVisibilityModifierCombinationForField( ReferenceBinding type, FieldDeclaration fieldDecl)1169 public void illegalVisibilityModifierCombinationForField( 1170 ReferenceBinding type, FieldDeclaration fieldDecl) { 1171 String[] arguments = new String[] { new String(fieldDecl.name()) }; 1172 this.handle(IProblem.IllegalVisibilityModifierCombinationForField, 1173 arguments, arguments, fieldDecl.sourceStart, 1174 fieldDecl.sourceEnd); 1175 } 1176 illegalVisibilityModifierCombinationForMemberType( SourceTypeBinding type)1177 public void illegalVisibilityModifierCombinationForMemberType( 1178 SourceTypeBinding type) { 1179 String[] arguments = new String[] { new String(type.sourceName()) }; 1180 this.handle(IProblem.IllegalVisibilityModifierCombinationForMemberType, 1181 arguments, arguments, type.sourceStart(), type.sourceEnd()); 1182 } 1183 illegalVisibilityModifierCombinationForMethod( ReferenceBinding type, AbstractMethodDeclaration methodDecl)1184 public void illegalVisibilityModifierCombinationForMethod( 1185 ReferenceBinding type, AbstractMethodDeclaration methodDecl) { 1186 String[] arguments = new String[] { new String(type.sourceName()), 1187 new String(methodDecl.selector) }; 1188 this.handle(IProblem.IllegalVisibilityModifierCombinationForMethod, 1189 arguments, arguments, methodDecl.sourceStart, 1190 methodDecl.sourceEnd); 1191 } 1192 illegalVisibilityModifierForInterfaceMemberType( SourceTypeBinding type)1193 public void illegalVisibilityModifierForInterfaceMemberType( 1194 SourceTypeBinding type) { 1195 String[] arguments = new String[] { new String(type.sourceName()) }; 1196 this.handle(IProblem.IllegalVisibilityModifierForInterfaceMemberType, 1197 arguments, arguments, type.sourceStart(), type.sourceEnd()); 1198 } 1199 illegalVoidExpression(ASTNode location)1200 public void illegalVoidExpression(ASTNode location) { 1201 this.handle(IProblem.InvalidVoidExpression, NoArgument, NoArgument, 1202 location.sourceStart, location.sourceEnd); 1203 } 1204 1205 // public void importProblem(ImportReference importRef, Binding 1206 // expectedImport) { 1207 // int problemId = expectedImport.problemId(); 1208 // int id; 1209 // switch (problemId) { 1210 // case NotFound : 1211 // // 1 1212 // id = IProblem.ImportNotFound; 1213 // break; 1214 // case NotVisible : 1215 // // 2 1216 // id = IProblem.ImportNotVisible; 1217 // break; 1218 // case Ambiguous : 1219 // // 3 1220 // id = IProblem.ImportAmbiguous; 1221 // break; 1222 // case InternalNameProvided : 1223 // // 4 1224 // id = IProblem.ImportInternalNameProvided; 1225 // break; 1226 // case InheritedNameHidesEnclosingName : 1227 // // 5 1228 // id = IProblem.ImportInheritedNameHidesEnclosingName; 1229 // break; 1230 // case NoError : 1231 // // 0 1232 // default : 1233 // needImplementation(); // want to fail to see why we were 1234 // // here... 1235 // return; 1236 // } 1237 // String argument; 1238 // if (expectedImport instanceof ProblemReferenceBinding) { 1239 // argument = CharOperation 1240 // .toString(((ProblemReferenceBinding) expectedImport).compoundName); 1241 // } else { 1242 // argument = CharOperation.toString(importRef.tokens); 1243 // } 1244 // String[] arguments = new String[]{argument}; 1245 // this.handle(id, arguments, arguments, importRef.sourceStart, 1246 // importRef.sourceEnd); 1247 // } incompatibleExceptionInThrowsClause(SourceTypeBinding type, MethodBinding currentMethod, MethodBinding inheritedMethod, ReferenceBinding exceptionType)1248 public void incompatibleExceptionInThrowsClause(SourceTypeBinding type, 1249 MethodBinding currentMethod, MethodBinding inheritedMethod, 1250 ReferenceBinding exceptionType) { 1251 if (type == currentMethod.declaringClass) { 1252 int id; 1253 if (currentMethod.declaringClass.isInterface() 1254 && !inheritedMethod.isPublic()) { // interface inheriting 1255 // Object protected 1256 // method 1257 id = IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod; 1258 } else { 1259 id = IProblem.IncompatibleExceptionInThrowsClause; 1260 } 1261 this 1262 .handle( 1263 // Exception %1 is not compatible with throws 1264 // clause in %2 1265 // 9.4.4 - The type of exception in the throws 1266 // clause is incompatible. 1267 id, 1268 new String[] { 1269 new String(exceptionType.sourceName()), 1270 new String( 1271 CharOperation 1272 .concat( 1273 inheritedMethod.declaringClass 1274 .readableName(), 1275 inheritedMethod 1276 .readableName(), 1277 '.')) }, 1278 new String[] { 1279 new String(exceptionType.sourceName()), 1280 new String( 1281 CharOperation 1282 .concat( 1283 inheritedMethod.declaringClass 1284 .shortReadableName(), 1285 inheritedMethod 1286 .shortReadableName(), 1287 '.')) }, 1288 currentMethod.sourceStart(), currentMethod 1289 .sourceEnd()); 1290 } else 1291 this 1292 .handle( 1293 // Exception %1 in throws clause of %2 is not 1294 // compatible with %3 1295 // 9.4.4 - The type of exception in the throws 1296 // clause is incompatible. 1297 IProblem.IncompatibleExceptionInInheritedMethodThrowsClause, 1298 new String[] { 1299 new String(exceptionType.sourceName()), 1300 new String(CharOperation.concat( 1301 currentMethod.declaringClass 1302 .sourceName(), 1303 currentMethod.readableName(), '.')), 1304 new String( 1305 CharOperation 1306 .concat( 1307 inheritedMethod.declaringClass 1308 .readableName(), 1309 inheritedMethod 1310 .readableName(), 1311 '.')) }, 1312 new String[] { 1313 new String(exceptionType.sourceName()), 1314 new String(CharOperation.concat( 1315 currentMethod.declaringClass 1316 .sourceName(), 1317 currentMethod.shortReadableName(), 1318 '.')), 1319 new String( 1320 CharOperation 1321 .concat( 1322 inheritedMethod.declaringClass 1323 .shortReadableName(), 1324 inheritedMethod 1325 .shortReadableName(), 1326 '.')) }, type 1327 .sourceStart(), type.sourceEnd()); 1328 } 1329 incompatibleReturnType(MethodBinding currentMethod, MethodBinding inheritedMethod)1330 public void incompatibleReturnType(MethodBinding currentMethod, 1331 MethodBinding inheritedMethod) { 1332 StringBuffer methodSignature = new StringBuffer(); 1333 methodSignature.append(inheritedMethod.declaringClass.readableName()) 1334 .append('.').append(inheritedMethod.readableName()); 1335 StringBuffer shortSignature = new StringBuffer(); 1336 shortSignature.append( 1337 inheritedMethod.declaringClass.shortReadableName()).append('.') 1338 .append(inheritedMethod.shortReadableName()); 1339 int id; 1340 if (currentMethod.declaringClass.isInterface() 1341 && !inheritedMethod.isPublic()) { // interface inheriting 1342 // Object protected method 1343 id = IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod; 1344 } else { 1345 id = IProblem.IncompatibleReturnType; 1346 } 1347 this.handle(id, new String[] { methodSignature.toString() }, 1348 new String[] { shortSignature.toString() }, currentMethod 1349 .sourceStart(), currentMethod.sourceEnd()); 1350 } 1351 incorrectLocationForEmptyDimension( ArrayAllocationExpression expression, int index)1352 public void incorrectLocationForEmptyDimension( 1353 ArrayAllocationExpression expression, int index) { 1354 this.handle(IProblem.IllegalDimension, NoArgument, NoArgument, 1355 expression.dimensions[index + 1].sourceStart, 1356 expression.dimensions[index + 1].sourceEnd); 1357 } 1358 incorrectSwitchType(Expression expression, TypeBinding testType)1359 public void incorrectSwitchType(Expression expression, TypeBinding testType) { 1360 this.handle(IProblem.IncorrectSwitchType, new String[] { new String( 1361 testType.readableName()) }, new String[] { new String(testType 1362 .shortReadableName()) }, expression.sourceStart, 1363 expression.sourceEnd); 1364 } 1365 inheritedMethodReducesVisibility(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods)1366 public void inheritedMethodReducesVisibility(SourceTypeBinding type, 1367 MethodBinding concreteMethod, MethodBinding[] abstractMethods) { 1368 StringBuffer concreteSignature = new StringBuffer(); 1369 concreteSignature.append(concreteMethod.declaringClass.readableName()) 1370 .append('.').append(concreteMethod.readableName()); 1371 StringBuffer shortSignature = new StringBuffer(); 1372 shortSignature 1373 .append(concreteMethod.declaringClass.shortReadableName()) 1374 .append('.').append(concreteMethod.shortReadableName()); 1375 this.handle( 1376 // The inherited method %1 cannot hide the public abstract 1377 // method in %2 1378 IProblem.InheritedMethodReducesVisibility, new String[] { 1379 new String(concreteSignature.toString()), 1380 new String(abstractMethods[0].declaringClass 1381 .readableName()) }, new String[] { 1382 new String(shortSignature.toString()), 1383 new String(abstractMethods[0].declaringClass 1384 .shortReadableName()) }, type.sourceStart(), 1385 type.sourceEnd()); 1386 } 1387 inheritedMethodsHaveIncompatibleReturnTypes( SourceTypeBinding type, MethodBinding[] inheritedMethods, int length)1388 public void inheritedMethodsHaveIncompatibleReturnTypes( 1389 SourceTypeBinding type, MethodBinding[] inheritedMethods, int length) { 1390 StringBuffer methodSignatures = new StringBuffer(); 1391 StringBuffer shortSignatures = new StringBuffer(); 1392 for (int i = length; --i >= 0;) { 1393 methodSignatures.append( 1394 inheritedMethods[i].declaringClass.readableName()).append( 1395 '.').append(inheritedMethods[i].readableName()); 1396 shortSignatures.append( 1397 inheritedMethods[i].declaringClass.shortReadableName()) 1398 .append('.') 1399 .append(inheritedMethods[i].shortReadableName()); 1400 if (i != 0) { 1401 methodSignatures.append(", "); //$NON-NLS-1$ 1402 shortSignatures.append(", "); //$NON-NLS-1$ 1403 } 1404 } 1405 this.handle( 1406 // Return type is incompatible with %1 1407 // 9.4.2 - The return type from the method is incompatible with 1408 // the declaration. 1409 IProblem.IncompatibleReturnType, 1410 new String[] { methodSignatures.toString() }, 1411 new String[] { shortSignatures.toString() }, 1412 type.sourceStart(), type.sourceEnd()); 1413 } 1414 initializerMustCompleteNormally(FieldDeclaration fieldDecl)1415 public void initializerMustCompleteNormally(FieldDeclaration fieldDecl) { 1416 this.handle(IProblem.InitializerMustCompleteNormally, NoArgument, 1417 NoArgument, fieldDecl.sourceStart, fieldDecl.sourceEnd); 1418 } 1419 innerTypesCannotDeclareStaticInitializers( ReferenceBinding innerType, ASTNode location)1420 public void innerTypesCannotDeclareStaticInitializers( 1421 ReferenceBinding innerType, ASTNode location) { 1422 this.handle(IProblem.CannotDefineStaticInitializerInLocalType, 1423 new String[] { new String(innerType.readableName()) }, 1424 new String[] { new String(innerType.shortReadableName()) }, 1425 location.sourceStart, location.sourceEnd); 1426 } 1427 interfaceCannotHaveConstructors( ConstructorDeclaration constructor)1428 public void interfaceCannotHaveConstructors( 1429 ConstructorDeclaration constructor) { 1430 this.handle(IProblem.InterfaceCannotHaveConstructors, NoArgument, 1431 NoArgument, constructor.sourceStart, constructor.sourceEnd, 1432 constructor, constructor.compilationResult()); 1433 } 1434 interfaceCannotHaveInitializers(SourceTypeBinding type, FieldDeclaration fieldDecl)1435 public void interfaceCannotHaveInitializers(SourceTypeBinding type, 1436 FieldDeclaration fieldDecl) { 1437 String[] arguments = new String[] { new String(type.sourceName()) }; 1438 this.handle(IProblem.InterfaceCannotHaveInitializers, arguments, 1439 arguments, fieldDecl.sourceStart, fieldDecl.sourceEnd); 1440 } 1441 invalidBreak(ASTNode location)1442 public void invalidBreak(ASTNode location) { 1443 this.handle(IProblem.InvalidBreak, NoArgument, NoArgument, 1444 location.sourceStart, location.sourceEnd); 1445 } 1446 invalidConstructor(Statement statement, MethodBinding targetConstructor)1447 public void invalidConstructor(Statement statement, 1448 MethodBinding targetConstructor) { 1449 boolean insideDefaultConstructor = (referenceContext instanceof ConstructorDeclaration) 1450 && ((ConstructorDeclaration) referenceContext) 1451 .isDefaultConstructor(); 1452 boolean insideImplicitConstructorCall = (statement instanceof ExplicitConstructorCall) 1453 && (((ExplicitConstructorCall) statement).accessMode == ExplicitConstructorCall.ImplicitSuper); 1454 int flag = IProblem.UndefinedConstructor; // default... 1455 switch (targetConstructor.problemId()) { 1456 case NotFound: 1457 if (insideDefaultConstructor) { 1458 flag = IProblem.UndefinedConstructorInDefaultConstructor; 1459 } else if (insideImplicitConstructorCall) { 1460 flag = IProblem.UndefinedConstructorInImplicitConstructorCall; 1461 } else { 1462 flag = IProblem.UndefinedConstructor; 1463 } 1464 break; 1465 case NotVisible: 1466 if (insideDefaultConstructor) { 1467 flag = IProblem.NotVisibleConstructorInDefaultConstructor; 1468 } else if (insideImplicitConstructorCall) { 1469 flag = IProblem.NotVisibleConstructorInImplicitConstructorCall; 1470 } else { 1471 flag = IProblem.NotVisibleConstructor; 1472 } 1473 break; 1474 case Ambiguous: 1475 if (insideDefaultConstructor) { 1476 flag = IProblem.AmbiguousConstructorInDefaultConstructor; 1477 } else if (insideImplicitConstructorCall) { 1478 flag = IProblem.AmbiguousConstructorInImplicitConstructorCall; 1479 } else { 1480 flag = IProblem.AmbiguousConstructor; 1481 } 1482 break; 1483 case NoError: 1484 // 0 1485 default: 1486 needImplementation(); // want to fail to see why we were 1487 // here... 1488 break; 1489 } 1490 this.handle(flag, new String[] { 1491 new String(targetConstructor.declaringClass.readableName()), 1492 parametersAsString(targetConstructor) }, 1493 new String[] { 1494 new String(targetConstructor.declaringClass 1495 .shortReadableName()), 1496 parametersAsShortString(targetConstructor) }, 1497 statement.sourceStart, statement.sourceEnd); 1498 } 1499 invalidContinue(ASTNode location)1500 public void invalidContinue(ASTNode location) { 1501 this.handle(IProblem.InvalidContinue, NoArgument, NoArgument, 1502 location.sourceStart, location.sourceEnd); 1503 } 1504 invalidEnclosingType(Expression expression, TypeBinding type, ReferenceBinding enclosingType)1505 public void invalidEnclosingType(Expression expression, TypeBinding type, 1506 ReferenceBinding enclosingType) { 1507 if (enclosingType.isAnonymousType()) 1508 enclosingType = enclosingType.superclass(); 1509 int flag = IProblem.UndefinedType; // default 1510 switch (type.problemId()) { 1511 case NotFound: 1512 // 1 1513 flag = IProblem.UndefinedType; 1514 break; 1515 case NotVisible: 1516 // 2 1517 flag = IProblem.NotVisibleType; 1518 break; 1519 case Ambiguous: 1520 // 3 1521 flag = IProblem.AmbiguousType; 1522 break; 1523 case InternalNameProvided: 1524 flag = IProblem.InternalTypeNameProvided; 1525 break; 1526 case NoError: 1527 // 0 1528 default: 1529 needImplementation(); // want to fail to see why we were 1530 // here... 1531 break; 1532 } 1533 this.handle(flag, new String[] { new String(enclosingType 1534 .readableName()) 1535 + "." + new String(type.readableName()) }, //$NON-NLS-1$ 1536 new String[] { new String(enclosingType.shortReadableName()) 1537 + "." + new String(type.shortReadableName()) }, //$NON-NLS-1$ 1538 expression.sourceStart, expression.sourceEnd); 1539 } 1540 invalidExpressionAsStatement(Expression expression)1541 public void invalidExpressionAsStatement(Expression expression) { 1542 this.handle(IProblem.InvalidExpressionAsStatement, NoArgument, 1543 NoArgument, expression.sourceStart, expression.sourceEnd); 1544 } 1545 invalidField(FieldReference fieldRef, TypeBinding searchedType)1546 public void invalidField(FieldReference fieldRef, TypeBinding searchedType) { 1547 int severity = Error; 1548 int flag = IProblem.UndefinedField; 1549 FieldBinding field = fieldRef.binding; 1550 switch (field.problemId()) { 1551 case NotFound: 1552 flag = IProblem.UndefinedField; 1553 /* 1554 * also need to check that the searchedType is the receiver type if 1555 * (searchedType.isHierarchyInconsistent()) severity = 1556 * SecondaryError; 1557 */ 1558 break; 1559 case NotVisible: 1560 flag = IProblem.NotVisibleField; 1561 break; 1562 case Ambiguous: 1563 flag = IProblem.AmbiguousField; 1564 break; 1565 case NonStaticReferenceInStaticContext: 1566 flag = IProblem.NonStaticFieldFromStaticInvocation; 1567 break; 1568 case NonStaticReferenceInConstructorInvocation: 1569 flag = IProblem.InstanceFieldDuringConstructorInvocation; 1570 break; 1571 case InheritedNameHidesEnclosingName: 1572 flag = IProblem.InheritedFieldHidesEnclosingName; 1573 break; 1574 case ReceiverTypeNotVisible: 1575 this.handle(IProblem.NotVisibleType, new String[] { new String( 1576 searchedType.leafComponentType().readableName()) }, 1577 new String[] { new String(searchedType.leafComponentType() 1578 .shortReadableName()) }, 1579 fieldRef.receiver.sourceStart, fieldRef.receiver.sourceEnd); 1580 return; 1581 case NoError: 1582 // 0 1583 default: 1584 needImplementation(); // want to fail to see why we were 1585 // here... 1586 break; 1587 } 1588 String[] arguments = new String[] { new String(field.readableName()) }; 1589 this.handle(flag, arguments, arguments, severity, fieldRef.sourceStart, 1590 fieldRef.sourceEnd); 1591 } 1592 invalidField(NameReference nameRef, FieldBinding field)1593 public void invalidField(NameReference nameRef, FieldBinding field) { 1594 int flag = IProblem.UndefinedField; 1595 switch (field.problemId()) { 1596 case NotFound: 1597 flag = IProblem.UndefinedField; 1598 break; 1599 case NotVisible: 1600 flag = IProblem.NotVisibleField; 1601 break; 1602 case Ambiguous: 1603 flag = IProblem.AmbiguousField; 1604 break; 1605 case NonStaticReferenceInStaticContext: 1606 flag = IProblem.NonStaticFieldFromStaticInvocation; 1607 break; 1608 case NonStaticReferenceInConstructorInvocation: 1609 flag = IProblem.InstanceFieldDuringConstructorInvocation; 1610 break; 1611 case InheritedNameHidesEnclosingName: 1612 flag = IProblem.InheritedFieldHidesEnclosingName; 1613 break; 1614 case ReceiverTypeNotVisible: 1615 this.handle(IProblem.NotVisibleType, new String[] { new String( 1616 field.declaringClass.leafComponentType().readableName()) }, 1617 new String[] { new String(field.declaringClass 1618 .leafComponentType().shortReadableName()) }, 1619 nameRef.sourceStart, nameRef.sourceEnd); 1620 return; 1621 case NoError: 1622 // 0 1623 default: 1624 needImplementation(); // want to fail to see why we were 1625 // here... 1626 break; 1627 } 1628 String[] arguments = new String[] { new String(field.readableName()) }; 1629 this.handle(flag, arguments, arguments, nameRef.sourceStart, 1630 nameRef.sourceEnd); 1631 } 1632 invalidField(QualifiedNameReference nameRef, FieldBinding field, int index, TypeBinding searchedType)1633 public void invalidField(QualifiedNameReference nameRef, 1634 FieldBinding field, int index, TypeBinding searchedType) { 1635 // the resolution of the index-th field of qname failed 1636 // qname.otherBindings[index] is the binding that has produced the 1637 // error 1638 // The different targetted errors should be : 1639 // UndefinedField 1640 // NotVisibleField 1641 // AmbiguousField 1642 if (searchedType.isBaseType()) { 1643 this.handle(IProblem.NoFieldOnBaseType, new String[] { 1644 new String(searchedType.readableName()), 1645 CharOperation.toString(CharOperation.subarray( 1646 nameRef.tokens, 0, index)), 1647 new String(nameRef.tokens[index]) }, new String[] { 1648 new String(searchedType.sourceName()), 1649 CharOperation.toString(CharOperation.subarray( 1650 nameRef.tokens, 0, index)), 1651 new String(nameRef.tokens[index]) }, nameRef.sourceStart, 1652 nameRef.sourceEnd); 1653 return; 1654 } 1655 int flag = IProblem.UndefinedField; 1656 switch (field.problemId()) { 1657 case NotFound: 1658 flag = IProblem.UndefinedField; 1659 /* 1660 * also need to check that the searchedType is the receiver type if 1661 * (searchedType.isHierarchyInconsistent()) severity = 1662 * SecondaryError; 1663 */ 1664 break; 1665 case NotVisible: 1666 flag = IProblem.NotVisibleField; 1667 break; 1668 case Ambiguous: 1669 flag = IProblem.AmbiguousField; 1670 break; 1671 case NonStaticReferenceInStaticContext: 1672 flag = IProblem.NonStaticFieldFromStaticInvocation; 1673 break; 1674 case NonStaticReferenceInConstructorInvocation: 1675 flag = IProblem.InstanceFieldDuringConstructorInvocation; 1676 break; 1677 case InheritedNameHidesEnclosingName: 1678 flag = IProblem.InheritedFieldHidesEnclosingName; 1679 break; 1680 case ReceiverTypeNotVisible: 1681 this.handle(IProblem.NotVisibleType, new String[] { new String( 1682 searchedType.leafComponentType().readableName()) }, 1683 new String[] { new String(searchedType.leafComponentType() 1684 .shortReadableName()) }, nameRef.sourceStart, 1685 nameRef.sourceEnd); 1686 return; 1687 case NoError: 1688 // 0 1689 default: 1690 needImplementation(); // want to fail to see why we were 1691 // here... 1692 break; 1693 } 1694 String[] arguments = new String[] { CharOperation 1695 .toString(CharOperation.subarray(nameRef.tokens, 0, index + 1)) }; 1696 this.handle(flag, arguments, arguments, nameRef.sourceStart, 1697 nameRef.sourceEnd); 1698 } 1699 invalidMethod(MessageSend messageSend, MethodBinding method)1700 public void invalidMethod(MessageSend messageSend, MethodBinding method) { 1701 // CODE should be UPDATED according to error coding in the different 1702 // method binding errors 1703 // The different targetted errors should be : 1704 // UndefinedMethod 1705 // NotVisibleMethod 1706 // AmbiguousMethod 1707 // InheritedNameHidesEnclosingName 1708 // InstanceMethodDuringConstructorInvocation 1709 // StaticMethodRequested 1710 int flag = IProblem.UndefinedMethod; // default... 1711 switch (method.problemId()) { 1712 case NotFound: 1713 flag = IProblem.UndefinedMethod; 1714 break; 1715 case NotVisible: 1716 flag = IProblem.NotVisibleMethod; 1717 break; 1718 case Ambiguous: 1719 flag = IProblem.AmbiguousMethod; 1720 break; 1721 case InheritedNameHidesEnclosingName: 1722 flag = IProblem.InheritedMethodHidesEnclosingName; 1723 break; 1724 case NonStaticReferenceInConstructorInvocation: 1725 flag = IProblem.InstanceMethodDuringConstructorInvocation; 1726 break; 1727 case NonStaticReferenceInStaticContext: 1728 flag = IProblem.StaticMethodRequested; 1729 break; 1730 case ReceiverTypeNotVisible: 1731 this.handle(IProblem.NotVisibleType, 1732 new String[] { new String(method.declaringClass 1733 .leafComponentType().readableName()) }, 1734 new String[] { new String(method.declaringClass 1735 .leafComponentType().shortReadableName()) }, 1736 messageSend.receiver.sourceStart, 1737 messageSend.receiver.sourceEnd); 1738 return; 1739 case NoError: 1740 // 0 1741 default: 1742 needImplementation(); // want to fail to see why we were 1743 // here... 1744 break; 1745 } 1746 if (flag == IProblem.UndefinedMethod) { 1747 ProblemMethodBinding problemMethod = (ProblemMethodBinding) method; 1748 if (problemMethod.closestMatch != null) { 1749 String closestParameterTypeNames = parametersAsString(problemMethod.closestMatch); 1750 String parameterTypeNames = parametersAsString(method); 1751 String closestParameterTypeShortNames = parametersAsShortString(problemMethod.closestMatch); 1752 String parameterTypeShortNames = parametersAsShortString(method); 1753 if (closestParameterTypeShortNames 1754 .equals(parameterTypeShortNames)) { 1755 closestParameterTypeShortNames = closestParameterTypeNames; 1756 parameterTypeShortNames = parameterTypeNames; 1757 } 1758 this 1759 .handle( 1760 IProblem.ParameterMismatch, 1761 new String[] { 1762 new String( 1763 problemMethod.closestMatch.declaringClass 1764 .readableName()), 1765 new String( 1766 problemMethod.closestMatch.selector), 1767 closestParameterTypeNames, 1768 parameterTypeNames }, 1769 new String[] { 1770 new String( 1771 problemMethod.closestMatch.declaringClass 1772 .shortReadableName()), 1773 new String( 1774 problemMethod.closestMatch.selector), 1775 closestParameterTypeShortNames, 1776 parameterTypeShortNames }, 1777 (int) (messageSend.nameSourcePosition >>> 32), 1778 (int) messageSend.nameSourcePosition); 1779 return; 1780 } 1781 } 1782 this.handle(flag, new String[] { 1783 new String(method.declaringClass.readableName()), 1784 new String(method.selector), parametersAsString(method) }, 1785 new String[] { 1786 new String(method.declaringClass.shortReadableName()), 1787 new String(method.selector), 1788 parametersAsShortString(method) }, 1789 (int) (messageSend.nameSourcePosition >>> 32), 1790 (int) messageSend.nameSourcePosition); 1791 } 1792 invalidNullToSynchronize(Expression expression)1793 public void invalidNullToSynchronize(Expression expression) { 1794 this.handle(IProblem.InvalidNullToSynchronized, NoArgument, NoArgument, 1795 expression.sourceStart, expression.sourceEnd); 1796 } 1797 invalidOperator(BinaryExpression expression, TypeBinding leftType, TypeBinding rightType)1798 public void invalidOperator(BinaryExpression expression, 1799 TypeBinding leftType, TypeBinding rightType) { 1800 String leftName = new String(leftType.readableName()); 1801 String rightName = new String(rightType.readableName()); 1802 String leftShortName = new String(leftType.shortReadableName()); 1803 String rightShortName = new String(rightType.shortReadableName()); 1804 if (leftShortName.equals(rightShortName)) { 1805 leftShortName = leftName; 1806 rightShortName = rightName; 1807 } 1808 this.handle(IProblem.InvalidOperator, new String[] { 1809 expression.operatorToString(), leftName + ", " + rightName }, //$NON-NLS-1$ 1810 new String[] { expression.operatorToString(), 1811 leftShortName + ", " + rightShortName }, //$NON-NLS-1$ 1812 expression.sourceStart, expression.sourceEnd); 1813 } 1814 invalidOperator(CompoundAssignment assign, TypeBinding leftType, TypeBinding rightType)1815 public void invalidOperator(CompoundAssignment assign, 1816 TypeBinding leftType, TypeBinding rightType) { 1817 String leftName = new String(leftType.readableName()); 1818 String rightName = new String(rightType.readableName()); 1819 String leftShortName = new String(leftType.shortReadableName()); 1820 String rightShortName = new String(rightType.shortReadableName()); 1821 if (leftShortName.equals(rightShortName)) { 1822 leftShortName = leftName; 1823 rightShortName = rightName; 1824 } 1825 this.handle(IProblem.InvalidOperator, new String[] { 1826 assign.operatorToString(), leftName + ", " + rightName }, //$NON-NLS-1$ 1827 new String[] { assign.operatorToString(), 1828 leftShortName + ", " + rightShortName }, //$NON-NLS-1$ 1829 assign.sourceStart, assign.sourceEnd); 1830 } 1831 invalidOperator(UnaryExpression expression, TypeBinding type)1832 public void invalidOperator(UnaryExpression expression, TypeBinding type) { 1833 this.handle(IProblem.InvalidOperator, 1834 new String[] { expression.operatorToString(), 1835 new String(type.readableName()) }, new String[] { 1836 expression.operatorToString(), 1837 new String(type.shortReadableName()) }, 1838 expression.sourceStart, expression.sourceEnd); 1839 } 1840 invalidParenthesizedExpression(ASTNode reference)1841 public void invalidParenthesizedExpression(ASTNode reference) { 1842 this.handle(IProblem.InvalidParenthesizedExpression, NoArgument, 1843 NoArgument, reference.sourceStart, reference.sourceEnd); 1844 } 1845 invalidSuperclass(SourceTypeBinding type, TypeReference superclassRef, ReferenceBinding expectedType)1846 public void invalidSuperclass(SourceTypeBinding type, 1847 TypeReference superclassRef, ReferenceBinding expectedType) { 1848 int problemId = expectedType.problemId(); 1849 int id; 1850 switch (problemId) { 1851 case NotFound: 1852 // 1 1853 id = IProblem.SuperclassNotFound; 1854 break; 1855 case NotVisible: 1856 // 2 1857 id = IProblem.SuperclassNotVisible; 1858 break; 1859 case Ambiguous: 1860 // 3 1861 id = IProblem.SuperclassAmbiguous; 1862 break; 1863 case InternalNameProvided: 1864 // 4 1865 id = IProblem.SuperclassInternalNameProvided; 1866 break; 1867 case InheritedNameHidesEnclosingName: 1868 // 5 1869 id = IProblem.SuperclassInheritedNameHidesEnclosingName; 1870 break; 1871 case NoError: 1872 // 0 1873 default: 1874 needImplementation(); // want to fail to see why we were 1875 // here... 1876 return; 1877 } 1878 this.handle(id, new String[] { new String(expectedType.readableName()), 1879 new String(type.sourceName()) }, new String[] { 1880 new String(expectedType.shortReadableName()), 1881 new String(type.sourceName()) }, superclassRef.sourceStart, 1882 superclassRef.sourceEnd); 1883 } 1884 invalidSuperinterface(SourceTypeBinding type, TypeReference superinterfaceRef, ReferenceBinding expectedType)1885 public void invalidSuperinterface(SourceTypeBinding type, 1886 TypeReference superinterfaceRef, ReferenceBinding expectedType) { 1887 int problemId = expectedType.problemId(); 1888 int id; 1889 switch (problemId) { 1890 case NotFound: 1891 // 1 1892 id = IProblem.InterfaceNotFound; 1893 break; 1894 case NotVisible: 1895 // 2 1896 id = IProblem.InterfaceNotVisible; 1897 break; 1898 case Ambiguous: 1899 // 3 1900 id = IProblem.InterfaceAmbiguous; 1901 break; 1902 case InternalNameProvided: 1903 // 4 1904 id = IProblem.InterfaceInternalNameProvided; 1905 break; 1906 case InheritedNameHidesEnclosingName: 1907 // 5 1908 id = IProblem.InterfaceInheritedNameHidesEnclosingName; 1909 break; 1910 case NoError: 1911 // 0 1912 default: 1913 needImplementation(); // want to fail to see why we were 1914 // here... 1915 return; 1916 } 1917 this.handle(id, new String[] { new String(expectedType.readableName()), 1918 new String(type.sourceName()) }, new String[] { 1919 new String(expectedType.shortReadableName()), 1920 new String(type.sourceName()) }, superinterfaceRef.sourceStart, 1921 superinterfaceRef.sourceEnd); 1922 } 1923 invalidType(ASTNode location, TypeBinding type)1924 public void invalidType(ASTNode location, TypeBinding type) { 1925 int flag = IProblem.UndefinedType; // default 1926 switch (type.problemId()) { 1927 case NotFound: 1928 flag = IProblem.UndefinedType; 1929 break; 1930 case NotVisible: 1931 flag = IProblem.NotVisibleType; 1932 break; 1933 case Ambiguous: 1934 flag = IProblem.AmbiguousType; 1935 break; 1936 case InternalNameProvided: 1937 flag = IProblem.InternalTypeNameProvided; 1938 break; 1939 case InheritedNameHidesEnclosingName: 1940 flag = IProblem.InheritedTypeHidesEnclosingName; 1941 break; 1942 case NoError: 1943 // 0 1944 default: 1945 needImplementation(); // want to fail to see why we were 1946 // here... 1947 break; 1948 } 1949 this.handle(flag, new String[] { new String(type.readableName()) }, 1950 new String[] { new String(type.shortReadableName()) }, 1951 location.sourceStart, location.sourceEnd); 1952 } 1953 invalidTypeReference(Expression expression)1954 public void invalidTypeReference(Expression expression) { 1955 this.handle(IProblem.InvalidTypeExpression, NoArgument, NoArgument, 1956 expression.sourceStart, expression.sourceEnd); 1957 } 1958 invalidTypeToSynchronize(Expression expression, TypeBinding type)1959 public void invalidTypeToSynchronize(Expression expression, TypeBinding type) { 1960 this.handle(IProblem.InvalidTypeToSynchronized, 1961 new String[] { new String(type.readableName()) }, 1962 new String[] { new String(type.shortReadableName()) }, 1963 expression.sourceStart, expression.sourceEnd); 1964 } 1965 invalidUnaryExpression(Expression expression)1966 public void invalidUnaryExpression(Expression expression) { 1967 this.handle(IProblem.InvalidUnaryExpression, NoArgument, NoArgument, 1968 expression.sourceStart, expression.sourceEnd); 1969 } 1970 isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl)1971 public void isClassPathCorrect(char[][] wellKnownTypeName, 1972 CompilationUnitDeclaration compUnitDecl) { 1973 referenceContext = compUnitDecl; 1974 String[] arguments = new String[] { CharOperation 1975 .toString(wellKnownTypeName) }; 1976 this.handle(IProblem.IsClassPathCorrect, arguments, arguments, 1977 AbortCompilation | Error, compUnitDecl == null ? 0 1978 : compUnitDecl.sourceStart, compUnitDecl == null ? 1 1979 : compUnitDecl.sourceEnd); 1980 } 1981 javadocDuplicatedReturnTag(int sourceStart, int sourceEnd)1982 public void javadocDuplicatedReturnTag(int sourceStart, int sourceEnd) { 1983 this.handle(IProblem.JavadocDuplicateReturnTag, NoArgument, NoArgument, 1984 sourceStart, sourceEnd); 1985 } 1986 javadocDeprecatedField(FieldBinding field, ASTNode location, int modifiers)1987 public void javadocDeprecatedField(FieldBinding field, ASTNode location, 1988 int modifiers) { 1989 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, 1990 modifiers)) { 1991 this.handle(IProblem.JavadocUsingDeprecatedField, new String[] { 1992 new String(field.declaringClass.readableName()), 1993 new String(field.name) }, new String[] { 1994 new String(field.declaringClass.shortReadableName()), 1995 new String(field.name) }, location.sourceStart, 1996 location.sourceEnd); 1997 } 1998 } 1999 javadocDeprecatedMethod(MethodBinding method, ASTNode location, int modifiers)2000 public void javadocDeprecatedMethod(MethodBinding method, ASTNode location, 2001 int modifiers) { 2002 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, 2003 modifiers)) { 2004 if (method.isConstructor()) { 2005 this 2006 .handle(IProblem.JavadocUsingDeprecatedConstructor, 2007 new String[] { 2008 new String(method.declaringClass 2009 .readableName()), 2010 parametersAsString(method) }, 2011 new String[] { 2012 new String(method.declaringClass 2013 .shortReadableName()), 2014 parametersAsShortString(method) }, 2015 location.sourceStart, location.sourceEnd); 2016 } else { 2017 this 2018 .handle(IProblem.JavadocUsingDeprecatedMethod, 2019 new String[] { 2020 new String(method.declaringClass 2021 .readableName()), 2022 new String(method.selector), 2023 parametersAsString(method) }, 2024 new String[] { 2025 new String(method.declaringClass 2026 .shortReadableName()), 2027 new String(method.selector), 2028 parametersAsShortString(method) }, 2029 location.sourceStart, location.sourceEnd); 2030 } 2031 } 2032 } 2033 javadocDeprecatedType(TypeBinding type, ASTNode location, int modifiers)2034 public void javadocDeprecatedType(TypeBinding type, ASTNode location, 2035 int modifiers) { 2036 if (location == null) 2037 return; // 1G828DN - no type ref for synthetic arguments 2038 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, 2039 modifiers)) { 2040 this.handle(IProblem.JavadocUsingDeprecatedType, 2041 new String[] { new String(type.readableName()) }, 2042 new String[] { new String(type.shortReadableName()) }, 2043 location.sourceStart, location.sourceEnd); 2044 } 2045 } 2046 2047 // public void javadocDuplicatedParamTag(JavadocSingleNameReference param, 2048 // int modifiers) { 2049 // if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, 2050 // modifiers)) { 2051 // String[] arguments = new String[] {String.valueOf(param.token)}; 2052 // this.handle(IProblem.JavadocDuplicateParamName, arguments, arguments, 2053 // param.sourceStart, param.sourceEnd); 2054 // } 2055 // } javadocDuplicatedThrowsClassName(TypeReference typeReference, int modifiers)2056 public void javadocDuplicatedThrowsClassName(TypeReference typeReference, 2057 int modifiers) { 2058 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, 2059 modifiers)) { 2060 String[] arguments = new String[] { String 2061 .valueOf(typeReference.resolvedType.sourceName()) }; 2062 this.handle(IProblem.JavadocDuplicateThrowsClassName, arguments, 2063 arguments, typeReference.sourceStart, 2064 typeReference.sourceEnd); 2065 } 2066 } 2067 javadocErrorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params, int modifiers)2068 public void javadocErrorNoMethodFor(MessageSend messageSend, 2069 TypeBinding recType, TypeBinding[] params, int modifiers) { 2070 StringBuffer buffer = new StringBuffer(); 2071 StringBuffer shortBuffer = new StringBuffer(); 2072 for (int i = 0, length = params.length; i < length; i++) { 2073 if (i != 0) { 2074 buffer.append(", "); //$NON-NLS-1$ 2075 shortBuffer.append(", "); //$NON-NLS-1$ 2076 } 2077 buffer.append(new String(params[i].readableName())); 2078 shortBuffer.append(new String(params[i].shortReadableName())); 2079 } 2080 2081 int id = recType.isArrayType() ? IProblem.JavadocNoMessageSendOnArrayType 2082 : IProblem.JavadocNoMessageSendOnBaseType; 2083 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, 2084 modifiers)) { 2085 this.handle(id, new String[] { new String(recType.readableName()), 2086 new String(messageSend.selector), buffer.toString() }, 2087 new String[] { new String(recType.shortReadableName()), 2088 new String(messageSend.selector), 2089 shortBuffer.toString() }, messageSend.sourceStart, 2090 messageSend.sourceEnd); 2091 } 2092 } 2093 javadocInvalidConstructor(Statement statement, MethodBinding targetConstructor, int modifiers)2094 public void javadocInvalidConstructor(Statement statement, 2095 MethodBinding targetConstructor, int modifiers) { 2096 2097 if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, 2098 modifiers)) { 2099 return; 2100 } 2101 // boolean insideDefaultConstructor = 2102 // (this.referenceContext instanceof ConstructorDeclaration) 2103 // && 2104 // ((ConstructorDeclaration)this.referenceContext).isDefaultConstructor(); 2105 // boolean insideImplicitConstructorCall = 2106 // (statement instanceof ExplicitConstructorCall) 2107 // && (((ExplicitConstructorCall) statement).accessMode == 2108 // ExplicitConstructorCall.ImplicitSuper); 2109 2110 int id = IProblem.JavadocUndefinedConstructor; // default... 2111 switch (targetConstructor.problemId()) { 2112 case NotFound: 2113 // if (insideDefaultConstructor){ 2114 // id = IProblem.JavadocUndefinedConstructorInDefaultConstructor; 2115 // } else if (insideImplicitConstructorCall){ 2116 // id = 2117 // IProblem.JavadocUndefinedConstructorInImplicitConstructorCall; 2118 // } else { 2119 id = IProblem.JavadocUndefinedConstructor; 2120 // } 2121 break; 2122 case NotVisible: 2123 // if (insideDefaultConstructor){ 2124 // id = IProblem.JavadocNotVisibleConstructorInDefaultConstructor; 2125 // } else if (insideImplicitConstructorCall){ 2126 // id = 2127 // IProblem.JavadocNotVisibleConstructorInImplicitConstructorCall; 2128 // } else { 2129 id = IProblem.JavadocNotVisibleConstructor; 2130 // } 2131 break; 2132 case Ambiguous: 2133 // if (insideDefaultConstructor){ 2134 // id = IProblem.AmbiguousConstructorInDefaultConstructor; 2135 // } else if (insideImplicitConstructorCall){ 2136 // id = IProblem.AmbiguousConstructorInImplicitConstructorCall; 2137 // } else { 2138 id = IProblem.JavadocAmbiguousConstructor; 2139 // } 2140 break; 2141 case NoError: // 0 2142 default: 2143 needImplementation(); // want to fail to see why we were here... 2144 break; 2145 } 2146 2147 this.handle(id, new String[] { 2148 new String(targetConstructor.declaringClass.readableName()), 2149 parametersAsString(targetConstructor) }, 2150 new String[] { 2151 new String(targetConstructor.declaringClass 2152 .shortReadableName()), 2153 parametersAsShortString(targetConstructor) }, 2154 statement.sourceStart, statement.sourceEnd); 2155 } 2156 javadocAmbiguousMethodReference(int sourceStart, int sourceEnd, Binding fieldBinding, int modifiers)2157 public void javadocAmbiguousMethodReference(int sourceStart, int sourceEnd, 2158 Binding fieldBinding, int modifiers) { 2159 int id = IProblem.JavadocAmbiguousMethodReference; 2160 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, 2161 modifiers)) { 2162 String[] arguments = new String[] { new String(fieldBinding 2163 .readableName()) }; 2164 handle(id, arguments, arguments, sourceStart, sourceEnd); 2165 } 2166 } 2167 2168 /* 2169 * Similar implementation than invalidField(FieldReference...) Note that 2170 * following problem id cannot occur for Javadoc: - 2171 * NonStaticReferenceInStaticContext : - 2172 * NonStaticReferenceInConstructorInvocation : - ReceiverTypeNotVisible : 2173 */ javadocInvalidField(int sourceStart, int sourceEnd, Binding fieldBinding, TypeBinding searchedType, int modifiers)2174 public void javadocInvalidField(int sourceStart, int sourceEnd, 2175 Binding fieldBinding, TypeBinding searchedType, int modifiers) { 2176 int id = IProblem.JavadocUndefinedField; 2177 switch (fieldBinding.problemId()) { 2178 case NotFound: 2179 id = IProblem.JavadocUndefinedField; 2180 break; 2181 case NotVisible: 2182 id = IProblem.JavadocNotVisibleField; 2183 break; 2184 case Ambiguous: 2185 id = IProblem.JavadocAmbiguousField; 2186 break; 2187 case InheritedNameHidesEnclosingName: 2188 id = IProblem.JavadocInheritedFieldHidesEnclosingName; 2189 break; 2190 case NoError: // 0 2191 default: 2192 needImplementation(); // want to fail to see why we were here... 2193 break; 2194 } 2195 2196 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, 2197 modifiers)) { 2198 String[] arguments = new String[] { new String(fieldBinding 2199 .readableName()) }; 2200 handle(id, arguments, arguments, sourceStart, sourceEnd); 2201 } 2202 } 2203 2204 /* 2205 * Similar implementation than invalidMethod(MessageSend...) Note that 2206 * following problem id cannot occur for Javadoc: - 2207 * NonStaticReferenceInStaticContext : - 2208 * NonStaticReferenceInConstructorInvocation : - ReceiverTypeNotVisible : 2209 */ javadocInvalidMethod(MessageSend messageSend, MethodBinding method, int modifiers)2210 public void javadocInvalidMethod(MessageSend messageSend, 2211 MethodBinding method, int modifiers) { 2212 if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, 2213 modifiers)) { 2214 return; 2215 } 2216 int id = IProblem.JavadocUndefinedMethod; // default... 2217 switch (method.problemId()) { 2218 case NotFound: 2219 id = IProblem.JavadocUndefinedMethod; 2220 break; 2221 case NotVisible: 2222 id = IProblem.JavadocNotVisibleMethod; 2223 break; 2224 case Ambiguous: 2225 id = IProblem.JavadocAmbiguousMethod; 2226 break; 2227 case InheritedNameHidesEnclosingName: 2228 id = IProblem.JavadocInheritedMethodHidesEnclosingName; 2229 break; 2230 case NoError: // 0 2231 default: 2232 needImplementation(); // want to fail to see why we were here... 2233 break; 2234 } 2235 2236 if (id == IProblem.JavadocUndefinedMethod) { 2237 ProblemMethodBinding problemMethod = (ProblemMethodBinding) method; 2238 if (problemMethod.closestMatch != null) { 2239 String closestParameterTypeNames = parametersAsString(problemMethod.closestMatch); 2240 String parameterTypeNames = parametersAsString(method); 2241 String closestParameterTypeShortNames = parametersAsShortString(problemMethod.closestMatch); 2242 String parameterTypeShortNames = parametersAsShortString(method); 2243 if (closestParameterTypeShortNames 2244 .equals(parameterTypeShortNames)) { 2245 closestParameterTypeShortNames = closestParameterTypeNames; 2246 parameterTypeShortNames = parameterTypeNames; 2247 } 2248 this 2249 .handle( 2250 IProblem.JavadocParameterMismatch, 2251 new String[] { 2252 new String( 2253 problemMethod.closestMatch.declaringClass 2254 .readableName()), 2255 new String( 2256 problemMethod.closestMatch.selector), 2257 closestParameterTypeNames, 2258 parameterTypeNames }, 2259 new String[] { 2260 new String( 2261 problemMethod.closestMatch.declaringClass 2262 .shortReadableName()), 2263 new String( 2264 problemMethod.closestMatch.selector), 2265 closestParameterTypeShortNames, 2266 parameterTypeShortNames }, 2267 (int) (messageSend.nameSourcePosition >>> 32), 2268 (int) messageSend.nameSourcePosition); 2269 return; 2270 } 2271 } 2272 2273 this.handle(id, new String[] { 2274 new String(method.declaringClass.readableName()), 2275 new String(method.selector), parametersAsString(method) }, 2276 new String[] { 2277 new String(method.declaringClass.shortReadableName()), 2278 new String(method.selector), 2279 parametersAsShortString(method) }, 2280 (int) (messageSend.nameSourcePosition >>> 32), 2281 (int) messageSend.nameSourcePosition); 2282 } 2283 2284 // public void javadocInvalidParamName(JavadocSingleNameReference param, int 2285 // modifiers) { 2286 // if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, 2287 // modifiers)) { 2288 // String[] arguments = new String[] {String.valueOf(param.token)}; 2289 // this.handle(IProblem.JavadocInvalidParamName, arguments, arguments, 2290 // param.sourceStart, param.sourceEnd); 2291 // } 2292 // } javadocInvalidSeeReference(int sourceStart, int sourceEnd)2293 public void javadocInvalidSeeReference(int sourceStart, int sourceEnd) { 2294 this.handle(IProblem.JavadocInvalidSeeReference, NoArgument, 2295 NoArgument, sourceStart, sourceEnd); 2296 } 2297 javadocInvalidSeeReferenceArgs(int sourceStart, int sourceEnd)2298 public void javadocInvalidSeeReferenceArgs(int sourceStart, int sourceEnd) { 2299 this.handle(IProblem.JavadocInvalidSeeArgs, NoArgument, NoArgument, 2300 sourceStart, sourceEnd); 2301 } 2302 javadocInvalidSeeUrlReference(int sourceStart, int sourceEnd)2303 public void javadocInvalidSeeUrlReference(int sourceStart, int sourceEnd) { 2304 this.handle(IProblem.JavadocInvalidSeeHref, NoArgument, NoArgument, 2305 sourceStart, sourceEnd); 2306 } 2307 javadocInvalidTag(int sourceStart, int sourceEnd)2308 public void javadocInvalidTag(int sourceStart, int sourceEnd) { 2309 this.handle(IProblem.JavadocInvalidTag, NoArgument, NoArgument, 2310 sourceStart, sourceEnd); 2311 } 2312 javadocInvalidThrowsClass(int sourceStart, int sourceEnd)2313 public void javadocInvalidThrowsClass(int sourceStart, int sourceEnd) { 2314 this.handle(IProblem.JavadocInvalidThrowsClass, NoArgument, NoArgument, 2315 sourceStart, sourceEnd); 2316 } 2317 javadocInvalidThrowsClassName(TypeReference typeReference, int modifiers)2318 public void javadocInvalidThrowsClassName(TypeReference typeReference, 2319 int modifiers) { 2320 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, 2321 modifiers)) { 2322 String[] arguments = new String[] { String 2323 .valueOf(typeReference.resolvedType.sourceName()) }; 2324 this.handle(IProblem.JavadocInvalidThrowsClassName, arguments, 2325 arguments, typeReference.sourceStart, 2326 typeReference.sourceEnd); 2327 } 2328 } 2329 javadocInvalidType(ASTNode location, TypeBinding type, int modifiers)2330 public void javadocInvalidType(ASTNode location, TypeBinding type, 2331 int modifiers) { 2332 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, 2333 modifiers)) { 2334 int id = IProblem.JavadocUndefinedType; // default 2335 switch (type.problemId()) { 2336 case NotFound: 2337 id = IProblem.JavadocUndefinedType; 2338 break; 2339 case NotVisible: 2340 id = IProblem.JavadocNotVisibleType; 2341 break; 2342 case Ambiguous: 2343 id = IProblem.JavadocAmbiguousType; 2344 break; 2345 case InternalNameProvided: 2346 id = IProblem.JavadocInternalTypeNameProvided; 2347 break; 2348 case InheritedNameHidesEnclosingName: 2349 id = IProblem.JavadocInheritedNameHidesEnclosingTypeName; 2350 break; 2351 case NoError: // 0 2352 default: 2353 needImplementation(); // want to fail to see why we were 2354 // here... 2355 break; 2356 } 2357 this.handle(id, new String[] { new String(type.readableName()) }, 2358 new String[] { new String(type.shortReadableName()) }, 2359 location.sourceStart, location.sourceEnd); 2360 } 2361 } 2362 javadocMalformedSeeReference(int sourceStart, int sourceEnd)2363 public void javadocMalformedSeeReference(int sourceStart, int sourceEnd) { 2364 this.handle(IProblem.JavadocMalformedSeeReference, NoArgument, 2365 NoArgument, sourceStart, sourceEnd); 2366 } 2367 javadocMissing(int sourceStart, int sourceEnd, int modifiers)2368 public void javadocMissing(int sourceStart, int sourceEnd, int modifiers) { 2369 boolean overriding = (modifiers & (CompilerModifiers.AccImplementing + CompilerModifiers.AccOverriding)) != 0; 2370 boolean report = (this.options 2371 .getSeverity(CompilerOptions.MissingJavadocComments) != ProblemSeverities.Ignore) 2372 && (!overriding || this.options.reportMissingJavadocCommentsOverriding); 2373 if (report) { 2374 String arg = javadocVisibilityArgument( 2375 this.options.reportMissingJavadocCommentsVisibility, 2376 modifiers); 2377 if (arg != null) { 2378 String[] arguments = new String[] { arg }; 2379 this.handle(IProblem.JavadocMissing, arguments, arguments, 2380 sourceStart, sourceEnd); 2381 } 2382 } 2383 } 2384 javadocMissingParamName(int sourceStart, int sourceEnd)2385 public void javadocMissingParamName(int sourceStart, int sourceEnd) { 2386 this.handle(IProblem.JavadocMissingParamName, NoArgument, NoArgument, 2387 sourceStart, sourceEnd); 2388 } 2389 javadocMissingParamTag(Argument param, int modifiers)2390 public void javadocMissingParamTag(Argument param, int modifiers) { 2391 boolean overriding = (modifiers & (CompilerModifiers.AccImplementing + CompilerModifiers.AccOverriding)) != 0; 2392 boolean report = (this.options 2393 .getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore) 2394 && (!overriding || this.options.reportMissingJavadocTagsOverriding); 2395 if (report 2396 && javadocVisibility( 2397 this.options.reportMissingJavadocTagsVisibility, 2398 modifiers)) { 2399 String[] arguments = new String[] { String.valueOf(param.name) }; 2400 this.handle(IProblem.JavadocMissingParamTag, arguments, arguments, 2401 param.sourceStart, param.sourceEnd); 2402 } 2403 } 2404 javadocMissingReturnTag(int sourceStart, int sourceEnd, int modifiers)2405 public void javadocMissingReturnTag(int sourceStart, int sourceEnd, 2406 int modifiers) { 2407 boolean overriding = (modifiers & (CompilerModifiers.AccImplementing + CompilerModifiers.AccOverriding)) != 0; 2408 boolean report = (this.options 2409 .getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore) 2410 && (!overriding || this.options.reportMissingJavadocTagsOverriding); 2411 if (report 2412 && javadocVisibility( 2413 this.options.reportMissingJavadocTagsVisibility, 2414 modifiers)) { 2415 this.handle(IProblem.JavadocMissingReturnTag, NoArgument, 2416 NoArgument, sourceStart, sourceEnd); 2417 } 2418 } 2419 javadocMissingSeeReference(int sourceStart, int sourceEnd)2420 public void javadocMissingSeeReference(int sourceStart, int sourceEnd) { 2421 this.handle(IProblem.JavadocMissingSeeReference, NoArgument, 2422 NoArgument, sourceStart, sourceEnd); 2423 } 2424 javadocMissingThrowsClassName(int sourceStart, int sourceEnd)2425 public void javadocMissingThrowsClassName(int sourceStart, int sourceEnd) { 2426 this.handle(IProblem.JavadocMissingThrowsClassName, NoArgument, 2427 NoArgument, sourceStart, sourceEnd); 2428 } 2429 javadocMissingThrowsTag(TypeReference typeRef, int modifiers)2430 public void javadocMissingThrowsTag(TypeReference typeRef, int modifiers) { 2431 boolean overriding = (modifiers & (CompilerModifiers.AccImplementing + CompilerModifiers.AccOverriding)) != 0; 2432 boolean report = (this.options 2433 .getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore) 2434 && (!overriding || this.options.reportMissingJavadocTagsOverriding); 2435 if (report 2436 && javadocVisibility( 2437 this.options.reportMissingJavadocTagsVisibility, 2438 modifiers)) { 2439 String[] arguments = new String[] { String 2440 .valueOf(typeRef.resolvedType.sourceName()) }; 2441 this.handle(IProblem.JavadocMissingThrowsTag, arguments, arguments, 2442 typeRef.sourceStart, typeRef.sourceEnd); 2443 } 2444 } 2445 javadocUnexpectedTag(int sourceStart, int sourceEnd)2446 public void javadocUnexpectedTag(int sourceStart, int sourceEnd) { 2447 this.handle(IProblem.JavadocUnexpectedTag, NoArgument, NoArgument, 2448 sourceStart, sourceEnd); 2449 } 2450 javadocUnterminatedInlineTag(int sourceStart, int sourceEnd)2451 public void javadocUnterminatedInlineTag(int sourceStart, int sourceEnd) { 2452 this.handle(IProblem.JavadocUnterminatedInlineTag, NoArgument, 2453 NoArgument, sourceStart, sourceEnd); 2454 } 2455 javadocVisibility(int visibility, int modifiers)2456 private boolean javadocVisibility(int visibility, int modifiers) { 2457 switch (modifiers & CompilerModifiers.AccVisibilityMASK) { 2458 case IConstants.AccPublic: 2459 return true; 2460 case IConstants.AccProtected: 2461 return (visibility != IConstants.AccPublic); 2462 // case IConstants.AccDefault: 2463 // return (visibility == IConstants.AccDefault || visibility == 2464 // IConstants.AccPrivate); 2465 case IConstants.AccPrivate: 2466 return (visibility == IConstants.AccPrivate); 2467 } 2468 return true; 2469 } 2470 javadocVisibilityArgument(int visibility, int modifiers)2471 private String javadocVisibilityArgument(int visibility, int modifiers) { 2472 String argument = null; 2473 switch (modifiers & CompilerModifiers.AccVisibilityMASK) { 2474 case IConstants.AccPublic: 2475 argument = CompilerOptions.PUBLIC; 2476 break; 2477 case IConstants.AccProtected: 2478 if (visibility != IConstants.AccPublic) { 2479 argument = CompilerOptions.PROTECTED; 2480 } 2481 break; 2482 // case IConstants.AccDefault: 2483 // if (visibility == IConstants.AccDefault || visibility == 2484 // IConstants.AccPrivate) { 2485 // argument = CompilerOptions.DEFAULT; 2486 // } 2487 // break; 2488 case IConstants.AccPrivate: 2489 if (visibility == IConstants.AccPrivate) { 2490 argument = CompilerOptions.PRIVATE; 2491 } 2492 break; 2493 } 2494 return argument; 2495 } 2496 methodNeedingAbstractModifier(MethodDeclaration methodDecl)2497 public void methodNeedingAbstractModifier(MethodDeclaration methodDecl) { 2498 this.handle(IProblem.MethodRequiresBody, NoArgument, NoArgument, 2499 methodDecl.sourceStart, methodDecl.sourceEnd); 2500 } 2501 methodNeedingNoBody(MethodDeclaration methodDecl)2502 public void methodNeedingNoBody(MethodDeclaration methodDecl) { 2503 this.handle( 2504 // ((methodDecl.modifiers & CompilerModifiers.AccNative) != 0) ? 2505 // IProblem.BodyForNativeMethod : 2506 // IProblem.BodyForAbstractMethod, 2507 IProblem.BodyForAbstractMethod, NoArgument, NoArgument, 2508 methodDecl.sourceStart, methodDecl.sourceEnd); 2509 } 2510 methodWithConstructorName(MethodDeclaration methodDecl)2511 public void methodWithConstructorName(MethodDeclaration methodDecl) { 2512 this.handle(IProblem.MethodButWithConstructorName, NoArgument, 2513 NoArgument, methodDecl.sourceStart, methodDecl.sourceEnd); 2514 } 2515 2516 // public void missingEnclosingInstanceSpecification(ReferenceBinding 2517 // enclosingType, ASTNode location) { 2518 // boolean insideConstructorCall = 2519 // (location instanceof ExplicitConstructorCall) 2520 // && (((ExplicitConstructorCall) location).accessMode == 2521 // ExplicitConstructorCall.ImplicitSuper); 2522 // 2523 // this.handle( 2524 // insideConstructorCall 2525 // ? IProblem.MissingEnclosingInstanceForConstructorCall 2526 // : IProblem.MissingEnclosingInstance, 2527 // new String[] {new String(enclosingType.readableName())}, 2528 // new String[] {new String(enclosingType.shortReadableName())}, 2529 // location.sourceStart, 2530 // location.sourceEnd); 2531 // } missingReturnType(AbstractMethodDeclaration methodDecl)2532 public void missingReturnType(AbstractMethodDeclaration methodDecl) { 2533 this.handle(IProblem.MissingReturnType, NoArgument, NoArgument, 2534 methodDecl.sourceStart, methodDecl.sourceEnd); 2535 } 2536 missingSemiColon(Expression expression)2537 public void missingSemiColon(Expression expression) { 2538 this.handle(IProblem.MissingSemiColon, NoArgument, NoArgument, 2539 expression.sourceStart, expression.sourceEnd); 2540 } 2541 mustDefineDimensionsOrInitializer( ArrayAllocationExpression expression)2542 public void mustDefineDimensionsOrInitializer( 2543 ArrayAllocationExpression expression) { 2544 this.handle(IProblem.MustDefineEitherDimensionExpressionsOrInitializer, 2545 NoArgument, NoArgument, expression.sourceStart, 2546 expression.sourceEnd); 2547 } 2548 mustSpecifyPackage(CompilationUnitDeclaration compUnitDecl)2549 public void mustSpecifyPackage(CompilationUnitDeclaration compUnitDecl) { 2550 String[] arguments = new String[] { new String(compUnitDecl 2551 .getFileName()) }; 2552 this.handle(IProblem.MustSpecifyPackage, arguments, arguments, 2553 compUnitDecl.sourceStart, compUnitDecl.sourceStart + 1); 2554 } 2555 mustUseAStaticMethod(MessageSend messageSend, MethodBinding method)2556 public void mustUseAStaticMethod(MessageSend messageSend, 2557 MethodBinding method) { 2558 this.handle(IProblem.StaticMethodRequested, new String[] { 2559 new String(method.declaringClass.readableName()), 2560 new String(method.selector), parametersAsString(method) }, 2561 new String[] { 2562 new String(method.declaringClass.shortReadableName()), 2563 new String(method.selector), 2564 parametersAsShortString(method) }, 2565 messageSend.sourceStart, messageSend.sourceEnd); 2566 } 2567 nativeMethodsCannotBeStrictfp(ReferenceBinding type, AbstractMethodDeclaration methodDecl)2568 public void nativeMethodsCannotBeStrictfp(ReferenceBinding type, 2569 AbstractMethodDeclaration methodDecl) { 2570 String[] arguments = new String[] { new String(type.sourceName()), 2571 new String(methodDecl.selector) }; 2572 this.handle(IProblem.NativeMethodsCannotBeStrictfp, arguments, 2573 arguments, methodDecl.sourceStart, methodDecl.sourceEnd); 2574 } 2575 needImplementation()2576 public void needImplementation() { 2577 this.abortDueToInternalError(Util.bind("abort.missingCode")); //$NON-NLS-1$ 2578 } 2579 needToEmulateFieldReadAccess(FieldBinding field, ASTNode location)2580 public void needToEmulateFieldReadAccess(FieldBinding field, 2581 ASTNode location) { 2582 this.handle(IProblem.NeedToEmulateFieldReadAccess, new String[] { 2583 new String(field.declaringClass.readableName()), 2584 new String(field.name) }, new String[] { 2585 new String(field.declaringClass.shortReadableName()), 2586 new String(field.name) }, location.sourceStart, 2587 location.sourceEnd); 2588 } 2589 needToEmulateFieldWriteAccess(FieldBinding field, ASTNode location)2590 public void needToEmulateFieldWriteAccess(FieldBinding field, 2591 ASTNode location) { 2592 this.handle(IProblem.NeedToEmulateFieldWriteAccess, new String[] { 2593 new String(field.declaringClass.readableName()), 2594 new String(field.name) }, new String[] { 2595 new String(field.declaringClass.shortReadableName()), 2596 new String(field.name) }, location.sourceStart, 2597 location.sourceEnd); 2598 } 2599 needToEmulateMethodAccess(MethodBinding method, ASTNode location)2600 public void needToEmulateMethodAccess(MethodBinding method, ASTNode location) { 2601 if (method.isConstructor()) 2602 this.handle(IProblem.NeedToEmulateConstructorAccess, new String[] { 2603 new String(method.declaringClass.readableName()), 2604 parametersAsString(method) }, new String[] { 2605 new String(method.declaringClass.shortReadableName()), 2606 parametersAsShortString(method) }, location.sourceStart, 2607 location.sourceEnd); 2608 else 2609 this.handle(IProblem.NeedToEmulateMethodAccess, new String[] { 2610 new String(method.declaringClass.readableName()), 2611 new String(method.selector), parametersAsString(method) }, 2612 new String[] { 2613 new String(method.declaringClass 2614 .shortReadableName()), 2615 new String(method.selector), 2616 parametersAsShortString(method) }, 2617 location.sourceStart, location.sourceEnd); 2618 } 2619 nestedClassCannotDeclareInterface(TypeDeclaration typeDecl)2620 public void nestedClassCannotDeclareInterface(TypeDeclaration typeDecl) { 2621 String[] arguments = new String[] { new String(typeDecl.name) }; 2622 this.handle(IProblem.CannotDefineInterfaceInLocalType, arguments, 2623 arguments, typeDecl.sourceStart, typeDecl.sourceEnd); 2624 } 2625 noMoreAvailableSpaceForArgument(LocalVariableBinding local, ASTNode location)2626 public void noMoreAvailableSpaceForArgument(LocalVariableBinding local, 2627 ASTNode location) { 2628 String[] arguments = new String[] { new String(local.name) }; 2629 this 2630 .handle( 2631 local instanceof SyntheticArgumentBinding ? IProblem.TooManySyntheticArgumentSlots 2632 : IProblem.TooManyArgumentSlots, arguments, 2633 arguments, Abort | Error, location.sourceStart, 2634 location.sourceEnd); 2635 } 2636 noMoreAvailableSpaceForLocal(LocalVariableBinding local, ASTNode location)2637 public void noMoreAvailableSpaceForLocal(LocalVariableBinding local, 2638 ASTNode location) { 2639 String[] arguments = new String[] { new String(local.name) }; 2640 this.handle(IProblem.TooManyLocalVariableSlots, arguments, arguments, 2641 Abort | Error, location.sourceStart, location.sourceEnd); 2642 } 2643 noSuchEnclosingInstance(TypeBinding targetType, ASTNode location, boolean isConstructorCall)2644 public void noSuchEnclosingInstance(TypeBinding targetType, 2645 ASTNode location, boolean isConstructorCall) { 2646 int id; 2647 if (isConstructorCall) { 2648 // 28 = No enclosing instance of type {0} is available due to some 2649 // intermediate constructor invocation 2650 id = IProblem.EnclosingInstanceInConstructorCall; 2651 } else if ((location instanceof ExplicitConstructorCall) 2652 && ((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper) { 2653 // 20 = No enclosing instance of type {0} is accessible to invoke 2654 // the super constructor. Must define a constructor and explicitly 2655 // qualify its super constructor invocation with an instance of {0} 2656 // (e.g. x.super() where x is an instance of {0}). 2657 id = IProblem.MissingEnclosingInstanceForConstructorCall; 2658 } else if (location instanceof AllocationExpression 2659 && (((AllocationExpression) location).binding.declaringClass 2660 .isMemberType() || (((AllocationExpression) location).binding.declaringClass 2661 .isAnonymousType() && ((AllocationExpression) location).binding.declaringClass 2662 .superclass().isMemberType()))) { 2663 // 21 = No enclosing instance of type {0} is accessible. Must 2664 // qualify the allocation with an enclosing instance of type {0} 2665 // (e.g. x.new A() where x is an instance of {0}). 2666 id = IProblem.MissingEnclosingInstance; 2667 } else { // default 2668 // 22 = No enclosing instance of the type {0} is accessible in 2669 // scope 2670 id = IProblem.IncorrectEnclosingInstanceReference; 2671 } 2672 this.handle(id, new String[] { new String(targetType.readableName()) }, 2673 new String[] { new String(targetType.shortReadableName()) }, 2674 location.sourceStart, location.sourceEnd); 2675 } 2676 notCompatibleTypesError(EqualExpression expression, TypeBinding leftType, TypeBinding rightType)2677 public void notCompatibleTypesError(EqualExpression expression, 2678 TypeBinding leftType, TypeBinding rightType) { 2679 String leftName = new String(leftType.readableName()); 2680 String rightName = new String(rightType.readableName()); 2681 String leftShortName = new String(leftType.shortReadableName()); 2682 String rightShortName = new String(rightType.shortReadableName()); 2683 if (leftShortName.equals(rightShortName)) { 2684 leftShortName = leftName; 2685 rightShortName = rightName; 2686 } 2687 this.handle(IProblem.IncompatibleTypesInEqualityOperator, new String[] { 2688 leftName, rightName }, new String[] { leftShortName, 2689 rightShortName }, expression.sourceStart, expression.sourceEnd); 2690 } 2691 notCompatibleTypesError(InstanceOfExpression expression, TypeBinding leftType, TypeBinding rightType)2692 public void notCompatibleTypesError(InstanceOfExpression expression, 2693 TypeBinding leftType, TypeBinding rightType) { 2694 String leftName = new String(leftType.readableName()); 2695 String rightName = new String(rightType.readableName()); 2696 String leftShortName = new String(leftType.shortReadableName()); 2697 String rightShortName = new String(rightType.shortReadableName()); 2698 if (leftShortName.equals(rightShortName)) { 2699 leftShortName = leftName; 2700 rightShortName = rightName; 2701 } 2702 this.handle(IProblem.IncompatibleTypesInConditionalOperator, 2703 new String[] { leftName, rightName }, new String[] { 2704 leftShortName, rightShortName }, 2705 expression.sourceStart, expression.sourceEnd); 2706 } 2707 objectCannotHaveSuperTypes(SourceTypeBinding type)2708 public void objectCannotHaveSuperTypes(SourceTypeBinding type) { 2709 this.handle(IProblem.ObjectCannotHaveSuperTypes, NoArgument, 2710 NoArgument, type.sourceStart(), type.sourceEnd()); 2711 } 2712 operatorOnlyValidOnNumericType(CompoundAssignment assignment, TypeBinding leftType, TypeBinding rightType)2713 public void operatorOnlyValidOnNumericType(CompoundAssignment assignment, 2714 TypeBinding leftType, TypeBinding rightType) { 2715 String leftName = new String(leftType.readableName()); 2716 String rightName = new String(rightType.readableName()); 2717 String leftShortName = new String(leftType.shortReadableName()); 2718 String rightShortName = new String(rightType.shortReadableName()); 2719 if (leftShortName.equals(rightShortName)) { 2720 leftShortName = leftName; 2721 rightShortName = rightName; 2722 } 2723 this.handle(IProblem.TypeMismatch, 2724 new String[] { leftName, rightName }, new String[] { 2725 leftShortName, rightShortName }, 2726 assignment.sourceStart, assignment.sourceEnd); 2727 } 2728 overridesDeprecatedMethod(MethodBinding localMethod, MethodBinding inheritedMethod)2729 public void overridesDeprecatedMethod(MethodBinding localMethod, 2730 MethodBinding inheritedMethod) { 2731 this.handle(IProblem.OverridingDeprecatedMethod, new String[] { 2732 new String(CharOperation.concat(localMethod.declaringClass 2733 .readableName(), localMethod.readableName(), '.')), 2734 new String(inheritedMethod.declaringClass.readableName()) }, 2735 new String[] { 2736 new String(CharOperation.concat( 2737 localMethod.declaringClass.shortReadableName(), 2738 localMethod.shortReadableName(), '.')), 2739 new String(inheritedMethod.declaringClass 2740 .shortReadableName()) }, localMethod 2741 .sourceStart(), localMethod.sourceEnd()); 2742 } 2743 overridesPackageDefaultMethod(MethodBinding localMethod, MethodBinding inheritedMethod)2744 public void overridesPackageDefaultMethod(MethodBinding localMethod, 2745 MethodBinding inheritedMethod) { 2746 this.handle(IProblem.OverridingNonVisibleMethod, new String[] { 2747 new String(CharOperation.concat(localMethod.declaringClass 2748 .readableName(), localMethod.readableName(), '.')), 2749 new String(inheritedMethod.declaringClass.readableName()) }, 2750 new String[] { 2751 new String(CharOperation.concat( 2752 localMethod.declaringClass.shortReadableName(), 2753 localMethod.shortReadableName(), '.')), 2754 new String(inheritedMethod.declaringClass 2755 .shortReadableName()) }, localMethod 2756 .sourceStart(), localMethod.sourceEnd()); 2757 } 2758 2759 // public void packageCollidesWithType(CompilationUnitDeclaration 2760 // compUnitDecl) { 2761 // String[] arguments = new String[]{CharOperation 2762 // .toString(compUnitDecl.currentPackage.tokens)}; 2763 // this.handle(IProblem.PackageCollidesWithType, arguments, arguments, 2764 // compUnitDecl.currentPackage.sourceStart, 2765 // compUnitDecl.currentPackage.sourceEnd); 2766 // } packageIsNotExpectedPackage( CompilationUnitDeclaration compUnitDecl)2767 public void packageIsNotExpectedPackage( 2768 CompilationUnitDeclaration compUnitDecl) { 2769 String[] arguments = new String[] { CharOperation 2770 .toString(compUnitDecl.compilationResult.compilationUnit 2771 .getPackageName()) }; 2772 this.handle(IProblem.PackageIsNotExpectedPackage, arguments, arguments, 2773 compUnitDecl.currentPackage == null ? 0 2774 : compUnitDecl.currentPackage.sourceStart, 2775 compUnitDecl.currentPackage == null ? 0 2776 : compUnitDecl.currentPackage.sourceEnd); 2777 } 2778 parametersAsString(MethodBinding method)2779 private String parametersAsString(MethodBinding method) { 2780 TypeBinding[] params = method.parameters; 2781 StringBuffer buffer = new StringBuffer(); 2782 for (int i = 0, length = params.length; i < length; i++) { 2783 if (i != 0) 2784 buffer.append(", "); //$NON-NLS-1$ 2785 buffer.append(new String(params[i].readableName())); 2786 } 2787 return buffer.toString(); 2788 } 2789 parametersAsShortString(MethodBinding method)2790 private String parametersAsShortString(MethodBinding method) { 2791 TypeBinding[] params = method.parameters; 2792 StringBuffer buffer = new StringBuffer(); 2793 for (int i = 0, length = params.length; i < length; i++) { 2794 if (i != 0) 2795 buffer.append(", "); //$NON-NLS-1$ 2796 buffer.append(new String(params[i].shortReadableName())); 2797 } 2798 return buffer.toString(); 2799 } 2800 parseError(int startPosition, int endPosition, char[] currentTokenSource, String errorTokenName, String[] possibleTokens)2801 public void parseError(int startPosition, int endPosition, 2802 char[] currentTokenSource, String errorTokenName, 2803 String[] possibleTokens) { 2804 if (possibleTokens.length == 0) { // no suggestion available 2805 if (isKeyword(currentTokenSource)) { 2806 String[] arguments = new String[] { new String( 2807 currentTokenSource) }; 2808 this.handle(IProblem.ParsingErrorOnKeywordNoSuggestion, 2809 arguments, arguments, 2810 // this is the current -invalid- token position 2811 startPosition, endPosition); 2812 return; 2813 } else { 2814 String[] arguments = new String[] { errorTokenName }; 2815 this.handle(IProblem.ParsingErrorNoSuggestion, arguments, 2816 arguments, 2817 // this is the current -invalid- token position 2818 startPosition, endPosition); 2819 return; 2820 } 2821 } 2822 // build a list of probable right tokens 2823 StringBuffer list = new StringBuffer(20); 2824 for (int i = 0, max = possibleTokens.length; i < max; i++) { 2825 if (i > 0) 2826 list.append(", "); //$NON-NLS-1$ 2827 list.append('"'); 2828 list.append(possibleTokens[i]); 2829 list.append('"'); 2830 } 2831 if (isKeyword(currentTokenSource)) { 2832 String[] arguments = new String[] { new String(currentTokenSource), 2833 list.toString() }; 2834 this.handle(IProblem.ParsingErrorOnKeyword, arguments, arguments, 2835 // this is the current -invalid- token position 2836 startPosition, endPosition); 2837 return; 2838 } 2839 // extract the literal when it's a literal 2840 if ((errorTokenName.equals("IntegerLiteral")) || //$NON-NLS-1$ 2841 (errorTokenName.equals("LongLiteral")) || //$NON-NLS-1$ 2842 (errorTokenName.equals("FloatingPointLiteral")) || //$NON-NLS-1$ 2843 (errorTokenName.equals("DoubleLiteral")) || //$NON-NLS-1$ 2844 (errorTokenName.equals("StringLiteral")) || //$NON-NLS-1$ 2845 (errorTokenName.equals("CharacterLiteral")) || //$NON-NLS-1$ 2846 (errorTokenName.equals("Identifier"))) { //$NON-NLS-1$ 2847 errorTokenName = new String(currentTokenSource); 2848 } 2849 String[] arguments = new String[] { errorTokenName, list.toString() }; 2850 this.handle(IProblem.ParsingError, arguments, arguments, 2851 // this is the current -invalid- token position 2852 startPosition, endPosition); 2853 } 2854 publicClassMustMatchFileName( CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl)2855 public void publicClassMustMatchFileName( 2856 CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) { 2857 this.referenceContext = typeDecl; // report the problem against the 2858 // type not the entire compilation 2859 // unit 2860 String[] arguments = new String[] { 2861 new String(compUnitDecl.getFileName()), 2862 new String(typeDecl.name) }; 2863 this.handle(IProblem.PublicClassMustMatchFileName, arguments, 2864 arguments, typeDecl.sourceStart, typeDecl.sourceEnd, 2865 compUnitDecl.compilationResult); 2866 } 2867 recursiveConstructorInvocation( ExplicitConstructorCall constructorCall)2868 public void recursiveConstructorInvocation( 2869 ExplicitConstructorCall constructorCall) { 2870 this.handle(IProblem.RecursiveConstructorInvocation, new String[] { 2871 new String(constructorCall.binding.declaringClass 2872 .readableName()), 2873 parametersAsString(constructorCall.binding) }, new String[] { 2874 new String(constructorCall.binding.declaringClass 2875 .shortReadableName()), 2876 parametersAsShortString(constructorCall.binding) }, 2877 constructorCall.sourceStart, constructorCall.sourceEnd); 2878 } 2879 redefineArgument(Argument arg)2880 public void redefineArgument(Argument arg) { 2881 String[] arguments = new String[] { new String(arg.name) }; 2882 this.handle(IProblem.RedefinedArgument, arguments, arguments, 2883 arg.sourceStart, arg.sourceEnd); 2884 } 2885 redefineLocal(LocalDeclaration localDecl)2886 public void redefineLocal(LocalDeclaration localDecl) { 2887 String[] arguments = new String[] { new String(localDecl.name) }; 2888 this.handle(IProblem.RedefinedLocal, arguments, arguments, 2889 localDecl.sourceStart, localDecl.sourceEnd); 2890 } 2891 referenceMustBeArrayTypeAt(TypeBinding arrayType, ArrayReference arrayRef)2892 public void referenceMustBeArrayTypeAt(TypeBinding arrayType, 2893 ArrayReference arrayRef) { 2894 this.handle(IProblem.ArrayReferenceRequired, new String[] { new String( 2895 arrayType.readableName()) }, new String[] { new String( 2896 arrayType.shortReadableName()) }, arrayRef.sourceStart, 2897 arrayRef.sourceEnd); 2898 } 2899 returnTypeCannotBeVoidArray(SourceTypeBinding type, MethodDeclaration methodDecl)2900 public void returnTypeCannotBeVoidArray(SourceTypeBinding type, 2901 MethodDeclaration methodDecl) { 2902 String[] arguments = new String[] { new String(methodDecl.selector) }; 2903 this.handle(IProblem.ReturnTypeCannotBeVoidArray, arguments, arguments, 2904 methodDecl.sourceStart, methodDecl.sourceEnd); 2905 } 2906 returnTypeProblem(SourceTypeBinding type, MethodDeclaration methodDecl, TypeBinding expectedType)2907 public void returnTypeProblem(SourceTypeBinding type, 2908 MethodDeclaration methodDecl, TypeBinding expectedType) { 2909 int problemId = expectedType.problemId(); 2910 int id; 2911 switch (problemId) { 2912 case NotFound: 2913 // 1 2914 id = IProblem.ReturnTypeNotFound; 2915 break; 2916 case NotVisible: 2917 // 2 2918 id = IProblem.ReturnTypeNotVisible; 2919 break; 2920 case Ambiguous: 2921 // 3 2922 id = IProblem.ReturnTypeAmbiguous; 2923 break; 2924 case InternalNameProvided: 2925 // 4 2926 id = IProblem.ReturnTypeInternalNameProvided; 2927 break; 2928 case InheritedNameHidesEnclosingName: 2929 // 5 2930 id = IProblem.ReturnTypeInheritedNameHidesEnclosingName; 2931 break; 2932 case NoError: 2933 // 0 2934 default: 2935 needImplementation(); // want to fail to see why we were 2936 // here... 2937 return; 2938 } 2939 this.handle(id, new String[] { new String(methodDecl.selector), 2940 new String(expectedType.readableName()) }, new String[] { 2941 new String(methodDecl.selector), 2942 new String(expectedType.shortReadableName()) }, 2943 methodDecl.returnType.sourceStart, 2944 methodDecl.returnType.sourceEnd); 2945 } 2946 scannerError(Parser parser, String errorTokenName)2947 public void scannerError(Parser parser, String errorTokenName) { 2948 Scanner scanner = parser.scanner; 2949 int flag = IProblem.ParsingErrorNoSuggestion; 2950 int startPos = scanner.startPosition; 2951 // special treatment for recognized errors.... 2952 if (errorTokenName.equals(Scanner.END_OF_SOURCE)) 2953 flag = IProblem.EndOfSource; 2954 else if (errorTokenName.equals(Scanner.INVALID_HEXA)) 2955 flag = IProblem.InvalidHexa; 2956 else if (errorTokenName.equals(Scanner.INVALID_OCTAL)) 2957 flag = IProblem.InvalidOctal; 2958 else if (errorTokenName.equals(Scanner.INVALID_CHARACTER_CONSTANT)) 2959 flag = IProblem.InvalidCharacterConstant; 2960 else if (errorTokenName.equals(Scanner.INVALID_ESCAPE)) 2961 flag = IProblem.InvalidEscape; 2962 else if (errorTokenName.equals(Scanner.INVALID_UNICODE_ESCAPE)) { 2963 flag = IProblem.InvalidUnicodeEscape; 2964 // better locate the error message 2965 char[] source = scanner.source; 2966 int checkPos = scanner.currentPosition - 1; 2967 if (checkPos >= source.length) 2968 checkPos = source.length - 1; 2969 while (checkPos >= startPos) { 2970 if (source[checkPos] == '\\') 2971 break; 2972 checkPos--; 2973 } 2974 startPos = checkPos; 2975 } else if (errorTokenName.equals(Scanner.INVALID_FLOAT)) 2976 flag = IProblem.InvalidFloat; 2977 else if (errorTokenName.equals(Scanner.UNTERMINATED_STRING)) 2978 flag = IProblem.UnterminatedString; 2979 else if (errorTokenName.equals(Scanner.UNTERMINATED_COMMENT)) 2980 flag = IProblem.UnterminatedComment; 2981 else if (errorTokenName.equals(Scanner.INVALID_CHAR_IN_STRING)) 2982 flag = IProblem.UnterminatedString; 2983 String[] arguments = flag == IProblem.ParsingErrorNoSuggestion ? new String[] { errorTokenName } 2984 : NoArgument; 2985 this.handle(flag, arguments, arguments, 2986 // this is the current -invalid- token position 2987 startPos, scanner.currentPosition - 1, 2988 parser.compilationUnit.compilationResult); 2989 } 2990 shouldReturn(TypeBinding returnType, ASTNode location)2991 public void shouldReturn(TypeBinding returnType, ASTNode location) { 2992 this.handle(IProblem.ShouldReturnValue, new String[] { new String( 2993 returnType.readableName()) }, new String[] { new String( 2994 returnType.shortReadableName()) }, location.sourceStart, 2995 location.sourceEnd); 2996 } 2997 signalNoImplicitStringConversionForCharArrayExpression( Expression expression)2998 public void signalNoImplicitStringConversionForCharArrayExpression( 2999 Expression expression) { 3000 this.handle(IProblem.NoImplicitStringConversionForCharArrayExpression, 3001 NoArgument, NoArgument, expression.sourceStart, 3002 expression.sourceEnd); 3003 } 3004 staticAndInstanceConflict(MethodBinding currentMethod, MethodBinding inheritedMethod)3005 public void staticAndInstanceConflict(MethodBinding currentMethod, 3006 MethodBinding inheritedMethod) { 3007 if (currentMethod.isStatic()) 3008 this.handle( 3009 // This static method cannot hide the instance method from 3010 // %1 3011 // 8.4.6.4 - If a class inherits more than one method with 3012 // the same signature a static (non-abstract) method cannot 3013 // hide an instance method. 3014 IProblem.CannotHideAnInstanceMethodWithAStaticMethod, 3015 new String[] { new String(inheritedMethod.declaringClass 3016 .readableName()) }, 3017 new String[] { new String(inheritedMethod.declaringClass 3018 .shortReadableName()) }, currentMethod 3019 .sourceStart(), currentMethod.sourceEnd()); 3020 else 3021 this.handle( 3022 // This instance method cannot override the static method 3023 // from %1 3024 // 8.4.6.4 - If a class inherits more than one method with 3025 // the same signature an instance (non-abstract) method 3026 // cannot override a static method. 3027 IProblem.CannotOverrideAStaticMethodWithAnInstanceMethod, 3028 new String[] { new String(inheritedMethod.declaringClass 3029 .readableName()) }, 3030 new String[] { new String(inheritedMethod.declaringClass 3031 .shortReadableName()) }, currentMethod 3032 .sourceStart(), currentMethod.sourceEnd()); 3033 } 3034 staticFieldAccessToNonStaticVariable(FieldReference fieldRef, FieldBinding field)3035 public void staticFieldAccessToNonStaticVariable(FieldReference fieldRef, 3036 FieldBinding field) { 3037 String[] arguments = new String[] { new String(field.readableName()) }; 3038 this.handle(IProblem.NonStaticFieldFromStaticInvocation, arguments, 3039 arguments, fieldRef.sourceStart, fieldRef.sourceEnd); 3040 } 3041 staticFieldAccessToNonStaticVariable( QualifiedNameReference nameRef, FieldBinding field)3042 public void staticFieldAccessToNonStaticVariable( 3043 QualifiedNameReference nameRef, FieldBinding field) { 3044 String[] arguments = new String[] { new String(field.readableName()) }; 3045 this.handle(IProblem.NonStaticFieldFromStaticInvocation, arguments, 3046 arguments, nameRef.sourceStart, nameRef.sourceEnd); 3047 } 3048 staticFieldAccessToNonStaticVariable( SingleNameReference nameRef, FieldBinding field)3049 public void staticFieldAccessToNonStaticVariable( 3050 SingleNameReference nameRef, FieldBinding field) { 3051 String[] arguments = new String[] { new String(field.readableName()) }; 3052 this.handle(IProblem.NonStaticFieldFromStaticInvocation, arguments, 3053 arguments, nameRef.sourceStart, nameRef.sourceEnd); 3054 } 3055 staticInheritedMethodConflicts(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods)3056 public void staticInheritedMethodConflicts(SourceTypeBinding type, 3057 MethodBinding concreteMethod, MethodBinding[] abstractMethods) { 3058 this.handle( 3059 // The static method %1 conflicts with the abstract method in %2 3060 // 8.4.6.4 - If a class inherits more than one method with the 3061 // same signature it is an error for one to be static 3062 // (non-abstract) and the other abstract. 3063 IProblem.StaticInheritedMethodConflicts, new String[] { 3064 new String(concreteMethod.readableName()), 3065 new String(abstractMethods[0].declaringClass 3066 .readableName()) }, new String[] { 3067 new String(concreteMethod.readableName()), 3068 new String(abstractMethods[0].declaringClass 3069 .shortReadableName()) }, type.sourceStart(), 3070 type.sourceEnd()); 3071 } 3072 stringConstantIsExceedingUtf8Limit(ASTNode location)3073 public void stringConstantIsExceedingUtf8Limit(ASTNode location) { 3074 this.handle(IProblem.StringConstantIsExceedingUtf8Limit, NoArgument, 3075 NoArgument, location.sourceStart, location.sourceEnd); 3076 } 3077 superclassMustBeAClass(SourceTypeBinding type, TypeReference superclassRef, ReferenceBinding superType)3078 public void superclassMustBeAClass(SourceTypeBinding type, 3079 TypeReference superclassRef, ReferenceBinding superType) { 3080 this.handle(IProblem.SuperclassMustBeAClass, new String[] { 3081 new String(superType.readableName()), 3082 new String(type.sourceName()) }, new String[] { 3083 new String(superType.shortReadableName()), 3084 new String(type.sourceName()) }, superclassRef.sourceStart, 3085 superclassRef.sourceEnd); 3086 } 3087 superinterfaceMustBeAnInterface(SourceTypeBinding type, TypeDeclaration typeDecl, ReferenceBinding superType)3088 public void superinterfaceMustBeAnInterface(SourceTypeBinding type, 3089 TypeDeclaration typeDecl, ReferenceBinding superType) { 3090 this.handle(IProblem.SuperInterfaceMustBeAnInterface, new String[] { 3091 new String(superType.readableName()), 3092 new String(type.sourceName()) }, new String[] { 3093 new String(superType.shortReadableName()), 3094 new String(type.sourceName()) }, typeDecl.sourceStart, 3095 typeDecl.sourceEnd); 3096 } 3097 task(String tag, String message, String priority, int start, int end)3098 public void task(String tag, String message, String priority, int start, 3099 int end) { 3100 this.handle(IProblem.Task, new String[] { tag, message, priority /* 3101 * secret 3102 * argument 3103 * that 3104 * is 3105 * not 3106 * surfaced 3107 * in 3108 * getMessage() 3109 */}, new String[] { tag, message, priority /* 3110 * secret argument that is 3111 * not surfaced in 3112 * getMessage() 3113 */}, start, end); 3114 } 3115 tooManyDimensions(ASTNode expression)3116 public void tooManyDimensions(ASTNode expression) { 3117 this.handle(IProblem.TooManyArrayDimensions, NoArgument, NoArgument, 3118 expression.sourceStart, expression.sourceEnd); 3119 } 3120 tooManyFields(TypeDeclaration typeDeclaration)3121 public void tooManyFields(TypeDeclaration typeDeclaration) { 3122 this.handle(IProblem.TooManyFields, new String[] { new String( 3123 typeDeclaration.binding.readableName()) }, 3124 new String[] { new String(typeDeclaration.binding 3125 .shortReadableName()) }, Abort | Error, 3126 typeDeclaration.sourceStart, typeDeclaration.sourceEnd); 3127 } 3128 tooManyMethods(TypeDeclaration typeDeclaration)3129 public void tooManyMethods(TypeDeclaration typeDeclaration) { 3130 this.handle(IProblem.TooManyMethods, new String[] { new String( 3131 typeDeclaration.binding.readableName()) }, 3132 new String[] { new String(typeDeclaration.binding 3133 .shortReadableName()) }, Abort | Error, 3134 typeDeclaration.sourceStart, typeDeclaration.sourceEnd); 3135 } 3136 typeCastError(CastExpression expression, TypeBinding leftType, TypeBinding rightType)3137 public void typeCastError(CastExpression expression, TypeBinding leftType, 3138 TypeBinding rightType) { 3139 String leftName = new String(leftType.readableName()); 3140 String rightName = new String(rightType.readableName()); 3141 String leftShortName = new String(leftType.shortReadableName()); 3142 String rightShortName = new String(rightType.shortReadableName()); 3143 if (leftShortName.equals(rightShortName)) { 3144 leftShortName = leftName; 3145 rightShortName = rightName; 3146 } 3147 this.handle(IProblem.IllegalCast, new String[] { rightName, leftName }, 3148 new String[] { rightShortName, leftShortName }, 3149 expression.sourceStart, expression.sourceEnd); 3150 } 3151 typeCollidesWithPackage( CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl)3152 public void typeCollidesWithPackage( 3153 CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) { 3154 this.referenceContext = typeDecl; // report the problem against the 3155 // type not the entire compilation 3156 // unit 3157 String[] arguments = new String[] { 3158 new String(compUnitDecl.getFileName()), 3159 new String(typeDecl.name) }; 3160 this.handle(IProblem.TypeCollidesWithPackage, arguments, arguments, 3161 typeDecl.sourceStart, typeDecl.sourceEnd, 3162 compUnitDecl.compilationResult); 3163 } 3164 typeMismatchError(TypeBinding resultType, TypeBinding expectedType, ASTNode location)3165 public void typeMismatchError(TypeBinding resultType, 3166 TypeBinding expectedType, ASTNode location) { 3167 String resultTypeName = new String(resultType.readableName()); 3168 String expectedTypeName = new String(expectedType.readableName()); 3169 String resultTypeShortName = new String(resultType.shortReadableName()); 3170 String expectedTypeShortName = new String(expectedType 3171 .shortReadableName()); 3172 if (resultTypeShortName.equals(expectedTypeShortName)) { 3173 resultTypeShortName = resultTypeName; 3174 expectedTypeShortName = expectedTypeName; 3175 } 3176 this.handle(IProblem.TypeMismatch, new String[] { resultTypeName, 3177 expectedTypeName }, new String[] { resultTypeShortName, 3178 expectedTypeShortName }, location.sourceStart, 3179 location.sourceEnd); 3180 } 3181 typeMismatchErrorActualTypeExpectedType(Expression expression, TypeBinding constantType, TypeBinding expectedType)3182 public void typeMismatchErrorActualTypeExpectedType(Expression expression, 3183 TypeBinding constantType, TypeBinding expectedType) { 3184 String constantTypeName = new String(constantType.readableName()); 3185 String expectedTypeName = new String(expectedType.readableName()); 3186 String constantTypeShortName = new String(constantType 3187 .shortReadableName()); 3188 String expectedTypeShortName = new String(expectedType 3189 .shortReadableName()); 3190 if (constantTypeShortName.equals(expectedTypeShortName)) { 3191 constantTypeShortName = constantTypeName; 3192 expectedTypeShortName = expectedTypeName; 3193 } 3194 this.handle(IProblem.TypeMismatch, new String[] { constantTypeName, 3195 expectedTypeName }, new String[] { constantTypeShortName, 3196 expectedTypeShortName }, expression.sourceStart, 3197 expression.sourceEnd); 3198 } 3199 3200 // public void undefinedLabel(BranchStatement statement) { 3201 // String[] arguments = new String[] { new String(statement.label) }; 3202 // this.handle(IProblem.UndefinedLabel, arguments, arguments, 3203 // statement.sourceStart, statement.sourceEnd); 3204 // } 3205 unexpectedStaticModifierForField(SourceTypeBinding type, FieldDeclaration fieldDecl)3206 public void unexpectedStaticModifierForField(SourceTypeBinding type, 3207 FieldDeclaration fieldDecl) { 3208 String[] arguments = new String[] { fieldDecl.name() }; 3209 this.handle(IProblem.UnexpectedStaticModifierForField, arguments, 3210 arguments, fieldDecl.sourceStart, fieldDecl.sourceEnd); 3211 } 3212 unexpectedStaticModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl)3213 public void unexpectedStaticModifierForMethod(ReferenceBinding type, 3214 AbstractMethodDeclaration methodDecl) { 3215 String[] arguments = new String[] { new String(type.sourceName()), 3216 new String(methodDecl.selector) }; 3217 this.handle(IProblem.UnexpectedStaticModifierForMethod, arguments, 3218 arguments, methodDecl.sourceStart, methodDecl.sourceEnd); 3219 } 3220 unhandledException(TypeBinding exceptionType, ASTNode location)3221 public void unhandledException(TypeBinding exceptionType, ASTNode location) { 3222 boolean insideDefaultConstructor = (referenceContext instanceof ConstructorDeclaration) 3223 && ((ConstructorDeclaration) referenceContext) 3224 .isDefaultConstructor(); 3225 boolean insideImplicitConstructorCall = (location instanceof ExplicitConstructorCall) 3226 && (((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper); 3227 this 3228 .handle( 3229 insideDefaultConstructor ? IProblem.UnhandledExceptionInDefaultConstructor 3230 : (insideImplicitConstructorCall ? IProblem.UndefinedConstructorInImplicitConstructorCall 3231 : IProblem.UnhandledException), 3232 new String[] { new String(exceptionType.readableName()) }, 3233 new String[] { new String(exceptionType 3234 .shortReadableName()) }, location.sourceStart, 3235 location.sourceEnd); 3236 } 3237 uninitializedBlankFinalField(FieldBinding binding, ASTNode location)3238 public void uninitializedBlankFinalField(FieldBinding binding, 3239 ASTNode location) { 3240 String[] arguments = new String[] { new String(binding.readableName()) }; 3241 this.handle(IProblem.UninitializedBlankFinalField, arguments, 3242 arguments, location.sourceStart, location.sourceEnd); 3243 } 3244 unmatchedBracket(int position, ReferenceContext context, CompilationResult compilationResult)3245 public void unmatchedBracket(int position, ReferenceContext context, 3246 CompilationResult compilationResult) { 3247 this.handle(IProblem.UnmatchedBracket, NoArgument, NoArgument, 3248 position, position, context, compilationResult); 3249 } 3250 unnecessaryEnclosingInstanceSpecification( Expression expression, ReferenceBinding targetType)3251 public void unnecessaryEnclosingInstanceSpecification( 3252 Expression expression, ReferenceBinding targetType) { 3253 this.handle(IProblem.IllegalEnclosingInstanceSpecification, 3254 new String[] { new String(targetType.readableName()) }, 3255 new String[] { new String(targetType.shortReadableName()) }, 3256 expression.sourceStart, expression.sourceEnd); 3257 } 3258 unnecessaryReceiverForStaticMethod(ASTNode location, MethodBinding method)3259 public void unnecessaryReceiverForStaticMethod(ASTNode location, 3260 MethodBinding method) { 3261 this.handle(IProblem.NonStaticAccessToStaticMethod, new String[] { 3262 new String(method.declaringClass.readableName()), 3263 new String(method.selector), parametersAsString(method) }, 3264 new String[] { 3265 new String(method.declaringClass.shortReadableName()), 3266 new String(method.selector), 3267 parametersAsShortString(method) }, 3268 location.sourceStart, location.sourceEnd); 3269 } 3270 unnecessaryReceiverForStaticField(ASTNode location, FieldBinding field)3271 public void unnecessaryReceiverForStaticField(ASTNode location, 3272 FieldBinding field) { 3273 this.handle(IProblem.NonStaticAccessToStaticField, new String[] { 3274 new String(field.declaringClass.readableName()), 3275 new String(field.name) }, new String[] { 3276 new String(field.declaringClass.shortReadableName()), 3277 new String(field.name) }, location.sourceStart, 3278 location.sourceEnd); 3279 } 3280 unreachableExceptionHandler(ReferenceBinding exceptionType, ASTNode location)3281 public void unreachableExceptionHandler(ReferenceBinding exceptionType, 3282 ASTNode location) { 3283 this.handle(IProblem.UnreachableCatch, NoArgument, NoArgument, 3284 location.sourceStart, location.sourceEnd); 3285 } 3286 unresolvableReference(NameReference nameRef, Binding binding)3287 public void unresolvableReference(NameReference nameRef, Binding binding) { 3288 int severity = Error; 3289 /* 3290 * also need to check that the searchedType is the receiver type if 3291 * (binding instanceof ProblemBinding) { ProblemBinding problem = 3292 * (ProblemBinding) binding; if (problem.searchType != null && 3293 * problem.searchType.isHierarchyInconsistent()) severity = 3294 * SecondaryError; } 3295 */ 3296 String[] arguments = new String[] { new String(binding.readableName()) }; 3297 this.handle(IProblem.UndefinedName, arguments, arguments, severity, 3298 nameRef.sourceStart, nameRef.sourceEnd); 3299 } 3300 unusedArgument(LocalDeclaration localDecl)3301 public void unusedArgument(LocalDeclaration localDecl) { 3302 String[] arguments = new String[] { localDecl.name() }; 3303 this.handle(IProblem.ArgumentIsNeverUsed, arguments, arguments, 3304 localDecl.sourceStart, localDecl.sourceEnd); 3305 } 3306 3307 // public void unusedImport(ImportReference importRef) { 3308 // String[] arguments = new 3309 // String[]{CharOperation.toString(importRef.tokens)}; 3310 // this.handle(IProblem.UnusedImport, arguments, arguments, 3311 // importRef.sourceStart, importRef.sourceEnd); 3312 // } unusedLocalVariable(LocalDeclaration localDecl)3313 public void unusedLocalVariable(LocalDeclaration localDecl) { 3314 String[] arguments = new String[] { localDecl.name() }; 3315 this.handle(IProblem.LocalVariableIsNeverUsed, arguments, arguments, 3316 localDecl.sourceStart, localDecl.sourceEnd); 3317 } 3318 unusedPrivateConstructor(ConstructorDeclaration constructorDecl)3319 public void unusedPrivateConstructor(ConstructorDeclaration constructorDecl) { 3320 if (computeSeverity(IProblem.UnusedPrivateConstructor) == Ignore) 3321 return; 3322 // no complaint for no-arg constructors (or default ones) - known 3323 // pattern to block instantiation 3324 if (constructorDecl.arguments == null 3325 || constructorDecl.arguments.length == 0) 3326 return; 3327 MethodBinding constructor = constructorDecl.binding; 3328 this.handle(IProblem.UnusedPrivateConstructor, new String[] { 3329 new String(constructor.declaringClass.readableName()), 3330 parametersAsString(constructor) }, new String[] { 3331 new String(constructor.declaringClass.shortReadableName()), 3332 parametersAsShortString(constructor) }, 3333 constructorDecl.sourceStart, constructorDecl.sourceEnd); 3334 } 3335 unusedPrivateField(FieldDeclaration fieldDecl)3336 public void unusedPrivateField(FieldDeclaration fieldDecl) { 3337 if (computeSeverity(IProblem.UnusedPrivateField) == Ignore) 3338 return; 3339 FieldBinding field = fieldDecl.binding; 3340 if (CharOperation.equals(TypeConstants.SERIALVERSIONUID, field.name) 3341 && field.isStatic() && field.isFinal() 3342 && TypeBinding.LongBinding == field.type) { 3343 return; // do not report unused serialVersionUID field 3344 } 3345 this.handle(IProblem.UnusedPrivateField, new String[] { 3346 new String(field.declaringClass.readableName()), 3347 new String(field.name), }, new String[] { 3348 new String(field.declaringClass.shortReadableName()), 3349 new String(field.name), }, fieldDecl.sourceStart, 3350 fieldDecl.sourceEnd); 3351 } 3352 unusedPrivateMethod(AbstractMethodDeclaration methodDecl)3353 public void unusedPrivateMethod(AbstractMethodDeclaration methodDecl) { 3354 if (computeSeverity(IProblem.UnusedPrivateMethod) == Ignore) 3355 return; 3356 MethodBinding method = methodDecl.binding; 3357 // no report for serialization support 'void 3358 // readObject(ObjectInputStream)' 3359 if (!method.isStatic() 3360 && TypeBinding.VoidBinding == method.returnType 3361 && method.parameters.length == 1 3362 && method.parameters[0].dimensions() == 0 3363 && CharOperation.equals(method.selector, 3364 TypeConstants.READOBJECT) 3365 && CharOperation.equals( 3366 TypeConstants.CharArray_JAVA_IO_OBJECTINPUTSTREAM, 3367 method.parameters[0].readableName())) { 3368 return; 3369 } 3370 // no report for serialization support 'void 3371 // writeObject(ObjectOutputStream)' 3372 if (!method.isStatic() 3373 && TypeBinding.VoidBinding == method.returnType 3374 && method.parameters.length == 1 3375 && method.parameters[0].dimensions() == 0 3376 && CharOperation.equals(method.selector, 3377 TypeConstants.WRITEOBJECT) 3378 && CharOperation.equals( 3379 TypeConstants.CharArray_JAVA_IO_OBJECTOUTPUTSTREAM, 3380 method.parameters[0].readableName())) { 3381 return; 3382 } 3383 // no report for serialization support 'Object readResolve()' 3384 if (!method.isStatic() 3385 && TypeBinding.T_Object == method.returnType.id 3386 && method.parameters.length == 0 3387 && CharOperation.equals(method.selector, 3388 TypeConstants.READRESOLVE)) { 3389 return; 3390 } 3391 // no report for serialization support 'Object writeReplace()' 3392 if (!method.isStatic() 3393 && TypeBinding.T_Object == method.returnType.id 3394 && method.parameters.length == 0 3395 && CharOperation.equals(method.selector, 3396 TypeConstants.WRITEREPLACE)) { 3397 return; 3398 } 3399 this.handle(IProblem.UnusedPrivateMethod, new String[] { 3400 new String(method.declaringClass.readableName()), 3401 new String(method.selector), parametersAsString(method) }, 3402 new String[] { 3403 new String(method.declaringClass.shortReadableName()), 3404 new String(method.selector), 3405 parametersAsShortString(method) }, 3406 methodDecl.sourceStart, methodDecl.sourceEnd); 3407 } 3408 unusedPrivateType(TypeDeclaration typeDecl)3409 public void unusedPrivateType(TypeDeclaration typeDecl) { 3410 if (computeSeverity(IProblem.UnusedPrivateType) == Ignore) 3411 return; 3412 ReferenceBinding type = typeDecl.binding; 3413 this.handle(IProblem.UnusedPrivateType, new String[] { new String(type 3414 .readableName()), }, new String[] { new String(type 3415 .shortReadableName()), }, typeDecl.sourceStart, 3416 typeDecl.sourceEnd); 3417 } 3418 useAssertAsAnIdentifier(int sourceStart, int sourceEnd)3419 public void useAssertAsAnIdentifier(int sourceStart, int sourceEnd) { 3420 this.handle(IProblem.UseAssertAsAnIdentifier, NoArgument, NoArgument, 3421 sourceStart, sourceEnd); 3422 } 3423 variableTypeCannotBeVoid(AbstractVariableDeclaration varDecl)3424 public void variableTypeCannotBeVoid(AbstractVariableDeclaration varDecl) { 3425 String[] arguments = new String[] { new String(varDecl.name) }; 3426 this.handle(IProblem.VariableTypeCannotBeVoid, arguments, arguments, 3427 varDecl.sourceStart, varDecl.sourceEnd); 3428 } 3429 variableTypeCannotBeVoidArray( AbstractVariableDeclaration varDecl)3430 public void variableTypeCannotBeVoidArray( 3431 AbstractVariableDeclaration varDecl) { 3432 String[] arguments = new String[] { new String(varDecl.name) }; 3433 this.handle(IProblem.VariableTypeCannotBeVoidArray, arguments, 3434 arguments, varDecl.sourceStart, varDecl.sourceEnd); 3435 } 3436 visibilityConflict(MethodBinding currentMethod, MethodBinding inheritedMethod)3437 public void visibilityConflict(MethodBinding currentMethod, 3438 MethodBinding inheritedMethod) { 3439 this.handle( 3440 // Cannot reduce the visibility of the inherited method from %1 3441 // 8.4.6.3 - The access modifier of an hiding method must 3442 // provide at least as much access as the hidden method. 3443 // 8.4.6.3 - The access modifier of an overiding method must 3444 // provide at least as much access as the overriden method. 3445 IProblem.MethodReducesVisibility, new String[] { new String( 3446 inheritedMethod.declaringClass.readableName()) }, 3447 new String[] { new String(inheritedMethod.declaringClass 3448 .shortReadableName()) }, currentMethod.sourceStart(), 3449 currentMethod.sourceEnd()); 3450 } 3451 wrongSequenceOfExceptionTypesError(TryStatement statement, int under, int upper)3452 public void wrongSequenceOfExceptionTypesError(TryStatement statement, 3453 int under, int upper) { 3454 // the two catch block under and upper are in an incorrect order. 3455 // under should be define BEFORE upper in the source 3456 TypeReference typeRef = statement.catchArguments[under].type; 3457 this.handle(IProblem.UnreachableCatch, NoArgument, NoArgument, 3458 typeRef.sourceStart, typeRef.sourceEnd); 3459 } 3460 nonExternalizedStringLiteral(ASTNode location)3461 public void nonExternalizedStringLiteral(ASTNode location) { 3462 this.handle(IProblem.NonExternalizedStringLiteral, NoArgument, 3463 NoArgument, location.sourceStart, location.sourceEnd); 3464 } 3465 noMoreAvailableSpaceForConstant(TypeDeclaration typeDeclaration)3466 public void noMoreAvailableSpaceForConstant(TypeDeclaration typeDeclaration) { 3467 this.handle(IProblem.TooManyBytesForStringConstant, 3468 new String[] { new String(typeDeclaration.binding 3469 .readableName()) }, new String[] { new String( 3470 typeDeclaration.binding.shortReadableName()) }, Abort 3471 | Error, typeDeclaration.sourceStart, 3472 typeDeclaration.sourceEnd); 3473 } 3474 noMoreAvailableSpaceInConstantPool( TypeDeclaration typeDeclaration)3475 public void noMoreAvailableSpaceInConstantPool( 3476 TypeDeclaration typeDeclaration) { 3477 this.handle(IProblem.TooManyConstantsInConstantPool, 3478 new String[] { new String(typeDeclaration.binding 3479 .readableName()) }, new String[] { new String( 3480 typeDeclaration.binding.shortReadableName()) }, Abort 3481 | Error, typeDeclaration.sourceStart, 3482 typeDeclaration.sourceEnd); 3483 } 3484 isKeyword(char[] tokenSource)3485 private boolean isKeyword(char[] tokenSource) { 3486 /* 3487 * This code is heavily grammar dependant 3488 */ 3489 if (tokenSource == null) { 3490 return false; 3491 } 3492 try { 3493 Scanner scanner = new Scanner(); 3494 scanner.setSource(tokenSource); 3495 int token = scanner.getNextToken(); 3496 char[] currentKeyword; 3497 try { 3498 currentKeyword = scanner.getCurrentIdentifierSource(); 3499 } catch (ArrayIndexOutOfBoundsException e) { 3500 return false; 3501 } 3502 int nextToken = scanner.getNextToken(); 3503 if (nextToken == Scanner.TokenNameEOF 3504 && scanner.startPosition == scanner.source.length) { // to 3505 // handle 3506 // case 3507 // where 3508 // we 3509 // had 3510 // an 3511 // ArrayIndexOutOfBoundsException 3512 // while reading the last token 3513 switch (token) { 3514 case Scanner.TokenNameERROR: 3515 if (CharOperation.equals("goto".toCharArray(), 3516 currentKeyword) 3517 || CharOperation.equals( 3518 "const".toCharArray(), currentKeyword)) { //$NON-NLS-1$ //$NON-NLS-2$ 3519 return true; 3520 } else { 3521 return false; 3522 } 3523 case Scanner.TokenNameabstract: 3524 // case Scanner.TokenNameassert: 3525 // case Scanner.TokenNamebyte: 3526 case Scanner.TokenNamebreak: 3527 // case Scanner.TokenNameboolean: 3528 case Scanner.TokenNamecase: 3529 // case Scanner.TokenNamechar: 3530 case Scanner.TokenNamecatch: 3531 case Scanner.TokenNameclass: 3532 case Scanner.TokenNamecontinue: 3533 case Scanner.TokenNamedo: 3534 // case Scanner.TokenNamedouble: 3535 case Scanner.TokenNamedefault: 3536 case Scanner.TokenNameelse: 3537 case Scanner.TokenNameextends: 3538 case Scanner.TokenNamefor: 3539 // case Scanner.TokenNamefinal: 3540 // case Scanner.TokenNamefloat: 3541 // case Scanner.TokenNamefalse : 3542 case Scanner.TokenNamefinally: 3543 case Scanner.TokenNameif: 3544 // case Scanner.TokenNameint: 3545 // case Scanner.TokenNameimport: 3546 case Scanner.TokenNameinterface: 3547 case Scanner.TokenNameimplements: 3548 case Scanner.TokenNameinstanceof: 3549 // case Scanner.TokenNamelong: 3550 case Scanner.TokenNamenew: 3551 // case Scanner.TokenNamenull : 3552 // case Scanner.TokenNamenative: 3553 case Scanner.TokenNamepublic: 3554 // case Scanner.TokenNamepackage: 3555 case Scanner.TokenNameprivate: 3556 case Scanner.TokenNameprotected: 3557 case Scanner.TokenNamereturn: 3558 // case Scanner.TokenNameshort: 3559 case Scanner.TokenNamesuper: 3560 case Scanner.TokenNamestatic: 3561 case Scanner.TokenNameswitch: 3562 // case Scanner.TokenNamestrictfp: 3563 // case Scanner.TokenNamesynchronized: 3564 case Scanner.TokenNametry: 3565 // case Scanner.TokenNamethis : 3566 // case Scanner.TokenNametrue : 3567 case Scanner.TokenNamethrow: 3568 // case Scanner.TokenNamethrows: 3569 // case Scanner.TokenNametransient: 3570 // case Scanner.TokenNamevoid: 3571 // case Scanner.TokenNamevolatile: 3572 case Scanner.TokenNamewhile: 3573 return true; 3574 default: 3575 return false; 3576 } 3577 } else { 3578 return false; 3579 } 3580 } catch (InvalidInputException e) { 3581 return false; 3582 } 3583 } 3584 3585 // jsurfer start phpParsingError(String[] messageArguments, int problemStartPosition, int problemEndPosition, ReferenceContext context, CompilationResult compilationResult)3586 public void phpParsingError(String[] messageArguments, 3587 int problemStartPosition, int problemEndPosition, 3588 ReferenceContext context, CompilationResult compilationResult) { 3589 this.handle(IProblem.PHPParsingError, NoArgument, messageArguments, 3590 problemStartPosition, problemEndPosition, context, 3591 compilationResult); 3592 } 3593 phpParsingWarning(String[] messageArguments, int problemStartPosition, int problemEndPosition, ReferenceContext context, CompilationResult compilationResult)3594 public void phpParsingWarning(String[] messageArguments, 3595 int problemStartPosition, int problemEndPosition, 3596 ReferenceContext context, CompilationResult compilationResult) { 3597 this.handle(IProblem.PHPParsingWarning, NoArgument, messageArguments, 3598 problemStartPosition, problemEndPosition, context, 3599 compilationResult); 3600 } 3601 phpVarDeprecatedWarning(int problemStartPosition, int problemEndPosition, ReferenceContext context, CompilationResult compilationResult)3602 public void phpVarDeprecatedWarning(int problemStartPosition, 3603 int problemEndPosition, ReferenceContext context, 3604 CompilationResult compilationResult) { 3605 if (computeSeverity(IProblem.PHPVarDeprecatedWarning) == Ignore) 3606 return; 3607 this.handle(IProblem.PHPVarDeprecatedWarning, NoArgument, 3608 new String[] {}, problemStartPosition, problemEndPosition, 3609 context, compilationResult); 3610 } 3611 phpIncludeNotExistWarning(String[] messageArguments, int problemStartPosition, int problemEndPosition, ReferenceContext context, CompilationResult compilationResult)3612 public void phpIncludeNotExistWarning(String[] messageArguments, 3613 int problemStartPosition, int problemEndPosition, 3614 ReferenceContext context, CompilationResult compilationResult) { 3615 if (computeSeverity(IProblem.PHPIncludeNotExistWarning) == Ignore) 3616 return; 3617 this.handle(IProblem.PHPIncludeNotExistWarning, NoArgument, 3618 messageArguments, problemStartPosition, problemEndPosition, 3619 context, compilationResult); 3620 } 3621 phpKeywordWarning(String[] messageArguments, int problemStartPosition, int problemEndPosition, ReferenceContext context, CompilationResult compilationResult)3622 public void phpKeywordWarning(String[] messageArguments, 3623 int problemStartPosition, int problemEndPosition, 3624 ReferenceContext context, CompilationResult compilationResult) { 3625 if (computeSeverity(IProblem.PHPBadStyleKeywordWarning) == Ignore) 3626 return; 3627 this.handle(IProblem.PHPBadStyleKeywordWarning, NoArgument, 3628 messageArguments, problemStartPosition, problemEndPosition, 3629 context, compilationResult); 3630 } 3631 phpUppercaseIdentifierWarning(int problemStartPosition, int problemEndPosition, ReferenceContext context, CompilationResult compilationResult)3632 public void phpUppercaseIdentifierWarning(int problemStartPosition, 3633 int problemEndPosition, ReferenceContext context, 3634 CompilationResult compilationResult) { 3635 if (computeSeverity(IProblem.PHPBadStyleUppercaseIdentifierWarning) == Ignore) 3636 return; 3637 this.handle(IProblem.PHPBadStyleUppercaseIdentifierWarning, NoArgument, 3638 new String[] {}, problemStartPosition, problemEndPosition, 3639 context, compilationResult); 3640 } 3641 uninitializedLocalVariable(String token, int problemStartPosition, int problemEndPosition, ReferenceContext context, CompilationResult compilationResult)3642 public void uninitializedLocalVariable(String token, 3643 int problemStartPosition, int problemEndPosition, 3644 ReferenceContext context, CompilationResult compilationResult) { 3645 if (computeSeverity(IProblem.UninitializedLocalVariable) == Ignore) 3646 return; 3647 // String[] arguments = new String[] { new 3648 // String(binding.readableName()) }; 3649 String[] arguments = new String[] { token }; 3650 this.handle(IProblem.UninitializedLocalVariable, arguments, arguments, 3651 problemStartPosition, problemEndPosition, context, 3652 compilationResult); 3653 } 3654 unreachableCode(String token, int problemStartPosition, int problemEndPosition, ReferenceContext context, CompilationResult compilationResult)3655 public void unreachableCode(String token, int problemStartPosition, 3656 int problemEndPosition, ReferenceContext context, 3657 CompilationResult compilationResult) { 3658 if (computeSeverity(IProblem.CodeCannotBeReached) == Ignore) 3659 return; 3660 this.handle(IProblem.CodeCannotBeReached, NoArgument, new String[] {}, 3661 problemStartPosition, problemEndPosition, context, 3662 compilationResult); 3663 } 3664 3665 }