1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.problem;
13 import org.eclipse.jdt.core.compiler.CharOperation;
14 import org.eclipse.jdt.core.compiler.IProblem;
15 import org.eclipse.jdt.internal.compiler.*;
16 import org.eclipse.jdt.internal.compiler.ast.*;
17 import org.eclipse.jdt.internal.compiler.env.IConstants;
18 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
19 import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
20 import org.eclipse.jdt.internal.compiler.lookup.*;
21 import org.eclipse.jdt.internal.compiler.parser.*;
22 import org.eclipse.jdt.internal.compiler.util.Util;
24 public class ProblemReporter extends ProblemHandler implements ProblemReasons {
26 public ReferenceContext referenceContext;
28 public ProblemReporter(IErrorHandlingPolicy policy, CompilerOptions options, IProblemFactory problemFactory) {
29 super(policy, options, problemFactory);
31 public void abortDueToInternalError(String errorMessage) {
32 String[] arguments = new String[] {errorMessage};
34 IProblem.Unclassified,
41 public void abortDueToInternalError(String errorMessage, ASTNode location) {
42 String[] arguments = new String[] {errorMessage};
44 IProblem.Unclassified,
51 public void abstractMethodCannotBeOverridden(SourceTypeBinding type, MethodBinding concreteMethod) {
54 // %1 must be abstract since it cannot override the inherited package-private abstract method %2
55 IProblem.AbstractMethodCannotBeOverridden,
57 new String(type.sourceName()),
60 concreteMethod.declaringClass.readableName(),
61 concreteMethod.readableName(),
64 new String(type.sourceName()),
67 concreteMethod.declaringClass.shortReadableName(),
68 concreteMethod.shortReadableName(),
73 public void abstractMethodInAbstractClass(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
75 String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
77 IProblem.AbstractMethodInAbstractClass,
80 methodDecl.sourceStart,
81 methodDecl.sourceEnd);
83 public void abstractMethodMustBeImplemented(SourceTypeBinding type, MethodBinding abstractMethod) {
85 // Must implement the inherited abstract method %1
86 // 8.4.3 - Every non-abstract subclass of an abstract type, A, must provide a concrete implementation of all of A's methods.
87 IProblem.AbstractMethodMustBeImplemented,
89 new String(abstractMethod.selector),
90 typesAsString(abstractMethod.isVarargs(), abstractMethod.parameters, false),
91 new String(abstractMethod.declaringClass.readableName()),
92 new String(type.readableName()),
95 new String(abstractMethod.selector),
96 typesAsString(abstractMethod.isVarargs(), abstractMethod.parameters, true),
97 new String(abstractMethod.declaringClass.shortReadableName()),
98 new String(type.shortReadableName()),
103 public void abstractMethodNeedingNoBody(AbstractMethodDeclaration method) {
105 IProblem.BodyForAbstractMethod,
111 method.compilationResult());
113 public void alreadyDefinedLabel(char[] labelName, ASTNode location) {
114 String[] arguments = new String[] {new String(labelName)};
116 IProblem.DuplicateLabel,
119 location.sourceStart,
122 public void annotationCircularity(TypeBinding sourceType, TypeBinding otherType, TypeReference reference) {
123 if (sourceType == otherType)
125 IProblem.AnnotationCircularitySelfReference,
126 new String[] {new String(sourceType.readableName())},
127 new String[] {new String(sourceType.shortReadableName())},
128 reference.sourceStart,
129 reference.sourceEnd);
132 IProblem.AnnotationCircularity,
133 new String[] {new String(sourceType.readableName()), new String(otherType.readableName())},
134 new String[] {new String(sourceType.shortReadableName()), new String(otherType.shortReadableName())},
135 reference.sourceStart,
136 reference.sourceEnd);
138 public void annotationCannotOverrideMethod(MethodBinding overrideMethod, MethodBinding inheritedMethod) {
139 ASTNode location = overrideMethod.sourceMethod();
141 IProblem.AnnotationCannotOverrideMethod,
143 new String(overrideMethod.declaringClass.readableName()),
144 new String(inheritedMethod.declaringClass.readableName()),
145 new String(inheritedMethod.selector),
146 typesAsString(inheritedMethod.isVarargs(), inheritedMethod.parameters, false)},
148 new String(overrideMethod.declaringClass.shortReadableName()),
149 new String(inheritedMethod.declaringClass.shortReadableName()),
150 new String(inheritedMethod.selector),
151 typesAsString(inheritedMethod.isVarargs(), inheritedMethod.parameters, true)},
152 location.sourceStart,
155 public void annotationFieldNeedConstantInitialization(FieldDeclaration fieldDecl) {
156 String str = new String(fieldDecl.name);
158 IProblem.AnnotationFieldNeedConstantInitialization,
159 new String[] { new String(fieldDecl.binding.declaringClass.readableName()), str },
160 new String[] { new String(fieldDecl.binding.declaringClass.shortReadableName()), str},
161 fieldDecl.sourceStart,
162 fieldDecl.sourceEnd);
164 public void annotationMembersCannotHaveParameters(AnnotationMethodDeclaration annotationMethodDeclaration) {
166 IProblem.AnnotationMembersCannotHaveParameters,
169 annotationMethodDeclaration.sourceStart,
170 annotationMethodDeclaration.sourceEnd);
172 public void annotationMembersCannotHaveTypeParameters(AnnotationMethodDeclaration annotationMethodDeclaration) {
174 IProblem.AnnotationMembersCannotHaveTypeParameters,
177 annotationMethodDeclaration.sourceStart,
178 annotationMethodDeclaration.sourceEnd);
180 public void annotationTypeDeclarationCannotHaveConstructor(ConstructorDeclaration constructorDeclaration) {
182 IProblem.AnnotationTypeDeclarationCannotHaveConstructor,
185 constructorDeclaration.sourceStart,
186 constructorDeclaration.sourceEnd);
188 public void annotationTypeDeclarationCannotHaveSuperclass(TypeDeclaration typeDeclaration) {
190 IProblem.AnnotationTypeDeclarationCannotHaveSuperclass,
193 typeDeclaration.sourceStart,
194 typeDeclaration.sourceEnd);
196 public void annotationTypeDeclarationCannotHaveSuperinterfaces(TypeDeclaration typeDeclaration) {
198 IProblem.AnnotationTypeDeclarationCannotHaveSuperinterfaces,
201 typeDeclaration.sourceStart,
202 typeDeclaration.sourceEnd);
204 public void annotationValueMustBeClassLiteral(TypeBinding annotationType, char[] name, Expression value) {
205 String str = new String(name);
207 IProblem.AnnotationValueMustBeClassLiteral,
208 new String[] { new String(annotationType.readableName()), str },
209 new String[] { new String(annotationType.shortReadableName()), str},
213 public void annotationValueMustBeConstant(TypeBinding annotationType, char[] name, Expression value) {
214 String str = new String(name);
216 IProblem.AnnotationValueMustBeConstant,
217 new String[] { new String(annotationType.readableName()), str },
218 new String[] { new String(annotationType.shortReadableName()), str},
222 public void anonymousClassCannotExtendFinalClass(Expression expression, TypeBinding type) {
224 IProblem.AnonymousClassCannotExtendFinalClass,
225 new String[] {new String(type.readableName())},
226 new String[] {new String(type.shortReadableName())},
227 expression.sourceStart,
228 expression.sourceEnd);
230 public void argumentTypeCannotBeVoid(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, Argument arg) {
231 String[] arguments = new String[] {new String(methodDecl.selector), new String(arg.name)};
233 IProblem.ArgumentTypeCannotBeVoid,
236 methodDecl.sourceStart,
237 methodDecl.sourceEnd);
239 public void argumentTypeCannotBeVoidArray(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, Argument arg) {
240 String[] arguments = new String[] {new String(methodDecl.selector), new String(arg.name)};
242 IProblem.ArgumentTypeCannotBeVoidArray,
245 methodDecl.sourceStart,
246 methodDecl.sourceEnd);
248 public void arrayConstantsOnlyInArrayInitializers(int sourceStart, int sourceEnd) {
250 IProblem.ArrayConstantsOnlyInArrayInitializers,
256 public void assignmentHasNoEffect(Assignment assignment, char[] name){
257 String[] arguments = new String[] { new String(name) };
259 IProblem.AssignmentHasNoEffect,
262 assignment.sourceStart,
263 assignment.sourceEnd);
265 public void attemptToReturnNonVoidExpression(ReturnStatement returnStatement, TypeBinding expectedType) {
267 IProblem.VoidMethodReturnsValue,
268 new String[] {new String(expectedType.readableName())},
269 new String[] {new String(expectedType.shortReadableName())},
270 returnStatement.sourceStart,
271 returnStatement.sourceEnd);
273 public void attemptToReturnVoidValue(ReturnStatement returnStatement) {
275 IProblem.MethodReturnsVoid,
278 returnStatement.sourceStart,
279 returnStatement.sourceEnd);
281 public void boundHasConflictingArguments(ASTNode location, TypeBinding type) {
283 IProblem.BoundHasConflictingArguments,
284 new String[] {new String(type.readableName())},
285 new String[] {new String(type.shortReadableName())},
286 location.sourceStart,
289 public void boundsMustBeAnInterface(ASTNode location, TypeBinding type) {
291 IProblem.BoundsMustBeAnInterface,
292 new String[] {new String(type.readableName())},
293 new String[] {new String(type.shortReadableName())},
294 location.sourceStart,
297 public void bytecodeExceeds64KLimit(AbstractMethodDeclaration location) {
298 MethodBinding method = location.binding;
299 if (location.isConstructor()) {
301 IProblem.BytecodeExceeds64KLimitForConstructor,
302 new String[] {new String(location.selector), typesAsString(method.isVarargs(), method.parameters, false)},
303 new String[] {new String(location.selector), typesAsString(method.isVarargs(), method.parameters, true)},
305 location.sourceStart,
309 IProblem.BytecodeExceeds64KLimit,
310 new String[] {new String(location.selector), typesAsString(method.isVarargs(), method.parameters, false)},
311 new String[] {new String(location.selector), typesAsString(method.isVarargs(), method.parameters, true)},
313 location.sourceStart,
317 public void bytecodeExceeds64KLimit(TypeDeclaration location) {
319 IProblem.BytecodeExceeds64KLimitForClinit,
323 location.sourceStart,
326 public void cannotAllocateVoidArray(Expression expression) {
328 IProblem.CannotAllocateVoidArray,
331 expression.sourceStart,
332 expression.sourceEnd);
334 public void cannotAssignToFinalField(FieldBinding field, ASTNode location) {
336 IProblem.FinalFieldAssignment,
338 (field.declaringClass == null ? "array" : new String(field.declaringClass.readableName())), //$NON-NLS-1$
339 new String(field.readableName())},
341 (field.declaringClass == null ? "array" : new String(field.declaringClass.shortReadableName())), //$NON-NLS-1$
342 new String(field.shortReadableName())},
343 location.sourceStart,
346 public void cannotAssignToFinalLocal(LocalVariableBinding local, ASTNode location) {
347 String[] arguments = new String[] { new String(local.readableName())};
349 IProblem.NonBlankFinalLocalAssignment,
352 location.sourceStart,
355 public void cannotAssignToFinalOuterLocal(LocalVariableBinding local, ASTNode location) {
356 String[] arguments = new String[] {new String(local.readableName())};
358 IProblem.FinalOuterLocalAssignment,
361 location.sourceStart,
364 public void cannotDeclareLocalInterface(char[] interfaceName, int sourceStart, int sourceEnd) {
365 String[] arguments = new String[] {new String(interfaceName)};
367 IProblem.CannotDefineInterfaceInLocalType,
373 public void cannotDefineDimensionsAndInitializer(ArrayAllocationExpression expresssion) {
375 IProblem.CannotDefineDimensionExpressionsWithInit,
378 expresssion.sourceStart,
379 expresssion.sourceEnd);
381 public void cannotDireclyInvokeAbstractMethod(MessageSend messageSend, MethodBinding method) {
383 IProblem.DirectInvocationOfAbstractMethod,
384 new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
385 new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
386 messageSend.sourceStart,
387 messageSend.sourceEnd);
389 public void cannotExtendEnum(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) {
390 String name = new String(type.sourceName());
391 String superTypeFullName = new String(superTypeBinding.readableName());
392 String superTypeShortName = new String(superTypeBinding.shortReadableName());
393 if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName;
395 IProblem.CannotExtendEnum,
396 new String[] {superTypeFullName, name},
397 new String[] {superTypeShortName, name},
398 superclass.sourceStart,
399 superclass.sourceEnd);
401 public void cannotImportPackage(ImportReference importRef) {
402 String[] arguments = new String[] {CharOperation.toString(importRef.tokens)};
404 IProblem.CannotImportPackage,
407 importRef.sourceStart,
408 importRef.sourceEnd);
410 public void cannotInstantiate(TypeReference typeRef, TypeBinding type) {
412 IProblem.InvalidClassInstantiation,
413 new String[] {new String(type.readableName())},
414 new String[] {new String(type.shortReadableName())},
418 public void cannotReferToNonFinalOuterLocal(LocalVariableBinding local, ASTNode location) {
419 String[] arguments =new String[]{ new String(local.readableName())};
421 IProblem.OuterLocalMustBeFinal,
424 location.sourceStart,
427 public void cannotReturnInInitializer(ASTNode location) {
429 IProblem.CannotReturnInInitializer,
432 location.sourceStart,
435 public void cannotThrowNull(ThrowStatement statement) {
437 IProblem.CannotThrowNull,
440 statement.sourceStart,
441 statement.sourceEnd);
443 public void cannotThrowType(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, TypeReference exceptionType, TypeBinding expectedType) {
445 IProblem.CannotThrowType,
446 new String[] {new String(expectedType.readableName())},
447 new String[] {new String(expectedType.shortReadableName())},
448 exceptionType.sourceStart,
449 exceptionType.sourceEnd);
451 public void cannotUseSuperInCodeSnippet(int start, int end) {
453 IProblem.CannotUseSuperInCodeSnippet,
460 public void cannotUseSuperInJavaLangObject(ASTNode reference) {
462 IProblem.ObjectHasNoSuperclass,
465 reference.sourceStart,
466 reference.sourceEnd);
468 public void cannotUseQualifiedEnumConstantInCaseLabel(QualifiedNameReference reference) {
469 String[] arguments = new String[]{ String.valueOf(reference.fieldBinding().name) };
471 IProblem.IllegalQualifiedEnumConstantLabel,
474 reference.sourceStart,
475 reference.sourceEnd);
477 public void caseExpressionMustBeConstant(Expression expression) {
479 IProblem.NonConstantExpression,
482 expression.sourceStart,
483 expression.sourceEnd);
485 public void classExtendFinalClass(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) {
486 String name = new String(type.sourceName());
487 String superTypeFullName = new String(superTypeBinding.readableName());
488 String superTypeShortName = new String(superTypeBinding.shortReadableName());
489 if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName;
491 IProblem.ClassExtendFinalClass,
492 new String[] {superTypeFullName, name},
493 new String[] {superTypeShortName, name},
494 superclass.sourceStart,
495 superclass.sourceEnd);
497 public void codeSnippetMissingClass(String missing, int start, int end) {
498 String[] arguments = new String[]{missing};
500 IProblem.CodeSnippetMissingClass,
507 public void codeSnippetMissingMethod(String className, String missingMethod, String argumentTypes, int start, int end) {
508 String[] arguments = new String[]{ className, missingMethod, argumentTypes };
510 IProblem.CodeSnippetMissingMethod,
518 * Given the current configuration, answers which category the problem
520 * Error | Warning | Ignore
522 public int computeSeverity(int problemId){
524 // severity can have been preset on the problem
525 // if ((problem.severity & Fatal) != 0){
529 // if not then check whether it is a configurable problem
532 case IProblem.MaskedCatch :
533 return this.options.getSeverity(CompilerOptions.MaskedCatchBlock);
535 case IProblem.UnusedImport :
536 return this.options.getSeverity(CompilerOptions.UnusedImport);
538 case IProblem.MethodButWithConstructorName :
539 return this.options.getSeverity(CompilerOptions.MethodWithConstructorName);
541 case IProblem.OverridingNonVisibleMethod :
542 return this.options.getSeverity(CompilerOptions.OverriddenPackageDefaultMethod);
544 case IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod :
545 case IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod :
546 return this.options.getSeverity(CompilerOptions.IncompatibleNonInheritedInterfaceMethod);
548 case IProblem.OverridingDeprecatedMethod :
549 case IProblem.UsingDeprecatedType :
550 case IProblem.UsingDeprecatedMethod :
551 case IProblem.UsingDeprecatedConstructor :
552 case IProblem.UsingDeprecatedField :
553 return this.options.getSeverity(CompilerOptions.UsingDeprecatedAPI);
555 case IProblem.LocalVariableIsNeverUsed :
556 return this.options.getSeverity(CompilerOptions.UnusedLocalVariable);
558 case IProblem.ArgumentIsNeverUsed :
559 return this.options.getSeverity(CompilerOptions.UnusedArgument);
561 case IProblem.NoImplicitStringConversionForCharArrayExpression :
562 return this.options.getSeverity(CompilerOptions.NoImplicitStringConversion);
564 case IProblem.NeedToEmulateFieldReadAccess :
565 case IProblem.NeedToEmulateFieldWriteAccess :
566 case IProblem.NeedToEmulateMethodAccess :
567 case IProblem.NeedToEmulateConstructorAccess :
568 return this.options.getSeverity(CompilerOptions.AccessEmulation);
570 case IProblem.NonExternalizedStringLiteral :
571 return this.options.getSeverity(CompilerOptions.NonExternalizedString);
573 case IProblem.UseAssertAsAnIdentifier :
574 return this.options.getSeverity(CompilerOptions.AssertUsedAsAnIdentifier);
575 case IProblem.UseEnumAsAnIdentifier :
576 return this.options.getSeverity(CompilerOptions.EnumUsedAsAnIdentifier);
578 case IProblem.NonStaticAccessToStaticMethod :
579 case IProblem.NonStaticAccessToStaticField :
580 return this.options.getSeverity(CompilerOptions.NonStaticAccessToStatic);
582 case IProblem.IndirectAccessToStaticMethod :
583 case IProblem.IndirectAccessToStaticField :
584 case IProblem.IndirectAccessToStaticType :
585 return this.options.getSeverity(CompilerOptions.IndirectStaticAccess);
587 case IProblem.AssignmentHasNoEffect:
588 return this.options.getSeverity(CompilerOptions.NoEffectAssignment);
590 case IProblem.UnusedPrivateConstructor:
591 case IProblem.UnusedPrivateMethod:
592 case IProblem.UnusedPrivateField:
593 case IProblem.UnusedPrivateType:
594 return this.options.getSeverity(CompilerOptions.UnusedPrivateMember);
599 case IProblem.LocalVariableHidingLocalVariable:
600 case IProblem.LocalVariableHidingField:
601 case IProblem.ArgumentHidingLocalVariable:
602 case IProblem.ArgumentHidingField:
603 return this.options.getSeverity(CompilerOptions.LocalVariableHiding);
605 case IProblem.FieldHidingLocalVariable:
606 case IProblem.FieldHidingField:
607 return this.options.getSeverity(CompilerOptions.FieldHiding);
609 case IProblem.PossibleAccidentalBooleanAssignment:
610 return this.options.getSeverity(CompilerOptions.AccidentalBooleanAssign);
612 case IProblem.SuperfluousSemicolon:
613 case IProblem.EmptyControlFlowStatement:
614 return this.options.getSeverity(CompilerOptions.EmptyStatement);
616 case IProblem.UndocumentedEmptyBlock:
617 return this.options.getSeverity(CompilerOptions.UndocumentedEmptyBlock);
619 case IProblem.UnnecessaryCast:
620 case IProblem.UnnecessaryArgumentCast:
621 case IProblem.UnnecessaryInstanceof:
622 return this.options.getSeverity(CompilerOptions.UnnecessaryTypeCheck);
624 case IProblem.FinallyMustCompleteNormally:
625 return this.options.getSeverity(CompilerOptions.FinallyBlockNotCompleting);
627 case IProblem.UnusedMethodDeclaredThrownException:
628 case IProblem.UnusedConstructorDeclaredThrownException:
629 return this.options.getSeverity(CompilerOptions.UnusedDeclaredThrownException);
631 case IProblem.UnqualifiedFieldAccess:
632 return this.options.getSeverity(CompilerOptions.UnqualifiedFieldAccess);
634 case IProblem.UnnecessaryElse:
635 return this.options.getSeverity(CompilerOptions.UnnecessaryElse);
637 case IProblem.UnsafeRawConstructorInvocation:
638 case IProblem.UnsafeRawMethodInvocation:
639 case IProblem.UnsafeRawConversion:
640 case IProblem.UnsafeRawFieldAssignment:
641 case IProblem.UnsafeGenericCast:
642 case IProblem.UnsafeReturnTypeOverride:
643 return this.options.getSeverity(CompilerOptions.UnsafeTypeOperation);
645 case IProblem.FinalBoundForTypeVariable:
646 return this.options.getSeverity(CompilerOptions.FinalParameterBound);
648 case IProblem.MissingSerialVersion:
649 return this.options.getSeverity(CompilerOptions.MissingSerialVersion);
651 case IProblem.ForbiddenReference:
652 return this.options.getSeverity(CompilerOptions.ForbiddenReference);
654 case IProblem.MethodVarargsArgumentNeedCast :
655 case IProblem.ConstructorVarargsArgumentNeedCast :
656 return this.options.getSeverity(CompilerOptions.VarargsArgumentNeedCast);
658 case IProblem.LocalVariableCannotBeNull :
659 case IProblem.LocalVariableCanOnlyBeNull :
660 return this.options.getSeverity(CompilerOptions.InconsistentNullCheck);
663 * Javadoc syntax errors
665 case IProblem.JavadocUnexpectedTag:
666 case IProblem.JavadocDuplicateReturnTag:
667 case IProblem.JavadocInvalidThrowsClass:
668 case IProblem.JavadocInvalidReference:
669 case IProblem.JavadocInvalidParamTagName:
670 case IProblem.JavadocInvalidParamTagTypeParameter:
671 case IProblem.JavadocMalformedSeeReference:
672 case IProblem.JavadocInvalidSeeHref:
673 case IProblem.JavadocInvalidSeeArgs:
674 case IProblem.JavadocInvalidTag:
675 case IProblem.JavadocUnterminatedInlineTag:
676 case IProblem.JavadocMissingHashCharacter:
677 case IProblem.JavadocEmptyReturnTag:
678 case IProblem.JavadocUnexpectedText:
679 if (this.options.docCommentSupport) {
680 return this.options.getSeverity(CompilerOptions.InvalidJavadoc);
682 return ProblemSeverities.Ignore;
686 * Javadoc tags resolved references errors
688 case IProblem.JavadocInvalidParamName:
689 case IProblem.JavadocDuplicateParamName:
690 case IProblem.JavadocMissingParamName:
691 case IProblem.JavadocInvalidThrowsClassName:
692 case IProblem.JavadocDuplicateThrowsClassName:
693 case IProblem.JavadocMissingThrowsClassName:
694 case IProblem.JavadocMissingReference:
695 case IProblem.JavadocInvalidValueReference:
696 case IProblem.JavadocUndefinedField:
697 case IProblem.JavadocAmbiguousField:
698 case IProblem.JavadocUndefinedConstructor:
699 case IProblem.JavadocAmbiguousConstructor:
700 case IProblem.JavadocUndefinedMethod:
701 case IProblem.JavadocAmbiguousMethod:
702 case IProblem.JavadocAmbiguousMethodReference:
703 case IProblem.JavadocParameterMismatch:
704 case IProblem.JavadocUndefinedType:
705 case IProblem.JavadocAmbiguousType:
706 case IProblem.JavadocInternalTypeNameProvided:
707 case IProblem.JavadocNoMessageSendOnArrayType:
708 case IProblem.JavadocNoMessageSendOnBaseType:
709 case IProblem.JavadocInheritedMethodHidesEnclosingName:
710 case IProblem.JavadocInheritedFieldHidesEnclosingName:
711 case IProblem.JavadocInheritedNameHidesEnclosingTypeName:
712 if (this.options.docCommentSupport && this.options.reportInvalidJavadocTags) {
713 return this.options.getSeverity(CompilerOptions.InvalidJavadoc);
715 return ProblemSeverities.Ignore;
718 * Javadoc invalid tags due to deprecated references
720 case IProblem.JavadocUsingDeprecatedField:
721 case IProblem.JavadocUsingDeprecatedConstructor:
722 case IProblem.JavadocUsingDeprecatedMethod:
723 case IProblem.JavadocUsingDeprecatedType:
724 if (this.options.docCommentSupport && this.options.reportInvalidJavadocTags && this.options.reportInvalidJavadocTagsDeprecatedRef) {
725 return this.options.getSeverity(CompilerOptions.InvalidJavadoc);
727 return ProblemSeverities.Ignore;
730 * Javadoc invalid tags due to non-visible references
732 case IProblem.JavadocNotVisibleField:
733 case IProblem.JavadocNotVisibleConstructor:
734 case IProblem.JavadocNotVisibleMethod:
735 case IProblem.JavadocNotVisibleType:
736 if (this.options.docCommentSupport && this.options.reportInvalidJavadocTags && this.options.reportInvalidJavadocTagsNotVisibleRef) {
737 return this.options.getSeverity(CompilerOptions.InvalidJavadoc);
739 return ProblemSeverities.Ignore;
742 * Javadoc missing tags errors
744 case IProblem.JavadocMissingParamTag:
745 case IProblem.JavadocMissingReturnTag:
746 case IProblem.JavadocMissingThrowsTag:
747 if (this.options.docCommentSupport) {
748 return this.options.getSeverity(CompilerOptions.MissingJavadocTags);
750 return ProblemSeverities.Ignore;
754 * Missing Javadoc errors
756 case IProblem.JavadocMissing:
757 if (this.options.docCommentSupport) {
758 return this.options.getSeverity(CompilerOptions.MissingJavadocComments);
760 return ProblemSeverities.Ignore;
763 // by default problems are errors.
768 public void conditionalArgumentsIncompatibleTypes(ConditionalExpression expression, TypeBinding trueType, TypeBinding falseType) {
770 IProblem.IncompatibleTypesInConditionalOperator,
771 new String[] {new String(trueType.readableName()), new String(falseType.readableName())},
772 new String[] {new String(trueType.sourceName()), new String(falseType.sourceName())},
773 expression.sourceStart,
774 expression.sourceEnd);
776 public void conflictingImport(ImportReference importRef) {
777 String[] arguments = new String[] {CharOperation.toString(importRef.tokens)};
779 IProblem.ConflictingImport,
782 importRef.sourceStart,
783 importRef.sourceEnd);
785 public void constantOutOfFormat(NumberLiteral literal) {
786 // the literal is not in a correct format
787 // this code is called on IntLiteral and LongLiteral
788 // example 000811 ...the 8 is uncorrect.
790 if ((literal instanceof LongLiteral) || (literal instanceof IntLiteral)) {
791 char[] source = literal.source();
795 if ((source[1] == 'x') || (source[1] == 'X')) {
797 Radix = "Hex"; //$NON-NLS-1$
800 Radix = "Octal"; //$NON-NLS-1$
802 //look for the first digit that is incorrect
804 label : for (int i = radix == 8 ? 1 : 2; i < source.length; i++) {
805 if (Character.digit(source[i], radix) == -1) {
810 String[] arguments = new String[] {
811 new String(literal.literalType(null).readableName()), // numeric literals do not need scope to reach type
812 Radix + " " + new String(source) + " (digit " + new String(new char[] {source[place]}) + ")"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
815 IProblem.NumericValueOutOfRange,
821 } catch (IndexOutOfBoundsException ex) {
822 // should never happen
825 // just in case .... use a predefined error..
826 // we should never come here...(except if the code changes !)
827 this.constantOutOfRange(literal, literal.literalType(null)); // numeric literals do not need scope to reach type
830 public void constantOutOfRange(Literal literal, TypeBinding literalType) {
831 String[] arguments = new String[] {new String(literalType.readableName()), new String(literal.source())};
833 IProblem.NumericValueOutOfRange,
839 public void corruptedSignature(TypeBinding enclosingType, char[] signature, int position) {
841 IProblem.CorruptedSignature,
842 new String[] { new String(enclosingType.readableName()), new String(signature), String.valueOf(position) },
843 new String[] { new String(enclosingType.shortReadableName()), new String(signature), String.valueOf(position) },
848 public void deprecatedField(FieldBinding field, ASTNode location) {
850 IProblem.UsingDeprecatedField,
851 new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
852 new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
853 location.sourceStart,
856 public void deprecatedMethod(MethodBinding method, ASTNode location) {
857 if (method.isConstructor()) {
859 IProblem.UsingDeprecatedConstructor,
860 new String[] {new String(method.declaringClass.readableName()), typesAsString(method.isVarargs(), method.parameters, false)},
861 new String[] {new String(method.declaringClass.shortReadableName()), typesAsString(method.isVarargs(), method.parameters, true)},
862 location.sourceStart,
866 IProblem.UsingDeprecatedMethod,
867 new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
868 new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
869 location.sourceStart,
873 public void methodMustOverride(AbstractMethodDeclaration method) {
874 MethodBinding binding = method.binding;
876 IProblem.MethodMustOverride,
877 new String[] {new String(binding.selector), typesAsString(binding.isVarargs(), binding.parameters, false), new String(binding.declaringClass.readableName()), },
878 new String[] {new String(binding.selector), typesAsString(binding.isVarargs(), binding.parameters, true), new String(binding.declaringClass.shortReadableName()),},
882 public void deprecatedType(TypeBinding type, ASTNode location) {
883 if (location == null) return; // 1G828DN - no type ref for synthetic arguments
885 IProblem.UsingDeprecatedType,
886 new String[] {new String(type.readableName())},
887 new String[] {new String(type.shortReadableName())},
888 location.sourceStart,
891 public void duplicateAnnotation(Annotation annotation) {
893 IProblem.DuplicateAnnotation,
894 new String[] {new String(annotation.resolvedType.readableName())},
895 new String[] {new String(annotation.resolvedType.shortReadableName())},
896 annotation.sourceStart,
897 annotation.sourceEnd);
899 public void duplicateAnnotationValue(TypeBinding annotationType, MemberValuePair memberValuePair) {
900 String name = new String(memberValuePair.name);
902 IProblem.DuplicateAnnotationMember,
903 new String[] { name, new String(annotationType.readableName())},
904 new String[] { name, new String(annotationType.shortReadableName())},
905 memberValuePair.sourceStart,
906 memberValuePair.sourceEnd);
908 public void duplicateTargetInTargetAnnotation(TypeBinding annotationType, NameReference reference) {
909 String name = new String(reference.fieldBinding().name);
911 IProblem.DuplicateTargetInTargetAnnotation,
912 new String[] { name, new String(annotationType.readableName())},
913 new String[] { name, new String(annotationType.shortReadableName())},
914 reference.sourceStart,
915 reference.sourceEnd);
917 public void duplicateCase(CaseStatement caseStatement) {
919 IProblem.DuplicateCase,
922 caseStatement.sourceStart,
923 caseStatement.sourceEnd);
925 public void duplicateDefaultCase(ASTNode statement) {
927 IProblem.DuplicateDefaultCase,
930 statement.sourceStart,
931 statement.sourceEnd);
933 public void duplicateFieldInType(SourceTypeBinding type, FieldDeclaration fieldDecl) {
935 IProblem.DuplicateField,
936 new String[] {new String(type.sourceName()), new String(fieldDecl.name)},
937 new String[] {new String(type.shortReadableName()), new String(fieldDecl.name)},
938 fieldDecl.sourceStart,
939 fieldDecl.sourceEnd);
942 public void duplicateImport(ImportReference importRef) {
943 String[] arguments = new String[] {CharOperation.toString(importRef.tokens)};
945 IProblem.DuplicateImport,
948 importRef.sourceStart,
949 importRef.sourceEnd);
951 public void duplicateInheritedMethods(SourceTypeBinding type, MethodBinding inheritedMethod1, MethodBinding inheritedMethod2) {
953 IProblem.DuplicateParameterizedMethods,
955 new String(inheritedMethod1.selector),
956 new String(inheritedMethod1.declaringClass.readableName()),
957 typesAsString(inheritedMethod1.isVarargs(), inheritedMethod1.original().parameters, false),
958 typesAsString(inheritedMethod2.isVarargs(), inheritedMethod2.original().parameters, false)},
960 new String(inheritedMethod1.selector),
961 new String(inheritedMethod1.declaringClass.shortReadableName()),
962 typesAsString(inheritedMethod1.isVarargs(), inheritedMethod1.original().parameters, true),
963 typesAsString(inheritedMethod2.isVarargs(), inheritedMethod2.original().parameters, true)},
967 public void duplicateInitializationOfBlankFinalField(FieldBinding field, Reference reference) {
968 String[] arguments = new String[]{ new String(field.readableName())};
970 IProblem.DuplicateBlankFinalFieldInitialization,
973 reference.sourceStart,
974 reference.sourceEnd);
976 public void duplicateInitializationOfFinalLocal(LocalVariableBinding local, ASTNode location) {
977 String[] arguments = new String[] { new String(local.readableName())};
979 IProblem.DuplicateFinalLocalInitialization,
982 location.sourceStart,
986 public void duplicateEnumSpecialMethod(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
987 MethodBinding method = methodDecl.binding;
989 IProblem.CannotDeclareEnumSpecialMethod,
991 new String(methodDecl.selector),
992 new String(method.declaringClass.readableName()),
993 typesAsString(method.isVarargs(), method.parameters, false)},
995 new String(methodDecl.selector),
996 new String(method.declaringClass.shortReadableName()),
997 typesAsString(method.isVarargs(), method.parameters, true)},
998 methodDecl.sourceStart,
999 methodDecl.sourceEnd);
1002 public void duplicateMethodInType(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
1003 MethodBinding method = methodDecl.binding;
1004 boolean duplicateErasure = false;
1005 if ((method.modifiers & CompilerModifiers.AccGenericSignature) != 0) {
1006 // chech it occurs in parameters (the bit is set for return type | params | thrown exceptions
1007 for (int i = 0, length = method.parameters.length; i < length; i++) {
1008 if ((method.parameters[i].tagBits & TagBits.HasTypeVariable) != 0) {
1009 duplicateErasure = true;
1014 if (duplicateErasure) {
1015 int length = method.parameters.length;
1016 TypeBinding[] erasures = new TypeBinding[length];
1017 for (int i = 0; i < length; i++) {
1018 erasures[i] = method.parameters[i].erasure();
1021 IProblem.DuplicateMethodErasure,
1023 new String(methodDecl.selector),
1024 new String(method.declaringClass.readableName()),
1025 typesAsString(method.isVarargs(), method.parameters, false),
1026 typesAsString(method.isVarargs(), erasures, false) } ,
1028 new String(methodDecl.selector),
1029 new String(method.declaringClass.shortReadableName()),
1030 typesAsString(method.isVarargs(), method.parameters, true),
1031 typesAsString(method.isVarargs(), erasures, true) },
1032 methodDecl.sourceStart,
1033 methodDecl.sourceEnd);
1036 IProblem.DuplicateMethod,
1038 new String(methodDecl.selector),
1039 new String(method.declaringClass.readableName()),
1040 typesAsString(method.isVarargs(), method.parameters, false)},
1042 new String(methodDecl.selector),
1043 new String(method.declaringClass.shortReadableName()),
1044 typesAsString(method.isVarargs(), method.parameters, true)},
1045 methodDecl.sourceStart,
1046 methodDecl.sourceEnd);
1049 public void duplicateModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
1050 /* to highlight modifiers use:
1053 DuplicateModifierForField,
1054 new String[] {new String(fieldDecl.name)},
1055 fieldDecl.modifiers.sourceStart,
1056 fieldDecl.modifiers.sourceEnd));
1058 String[] arguments = new String[] {new String(fieldDecl.name)};
1060 IProblem.DuplicateModifierForField,
1063 fieldDecl.sourceStart,
1064 fieldDecl.sourceEnd);
1066 public void duplicateModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
1068 IProblem.DuplicateModifierForMethod,
1069 new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
1070 new String[] {new String(type.shortReadableName()), new String(methodDecl.selector)},
1071 methodDecl.sourceStart,
1072 methodDecl.sourceEnd);
1074 public void duplicateModifierForType(SourceTypeBinding type) {
1075 String[] arguments = new String[] {new String(type.sourceName())};
1077 IProblem.DuplicateModifierForType,
1083 public void duplicateModifierForVariable(LocalDeclaration localDecl, boolean complainForArgument) {
1084 String[] arguments = new String[] {new String(localDecl.name)};
1087 ? IProblem.DuplicateModifierForArgument
1088 : IProblem.DuplicateModifierForVariable,
1091 localDecl.sourceStart,
1092 localDecl.sourceEnd);
1094 public void duplicateNestedType(TypeDeclaration typeDecl) {
1095 String[] arguments = new String[] {new String(typeDecl.name)};
1097 IProblem.DuplicateNestedType,
1100 typeDecl.sourceStart,
1101 typeDecl.sourceEnd);
1103 public void duplicateSuperinterface(SourceTypeBinding type, TypeDeclaration typeDecl, ReferenceBinding superType) {
1105 IProblem.DuplicateSuperInterface,
1107 new String(superType.readableName()),
1108 new String(type.sourceName())},
1110 new String(superType.shortReadableName()),
1111 new String(type.sourceName())},
1112 typeDecl.sourceStart,
1113 typeDecl.sourceEnd);
1115 public void duplicateTypeParameterInType(TypeParameter typeParameter) {
1117 IProblem.DuplicateTypeVariable,
1118 new String[] { new String(typeParameter.name)},
1119 new String[] { new String(typeParameter.name)},
1120 typeParameter.sourceStart,
1121 typeParameter.sourceEnd);
1123 public void duplicateTypes(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
1124 String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
1125 this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
1127 IProblem.DuplicateTypes,
1130 typeDecl.sourceStart,
1132 compUnitDecl.compilationResult);
1134 public void emptyControlFlowStatement(int sourceStart, int sourceEnd) {
1136 IProblem.EmptyControlFlowStatement,
1142 public void enumAbstractMethodMustBeImplemented(AbstractMethodDeclaration method) {
1143 MethodBinding abstractMethod = method.binding;
1145 // Must implement the inherited abstract method %1
1146 // 8.4.3 - Every non-abstract subclass of an abstract type, A, must provide a concrete implementation of all of A's methods.
1147 IProblem.EnumAbstractMethodMustBeImplemented,
1149 new String(abstractMethod.selector),
1150 typesAsString(abstractMethod.isVarargs(), abstractMethod.parameters, false),
1151 new String(abstractMethod.declaringClass.readableName()),
1154 new String(abstractMethod.selector),
1155 typesAsString(abstractMethod.isVarargs(), abstractMethod.parameters, true),
1156 new String(abstractMethod.declaringClass.shortReadableName()),
1158 method.sourceStart(),
1159 method.sourceEnd());
1162 public void errorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params) {
1163 StringBuffer buffer = new StringBuffer();
1164 StringBuffer shortBuffer = new StringBuffer();
1165 for (int i = 0, length = params.length; i < length; i++) {
1167 buffer.append(", "); //$NON-NLS-1$
1168 shortBuffer.append(", "); //$NON-NLS-1$
1170 buffer.append(new String(params[i].readableName()));
1171 shortBuffer.append(new String(params[i].shortReadableName()));
1174 int id = recType.isArrayType() ? IProblem.NoMessageSendOnArrayType : IProblem.NoMessageSendOnBaseType;
1176 if ((messageSend.bits & ASTNode.InsideJavadoc) != 0) {
1177 id |= IProblem.Javadoc;
1178 if (!reportInvalidJavadocTagsVisibility()) return;
1183 new String[] {new String(recType.readableName()), new String(messageSend.selector), buffer.toString()},
1184 new String[] {new String(recType.shortReadableName()), new String(messageSend.selector), shortBuffer.toString()},
1185 messageSend.sourceStart,
1186 messageSend.sourceEnd);
1188 public void errorThisSuperInStatic(ASTNode reference) {
1189 String[] arguments = new String[] {reference.isSuper() ? "super" : "this"}; //$NON-NLS-2$ //$NON-NLS-1$
1191 IProblem.ThisInStaticContext,
1194 reference.sourceStart,
1195 reference.sourceEnd);
1197 public void cannotInvokeSuperConstructorInEnum(ExplicitConstructorCall constructorCall, MethodBinding enumConstructor) {
1199 IProblem.CannotInvokeSuperConstructorInEnum,
1201 new String(enumConstructor.declaringClass.sourceName()),
1202 typesAsString(enumConstructor.isVarargs(), enumConstructor.parameters, false),
1205 new String(enumConstructor.declaringClass.sourceName()),
1206 typesAsString(enumConstructor.isVarargs(), enumConstructor.parameters, true),
1208 constructorCall.sourceStart,
1209 constructorCall.sourceEnd);
1211 public void expressionShouldBeAVariable(Expression expression) {
1213 IProblem.ExpressionShouldBeAVariable,
1216 expression.sourceStart,
1217 expression.sourceEnd);
1219 public void fieldHiding(FieldDeclaration fieldDecl, Binding hiddenVariable) {
1220 FieldBinding field = fieldDecl.binding;
1221 if (CharOperation.equals(TypeConstants.SERIALVERSIONUID, field.name)
1224 && BaseTypes.LongBinding == field.type) {
1225 return; // do not report unused serialVersionUID field
1227 if (CharOperation.equals(TypeConstants.SERIALPERSISTENTFIELDS, field.name)
1230 && field.type.dimensions() == 1
1231 && CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTSTREAMFIELD, field.type.leafComponentType().readableName())) {
1232 return; // do not report unused serialPersistentFields field
1235 if (hiddenVariable instanceof LocalVariableBinding) {
1237 IProblem.FieldHidingLocalVariable,
1238 new String[] {new String(field.declaringClass.readableName()), new String(field.name) },
1239 new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name) },
1240 fieldDecl.sourceStart,
1241 fieldDecl.sourceEnd);
1242 } else if (hiddenVariable instanceof FieldBinding) {
1243 FieldBinding hiddenField = (FieldBinding) hiddenVariable;
1245 IProblem.FieldHidingField,
1246 new String[] {new String(field.declaringClass.readableName()), new String(field.name) , new String(hiddenField.declaringClass.readableName()) },
1247 new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name) , new String(hiddenField.declaringClass.shortReadableName()) },
1248 fieldDecl.sourceStart,
1249 fieldDecl.sourceEnd);
1252 private int fieldLocation(FieldBinding field, ASTNode node) {
1253 if (node instanceof QualifiedNameReference) {
1254 QualifiedNameReference ref = (QualifiedNameReference) node;
1255 FieldBinding[] bindings = ref.otherBindings;
1256 if (bindings != null)
1257 for (int i = bindings.length; --i >= 0;)
1258 if (bindings[i] == field)
1259 return (int) ref.sourcePositions[i + 1]; // first position is for the primary field
1261 return node.sourceEnd;
1263 public void fieldsOrThisBeforeConstructorInvocation(ThisReference reference) {
1265 IProblem.ThisSuperDuringConstructorInvocation,
1268 reference.sourceStart,
1269 reference.sourceEnd);
1271 public void finallyMustCompleteNormally(Block finallyBlock) {
1273 IProblem.FinallyMustCompleteNormally,
1276 finallyBlock.sourceStart,
1277 finallyBlock.sourceEnd);
1279 public void finalMethodCannotBeOverridden(MethodBinding currentMethod, MethodBinding inheritedMethod) {
1281 // Cannot override the final method from %1
1282 // 8.4.3.3 - Final methods cannot be overridden or hidden.
1283 IProblem.FinalMethodCannotBeOverridden,
1284 new String[] {new String(inheritedMethod.declaringClass.readableName())},
1285 new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
1286 currentMethod.sourceStart(),
1287 currentMethod.sourceEnd());
1289 public void finalVariableBound(TypeVariableBinding typeVariable, TypeReference typeRef) {
1291 IProblem.FinalBoundForTypeVariable,
1292 new String[] { new String(typeVariable.sourceName), new String(typeRef.resolvedType.readableName())},
1293 new String[] { new String(typeVariable.sourceName), new String(typeRef.resolvedType.shortReadableName())},
1294 typeRef.sourceStart,
1297 public void forbiddenReference(TypeBinding type, ASTNode location, String messageTemplate) {
1298 if (location == null) return;
1299 // this problem has a message template extracted from the access restriction rule
1301 IProblem.ForbiddenReference,
1302 new String[] { new String(type.readableName()) }, // distinct from msg arg for quickfix purpose
1303 new String[] { Util.bindMessage(messageTemplate, new String[]{ new String(type.shortReadableName()) } ) },
1304 location.sourceStart,
1305 location.sourceEnd);
1307 public void forwardReference(Reference reference, int indexInQualification, TypeBinding type) {
1309 IProblem.ReferenceToForwardField,
1312 reference.sourceStart,
1313 reference.sourceEnd);
1315 public void forwardTypeVariableReference(ASTNode location, TypeVariableBinding type) {
1317 IProblem.ReferenceToForwardTypeVariable,
1318 new String[] {new String(type.readableName())},
1319 new String[] {new String(type.shortReadableName())},
1320 location.sourceStart,
1321 location.sourceEnd);
1323 public void genericTypeCannotExtendThrowable(TypeDeclaration typeDecl) {
1325 IProblem.GenericTypeCannotExtendThrowable,
1326 new String[]{ new String(typeDecl.binding.readableName()) },
1327 new String[]{ new String(typeDecl.binding.shortReadableName()) },
1328 typeDecl.superclass.sourceStart,
1329 typeDecl.superclass.sourceEnd);
1331 // use this private API when the compilation unit result can be found through the
1332 // reference context. Otherwise, use the other API taking a problem and a compilation result
1334 private void handle(
1336 String[] problemArguments,
1337 String[] messageArguments,
1338 int problemStartPosition,
1339 int problemEndPosition){
1345 problemStartPosition,
1347 this.referenceContext,
1348 this.referenceContext == null ? null : this.referenceContext.compilationResult());
1349 this.referenceContext = null;
1351 // use this private API when the compilation unit result cannot be found through the
1352 // reference context.
1354 private void handle(
1356 String[] problemArguments,
1357 String[] messageArguments,
1358 int problemStartPosition,
1359 int problemEndPosition,
1360 CompilationResult unitResult){
1366 problemStartPosition,
1368 this.referenceContext,
1370 this.referenceContext = null;
1372 // use this private API when the compilation unit result can be found through the
1373 // reference context. Otherwise, use the other API taking a problem and a compilation result
1375 private void handle(
1377 String[] problemArguments,
1378 String[] messageArguments,
1380 int problemStartPosition,
1381 int problemEndPosition){
1388 problemStartPosition,
1390 this.referenceContext,
1391 this.referenceContext == null ? null : this.referenceContext.compilationResult());
1392 this.referenceContext = null;
1394 public void hiddenCatchBlock(ReferenceBinding exceptionType, ASTNode location) {
1396 IProblem.MaskedCatch,
1398 new String(exceptionType.readableName()),
1401 new String(exceptionType.shortReadableName()),
1403 location.sourceStart,
1404 location.sourceEnd);
1406 public void hidingEnclosingType(TypeDeclaration typeDecl) {
1407 String[] arguments = new String[] {new String(typeDecl.name)};
1409 IProblem.HidingEnclosingType,
1412 typeDecl.sourceStart,
1413 typeDecl.sourceEnd);
1415 public void hierarchyCircularity(SourceTypeBinding sourceType, ReferenceBinding superType, TypeReference reference) {
1419 if (reference == null) { // can only happen when java.lang.Object is busted
1420 start = sourceType.sourceStart();
1421 end = sourceType.sourceEnd();
1423 start = reference.sourceStart;
1424 end = reference.sourceEnd;
1427 if (sourceType == superType)
1429 IProblem.HierarchyCircularitySelfReference,
1430 new String[] {new String(sourceType.readableName()) },
1431 new String[] {new String(sourceType.shortReadableName()) },
1436 IProblem.HierarchyCircularity,
1437 new String[] {new String(sourceType.readableName()), new String(superType.readableName())},
1438 new String[] {new String(sourceType.shortReadableName()), new String(superType.shortReadableName())},
1442 public void hierarchyHasProblems(SourceTypeBinding type) {
1443 String[] arguments = new String[] {new String(type.sourceName())};
1445 IProblem.HierarchyHasProblems,
1451 public void illegalAbstractModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
1452 String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
1454 IProblem.IllegalAbstractModifierCombinationForMethod,
1457 methodDecl.sourceStart,
1458 methodDecl.sourceEnd);
1460 public void illegalClassLiteralForTypeVariable(TypeVariableBinding variable, ASTNode location) {
1461 String[] arguments = new String[] { new String(variable.sourceName) };
1463 IProblem.IllegalClassLiteralForTypeVariable,
1466 location.sourceStart,
1467 location.sourceEnd);
1469 public void illegalExtendedDimensions(AnnotationMethodDeclaration annotationTypeMemberDeclaration) {
1471 IProblem.IllegalExtendedDimensions,
1474 annotationTypeMemberDeclaration.sourceStart,
1475 annotationTypeMemberDeclaration.sourceEnd);
1477 public void illegalExtendedDimensions(Argument argument) {
1479 IProblem.IllegalExtendedDimensionsForVarArgs,
1482 argument.sourceStart,
1483 argument.sourceEnd);
1485 public void illegalGenericArray(TypeBinding leadtComponentType, ASTNode location) {
1487 IProblem.IllegalGenericArray,
1488 new String[]{ new String(leadtComponentType.readableName())},
1489 new String[]{ new String(leadtComponentType.shortReadableName())},
1490 location.sourceStart,
1491 location.sourceEnd);
1493 public void illegalInstanceOfGenericType(TypeBinding checkedType, ASTNode location) {
1494 if (checkedType.isTypeVariable()) {
1496 IProblem.IllegalInstanceofTypeParameter,
1497 new String[] { new String(checkedType.readableName()), new String(checkedType.erasure().readableName())},
1498 new String[] { new String(checkedType.shortReadableName()), new String(checkedType.erasure().shortReadableName())},
1499 location.sourceStart,
1500 location.sourceEnd);
1504 IProblem.IllegalInstanceofParameterizedType,
1505 new String[] { new String(checkedType.readableName()), new String(checkedType.erasure().sourceName())},
1506 new String[] { new String(checkedType.shortReadableName()), new String(checkedType.erasure().sourceName())},
1507 location.sourceStart,
1508 location.sourceEnd);
1510 public void illegalModifierCombinationFinalAbstractForClass(SourceTypeBinding type) {
1511 String[] arguments = new String[] {new String(type.sourceName())};
1513 IProblem.IllegalModifierCombinationFinalAbstractForClass,
1519 public void illegalModifierCombinationFinalVolatileForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
1520 String[] arguments = new String[] {new String(fieldDecl.name)};
1523 IProblem.IllegalModifierCombinationFinalVolatileForField,
1526 fieldDecl.sourceStart,
1527 fieldDecl.sourceEnd);
1530 public void illegalModifierForClass(SourceTypeBinding type) {
1531 String[] arguments = new String[] {new String(type.sourceName())};
1533 IProblem.IllegalModifierForClass,
1539 public void illegalModifierForEnum(SourceTypeBinding type) {
1540 String[] arguments = new String[] {new String(type.sourceName())};
1542 IProblem.IllegalModifierForEnum,
1548 public void illegalModifierForLocalEnum(SourceTypeBinding type) {
1549 String[] arguments = new String[] {new String(type.sourceName())};
1551 IProblem.IllegalModifierForLocalEnum,
1557 public void illegalModifierForMemberEnum(SourceTypeBinding type) {
1558 String[] arguments = new String[] {new String(type.sourceName())};
1560 IProblem.IllegalModifierForMemberEnum,
1566 public void illegalModifierForEnumConstant(ReferenceBinding type, FieldDeclaration fieldDecl) {
1567 String[] arguments = new String[] {new String(fieldDecl.name)};
1569 IProblem.IllegalModifierForEnumConstant,
1572 fieldDecl.sourceStart,
1573 fieldDecl.sourceEnd);
1575 public void illegalModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
1576 String[] arguments = new String[] {new String(fieldDecl.name)};
1578 IProblem.IllegalModifierForField,
1581 fieldDecl.sourceStart,
1582 fieldDecl.sourceEnd);
1584 public void illegalModifierForInterface(SourceTypeBinding type) {
1585 String[] arguments = new String[] {new String(type.sourceName())};
1587 IProblem.IllegalModifierForInterface,
1593 public void illegalModifierForInterfaceField(FieldDeclaration fieldDecl) {
1594 String name = new String(fieldDecl.name);
1596 IProblem.IllegalModifierForInterfaceField,
1598 new String(fieldDecl.binding.declaringClass.readableName()),
1602 new String(fieldDecl.binding.declaringClass.shortReadableName()),
1605 fieldDecl.sourceStart,
1606 fieldDecl.sourceEnd);
1608 public void illegalModifierForInterfaceMethod(AbstractMethodDeclaration methodDecl) {
1610 IProblem.IllegalModifierForInterfaceMethod,
1612 new String(methodDecl.binding.declaringClass.readableName()),
1613 new String(methodDecl.selector),
1614 typesAsString(methodDecl.binding.isVarargs(), methodDecl.binding.parameters, false),
1617 new String(methodDecl.binding.declaringClass.shortReadableName()),
1618 new String(methodDecl.selector),
1619 typesAsString(methodDecl.binding.isVarargs(), methodDecl.binding.parameters, true),
1621 methodDecl.sourceStart,
1622 methodDecl.sourceEnd);
1624 public void illegalModifierForLocalClass(SourceTypeBinding type) {
1625 String[] arguments = new String[] {new String(type.sourceName())};
1627 IProblem.IllegalModifierForLocalClass,
1633 public void illegalModifierForMemberClass(SourceTypeBinding type) {
1634 String[] arguments = new String[] {new String(type.sourceName())};
1636 IProblem.IllegalModifierForMemberClass,
1642 public void illegalModifierForMemberInterface(SourceTypeBinding type) {
1643 String[] arguments = new String[] {new String(type.sourceName())};
1645 IProblem.IllegalModifierForMemberInterface,
1651 public void illegalModifierForAnnotationType(SourceTypeBinding type) {
1652 String[] arguments = new String[] {new String(type.sourceName())};
1654 IProblem.IllegalModifierForAnnotationType,
1660 public void illegalModifierForAnnotationMemberType(SourceTypeBinding type) {
1661 String[] arguments = new String[] {new String(type.sourceName())};
1663 IProblem.IllegalModifierForAnnotationMemberType,
1669 public void illegalModifierForAnnotationField(FieldDeclaration fieldDecl) {
1670 String name = new String(fieldDecl.name);
1672 IProblem.IllegalModifierForAnnotationField,
1674 new String(fieldDecl.binding.declaringClass.readableName()),
1678 new String(fieldDecl.binding.declaringClass.shortReadableName()),
1681 fieldDecl.sourceStart,
1682 fieldDecl.sourceEnd);
1685 public void illegalModifierForAnnotationMember(AbstractMethodDeclaration methodDecl) {
1687 IProblem.IllegalModifierForAnnotationMethod,
1689 new String(methodDecl.binding.declaringClass.readableName()),
1690 new String(methodDecl.selector),
1693 new String(methodDecl.binding.declaringClass.shortReadableName()),
1694 new String(methodDecl.selector),
1696 methodDecl.sourceStart,
1697 methodDecl.sourceEnd);
1699 public void illegalModifierForMethod(AbstractMethodDeclaration methodDecl) {
1701 IProblem.IllegalModifierForMethod,
1703 new String(methodDecl.selector),
1704 typesAsString(methodDecl.binding.isVarargs(), methodDecl.binding.parameters, false),
1705 new String(methodDecl.binding.declaringClass.readableName()),
1708 new String(methodDecl.selector),
1709 typesAsString(methodDecl.binding.isVarargs(), methodDecl.binding.parameters, true),
1710 new String(methodDecl.binding.declaringClass.shortReadableName()),
1712 methodDecl.sourceStart,
1713 methodDecl.sourceEnd);
1715 public void illegalModifierForVariable(LocalDeclaration localDecl, boolean complainAsArgument) {
1716 String[] arguments = new String[] {new String(localDecl.name)};
1719 ? IProblem.IllegalModifierForArgument
1720 : IProblem.IllegalModifierForVariable,
1723 localDecl.sourceStart,
1724 localDecl.sourceEnd);
1726 public void illegalPrimitiveOrArrayTypeForEnclosingInstance(TypeBinding enclosingType, ASTNode location) {
1728 IProblem.IllegalPrimitiveOrArrayTypeForEnclosingInstance,
1729 new String[] {new String(enclosingType.readableName())},
1730 new String[] {new String(enclosingType.shortReadableName())},
1731 location.sourceStart,
1732 location.sourceEnd);
1734 public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
1735 String[] arguments = new String[] {new String(type.sourceName())};
1737 IProblem.IllegalStaticModifierForMemberType,
1743 public void illegalUsageOfQualifiedTypeReference(QualifiedTypeReference qualifiedTypeReference) {
1744 StringBuffer buffer = new StringBuffer();
1745 char[][] tokens = qualifiedTypeReference.tokens;
1746 for (int i = 0; i < tokens.length; i++) {
1747 if (i > 0) buffer.append('.');
1748 buffer.append(tokens[i]);
1750 String[] arguments = new String[] { String.valueOf(buffer)};
1752 IProblem.IllegalUsageOfQualifiedTypeReference,
1755 qualifiedTypeReference.sourceStart,
1756 qualifiedTypeReference.sourceEnd);
1758 public void illegalVararg(Argument argType, AbstractMethodDeclaration methodDecl) {
1759 String[] arguments = new String[] {CharOperation.toString(argType.type.getTypeName()), new String(methodDecl.selector)};
1761 IProblem.IllegalVararg,
1764 argType.sourceStart,
1767 public void illegalVisibilityModifierCombinationForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
1768 String[] arguments = new String[] {new String(fieldDecl.name)};
1770 IProblem.IllegalVisibilityModifierCombinationForField,
1773 fieldDecl.sourceStart,
1774 fieldDecl.sourceEnd);
1776 public void illegalVisibilityModifierCombinationForMemberType(SourceTypeBinding type) {
1777 String[] arguments = new String[] {new String(type.sourceName())};
1779 IProblem.IllegalVisibilityModifierCombinationForMemberType,
1785 public void illegalVisibilityModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
1786 String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
1788 IProblem.IllegalVisibilityModifierCombinationForMethod,
1791 methodDecl.sourceStart,
1792 methodDecl.sourceEnd);
1794 public void illegalVisibilityModifierForInterfaceMemberType(SourceTypeBinding type) {
1795 String[] arguments = new String[] {new String(type.sourceName())};
1797 IProblem.IllegalVisibilityModifierForInterfaceMemberType,
1803 public void illegalVoidExpression(ASTNode location) {
1805 IProblem.InvalidVoidExpression,
1808 location.sourceStart,
1809 location.sourceEnd);
1811 public void importProblem(ImportReference importRef, Binding expectedImport) {
1812 if (expectedImport.problemId() == NotFound) {
1813 char[][] tokens = expectedImport instanceof ProblemReferenceBinding
1814 ? ((ProblemReferenceBinding) expectedImport).compoundName
1816 String[] arguments = new String[]{CharOperation.toString(tokens)};
1818 IProblem.ImportNotFound,
1821 importRef.sourceStart,
1822 (int) importRef.sourcePositions[tokens.length - 1]);
1825 if (expectedImport.problemId() == InvalidTypeForStaticImport) {
1826 char[][] tokens = importRef.tokens;
1827 String[] arguments = new String[]{CharOperation.toString(tokens)};
1829 IProblem.InvalidTypeForStaticImport,
1832 importRef.sourceStart,
1833 (int) importRef.sourcePositions[tokens.length - 1]);
1836 invalidType(importRef, (TypeBinding)expectedImport);
1838 public void incompatibleExceptionInThrowsClause(SourceTypeBinding type, MethodBinding currentMethod, MethodBinding inheritedMethod, ReferenceBinding exceptionType) {
1839 if (type == currentMethod.declaringClass) {
1841 if (currentMethod.declaringClass.isInterface()
1842 && !inheritedMethod.isPublic()){ // interface inheriting Object protected method
1843 id = IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod;
1845 id = IProblem.IncompatibleExceptionInThrowsClause;
1848 // Exception %1 is not compatible with throws clause in %2
1849 // 9.4.4 - The type of exception in the throws clause is incompatible.
1852 new String(exceptionType.sourceName()),
1854 CharOperation.concat(
1855 inheritedMethod.declaringClass.readableName(),
1856 inheritedMethod.readableName(),
1859 new String(exceptionType.sourceName()),
1861 CharOperation.concat(
1862 inheritedMethod.declaringClass.shortReadableName(),
1863 inheritedMethod.shortReadableName(),
1865 currentMethod.sourceStart(),
1866 currentMethod.sourceEnd());
1869 // Exception %1 in throws clause of %2 is not compatible with %3
1870 // 9.4.4 - The type of exception in the throws clause is incompatible.
1871 IProblem.IncompatibleExceptionInInheritedMethodThrowsClause,
1873 new String(exceptionType.sourceName()),
1875 CharOperation.concat(
1876 currentMethod.declaringClass.sourceName(),
1877 currentMethod.readableName(),
1880 CharOperation.concat(
1881 inheritedMethod.declaringClass.readableName(),
1882 inheritedMethod.readableName(),
1885 new String(exceptionType.sourceName()),
1887 CharOperation.concat(
1888 currentMethod.declaringClass.sourceName(),
1889 currentMethod.shortReadableName(),
1892 CharOperation.concat(
1893 inheritedMethod.declaringClass.shortReadableName(),
1894 inheritedMethod.shortReadableName(),
1899 public void incompatibleReturnType(MethodBinding currentMethod, MethodBinding inheritedMethod) {
1900 StringBuffer methodSignature = new StringBuffer();
1902 .append(inheritedMethod.declaringClass.readableName())
1904 .append(inheritedMethod.readableName());
1906 StringBuffer shortSignature = new StringBuffer();
1908 .append(inheritedMethod.declaringClass.shortReadableName())
1910 .append(inheritedMethod.shortReadableName());
1913 if (currentMethod.declaringClass.isInterface()
1914 && !inheritedMethod.isPublic()){ // interface inheriting Object protected method
1915 id = IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod;
1917 id = IProblem.IncompatibleReturnType;
1921 new String[] {methodSignature.toString()},
1922 new String[] {shortSignature.toString()},
1923 currentMethod.sourceStart(),
1924 currentMethod.sourceEnd());
1926 public void disallowedTargetForAnnotation(Annotation annotation) {
1928 IProblem.DisallowedTargetForAnnotation,
1929 new String[] {new String(annotation.resolvedType.readableName())},
1930 new String[] {new String(annotation.resolvedType.shortReadableName())},
1931 annotation.sourceStart,
1932 annotation.sourceEnd);
1934 public void incorrectArityForParameterizedType(ASTNode location, TypeBinding type, TypeBinding[] argumentTypes) {
1935 if (location == null) {
1937 IProblem.IncorrectArityForParameterizedType,
1938 new String[] {new String(type.readableName()), typesAsString(false, argumentTypes, false)},
1939 new String[] {new String(type.shortReadableName()), typesAsString(false, argumentTypes, true)},
1940 AbortCompilation | Error,
1945 IProblem.IncorrectArityForParameterizedType,
1946 new String[] {new String(type.readableName()), typesAsString(false, argumentTypes, false)},
1947 new String[] {new String(type.shortReadableName()), typesAsString(false, argumentTypes, true)},
1948 location.sourceStart,
1949 location.sourceEnd);
1951 public void incorrectLocationForNonEmptyDimension(ArrayAllocationExpression expression, int index) {
1953 IProblem.IllegalDimension,
1956 expression.dimensions[index].sourceStart,
1957 expression.dimensions[index].sourceEnd);
1959 public void incorrectSwitchType(Expression expression, TypeBinding testType) {
1961 IProblem.IncorrectSwitchType,
1962 new String[] {new String(testType.readableName())},
1963 new String[] {new String(testType.shortReadableName())},
1964 expression.sourceStart,
1965 expression.sourceEnd);
1967 public void indirectAccessToStaticField(ASTNode location, FieldBinding field){
1969 IProblem.IndirectAccessToStaticField,
1970 new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
1971 new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
1972 location.sourceStart,
1973 fieldLocation(field, location));
1975 public void indirectAccessToStaticMethod(ASTNode location, MethodBinding method) {
1977 IProblem.IndirectAccessToStaticMethod,
1978 new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
1979 new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
1980 location.sourceStart,
1981 location.sourceEnd);
1983 public void indirectAccessToStaticType(ASTNode location, ReferenceBinding type) {
1985 IProblem.IndirectAccessToStaticMethod,
1986 new String[] {new String(type.enclosingType().readableName()), new String(type.sourceName) },
1987 new String[] {new String(type.enclosingType().shortReadableName()), new String(type.sourceName) },
1988 location.sourceStart,
1989 location.sourceEnd);
1991 public void inheritedMethodsHaveNameClash(SourceTypeBinding type, MethodBinding oneMethod, MethodBinding twoMethod) {
1993 IProblem.MethodNameClash,
1995 new String(oneMethod.selector),
1996 typesAsString(oneMethod.original().isVarargs(), oneMethod.original().parameters, false),
1997 new String(oneMethod.declaringClass.readableName()),
1998 typesAsString(twoMethod.original().isVarargs(), twoMethod.original().parameters, false),
1999 new String(twoMethod.declaringClass.readableName()),
2002 new String(oneMethod.selector),
2003 typesAsString(oneMethod.original().isVarargs(), oneMethod.original().parameters, true),
2004 new String(oneMethod.declaringClass.shortReadableName()),
2005 typesAsString(twoMethod.original().isVarargs(), twoMethod.original().parameters, true),
2006 new String(twoMethod.declaringClass.shortReadableName()),
2011 public void inheritedMethodReducesVisibility(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
2012 StringBuffer concreteSignature = new StringBuffer();
2014 .append(concreteMethod.declaringClass.readableName())
2016 .append(concreteMethod.readableName());
2017 StringBuffer shortSignature = new StringBuffer();
2019 .append(concreteMethod.declaringClass.shortReadableName())
2021 .append(concreteMethod.shortReadableName());
2023 // The inherited method %1 cannot hide the public abstract method in %2
2024 IProblem.InheritedMethodReducesVisibility,
2026 concreteSignature.toString(),
2027 new String(abstractMethods[0].declaringClass.readableName())},
2029 new String(shortSignature.toString()),
2030 new String(abstractMethods[0].declaringClass.shortReadableName())},
2034 public void inheritedMethodsHaveIncompatibleReturnTypes(SourceTypeBinding type, MethodBinding[] inheritedMethods, int length) {
2035 StringBuffer methodSignatures = new StringBuffer();
2036 StringBuffer shortSignatures = new StringBuffer();
2037 for (int i = length; --i >= 0;) {
2039 .append(inheritedMethods[i].declaringClass.readableName())
2041 .append(inheritedMethods[i].readableName());
2043 .append(inheritedMethods[i].declaringClass.shortReadableName())
2045 .append(inheritedMethods[i].shortReadableName());
2047 methodSignatures.append(", "); //$NON-NLS-1$
2048 shortSignatures.append(", "); //$NON-NLS-1$
2053 // Return type is incompatible with %1
2054 // 9.4.2 - The return type from the method is incompatible with the declaration.
2055 IProblem.IncompatibleReturnType,
2056 new String[] {methodSignatures.toString()},
2057 new String[] {shortSignatures.toString()},
2061 public void initializerMustCompleteNormally(FieldDeclaration fieldDecl) {
2063 IProblem.InitializerMustCompleteNormally,
2066 fieldDecl.sourceStart,
2067 fieldDecl.sourceEnd);
2069 public void innerTypesCannotDeclareStaticInitializers(ReferenceBinding innerType, ASTNode location) {
2071 IProblem.CannotDefineStaticInitializerInLocalType,
2072 new String[] {new String(innerType.readableName())},
2073 new String[] {new String(innerType.shortReadableName())},
2074 location.sourceStart,
2075 location.sourceEnd);
2077 public void interfaceCannotHaveConstructors(ConstructorDeclaration constructor) {
2079 IProblem.InterfaceCannotHaveConstructors,
2082 constructor.sourceStart,
2083 constructor.sourceEnd,
2085 constructor.compilationResult());
2087 public void interfaceCannotHaveInitializers(SourceTypeBinding type, FieldDeclaration fieldDecl) {
2088 String[] arguments = new String[] {new String(type.sourceName())};
2091 IProblem.InterfaceCannotHaveInitializers,
2094 fieldDecl.sourceStart,
2095 fieldDecl.sourceEnd);
2097 public void invalidAnnotationMemberType(MethodDeclaration methodDecl) {
2099 IProblem.InvalidAnnotationMemberType,
2101 new String(methodDecl.binding.returnType.readableName()),
2102 new String(methodDecl.selector),
2103 new String(methodDecl.binding.declaringClass.readableName()),
2106 new String(methodDecl.binding.returnType.shortReadableName()),
2107 new String(methodDecl.selector),
2108 new String(methodDecl.binding.declaringClass.shortReadableName()),
2110 methodDecl.returnType.sourceStart,
2111 methodDecl.returnType.sourceEnd);
2114 public void invalidBreak(ASTNode location) {
2116 IProblem.InvalidBreak,
2119 location.sourceStart,
2120 location.sourceEnd);
2122 public void invalidConstructor(Statement statement, MethodBinding targetConstructor) {
2124 boolean insideDefaultConstructor =
2125 (this.referenceContext instanceof ConstructorDeclaration)
2126 && ((ConstructorDeclaration)this.referenceContext).isDefaultConstructor();
2127 boolean insideImplicitConstructorCall =
2128 (statement instanceof ExplicitConstructorCall)
2129 && (((ExplicitConstructorCall) statement).accessMode == ExplicitConstructorCall.ImplicitSuper);
2131 int sourceStart = statement.sourceStart;
2132 int sourceEnd = statement.sourceEnd;
2133 if (statement instanceof AllocationExpression) {
2134 AllocationExpression allocation = (AllocationExpression)statement;
2135 if (allocation.enumConstant != null) {
2136 sourceStart = allocation.enumConstant.sourceStart;
2137 sourceEnd = allocation.enumConstant.sourceEnd;
2141 int id = IProblem.UndefinedConstructor; //default...
2142 MethodBinding shownConstructor = targetConstructor;
2143 switch (targetConstructor.problemId()) {
2145 if (insideDefaultConstructor){
2146 id = IProblem.UndefinedConstructorInDefaultConstructor;
2147 } else if (insideImplicitConstructorCall){
2148 id = IProblem.UndefinedConstructorInImplicitConstructorCall;
2150 id = IProblem.UndefinedConstructor;
2154 if (insideDefaultConstructor){
2155 id = IProblem.NotVisibleConstructorInDefaultConstructor;
2156 } else if (insideImplicitConstructorCall){
2157 id = IProblem.NotVisibleConstructorInImplicitConstructorCall;
2159 id = IProblem.NotVisibleConstructor;
2161 ProblemMethodBinding problemConstructor = (ProblemMethodBinding) targetConstructor;
2162 if (problemConstructor.closestMatch != null) {
2163 shownConstructor = problemConstructor.closestMatch.original();
2167 if (insideDefaultConstructor){
2168 id = IProblem.AmbiguousConstructorInDefaultConstructor;
2169 } else if (insideImplicitConstructorCall){
2170 id = IProblem.AmbiguousConstructorInImplicitConstructorCall;
2172 id = IProblem.AmbiguousConstructor;
2175 case ParameterBoundMismatch :
2176 problemConstructor = (ProblemMethodBinding) targetConstructor;
2177 ParameterizedGenericMethodBinding substitutedConstructor = (ParameterizedGenericMethodBinding) problemConstructor.closestMatch;
2178 shownConstructor = substitutedConstructor.original();
2179 TypeBinding typeArgument = targetConstructor.parameters[0];
2180 TypeVariableBinding typeParameter = (TypeVariableBinding) targetConstructor.parameters[1];
2182 IProblem.GenericConstructorTypeArgumentMismatch,
2184 new String(shownConstructor.declaringClass.sourceName()),
2185 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false),
2186 new String(shownConstructor.declaringClass.readableName()),
2187 typesAsString(substitutedConstructor.isVarargs(), substitutedConstructor.parameters, false),
2188 new String(typeArgument.readableName()),
2189 new String(typeParameter.sourceName),
2190 parameterBoundAsString(typeParameter, false) },
2192 new String(shownConstructor.declaringClass.sourceName()),
2193 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true),
2194 new String(shownConstructor.declaringClass.shortReadableName()),
2195 typesAsString(substitutedConstructor.isVarargs(), substitutedConstructor.parameters, true),
2196 new String(typeArgument.shortReadableName()),
2197 new String(typeParameter.sourceName),
2198 parameterBoundAsString(typeParameter, true) },
2203 case TypeParameterArityMismatch :
2204 problemConstructor = (ProblemMethodBinding) targetConstructor;
2205 shownConstructor = problemConstructor.closestMatch;
2206 if (shownConstructor.typeVariables == TypeConstants.NoTypeVariables) {
2208 IProblem.NonGenericConstructor,
2210 new String(shownConstructor.declaringClass.sourceName()),
2211 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false),
2212 new String(shownConstructor.declaringClass.readableName()),
2213 typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false) },
2215 new String(shownConstructor.declaringClass.sourceName()),
2216 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true),
2217 new String(shownConstructor.declaringClass.shortReadableName()),
2218 typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true) },
2223 IProblem.IncorrectArityForParameterizedConstructor ,
2225 new String(shownConstructor.declaringClass.sourceName()),
2226 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false),
2227 new String(shownConstructor.declaringClass.readableName()),
2228 typesAsString(false, shownConstructor.typeVariables, false),
2229 typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false) },
2231 new String(shownConstructor.declaringClass.sourceName()),
2232 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true),
2233 new String(shownConstructor.declaringClass.shortReadableName()),
2234 typesAsString(false, shownConstructor.typeVariables, true),
2235 typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true) },
2240 case ParameterizedMethodTypeMismatch :
2241 problemConstructor = (ProblemMethodBinding) targetConstructor;
2242 shownConstructor = problemConstructor.closestMatch;
2244 IProblem.ParameterizedConstructorArgumentTypeMismatch,
2246 new String(shownConstructor.declaringClass.sourceName()),
2247 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false),
2248 new String(shownConstructor.declaringClass.readableName()),
2249 typesAsString(false, ((ParameterizedGenericMethodBinding)shownConstructor).typeArguments, false),
2250 typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false) },
2252 new String(shownConstructor.declaringClass.sourceName()),
2253 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true),
2254 new String(shownConstructor.declaringClass.shortReadableName()),
2255 typesAsString(false, ((ParameterizedGenericMethodBinding)shownConstructor).typeArguments, true),
2256 typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true) },
2260 case TypeArgumentsForRawGenericMethod :
2261 problemConstructor = (ProblemMethodBinding) targetConstructor;
2262 shownConstructor = problemConstructor.closestMatch;
2264 IProblem.TypeArgumentsForRawGenericConstructor,
2266 new String(shownConstructor.declaringClass.sourceName()),
2267 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false),
2268 new String(shownConstructor.declaringClass.readableName()),
2269 typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false) },
2271 new String(shownConstructor.declaringClass.sourceName()),
2272 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true),
2273 new String(shownConstructor.declaringClass.shortReadableName()),
2274 typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true) },
2280 needImplementation(); // want to fail to see why we were here...
2286 new String[] {new String(targetConstructor.declaringClass.readableName()), typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false)},
2287 new String[] {new String(targetConstructor.declaringClass.shortReadableName()), typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true)},
2291 public void invalidContinue(ASTNode location) {
2293 IProblem.InvalidContinue,
2296 location.sourceStart,
2297 location.sourceEnd);
2299 public void invalidEnclosingType(Expression expression, TypeBinding type, ReferenceBinding enclosingType) {
2301 if (enclosingType.isAnonymousType()) enclosingType = enclosingType.superclass();
2302 int flag = IProblem.UndefinedType; // default
2303 switch (type.problemId()) {
2304 case NotFound : // 1
2305 flag = IProblem.UndefinedType;
2307 case NotVisible : // 2
2308 flag = IProblem.NotVisibleType;
2310 case Ambiguous : // 3
2311 flag = IProblem.AmbiguousType;
2313 case InternalNameProvided :
2314 flag = IProblem.InternalTypeNameProvided;
2318 needImplementation(); // want to fail to see why we were here...
2324 new String[] {new String(enclosingType.readableName()) + "." + new String(type.readableName())}, //$NON-NLS-1$
2325 new String[] {new String(enclosingType.shortReadableName()) + "." + new String(type.shortReadableName())}, //$NON-NLS-1$
2326 expression.sourceStart,
2327 expression.sourceEnd);
2330 public void invalidExplicitConstructorCall(ASTNode location) {
2333 IProblem.InvalidExplicitConstructorCall,
2336 location.sourceStart,
2337 location.sourceEnd);
2340 public void invalidExpressionAsStatement(Expression expression){
2342 IProblem.InvalidExpressionAsStatement,
2345 expression.sourceStart,
2346 expression.sourceEnd);
2348 public void invalidField(FieldReference fieldRef, TypeBinding searchedType) {
2349 int id = IProblem.UndefinedField;
2350 FieldBinding field = fieldRef.binding;
2351 switch (field.problemId()) {
2353 id = IProblem.UndefinedField;
2354 /* also need to check that the searchedType is the receiver type
2355 if (searchedType.isHierarchyInconsistent())
2356 severity = SecondaryError;
2360 id = IProblem.NotVisibleField;
2363 id = IProblem.AmbiguousField;
2365 case NonStaticReferenceInStaticContext :
2366 id = IProblem.NonStaticFieldFromStaticInvocation;
2368 case NonStaticReferenceInConstructorInvocation :
2369 id = IProblem.InstanceFieldDuringConstructorInvocation;
2371 case InheritedNameHidesEnclosingName :
2372 id = IProblem.InheritedFieldHidesEnclosingName;
2374 case ReceiverTypeNotVisible :
2376 IProblem.NotVisibleType, // cannot occur in javadoc comments
2377 new String[] {new String(searchedType.leafComponentType().readableName())},
2378 new String[] {new String(searchedType.leafComponentType().shortReadableName())},
2379 fieldRef.receiver.sourceStart,
2380 fieldRef.receiver.sourceEnd);
2385 needImplementation(); // want to fail to see why we were here...
2389 String[] arguments = new String[] {new String(field.readableName())};
2394 fieldRef.sourceStart,
2395 fieldRef.sourceEnd);
2397 public void invalidField(NameReference nameRef, FieldBinding field) {
2398 int id = IProblem.UndefinedField;
2399 switch (field.problemId()) {
2401 id = IProblem.UndefinedField;
2404 id = IProblem.NotVisibleField;
2407 id = IProblem.AmbiguousField;
2409 case NonStaticReferenceInStaticContext :
2410 id = IProblem.NonStaticFieldFromStaticInvocation;
2412 case NonStaticReferenceInConstructorInvocation :
2413 id = IProblem.InstanceFieldDuringConstructorInvocation;
2415 case InheritedNameHidesEnclosingName :
2416 id = IProblem.InheritedFieldHidesEnclosingName;
2418 case ReceiverTypeNotVisible :
2420 IProblem.NotVisibleType,
2421 new String[] {new String(field.declaringClass.leafComponentType().readableName())},
2422 new String[] {new String(field.declaringClass.leafComponentType().shortReadableName())},
2423 nameRef.sourceStart,
2428 needImplementation(); // want to fail to see why we were here...
2431 String[] arguments = new String[] {new String(field.readableName())};
2436 nameRef.sourceStart,
2439 public void invalidField(QualifiedNameReference nameRef, FieldBinding field, int index, TypeBinding searchedType) {
2440 //the resolution of the index-th field of qname failed
2441 //qname.otherBindings[index] is the binding that has produced the error
2443 //The different targetted errors should be :
2448 if (searchedType.isBaseType()) {
2450 IProblem.NoFieldOnBaseType,
2452 new String(searchedType.readableName()),
2453 CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index)),
2454 new String(nameRef.tokens[index])},
2456 new String(searchedType.sourceName()),
2457 CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index)),
2458 new String(nameRef.tokens[index])},
2459 nameRef.sourceStart,
2460 (int) nameRef.sourcePositions[index]);
2464 int id = IProblem.UndefinedField;
2465 switch (field.problemId()) {
2467 id = IProblem.UndefinedField;
2468 /* also need to check that the searchedType is the receiver type
2469 if (searchedType.isHierarchyInconsistent())
2470 severity = SecondaryError;
2474 id = IProblem.NotVisibleField;
2477 id = IProblem.AmbiguousField;
2479 case NonStaticReferenceInStaticContext :
2480 id = IProblem.NonStaticFieldFromStaticInvocation;
2482 case NonStaticReferenceInConstructorInvocation :
2483 id = IProblem.InstanceFieldDuringConstructorInvocation;
2485 case InheritedNameHidesEnclosingName :
2486 id = IProblem.InheritedFieldHidesEnclosingName;
2488 case ReceiverTypeNotVisible :
2490 IProblem.NotVisibleType,
2491 new String[] {new String(searchedType.leafComponentType().readableName())},
2492 new String[] {new String(searchedType.leafComponentType().shortReadableName())},
2493 nameRef.sourceStart,
2498 needImplementation(); // want to fail to see why we were here...
2501 String[] arguments = new String[] {CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index + 1))};
2506 nameRef.sourceStart,
2507 (int) nameRef.sourcePositions[index]);
2509 public void invalidFileNameForPackageAnnotations(Annotation annotation) {
2511 IProblem.InvalidFileNameForPackageAnnotations,
2514 annotation.sourceStart,
2515 annotation.sourceEnd);
2517 public void invalidMethod(MessageSend messageSend, MethodBinding method) {
2518 int id = IProblem.UndefinedMethod; //default...
2519 MethodBinding shownMethod = method;
2520 switch (method.problemId()) {
2522 id = IProblem.UndefinedMethod;
2523 ProblemMethodBinding problemMethod = (ProblemMethodBinding) method;
2524 if (problemMethod.closestMatch != null) {
2525 shownMethod = problemMethod.closestMatch;
2526 String closestParameterTypeNames = typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false);
2527 String parameterTypeNames = typesAsString(method.isVarargs(), method.parameters, false);
2528 String closestParameterTypeShortNames = typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true);
2529 String parameterTypeShortNames = typesAsString(method.isVarargs(), method.parameters, true);
2530 if (closestParameterTypeShortNames.equals(parameterTypeShortNames)){
2531 closestParameterTypeShortNames = closestParameterTypeNames;
2532 parameterTypeShortNames = parameterTypeNames;
2535 IProblem.ParameterMismatch,
2537 new String(shownMethod.declaringClass.readableName()),
2538 new String(shownMethod.selector),
2539 closestParameterTypeNames,
2543 new String(shownMethod.declaringClass.shortReadableName()),
2544 new String(shownMethod.selector),
2545 closestParameterTypeShortNames,
2546 parameterTypeShortNames
2548 (int) (messageSend.nameSourcePosition >>> 32),
2549 (int) messageSend.nameSourcePosition);
2554 id = IProblem.NotVisibleMethod;
2555 problemMethod = (ProblemMethodBinding) method;
2556 if (problemMethod.closestMatch != null) {
2557 shownMethod = problemMethod.closestMatch.original();
2561 id = IProblem.AmbiguousMethod;
2563 case InheritedNameHidesEnclosingName :
2564 id = IProblem.InheritedMethodHidesEnclosingName;
2566 case NonStaticReferenceInConstructorInvocation :
2567 id = IProblem.InstanceMethodDuringConstructorInvocation;
2569 case NonStaticReferenceInStaticContext :
2570 id = IProblem.StaticMethodRequested;
2572 case ReceiverTypeNotVisible :
2574 IProblem.NotVisibleType, // cannot occur in javadoc comments
2575 new String[] {new String(method.declaringClass.leafComponentType().readableName())},
2576 new String[] {new String(method.declaringClass.leafComponentType().shortReadableName())},
2577 messageSend.receiver.sourceStart,
2578 messageSend.receiver.sourceEnd);
2580 case ParameterBoundMismatch :
2581 problemMethod = (ProblemMethodBinding) method;
2582 ParameterizedGenericMethodBinding substitutedMethod = (ParameterizedGenericMethodBinding) problemMethod.closestMatch;
2583 shownMethod = substitutedMethod.original();
2584 TypeBinding typeArgument = method.parameters[0];
2585 TypeVariableBinding typeParameter = (TypeVariableBinding) method.parameters[1];
2587 IProblem.GenericMethodTypeArgumentMismatch,
2589 new String(shownMethod.selector),
2590 typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false),
2591 new String(shownMethod.declaringClass.readableName()),
2592 typesAsString(substitutedMethod.isVarargs(), substitutedMethod.parameters, false),
2593 new String(typeArgument.readableName()),
2594 new String(typeParameter.sourceName),
2595 parameterBoundAsString(typeParameter, false) },
2597 new String(shownMethod.selector),
2598 typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true),
2599 new String(shownMethod.declaringClass.shortReadableName()),
2600 typesAsString(substitutedMethod.isVarargs(), substitutedMethod.parameters, true),
2601 new String(typeArgument.shortReadableName()),
2602 new String(typeParameter.sourceName),
2603 parameterBoundAsString(typeParameter, true) },
2604 (int) (messageSend.nameSourcePosition >>> 32),
2605 (int) messageSend.nameSourcePosition);
2607 case TypeParameterArityMismatch :
2608 problemMethod = (ProblemMethodBinding) method;
2609 shownMethod = problemMethod.closestMatch;
2610 if (shownMethod.typeVariables == TypeConstants.NoTypeVariables) {
2612 IProblem.NonGenericMethod ,
2614 new String(shownMethod.selector),
2615 typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false),
2616 new String(shownMethod.declaringClass.readableName()),
2617 typesAsString(method.isVarargs(), method.parameters, false) },
2619 new String(shownMethod.selector),
2620 typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true),
2621 new String(shownMethod.declaringClass.shortReadableName()),
2622 typesAsString(method.isVarargs(), method.parameters, true) },
2623 (int) (messageSend.nameSourcePosition >>> 32),
2624 (int) messageSend.nameSourcePosition);
2627 IProblem.IncorrectArityForParameterizedMethod ,
2629 new String(shownMethod.selector),
2630 typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false),
2631 new String(shownMethod.declaringClass.readableName()),
2632 typesAsString(false, shownMethod.typeVariables, false),
2633 typesAsString(method.isVarargs(), method.parameters, false) },
2635 new String(shownMethod.selector),
2636 typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true),
2637 new String(shownMethod.declaringClass.shortReadableName()),
2638 typesAsString(false, shownMethod.typeVariables, true),
2639 typesAsString(method.isVarargs(), method.parameters, true) },
2640 (int) (messageSend.nameSourcePosition >>> 32),
2641 (int) messageSend.nameSourcePosition);
2644 case ParameterizedMethodTypeMismatch :
2645 problemMethod = (ProblemMethodBinding) method;
2646 shownMethod = problemMethod.closestMatch;
2648 IProblem.ParameterizedMethodArgumentTypeMismatch,
2650 new String(shownMethod.selector),
2651 typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false),
2652 new String(shownMethod.declaringClass.readableName()),
2653 typesAsString(false, ((ParameterizedGenericMethodBinding)shownMethod).typeArguments, false),
2654 typesAsString(method.isVarargs(), method.parameters, false) },
2656 new String(shownMethod.selector),
2657 typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true),
2658 new String(shownMethod.declaringClass.shortReadableName()),
2659 typesAsString(false, ((ParameterizedGenericMethodBinding)shownMethod).typeArguments, true),
2660 typesAsString(method.isVarargs(), method.parameters, true) },
2661 (int) (messageSend.nameSourcePosition >>> 32),
2662 (int) messageSend.nameSourcePosition);
2664 case TypeArgumentsForRawGenericMethod :
2665 problemMethod = (ProblemMethodBinding) method;
2666 shownMethod = problemMethod.closestMatch;
2668 IProblem.TypeArgumentsForRawGenericMethod ,
2670 new String(shownMethod.selector),
2671 typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false),
2672 new String(shownMethod.declaringClass.readableName()),
2673 typesAsString(method.isVarargs(), method.parameters, false) },
2675 new String(shownMethod.selector),
2676 typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true),
2677 new String(shownMethod.declaringClass.shortReadableName()),
2678 typesAsString(method.isVarargs(), method.parameters, true) },
2679 (int) (messageSend.nameSourcePosition >>> 32),
2680 (int) messageSend.nameSourcePosition);
2684 needImplementation(); // want to fail to see why we were here...
2691 new String(method.declaringClass.readableName()),
2692 new String(shownMethod.selector), typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false)},
2694 new String(method.declaringClass.shortReadableName()),
2695 new String(shownMethod.selector), typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true)},
2696 (int) (messageSend.nameSourcePosition >>> 32),
2697 (int) messageSend.nameSourcePosition);
2699 public void invalidNullToSynchronize(Expression expression) {
2701 IProblem.InvalidNullToSynchronized,
2704 expression.sourceStart,
2705 expression.sourceEnd);
2707 public void invalidOperator(BinaryExpression expression, TypeBinding leftType, TypeBinding rightType) {
2708 String leftName = new String(leftType.readableName());
2709 String rightName = new String(rightType.readableName());
2710 String leftShortName = new String(leftType.shortReadableName());
2711 String rightShortName = new String(rightType.shortReadableName());
2712 if (leftShortName.equals(rightShortName)){
2713 leftShortName = leftName;
2714 rightShortName = rightName;
2717 IProblem.InvalidOperator,
2719 expression.operatorToString(),
2720 leftName + ", " + rightName}, //$NON-NLS-1$
2722 expression.operatorToString(),
2723 leftShortName + ", " + rightShortName}, //$NON-NLS-1$
2724 expression.sourceStart,
2725 expression.sourceEnd);
2727 public void invalidOperator(CompoundAssignment assign, TypeBinding leftType, TypeBinding rightType) {
2728 String leftName = new String(leftType.readableName());
2729 String rightName = new String(rightType.readableName());
2730 String leftShortName = new String(leftType.shortReadableName());
2731 String rightShortName = new String(rightType.shortReadableName());
2732 if (leftShortName.equals(rightShortName)){
2733 leftShortName = leftName;
2734 rightShortName = rightName;
2737 IProblem.InvalidOperator,
2739 assign.operatorToString(),
2740 leftName + ", " + rightName}, //$NON-NLS-1$
2742 assign.operatorToString(),
2743 leftShortName + ", " + rightShortName}, //$NON-NLS-1$
2747 public void invalidOperator(UnaryExpression expression, TypeBinding type) {
2749 IProblem.InvalidOperator,
2750 new String[] {expression.operatorToString(), new String(type.readableName())},
2751 new String[] {expression.operatorToString(), new String(type.shortReadableName())},
2752 expression.sourceStart,
2753 expression.sourceEnd);
2755 public void invalidParameterizedExceptionType(TypeBinding exceptionType, ASTNode location) {
2757 IProblem.InvalidParameterizedExceptionType,
2758 new String[] {new String(exceptionType.readableName())},
2759 new String[] {new String(exceptionType.shortReadableName())},
2760 location.sourceStart,
2761 location.sourceEnd);
2763 public void invalidParenthesizedExpression(ASTNode reference) {
2765 IProblem.InvalidParenthesizedExpression,
2768 reference.sourceStart,
2769 reference.sourceEnd);
2771 public void invalidType(ASTNode location, TypeBinding type) {
2772 int id = IProblem.UndefinedType; // default
2773 switch (type.problemId()) {
2775 id = IProblem.UndefinedType;
2778 id = IProblem.NotVisibleType;
2781 id = IProblem.AmbiguousType;
2783 case InternalNameProvided :
2784 id = IProblem.InternalTypeNameProvided;
2786 case InheritedNameHidesEnclosingName :
2787 id = IProblem.InheritedTypeHidesEnclosingName;
2789 case NonStaticReferenceInStaticContext :
2790 id = IProblem.TypeVariableReferenceFromStaticContext;
2792 case IllegalSuperTypeVariable :
2793 id = IProblem.IllegalTypeVariableSuperReference;
2797 needImplementation(); // want to fail to see why we were here...
2801 int end = location.sourceEnd;
2802 if (location instanceof QualifiedNameReference) {
2803 QualifiedNameReference ref = (QualifiedNameReference) location;
2804 if (ref.indexOfFirstFieldBinding >= 1)
2805 end = (int) ref.sourcePositions[ref.indexOfFirstFieldBinding - 1];
2806 } else if (location instanceof ArrayQualifiedTypeReference) {
2807 if (!(location instanceof ParameterizedQualifiedTypeReference)) {
2808 ArrayQualifiedTypeReference arrayQualifiedTypeReference = (ArrayQualifiedTypeReference) location;
2809 long[] positions = arrayQualifiedTypeReference.sourcePositions;
2810 end = (int) positions[positions.length - 1];
2812 } else if (location instanceof QualifiedTypeReference) {
2813 QualifiedTypeReference ref = (QualifiedTypeReference) location;
2814 if (type instanceof ReferenceBinding) {
2815 char[][] name = ((ReferenceBinding) type).compoundName;
2816 end = (int) ref.sourcePositions[name.length - 1];
2818 } else if (location instanceof ImportReference) {
2819 ImportReference ref = (ImportReference) location;
2820 if (type instanceof ReferenceBinding) {
2821 char[][] name = ((ReferenceBinding) type).compoundName;
2822 end = (int) ref.sourcePositions[name.length - 1];
2824 } else if (location instanceof ArrayTypeReference) {
2825 if (!(location instanceof ParameterizedSingleTypeReference)) {
2826 ArrayTypeReference arrayTypeReference = (ArrayTypeReference) location;
2827 end = arrayTypeReference.originalSourceEnd;
2832 new String[] {new String(type.leafComponentType().readableName()) },
2833 new String[] {new String(type.leafComponentType().shortReadableName())},
2834 location.sourceStart,
2837 public void invalidTypeForCollection(Expression expression) {
2839 IProblem.InvalidTypeForCollection,
2842 expression.sourceStart,
2843 expression.sourceEnd);
2845 public void invalidTypeReference(Expression expression) {
2847 IProblem.InvalidTypeExpression,
2850 expression.sourceStart,
2851 expression.sourceEnd);
2853 public void invalidTypeToSynchronize(Expression expression, TypeBinding type) {
2855 IProblem.InvalidTypeToSynchronized,
2856 new String[] {new String(type.readableName())},
2857 new String[] {new String(type.shortReadableName())},
2858 expression.sourceStart,
2859 expression.sourceEnd);
2861 public void invalidTypeVariableAsException(TypeBinding exceptionType, ASTNode location) {
2863 IProblem.InvalidTypeVariableExceptionType,
2864 new String[] {new String(exceptionType.readableName())},
2865 new String[] {new String(exceptionType.shortReadableName())},
2866 location.sourceStart,
2867 location.sourceEnd);
2869 public void invalidUnaryExpression(Expression expression) {
2871 IProblem.InvalidUnaryExpression,
2874 expression.sourceStart,
2875 expression.sourceEnd);
2877 public void invalidUsageOfAnnotation(Annotation annotation) {
2879 IProblem.InvalidUsageOfAnnotations,
2882 annotation.sourceStart,
2883 annotation.sourceEnd);
2885 public void invalidUsageOfAnnotationDeclarations(TypeDeclaration annotationTypeDeclaration) {
2887 IProblem.InvalidUsageOfAnnotationDeclarations,
2890 annotationTypeDeclaration.sourceStart,
2891 annotationTypeDeclaration.sourceEnd);
2893 public void invalidUsageOfEnumDeclarations(TypeDeclaration enumDeclaration) {
2895 IProblem.InvalidUsageOfEnumDeclarations,
2898 enumDeclaration.sourceStart,
2899 enumDeclaration.sourceEnd);
2901 public void invalidUsageOfForeachStatements(LocalDeclaration elementVariable, Expression collection) {
2903 IProblem.InvalidUsageOfForeachStatements,
2906 elementVariable.declarationSourceStart,
2907 collection.sourceEnd);
2909 public void invalidUsageOfStaticImports(ImportReference staticImport) {
2911 IProblem.InvalidUsageOfStaticImports,
2914 staticImport.declarationSourceStart,
2915 staticImport.declarationSourceEnd);
2917 public void invalidUsageOfTypeArguments(TypeReference firstTypeReference, TypeReference lastTypeReference) {
2919 IProblem.InvalidUsageOfTypeArguments,
2922 firstTypeReference.sourceStart,
2923 lastTypeReference.sourceEnd);
2925 public void invalidUsageOfTypeParameters(TypeParameter firstTypeParameter, TypeParameter lastTypeParameter) {
2927 IProblem.InvalidUsageOfTypeParameters,
2930 firstTypeParameter.declarationSourceStart,
2931 lastTypeParameter.declarationSourceEnd);
2933 public void invalidUsageOfVarargs(Argument argument) {
2935 IProblem.InvalidUsageOfVarargs,
2938 argument.type.sourceStart,
2939 argument.sourceEnd);
2941 public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl) {
2942 this.referenceContext = compUnitDecl;
2943 String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)};
2945 IProblem.IsClassPathCorrect,
2948 AbortCompilation | Error,
2953 private boolean isIdentifier(int token) {
2954 return token == TerminalTokens.TokenNameIdentifier;
2957 private boolean isKeyword(int token) {
2959 case TerminalTokens.TokenNameabstract:
2960 case TerminalTokens.TokenNameassert:
2961 case TerminalTokens.TokenNamebyte:
2962 case TerminalTokens.TokenNamebreak:
2963 case TerminalTokens.TokenNameboolean:
2964 case TerminalTokens.TokenNamecase:
2965 case TerminalTokens.TokenNamechar:
2966 case TerminalTokens.TokenNamecatch:
2967 case TerminalTokens.TokenNameclass:
2968 case TerminalTokens.TokenNamecontinue:
2969 case TerminalTokens.TokenNamedo:
2970 case TerminalTokens.TokenNamedouble:
2971 case TerminalTokens.TokenNamedefault:
2972 case TerminalTokens.TokenNameelse:
2973 case TerminalTokens.TokenNameextends:
2974 case TerminalTokens.TokenNamefor:
2975 case TerminalTokens.TokenNamefinal:
2976 case TerminalTokens.TokenNamefloat:
2977 case TerminalTokens.TokenNamefalse:
2978 case TerminalTokens.TokenNamefinally:
2979 case TerminalTokens.TokenNameif:
2980 case TerminalTokens.TokenNameint:
2981 case TerminalTokens.TokenNameimport:
2982 case TerminalTokens.TokenNameinterface:
2983 case TerminalTokens.TokenNameimplements:
2984 case TerminalTokens.TokenNameinstanceof:
2985 case TerminalTokens.TokenNamelong:
2986 case TerminalTokens.TokenNamenew:
2987 case TerminalTokens.TokenNamenull:
2988 case TerminalTokens.TokenNamenative:
2989 case TerminalTokens.TokenNamepublic:
2990 case TerminalTokens.TokenNamepackage:
2991 case TerminalTokens.TokenNameprivate:
2992 case TerminalTokens.TokenNameprotected:
2993 case TerminalTokens.TokenNamereturn:
2994 case TerminalTokens.TokenNameshort:
2995 case TerminalTokens.TokenNamesuper:
2996 case TerminalTokens.TokenNamestatic:
2997 case TerminalTokens.TokenNameswitch:
2998 case TerminalTokens.TokenNamestrictfp:
2999 case TerminalTokens.TokenNamesynchronized:
3000 case TerminalTokens.TokenNametry:
3001 case TerminalTokens.TokenNamethis:
3002 case TerminalTokens.TokenNametrue:
3003 case TerminalTokens.TokenNamethrow:
3004 case TerminalTokens.TokenNamethrows:
3005 case TerminalTokens.TokenNametransient:
3006 case TerminalTokens.TokenNamevoid:
3007 case TerminalTokens.TokenNamevolatile:
3008 case TerminalTokens.TokenNamewhile:
3015 private boolean isLiteral(int token) {
3017 case TerminalTokens.TokenNameIntegerLiteral:
3018 case TerminalTokens.TokenNameLongLiteral:
3019 case TerminalTokens.TokenNameFloatingPointLiteral:
3020 case TerminalTokens.TokenNameDoubleLiteral:
3021 case TerminalTokens.TokenNameStringLiteral:
3022 case TerminalTokens.TokenNameCharacterLiteral:
3028 public void javadocAmbiguousMethodReference(int sourceStart, int sourceEnd, Binding fieldBinding, int modifiers) {
3029 int id = IProblem.JavadocAmbiguousMethodReference;
3030 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3031 String[] arguments = new String[] {new String(fieldBinding.readableName())};
3032 handle(id, arguments, arguments, sourceStart, sourceEnd);
3035 public void javadocDeprecatedField(FieldBinding field, ASTNode location, int modifiers) {
3036 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3038 IProblem.JavadocUsingDeprecatedField,
3039 new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
3040 new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
3041 location.sourceStart,
3042 location.sourceEnd);
3045 public void javadocDeprecatedMethod(MethodBinding method, ASTNode location, int modifiers) {
3046 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3047 if (method.isConstructor()) {
3049 IProblem.JavadocUsingDeprecatedConstructor,
3050 new String[] {new String(method.declaringClass.readableName()), typesAsString(method.isVarargs(), method.parameters, false)},
3051 new String[] {new String(method.declaringClass.shortReadableName()), typesAsString(method.isVarargs(), method.parameters, true)},
3052 location.sourceStart,
3053 location.sourceEnd);
3056 IProblem.JavadocUsingDeprecatedMethod,
3057 new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
3058 new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
3059 location.sourceStart,
3060 location.sourceEnd);
3064 public void javadocDeprecatedType(TypeBinding type, ASTNode location, int modifiers) {
3065 if (location == null) return; // 1G828DN - no type ref for synthetic arguments
3066 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3068 IProblem.JavadocUsingDeprecatedType,
3069 new String[] {new String(type.readableName())},
3070 new String[] {new String(type.shortReadableName())},
3071 location.sourceStart,
3072 location.sourceEnd);
3075 public void javadocDuplicatedParamTag(char[] token, int sourceStart, int sourceEnd, int modifiers) {
3076 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3077 String[] arguments = new String[] {String.valueOf(token)};
3078 this.handle(IProblem.JavadocDuplicateParamName, arguments, arguments, sourceStart, sourceEnd);
3081 public void javadocDuplicatedReturnTag(int sourceStart, int sourceEnd){
3082 this.handle(IProblem.JavadocDuplicateReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd);
3084 public void javadocDuplicatedThrowsClassName(TypeReference typeReference, int modifiers) {
3085 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3086 String[] arguments = new String[] {String.valueOf(typeReference.resolvedType.sourceName())};
3087 this.handle(IProblem.JavadocDuplicateThrowsClassName, arguments, arguments, typeReference.sourceStart, typeReference.sourceEnd);
3090 public void javadocEmptyReturnTag(int sourceStart, int sourceEnd) {
3091 this.handle(IProblem.JavadocEmptyReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd);
3093 public void javadocErrorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params, int modifiers) {
3094 StringBuffer buffer = new StringBuffer();
3095 StringBuffer shortBuffer = new StringBuffer();
3096 for (int i = 0, length = params.length; i < length; i++) {
3098 buffer.append(", "); //$NON-NLS-1$
3099 shortBuffer.append(", "); //$NON-NLS-1$
3101 buffer.append(new String(params[i].readableName()));
3102 shortBuffer.append(new String(params[i].shortReadableName()));
3105 int id = recType.isArrayType() ? IProblem.JavadocNoMessageSendOnArrayType : IProblem.JavadocNoMessageSendOnBaseType;
3106 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3109 new String[] {new String(recType.readableName()), new String(messageSend.selector), buffer.toString()},
3110 new String[] {new String(recType.shortReadableName()), new String(messageSend.selector), shortBuffer.toString()},
3111 messageSend.sourceStart,
3112 messageSend.sourceEnd);
3115 public void javadocInvalidConstructor(Statement statement, MethodBinding targetConstructor, int modifiers) {
3117 if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) return;
3118 int id = IProblem.JavadocUndefinedConstructor; //default...
3119 switch (targetConstructor.problemId()) {
3121 id = IProblem.JavadocUndefinedConstructor;
3124 id = IProblem.JavadocNotVisibleConstructor;
3127 id = IProblem.JavadocAmbiguousConstructor;
3131 needImplementation(); // want to fail to see why we were here...
3136 new String[] {new String(targetConstructor.declaringClass.readableName()), typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false)},
3137 new String[] {new String(targetConstructor.declaringClass.shortReadableName()), typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true)},
3138 statement.sourceStart,
3139 statement.sourceEnd);
3142 * Similar implementation than invalidField(FieldReference...)
3143 * Note that following problem id cannot occur for Javadoc:
3144 * - NonStaticReferenceInStaticContext :
3145 * - NonStaticReferenceInConstructorInvocation :
3146 * - ReceiverTypeNotVisible :
3148 public void javadocInvalidField(int sourceStart, int sourceEnd, Binding fieldBinding, TypeBinding searchedType, int modifiers) {
3149 int id = IProblem.JavadocUndefinedField;
3150 switch (fieldBinding.problemId()) {
3152 id = IProblem.JavadocUndefinedField;
3155 id = IProblem.JavadocNotVisibleField;
3158 id = IProblem.JavadocAmbiguousField;
3160 case InheritedNameHidesEnclosingName :
3161 id = IProblem.JavadocInheritedFieldHidesEnclosingName;
3165 needImplementation(); // want to fail to see why we were here...
3169 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3170 String[] arguments = new String[] {new String(fieldBinding.readableName())};
3171 handle(id, arguments, arguments, sourceStart, sourceEnd);
3175 * Similar implementation than invalidMethod(MessageSend...)
3176 * Note that following problem id cannot occur for Javadoc:
3177 * - NonStaticReferenceInStaticContext :
3178 * - NonStaticReferenceInConstructorInvocation :
3179 * - ReceiverTypeNotVisible :
3181 public void javadocInvalidMethod(MessageSend messageSend, MethodBinding method, int modifiers) {
3182 if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) return;
3184 int id = IProblem.JavadocUndefinedMethod; //default...
3185 switch (method.problemId()) {
3187 id = IProblem.JavadocUndefinedMethod;
3190 id = IProblem.JavadocNotVisibleMethod;
3193 id = IProblem.JavadocAmbiguousMethod;
3195 case InheritedNameHidesEnclosingName :
3196 id = IProblem.JavadocInheritedMethodHidesEnclosingName;
3200 needImplementation(); // want to fail to see why we were here...
3203 if (id == IProblem.JavadocUndefinedMethod) {
3204 ProblemMethodBinding problemMethod = (ProblemMethodBinding) method;
3205 if (problemMethod.closestMatch != null) {
3206 String closestParameterTypeNames = typesAsString(problemMethod.closestMatch.isVarargs(), problemMethod.closestMatch.parameters, false);
3207 String parameterTypeNames = typesAsString(method.isVarargs(), method.parameters, false);
3208 String closestParameterTypeShortNames = typesAsString(problemMethod.closestMatch.isVarargs(), problemMethod.closestMatch.parameters, true);
3209 String parameterTypeShortNames = typesAsString(method.isVarargs(), method.parameters, true);
3210 if (closestParameterTypeShortNames.equals(parameterTypeShortNames)){
3211 closestParameterTypeShortNames = closestParameterTypeNames;
3212 parameterTypeShortNames = parameterTypeNames;
3215 IProblem.JavadocParameterMismatch,
3217 new String(problemMethod.closestMatch.declaringClass.readableName()),
3218 new String(problemMethod.closestMatch.selector),
3219 closestParameterTypeNames,
3223 new String(problemMethod.closestMatch.declaringClass.shortReadableName()),
3224 new String(problemMethod.closestMatch.selector),
3225 closestParameterTypeShortNames,
3226 parameterTypeShortNames
3228 (int) (messageSend.nameSourcePosition >>> 32),
3229 (int) messageSend.nameSourcePosition);
3237 new String(method.declaringClass.readableName()),
3238 new String(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
3240 new String(method.declaringClass.shortReadableName()),
3241 new String(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
3242 (int) (messageSend.nameSourcePosition >>> 32),
3243 (int) messageSend.nameSourcePosition);
3245 public void javadocInvalidParamTagName(int sourceStart, int sourceEnd) {
3246 this.handle(IProblem.JavadocInvalidParamTagName, NoArgument, NoArgument, sourceStart, sourceEnd);
3248 public void javadocInvalidParamTypeParameter(int sourceStart, int sourceEnd) {
3249 this.handle(IProblem.JavadocInvalidParamTagTypeParameter, NoArgument, NoArgument, sourceStart, sourceEnd);
3251 public void javadocInvalidReference(int sourceStart, int sourceEnd) {
3252 this.handle(IProblem.JavadocInvalidReference, NoArgument, NoArgument, sourceStart, sourceEnd);
3254 public void javadocInvalidSeeReferenceArgs(int sourceStart, int sourceEnd) {
3255 this.handle(IProblem.JavadocInvalidSeeArgs, NoArgument, NoArgument, sourceStart, sourceEnd);
3257 public void javadocInvalidSeeUrlReference(int sourceStart, int sourceEnd) {
3258 this.handle(IProblem.JavadocInvalidSeeHref, NoArgument, NoArgument, sourceStart, sourceEnd);
3260 public void javadocInvalidTag(int sourceStart, int sourceEnd) {
3261 this.handle(IProblem.JavadocInvalidTag, NoArgument, NoArgument, sourceStart, sourceEnd);
3263 public void javadocInvalidThrowsClass(int sourceStart, int sourceEnd) {
3264 this.handle(IProblem.JavadocInvalidThrowsClass, NoArgument, NoArgument, sourceStart, sourceEnd);
3266 public void javadocInvalidThrowsClassName(TypeReference typeReference, int modifiers) {
3267 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3268 String[] arguments = new String[] {String.valueOf(typeReference.resolvedType.sourceName())};
3269 this.handle(IProblem.JavadocInvalidThrowsClassName, arguments, arguments, typeReference.sourceStart, typeReference.sourceEnd);
3272 public void javadocInvalidType(ASTNode location, TypeBinding type, int modifiers) {
3273 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3274 int id = IProblem.JavadocUndefinedType; // default
3275 switch (type.problemId()) {
3277 id = IProblem.JavadocUndefinedType;
3280 id = IProblem.JavadocNotVisibleType;
3283 id = IProblem.JavadocAmbiguousType;
3285 case InternalNameProvided :
3286 id = IProblem.JavadocInternalTypeNameProvided;
3288 case InheritedNameHidesEnclosingName :
3289 id = IProblem.JavadocInheritedNameHidesEnclosingTypeName;
3293 needImplementation(); // want to fail to see why we were here...
3298 new String[] {new String(type.readableName())},
3299 new String[] {new String(type.shortReadableName())},
3300 location.sourceStart,
3301 location.sourceEnd);
3304 public void javadocInvalidValueReference(int sourceStart, int sourceEnd, int modifiers) {
3305 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
3306 this.handle(IProblem.JavadocInvalidValueReference, NoArgument, NoArgument, sourceStart, sourceEnd);
3308 public void javadocMalformedSeeReference(int sourceStart, int sourceEnd) {
3309 this.handle(IProblem.JavadocMalformedSeeReference, NoArgument, NoArgument, sourceStart, sourceEnd);
3311 public void javadocMissing(int sourceStart, int sourceEnd, int modifiers){
3312 boolean overriding = (modifiers & (CompilerModifiers.AccImplementing|CompilerModifiers.AccOverriding)) != 0;
3313 boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocComments) != ProblemSeverities.Ignore)
3314 && (!overriding || this.options.reportMissingJavadocCommentsOverriding);
3316 String arg = javadocVisibilityArgument(this.options.reportMissingJavadocCommentsVisibility, modifiers);
3318 String[] arguments = new String[] { arg };
3319 this.handle(IProblem.JavadocMissing, arguments, arguments, sourceStart, sourceEnd);
3323 public void javadocMissingHashCharacter(int sourceStart, int sourceEnd, String ref){
3324 String[] arguments = new String[] { ref };
3325 this.handle(IProblem.JavadocMissingHashCharacter, arguments, arguments, sourceStart, sourceEnd);
3327 public void javadocMissingParamName(int sourceStart, int sourceEnd, int modifiers){
3328 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
3329 this.handle(IProblem.JavadocMissingParamName, NoArgument, NoArgument, sourceStart, sourceEnd);
3331 public void javadocMissingParamTag(char[] name, int sourceStart, int sourceEnd, int modifiers) {
3332 boolean overriding = (modifiers & (CompilerModifiers.AccImplementing|CompilerModifiers.AccOverriding)) != 0;
3333 boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore)
3334 && (!overriding || this.options.reportMissingJavadocTagsOverriding);
3335 if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) {
3336 String[] arguments = new String[] { String.valueOf(name) };
3337 this.handle(IProblem.JavadocMissingParamTag, arguments, arguments, sourceStart, sourceEnd);
3340 public void javadocMissingReference(int sourceStart, int sourceEnd, int modifiers){
3341 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
3342 this.handle(IProblem.JavadocMissingReference, NoArgument, NoArgument, sourceStart, sourceEnd);
3344 public void javadocMissingReturnTag(int sourceStart, int sourceEnd, int modifiers){
3345 boolean overriding = (modifiers & (CompilerModifiers.AccImplementing|CompilerModifiers.AccOverriding)) != 0;
3346 boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore)
3347 && (!overriding || this.options.reportMissingJavadocTagsOverriding);
3348 if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) {
3349 this.handle(IProblem.JavadocMissingReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd);
3352 public void javadocMissingThrowsClassName(int sourceStart, int sourceEnd, int modifiers){
3353 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
3354 this.handle(IProblem.JavadocMissingThrowsClassName, NoArgument, NoArgument, sourceStart, sourceEnd);
3356 public void javadocMissingThrowsTag(TypeReference typeRef, int modifiers){
3357 boolean overriding = (modifiers & (CompilerModifiers.AccImplementing|CompilerModifiers.AccOverriding)) != 0;
3358 boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore)
3359 && (!overriding || this.options.reportMissingJavadocTagsOverriding);
3360 if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) {
3361 String[] arguments = new String[] { String.valueOf(typeRef.resolvedType.sourceName()) };
3362 this.handle(IProblem.JavadocMissingThrowsTag, arguments, arguments, typeRef.sourceStart, typeRef.sourceEnd);
3365 public void javadocUndeclaredParamTagName(char[] token, int sourceStart, int sourceEnd, int modifiers) {
3366 if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3367 String[] arguments = new String[] {String.valueOf(token)};
3368 this.handle(IProblem.JavadocInvalidParamName, arguments, arguments, sourceStart, sourceEnd);
3371 public void javadocUnexpectedTag(int sourceStart, int sourceEnd) {
3372 this.handle(IProblem.JavadocUnexpectedTag, NoArgument, NoArgument, sourceStart, sourceEnd);
3374 public void javadocUnexpectedText(int sourceStart, int sourceEnd) {
3375 this.handle(IProblem.JavadocUnexpectedText, NoArgument, NoArgument, sourceStart, sourceEnd);
3377 public void javadocUnterminatedInlineTag(int sourceStart, int sourceEnd) {
3378 this.handle(IProblem.JavadocUnterminatedInlineTag, NoArgument, NoArgument, sourceStart, sourceEnd);
3380 private boolean javadocVisibility(int visibility, int modifiers) {
3381 if (modifiers < 0) return true;
3382 switch (modifiers & CompilerModifiers.AccVisibilityMASK) {
3383 case IConstants.AccPublic :
3385 case IConstants.AccProtected:
3386 return (visibility != IConstants.AccPublic);
3387 case IConstants.AccDefault:
3388 return (visibility == IConstants.AccDefault || visibility == IConstants.AccPrivate);
3389 case IConstants.AccPrivate:
3390 return (visibility == IConstants.AccPrivate);
3394 private String javadocVisibilityArgument(int visibility, int modifiers) {
3395 String argument = null;
3396 switch (modifiers & CompilerModifiers.AccVisibilityMASK) {
3397 case IConstants.AccPublic :
3398 argument = CompilerOptions.PUBLIC;
3400 case IConstants.AccProtected:
3401 if (visibility != IConstants.AccPublic) {
3402 argument = CompilerOptions.PROTECTED;
3405 case IConstants.AccDefault:
3406 if (visibility == IConstants.AccDefault || visibility == IConstants.AccPrivate) {
3407 argument = CompilerOptions.DEFAULT;
3410 case IConstants.AccPrivate:
3411 if (visibility == IConstants.AccPrivate) {
3412 argument = CompilerOptions.PRIVATE;
3418 public void localVariableCannotBeNull(LocalVariableBinding local, ASTNode location) {
3419 String[] arguments = new String[] {new String(local.name) };
3421 IProblem.LocalVariableCannotBeNull,
3424 location.sourceStart,
3425 location.sourceEnd);
3427 public void localVariableCanOnlyBeNull(LocalVariableBinding local, ASTNode location) {
3428 String[] arguments = new String[] {new String(local.name) };
3430 IProblem.LocalVariableCanOnlyBeNull,
3433 location.sourceStart,
3434 location.sourceEnd);
3436 public void localVariableHiding(LocalDeclaration local, Binding hiddenVariable, boolean isSpecialArgHidingField) {
3437 if (hiddenVariable instanceof LocalVariableBinding) {
3438 String[] arguments = new String[] {new String(local.name) };
3440 (local instanceof Argument)
3441 ? IProblem.ArgumentHidingLocalVariable
3442 : IProblem.LocalVariableHidingLocalVariable,
3447 } else if (hiddenVariable instanceof FieldBinding) {
3448 if (isSpecialArgHidingField && !this.options.reportSpecialParameterHidingField){
3451 FieldBinding field = (FieldBinding) hiddenVariable;
3453 (local instanceof Argument)
3454 ? IProblem.ArgumentHidingField
3455 : IProblem.LocalVariableHidingField,
3456 new String[] {new String(local.name) , new String(field.declaringClass.readableName()) },
3457 new String[] {new String(local.name), new String(field.declaringClass.shortReadableName()) },
3462 public void methodNameClash(MethodBinding currentMethod, MethodBinding inheritedMethod) {
3464 IProblem.MethodNameClash,
3466 new String(currentMethod.selector),
3467 typesAsString(currentMethod.original().isVarargs(), currentMethod.original().parameters, false),
3468 new String(currentMethod.declaringClass.readableName()),
3469 typesAsString(inheritedMethod.original().isVarargs(), inheritedMethod.original().parameters, false),
3470 new String(inheritedMethod.declaringClass.readableName()),
3473 new String(currentMethod.selector),
3474 typesAsString(currentMethod.original().isVarargs(), currentMethod.original().parameters, true),
3475 new String(currentMethod.declaringClass.shortReadableName()),
3476 typesAsString(inheritedMethod.original().isVarargs(), inheritedMethod.original().parameters, true),
3477 new String(inheritedMethod.declaringClass.shortReadableName()),
3479 currentMethod.sourceStart(),
3480 currentMethod.sourceEnd());
3483 public void methodNeedBody(AbstractMethodDeclaration methodDecl) {
3485 IProblem.MethodRequiresBody,
3488 methodDecl.sourceStart,
3489 methodDecl.sourceEnd);
3491 public void methodNeedingNoBody(MethodDeclaration methodDecl) {
3493 ((methodDecl.modifiers & IConstants.AccNative) != 0) ? IProblem.BodyForNativeMethod : IProblem.BodyForAbstractMethod,
3496 methodDecl.sourceStart,
3497 methodDecl.sourceEnd);
3499 public void methodWithConstructorName(MethodDeclaration methodDecl) {
3501 IProblem.MethodButWithConstructorName,
3504 methodDecl.sourceStart,
3505 methodDecl.sourceEnd);
3507 public void parameterizedMemberTypeMissingArguments(ASTNode location, TypeBinding type) {
3508 if (location == null) { // binary case
3510 IProblem.MissingArgumentsForParameterizedMemberType,
3511 new String[] {new String(type.readableName())},
3512 new String[] {new String(type.shortReadableName())},
3513 AbortCompilation | Error,
3519 IProblem.MissingArgumentsForParameterizedMemberType,
3520 new String[] {new String(type.readableName())},
3521 new String[] {new String(type.shortReadableName())},
3522 location.sourceStart,
3523 location.sourceEnd);
3525 public void missingReturnType(AbstractMethodDeclaration methodDecl) {
3527 IProblem.MissingReturnType,
3530 methodDecl.sourceStart,
3531 methodDecl.sourceEnd);
3533 public void missingSemiColon(Expression expression){
3535 IProblem.MissingSemiColon,
3538 expression.sourceStart,
3539 expression.sourceEnd);
3541 public void missingSerialVersion(TypeDeclaration typeDecl) {
3542 String[] arguments = new String[] {new String(typeDecl.name)};
3544 IProblem.MissingSerialVersion,
3547 typeDecl.sourceStart,
3548 typeDecl.sourceEnd);
3550 public void missingValueForAnnotationMember(Annotation annotation, char[] memberName) {
3551 String memberString = new String(memberName);
3553 IProblem.MissingValueForAnnotationMember,
3554 new String[] {new String(annotation.resolvedType.readableName()), memberString },
3555 new String[] {new String(annotation.resolvedType.shortReadableName()), memberString},
3556 annotation.sourceStart,
3557 annotation.sourceEnd);
3559 public void mustDefineDimensionsOrInitializer(ArrayAllocationExpression expression) {
3561 IProblem.MustDefineEitherDimensionExpressionsOrInitializer,
3564 expression.sourceStart,
3565 expression.sourceEnd);
3567 public void mustSpecifyPackage(CompilationUnitDeclaration compUnitDecl) {
3568 String[] arguments = new String[] {new String(compUnitDecl.getFileName())};
3570 IProblem.MustSpecifyPackage,
3573 compUnitDecl.sourceStart,
3574 compUnitDecl.sourceStart + 1);
3576 public void mustUseAStaticMethod(MessageSend messageSend, MethodBinding method) {
3578 IProblem.StaticMethodRequested,
3579 new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
3580 new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
3581 messageSend.sourceStart,
3582 messageSend.sourceEnd);
3585 public void nativeMethodsCannotBeStrictfp(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
3586 String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
3588 IProblem.NativeMethodsCannotBeStrictfp,
3591 methodDecl.sourceStart,
3592 methodDecl.sourceEnd);
3594 public void needImplementation() {
3595 this.abortDueToInternalError(Util.bind("abort.missingCode")); //$NON-NLS-1$
3597 public void needToEmulateFieldAccess(FieldBinding field, ASTNode location, boolean isReadAccess) {
3600 ? IProblem.NeedToEmulateFieldReadAccess
3601 : IProblem.NeedToEmulateFieldWriteAccess,
3602 new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
3603 new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
3604 location.sourceStart,
3605 location.sourceEnd);
3607 public void needToEmulateMethodAccess(
3608 MethodBinding method,
3611 if (method.isConstructor())
3613 IProblem.NeedToEmulateConstructorAccess,
3615 new String(method.declaringClass.readableName()),
3616 typesAsString(method.isVarargs(), method.parameters, false)
3619 new String(method.declaringClass.shortReadableName()),
3620 typesAsString(method.isVarargs(), method.parameters, true)
3622 location.sourceStart,
3623 location.sourceEnd);
3626 IProblem.NeedToEmulateMethodAccess,
3628 new String(method.declaringClass.readableName()),
3629 new String(method.selector),
3630 typesAsString(method.isVarargs(), method.parameters, false)
3633 new String(method.declaringClass.shortReadableName()),
3634 new String(method.selector),
3635 typesAsString(method.isVarargs(), method.parameters, true)
3637 location.sourceStart,
3638 location.sourceEnd);
3640 public void nestedClassCannotDeclareInterface(TypeDeclaration typeDecl) {
3641 String[] arguments = new String[] {new String(typeDecl.name)};
3643 IProblem.CannotDefineInterfaceInLocalType,
3646 typeDecl.sourceStart,
3647 typeDecl.sourceEnd);
3649 public void noMoreAvailableSpaceForArgument(LocalVariableBinding local, ASTNode location) {
3650 String[] arguments = new String[]{ new String(local.name) };
3652 local instanceof SyntheticArgumentBinding
3653 ? IProblem.TooManySyntheticArgumentSlots
3654 : IProblem.TooManyArgumentSlots,
3658 location.sourceStart,
3659 location.sourceEnd);
3662 public void noMoreAvailableSpaceForConstant(TypeDeclaration typeDeclaration) {
3664 IProblem.TooManyBytesForStringConstant,
3665 new String[]{ new String(typeDeclaration.binding.readableName())},
3666 new String[]{ new String(typeDeclaration.binding.shortReadableName())},
3668 typeDeclaration.sourceStart,
3669 typeDeclaration.sourceEnd);
3671 public void noMoreAvailableSpaceForLocal(LocalVariableBinding local, ASTNode location) {
3672 String[] arguments = new String[]{ new String(local.name) };
3674 IProblem.TooManyLocalVariableSlots,
3678 location.sourceStart,
3679 location.sourceEnd);
3682 public void noMoreAvailableSpaceInConstantPool(TypeDeclaration typeDeclaration) {
3684 IProblem.TooManyConstantsInConstantPool,
3685 new String[]{ new String(typeDeclaration.binding.readableName())},
3686 new String[]{ new String(typeDeclaration.binding.shortReadableName())},
3688 typeDeclaration.sourceStart,
3689 typeDeclaration.sourceEnd);
3691 public void nonExternalizedStringLiteral(ASTNode location) {
3693 IProblem.NonExternalizedStringLiteral,
3696 location.sourceStart,
3697 location.sourceEnd);
3699 public void nonGenericTypeCannotBeParameterized(ASTNode location, TypeBinding type, TypeBinding[] argumentTypes) {
3700 if (location == null) { // binary case
3702 IProblem.NonGenericType,
3703 new String[] {new String(type.readableName()), typesAsString(false, argumentTypes, false)},
3704 new String[] {new String(type.shortReadableName()), typesAsString(false, argumentTypes, true)},
3705 AbortCompilation | Error,
3711 IProblem.NonGenericType,
3712 new String[] {new String(type.readableName()), typesAsString(false, argumentTypes, false)},
3713 new String[] {new String(type.shortReadableName()), typesAsString(false, argumentTypes, true)},
3714 location.sourceStart,
3715 location.sourceEnd);
3717 public void nonStaticAccessToStaticField(ASTNode location, FieldBinding field) {
3719 IProblem.NonStaticAccessToStaticField,
3720 new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
3721 new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
3722 location.sourceStart,
3723 fieldLocation(field, location));
3725 public void nonStaticAccessToStaticMethod(ASTNode location, MethodBinding method) {
3727 IProblem.NonStaticAccessToStaticMethod,
3728 new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
3729 new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
3730 location.sourceStart,
3731 location.sourceEnd);
3733 public void noSuchEnclosingInstance(TypeBinding targetType, ASTNode location, boolean isConstructorCall) {
3737 if (isConstructorCall) {
3738 //28 = No enclosing instance of type {0} is available due to some intermediate constructor invocation
3739 id = IProblem.EnclosingInstanceInConstructorCall;
3740 } else if ((location instanceof ExplicitConstructorCall)
3741 && ((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper) {
3742 //20 = No enclosing instance of type {0} is accessible to invoke the super constructor. Must define a constructor and explicitly qualify its super constructor invocation with an instance of {0} (e.g. x.super() where x is an instance of {0}).
3743 id = IProblem.MissingEnclosingInstanceForConstructorCall;
3744 } else if (location instanceof AllocationExpression
3745 && (((AllocationExpression) location).binding.declaringClass.isMemberType()
3746 || (((AllocationExpression) location).binding.declaringClass.isAnonymousType()
3747 && ((AllocationExpression) location).binding.declaringClass.superclass().isMemberType()))) {
3748 //21 = No enclosing instance of type {0} is accessible. Must qualify the allocation with an enclosing instance of type {0} (e.g. x.new A() where x is an instance of {0}).
3749 id = IProblem.MissingEnclosingInstance;
3751 //22 = No enclosing instance of the type {0} is accessible in scope
3752 id = IProblem.IncorrectEnclosingInstanceReference;
3757 new String[] { new String(targetType.readableName())},
3758 new String[] { new String(targetType.shortReadableName())},
3759 location.sourceStart,
3760 location.sourceEnd);
3762 public void notCompatibleTypesError(EqualExpression expression, TypeBinding leftType, TypeBinding rightType) {
3763 String leftName = new String(leftType.readableName());
3764 String rightName = new String(rightType.readableName());
3765 String leftShortName = new String(leftType.shortReadableName());
3766 String rightShortName = new String(rightType.shortReadableName());
3767 if (leftShortName.equals(rightShortName)){
3768 leftShortName = leftName;
3769 rightShortName = rightName;
3772 IProblem.IncompatibleTypesInEqualityOperator,
3773 new String[] {leftName, rightName },
3774 new String[] {leftShortName, rightShortName },
3775 expression.sourceStart,
3776 expression.sourceEnd);
3778 public void notCompatibleTypesError(InstanceOfExpression expression, TypeBinding leftType, TypeBinding rightType) {
3779 String leftName = new String(leftType.readableName());
3780 String rightName = new String(rightType.readableName());
3781 String leftShortName = new String(leftType.shortReadableName());
3782 String rightShortName = new String(rightType.shortReadableName());
3783 if (leftShortName.equals(rightShortName)){
3784 leftShortName = leftName;
3785 rightShortName = rightName;
3788 IProblem.IncompatibleTypesInConditionalOperator,
3789 new String[] {leftName, rightName },
3790 new String[] {leftShortName, rightShortName },
3791 expression.sourceStart,
3792 expression.sourceEnd);
3794 public void notCompatibleTypesErrorInForeach(Expression expression, TypeBinding leftType, TypeBinding rightType) {
3795 String leftName = new String(leftType.readableName());
3796 String rightName = new String(rightType.readableName());
3797 String leftShortName = new String(leftType.shortReadableName());
3798 String rightShortName = new String(rightType.shortReadableName());
3799 if (leftShortName.equals(rightShortName)){
3800 leftShortName = leftName;
3801 rightShortName = rightName;
3804 IProblem.IncompatibleTypesInForeach,
3805 new String[] {leftName, rightName },
3806 new String[] {leftShortName, rightShortName },
3807 expression.sourceStart,
3808 expression.sourceEnd);
3810 public void objectCannotBeGeneric(TypeDeclaration typeDecl) {
3812 IProblem.ObjectCannotBeGeneric,
3815 typeDecl.typeParameters[0].sourceStart,
3816 typeDecl.typeParameters[typeDecl.typeParameters.length-1].sourceEnd);
3818 public void objectCannotHaveSuperTypes(SourceTypeBinding type) {
3820 IProblem.ObjectCannotHaveSuperTypes,
3826 public void objectMustBeClass(SourceTypeBinding type) {
3828 IProblem.ObjectMustBeClass,
3834 public void operatorOnlyValidOnNumericType(CompoundAssignment assignment, TypeBinding leftType, TypeBinding rightType) {
3835 String leftName = new String(leftType.readableName());
3836 String rightName = new String(rightType.readableName());
3837 String leftShortName = new String(leftType.shortReadableName());
3838 String rightShortName = new String(rightType.shortReadableName());
3839 if (leftShortName.equals(rightShortName)){
3840 leftShortName = leftName;
3841 rightShortName = rightName;
3844 IProblem.TypeMismatch,
3845 new String[] {leftName, rightName },
3846 new String[] {leftShortName, rightShortName },
3847 assignment.sourceStart,
3848 assignment.sourceEnd);
3850 public void overridesDeprecatedMethod(MethodBinding localMethod, MethodBinding inheritedMethod) {
3852 IProblem.OverridingDeprecatedMethod,
3855 CharOperation.concat(
3856 localMethod.declaringClass.readableName(),
3857 localMethod.readableName(),
3859 new String(inheritedMethod.declaringClass.readableName())},
3862 CharOperation.concat(
3863 localMethod.declaringClass.shortReadableName(),
3864 localMethod.shortReadableName(),
3866 new String(inheritedMethod.declaringClass.shortReadableName())},
3867 localMethod.sourceStart(),
3868 localMethod.sourceEnd());
3870 public void overridesPackageDefaultMethod(MethodBinding localMethod, MethodBinding inheritedMethod) {
3872 IProblem.OverridingNonVisibleMethod,
3875 CharOperation.concat(
3876 localMethod.declaringClass.readableName(),
3877 localMethod.readableName(),
3879 new String(inheritedMethod.declaringClass.readableName())},
3882 CharOperation.concat(
3883 localMethod.declaringClass.shortReadableName(),
3884 localMethod.shortReadableName(),
3886 new String(inheritedMethod.declaringClass.shortReadableName())},
3887 localMethod.sourceStart(),
3888 localMethod.sourceEnd());
3890 public void packageCollidesWithType(CompilationUnitDeclaration compUnitDecl) {
3891 String[] arguments = new String[] {CharOperation.toString(compUnitDecl.currentPackage.tokens)};
3893 IProblem.PackageCollidesWithType,
3896 compUnitDecl.currentPackage.sourceStart,
3897 compUnitDecl.currentPackage.sourceEnd);
3899 public void packageIsNotExpectedPackage(CompilationUnitDeclaration compUnitDecl) {
3900 String[] arguments = new String[] {CharOperation.toString(compUnitDecl.compilationResult.compilationUnit.getPackageName())};
3902 IProblem.PackageIsNotExpectedPackage,
3905 compUnitDecl.currentPackage == null ? 0 : compUnitDecl.currentPackage.sourceStart,
3906 compUnitDecl.currentPackage == null ? 0 : compUnitDecl.currentPackage.sourceEnd);
3908 private String parameterBoundAsString(TypeVariableBinding typeVariable, boolean makeShort) {
3909 StringBuffer nameBuffer = new StringBuffer(10);
3910 if (typeVariable.firstBound == typeVariable.superclass) {
3911 nameBuffer.append(makeShort ? typeVariable.superclass.shortReadableName() : typeVariable.superclass.readableName());
3914 if ((length = typeVariable.superInterfaces.length) > 0) {
3915 for (int i = 0; i < length; i++) {
3916 if (i > 0 || typeVariable.firstBound == typeVariable.superclass) nameBuffer.append(" & "); //$NON-NLS-1$
3917 nameBuffer.append(makeShort ? typeVariable.superInterfaces[i].shortReadableName() : typeVariable.superInterfaces[i].readableName());
3920 return nameBuffer.toString();
3923 public void parseError(
3927 char[] currentTokenSource,
3928 String errorTokenName,
3929 String[] possibleTokens) {
3931 if (possibleTokens.length == 0) { //no suggestion available
3932 if (isKeyword(currentToken)) {
3933 String[] arguments = new String[] {new String(currentTokenSource)};
3935 IProblem.ParsingErrorOnKeywordNoSuggestion,
3938 // this is the current -invalid- token position
3943 String[] arguments = new String[] {errorTokenName};
3945 IProblem.ParsingErrorNoSuggestion,
3948 // this is the current -invalid- token position
3955 //build a list of probable right tokens
3956 StringBuffer list = new StringBuffer(20);
3957 for (int i = 0, max = possibleTokens.length; i < max; i++) {
3959 list.append(", "); //$NON-NLS-1$
3961 list.append(possibleTokens[i]);
3965 if (isKeyword(currentToken)) {
3966 String[] arguments = new String[] {new String(currentTokenSource), list.toString()};
3968 IProblem.ParsingErrorOnKeyword,
3971 // this is the current -invalid- token position
3976 //extract the literal when it's a literal
3977 if (isLiteral(currentToken) ||
3978 isIdentifier(currentToken)) { //$NON-NLS-1$
3979 errorTokenName = new String(currentTokenSource);
3982 String[] arguments = new String[] {errorTokenName, list.toString()};
3984 IProblem.ParsingError,
3987 // this is the current -invalid- token position
3991 public void parseErrorDeleteToken(
3995 char[] errorTokenSource,
3996 String errorTokenName){
3998 IProblem.ParsingErrorDeleteToken,
4006 public void parseErrorDeleteTokens(
4010 IProblem.ParsingErrorDeleteTokens,
4016 public void parseErrorInsertAfterToken(
4020 char[] errorTokenSource,
4021 String errorTokenName,
4022 String expectedToken){
4024 IProblem.ParsingErrorInsertTokenAfter,
4033 public void parseErrorInsertBeforeToken(
4037 char[] errorTokenSource,
4038 String errorTokenName,
4039 String expectedToken){
4041 IProblem.ParsingErrorInsertTokenBefore,
4049 public void parseErrorInsertToComplete(
4054 String[] arguments = new String[] {inserted, completed};
4056 IProblem.ParsingErrorInsertToComplete,
4062 public void parseErrorInsertToCompletePhrase(
4066 String[] arguments = new String[] {inserted};
4068 IProblem.ParsingErrorInsertToCompletePhrase,
4074 public void parseErrorInsertToCompleteScope(
4078 String[] arguments = new String[] {inserted};
4080 IProblem.ParsingErrorInsertToCompleteScope,
4086 public void parseErrorInvalidToken(
4090 char[] errorTokenSource,
4091 String errorTokenName,
4092 String expectedToken){
4094 IProblem.ParsingErrorInvalidToken,
4102 public void parseErrorMergeTokens(
4105 String expectedToken){
4106 String[] arguments = new String[] {expectedToken};
4108 IProblem.ParsingErrorMergeTokens,
4114 public void parseErrorMisplacedConstruct(
4118 IProblem.ParsingErrorMisplacedConstruct,
4124 public void parseErrorNoSuggestion(
4128 char[] errorTokenSource,
4129 String errorTokenName){
4131 IProblem.ParsingErrorNoSuggestion,
4139 public void parseErrorNoSuggestionForTokens(
4143 IProblem.ParsingErrorNoSuggestionForTokens,
4149 public void parseErrorReplaceToken(
4153 char[] errorTokenSource,
4154 String errorTokenName,
4155 String expectedToken){
4157 IProblem.ParsingError,
4165 public void parseErrorReplaceTokens(
4168 String expectedToken){
4169 String[] arguments = new String[] {expectedToken};
4171 IProblem.ParsingErrorReplaceTokens,
4177 public void parseErrorUnexpectedEnd(
4182 if(this.referenceContext instanceof ConstructorDeclaration) {
4183 arguments = new String[] {Util.bind("parser.endOfConstructor")}; //$NON-NLS-1$
4184 } else if(this.referenceContext instanceof MethodDeclaration) {
4185 arguments = new String[] {Util.bind("parser.endOfMethod")}; //$NON-NLS-1$
4186 } else if(this.referenceContext instanceof TypeDeclaration) {
4187 arguments = new String[] {Util.bind("parser.endOfInitializer")}; //$NON-NLS-1$
4189 arguments = new String[] {Util.bind("parser.endOfFile")}; //$NON-NLS-1$
4192 IProblem.ParsingErrorUnexpectedEOF,
4198 public void possibleAccidentalBooleanAssignment(Assignment assignment) {
4200 IProblem.PossibleAccidentalBooleanAssignment,
4203 assignment.sourceStart,
4204 assignment.sourceEnd);
4206 public void publicClassMustMatchFileName(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
4207 this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
4208 String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
4210 IProblem.PublicClassMustMatchFileName,
4213 typeDecl.sourceStart,
4215 compUnitDecl.compilationResult);
4217 public void rawMemberTypeCannotBeParameterized(ASTNode location, ReferenceBinding type, TypeBinding[] argumentTypes) {
4218 if (location == null) { // binary case
4220 IProblem.RawMemberTypeCannotBeParameterized,
4221 new String[] {new String(type.readableName()), typesAsString(false, argumentTypes, false), new String(type.enclosingType().readableName())},
4222 new String[] {new String(type.shortReadableName()), typesAsString(false, argumentTypes, true), new String(type.enclosingType().shortReadableName())},
4223 AbortCompilation | Error,
4229 IProblem.RawMemberTypeCannotBeParameterized,
4230 new String[] {new String(type.readableName()), typesAsString(false, argumentTypes, false), new String(type.enclosingType().readableName())},
4231 new String[] {new String(type.shortReadableName()), typesAsString(false, argumentTypes, true), new String(type.enclosingType().shortReadableName())},
4232 location.sourceStart,
4233 location.sourceEnd);
4235 public void recursiveConstructorInvocation(ExplicitConstructorCall constructorCall) {
4238 IProblem.RecursiveConstructorInvocation,
4240 new String(constructorCall.binding.declaringClass.readableName()),
4241 typesAsString(constructorCall.binding.isVarargs(), constructorCall.binding.parameters, false)
4244 new String(constructorCall.binding.declaringClass.shortReadableName()),
4245 typesAsString(constructorCall.binding.isVarargs(), constructorCall.binding.parameters, true)
4247 constructorCall.sourceStart,
4248 constructorCall.sourceEnd);
4251 public void redefineArgument(Argument arg) {
4252 String[] arguments = new String[] {new String(arg.name)};
4254 IProblem.RedefinedArgument,
4260 public void redefineLocal(LocalDeclaration localDecl) {
4261 String[] arguments = new String[] {new String(localDecl.name)};
4263 IProblem.RedefinedLocal,
4266 localDecl.sourceStart,
4267 localDecl.sourceEnd);
4269 public void referenceMustBeArrayTypeAt(TypeBinding arrayType, ArrayReference arrayRef) {
4271 IProblem.ArrayReferenceRequired,
4272 new String[] {new String(arrayType.readableName())},
4273 new String[] {new String(arrayType.shortReadableName())},
4274 arrayRef.sourceStart,
4275 arrayRef.sourceEnd);
4277 public void returnTypeCannotBeVoidArray(SourceTypeBinding type, MethodDeclaration methodDecl) {
4278 String[] arguments = new String[] {new String(methodDecl.selector)};
4280 IProblem.ReturnTypeCannotBeVoidArray,
4283 methodDecl.sourceStart,
4284 methodDecl.sourceEnd);
4287 public void scannerError(Parser parser, String errorTokenName) {
4288 Scanner scanner = parser.scanner;
4290 int flag = IProblem.ParsingErrorNoSuggestion;
4291 int startPos = scanner.startPosition;
4293 //special treatment for recognized errors....
4294 if (errorTokenName.equals(Scanner.END_OF_SOURCE))
4295 flag = IProblem.EndOfSource;
4296 else if (errorTokenName.equals(Scanner.INVALID_HEXA))
4297 flag = IProblem.InvalidHexa;
4298 else if (errorTokenName.equals(Scanner.INVALID_OCTAL))
4299 flag = IProblem.InvalidOctal;
4300 else if (errorTokenName.equals(Scanner.INVALID_CHARACTER_CONSTANT))
4301 flag = IProblem.InvalidCharacterConstant;
4302 else if (errorTokenName.equals(Scanner.INVALID_ESCAPE))
4303 flag = IProblem.InvalidEscape;
4304 else if (errorTokenName.equals(Scanner.INVALID_UNICODE_ESCAPE)){
4305 flag = IProblem.InvalidUnicodeEscape;
4306 // better locate the error message
4307 char[] source = scanner.source;
4308 int checkPos = scanner.currentPosition - 1;
4309 if (checkPos >= source.length) checkPos = source.length - 1;
4310 while (checkPos >= startPos){
4311 if (source[checkPos] == '\\') break;
4314 startPos = checkPos;
4315 } else if (errorTokenName.equals(Scanner.INVALID_FLOAT))
4316 flag = IProblem.InvalidFloat;
4317 else if (errorTokenName.equals(Scanner.UNTERMINATED_STRING))
4318 flag = IProblem.UnterminatedString;
4319 else if (errorTokenName.equals(Scanner.UNTERMINATED_COMMENT))
4320 flag = IProblem.UnterminatedComment;
4321 else if (errorTokenName.equals(Scanner.INVALID_CHAR_IN_STRING))
4322 flag = IProblem.UnterminatedString;
4323 else if (errorTokenName.equals(Scanner.INVALID_DIGIT))
4324 flag = IProblem.InvalidDigit;
4326 String[] arguments = flag == IProblem.ParsingErrorNoSuggestion
4327 ? new String[] {errorTokenName}
4333 // this is the current -invalid- token position
4335 scanner.currentPosition - 1,
4336 parser.compilationUnit.compilationResult);
4338 public void shouldReturn(TypeBinding returnType, ASTNode location) {
4340 IProblem.ShouldReturnValue,
4341 new String[] { new String (returnType.readableName())},
4342 new String[] { new String (returnType.shortReadableName())},
4343 location.sourceStart,
4344 location.sourceEnd);
4346 public void signalNoImplicitStringConversionForCharArrayExpression(Expression expression) {
4348 IProblem.NoImplicitStringConversionForCharArrayExpression,
4351 expression.sourceStart,
4352 expression.sourceEnd);
4354 public void staticAndInstanceConflict(MethodBinding currentMethod, MethodBinding inheritedMethod) {
4355 if (currentMethod.isStatic())
4357 // This static method cannot hide the instance method from %1
4358 // 8.4.6.4 - If a class inherits more than one method with the same signature a static (non-abstract) method cannot hide an instance method.
4359 IProblem.CannotHideAnInstanceMethodWithAStaticMethod,
4360 new String[] {new String(inheritedMethod.declaringClass.readableName())},
4361 new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
4362 currentMethod.sourceStart(),
4363 currentMethod.sourceEnd());
4366 // This instance method cannot override the static method from %1
4367 // 8.4.6.4 - If a class inherits more than one method with the same signature an instance (non-abstract) method cannot override a static method.
4368 IProblem.CannotOverrideAStaticMethodWithAnInstanceMethod,
4369 new String[] {new String(inheritedMethod.declaringClass.readableName())},
4370 new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
4371 currentMethod.sourceStart(),
4372 currentMethod.sourceEnd());
4374 public void staticFieldAccessToNonStaticVariable(ASTNode location, FieldBinding field) {
4375 String[] arguments = new String[] {new String(field.readableName())};
4377 IProblem.NonStaticFieldFromStaticInvocation,
4380 location.sourceStart,
4381 fieldLocation(field, location));
4383 public void staticInheritedMethodConflicts(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
4385 // The static method %1 conflicts with the abstract method in %2
4386 // 8.4.6.4 - If a class inherits more than one method with the same signature it is an error for one to be static (non-abstract) and the other abstract.
4387 IProblem.StaticInheritedMethodConflicts,
4389 new String(concreteMethod.readableName()),
4390 new String(abstractMethods[0].declaringClass.readableName())},
4392 new String(concreteMethod.readableName()),
4393 new String(abstractMethods[0].declaringClass.shortReadableName())},
4397 public void staticMemberOfParameterizedType(ASTNode location, ReferenceBinding type) {
4398 if (location == null) { // binary case
4400 IProblem.StaticMemberOfParameterizedType,
4401 new String[] {new String(type.readableName()), new String(type.enclosingType().readableName()), },
4402 new String[] {new String(type.shortReadableName()), new String(type.enclosingType().shortReadableName()), },
4403 AbortCompilation | Error,
4409 IProblem.StaticMemberOfParameterizedType,
4410 new String[] {new String(type.readableName()), new String(type.enclosingType().readableName()), },
4411 new String[] {new String(type.shortReadableName()), new String(type.enclosingType().shortReadableName()), },
4412 location.sourceStart,
4413 location.sourceEnd);
4415 public void stringConstantIsExceedingUtf8Limit(ASTNode location) {
4417 IProblem.StringConstantIsExceedingUtf8Limit,
4420 location.sourceStart,
4421 location.sourceEnd);
4423 public void superclassMustBeAClass(SourceTypeBinding type, TypeReference superclassRef, ReferenceBinding superType) {
4425 IProblem.SuperclassMustBeAClass,
4426 new String[] {new String(superType.readableName()), new String(type.sourceName())},
4427 new String[] {new String(superType.shortReadableName()), new String(type.sourceName())},
4428 superclassRef.sourceStart,
4429 superclassRef.sourceEnd);
4431 public void superfluousSemicolon(int sourceStart, int sourceEnd) {
4433 IProblem.SuperfluousSemicolon,
4439 public void superinterfaceMustBeAnInterface(SourceTypeBinding type, TypeReference superInterfaceRef, ReferenceBinding superType) {
4441 IProblem.SuperInterfaceMustBeAnInterface,
4442 new String[] {new String(superType.readableName()), new String(type.sourceName())},
4443 new String[] {new String(superType.shortReadableName()), new String(type.sourceName())},
4444 superInterfaceRef.sourceStart,
4445 superInterfaceRef.sourceEnd);
4447 public void superinterfacesCollide(ReferenceBinding type, TypeDeclaration typeDecl, ReferenceBinding superType, ReferenceBinding inheritedSuperType) {
4449 IProblem.SuperInterfacesCollide,
4450 new String[] {new String(superType.readableName()), new String(inheritedSuperType.readableName()), new String(type.sourceName())},
4451 new String[] {new String(superType.shortReadableName()), new String(inheritedSuperType.shortReadableName()), new String(type.sourceName())},
4452 typeDecl.sourceStart,
4453 typeDecl.sourceEnd);
4455 public void superTypeCannotUseWildcard(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) {
4456 String name = new String(type.sourceName());
4457 String superTypeFullName = new String(superTypeBinding.readableName());
4458 String superTypeShortName = new String(superTypeBinding.shortReadableName());
4459 if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName;
4461 IProblem.SuperTypeUsingWildcard,
4462 new String[] {superTypeFullName, name},
4463 new String[] {superTypeShortName, name},
4464 superclass.sourceStart,
4465 superclass.sourceEnd);
4468 private void syntaxError(
4473 char[] currentTokenSource,
4474 String errorTokenName,
4475 String expectedToken) {
4478 if (isKeyword(currentKind) ||
4479 isLiteral(currentKind) ||
4480 isIdentifier(currentKind)) { //$NON-NLS-1$
4481 eTokenName = new String(currentTokenSource);
4483 eTokenName = errorTokenName;
4487 if(expectedToken != null) {
4488 arguments = new String[] {eTokenName, expectedToken};
4490 arguments = new String[] {eTokenName};
4500 public void task(String tag, String message, String priority, int start, int end){
4503 new String[] { tag, message, priority/*secret argument that is not surfaced in getMessage()*/},
4504 new String[] { tag, message, priority/*secret argument that is not surfaced in getMessage()*/},
4508 public void tooManyDimensions(ASTNode expression) {
4510 IProblem.TooManyArrayDimensions,
4513 expression.sourceStart,
4514 expression.sourceEnd);
4516 public void tooManyFields(TypeDeclaration typeDeclaration) {
4518 IProblem.TooManyFields,
4519 new String[]{ new String(typeDeclaration.binding.readableName())},
4520 new String[]{ new String(typeDeclaration.binding.shortReadableName())},
4522 typeDeclaration.sourceStart,
4523 typeDeclaration.sourceEnd);
4525 public void tooManyMethods(TypeDeclaration typeDeclaration) {
4527 IProblem.TooManyMethods,
4528 new String[]{ new String(typeDeclaration.binding.readableName())},
4529 new String[]{ new String(typeDeclaration.binding.shortReadableName())},
4531 typeDeclaration.sourceStart,
4532 typeDeclaration.sourceEnd);
4534 public void typeCastError(CastExpression expression, TypeBinding leftType, TypeBinding rightType) {
4535 String leftName = new String(leftType.readableName());
4536 String rightName = new String(rightType.readableName());
4537 String leftShortName = new String(leftType.shortReadableName());
4538 String rightShortName = new String(rightType.shortReadableName());
4539 if (leftShortName.equals(rightShortName)){
4540 leftShortName = leftName;
4541 rightShortName = rightName;
4544 IProblem.IllegalCast,
4545 new String[] { rightName, leftName },
4546 new String[] { rightShortName, leftShortName },
4547 expression.sourceStart,
4548 expression.sourceEnd);
4550 public void typeCollidesWithPackage(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
4551 this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
4552 String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
4554 IProblem.TypeCollidesWithPackage,
4557 typeDecl.sourceStart,
4559 compUnitDecl.compilationResult);
4561 public void typeMismatchError(TypeBinding actualType, TypeBinding expectedType, ASTNode location) {
4563 IProblem.TypeMismatch,
4564 new String[] {new String(actualType.readableName()), new String(expectedType.readableName())},
4565 new String[] {new String(actualType.shortReadableName()), new String(expectedType.shortReadableName())},
4566 location.sourceStart,
4567 location.sourceEnd);
4569 public void typeMismatchError(TypeBinding typeArgument, TypeVariableBinding typeParameter, ReferenceBinding genericType, ASTNode location) {
4570 if (location == null) { // binary case
4572 IProblem.TypeArgumentMismatch,
4573 new String[] { new String(typeArgument.readableName()), new String(genericType.readableName()), new String(typeParameter.sourceName), parameterBoundAsString(typeParameter, false) },
4574 new String[] { new String(typeArgument.shortReadableName()), new String(genericType.shortReadableName()), new String(typeParameter.sourceName), parameterBoundAsString(typeParameter, true) },
4575 AbortCompilation | Error,
4581 IProblem.TypeArgumentMismatch,
4582 new String[] { new String(typeArgument.readableName()), new String(genericType.readableName()), new String(typeParameter.sourceName), parameterBoundAsString(typeParameter, false) },
4583 new String[] { new String(typeArgument.shortReadableName()), new String(genericType.shortReadableName()), new String(typeParameter.sourceName), parameterBoundAsString(typeParameter, true) },
4584 location.sourceStart,
4585 location.sourceEnd);
4587 private String typesAsString(boolean isVarargs, TypeBinding[] types, boolean makeShort) {
4588 StringBuffer buffer = new StringBuffer(10);
4589 for (int i = 0, length = types.length; i < length; i++) {
4591 buffer.append(", "); //$NON-NLS-1$
4592 TypeBinding type = types[i];
4593 boolean isVarargType = isVarargs && i == length-1;
4594 if (isVarargType) type = ((ArrayBinding)type).elementsType();
4595 buffer.append(new String(makeShort ? type.shortReadableName() : type.readableName()));
4596 if (isVarargType) buffer.append("..."); //$NON-NLS-1$
4598 return buffer.toString();
4600 public void undefinedAnnotationValue(TypeBinding annotationType, MemberValuePair memberValuePair) {
4601 String name = new String(memberValuePair.name);
4603 IProblem.UndefinedAnnotationMember,
4604 new String[] { name, new String(annotationType.readableName())},
4605 new String[] { name, new String(annotationType.shortReadableName())},
4606 memberValuePair.sourceStart,
4607 memberValuePair.sourceEnd);
4609 public void undefinedLabel(BranchStatement statement) {
4610 String[] arguments = new String[] {new String(statement.label)};
4612 IProblem.UndefinedLabel,
4615 statement.sourceStart,
4616 statement.sourceEnd);
4618 // can only occur inside binaries
4619 public void undefinedTypeVariableSignature(char[] variableName, ReferenceBinding binaryType) {
4621 IProblem.UndefinedTypeVariable,
4622 new String[] {new String(variableName), new String(binaryType.readableName()) },
4623 new String[] {new String(variableName), new String(binaryType.shortReadableName())},
4624 AbortCompilation | Error,
4628 public void undocumentedEmptyBlock(int blockStart, int blockEnd) {
4630 IProblem.UndocumentedEmptyBlock,
4636 public void unexpectedStaticModifierForField(SourceTypeBinding type, FieldDeclaration fieldDecl) {
4637 String[] arguments = new String[] {new String(fieldDecl.name)};
4639 IProblem.UnexpectedStaticModifierForField,
4642 fieldDecl.sourceStart,
4643 fieldDecl.sourceEnd);
4645 public void unexpectedStaticModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
4646 String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
4648 IProblem.UnexpectedStaticModifierForMethod,
4651 methodDecl.sourceStart,
4652 methodDecl.sourceEnd);
4654 public void unhandledException(TypeBinding exceptionType, ASTNode location) {
4656 boolean insideDefaultConstructor =
4657 (this.referenceContext instanceof ConstructorDeclaration)
4658 && ((ConstructorDeclaration)this.referenceContext).isDefaultConstructor();
4659 boolean insideImplicitConstructorCall =
4660 (location instanceof ExplicitConstructorCall)
4661 && (((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper);
4664 insideDefaultConstructor
4665 ? IProblem.UnhandledExceptionInDefaultConstructor
4666 : (insideImplicitConstructorCall
4667 ? IProblem.UndefinedConstructorInImplicitConstructorCall
4668 : IProblem.UnhandledException),
4669 new String[] {new String(exceptionType.readableName())},
4670 new String[] {new String(exceptionType.shortReadableName())},
4671 location.sourceStart,
4672 location.sourceEnd);
4674 public void uninitializedBlankFinalField(FieldBinding binding, ASTNode location) {
4675 String[] arguments = new String[] {new String(binding.readableName())};
4677 IProblem.UninitializedBlankFinalField,
4680 location.sourceStart,
4681 fieldLocation(binding, location));
4683 public void uninitializedLocalVariable(LocalVariableBinding binding, ASTNode location) {
4684 String[] arguments = new String[] {new String(binding.readableName())};
4686 IProblem.UninitializedLocalVariable,
4689 location.sourceStart,
4690 location.sourceEnd);
4692 public void unmatchedBracket(int position, ReferenceContext context, CompilationResult compilationResult) {
4694 IProblem.UnmatchedBracket,
4702 public void unnecessaryCast(CastExpression castExpression) {
4703 TypeBinding castedExpressionType = castExpression.expression.resolvedType;
4705 IProblem.UnnecessaryCast,
4706 new String[]{ new String(castedExpressionType.readableName()), new String(castExpression.resolvedType.readableName())},
4707 new String[]{ new String(castedExpressionType.shortReadableName()), new String(castExpression.resolvedType.shortReadableName())},
4708 castExpression.sourceStart,
4709 castExpression.sourceEnd);
4711 public void unnecessaryCastForArgument(CastExpression castExpression, TypeBinding parameterType) {
4712 TypeBinding castedExpressionType = castExpression.expression.resolvedType;
4714 IProblem.UnnecessaryArgumentCast,
4715 new String[]{ new String(castedExpressionType.readableName()), new String(castExpression.resolvedType.readableName()), new String(parameterType.readableName())},
4716 new String[]{ new String(castedExpressionType.shortReadableName()), new String(castExpression.resolvedType.shortReadableName()), new String(parameterType.shortReadableName())},
4717 castExpression.sourceStart,
4718 castExpression.sourceEnd);
4720 public void unnecessaryElse(ASTNode location) {
4722 IProblem.UnnecessaryElse,
4725 location.sourceStart,
4726 location.sourceEnd);
4728 public void unnecessaryEnclosingInstanceSpecification(Expression expression, ReferenceBinding targetType) {
4730 IProblem.IllegalEnclosingInstanceSpecification,
4731 new String[]{ new String(targetType.readableName())},
4732 new String[]{ new String(targetType.shortReadableName())},
4733 expression.sourceStart,
4734 expression.sourceEnd);
4736 public void unnecessaryInstanceof(InstanceOfExpression instanceofExpression, TypeBinding checkType) {
4737 TypeBinding expressionType = instanceofExpression.expression.resolvedType;
4739 IProblem.UnnecessaryInstanceof,
4740 new String[]{ new String(expressionType.readableName()), new String(checkType.readableName())},
4741 new String[]{ new String(expressionType.shortReadableName()), new String(checkType.shortReadableName())},
4742 instanceofExpression.sourceStart,
4743 instanceofExpression.sourceEnd);
4745 public void unqualifiedFieldAccess(NameReference reference, FieldBinding field) {
4746 int end = reference.sourceEnd;
4747 if (reference instanceof QualifiedNameReference) {
4748 QualifiedNameReference qref = (QualifiedNameReference) reference;
4749 end = (int) qref.sourcePositions[0];
4752 IProblem.UnqualifiedFieldAccess,
4753 new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
4754 new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
4755 reference.sourceStart,
4758 public void unreachableCatchBlock(ReferenceBinding exceptionType, ASTNode location) {
4760 IProblem.UnreachableCatch,
4762 new String(exceptionType.readableName()),
4765 new String(exceptionType.shortReadableName()),
4767 location.sourceStart,
4768 location.sourceEnd);
4770 public void unreachableCode(Statement statement) {
4772 IProblem.CodeCannotBeReached,
4775 statement.sourceStart,
4776 statement.sourceEnd);
4778 public void unresolvableReference(NameReference nameRef, Binding binding) {
4779 int severity = Error;
4780 /* also need to check that the searchedType is the receiver type
4781 if (binding instanceof ProblemBinding) {
4782 ProblemBinding problem = (ProblemBinding) binding;
4783 if (problem.searchType != null && problem.searchType.isHierarchyInconsistent())
4784 severity = SecondaryError;
4787 String[] arguments = new String[] {new String(binding.readableName())};
4788 int end = nameRef.sourceEnd;
4789 if (nameRef instanceof QualifiedNameReference) {
4790 QualifiedNameReference ref = (QualifiedNameReference) nameRef;
4791 if (ref.indexOfFirstFieldBinding >= 1)
4792 end = (int) ref.sourcePositions[ref.indexOfFirstFieldBinding - 1];
4795 IProblem.UndefinedName,
4799 nameRef.sourceStart,
4802 public void unsafeCast(CastExpression castExpression) {
4803 TypeBinding castedExpressionType = castExpression.expression.resolvedType;
4805 IProblem.UnsafeGenericCast,
4806 new String[]{ new String(castedExpressionType.readableName()), new String(castExpression.resolvedType.readableName())},
4807 new String[]{ new String(castedExpressionType.shortReadableName()), new String(castExpression.resolvedType.shortReadableName())},
4808 castExpression.sourceStart,
4809 castExpression.sourceEnd);
4811 public void unsafeRawConversion(Expression expression, TypeBinding expressionType, TypeBinding expectedType) {
4813 IProblem.UnsafeRawConversion,
4814 new String[] { new String(expressionType.readableName()), new String(expectedType.readableName()), new String(expectedType.erasure().readableName()) },
4815 new String[] { new String(expressionType.shortReadableName()), new String(expectedType.shortReadableName()), new String(expectedType.erasure().shortReadableName()) },
4816 expression.sourceStart,
4817 expression.sourceEnd);
4819 public void unsafeRawFieldAssignment(FieldBinding rawField, TypeBinding expressionType, ASTNode location) {
4821 IProblem.UnsafeRawFieldAssignment,
4823 new String(expressionType.readableName()), new String(rawField.name), new String(rawField.declaringClass.readableName()), new String(rawField.declaringClass.erasure().readableName()) },
4825 new String(expressionType.shortReadableName()), new String(rawField.name), new String(rawField.declaringClass.shortReadableName()), new String(rawField.declaringClass.erasure().shortReadableName()) },
4826 location.sourceStart,
4827 location.sourceEnd);
4829 public void unsafeRawInvocation(ASTNode location, MethodBinding rawMethod) {
4830 if (rawMethod.isConstructor()) {
4832 IProblem.UnsafeRawConstructorInvocation,
4834 new String(rawMethod.declaringClass.readableName()),
4835 typesAsString(rawMethod.original().isVarargs(), rawMethod.parameters, false),
4836 new String(rawMethod.declaringClass.erasure().readableName()),
4839 new String(rawMethod.declaringClass.shortReadableName()),
4840 typesAsString(rawMethod.original().isVarargs(), rawMethod.parameters, true),
4841 new String(rawMethod.declaringClass.erasure().shortReadableName()),
4843 location.sourceStart,
4844 location.sourceEnd);
4847 IProblem.UnsafeRawMethodInvocation,
4849 new String(rawMethod.selector),
4850 typesAsString(rawMethod.original().isVarargs(), rawMethod.parameters, false),
4851 new String(rawMethod.declaringClass.readableName()),
4852 new String(rawMethod.declaringClass.erasure().readableName()),
4855 new String(rawMethod.selector),
4856 typesAsString(rawMethod.original().isVarargs(), rawMethod.parameters, true),
4857 new String(rawMethod.declaringClass.shortReadableName()),
4858 new String(rawMethod.declaringClass.erasure().shortReadableName()),
4860 location.sourceStart,
4861 location.sourceEnd);
4864 public void unsafeReturnTypeOverride(MethodBinding currentMethod, MethodBinding inheritedMethod, ASTNode location) {
4867 IProblem.UnsafeReturnTypeOverride,
4869 new String(currentMethod.returnType.readableName()),
4870 new String(currentMethod.selector),
4871 typesAsString(currentMethod.original().isVarargs(), currentMethod.original().parameters, false),
4872 new String(currentMethod.declaringClass.readableName()),
4873 new String(inheritedMethod.returnType.readableName()),
4874 //new String(inheritedMethod.returnType.erasure().readableName()),
4877 new String(currentMethod.returnType.shortReadableName()),
4878 new String(currentMethod.selector),
4879 typesAsString(currentMethod.original().isVarargs(), currentMethod.original().parameters, true),
4880 new String(currentMethod.declaringClass.shortReadableName()),
4881 new String(inheritedMethod.returnType.shortReadableName()),
4882 //new String(inheritedMethod.returnType.erasure().shortReadableName()),
4884 location.sourceStart,
4885 location.sourceEnd);
4887 public void unusedArgument(LocalDeclaration localDecl) {
4889 String[] arguments = new String[] {new String(localDecl.name)};
4891 IProblem.ArgumentIsNeverUsed,
4894 localDecl.sourceStart,
4895 localDecl.sourceEnd);
4897 public void unusedDeclaredThrownException(ReferenceBinding exceptionType, AbstractMethodDeclaration method, ASTNode location) {
4898 if (method.isConstructor()) {
4900 IProblem.UnusedConstructorDeclaredThrownException,
4902 new String(method.binding.declaringClass.readableName()),
4903 typesAsString(method.binding.isVarargs(), method.binding.parameters, false),
4904 new String(exceptionType.readableName()),
4907 new String(method.binding.declaringClass.shortReadableName()),
4908 typesAsString(method.binding.isVarargs(), method.binding.parameters, true),
4909 new String(exceptionType.shortReadableName()),
4911 location.sourceStart,
4912 location.sourceEnd);
4915 IProblem.UnusedMethodDeclaredThrownException,
4917 new String(method.binding.declaringClass.readableName()),
4918 new String(method.selector),
4919 typesAsString(method.binding.isVarargs(), method.binding.parameters, false),
4920 new String(exceptionType.readableName()),
4923 new String(method.binding.declaringClass.shortReadableName()),
4924 new String(method.selector),
4925 typesAsString(method.binding.isVarargs(), method.binding.parameters, true),
4926 new String(exceptionType.shortReadableName()),
4928 location.sourceStart,
4929 location.sourceEnd);
4932 public void unusedImport(ImportReference importRef) {
4933 String[] arguments = new String[] { CharOperation.toString(importRef.tokens) };
4935 IProblem.UnusedImport,
4938 importRef.sourceStart,
4939 importRef.sourceEnd);
4941 public void unusedLocalVariable(LocalDeclaration localDecl) {
4942 String[] arguments = new String[] {new String(localDecl.name)};
4944 IProblem.LocalVariableIsNeverUsed,
4947 localDecl.sourceStart,
4948 localDecl.sourceEnd);
4950 public void unusedPrivateConstructor(ConstructorDeclaration constructorDecl) {
4952 if (computeSeverity(IProblem.UnusedPrivateConstructor) == Ignore) return;
4954 // no complaint for no-arg constructors (or default ones) - known pattern to block instantiation
4955 if (constructorDecl.arguments == null || constructorDecl.arguments.length == 0) return;
4957 MethodBinding constructor = constructorDecl.binding;
4959 IProblem.UnusedPrivateConstructor,
4961 new String(constructor.declaringClass.readableName()),
4962 typesAsString(constructor.isVarargs(), constructor.parameters, false)
4965 new String(constructor.declaringClass.shortReadableName()),
4966 typesAsString(constructor.isVarargs(), constructor.parameters, true)
4968 constructorDecl.sourceStart,
4969 constructorDecl.sourceEnd);
4971 public void unusedPrivateField(FieldDeclaration fieldDecl) {
4973 if (computeSeverity(IProblem.UnusedPrivateField) == Ignore) return;
4975 FieldBinding field = fieldDecl.binding;
4977 if (CharOperation.equals(TypeConstants.SERIALVERSIONUID, field.name)
4980 && BaseTypes.LongBinding == field.type) {
4981 return; // do not report unused serialVersionUID field
4983 if (CharOperation.equals(TypeConstants.SERIALPERSISTENTFIELDS, field.name)
4986 && field.type.dimensions() == 1
4987 && CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTSTREAMFIELD, field.type.leafComponentType().readableName())) {
4988 return; // do not report unused serialPersistentFields field
4991 IProblem.UnusedPrivateField,
4993 new String(field.declaringClass.readableName()),
4994 new String(field.name),
4997 new String(field.declaringClass.shortReadableName()),
4998 new String(field.name),
5000 fieldDecl.sourceStart,
5001 fieldDecl.sourceEnd);
5003 public void unusedPrivateMethod(AbstractMethodDeclaration methodDecl) {
5005 if (computeSeverity(IProblem.UnusedPrivateMethod) == Ignore) return;
5007 MethodBinding method = methodDecl.binding;
5009 // no report for serialization support 'void readObject(ObjectInputStream)'
5010 if (!method.isStatic()
5011 && BaseTypes.VoidBinding == method.returnType
5012 && method.parameters.length == 1
5013 && method.parameters[0].dimensions() == 0
5014 && CharOperation.equals(method.selector, TypeConstants.READOBJECT)
5015 && CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTINPUTSTREAM, method.parameters[0].readableName())) {
5018 // no report for serialization support 'void writeObject(ObjectOutputStream)'
5019 if (!method.isStatic()
5020 && BaseTypes.VoidBinding == method.returnType
5021 && method.parameters.length == 1
5022 && method.parameters[0].dimensions() == 0
5023 && CharOperation.equals(method.selector, TypeConstants.WRITEOBJECT)
5024 && CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTOUTPUTSTREAM, method.parameters[0].readableName())) {
5027 // no report for serialization support 'Object readResolve()'
5028 if (!method.isStatic()
5029 && TypeIds.T_JavaLangObject == method.returnType.id
5030 && method.parameters.length == 0
5031 && CharOperation.equals(method.selector, TypeConstants.READRESOLVE)) {
5034 // no report for serialization support 'Object writeReplace()'
5035 if (!method.isStatic()
5036 && TypeIds.T_JavaLangObject == method.returnType.id
5037 && method.parameters.length == 0
5038 && CharOperation.equals(method.selector, TypeConstants.WRITEREPLACE)) {
5042 IProblem.UnusedPrivateMethod,
5044 new String(method.declaringClass.readableName()),
5045 new String(method.selector),
5046 typesAsString(method.isVarargs(), method.parameters, false)
5049 new String(method.declaringClass.shortReadableName()),
5050 new String(method.selector),
5051 typesAsString(method.isVarargs(), method.parameters, true)
5053 methodDecl.sourceStart,
5054 methodDecl.sourceEnd);
5056 public void unusedPrivateType(TypeDeclaration typeDecl) {
5058 if (computeSeverity(IProblem.UnusedPrivateType) == Ignore) return;
5060 ReferenceBinding type = typeDecl.binding;
5062 IProblem.UnusedPrivateType,
5064 new String(type.readableName()),
5067 new String(type.shortReadableName()),
5069 typeDecl.sourceStart,
5070 typeDecl.sourceEnd);
5072 public void useAssertAsAnIdentifier(int sourceStart, int sourceEnd) {
5074 IProblem.UseAssertAsAnIdentifier,
5080 public void useEnumAsAnIdentifier(int sourceStart, int sourceEnd) {
5082 IProblem.UseEnumAsAnIdentifier,
5088 public void varargsArgumentNeedCast(MethodBinding method, TypeBinding argumentType, InvocationSite location) {
5089 TypeBinding lastParam = method.parameters[method.parameters.length-1];
5090 if (method.isConstructor()) {
5092 IProblem.ConstructorVarargsArgumentNeedCast,
5093 new String[] {new String(argumentType.readableName()), new String(lastParam.readableName()), new String(method.declaringClass.readableName()), typesAsString(method.isVarargs(), method.parameters, false), },
5094 new String[] {new String(argumentType.shortReadableName()), new String(lastParam.shortReadableName()), new String(method.declaringClass.shortReadableName()), typesAsString(method.isVarargs(), method.parameters, true), },
5095 location.sourceStart(),
5096 location.sourceEnd());
5099 IProblem.MethodVarargsArgumentNeedCast,
5100 new String[] { new String(argumentType.readableName()), new String(lastParam.readableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, false), new String(method.declaringClass.readableName()), },
5101 new String[] { new String(argumentType.shortReadableName()), new String(lastParam.shortReadableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, true), new String(method.declaringClass.shortReadableName()), },
5102 location.sourceStart(),
5103 location.sourceEnd());
5106 public void variableTypeCannotBeVoid(AbstractVariableDeclaration varDecl) {
5107 String[] arguments = new String[] {new String(varDecl.name)};
5109 IProblem.VariableTypeCannotBeVoid,
5112 varDecl.sourceStart,
5115 public void variableTypeCannotBeVoidArray(AbstractVariableDeclaration varDecl) {
5116 String[] arguments = new String[] {new String(varDecl.name)};
5118 IProblem.VariableTypeCannotBeVoidArray,
5121 varDecl.sourceStart,
5124 public void visibilityConflict(MethodBinding currentMethod, MethodBinding inheritedMethod) {
5126 // Cannot reduce the visibility of the inherited method from %1
5127 // 8.4.6.3 - The access modifier of an hiding method must provide at least as much access as the hidden method.
5128 // 8.4.6.3 - The access modifier of an overiding method must provide at least as much access as the overriden method.
5129 IProblem.MethodReducesVisibility,
5130 new String[] {new String(inheritedMethod.declaringClass.readableName())},
5131 new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
5132 currentMethod.sourceStart(),
5133 currentMethod.sourceEnd());
5135 public void wildcardAssignment(TypeBinding variableType, TypeBinding expressionType, ASTNode location) {
5137 IProblem.WildcardFieldAssignment,
5139 new String(expressionType.readableName()), new String(variableType.readableName()) },
5141 new String(expressionType.shortReadableName()), new String(variableType.shortReadableName()) },
5142 location.sourceStart,
5143 location.sourceEnd);
5145 public void wildcardInvocation(ASTNode location, TypeBinding receiverType, MethodBinding method, TypeBinding[] arguments) {
5146 TypeBinding offendingArgument = null;
5147 TypeBinding offendingParameter = null;
5148 for (int i = 0, length = method.parameters.length; i < length; i++) {
5149 TypeBinding parameter = method.parameters[i];
5150 if (parameter.isWildcard() && (((WildcardBinding) parameter).kind != Wildcard.SUPER)) {
5151 offendingParameter = parameter;
5152 offendingArgument = arguments[i];
5157 if (method.isConstructor()) {
5159 IProblem.WildcardConstructorInvocation,
5161 new String(receiverType.sourceName()),
5162 typesAsString(method.isVarargs(), method.parameters, false),
5163 new String(receiverType.readableName()),
5164 typesAsString(false, arguments, false),
5165 new String(offendingArgument.readableName()),
5166 new String(offendingParameter.readableName()),
5169 new String(receiverType.sourceName()),
5170 typesAsString(method.isVarargs(), method.parameters, true),
5171 new String(receiverType.shortReadableName()),
5172 typesAsString(false, arguments, true),
5173 new String(offendingArgument.shortReadableName()),
5174 new String(offendingParameter.shortReadableName()),
5176 location.sourceStart,
5177 location.sourceEnd);
5180 IProblem.WildcardMethodInvocation,
5182 new String(method.selector),
5183 typesAsString(method.isVarargs(), method.parameters, false),
5184 new String(receiverType.readableName()),
5185 typesAsString(false, arguments, false),
5186 new String(offendingArgument.readableName()),
5187 new String(offendingParameter.readableName()),
5190 new String(method.selector),
5191 typesAsString(method.isVarargs(), method.parameters, true),
5192 new String(receiverType.shortReadableName()),
5193 typesAsString(false, arguments, true),
5194 new String(offendingArgument.shortReadableName()),
5195 new String(offendingParameter.shortReadableName()),
5197 location.sourceStart,
5198 location.sourceEnd);
5201 public void wrongSequenceOfExceptionTypesError(TryStatement statement, TypeBinding exceptionType, int under, TypeBinding hidingExceptionType) {
5202 //the two catch block under and upper are in an incorrect order.
5203 //under should be define BEFORE upper in the source
5205 TypeReference typeRef = statement.catchArguments[under].type;
5207 IProblem.InvalidCatchBlockSequence,
5209 new String(exceptionType.readableName()),
5210 new String(hidingExceptionType.readableName()),
5213 new String(exceptionType.shortReadableName()),
5214 new String(hidingExceptionType.shortReadableName()),
5216 typeRef.sourceStart,