KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > problem > ProblemReporter


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.compiler.problem;
12
13 import java.io.CharConversionException JavaDoc;
14 import java.io.PrintWriter JavaDoc;
15 import java.io.StringWriter JavaDoc;
16 import java.text.MessageFormat JavaDoc;
17
18 import org.eclipse.jdt.core.compiler.CategorizedProblem;
19 import org.eclipse.jdt.core.compiler.CharOperation;
20 import org.eclipse.jdt.core.compiler.IProblem;
21 import org.eclipse.jdt.core.compiler.InvalidInputException;
22 import org.eclipse.jdt.internal.compiler.*;
23 import org.eclipse.jdt.internal.compiler.ast.*;
24 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
25 import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
26 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
27 import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
28 import org.eclipse.jdt.internal.compiler.lookup.*;
29 import org.eclipse.jdt.internal.compiler.parser.*;
30 import org.eclipse.jdt.internal.compiler.util.Messages;
31
32 public class ProblemReporter extends ProblemHandler {
33     
34     public ReferenceContext referenceContext;
35     private Scanner positionScanner;
36     
37 public static long getIrritant(int problemID) {
38     switch(problemID){
39
40         case IProblem.MaskedCatch :
41             return CompilerOptions.MaskedCatchBlock;
42
43         case IProblem.UnusedImport :
44             return CompilerOptions.UnusedImport;
45             
46         case IProblem.MethodButWithConstructorName :
47             return CompilerOptions.MethodWithConstructorName;
48         
49         case IProblem.OverridingNonVisibleMethod :
50             return CompilerOptions.OverriddenPackageDefaultMethod;
51
52         case IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod :
53         case IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod :
54             return CompilerOptions.IncompatibleNonInheritedInterfaceMethod;
55
56         case IProblem.OverridingDeprecatedMethod :
57         case IProblem.UsingDeprecatedType :
58         case IProblem.UsingDeprecatedMethod :
59         case IProblem.UsingDeprecatedConstructor :
60         case IProblem.UsingDeprecatedField :
61             return CompilerOptions.UsingDeprecatedAPI;
62         
63         case IProblem.LocalVariableIsNeverUsed :
64             return CompilerOptions.UnusedLocalVariable;
65         
66         case IProblem.ArgumentIsNeverUsed :
67             return CompilerOptions.UnusedArgument;
68
69         case IProblem.NoImplicitStringConversionForCharArrayExpression :
70             return CompilerOptions.NoImplicitStringConversion;
71
72         case IProblem.NeedToEmulateFieldReadAccess :
73         case IProblem.NeedToEmulateFieldWriteAccess :
74         case IProblem.NeedToEmulateMethodAccess :
75         case IProblem.NeedToEmulateConstructorAccess :
76             return CompilerOptions.AccessEmulation;
77
78         case IProblem.NonExternalizedStringLiteral :
79         case IProblem.UnnecessaryNLSTag :
80             return CompilerOptions.NonExternalizedString;
81
82         case IProblem.UseAssertAsAnIdentifier :
83             return CompilerOptions.AssertUsedAsAnIdentifier;
84             
85         case IProblem.UseEnumAsAnIdentifier :
86             return CompilerOptions.EnumUsedAsAnIdentifier;
87
88         case IProblem.NonStaticAccessToStaticMethod :
89         case IProblem.NonStaticAccessToStaticField :
90             return CompilerOptions.NonStaticAccessToStatic;
91
92         case IProblem.IndirectAccessToStaticMethod :
93         case IProblem.IndirectAccessToStaticField :
94         case IProblem.IndirectAccessToStaticType :
95             return CompilerOptions.IndirectStaticAccess;
96
97         case IProblem.AssignmentHasNoEffect:
98             return CompilerOptions.NoEffectAssignment;
99
100         case IProblem.UnusedPrivateConstructor:
101         case IProblem.UnusedPrivateMethod:
102         case IProblem.UnusedPrivateField:
103         case IProblem.UnusedPrivateType:
104             return CompilerOptions.UnusedPrivateMember;
105
106         case IProblem.LocalVariableHidingLocalVariable:
107         case IProblem.LocalVariableHidingField:
108         case IProblem.ArgumentHidingLocalVariable:
109         case IProblem.ArgumentHidingField:
110             return CompilerOptions.LocalVariableHiding;
111
112         case IProblem.FieldHidingLocalVariable:
113         case IProblem.FieldHidingField:
114             return CompilerOptions.FieldHiding;
115
116         case IProblem.TypeParameterHidingType:
117         case IProblem.TypeHidingTypeParameterFromType:
118         case IProblem.TypeHidingTypeParameterFromMethod:
119         case IProblem.TypeHidingType:
120             return CompilerOptions.TypeHiding;
121             
122         case IProblem.PossibleAccidentalBooleanAssignment:
123             return CompilerOptions.AccidentalBooleanAssign;
124
125         case IProblem.SuperfluousSemicolon:
126         case IProblem.EmptyControlFlowStatement:
127             return CompilerOptions.EmptyStatement;
128
129         case IProblem.UndocumentedEmptyBlock:
130             return CompilerOptions.UndocumentedEmptyBlock;
131             
132         case IProblem.UnnecessaryCast:
133         case IProblem.UnnecessaryInstanceof:
134             return CompilerOptions.UnnecessaryTypeCheck;
135             
136         case IProblem.FinallyMustCompleteNormally:
137             return CompilerOptions.FinallyBlockNotCompleting;
138             
139         case IProblem.UnusedMethodDeclaredThrownException:
140         case IProblem.UnusedConstructorDeclaredThrownException:
141             return CompilerOptions.UnusedDeclaredThrownException;
142
143         case IProblem.UnqualifiedFieldAccess:
144             return CompilerOptions.UnqualifiedFieldAccess;
145         
146         case IProblem.UnnecessaryElse:
147             return CompilerOptions.UnnecessaryElse;
148
149         case IProblem.UnsafeRawConstructorInvocation:
150         case IProblem.UnsafeRawMethodInvocation:
151         case IProblem.UnsafeTypeConversion:
152         case IProblem.UnsafeRawFieldAssignment:
153         case IProblem.UnsafeGenericCast:
154         case IProblem.UnsafeReturnTypeOverride:
155         case IProblem.UnsafeRawGenericMethodInvocation:
156         case IProblem.UnsafeRawGenericConstructorInvocation:
157         case IProblem.UnsafeGenericArrayForVarargs:
158             return CompilerOptions.UncheckedTypeOperation;
159
160         case IProblem.RawTypeReference:
161             return CompilerOptions.RawTypeReference;
162
163         case IProblem.MissingOverrideAnnotation:
164             return CompilerOptions.MissingOverrideAnnotation;
165             
166         case IProblem.FieldMissingDeprecatedAnnotation:
167         case IProblem.MethodMissingDeprecatedAnnotation:
168         case IProblem.TypeMissingDeprecatedAnnotation:
169             return CompilerOptions.MissingDeprecatedAnnotation;
170             
171         case IProblem.FinalBoundForTypeVariable:
172             return CompilerOptions.FinalParameterBound;
173
174         case IProblem.MissingSerialVersion:
175             return CompilerOptions.MissingSerialVersion;
176         
177         case IProblem.ForbiddenReference:
178             return CompilerOptions.ForbiddenReference;
179
180         case IProblem.DiscouragedReference:
181             return CompilerOptions.DiscouragedReference;
182
183         case IProblem.MethodVarargsArgumentNeedCast :
184         case IProblem.ConstructorVarargsArgumentNeedCast :
185             return CompilerOptions.VarargsArgumentNeedCast;
186
187         case IProblem.NullLocalVariableReference:
188             return CompilerOptions.NullReference;
189
190         case IProblem.PotentialNullLocalVariableReference:
191             return CompilerOptions.PotentialNullReference;
192             
193         case IProblem.RedundantLocalVariableNullAssignment:
194         case IProblem.RedundantNullCheckOnNonNullLocalVariable:
195         case IProblem.RedundantNullCheckOnNullLocalVariable:
196         case IProblem.NonNullLocalVariableComparisonYieldsFalse:
197         case IProblem.NullLocalVariableComparisonYieldsFalse:
198         case IProblem.NullLocalVariableInstanceofYieldsFalse:
199             return CompilerOptions.RedundantNullCheck;
200             
201         case IProblem.BoxingConversion :
202         case IProblem.UnboxingConversion :
203             return CompilerOptions.AutoBoxing;
204
205         case IProblem.MissingEnumConstantCase :
206             return CompilerOptions.IncompleteEnumSwitch;
207             
208         case IProblem.AnnotationTypeUsedAsSuperInterface :
209             return CompilerOptions.AnnotationSuperInterface;
210             
211         case IProblem.UnhandledWarningToken :
212             return CompilerOptions.UnhandledWarningToken;
213             
214         case IProblem.UnusedLabel :
215             return CompilerOptions.UnusedLabel;
216
217         case IProblem.JavadocUnexpectedTag:
218         case IProblem.JavadocDuplicateTag:
219         case IProblem.JavadocDuplicateReturnTag:
220         case IProblem.JavadocInvalidThrowsClass:
221         case IProblem.JavadocInvalidSeeReference:
222         case IProblem.JavadocInvalidParamTagName:
223         case IProblem.JavadocInvalidParamTagTypeParameter:
224         case IProblem.JavadocMalformedSeeReference:
225         case IProblem.JavadocInvalidSeeHref:
226         case IProblem.JavadocInvalidSeeArgs:
227         case IProblem.JavadocInvalidTag:
228         case IProblem.JavadocUnterminatedInlineTag:
229         case IProblem.JavadocMissingHashCharacter:
230         case IProblem.JavadocEmptyReturnTag:
231         case IProblem.JavadocUnexpectedText:
232         case IProblem.JavadocInvalidParamName:
233         case IProblem.JavadocDuplicateParamName:
234         case IProblem.JavadocMissingParamName:
235         case IProblem.JavadocMissingIdentifier:
236         case IProblem.JavadocInvalidMemberTypeQualification:
237         case IProblem.JavadocInvalidThrowsClassName:
238         case IProblem.JavadocDuplicateThrowsClassName:
239         case IProblem.JavadocMissingThrowsClassName:
240         case IProblem.JavadocMissingSeeReference:
241         case IProblem.JavadocInvalidValueReference:
242         case IProblem.JavadocUndefinedField:
243         case IProblem.JavadocAmbiguousField:
244         case IProblem.JavadocUndefinedConstructor:
245         case IProblem.JavadocAmbiguousConstructor:
246         case IProblem.JavadocUndefinedMethod:
247         case IProblem.JavadocAmbiguousMethod:
248         case IProblem.JavadocAmbiguousMethodReference:
249         case IProblem.JavadocParameterMismatch:
250         case IProblem.JavadocUndefinedType:
251         case IProblem.JavadocAmbiguousType:
252         case IProblem.JavadocInternalTypeNameProvided:
253         case IProblem.JavadocNoMessageSendOnArrayType:
254         case IProblem.JavadocNoMessageSendOnBaseType:
255         case IProblem.JavadocInheritedMethodHidesEnclosingName:
256         case IProblem.JavadocInheritedFieldHidesEnclosingName:
257         case IProblem.JavadocInheritedNameHidesEnclosingTypeName:
258         case IProblem.JavadocNonStaticTypeFromStaticInvocation:
259         case IProblem.JavadocGenericMethodTypeArgumentMismatch:
260         case IProblem.JavadocNonGenericMethod:
261         case IProblem.JavadocIncorrectArityForParameterizedMethod:
262         case IProblem.JavadocParameterizedMethodArgumentTypeMismatch:
263         case IProblem.JavadocTypeArgumentsForRawGenericMethod:
264         case IProblem.JavadocGenericConstructorTypeArgumentMismatch:
265         case IProblem.JavadocNonGenericConstructor:
266         case IProblem.JavadocIncorrectArityForParameterizedConstructor:
267         case IProblem.JavadocParameterizedConstructorArgumentTypeMismatch:
268         case IProblem.JavadocTypeArgumentsForRawGenericConstructor:
269         case IProblem.JavadocNotVisibleField:
270         case IProblem.JavadocNotVisibleConstructor:
271         case IProblem.JavadocNotVisibleMethod:
272         case IProblem.JavadocNotVisibleType:
273         case IProblem.JavadocUsingDeprecatedField:
274         case IProblem.JavadocUsingDeprecatedConstructor:
275         case IProblem.JavadocUsingDeprecatedMethod:
276         case IProblem.JavadocUsingDeprecatedType:
277         case IProblem.JavadocHiddenReference:
278             return CompilerOptions.InvalidJavadoc;
279
280         case IProblem.JavadocMissingParamTag:
281         case IProblem.JavadocMissingReturnTag:
282         case IProblem.JavadocMissingThrowsTag:
283             return CompilerOptions.MissingJavadocTags;
284
285         case IProblem.JavadocMissing:
286             return CompilerOptions.MissingJavadocComments;
287
288         case IProblem.ParameterAssignment:
289             return CompilerOptions.ParameterAssignment;
290
291         case IProblem.FallthroughCase:
292             return CompilerOptions.FallthroughCase;
293             
294         case IProblem.OverridingMethodWithoutSuperInvocation:
295             return CompilerOptions.OverridingMethodWithoutSuperInvocation;
296     }
297     return 0;
298 }
299 /**
300  * Compute problem category ID based on problem ID
301  * @param problemID
302  * @return a category ID
303  * @see CategorizedProblem
304  */

305 public static int getProblemCategory(int severity, int problemID) {
306     categorizeOnIrritant: {
307         // fatal problems even if optional are all falling into same category (not irritant based)
308
if ((severity & ProblemSeverities.Fatal) != 0)
309             break categorizeOnIrritant;
310         long irritant = getIrritant(problemID);
311         int irritantInt = (int) irritant;
312         if (irritantInt == irritant) {
313             switch (irritantInt) {
314                 case (int)CompilerOptions.MethodWithConstructorName:
315                 case (int)CompilerOptions.AccessEmulation:
316                 case (int)CompilerOptions.AssertUsedAsAnIdentifier:
317                 case (int)CompilerOptions.NonStaticAccessToStatic:
318                 case (int)CompilerOptions.UnqualifiedFieldAccess:
319                 case (int)CompilerOptions.UndocumentedEmptyBlock:
320                 case (int)CompilerOptions.IndirectStaticAccess:
321                     return CategorizedProblem.CAT_CODE_STYLE;
322                     
323                 case (int)CompilerOptions.MaskedCatchBlock:
324                 case (int)CompilerOptions.NoImplicitStringConversion:
325                 case (int)CompilerOptions.NoEffectAssignment:
326                 case (int)CompilerOptions.AccidentalBooleanAssign:
327                 case (int)CompilerOptions.EmptyStatement:
328                 case (int)CompilerOptions.FinallyBlockNotCompleting:
329                     return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM;
330         
331                 case (int)CompilerOptions.OverriddenPackageDefaultMethod:
332                 case (int)CompilerOptions.IncompatibleNonInheritedInterfaceMethod:
333                 case (int)CompilerOptions.LocalVariableHiding:
334                 case (int)CompilerOptions.FieldHiding:
335                     return CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT;
336                     
337                 case (int)CompilerOptions.UnusedLocalVariable:
338                 case (int)CompilerOptions.UnusedArgument:
339                 case (int)CompilerOptions.UnusedImport:
340                 case (int)CompilerOptions.UnusedPrivateMember:
341                 case (int)CompilerOptions.UnusedDeclaredThrownException:
342                 case (int)CompilerOptions.UnnecessaryTypeCheck:
343                 case (int)CompilerOptions.UnnecessaryElse:
344                     return CategorizedProblem.CAT_UNNECESSARY_CODE;
345         
346                 case (int)CompilerOptions.UsingDeprecatedAPI:
347                     return CategorizedProblem.CAT_DEPRECATION;
348                     
349                 case (int)CompilerOptions.NonExternalizedString:
350                     return CategorizedProblem.CAT_NLS;
351                     
352                 case (int)CompilerOptions.Task:
353                     return CategorizedProblem.CAT_UNSPECIFIED; // TODO may want to improve
354

355                 case (int)CompilerOptions.MissingJavadocComments:
356                 case (int)CompilerOptions.MissingJavadocTags:
357                 case (int)CompilerOptions.InvalidJavadoc:
358                 case (int)(CompilerOptions.InvalidJavadoc | CompilerOptions.UsingDeprecatedAPI):
359                     return CategorizedProblem.CAT_JAVADOC;
360                     
361                 case (int)CompilerOptions.UncheckedTypeOperation:
362                     return CategorizedProblem.CAT_UNCHECKED_RAW;
363                     
364                 default:
365                     break categorizeOnIrritant;
366             }
367         } else {
368             irritantInt = (int)(irritant >>> 32);
369             switch (irritantInt) {
370                 case (int)(CompilerOptions.FinalParameterBound >>> 32):
371                 case (int)(CompilerOptions.EnumUsedAsAnIdentifier >>> 32):
372                 case (int)(CompilerOptions.AnnotationSuperInterface >>> 32):
373                 case (int)(CompilerOptions.AutoBoxing >>> 32):
374                 case (int)(CompilerOptions.MissingOverrideAnnotation >>> 32):
375                 case (int)(CompilerOptions.MissingDeprecatedAnnotation >>> 32):
376                 case (int)(CompilerOptions.ParameterAssignment >>> 32):
377                     return CategorizedProblem.CAT_CODE_STYLE;
378                 
379                 case (int)(CompilerOptions.MissingSerialVersion >>> 32):
380                 case (int)(CompilerOptions.VarargsArgumentNeedCast >>> 32):
381                 case (int)(CompilerOptions.NullReference >>> 32):
382                 case (int)(CompilerOptions.PotentialNullReference >>> 32):
383                 case (int)(CompilerOptions.RedundantNullCheck >>> 32):
384                 case (int)(CompilerOptions.IncompleteEnumSwitch >>> 32):
385                 case (int)(CompilerOptions.FallthroughCase >>> 32):
386                 case (int)(CompilerOptions.OverridingMethodWithoutSuperInvocation >>> 32):
387                     return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM;
388     
389                 case (int)(CompilerOptions.TypeHiding >>> 32):
390                     return CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT;
391                     
392                 case (int)(CompilerOptions.UnhandledWarningToken >>> 32):
393                 case (int)(CompilerOptions.UnusedLabel >>> 32):
394                     return CategorizedProblem.CAT_UNNECESSARY_CODE;
395
396                 case (int)(CompilerOptions.ForbiddenReference >>> 32):
397                 case (int)(CompilerOptions.DiscouragedReference >>> 32):
398                     return CategorizedProblem.CAT_RESTRICTION;
399     
400                 case (int)(CompilerOptions.RawTypeReference >>> 32):
401                     return CategorizedProblem.CAT_UNCHECKED_RAW;
402
403                 default:
404                     break categorizeOnIrritant;
405             }
406         }
407     }
408     // categorize fatal problems per ID
409
switch (problemID) {
410         case IProblem.IsClassPathCorrect :
411         case IProblem.CorruptedSignature :
412             return CategorizedProblem.CAT_BUILDPATH;
413             
414         default :
415             if ((problemID & IProblem.Syntax) != 0)
416                 return CategorizedProblem.CAT_SYNTAX;
417             if ((problemID & IProblem.ImportRelated) != 0)
418                 return CategorizedProblem.CAT_IMPORT;
419             if ((problemID & IProblem.TypeRelated) != 0)
420                 return CategorizedProblem.CAT_TYPE;
421             if ((problemID & (IProblem.FieldRelated|IProblem.MethodRelated|IProblem.ConstructorRelated)) != 0)
422                 return CategorizedProblem.CAT_MEMBER;
423     }
424     return CategorizedProblem.CAT_INTERNAL;
425 }
426 public ProblemReporter(IErrorHandlingPolicy policy, CompilerOptions options, IProblemFactory problemFactory) {
427     super(policy, options, problemFactory);
428 }
429 public void abortDueToInternalError(String JavaDoc errorMessage) {
430     this.abortDueToInternalError(errorMessage, null);
431 }
432 public void abortDueToInternalError(String JavaDoc errorMessage, ASTNode location) {
433     String JavaDoc[] arguments = new String JavaDoc[] {errorMessage};
434     this.handle(
435         IProblem.Unclassified,
436         arguments,
437         arguments,
438         ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
439         location == null ? 0 : location.sourceStart,
440         location == null ? 0 : location.sourceEnd);
441 }
442 public void abstractMethodCannotBeOverridden(SourceTypeBinding type, MethodBinding concreteMethod) {
443
444     this.handle(
445         // %1 must be abstract since it cannot override the inherited package-private abstract method %2
446
IProblem.AbstractMethodCannotBeOverridden,
447         new String JavaDoc[] {
448             new String JavaDoc(type.sourceName()),
449             new String JavaDoc(
450                     CharOperation.concat(
451                         concreteMethod.declaringClass.readableName(),
452                         concreteMethod.readableName(),
453                         '.'))},
454         new String JavaDoc[] {
455             new String JavaDoc(type.sourceName()),
456             new String JavaDoc(
457                     CharOperation.concat(
458                         concreteMethod.declaringClass.shortReadableName(),
459                         concreteMethod.shortReadableName(),
460                         '.'))},
461         type.sourceStart(),
462         type.sourceEnd());
463 }
464 public void abstractMethodInAbstractClass(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
465
466     String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName()), new String JavaDoc(methodDecl.selector)};
467     this.handle(
468         IProblem.AbstractMethodInAbstractClass,
469         arguments,
470         arguments,
471         methodDecl.sourceStart,
472         methodDecl.sourceEnd);
473 }
474 public void abstractMethodMustBeImplemented(SourceTypeBinding type, MethodBinding abstractMethod) {
475     this.handle(
476         // Must implement the inherited abstract method %1
477
// 8.4.3 - Every non-abstract subclass of an abstract type, A, must provide a concrete implementation of all of A's methods.
478
IProblem.AbstractMethodMustBeImplemented,
479         new String JavaDoc[] {
480                 new String JavaDoc(abstractMethod.selector),
481                 typesAsString(abstractMethod.isVarargs(), abstractMethod.parameters, false),
482                 new String JavaDoc(abstractMethod.declaringClass.readableName()),
483                 new String JavaDoc(type.readableName()),
484         },
485         new String JavaDoc[] {
486                 new String JavaDoc(abstractMethod.selector),
487                 typesAsString(abstractMethod.isVarargs(), abstractMethod.parameters, true),
488                 new String JavaDoc(abstractMethod.declaringClass.shortReadableName()),
489                 new String JavaDoc(type.shortReadableName()),
490         },
491         type.sourceStart(),
492         type.sourceEnd());
493 }
494 public void abstractMethodNeedingNoBody(AbstractMethodDeclaration method) {
495     this.handle(
496         IProblem.BodyForAbstractMethod,
497         NoArgument,
498         NoArgument,
499         method.sourceStart,
500         method.sourceEnd,
501         method,
502         method.compilationResult());
503 }
504 public void alreadyDefinedLabel(char[] labelName, ASTNode location) {
505     String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(labelName)};
506     this.handle(
507         IProblem.DuplicateLabel,
508         arguments,
509         arguments,
510         location.sourceStart,
511         location.sourceEnd);
512 }
513 public void annotationCannotOverrideMethod(MethodBinding overrideMethod, MethodBinding inheritedMethod) {
514     ASTNode location = overrideMethod.sourceMethod();
515     this.handle(
516         IProblem.AnnotationCannotOverrideMethod,
517         new String JavaDoc[] {
518                 new String JavaDoc(overrideMethod.declaringClass.readableName()),
519                 new String JavaDoc(inheritedMethod.declaringClass.readableName()),
520                 new String JavaDoc(inheritedMethod.selector),
521                 typesAsString(inheritedMethod.isVarargs(), inheritedMethod.parameters, false)},
522         new String JavaDoc[] {
523                 new String JavaDoc(overrideMethod.declaringClass.shortReadableName()),
524                 new String JavaDoc(inheritedMethod.declaringClass.shortReadableName()),
525                 new String JavaDoc(inheritedMethod.selector),
526                 typesAsString(inheritedMethod.isVarargs(), inheritedMethod.parameters, true)},
527         location.sourceStart,
528         location.sourceEnd);
529 }
530 public void annotationCircularity(TypeBinding sourceType, TypeBinding otherType, TypeReference reference) {
531     if (sourceType == otherType)
532         this.handle(
533             IProblem.AnnotationCircularitySelfReference,
534             new String JavaDoc[] {new String JavaDoc(sourceType.readableName())},
535             new String JavaDoc[] {new String JavaDoc(sourceType.shortReadableName())},
536             reference.sourceStart,
537             reference.sourceEnd);
538     else
539         this.handle(
540             IProblem.AnnotationCircularity,
541             new String JavaDoc[] {new String JavaDoc(sourceType.readableName()), new String JavaDoc(otherType.readableName())},
542             new String JavaDoc[] {new String JavaDoc(sourceType.shortReadableName()), new String JavaDoc(otherType.shortReadableName())},
543             reference.sourceStart,
544             reference.sourceEnd);
545 }
546 public void annotationMembersCannotHaveParameters(AnnotationMethodDeclaration annotationMethodDeclaration) {
547     this.handle(
548         IProblem.AnnotationMembersCannotHaveParameters,
549         NoArgument,
550         NoArgument,
551         annotationMethodDeclaration.sourceStart,
552         annotationMethodDeclaration.sourceEnd);
553 }
554 public void annotationMembersCannotHaveTypeParameters(AnnotationMethodDeclaration annotationMethodDeclaration) {
555     this.handle(
556         IProblem.AnnotationMembersCannotHaveTypeParameters,
557         NoArgument,
558         NoArgument,
559         annotationMethodDeclaration.sourceStart,
560         annotationMethodDeclaration.sourceEnd);
561 }
562 public void annotationTypeDeclarationCannotHaveConstructor(ConstructorDeclaration constructorDeclaration) {
563     this.handle(
564         IProblem.AnnotationTypeDeclarationCannotHaveConstructor,
565         NoArgument,
566         NoArgument,
567         constructorDeclaration.sourceStart,
568         constructorDeclaration.sourceEnd);
569 }
570 public void annotationTypeDeclarationCannotHaveSuperclass(TypeDeclaration typeDeclaration) {
571     this.handle(
572         IProblem.AnnotationTypeDeclarationCannotHaveSuperclass,
573         NoArgument,
574         NoArgument,
575         typeDeclaration.sourceStart,
576         typeDeclaration.sourceEnd);
577 }
578 public void annotationTypeDeclarationCannotHaveSuperinterfaces(TypeDeclaration typeDeclaration) {
579     this.handle(
580         IProblem.AnnotationTypeDeclarationCannotHaveSuperinterfaces,
581         NoArgument,
582         NoArgument,
583         typeDeclaration.sourceStart,
584         typeDeclaration.sourceEnd);
585 }
586 public void annotationTypeUsedAsSuperinterface(SourceTypeBinding type, TypeReference superInterfaceRef, ReferenceBinding superType) {
587     this.handle(
588         IProblem.AnnotationTypeUsedAsSuperInterface,
589         new String JavaDoc[] {new String JavaDoc(superType.readableName()), new String JavaDoc(type.sourceName())},
590         new String JavaDoc[] {new String JavaDoc(superType.shortReadableName()), new String JavaDoc(type.sourceName())},
591         superInterfaceRef.sourceStart,
592         superInterfaceRef.sourceEnd);
593 }
594 public void annotationValueMustBeAnnotation(TypeBinding annotationType, char[] name, Expression value, TypeBinding expectedType) {
595     String JavaDoc str = new String JavaDoc(name);
596     this.handle(
597         IProblem.AnnotationValueMustBeAnnotation,
598         new String JavaDoc[] { new String JavaDoc(annotationType.readableName()), str, new String JavaDoc(expectedType.readableName()), },
599         new String JavaDoc[] { new String JavaDoc(annotationType.shortReadableName()), str, new String JavaDoc(expectedType.readableName()), },
600         value.sourceStart,
601         value.sourceEnd);
602 }
603 public void annotationValueMustBeArrayInitializer(TypeBinding annotationType, char[] name, Expression value) {
604     String JavaDoc str = new String JavaDoc(name);
605     this.handle(
606         IProblem.AnnotationValueMustBeArrayInitializer,
607         new String JavaDoc[] { new String JavaDoc(annotationType.readableName()), str },
608         new String JavaDoc[] { new String JavaDoc(annotationType.shortReadableName()), str},
609         value.sourceStart,
610         value.sourceEnd);
611 }
612 public void annotationValueMustBeClassLiteral(TypeBinding annotationType, char[] name, Expression value) {
613     String JavaDoc str = new String JavaDoc(name);
614     this.handle(
615         IProblem.AnnotationValueMustBeClassLiteral,
616         new String JavaDoc[] { new String JavaDoc(annotationType.readableName()), str },
617         new String JavaDoc[] { new String JavaDoc(annotationType.shortReadableName()), str},
618         value.sourceStart,
619         value.sourceEnd);
620 }
621 public void annotationValueMustBeConstant(TypeBinding annotationType, char[] name, Expression value, boolean isEnum) {
622     String JavaDoc str = new String JavaDoc(name);
623     if (isEnum) {
624         this.handle(
625             IProblem.AnnotationValueMustBeAnEnumConstant,
626             new String JavaDoc[] { new String JavaDoc(annotationType.readableName()), str },
627             new String JavaDoc[] { new String JavaDoc(annotationType.shortReadableName()), str},
628             value.sourceStart,
629             value.sourceEnd);
630     } else {
631         this.handle(
632             IProblem.AnnotationValueMustBeConstant,
633             new String JavaDoc[] { new String JavaDoc(annotationType.readableName()), str },
634             new String JavaDoc[] { new String JavaDoc(annotationType.shortReadableName()), str},
635             value.sourceStart,
636             value.sourceEnd);
637     }
638 }
639 public void anonymousClassCannotExtendFinalClass(Expression expression, TypeBinding type) {
640     this.handle(
641         IProblem.AnonymousClassCannotExtendFinalClass,
642         new String JavaDoc[] {new String JavaDoc(type.readableName())},
643         new String JavaDoc[] {new String JavaDoc(type.shortReadableName())},
644         expression.sourceStart,
645         expression.sourceEnd);
646 }
647 public void argumentTypeCannotBeVoid(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, Argument arg) {
648     String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(methodDecl.selector), new String JavaDoc(arg.name)};
649     this.handle(
650         IProblem.ArgumentTypeCannotBeVoid,
651         arguments,
652         arguments,
653         methodDecl.sourceStart,
654         methodDecl.sourceEnd);
655 }
656 public void argumentTypeCannotBeVoidArray(Argument arg) {
657     this.handle(
658         IProblem.CannotAllocateVoidArray,
659         NoArgument,
660         NoArgument,
661         arg.type.sourceStart,
662         arg.type.sourceEnd);
663 }
664 public void arrayConstantsOnlyInArrayInitializers(int sourceStart, int sourceEnd) {
665     this.handle(
666         IProblem.ArrayConstantsOnlyInArrayInitializers,
667         NoArgument,
668         NoArgument,
669         sourceStart,
670         sourceEnd);
671 }
672 public void assignmentHasNoEffect(AbstractVariableDeclaration location, char[] name){
673     int severity = computeSeverity(IProblem.AssignmentHasNoEffect);
674     if (severity == ProblemSeverities.Ignore) return;
675     String JavaDoc[] arguments = new String JavaDoc[] { new String JavaDoc(name) };
676     int start = location.sourceStart;
677     int end = location.sourceEnd;
678     if (location.initialization != null) {
679         end = location.initialization.sourceEnd;
680     }
681     this.handle(
682             IProblem.AssignmentHasNoEffect,
683             arguments,
684             arguments,
685             severity,
686             start,
687             end);
688 }
689 public void assignmentHasNoEffect(Assignment location, char[] name){
690     int severity = computeSeverity(IProblem.AssignmentHasNoEffect);
691     if (severity == ProblemSeverities.Ignore) return;
692     String JavaDoc[] arguments = new String JavaDoc[] { new String JavaDoc(name) };
693     this.handle(
694             IProblem.AssignmentHasNoEffect,
695             arguments,
696             arguments,
697             severity,
698             location.sourceStart,
699             location.sourceEnd);
700 }
701 public void attemptToReturnNonVoidExpression(ReturnStatement returnStatement, TypeBinding expectedType) {
702     this.handle(
703         IProblem.VoidMethodReturnsValue,
704         new String JavaDoc[] {new String JavaDoc(expectedType.readableName())},
705         new String JavaDoc[] {new String JavaDoc(expectedType.shortReadableName())},
706         returnStatement.sourceStart,
707         returnStatement.sourceEnd);
708 }
709 public void attemptToReturnVoidValue(ReturnStatement returnStatement) {
710     this.handle(
711         IProblem.MethodReturnsVoid,
712         NoArgument,
713         NoArgument,
714         returnStatement.sourceStart,
715         returnStatement.sourceEnd);
716 }
717 public void autoboxing(Expression expression, TypeBinding originalType, TypeBinding convertedType) {
718     if (this.options.getSeverity(CompilerOptions.AutoBoxing) == ProblemSeverities.Ignore) return;
719     this.handle(
720         originalType.isBaseType() ? IProblem.BoxingConversion : IProblem.UnboxingConversion,
721         new String JavaDoc[] { new String JavaDoc(originalType.readableName()), new String JavaDoc(convertedType.readableName()), },
722         new String JavaDoc[] { new String JavaDoc(originalType.shortReadableName()), new String JavaDoc(convertedType.shortReadableName()), },
723         expression.sourceStart,
724         expression.sourceEnd);
725 }
726 public void boundCannotBeArray(ASTNode location, TypeBinding type) {
727     this.handle(
728         IProblem.BoundCannotBeArray,
729         new String JavaDoc[] {new String JavaDoc(type.readableName())},
730         new String JavaDoc[] {new String JavaDoc(type.shortReadableName())},
731         location.sourceStart,
732         location.sourceEnd);
733 }
734 public void boundMustBeAnInterface(ASTNode location, TypeBinding type) {
735     this.handle(
736         IProblem.BoundMustBeAnInterface,
737         new String JavaDoc[] {new String JavaDoc(type.readableName())},
738         new String JavaDoc[] {new String JavaDoc(type.shortReadableName())},
739         location.sourceStart,
740         location.sourceEnd);
741 }
742 public void bytecodeExceeds64KLimit(AbstractMethodDeclaration location) {
743     MethodBinding method = location.binding;
744     if (location.isConstructor()) {
745         this.handle(
746             IProblem.BytecodeExceeds64KLimitForConstructor,
747             new String JavaDoc[] {new String JavaDoc(location.selector), typesAsString(method.isVarargs(), method.parameters, false)},
748             new String JavaDoc[] {new String JavaDoc(location.selector), typesAsString(method.isVarargs(), method.parameters, true)},
749             ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
750             location.sourceStart,
751             location.sourceEnd);
752     } else {
753         this.handle(
754             IProblem.BytecodeExceeds64KLimit,
755             new String JavaDoc[] {new String JavaDoc(location.selector), typesAsString(method.isVarargs(), method.parameters, false)},
756             new String JavaDoc[] {new String JavaDoc(location.selector), typesAsString(method.isVarargs(), method.parameters, true)},
757             ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
758             location.sourceStart,
759             location.sourceEnd);
760     }
761 }
762 public void bytecodeExceeds64KLimit(TypeDeclaration location) {
763     this.handle(
764         IProblem.BytecodeExceeds64KLimitForClinit,
765         NoArgument,
766         NoArgument,
767         ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
768         location.sourceStart,
769         location.sourceEnd);
770 }
771 public void cannotAllocateVoidArray(Expression expression) {
772     this.handle(
773         IProblem.CannotAllocateVoidArray,
774         NoArgument,
775         NoArgument,
776         expression.sourceStart,
777         expression.sourceEnd);
778 }
779 public void cannotAssignToFinalField(FieldBinding field, ASTNode location) {
780     this.handle(
781         IProblem.FinalFieldAssignment,
782         new String JavaDoc[] {
783             (field.declaringClass == null ? "array" : new String JavaDoc(field.declaringClass.readableName())), //$NON-NLS-1$
784
new String JavaDoc(field.readableName())},
785         new String JavaDoc[] {
786             (field.declaringClass == null ? "array" : new String JavaDoc(field.declaringClass.shortReadableName())), //$NON-NLS-1$
787
new String JavaDoc(field.shortReadableName())},
788         nodeSourceStart(field, location),
789         nodeSourceEnd(field, location));
790 }
791 public void cannotAssignToFinalLocal(LocalVariableBinding local, ASTNode location) {
792     String JavaDoc[] arguments = new String JavaDoc[] { new String JavaDoc(local.readableName())};
793     this.handle(
794         IProblem.NonBlankFinalLocalAssignment,
795         arguments,
796         arguments,
797         nodeSourceStart(local, location),
798         nodeSourceEnd(local, location));
799 }
800 public void cannotAssignToFinalOuterLocal(LocalVariableBinding local, ASTNode location) {
801     String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(local.readableName())};
802     this.handle(
803         IProblem.FinalOuterLocalAssignment,
804         arguments,
805         arguments,
806         nodeSourceStart(local, location),
807         nodeSourceEnd(local, location));
808 }
809 public void cannotDefineDimensionsAndInitializer(ArrayAllocationExpression expresssion) {
810     this.handle(
811         IProblem.CannotDefineDimensionExpressionsWithInit,
812         NoArgument,
813         NoArgument,
814         expresssion.sourceStart,
815         expresssion.sourceEnd);
816 }
817 public void cannotDireclyInvokeAbstractMethod(MessageSend messageSend, MethodBinding method) {
818     this.handle(
819         IProblem.DirectInvocationOfAbstractMethod,
820         new String JavaDoc[] {new String JavaDoc(method.declaringClass.readableName()), new String JavaDoc(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
821         new String JavaDoc[] {new String JavaDoc(method.declaringClass.shortReadableName()), new String JavaDoc(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
822         messageSend.sourceStart,
823         messageSend.sourceEnd);
824 }
825 public void cannotExtendEnum(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) {
826     String JavaDoc name = new String JavaDoc(type.sourceName());
827     String JavaDoc superTypeFullName = new String JavaDoc(superTypeBinding.readableName());
828     String JavaDoc superTypeShortName = new String JavaDoc(superTypeBinding.shortReadableName());
829     if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName;
830     this.handle(
831         IProblem.CannotExtendEnum,
832         new String JavaDoc[] {superTypeFullName, name},
833         new String JavaDoc[] {superTypeShortName, name},
834         superclass.sourceStart,
835         superclass.sourceEnd);
836 }
837 public void cannotImportPackage(ImportReference importRef) {
838     String JavaDoc[] arguments = new String JavaDoc[] {CharOperation.toString(importRef.tokens)};
839     this.handle(
840         IProblem.CannotImportPackage,
841         arguments,
842         arguments,
843         importRef.sourceStart,
844         importRef.sourceEnd);
845 }
846 public void cannotInstantiate(TypeReference typeRef, TypeBinding type) {
847     this.handle(
848         IProblem.InvalidClassInstantiation,
849         new String JavaDoc[] {new String JavaDoc(type.readableName())},
850         new String JavaDoc[] {new String JavaDoc(type.shortReadableName())},
851         typeRef.sourceStart,
852         typeRef.sourceEnd);
853 }
854 public void cannotInvokeSuperConstructorInEnum(ExplicitConstructorCall constructorCall, MethodBinding enumConstructor) {
855     this.handle(
856         IProblem.CannotInvokeSuperConstructorInEnum,
857         new String JavaDoc[] {
858                 new String JavaDoc(enumConstructor.declaringClass.sourceName()),
859                 typesAsString(enumConstructor.isVarargs(), enumConstructor.parameters, false),
860          },
861         new String JavaDoc[] {
862                 new String JavaDoc(enumConstructor.declaringClass.sourceName()),
863                 typesAsString(enumConstructor.isVarargs(), enumConstructor.parameters, true),
864          },
865         constructorCall.sourceStart,
866         constructorCall.sourceEnd);
867 }
868 public void cannotReadSource(CompilationUnitDeclaration unit, AbortCompilationUnit abortException, boolean verbose) {
869     String JavaDoc fileName = new String JavaDoc(unit.compilationResult.fileName);
870     if (abortException.exception instanceof CharConversionException JavaDoc) {
871         // specific encoding issue
872
String JavaDoc encoding = abortException.encoding;
873         if (encoding == null) {
874             encoding = System.getProperty("file.encoding"); //$NON-NLS-1$
875
}
876         String JavaDoc[] arguments = new String JavaDoc[]{ fileName, encoding, };
877         this.handle(
878                 IProblem.InvalidEncoding,
879                 arguments,
880                 arguments,
881                 0,
882                 0);
883         return;
884     }
885     StringWriter JavaDoc stringWriter = new StringWriter JavaDoc();
886     PrintWriter JavaDoc writer = new PrintWriter JavaDoc(stringWriter);
887     if (verbose) {
888         abortException.exception.printStackTrace(writer);
889     } else {
890         writer.print(abortException.exception.getClass().getName());
891         writer.print(':');
892         writer.print(abortException.exception.getMessage());
893     }
894     String JavaDoc exceptionTrace = stringWriter.toString();
895     String JavaDoc[] arguments = new String JavaDoc[]{ fileName, exceptionTrace, };
896     this.handle(
897             IProblem.CannotReadSource,
898             arguments,
899             arguments,
900             0,
901             0);
902 }
903 public void cannotReferToNonFinalOuterLocal(LocalVariableBinding local, ASTNode location) {
904     String JavaDoc[] arguments =new String JavaDoc[]{ new String JavaDoc(local.readableName())};
905     this.handle(
906         IProblem.OuterLocalMustBeFinal,
907         arguments,
908         arguments,
909         nodeSourceStart(local, location),
910         nodeSourceEnd(local, location));
911 }
912 public void cannotReturnInInitializer(ASTNode location) {
913     this.handle(
914         IProblem.CannotReturnInInitializer,
915         NoArgument,
916         NoArgument,
917         location.sourceStart,
918         location.sourceEnd);
919 }
920 public void cannotThrowNull(ASTNode expression) {
921     this.handle(
922         IProblem.CannotThrowNull,
923         NoArgument,
924         NoArgument,
925         expression.sourceStart,
926         expression.sourceEnd);
927 }
928 public void cannotThrowType(ASTNode exception, TypeBinding expectedType) {
929     this.handle(
930         IProblem.CannotThrowType,
931         new String JavaDoc[] {new String JavaDoc(expectedType.readableName())},
932         new String JavaDoc[] {new String JavaDoc(expectedType.shortReadableName())},
933         exception.sourceStart,
934         exception.sourceEnd);
935 }
936 public void cannotUseQualifiedEnumConstantInCaseLabel(Reference location, FieldBinding field) {
937     this.handle(
938             IProblem.IllegalQualifiedEnumConstantLabel,
939             new String JavaDoc[]{ String.valueOf(field.declaringClass.readableName()), String.valueOf(field.name) },
940             new String JavaDoc[]{ String.valueOf(field.declaringClass.shortReadableName()), String.valueOf(field.name) },
941             nodeSourceStart(field, location),
942             nodeSourceEnd(field, location));
943 }
944 public void cannotUseSuperInCodeSnippet(int start, int end) {
945     this.handle(
946         IProblem.CannotUseSuperInCodeSnippet,
947         NoArgument,
948         NoArgument,
949         ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
950         start,
951         end);
952 }
953 public void cannotUseSuperInJavaLangObject(ASTNode reference) {
954     this.handle(
955         IProblem.ObjectHasNoSuperclass,
956         NoArgument,
957         NoArgument,
958         reference.sourceStart,
959         reference.sourceEnd);
960 }
961 public void caseExpressionMustBeConstant(Expression expression) {
962     this.handle(
963         IProblem.NonConstantExpression,
964         NoArgument,
965         NoArgument,
966         expression.sourceStart,
967         expression.sourceEnd);
968 }
969 public void classExtendFinalClass(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) {
970     String JavaDoc name = new String JavaDoc(type.sourceName());
971     String JavaDoc superTypeFullName = new String JavaDoc(superTypeBinding.readableName());
972     String JavaDoc superTypeShortName = new String JavaDoc(superTypeBinding.shortReadableName());
973     if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName;
974     this.handle(
975         IProblem.ClassExtendFinalClass,
976         new String JavaDoc[] {superTypeFullName, name},
977         new String JavaDoc[] {superTypeShortName, name},
978         superclass.sourceStart,
979         superclass.sourceEnd);
980 }
981 public void codeSnippetMissingClass(String JavaDoc missing, int start, int end) {
982     String JavaDoc[] arguments = new String JavaDoc[]{missing};
983     this.handle(
984         IProblem.CodeSnippetMissingClass,
985         arguments,
986         arguments,
987         ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
988         start,
989         end);
990 }
991 public void codeSnippetMissingMethod(String JavaDoc className, String JavaDoc missingMethod, String JavaDoc argumentTypes, int start, int end) {
992     String JavaDoc[] arguments = new String JavaDoc[]{ className, missingMethod, argumentTypes };
993     this.handle(
994         IProblem.CodeSnippetMissingMethod,
995         arguments,
996         arguments,
997         ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
998         start,
999         end);
1000}
1001/*
1002 * Given the current configuration, answers which category the problem
1003 * falls into:
1004 * ProblemSeverities.Error | ProblemSeverities.Warning | ProblemSeverities.Ignore
1005 * when different from Ignore, severity can be coupled with ProblemSeverities.Optional
1006 * to indicate that this problem is configurable through options
1007 */

1008public int computeSeverity(int problemID){
1009
1010    switch (problemID) {
1011        case IProblem.Task :
1012            return ProblemSeverities.Warning;
1013        case IProblem.VarargsConflict :
1014            return ProblemSeverities.Warning;
1015        case IProblem.TypeCollidesWithPackage :
1016            return ProblemSeverities.Warning;
1017            
1018        /*
1019         * Javadoc tags resolved references errors
1020         */

1021        case IProblem.JavadocInvalidParamName:
1022        case IProblem.JavadocDuplicateParamName:
1023        case IProblem.JavadocMissingParamName:
1024        case IProblem.JavadocMissingIdentifier:
1025        case IProblem.JavadocInvalidMemberTypeQualification:
1026        case IProblem.JavadocInvalidThrowsClassName:
1027        case IProblem.JavadocDuplicateThrowsClassName:
1028        case IProblem.JavadocMissingThrowsClassName:
1029        case IProblem.JavadocMissingSeeReference:
1030        case IProblem.JavadocInvalidValueReference:
1031        case IProblem.JavadocUndefinedField:
1032        case IProblem.JavadocAmbiguousField:
1033        case IProblem.JavadocUndefinedConstructor:
1034        case IProblem.JavadocAmbiguousConstructor:
1035        case IProblem.JavadocUndefinedMethod:
1036        case IProblem.JavadocAmbiguousMethod:
1037        case IProblem.JavadocAmbiguousMethodReference:
1038        case IProblem.JavadocParameterMismatch:
1039        case IProblem.JavadocUndefinedType:
1040        case IProblem.JavadocAmbiguousType:
1041        case IProblem.JavadocInternalTypeNameProvided:
1042        case IProblem.JavadocNoMessageSendOnArrayType:
1043        case IProblem.JavadocNoMessageSendOnBaseType:
1044        case IProblem.JavadocInheritedMethodHidesEnclosingName:
1045        case IProblem.JavadocInheritedFieldHidesEnclosingName:
1046        case IProblem.JavadocInheritedNameHidesEnclosingTypeName:
1047        case IProblem.JavadocNonStaticTypeFromStaticInvocation:
1048        case IProblem.JavadocGenericMethodTypeArgumentMismatch:
1049        case IProblem.JavadocNonGenericMethod:
1050        case IProblem.JavadocIncorrectArityForParameterizedMethod:
1051        case IProblem.JavadocParameterizedMethodArgumentTypeMismatch:
1052        case IProblem.JavadocTypeArgumentsForRawGenericMethod:
1053        case IProblem.JavadocGenericConstructorTypeArgumentMismatch:
1054        case IProblem.JavadocNonGenericConstructor:
1055        case IProblem.JavadocIncorrectArityForParameterizedConstructor:
1056        case IProblem.JavadocParameterizedConstructorArgumentTypeMismatch:
1057        case IProblem.JavadocTypeArgumentsForRawGenericConstructor:
1058        case IProblem.JavadocEmptyReturnTag:
1059            if (!this.options.reportInvalidJavadocTags) {
1060                return ProblemSeverities.Ignore;
1061            }
1062            break;
1063        /*
1064         * Javadoc invalid tags due to deprecated references
1065         */

1066        case IProblem.JavadocUsingDeprecatedField:
1067        case IProblem.JavadocUsingDeprecatedConstructor:
1068        case IProblem.JavadocUsingDeprecatedMethod:
1069        case IProblem.JavadocUsingDeprecatedType:
1070            if (!(this.options.reportInvalidJavadocTags && this.options.reportInvalidJavadocTagsDeprecatedRef)) {
1071                return ProblemSeverities.Ignore;
1072            }
1073            break;
1074        /*
1075         * Javadoc invalid tags due to non-visible references
1076         */

1077        case IProblem.JavadocNotVisibleField:
1078        case IProblem.JavadocNotVisibleConstructor:
1079        case IProblem.JavadocNotVisibleMethod:
1080        case IProblem.JavadocNotVisibleType:
1081        case IProblem.JavadocHiddenReference:
1082            if (!(this.options.reportInvalidJavadocTags && this.options.reportInvalidJavadocTagsNotVisibleRef)) {
1083                return ProblemSeverities.Ignore;
1084            }
1085            break;
1086    }
1087    long irritant = getIrritant(problemID);
1088    if (irritant != 0) {
1089        if ((problemID & IProblem.Javadoc) != 0 && !this.options.docCommentSupport)
1090            return ProblemSeverities.Ignore;
1091        return this.options.getSeverity(irritant);
1092    }
1093    return ProblemSeverities.Error | ProblemSeverities.Fatal;
1094}
1095public void conditionalArgumentsIncompatibleTypes(ConditionalExpression expression, TypeBinding trueType, TypeBinding falseType) {
1096    this.handle(
1097        IProblem.IncompatibleTypesInConditionalOperator,
1098        new String JavaDoc[] {new String JavaDoc(trueType.readableName()), new String JavaDoc(falseType.readableName())},
1099        new String JavaDoc[] {new String JavaDoc(trueType.sourceName()), new String JavaDoc(falseType.sourceName())},
1100        expression.sourceStart,
1101        expression.sourceEnd);
1102}
1103public void conflictingImport(ImportReference importRef) {
1104    String JavaDoc[] arguments = new String JavaDoc[] {CharOperation.toString(importRef.tokens)};
1105    this.handle(
1106        IProblem.ConflictingImport,
1107        arguments,
1108        arguments,
1109        importRef.sourceStart,
1110        importRef.sourceEnd);
1111}
1112public void constantOutOfFormat(NumberLiteral literal) {
1113    // the literal is not in a correct format
1114
// this code is called on IntLiteral and LongLiteral
1115
// example 000811 ...the 8 is uncorrect.
1116

1117    if ((literal instanceof LongLiteral) || (literal instanceof IntLiteral)) {
1118        char[] source = literal.source();
1119        try {
1120            final String JavaDoc Radix;
1121            final int radix;
1122            if ((source[1] == 'x') || (source[1] == 'X')) {
1123                radix = 16;
1124                Radix = "Hex"; //$NON-NLS-1$
1125
} else {
1126                radix = 8;
1127                Radix = "Octal"; //$NON-NLS-1$
1128
}
1129            //look for the first digit that is incorrect
1130
int place = -1;
1131            label : for (int i = radix == 8 ? 1 : 2; i < source.length; i++) {
1132                if (ScannerHelper.digit(source[i], radix) == -1) {
1133                    place = i;
1134                    break label;
1135                }
1136            }
1137            String JavaDoc[] arguments = new String JavaDoc[] {
1138                new String JavaDoc(literal.literalType(null).readableName()), // numeric literals do not need scope to reach type
1139
Radix + " " + new String JavaDoc(source) + " (digit " + new String JavaDoc(new char[] {source[place]}) + ")"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1140

1141            this.handle(
1142                IProblem.NumericValueOutOfRange,
1143                arguments,
1144                arguments,
1145                literal.sourceStart,
1146                literal.sourceEnd);
1147            return;
1148        } catch (IndexOutOfBoundsException JavaDoc ex) {
1149            // should never happen
1150
}
1151    
1152        // just in case .... use a predefined error..
1153
// we should never come here...(except if the code changes !)
1154
this.constantOutOfRange(literal, literal.literalType(null)); // numeric literals do not need scope to reach type
1155
}
1156}
1157public void constantOutOfRange(Literal literal, TypeBinding literalType) {
1158    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(literalType.readableName()), new String JavaDoc(literal.source())};
1159    this.handle(
1160        IProblem.NumericValueOutOfRange,
1161        arguments,
1162        arguments,
1163        literal.sourceStart,
1164        literal.sourceEnd);
1165}
1166public void corruptedSignature(TypeBinding enclosingType, char[] signature, int position) {
1167    this.handle(
1168        IProblem.CorruptedSignature,
1169        new String JavaDoc[] { new String JavaDoc(enclosingType.readableName()), new String JavaDoc(signature), String.valueOf(position) },
1170        new String JavaDoc[] { new String JavaDoc(enclosingType.shortReadableName()), new String JavaDoc(signature), String.valueOf(position) },
1171        ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
1172        0,
1173        0);
1174}
1175public void deprecatedField(FieldBinding field, ASTNode location) {
1176    int severity = computeSeverity(IProblem.UsingDeprecatedField);
1177    if (severity == ProblemSeverities.Ignore) return;
1178    this.handle(
1179        IProblem.UsingDeprecatedField,
1180        new String JavaDoc[] {new String JavaDoc(field.declaringClass.readableName()), new String JavaDoc(field.name)},
1181        new String JavaDoc[] {new String JavaDoc(field.declaringClass.shortReadableName()), new String JavaDoc(field.name)},
1182        severity,
1183        nodeSourceStart(field, location),
1184        nodeSourceEnd(field, location));
1185}
1186public void deprecatedMethod(MethodBinding method, ASTNode location) {
1187    boolean isConstructor = method.isConstructor();
1188    int severity = computeSeverity(isConstructor ? IProblem.UsingDeprecatedConstructor : IProblem.UsingDeprecatedMethod);
1189    if (severity == ProblemSeverities.Ignore) return;
1190    if (isConstructor) {
1191        this.handle(
1192            IProblem.UsingDeprecatedConstructor,
1193            new String JavaDoc[] {new String JavaDoc(method.declaringClass.readableName()), typesAsString(method.isVarargs(), method.parameters, false)},
1194            new String JavaDoc[] {new String JavaDoc(method.declaringClass.shortReadableName()), typesAsString(method.isVarargs(), method.parameters, true)},
1195            severity,
1196            location.sourceStart,
1197            location.sourceEnd);
1198    } else {
1199        this.handle(
1200            IProblem.UsingDeprecatedMethod,
1201            new String JavaDoc[] {new String JavaDoc(method.declaringClass.readableName()), new String JavaDoc(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
1202            new String JavaDoc[] {new String JavaDoc(method.declaringClass.shortReadableName()), new String JavaDoc(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
1203            severity,
1204            location.sourceStart,
1205            location.sourceEnd);
1206    }
1207}
1208public void deprecatedType(TypeBinding type, ASTNode location) {
1209    if (location == null) return; // 1G828DN - no type ref for synthetic arguments
1210
int severity = computeSeverity(IProblem.UsingDeprecatedType);
1211    if (severity == ProblemSeverities.Ignore) return;
1212    type = type.leafComponentType();
1213    this.handle(
1214        IProblem.UsingDeprecatedType,
1215        new String JavaDoc[] {new String JavaDoc(type.readableName())},
1216        new String JavaDoc[] {new String JavaDoc(type.shortReadableName())},
1217        severity,
1218        location.sourceStart,
1219        nodeSourceEnd(null, location));
1220}
1221public void disallowedTargetForAnnotation(Annotation annotation) {
1222    this.handle(
1223        IProblem.DisallowedTargetForAnnotation,
1224        new String JavaDoc[] {new String JavaDoc(annotation.resolvedType.readableName())},
1225        new String JavaDoc[] {new String JavaDoc(annotation.resolvedType.shortReadableName())},
1226        annotation.sourceStart,
1227        annotation.sourceEnd);
1228}
1229public void duplicateAnnotation(Annotation annotation) {
1230    this.handle(
1231        IProblem.DuplicateAnnotation,
1232        new String JavaDoc[] {new String JavaDoc(annotation.resolvedType.readableName())},
1233        new String JavaDoc[] {new String JavaDoc(annotation.resolvedType.shortReadableName())},
1234        annotation.sourceStart,
1235        annotation.sourceEnd);
1236}
1237public void duplicateAnnotationValue(TypeBinding annotationType, MemberValuePair memberValuePair) {
1238    String JavaDoc name = new String JavaDoc(memberValuePair.name);
1239    this.handle(
1240        IProblem.DuplicateAnnotationMember,
1241        new String JavaDoc[] { name, new String JavaDoc(annotationType.readableName())},
1242        new String JavaDoc[] { name, new String JavaDoc(annotationType.shortReadableName())},
1243        memberValuePair.sourceStart,
1244        memberValuePair.sourceEnd);
1245}
1246public void duplicateBounds(ASTNode location, TypeBinding type) {
1247    this.handle(
1248        IProblem.DuplicateBounds,
1249        new String JavaDoc[] {new String JavaDoc(type.readableName())},
1250        new String JavaDoc[] {new String JavaDoc(type.shortReadableName())},
1251        location.sourceStart,
1252        location.sourceEnd);
1253}
1254public void duplicateCase(CaseStatement caseStatement) {
1255    this.handle(
1256        IProblem.DuplicateCase,
1257        NoArgument,
1258        NoArgument,
1259        caseStatement.sourceStart,
1260        caseStatement.sourceEnd);
1261}
1262public void duplicateDefaultCase(ASTNode statement) {
1263    this.handle(
1264        IProblem.DuplicateDefaultCase,
1265        NoArgument,
1266        NoArgument,
1267        statement.sourceStart,
1268        statement.sourceEnd);
1269}
1270
1271public void duplicateEnumSpecialMethod(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
1272    MethodBinding method = methodDecl.binding;
1273    this.handle(
1274        IProblem.CannotDeclareEnumSpecialMethod,
1275        new String JavaDoc[] {
1276            new String JavaDoc(methodDecl.selector),
1277            new String JavaDoc(method.declaringClass.readableName()),
1278            typesAsString(method.isVarargs(), method.parameters, false)},
1279        new String JavaDoc[] {
1280            new String JavaDoc(methodDecl.selector),
1281            new String JavaDoc(method.declaringClass.shortReadableName()),
1282            typesAsString(method.isVarargs(), method.parameters, true)},
1283        methodDecl.sourceStart,
1284        methodDecl.sourceEnd);
1285}
1286public void duplicateFieldInType(SourceTypeBinding type, FieldDeclaration fieldDecl) {
1287    this.handle(
1288        IProblem.DuplicateField,
1289        new String JavaDoc[] {new String JavaDoc(type.sourceName()), new String JavaDoc(fieldDecl.name)},
1290        new String JavaDoc[] {new String JavaDoc(type.shortReadableName()), new String JavaDoc(fieldDecl.name)},
1291        fieldDecl.sourceStart,
1292        fieldDecl.sourceEnd);
1293}
1294
1295public void duplicateImport(ImportReference importRef) {
1296    String JavaDoc[] arguments = new String JavaDoc[] {CharOperation.toString(importRef.tokens)};
1297    this.handle(
1298        IProblem.DuplicateImport,
1299        arguments,
1300        arguments,
1301        importRef.sourceStart,
1302        importRef.sourceEnd);
1303}
1304public void duplicateInheritedMethods(SourceTypeBinding type, MethodBinding inheritedMethod1, MethodBinding inheritedMethod2) {
1305    this.handle(
1306        IProblem.DuplicateParameterizedMethods,
1307        new String JavaDoc[] {
1308            new String JavaDoc(inheritedMethod1.selector),
1309            new String JavaDoc(inheritedMethod1.declaringClass.readableName()),
1310            typesAsString(inheritedMethod1.isVarargs(), inheritedMethod1.original().parameters, false),
1311            typesAsString(inheritedMethod2.isVarargs(), inheritedMethod2.original().parameters, false)},
1312        new String JavaDoc[] {
1313            new String JavaDoc(inheritedMethod1.selector),
1314            new String JavaDoc(inheritedMethod1.declaringClass.shortReadableName()),
1315            typesAsString(inheritedMethod1.isVarargs(), inheritedMethod1.original().parameters, true),
1316            typesAsString(inheritedMethod2.isVarargs(), inheritedMethod2.original().parameters, true)},
1317        type.sourceStart(),
1318        type.sourceEnd());
1319}
1320public void duplicateInitializationOfBlankFinalField(FieldBinding field, Reference reference) {
1321    String JavaDoc[] arguments = new String JavaDoc[]{ new String JavaDoc(field.readableName())};
1322    this.handle(
1323        IProblem.DuplicateBlankFinalFieldInitialization,
1324        arguments,
1325        arguments,
1326        nodeSourceStart(field, reference),
1327        nodeSourceEnd(field, reference));
1328}
1329public void duplicateInitializationOfFinalLocal(LocalVariableBinding local, ASTNode location) {
1330    String JavaDoc[] arguments = new String JavaDoc[] { new String JavaDoc(local.readableName())};
1331    this.handle(
1332        IProblem.DuplicateFinalLocalInitialization,
1333        arguments,
1334        arguments,
1335        nodeSourceStart(local, location),
1336        nodeSourceEnd(local, location));
1337}
1338
1339public void duplicateMethodInType(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
1340    MethodBinding method = methodDecl.binding;
1341    boolean duplicateErasure = false;
1342    if ((method.modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0) {
1343        // chech it occurs in parameters (the bit is set for return type | params | thrown exceptions
1344
for (int i = 0, length = method.parameters.length; i < length; i++) {
1345            if ((method.parameters[i].tagBits & TagBits.HasTypeVariable) != 0) {
1346                duplicateErasure = true;
1347                break;
1348            }
1349        }
1350    }
1351    if (duplicateErasure) {
1352        int length = method.parameters.length;
1353        TypeBinding[] erasures = new TypeBinding[length];
1354        for (int i = 0; i < length; i++) {
1355            erasures[i] = method.parameters[i].erasure();
1356        }
1357        this.handle(
1358            IProblem.DuplicateMethodErasure,
1359            new String JavaDoc[] {
1360                new String JavaDoc(methodDecl.selector),
1361                new String JavaDoc(method.declaringClass.readableName()),
1362                typesAsString(method.isVarargs(), method.parameters, false),
1363                typesAsString(method.isVarargs(), erasures, false) } ,
1364            new String JavaDoc[] {
1365                new String JavaDoc(methodDecl.selector),
1366                new String JavaDoc(method.declaringClass.shortReadableName()),
1367                typesAsString(method.isVarargs(), method.parameters, true),
1368                typesAsString(method.isVarargs(), erasures, true) },
1369            methodDecl.sourceStart,
1370            methodDecl.sourceEnd);
1371    } else {
1372        this.handle(
1373            IProblem.DuplicateMethod,
1374            new String JavaDoc[] {
1375                new String JavaDoc(methodDecl.selector),
1376                new String JavaDoc(method.declaringClass.readableName()),
1377                typesAsString(method.isVarargs(), method.parameters, false)},
1378            new String JavaDoc[] {
1379                new String JavaDoc(methodDecl.selector),
1380                new String JavaDoc(method.declaringClass.shortReadableName()),
1381                typesAsString(method.isVarargs(), method.parameters, true)},
1382            methodDecl.sourceStart,
1383            methodDecl.sourceEnd);
1384    }
1385}
1386public void duplicateModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
1387/* to highlight modifiers use:
1388    this.handle(
1389        new Problem(
1390            DuplicateModifierForField,
1391            new String[] {new String(fieldDecl.name)},
1392            fieldDecl.modifiers.sourceStart,
1393            fieldDecl.modifiers.sourceEnd));
1394*/

1395    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(fieldDecl.name)};
1396    this.handle(
1397        IProblem.DuplicateModifierForField,
1398        arguments,
1399        arguments,
1400        fieldDecl.sourceStart,
1401        fieldDecl.sourceEnd);
1402}
1403public void duplicateModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
1404    this.handle(
1405        IProblem.DuplicateModifierForMethod,
1406        new String JavaDoc[] {new String JavaDoc(type.sourceName()), new String JavaDoc(methodDecl.selector)},
1407        new String JavaDoc[] {new String JavaDoc(type.shortReadableName()), new String JavaDoc(methodDecl.selector)},
1408        methodDecl.sourceStart,
1409        methodDecl.sourceEnd);
1410}
1411public void duplicateModifierForType(SourceTypeBinding type) {
1412    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName())};
1413    this.handle(
1414        IProblem.DuplicateModifierForType,
1415        arguments,
1416        arguments,
1417        type.sourceStart(),
1418        type.sourceEnd());
1419}
1420public void duplicateModifierForVariable(LocalDeclaration localDecl, boolean complainForArgument) {
1421    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(localDecl.name)};
1422    this.handle(
1423        complainForArgument
1424            ? IProblem.DuplicateModifierForArgument
1425            : IProblem.DuplicateModifierForVariable,
1426        arguments,
1427        arguments,
1428        localDecl.sourceStart,
1429        localDecl.sourceEnd);
1430}
1431public void duplicateNestedType(TypeDeclaration typeDecl) {
1432    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(typeDecl.name)};
1433    this.handle(
1434        IProblem.DuplicateNestedType,
1435        arguments,
1436        arguments,
1437        typeDecl.sourceStart,
1438        typeDecl.sourceEnd);
1439}
1440public void duplicateSuperinterface(SourceTypeBinding type, TypeReference reference, ReferenceBinding superType) {
1441    this.handle(
1442        IProblem.DuplicateSuperInterface,
1443        new String JavaDoc[] {
1444            new String JavaDoc(superType.readableName()),
1445            new String JavaDoc(type.sourceName())},
1446        new String JavaDoc[] {
1447            new String JavaDoc(superType.shortReadableName()),
1448            new String JavaDoc(type.sourceName())},
1449        reference.sourceStart,
1450        reference.sourceEnd);
1451}
1452public void duplicateTargetInTargetAnnotation(TypeBinding annotationType, NameReference reference) {
1453    FieldBinding field = reference.fieldBinding();
1454    String JavaDoc name = new String JavaDoc(field.name);
1455    this.handle(
1456        IProblem.DuplicateTargetInTargetAnnotation,
1457        new String JavaDoc[] { name, new String JavaDoc(annotationType.readableName())},
1458        new String JavaDoc[] { name, new String JavaDoc(annotationType.shortReadableName())},
1459        nodeSourceStart(field, reference),
1460        nodeSourceEnd(field, reference));
1461}
1462public void duplicateTypeParameterInType(TypeParameter typeParameter) {
1463    this.handle(
1464        IProblem.DuplicateTypeVariable,
1465        new String JavaDoc[] { new String JavaDoc(typeParameter.name)},
1466        new String JavaDoc[] { new String JavaDoc(typeParameter.name)},
1467        typeParameter.sourceStart,
1468        typeParameter.sourceEnd);
1469}
1470public void duplicateTypes(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
1471    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(compUnitDecl.getFileName()), new String JavaDoc(typeDecl.name)};
1472    this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
1473
this.handle(
1474        IProblem.DuplicateTypes,
1475        arguments,
1476        arguments,
1477        typeDecl.sourceStart,
1478        typeDecl.sourceEnd,
1479        compUnitDecl.compilationResult);
1480}
1481public void emptyControlFlowStatement(int sourceStart, int sourceEnd) {
1482    this.handle(
1483        IProblem.EmptyControlFlowStatement,
1484        NoArgument,
1485        NoArgument,
1486        sourceStart,
1487        sourceEnd);
1488}
1489public void enumAbstractMethodMustBeImplemented(AbstractMethodDeclaration method) {
1490    MethodBinding abstractMethod = method.binding;
1491    this.handle(
1492        // Must implement the inherited abstract method %1
1493
// 8.4.3 - Every non-abstract subclass of an abstract type, A, must provide a concrete implementation of all of A's methods.
1494
IProblem.EnumAbstractMethodMustBeImplemented,
1495        new String JavaDoc[] {
1496                new String JavaDoc(abstractMethod.selector),
1497                typesAsString(abstractMethod.isVarargs(), abstractMethod.parameters, false),
1498                new String JavaDoc(abstractMethod.declaringClass.readableName()),
1499        },
1500        new String JavaDoc[] {
1501                new String JavaDoc(abstractMethod.selector),
1502                typesAsString(abstractMethod.isVarargs(), abstractMethod.parameters, true),
1503                new String JavaDoc(abstractMethod.declaringClass.shortReadableName()),
1504        },
1505        method.sourceStart(),
1506        method.sourceEnd());
1507}
1508public void enumConstantsCannotBeSurroundedByParenthesis(Expression expression) {
1509    this.handle(
1510        IProblem.EnumConstantsCannotBeSurroundedByParenthesis,
1511        NoArgument,
1512        NoArgument,
1513        expression.sourceStart,
1514        expression.sourceEnd);
1515}
1516public void enumStaticFieldUsedDuringInitialization(FieldBinding field, ASTNode location) {
1517    this.handle(
1518        IProblem.EnumStaticFieldInInInitializerContext,
1519        new String JavaDoc[] {new String JavaDoc(field.declaringClass.readableName()), new String JavaDoc(field.name)},
1520        new String JavaDoc[] {new String JavaDoc(field.declaringClass.shortReadableName()), new String JavaDoc(field.name)},
1521        nodeSourceStart(field, location),
1522        nodeSourceEnd(field, location));
1523}
1524public void enumSwitchCannotTargetField(Reference reference, FieldBinding field) {
1525    this.handle(
1526            IProblem.EnumSwitchCannotTargetField,
1527            new String JavaDoc[]{ String.valueOf(field.declaringClass.readableName()), String.valueOf(field.name) },
1528            new String JavaDoc[]{ String.valueOf(field.declaringClass.shortReadableName()), String.valueOf(field.name) },
1529            nodeSourceStart(field, reference),
1530            nodeSourceEnd(field, reference));
1531}
1532public void errorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params) {
1533    StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
1534    StringBuffer JavaDoc shortBuffer = new StringBuffer JavaDoc();
1535    for (int i = 0, length = params.length; i < length; i++) {
1536        if (i != 0){
1537            buffer.append(", "); //$NON-NLS-1$
1538
shortBuffer.append(", "); //$NON-NLS-1$
1539
}
1540        buffer.append(new String JavaDoc(params[i].readableName()));
1541        shortBuffer.append(new String JavaDoc(params[i].shortReadableName()));
1542    }
1543
1544    int id = recType.isArrayType() ? IProblem.NoMessageSendOnArrayType : IProblem.NoMessageSendOnBaseType;
1545    this.handle(
1546        id,
1547        new String JavaDoc[] {new String JavaDoc(recType.readableName()), new String JavaDoc(messageSend.selector), buffer.toString()},
1548        new String JavaDoc[] {new String JavaDoc(recType.shortReadableName()), new String JavaDoc(messageSend.selector), shortBuffer.toString()},
1549        messageSend.sourceStart,
1550        messageSend.sourceEnd);
1551}
1552public void errorThisSuperInStatic(ASTNode reference) {
1553    String JavaDoc[] arguments = new String JavaDoc[] {reference.isSuper() ? "super" : "this"}; //$NON-NLS-2$ //$NON-NLS-1$
1554
this.handle(
1555        IProblem.ThisInStaticContext,
1556        arguments,
1557        arguments,
1558        reference.sourceStart,
1559        reference.sourceEnd);
1560}
1561public void expressionShouldBeAVariable(Expression expression) {
1562    this.handle(
1563        IProblem.ExpressionShouldBeAVariable,
1564        NoArgument,
1565        NoArgument,
1566        expression.sourceStart,
1567        expression.sourceEnd);
1568}
1569public void fieldHiding(FieldDeclaration fieldDecl, Binding hiddenVariable) {
1570    FieldBinding field = fieldDecl.binding;
1571    if (CharOperation.equals(TypeConstants.SERIALVERSIONUID, field.name)
1572            && field.isStatic()
1573            && field.isFinal()
1574            && TypeBinding.LONG == field.type) {
1575                return; // do not report unused serialVersionUID field
1576
}
1577    if (CharOperation.equals(TypeConstants.SERIALPERSISTENTFIELDS, field.name)
1578            && field.isStatic()
1579            && field.isFinal()
1580            && field.type.dimensions() == 1
1581            && CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTSTREAMFIELD, field.type.leafComponentType().readableName())) {
1582                return; // do not report unused serialPersistentFields field
1583
}
1584    boolean isLocal = hiddenVariable instanceof LocalVariableBinding;
1585    int severity = computeSeverity(isLocal ? IProblem.FieldHidingLocalVariable : IProblem.FieldHidingField);
1586    if (severity == ProblemSeverities.Ignore) return;
1587    if (isLocal) {
1588        this.handle(
1589            IProblem.FieldHidingLocalVariable,
1590            new String JavaDoc[] {new String JavaDoc(field.declaringClass.readableName()), new String JavaDoc(field.name) },
1591            new String JavaDoc[] {new String JavaDoc(field.declaringClass.shortReadableName()), new String JavaDoc(field.name) },
1592            severity,
1593            nodeSourceStart(hiddenVariable, fieldDecl),
1594            nodeSourceEnd(hiddenVariable, fieldDecl));
1595    } else if (hiddenVariable instanceof FieldBinding) {
1596        FieldBinding hiddenField = (FieldBinding) hiddenVariable;
1597        this.handle(
1598            IProblem.FieldHidingField,
1599            new String JavaDoc[] {new String JavaDoc(field.declaringClass.readableName()), new String JavaDoc(field.name) , new String JavaDoc(hiddenField.declaringClass.readableName()) },
1600            new String JavaDoc[] {new String JavaDoc(field.declaringClass.shortReadableName()), new String JavaDoc(field.name) , new String JavaDoc(hiddenField.declaringClass.shortReadableName()) },
1601            severity,
1602            nodeSourceStart(hiddenField, fieldDecl),
1603            nodeSourceEnd(hiddenField, fieldDecl));
1604    }
1605}
1606public void fieldsOrThisBeforeConstructorInvocation(ThisReference reference) {
1607    this.handle(
1608        IProblem.ThisSuperDuringConstructorInvocation,
1609        NoArgument,
1610        NoArgument,
1611        reference.sourceStart,
1612        reference.sourceEnd);
1613}
1614public void finallyMustCompleteNormally(Block finallyBlock) {
1615    this.handle(
1616        IProblem.FinallyMustCompleteNormally,
1617        NoArgument,
1618        NoArgument,
1619        finallyBlock.sourceStart,
1620        finallyBlock.sourceEnd);
1621}
1622public void finalMethodCannotBeOverridden(MethodBinding currentMethod, MethodBinding inheritedMethod) {
1623    this.handle(
1624        // Cannot override the final method from %1
1625
// 8.4.3.3 - Final methods cannot be overridden or hidden.
1626
IProblem.FinalMethodCannotBeOverridden,
1627        new String JavaDoc[] {new String JavaDoc(inheritedMethod.declaringClass.readableName())},
1628        new String JavaDoc[] {new String JavaDoc(inheritedMethod.declaringClass.shortReadableName())},
1629        currentMethod.sourceStart(),
1630        currentMethod.sourceEnd());
1631}
1632public void finalVariableBound(TypeVariableBinding typeVariable, TypeReference typeRef) {
1633    int severity = computeSeverity(IProblem.FinalBoundForTypeVariable);
1634    if (severity == ProblemSeverities.Ignore) return;
1635    this.handle(
1636        IProblem.FinalBoundForTypeVariable,
1637        new String JavaDoc[] { new String JavaDoc(typeVariable.sourceName), new String JavaDoc(typeRef.resolvedType.readableName())},
1638        new String JavaDoc[] { new String JavaDoc(typeVariable.sourceName), new String JavaDoc(typeRef.resolvedType.shortReadableName())},
1639        severity,
1640        typeRef.sourceStart,
1641        typeRef.sourceEnd);
1642}
1643public void forbiddenReference(FieldBinding field, ASTNode location,
1644        String JavaDoc messageTemplate, int problemId) {
1645    this.handle(
1646        problemId,
1647        new String JavaDoc[] { new String JavaDoc(field.readableName()) }, // distinct from msg arg for quickfix purpose
1648
new String JavaDoc[] {
1649            MessageFormat.format(messageTemplate,
1650                new String JavaDoc[]{
1651                    new String JavaDoc(field.shortReadableName()),
1652                    new String JavaDoc(field.declaringClass.shortReadableName())})},
1653        nodeSourceStart(field, location),
1654        nodeSourceEnd(field, location));
1655}
1656public void forbiddenReference(MethodBinding method, ASTNode location,
1657        String JavaDoc messageTemplate, int problemId) {
1658    if (method.isConstructor())
1659        this.handle(
1660            problemId,
1661            new String JavaDoc[] { new String JavaDoc(method.readableName()) }, // distinct from msg arg for quickfix purpose
1662
new String JavaDoc[] {
1663                MessageFormat.format(messageTemplate,
1664                        new String JavaDoc[]{new String JavaDoc(method.shortReadableName())})},
1665            location.sourceStart,
1666            location.sourceEnd);
1667    else
1668        this.handle(
1669            problemId,
1670            new String JavaDoc[] { new String JavaDoc(method.readableName()) }, // distinct from msg arg for quickfix purpose
1671
new String JavaDoc[] {
1672                MessageFormat.format(messageTemplate,
1673                    new String JavaDoc[]{
1674                        new String JavaDoc(method.shortReadableName()),
1675                        new String JavaDoc(method.declaringClass.shortReadableName())})},
1676            location.sourceStart,
1677            location.sourceEnd);
1678}
1679public void forbiddenReference(TypeBinding type, ASTNode location, String JavaDoc messageTemplate, int problemId) {
1680    if (location == null) return;
1681    int severity = computeSeverity(problemId);
1682    if (severity == ProblemSeverities.Ignore) return;
1683    // this problem has a message template extracted from the access restriction rule
1684
this.handle(
1685        problemId,
1686        new String JavaDoc[] { new String JavaDoc(type.readableName()) }, // distinct from msg arg for quickfix purpose
1687
new String JavaDoc[] { MessageFormat.format(messageTemplate, new String JavaDoc[]{ new String JavaDoc(type.shortReadableName())})},
1688        severity,
1689        location.sourceStart,
1690        location.sourceEnd);
1691}
1692public void forwardReference(Reference reference, int indexInQualification, TypeBinding type) {
1693    this.handle(
1694        IProblem.ReferenceToForwardField,
1695        NoArgument,
1696        NoArgument,
1697        reference.sourceStart,
1698        reference.sourceEnd);
1699}
1700public void forwardTypeVariableReference(ASTNode location, TypeVariableBinding type) {
1701    this.handle(
1702        IProblem.ReferenceToForwardTypeVariable,
1703        new String JavaDoc[] {new String JavaDoc(type.readableName())},
1704        new String JavaDoc[] {new String JavaDoc(type.shortReadableName())},
1705        location.sourceStart,
1706        location.sourceEnd);
1707}
1708public void genericTypeCannotExtendThrowable(TypeDeclaration typeDecl) {
1709    ASTNode location = typeDecl.binding.isAnonymousType() ? typeDecl.allocation.type : typeDecl.superclass;
1710    this.handle(
1711        IProblem.GenericTypeCannotExtendThrowable,
1712        new String JavaDoc[]{ new String JavaDoc(typeDecl.binding.readableName()) },
1713        new String JavaDoc[]{ new String JavaDoc(typeDecl.binding.shortReadableName()) },
1714        location.sourceStart,
1715        location.sourceEnd);
1716}
1717// use this private API when the compilation unit result can be found through the
1718
// reference context. Otherwise, use the other API taking a problem and a compilation result
1719
// as arguments
1720
private void handle(
1721    int problemId,
1722    String JavaDoc[] problemArguments,
1723    String JavaDoc[] messageArguments,
1724    int problemStartPosition,
1725    int problemEndPosition){
1726
1727    this.handle(
1728            problemId,
1729            problemArguments,
1730            messageArguments,
1731            problemStartPosition,
1732            problemEndPosition,
1733            this.referenceContext,
1734            this.referenceContext == null ? null : this.referenceContext.compilationResult());
1735    this.referenceContext = null;
1736}
1737// use this private API when the compilation unit result cannot be found through the
1738
// reference context.
1739
private void handle(
1740    int problemId,
1741    String JavaDoc[] problemArguments,
1742    String JavaDoc[] messageArguments,
1743    int problemStartPosition,
1744    int problemEndPosition,
1745    CompilationResult unitResult){
1746
1747    this.handle(
1748            problemId,
1749            problemArguments,
1750            messageArguments,
1751            problemStartPosition,
1752            problemEndPosition,
1753            this.referenceContext,
1754            unitResult);
1755    this.referenceContext = null;
1756}
1757// use this private API when the compilation unit result can be found through the
1758
// reference context. Otherwise, use the other API taking a problem and a compilation result
1759
// as arguments
1760
private void handle(
1761    int problemId,
1762    String JavaDoc[] problemArguments,
1763    String JavaDoc[] messageArguments,
1764    int severity,
1765    int problemStartPosition,
1766    int problemEndPosition){
1767
1768    this.handle(
1769            problemId,
1770            problemArguments,
1771            messageArguments,
1772            severity,
1773            problemStartPosition,
1774            problemEndPosition,
1775            this.referenceContext,
1776            this.referenceContext == null ? null : this.referenceContext.compilationResult());
1777    this.referenceContext = null;
1778}
1779
1780public void hiddenCatchBlock(ReferenceBinding exceptionType, ASTNode location) {
1781    this.handle(
1782        IProblem.MaskedCatch,
1783        new String JavaDoc[] {
1784            new String JavaDoc(exceptionType.readableName()),
1785         },
1786        new String JavaDoc[] {
1787            new String JavaDoc(exceptionType.shortReadableName()),
1788         },
1789        location.sourceStart,
1790        location.sourceEnd);
1791}
1792
1793public void hierarchyCircularity(SourceTypeBinding sourceType, ReferenceBinding superType, TypeReference reference) {
1794    int start = 0;
1795    int end = 0;
1796
1797    if (reference == null) { // can only happen when java.lang.Object is busted
1798
start = sourceType.sourceStart();
1799        end = sourceType.sourceEnd();
1800    } else {
1801        start = reference.sourceStart;
1802        end = reference.sourceEnd;
1803    }
1804
1805    if (sourceType == superType)
1806        this.handle(
1807            IProblem.HierarchyCircularitySelfReference,
1808            new String JavaDoc[] {new String JavaDoc(sourceType.readableName()) },
1809            new String JavaDoc[] {new String JavaDoc(sourceType.shortReadableName()) },
1810            start,
1811            end);
1812    else
1813        this.handle(
1814            IProblem.HierarchyCircularity,
1815            new String JavaDoc[] {new String JavaDoc(sourceType.readableName()), new String JavaDoc(superType.readableName())},
1816            new String JavaDoc[] {new String JavaDoc(sourceType.shortReadableName()), new String JavaDoc(superType.shortReadableName())},
1817            start,
1818            end);
1819}
1820
1821public void hierarchyHasProblems(SourceTypeBinding type) {
1822    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName())};
1823    this.handle(
1824        IProblem.HierarchyHasProblems,
1825        arguments,
1826        arguments,
1827        type.sourceStart(),
1828        type.sourceEnd());
1829}
1830public void illegalAbstractModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
1831    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName()), new String JavaDoc(methodDecl.selector)};
1832    this.handle(
1833        IProblem.IllegalAbstractModifierCombinationForMethod,
1834        arguments,
1835        arguments,
1836        methodDecl.sourceStart,
1837        methodDecl.sourceEnd);
1838}
1839public void illegalAccessFromTypeVariable(TypeVariableBinding variable, ASTNode location) {
1840    String JavaDoc[] arguments = new String JavaDoc[] { new String JavaDoc(variable.sourceName) };
1841    this.handle(
1842        IProblem.IllegalAccessFromTypeVariable,
1843        arguments,
1844        arguments,
1845        location.sourceStart,
1846        location.sourceEnd);
1847}
1848public void illegalClassLiteralForTypeVariable(TypeVariableBinding variable, ASTNode location) {
1849    String JavaDoc[] arguments = new String JavaDoc[] { new String JavaDoc(variable.sourceName) };
1850    this.handle(
1851        IProblem.IllegalClassLiteralForTypeVariable,
1852        arguments,
1853        arguments,
1854        location.sourceStart,
1855        location.sourceEnd);
1856}
1857public void illegalExtendedDimensions(AnnotationMethodDeclaration annotationTypeMemberDeclaration) {
1858    this.handle(
1859        IProblem.IllegalExtendedDimensions,
1860        NoArgument,
1861        NoArgument,
1862        annotationTypeMemberDeclaration.sourceStart,
1863        annotationTypeMemberDeclaration.sourceEnd);
1864}
1865public void illegalExtendedDimensions(Argument argument) {
1866    this.handle(
1867        IProblem.IllegalExtendedDimensionsForVarArgs,
1868        NoArgument,
1869        NoArgument,
1870        argument.sourceStart,
1871        argument.sourceEnd);
1872}
1873public void illegalGenericArray(TypeBinding leafComponentType, ASTNode location) {
1874    this.handle(
1875        IProblem.IllegalGenericArray,
1876        new String JavaDoc[]{ new String JavaDoc(leafComponentType.readableName())},
1877        new String JavaDoc[]{ new String JavaDoc(leafComponentType.shortReadableName())},
1878        location.sourceStart,
1879        location.sourceEnd);
1880}
1881public void illegalInstanceOfGenericType(TypeBinding checkedType, ASTNode location) {
1882    if (checkedType.isTypeVariable()) {
1883        this.handle(
1884        IProblem.IllegalInstanceofTypeParameter,
1885            new String JavaDoc[] { new String JavaDoc(checkedType.readableName()), new String JavaDoc(checkedType.erasure().readableName())},
1886            new String JavaDoc[] { new String JavaDoc(checkedType.shortReadableName()), new String JavaDoc(checkedType.erasure().shortReadableName())},
1887            location.sourceStart,
1888            location.sourceEnd);
1889        return;
1890    }
1891    this.handle(
1892        IProblem.IllegalInstanceofParameterizedType,
1893        new String JavaDoc[] { new String JavaDoc(checkedType.readableName()), new String JavaDoc(checkedType.erasure().sourceName())},
1894        new String JavaDoc[] { new String JavaDoc(checkedType.shortReadableName()), new String JavaDoc(checkedType.erasure().sourceName())},
1895        location.sourceStart,
1896        location.sourceEnd);
1897}
1898public void illegalLocalTypeDeclaration(TypeDeclaration typeDeclaration) {
1899    if (isRecoveredName(typeDeclaration.name)) return;
1900    
1901    int problemID = 0;
1902    if ((typeDeclaration.modifiers & ClassFileConstants.AccEnum) != 0) {
1903        problemID = IProblem.CannotDefineEnumInLocalType;
1904    } else if ((typeDeclaration.modifiers & ClassFileConstants.AccAnnotation) != 0) {
1905        problemID = IProblem.CannotDefineAnnotationInLocalType;
1906    } else if ((typeDeclaration.modifiers & ClassFileConstants.AccInterface) != 0) {
1907        problemID = IProblem.CannotDefineInterfaceInLocalType;
1908    }
1909    if (problemID != 0) {
1910        String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(typeDeclaration.name)};
1911        this.handle(
1912            problemID,
1913            arguments,
1914            arguments,
1915            typeDeclaration.sourceStart,
1916            typeDeclaration.sourceEnd);
1917    }
1918}
1919public void illegalModifierCombinationFinalAbstractForClass(SourceTypeBinding type) {
1920    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName())};
1921    this.handle(
1922        IProblem.IllegalModifierCombinationFinalAbstractForClass,
1923        arguments,
1924        arguments,
1925        type.sourceStart(),
1926        type.sourceEnd());
1927}
1928public void illegalModifierCombinationFinalVolatileForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
1929    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(fieldDecl.name)};
1930
1931    this.handle(
1932        IProblem.IllegalModifierCombinationFinalVolatileForField,
1933        arguments,
1934        arguments,
1935        fieldDecl.sourceStart,
1936        fieldDecl.sourceEnd);
1937}
1938public void illegalModifierForAnnotationField(FieldDeclaration fieldDecl) {
1939    String JavaDoc name = new String JavaDoc(fieldDecl.name);
1940    this.handle(
1941        IProblem.IllegalModifierForAnnotationField,
1942        new String JavaDoc[] {
1943            new String JavaDoc(fieldDecl.binding.declaringClass.readableName()),
1944            name,
1945        },
1946        new String JavaDoc[] {
1947            new String JavaDoc(fieldDecl.binding.declaringClass.shortReadableName()),
1948            name,
1949        },
1950        fieldDecl.sourceStart,
1951        fieldDecl.sourceEnd);
1952}
1953public void illegalModifierForAnnotationMember(AbstractMethodDeclaration methodDecl) {
1954    this.handle(
1955        IProblem.IllegalModifierForAnnotationMethod,
1956        new String JavaDoc[] {
1957            new String JavaDoc(methodDecl.binding.declaringClass.readableName()),
1958            new String JavaDoc(methodDecl.selector),
1959        },
1960        new String JavaDoc[] {
1961            new String JavaDoc(methodDecl.binding.declaringClass.shortReadableName()),
1962            new String JavaDoc(methodDecl.selector),
1963        },
1964        methodDecl.sourceStart,
1965        methodDecl.sourceEnd);
1966}
1967public void illegalModifierForAnnotationMemberType(SourceTypeBinding type) {
1968    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName())};
1969    this.handle(
1970        IProblem.IllegalModifierForAnnotationMemberType,
1971        arguments,
1972        arguments,
1973        type.sourceStart(),
1974        type.sourceEnd());
1975}
1976public void illegalModifierForAnnotationType(SourceTypeBinding type) {
1977    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName())};
1978    this.handle(
1979        IProblem.IllegalModifierForAnnotationType,
1980        arguments,
1981        arguments,
1982        type.sourceStart(),
1983        type.sourceEnd());
1984}
1985public void illegalModifierForClass(SourceTypeBinding type) {
1986    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName())};
1987    this.handle(
1988        IProblem.IllegalModifierForClass,
1989        arguments,
1990        arguments,
1991        type.sourceStart(),
1992        type.sourceEnd());
1993}
1994public void illegalModifierForEnum(SourceTypeBinding type) {
1995    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName())};
1996    this.handle(
1997        IProblem.IllegalModifierForEnum,
1998        arguments,
1999        arguments,
2000        type.sourceStart(),
2001        type.sourceEnd());
2002}
2003public void illegalModifierForEnumConstant(ReferenceBinding type, FieldDeclaration fieldDecl) {
2004    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(fieldDecl.name)};
2005    this.handle(
2006        IProblem.IllegalModifierForEnumConstant,
2007        arguments,
2008        arguments,
2009        fieldDecl.sourceStart,
2010        fieldDecl.sourceEnd);
2011}
2012
2013public void illegalModifierForEnumConstructor(AbstractMethodDeclaration constructor) {
2014    this.handle(
2015        IProblem.IllegalModifierForEnumConstructor,
2016        NoArgument,
2017        NoArgument,
2018        constructor.sourceStart,
2019        constructor.sourceEnd);
2020}
2021public void illegalModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
2022    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(fieldDecl.name)};
2023    this.handle(
2024        IProblem.IllegalModifierForField,
2025        arguments,
2026        arguments,
2027        fieldDecl.sourceStart,
2028        fieldDecl.sourceEnd);
2029}
2030public void illegalModifierForInterface(SourceTypeBinding type) {
2031    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName())};
2032    this.handle(
2033        IProblem.IllegalModifierForInterface,
2034        arguments,
2035        arguments,
2036        type.sourceStart(),
2037        type.sourceEnd());
2038}
2039
2040public void illegalModifierForInterfaceField(FieldDeclaration fieldDecl) {
2041    String JavaDoc name = new String JavaDoc(fieldDecl.name);
2042    this.handle(
2043        IProblem.IllegalModifierForInterfaceField,
2044        new String JavaDoc[] {
2045            new String JavaDoc(fieldDecl.binding.declaringClass.readableName()),
2046            name,
2047        },
2048        new String JavaDoc[] {
2049            new String JavaDoc(fieldDecl.binding.declaringClass.shortReadableName()),
2050            name,
2051        },
2052        fieldDecl.sourceStart,
2053        fieldDecl.sourceEnd);
2054}
2055public void illegalModifierForInterfaceMethod(AbstractMethodDeclaration methodDecl) {
2056    this.handle(
2057        IProblem.IllegalModifierForInterfaceMethod,
2058        new String JavaDoc[] {
2059            new String JavaDoc(methodDecl.binding.declaringClass.readableName()),
2060            new String JavaDoc(methodDecl.selector),
2061            typesAsString(methodDecl.binding.isVarargs(), methodDecl.binding.parameters, false),
2062        },
2063        new String JavaDoc[] {
2064            new String JavaDoc(methodDecl.binding.declaringClass.shortReadableName()),
2065            new String JavaDoc(methodDecl.selector),
2066            typesAsString(methodDecl.binding.isVarargs(), methodDecl.binding.parameters, true),
2067        },
2068        methodDecl.sourceStart,
2069        methodDecl.sourceEnd);
2070}
2071public void illegalModifierForLocalClass(SourceTypeBinding type) {
2072    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName())};
2073    this.handle(
2074        IProblem.IllegalModifierForLocalClass,
2075        arguments,
2076        arguments,
2077        type.sourceStart(),
2078        type.sourceEnd());
2079}
2080public void illegalModifierForLocalEnum(SourceTypeBinding type) {
2081    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName())};
2082    this.handle(
2083        IProblem.IllegalModifierForLocalEnum,
2084        arguments,
2085        arguments,
2086        type.sourceStart(),
2087        type.sourceEnd());
2088}
2089public void illegalModifierForMemberClass(SourceTypeBinding type) {
2090    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName())};
2091    this.handle(
2092        IProblem.IllegalModifierForMemberClass,
2093        arguments,
2094        arguments,
2095        type.sourceStart(),
2096        type.sourceEnd());
2097}
2098public void illegalModifierForMemberEnum(SourceTypeBinding type) {
2099    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName())};
2100    this.handle(
2101        IProblem.IllegalModifierForMemberEnum,
2102        arguments,
2103        arguments,
2104        type.sourceStart(),
2105        type.sourceEnd());
2106}
2107public void illegalModifierForMemberInterface(SourceTypeBinding type) {
2108    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName())};
2109    this.handle(
2110        IProblem.IllegalModifierForMemberInterface,
2111        arguments,
2112        arguments,
2113        type.sourceStart(),
2114        type.sourceEnd());
2115}
2116public void illegalModifierForMethod(AbstractMethodDeclaration methodDecl) {
2117    this.handle(
2118        IProblem.IllegalModifierForMethod,
2119        new String JavaDoc[] {
2120            new String JavaDoc(methodDecl.selector),
2121            typesAsString(methodDecl.binding.isVarargs(), methodDecl.binding.parameters, false),
2122            new String JavaDoc(methodDecl.binding.declaringClass.readableName()),
2123        },
2124        new String JavaDoc[] {
2125            new String JavaDoc(methodDecl.selector),
2126            typesAsString(methodDecl.binding.isVarargs(), methodDecl.binding.parameters, true),
2127            new String JavaDoc(methodDecl.binding.declaringClass.shortReadableName()),
2128        },
2129        methodDecl.sourceStart,
2130        methodDecl.sourceEnd);
2131}
2132public void illegalModifierForVariable(LocalDeclaration localDecl, boolean complainAsArgument) {
2133    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(localDecl.name)};
2134    this.handle(
2135        complainAsArgument
2136            ? IProblem.IllegalModifierForArgument
2137            : IProblem.IllegalModifierForVariable,
2138        arguments,
2139        arguments,
2140        localDecl.sourceStart,
2141        localDecl.sourceEnd);
2142}
2143public void illegalPrimitiveOrArrayTypeForEnclosingInstance(TypeBinding enclosingType, ASTNode location) {
2144    this.handle(
2145        IProblem.IllegalPrimitiveOrArrayTypeForEnclosingInstance,
2146        new String JavaDoc[] {new String JavaDoc(enclosingType.readableName())},
2147        new String JavaDoc[] {new String JavaDoc(enclosingType.shortReadableName())},
2148        location.sourceStart,
2149        location.sourceEnd);
2150}
2151public void illegalQualifiedParameterizedTypeAllocation(TypeReference qualifiedTypeReference, TypeBinding allocatedType) {
2152    this.handle(
2153        IProblem.IllegalQualifiedParameterizedTypeAllocation,
2154        new String JavaDoc[] { new String JavaDoc(allocatedType.readableName()), new String JavaDoc(allocatedType.enclosingType().readableName()), },
2155        new String JavaDoc[] { new String JavaDoc(allocatedType.shortReadableName()), new String JavaDoc(allocatedType.enclosingType().shortReadableName()), },
2156        qualifiedTypeReference.sourceStart,
2157        qualifiedTypeReference.sourceEnd);
2158}
2159public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
2160    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName())};
2161    this.handle(
2162        IProblem.IllegalStaticModifierForMemberType,
2163        arguments,
2164        arguments,
2165        type.sourceStart(),
2166        type.sourceEnd());
2167}
2168public void illegalUsageOfQualifiedTypeReference(QualifiedTypeReference qualifiedTypeReference) {
2169    StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
2170    char[][] tokens = qualifiedTypeReference.tokens;
2171    for (int i = 0; i < tokens.length; i++) {
2172        if (i > 0) buffer.append('.');
2173        buffer.append(tokens[i]);
2174    }
2175    String JavaDoc[] arguments = new String JavaDoc[] { String.valueOf(buffer)};
2176    this.handle(
2177        IProblem.IllegalUsageOfQualifiedTypeReference,
2178        arguments,
2179        arguments,
2180        qualifiedTypeReference.sourceStart,
2181        qualifiedTypeReference.sourceEnd);
2182}
2183public void illegalVararg(Argument argType, AbstractMethodDeclaration methodDecl) {
2184    String JavaDoc[] arguments = new String JavaDoc[] {CharOperation.toString(argType.type.getTypeName()), new String JavaDoc(methodDecl.selector)};
2185    this.handle(
2186        IProblem.IllegalVararg,
2187        arguments,
2188        arguments,
2189        argType.sourceStart,
2190        argType.sourceEnd);
2191}
2192public void illegalVisibilityModifierCombinationForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
2193    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(fieldDecl.name)};
2194    this.handle(
2195        IProblem.IllegalVisibilityModifierCombinationForField,
2196        arguments,
2197        arguments,
2198        fieldDecl.sourceStart,
2199        fieldDecl.sourceEnd);
2200}
2201public void illegalVisibilityModifierCombinationForMemberType(SourceTypeBinding type) {
2202    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName())};
2203    this.handle(
2204        IProblem.IllegalVisibilityModifierCombinationForMemberType,
2205        arguments,
2206        arguments,
2207        type.sourceStart(),
2208        type.sourceEnd());
2209}
2210public void illegalVisibilityModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
2211    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName()), new String JavaDoc(methodDecl.selector)};
2212    this.handle(
2213        IProblem.IllegalVisibilityModifierCombinationForMethod,
2214        arguments,
2215        arguments,
2216        methodDecl.sourceStart,
2217        methodDecl.sourceEnd);
2218}
2219public void illegalVisibilityModifierForInterfaceMemberType(SourceTypeBinding type) {
2220    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName())};
2221    this.handle(
2222        IProblem.IllegalVisibilityModifierForInterfaceMemberType,
2223        arguments,
2224        arguments,
2225        type.sourceStart(),
2226        type.sourceEnd());
2227}
2228public void illegalVoidExpression(ASTNode location) {
2229    this.handle(
2230        IProblem.InvalidVoidExpression,
2231        NoArgument,
2232        NoArgument,
2233        location.sourceStart,
2234        location.sourceEnd);
2235}
2236public void importProblem(ImportReference importRef, Binding expectedImport) {
2237    if (expectedImport instanceof FieldBinding) {
2238        int id = IProblem.UndefinedField;
2239        FieldBinding field = (FieldBinding) expectedImport;
2240        String JavaDoc[] readableArguments = null;
2241        String JavaDoc[] shortArguments = null;
2242        switch (expectedImport.problemId()) {
2243            case ProblemReasons.NotVisible :
2244                id = IProblem.NotVisibleField;
2245                readableArguments = new String JavaDoc[] {CharOperation.toString(importRef.tokens), new String JavaDoc(field.declaringClass.readableName())};
2246                shortArguments = new String JavaDoc[] {CharOperation.toString(importRef.tokens), new String JavaDoc(field.declaringClass.shortReadableName())};
2247                break;
2248            case ProblemReasons.Ambiguous :
2249                id = IProblem.AmbiguousField;
2250                readableArguments = new String JavaDoc[] {new String JavaDoc(field.readableName())};
2251                shortArguments = new String JavaDoc[] {new String JavaDoc(field.readableName())};
2252                break;
2253            case ProblemReasons.ReceiverTypeNotVisible :
2254                id = IProblem.NotVisibleType;
2255                readableArguments = new String JavaDoc[] {new String JavaDoc(field.declaringClass.leafComponentType().readableName())};
2256                shortArguments = new String JavaDoc[] {new String JavaDoc(field.declaringClass.leafComponentType().shortReadableName())};
2257                break;
2258        }
2259        this.handle(
2260            id,
2261            readableArguments,
2262            shortArguments,
2263            nodeSourceStart(field, importRef),
2264            nodeSourceEnd(field, importRef));
2265        return;
2266    }
2267
2268    if (expectedImport.problemId() == ProblemReasons.NotFound) {
2269        char[][] tokens = expectedImport instanceof ProblemReferenceBinding
2270            ? ((ProblemReferenceBinding) expectedImport).compoundName
2271            : importRef.tokens;
2272        String JavaDoc[] arguments = new String JavaDoc[]{CharOperation.toString(tokens)};
2273        this.handle(
2274                IProblem.ImportNotFound,
2275                arguments,
2276                arguments,
2277                importRef.sourceStart,
2278                (int) importRef.sourcePositions[tokens.length - 1]);
2279        return;
2280    }
2281    if (expectedImport.problemId() == ProblemReasons.InvalidTypeForStaticImport) {
2282        char[][] tokens = importRef.tokens;
2283        String JavaDoc[] arguments = new String JavaDoc[]{CharOperation.toString(tokens)};
2284        this.handle(
2285                IProblem.InvalidTypeForStaticImport,
2286                arguments,
2287                arguments,
2288                importRef.sourceStart,
2289                (int) importRef.sourcePositions[tokens.length - 1]);
2290        return;
2291    }
2292    invalidType(importRef, (TypeBinding)expectedImport);
2293}
2294public void incompatibleExceptionInThrowsClause(SourceTypeBinding type, MethodBinding currentMethod, MethodBinding inheritedMethod, ReferenceBinding exceptionType) {
2295    if (type == currentMethod.declaringClass) {
2296        int id;
2297        if (currentMethod.declaringClass.isInterface()
2298                && !inheritedMethod.isPublic()){ // interface inheriting Object protected method
2299
id = IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod;
2300        } else {
2301            id = IProblem.IncompatibleExceptionInThrowsClause;
2302        }
2303        this.handle(
2304            // Exception %1 is not compatible with throws clause in %2
2305
// 9.4.4 - The type of exception in the throws clause is incompatible.
2306
id,
2307            new String JavaDoc[] {
2308                new String JavaDoc(exceptionType.sourceName()),
2309                new String JavaDoc(
2310                    CharOperation.concat(
2311                        inheritedMethod.declaringClass.readableName(),
2312                        inheritedMethod.readableName(),
2313                        '.'))},
2314            new String JavaDoc[] {
2315                new String JavaDoc(exceptionType.sourceName()),
2316                new String JavaDoc(
2317                    CharOperation.concat(
2318                        inheritedMethod.declaringClass.shortReadableName(),
2319                        inheritedMethod.shortReadableName(),
2320                        '.'))},
2321            currentMethod.sourceStart(),
2322            currentMethod.sourceEnd());
2323    } else
2324        this.handle(
2325            // Exception %1 in throws clause of %2 is not compatible with %3
2326
// 9.4.4 - The type of exception in the throws clause is incompatible.
2327
IProblem.IncompatibleExceptionInInheritedMethodThrowsClause,
2328            new String JavaDoc[] {
2329                new String JavaDoc(exceptionType.sourceName()),
2330                new String JavaDoc(
2331                    CharOperation.concat(
2332                        currentMethod.declaringClass.sourceName(),
2333                        currentMethod.readableName(),
2334                        '.')),
2335                new String JavaDoc(
2336                    CharOperation.concat(
2337                        inheritedMethod.declaringClass.readableName(),
2338                        inheritedMethod.readableName(),
2339                        '.'))},
2340            new String JavaDoc[] {
2341                new String JavaDoc(exceptionType.sourceName()),
2342                new String JavaDoc(
2343                    CharOperation.concat(
2344                        currentMethod.declaringClass.sourceName(),
2345                        currentMethod.shortReadableName(),
2346                        '.')),
2347                new String JavaDoc(
2348                    CharOperation.concat(
2349                        inheritedMethod.declaringClass.shortReadableName(),
2350                        inheritedMethod.shortReadableName(),
2351                        '.'))},
2352            type.sourceStart(),
2353            type.sourceEnd());
2354}
2355public void incompatibleReturnType(MethodBinding currentMethod, MethodBinding inheritedMethod) {
2356    StringBuffer JavaDoc methodSignature = new StringBuffer JavaDoc();
2357    methodSignature
2358        .append(inheritedMethod.declaringClass.readableName())
2359        .append('.')
2360        .append(inheritedMethod.readableName());
2361
2362    StringBuffer JavaDoc shortSignature = new StringBuffer JavaDoc();
2363    shortSignature
2364        .append(inheritedMethod.declaringClass.shortReadableName())
2365        .append('.')
2366        .append(inheritedMethod.shortReadableName());
2367
2368    int id;
2369    final ReferenceBinding declaringClass = currentMethod.declaringClass;
2370    if (declaringClass.isInterface()
2371            && !inheritedMethod.isPublic()){ // interface inheriting Object protected method
2372
id = IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod;
2373    } else {
2374        id = IProblem.IncompatibleReturnType;
2375    }
2376    AbstractMethodDeclaration method = currentMethod.sourceMethod();
2377    int sourceStart = 0;
2378    int sourceEnd = 0;
2379    if (method == null) {
2380        if (declaringClass instanceof SourceTypeBinding) {
2381            SourceTypeBinding sourceTypeBinding = (SourceTypeBinding) declaringClass;
2382            sourceStart = sourceTypeBinding.sourceStart();
2383            sourceEnd = sourceTypeBinding.sourceEnd();
2384        }
2385    } else if (method.isConstructor()){
2386        sourceStart = method.sourceStart;
2387        sourceEnd = method.sourceEnd;
2388    } else {
2389        TypeReference returnType = ((MethodDeclaration) method).returnType;
2390        sourceStart = returnType.sourceStart;
2391        if (returnType instanceof ParameterizedSingleTypeReference) {
2392            ParameterizedSingleTypeReference typeReference = (ParameterizedSingleTypeReference) returnType;
2393            TypeReference[] typeArguments = typeReference.typeArguments;
2394            if (typeArguments[typeArguments.length - 1].sourceEnd > typeReference.sourceEnd) {
2395                sourceEnd = retrieveClosingAngleBracketPosition(typeReference.sourceEnd);
2396            } else {
2397                sourceEnd = returnType.sourceEnd;
2398            }
2399        } else if (returnType instanceof ParameterizedQualifiedTypeReference) {
2400            ParameterizedQualifiedTypeReference typeReference = (ParameterizedQualifiedTypeReference) returnType;
2401            sourceEnd = retrieveClosingAngleBracketPosition(typeReference.sourceEnd);
2402        } else {
2403            sourceEnd = returnType.sourceEnd;
2404        }
2405    }
2406    this.handle(
2407        id,
2408        new String JavaDoc[] {methodSignature.toString()},
2409        new String JavaDoc[] {shortSignature.toString()},
2410        sourceStart,
2411        sourceEnd);
2412}
2413public void incorrectArityForParameterizedType(ASTNode location, TypeBinding type, TypeBinding[] argumentTypes) {
2414    if (location == null) {
2415        this.handle(
2416            IProblem.IncorrectArityForParameterizedType,
2417            new String JavaDoc[] {new String JavaDoc(type.readableName()), typesAsString(false, argumentTypes, false)},
2418            new String JavaDoc[] {new String JavaDoc(type.shortReadableName()), typesAsString(false, argumentTypes, true)},
2419            ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
2420            0,
2421            0);
2422        return; // not reached since aborted above
2423
}
2424    this.handle(
2425        IProblem.IncorrectArityForParameterizedType,
2426        new String JavaDoc[] {new String JavaDoc(type.readableName()), typesAsString(false, argumentTypes, false)},
2427        new String JavaDoc[] {new String JavaDoc(type.shortReadableName()), typesAsString(false, argumentTypes, true)},
2428        location.sourceStart,
2429        location.sourceEnd);
2430}
2431public void incorrectLocationForNonEmptyDimension(ArrayAllocationExpression expression, int index) {
2432    this.handle(
2433        IProblem.IllegalDimension,
2434        NoArgument,
2435        NoArgument,
2436        expression.dimensions[index].sourceStart,
2437        expression.dimensions[index].sourceEnd);
2438}
2439public void incorrectSwitchType(Expression expression, TypeBinding testType) {
2440    this.handle(
2441        IProblem.IncorrectSwitchType,
2442        new String JavaDoc[] {new String JavaDoc(testType.readableName())},
2443        new String JavaDoc[] {new String JavaDoc(testType.shortReadableName())},
2444        expression.sourceStart,
2445        expression.sourceEnd);
2446}
2447public void indirectAccessToStaticField(ASTNode location, FieldBinding field){
2448    int severity = computeSeverity(IProblem.IndirectAccessToStaticField);
2449    if (severity == ProblemSeverities.Ignore) return;
2450    this.handle(
2451        IProblem.IndirectAccessToStaticField,
2452        new String JavaDoc[] {new String JavaDoc(field.declaringClass.readableName()), new String JavaDoc(field.name)},
2453        new String JavaDoc[] {new String JavaDoc(field.declaringClass.shortReadableName()), new String JavaDoc(field.name)},
2454        severity,
2455        nodeSourceStart(field, location),
2456        nodeSourceEnd(field, location));
2457}
2458public void indirectAccessToStaticMethod(ASTNode location, MethodBinding method) {
2459    int severity = computeSeverity(IProblem.IndirectAccessToStaticMethod);
2460    if (severity == ProblemSeverities.Ignore) return;
2461    this.handle(
2462        IProblem.IndirectAccessToStaticMethod,
2463        new String JavaDoc[] {new String JavaDoc(method.declaringClass.readableName()), new String JavaDoc(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
2464        new String JavaDoc[] {new String JavaDoc(method.declaringClass.shortReadableName()), new String JavaDoc(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
2465        severity,
2466        location.sourceStart,
2467        location.sourceEnd);
2468}
2469public void inheritedMethodReducesVisibility(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
2470    StringBuffer JavaDoc concreteSignature = new StringBuffer JavaDoc();
2471    concreteSignature
2472        .append(concreteMethod.declaringClass.readableName())
2473        .append('.')
2474        .append(concreteMethod.readableName());
2475    StringBuffer JavaDoc shortSignature = new StringBuffer JavaDoc();
2476    shortSignature
2477        .append(concreteMethod.declaringClass.shortReadableName())
2478        .append('.')
2479        .append(concreteMethod.shortReadableName());
2480    this.handle(
2481        // The inherited method %1 cannot hide the public abstract method in %2
2482
IProblem.InheritedMethodReducesVisibility,
2483        new String JavaDoc[] {
2484            concreteSignature.toString(),
2485            new String JavaDoc(abstractMethods[0].declaringClass.readableName())},
2486        new String JavaDoc[] {
2487            new String JavaDoc(shortSignature.toString()),
2488            new String JavaDoc(abstractMethods[0].declaringClass.shortReadableName())},
2489        type.sourceStart(),
2490        type.sourceEnd());
2491}
2492public void inheritedMethodsHaveIncompatibleReturnTypes(ASTNode location, MethodBinding[] inheritedMethods, int length) {
2493    StringBuffer JavaDoc methodSignatures = new StringBuffer JavaDoc();
2494    StringBuffer JavaDoc shortSignatures = new StringBuffer JavaDoc();
2495    for (int i = length; --i >= 0;) {
2496        methodSignatures
2497            .append(inheritedMethods[i].declaringClass.readableName())
2498            .append('.')
2499            .append(inheritedMethods[i].readableName());
2500        shortSignatures
2501            .append(inheritedMethods[i].declaringClass.shortReadableName())
2502            .append('.')
2503            .append(inheritedMethods[i].shortReadableName());
2504        if (i != 0){
2505            methodSignatures.append(", "); //$NON-NLS-1$
2506
shortSignatures.append(", "); //$NON-NLS-1$
2507
}
2508    }
2509
2510    this.handle(
2511        // Return type is incompatible with %1
2512
// 9.4.2 - The return type from the method is incompatible with the declaration.
2513
IProblem.IncompatibleReturnType,
2514        new String JavaDoc[] {methodSignatures.toString()},
2515        new String JavaDoc[] {shortSignatures.toString()},
2516        location.sourceStart,
2517        location.sourceEnd);
2518}
2519public void inheritedMethodsHaveIncompatibleReturnTypes(SourceTypeBinding type, MethodBinding[] inheritedMethods, int length) {
2520    StringBuffer JavaDoc methodSignatures = new StringBuffer JavaDoc();
2521    StringBuffer JavaDoc shortSignatures = new StringBuffer JavaDoc();
2522    for (int i = length; --i >= 0;) {
2523        methodSignatures
2524            .append(inheritedMethods[i].declaringClass.readableName())
2525            .append('.')
2526            .append(inheritedMethods[i].readableName());
2527        shortSignatures
2528            .append(inheritedMethods[i].declaringClass.shortReadableName())
2529            .append('.')
2530            .append(inheritedMethods[i].shortReadableName());
2531        if (i != 0){
2532            methodSignatures.append(", "); //$NON-NLS-1$
2533
shortSignatures.append(", "); //$NON-NLS-1$
2534
}
2535    }
2536
2537    this.handle(
2538        // Return type is incompatible with %1
2539
// 9.4.2 - The return type from the method is incompatible with the declaration.
2540
IProblem.IncompatibleReturnType,
2541        new String JavaDoc[] {methodSignatures.toString()},
2542        new String JavaDoc[] {shortSignatures.toString()},
2543        type.sourceStart(),
2544        type.sourceEnd());
2545}
2546public void inheritedMethodsHaveNameClash(SourceTypeBinding type, MethodBinding oneMethod, MethodBinding twoMethod) {
2547    this.handle(
2548        IProblem.MethodNameClash,
2549        new String JavaDoc[] {
2550            new String JavaDoc(oneMethod.selector),
2551            typesAsString(oneMethod.original().isVarargs(), oneMethod.original().parameters, false),
2552            new String JavaDoc(oneMethod.declaringClass.readableName()),
2553            typesAsString(twoMethod.original().isVarargs(), twoMethod.original().parameters, false),
2554            new String JavaDoc(twoMethod.declaringClass.readableName()),
2555         },
2556        new String JavaDoc[] {
2557            new String JavaDoc(oneMethod.selector),
2558            typesAsString(oneMethod.original().isVarargs(), oneMethod.original().parameters, true),
2559            new String JavaDoc(oneMethod.declaringClass.shortReadableName()),
2560            typesAsString(twoMethod.original().isVarargs(), twoMethod.original().parameters, true),
2561            new String JavaDoc(twoMethod.declaringClass.shortReadableName()),
2562         },
2563         type.sourceStart(),
2564         type.sourceEnd());
2565}
2566public void initializerMustCompleteNormally(FieldDeclaration fieldDecl) {
2567    this.handle(
2568        IProblem.InitializerMustCompleteNormally,
2569        NoArgument,
2570        NoArgument,
2571        fieldDecl.sourceStart,
2572        fieldDecl.sourceEnd);
2573}
2574public void innerTypesCannotDeclareStaticInitializers(ReferenceBinding innerType, Initializer initializer) {
2575    this.handle(
2576        IProblem.CannotDefineStaticInitializerInLocalType,
2577        new String JavaDoc[] {new String JavaDoc(innerType.readableName())},
2578        new String JavaDoc[] {new String JavaDoc(innerType.shortReadableName())},
2579        initializer.sourceStart,
2580        initializer.sourceStart);
2581}
2582public void interfaceCannotHaveConstructors(ConstructorDeclaration constructor) {
2583    this.handle(
2584        IProblem.InterfaceCannotHaveConstructors,
2585        NoArgument,
2586        NoArgument,
2587        constructor.sourceStart,
2588        constructor.sourceEnd,
2589        constructor,
2590        constructor.compilationResult());
2591}
2592public void interfaceCannotHaveInitializers(SourceTypeBinding type, FieldDeclaration fieldDecl) {
2593    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName())};
2594
2595    this.handle(
2596        IProblem.InterfaceCannotHaveInitializers,
2597        arguments,
2598        arguments,
2599        fieldDecl.sourceStart,
2600        fieldDecl.sourceEnd);
2601}
2602public void invalidAnnotationMemberType(MethodDeclaration methodDecl) {
2603    this.handle(
2604        IProblem.InvalidAnnotationMemberType,
2605        new String JavaDoc[] {
2606            new String JavaDoc(methodDecl.binding.returnType.readableName()),
2607            new String JavaDoc(methodDecl.selector),
2608            new String JavaDoc(methodDecl.binding.declaringClass.readableName()),
2609        },
2610        new String JavaDoc[] {
2611            new String JavaDoc(methodDecl.binding.returnType.shortReadableName()),
2612            new String JavaDoc(methodDecl.selector),
2613            new String JavaDoc(methodDecl.binding.declaringClass.shortReadableName()),
2614        },
2615        methodDecl.returnType.sourceStart,
2616        methodDecl.returnType.sourceEnd);
2617    
2618}
2619public void invalidBreak(ASTNode location) {
2620    this.handle(
2621        IProblem.InvalidBreak,
2622        NoArgument,
2623        NoArgument,
2624        location.sourceStart,
2625        location.sourceEnd);
2626}
2627public void invalidConstructor(Statement statement, MethodBinding targetConstructor) {
2628    boolean insideDefaultConstructor =
2629        (this.referenceContext instanceof ConstructorDeclaration)
2630            && ((ConstructorDeclaration)this.referenceContext).isDefaultConstructor();
2631    boolean insideImplicitConstructorCall =
2632        (statement instanceof ExplicitConstructorCall)
2633            && (((ExplicitConstructorCall) statement).accessMode == ExplicitConstructorCall.ImplicitSuper);
2634
2635    int sourceStart = statement.sourceStart;
2636    int sourceEnd = statement.sourceEnd;
2637    if (statement instanceof AllocationExpression) {
2638        AllocationExpression allocation = (AllocationExpression)statement;
2639        if (allocation.enumConstant != null) {
2640            sourceStart = allocation.enumConstant.sourceStart;
2641            sourceEnd = allocation.enumConstant.sourceEnd;
2642        }
2643    }
2644    
2645    int id = IProblem.UndefinedConstructor; //default...
2646
MethodBinding shownConstructor = targetConstructor;
2647    switch (targetConstructor.problemId()) {
2648        case ProblemReasons.NotFound :
2649            if (insideDefaultConstructor){
2650                id = IProblem.UndefinedConstructorInDefaultConstructor;
2651            } else if (insideImplicitConstructorCall){
2652                id = IProblem.UndefinedConstructorInImplicitConstructorCall;
2653            } else {
2654                id = IProblem.UndefinedConstructor;
2655            }
2656            break;
2657        case ProblemReasons.NotVisible :
2658            if (insideDefaultConstructor){
2659                id = IProblem.NotVisibleConstructorInDefaultConstructor;
2660            } else if (insideImplicitConstructorCall){
2661                id = IProblem.NotVisibleConstructorInImplicitConstructorCall;
2662            } else {
2663                id = IProblem.NotVisibleConstructor;
2664            }
2665            ProblemMethodBinding problemConstructor = (ProblemMethodBinding) targetConstructor;
2666            if (problemConstructor.closestMatch != null) {
2667                shownConstructor = problemConstructor.closestMatch.original();
2668            }
2669            break;
2670        case ProblemReasons.Ambiguous :
2671            if (insideDefaultConstructor){
2672                id = IProblem.AmbiguousConstructorInDefaultConstructor;
2673            } else if (insideImplicitConstructorCall){
2674                id = IProblem.AmbiguousConstructorInImplicitConstructorCall;
2675            } else {
2676                id = IProblem.AmbiguousConstructor;
2677            }
2678            break;
2679        case ProblemReasons.ParameterBoundMismatch :
2680            problemConstructor = (ProblemMethodBinding) targetConstructor;
2681            ParameterizedGenericMethodBinding substitutedConstructor = (ParameterizedGenericMethodBinding) problemConstructor.closestMatch;
2682            shownConstructor = substitutedConstructor.original();
2683            int augmentedLength = problemConstructor.parameters.length;
2684            TypeBinding inferredTypeArgument = problemConstructor.parameters[augmentedLength-2];
2685            TypeVariableBinding typeParameter = (TypeVariableBinding) problemConstructor.parameters[augmentedLength-1];
2686            TypeBinding[] invocationArguments = new TypeBinding[augmentedLength-2]; // remove extra info from the end
2687
System.arraycopy(problemConstructor.parameters, 0, invocationArguments, 0, augmentedLength-2);
2688            this.handle(
2689                IProblem.GenericConstructorTypeArgumentMismatch,
2690                new String JavaDoc[] {
2691                        new String JavaDoc(shownConstructor.declaringClass.sourceName()),
2692                        typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false),
2693                        new String JavaDoc(shownConstructor.declaringClass.readableName()),
2694                        typesAsString(false, invocationArguments, false),
2695                        new String JavaDoc(inferredTypeArgument.readableName()),
2696                        new String JavaDoc(typeParameter.sourceName),
2697                        parameterBoundAsString(typeParameter, false) },
2698                new String JavaDoc[] {
2699                        new String JavaDoc(shownConstructor.declaringClass.sourceName()),
2700                        typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true),
2701                        new String JavaDoc(shownConstructor.declaringClass.shortReadableName()),
2702                        typesAsString(false, invocationArguments, true),
2703                        new String JavaDoc(inferredTypeArgument.shortReadableName()),
2704                        new String JavaDoc(typeParameter.sourceName),
2705                        parameterBoundAsString(typeParameter, true) },
2706                sourceStart,
2707                sourceEnd);
2708            return;
2709            
2710        case ProblemReasons.TypeParameterArityMismatch :
2711            problemConstructor = (ProblemMethodBinding) targetConstructor;
2712            shownConstructor = problemConstructor.closestMatch;
2713            if (shownConstructor.typeVariables == Binding.NO_TYPE_VARIABLES) {
2714                this.handle(
2715                    IProblem.NonGenericConstructor,
2716                    new String JavaDoc[] {
2717                            new String JavaDoc(shownConstructor.declaringClass.sourceName()),
2718                            typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false),
2719                            new String JavaDoc(shownConstructor.declaringClass.readableName()),
2720                            typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false) },
2721                    new String JavaDoc[] {
2722                            new String JavaDoc(shownConstructor.declaringClass.sourceName()),
2723                            typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true),
2724                            new String JavaDoc(shownConstructor.declaringClass.shortReadableName()),
2725                            typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true) },
2726                    sourceStart,
2727                    sourceEnd);
2728            } else {
2729                this.handle(
2730                    IProblem.IncorrectArityForParameterizedConstructor ,
2731                    new String JavaDoc[] {
2732                            new String JavaDoc(shownConstructor.declaringClass.sourceName()),
2733                            typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false),
2734                            new String JavaDoc(shownConstructor.declaringClass.readableName()),
2735                            typesAsString(false, shownConstructor.typeVariables, false),
2736                            typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false) },
2737                    new String JavaDoc[] {
2738                            new String JavaDoc(shownConstructor.declaringClass.sourceName()),
2739                            typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true),
2740                            new String JavaDoc(shownConstructor.declaringClass.shortReadableName()),
2741                            typesAsString(false, shownConstructor.typeVariables, true),
2742                            typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true) },
2743                    sourceStart,
2744                    sourceEnd);
2745            }
2746            return;
2747        case ProblemReasons.ParameterizedMethodTypeMismatch :
2748            problemConstructor = (ProblemMethodBinding) targetConstructor;
2749            shownConstructor = problemConstructor.closestMatch;
2750            this.handle(
2751                IProblem.ParameterizedConstructorArgumentTypeMismatch,
2752                new String JavaDoc[] {
2753                        new String JavaDoc(shownConstructor.declaringClass.sourceName()),
2754                        typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false),
2755                        new String JavaDoc(shownConstructor.declaringClass.readableName()),
2756                        typesAsString(false, ((ParameterizedGenericMethodBinding)shownConstructor).typeArguments, false),
2757                        typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false) },
2758                new String JavaDoc[] {
2759                        new String JavaDoc(shownConstructor.declaringClass.sourceName()),
2760                        typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true),
2761                        new String JavaDoc(shownConstructor.declaringClass.shortReadableName()),
2762                        typesAsString(false, ((ParameterizedGenericMethodBinding)shownConstructor).typeArguments, true),
2763                        typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true) },
2764                sourceStart,
2765                sourceEnd);
2766            return;
2767        case ProblemReasons.TypeArgumentsForRawGenericMethod :
2768            problemConstructor = (ProblemMethodBinding) targetConstructor;
2769            shownConstructor = problemConstructor.closestMatch;
2770            this.handle(
2771                IProblem.TypeArgumentsForRawGenericConstructor,
2772                new String JavaDoc[] {
2773                        new String JavaDoc(shownConstructor.declaringClass.sourceName()),
2774                        typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false),
2775                        new String JavaDoc(shownConstructor.declaringClass.readableName()),
2776                        typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false) },
2777                new String JavaDoc[] {
2778                        new String JavaDoc(shownConstructor.declaringClass.sourceName()),
2779                        typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true),
2780                        new String JavaDoc(shownConstructor.declaringClass.shortReadableName()),
2781                        typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true) },
2782                sourceStart,
2783                sourceEnd);
2784            return;
2785        case ProblemReasons.NoError : // 0
2786
default :
2787            needImplementation(); // want to fail to see why we were here...
2788
break;
2789    }
2790
2791    this.handle(
2792        id,
2793        new String JavaDoc[] {new String JavaDoc(targetConstructor.declaringClass.readableName()), typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false)},
2794        new String JavaDoc[] {new String JavaDoc(targetConstructor.declaringClass.shortReadableName()), typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true)},
2795        sourceStart,
2796        sourceEnd);
2797}
2798public void invalidContinue(ASTNode location) {
2799    this.handle(
2800        IProblem.InvalidContinue,
2801        NoArgument,
2802        NoArgument,
2803        location.sourceStart,
2804        location.sourceEnd);
2805}
2806public void invalidEnclosingType(Expression expression, TypeBinding type, ReferenceBinding enclosingType) {
2807
2808    if (enclosingType.isAnonymousType()) enclosingType = enclosingType.superclass();
2809    if (enclosingType.sourceName != null && enclosingType.sourceName.length == 0) return;
2810    
2811    int flag = IProblem.UndefinedType; // default
2812
switch (type.problemId()) {
2813        case ProblemReasons.NotFound : // 1
2814
flag = IProblem.UndefinedType;
2815            break;
2816        case ProblemReasons.NotVisible : // 2
2817
flag = IProblem.NotVisibleType;
2818            break;
2819        case ProblemReasons.Ambiguous : // 3
2820
flag = IProblem.AmbiguousType;
2821            break;
2822        case ProblemReasons.InternalNameProvided :
2823            flag = IProblem.InternalTypeNameProvided;
2824            break;
2825        case ProblemReasons.NoError : // 0
2826
default :
2827            needImplementation(); // want to fail to see why we were here...
2828
break;
2829    }
2830
2831    this.handle(
2832        flag,
2833        new String JavaDoc[] {new String JavaDoc(enclosingType.readableName()) + "." + new String JavaDoc(type.readableName())}, //$NON-NLS-1$
2834
new String JavaDoc[] {new String JavaDoc(enclosingType.shortReadableName()) + "." + new String JavaDoc(type.shortReadableName())}, //$NON-NLS-1$
2835
expression.sourceStart,
2836        expression.sourceEnd);
2837}
2838public void invalidExplicitConstructorCall(ASTNode location) {
2839    
2840    this.handle(
2841        IProblem.InvalidExplicitConstructorCall,
2842        NoArgument,
2843        NoArgument,
2844        location.sourceStart,
2845        location.sourceEnd);
2846}
2847public void invalidExpressionAsStatement(Expression expression){
2848    this.handle(
2849        IProblem.InvalidExpressionAsStatement,
2850        NoArgument,
2851        NoArgument,
2852        expression.sourceStart,
2853        expression.sourceEnd);
2854}
2855public void invalidField(FieldReference fieldRef, TypeBinding searchedType) {
2856    if(isRecoveredName(fieldRef.token)) return;
2857    
2858    int id = IProblem.UndefinedField;
2859    FieldBinding field = fieldRef.binding;
2860    switch (field.problemId()) {
2861        case ProblemReasons.NotFound :
2862            id = IProblem.UndefinedField;
2863/* also need to check that the searchedType is the receiver type
2864            if (searchedType.isHierarchyInconsistent())
2865                severity = SecondaryError;
2866*/

2867            break;
2868        case ProblemReasons.NotVisible :
2869            this.handle(
2870                IProblem.NotVisibleField,
2871                new String JavaDoc[] {new String JavaDoc(fieldRef.token), new String JavaDoc(field.declaringClass.readableName())},
2872                new String JavaDoc[] {new String JavaDoc(fieldRef.token), new String JavaDoc(field.declaringClass.shortReadableName())},
2873                nodeSourceStart(field, fieldRef),
2874                nodeSourceEnd(field, fieldRef));
2875            return;
2876        case ProblemReasons.Ambiguous :
2877            id = IProblem.AmbiguousField;
2878            break;
2879        case ProblemReasons.NonStaticReferenceInStaticContext :
2880            id = IProblem.NonStaticFieldFromStaticInvocation;
2881            break;
2882        case ProblemReasons.NonStaticReferenceInConstructorInvocation :
2883            id = IProblem.InstanceFieldDuringConstructorInvocation;
2884            break;
2885        case ProblemReasons.InheritedNameHidesEnclosingName :
2886            id = IProblem.InheritedFieldHidesEnclosingName;
2887            break;
2888        case ProblemReasons.ReceiverTypeNotVisible :
2889            this.handle(
2890                IProblem.NotVisibleType, // cannot occur in javadoc comments
2891
new String JavaDoc[] {new String JavaDoc(searchedType.leafComponentType().readableName())},
2892                new String JavaDoc[] {new String JavaDoc(searchedType.leafComponentType().shortReadableName())},
2893                fieldRef.receiver.sourceStart,
2894                fieldRef.receiver.sourceEnd);
2895            return;
2896            
2897        case ProblemReasons.NoError : // 0
2898
default :
2899            needImplementation(); // want to fail to see why we were here...
2900
break;
2901    }
2902
2903    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(field.readableName())};
2904    this.handle(
2905        id,
2906        arguments,
2907        arguments,
2908        nodeSourceStart(field, fieldRef),
2909        nodeSourceEnd(field, fieldRef));
2910}
2911public void invalidField(NameReference nameRef, FieldBinding field) {
2912    if (nameRef instanceof QualifiedNameReference) {
2913        QualifiedNameReference ref = (QualifiedNameReference) nameRef;
2914        if (isRecoveredName(ref.tokens)) return;
2915    } else {
2916        SingleNameReference ref = (SingleNameReference) nameRef;
2917        if (isRecoveredName(ref.token)) return;
2918    }
2919    int id = IProblem.UndefinedField;
2920    switch (field.problemId()) {
2921        case ProblemReasons.NotFound :
2922            id = IProblem.UndefinedField;
2923            break;
2924        case ProblemReasons.NotVisible :
2925            char[] name = field.readableName();
2926            name = CharOperation.lastSegment(name, '.');
2927            this.handle(
2928                IProblem.NotVisibleField,
2929                new String JavaDoc[] {new String JavaDoc(name), new String JavaDoc(field.declaringClass.readableName())},
2930                new String JavaDoc[] {new String JavaDoc(name), new String JavaDoc(field.declaringClass.shortReadableName())},
2931                nodeSourceStart(field, nameRef),
2932                nodeSourceEnd(field, nameRef));
2933            return;
2934        case ProblemReasons.Ambiguous :
2935            id = IProblem.AmbiguousField;
2936            break;
2937        case ProblemReasons.NonStaticReferenceInStaticContext :
2938            id = IProblem.NonStaticFieldFromStaticInvocation;
2939            break;
2940        case ProblemReasons.NonStaticReferenceInConstructorInvocation :
2941            id = IProblem.InstanceFieldDuringConstructorInvocation;
2942            break;
2943        case ProblemReasons.InheritedNameHidesEnclosingName :
2944            id = IProblem.InheritedFieldHidesEnclosingName;
2945            break;
2946        case ProblemReasons.ReceiverTypeNotVisible :
2947            this.handle(
2948                IProblem.NotVisibleType,
2949                new String JavaDoc[] {new String JavaDoc(field.declaringClass.leafComponentType().readableName())},
2950                new String JavaDoc[] {new String JavaDoc(field.declaringClass.leafComponentType().shortReadableName())},
2951                nameRef.sourceStart,
2952                nameRef.sourceEnd);
2953            return;
2954        case ProblemReasons.NoError : // 0
2955
default :
2956            needImplementation(); // want to fail to see why we were here...
2957
break;
2958    }
2959    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(field.readableName())};
2960    this.handle(
2961        id,
2962        arguments,
2963        arguments,
2964        nameRef.sourceStart,
2965        nameRef.sourceEnd);
2966}
2967public void invalidField(QualifiedNameReference nameRef, FieldBinding field, int index, TypeBinding searchedType) {
2968    //the resolution of the index-th field of qname failed
2969
//qname.otherBindings[index] is the binding that has produced the error
2970

2971    //The different targetted errors should be :
2972
//UndefinedField
2973
//NotVisibleField
2974
//AmbiguousField
2975

2976    if (isRecoveredName(nameRef.tokens)) return;
2977    
2978    if (searchedType.isBaseType()) {
2979        this.handle(
2980            IProblem.NoFieldOnBaseType,
2981            new String JavaDoc[] {
2982                new String JavaDoc(searchedType.readableName()),
2983                CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index)),
2984                new String JavaDoc(nameRef.tokens[index])},
2985            new String JavaDoc[] {
2986                new String JavaDoc(searchedType.sourceName()),
2987                CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index)),
2988                new String JavaDoc(nameRef.tokens[index])},
2989            nameRef.sourceStart,
2990            (int) nameRef.sourcePositions[index]);
2991        return;
2992    }
2993
2994    int id = IProblem.UndefinedField;
2995    switch (field.problemId()) {
2996        case ProblemReasons.NotFound :
2997            id = IProblem.UndefinedField;
2998/* also need to check that the searchedType is the receiver type
2999            if (searchedType.isHierarchyInconsistent())
3000                severity = SecondaryError;
3001*/

3002            break;
3003        case ProblemReasons.NotVisible :
3004            String JavaDoc fieldName = new String JavaDoc(nameRef.tokens[index]);
3005            this.handle(
3006                IProblem.NotVisibleField,
3007                new String JavaDoc[] {fieldName, new String JavaDoc(field.declaringClass.readableName())},
3008                new String JavaDoc[] {fieldName, new String JavaDoc(field.declaringClass.shortReadableName())},
3009                nodeSourceStart(field, nameRef),
3010                nodeSourceEnd(field, nameRef));
3011            return;
3012        case ProblemReasons.Ambiguous :
3013            id = IProblem.AmbiguousField;
3014            break;
3015        case ProblemReasons.NonStaticReferenceInStaticContext :
3016            id = IProblem.NonStaticFieldFromStaticInvocation;
3017            break;
3018        case ProblemReasons.NonStaticReferenceInConstructorInvocation :
3019            id = IProblem.InstanceFieldDuringConstructorInvocation;
3020            break;
3021        case ProblemReasons.InheritedNameHidesEnclosingName :
3022            id = IProblem.InheritedFieldHidesEnclosingName;
3023            break;
3024        case ProblemReasons.ReceiverTypeNotVisible :
3025            this.handle(
3026                IProblem.NotVisibleType,
3027                new String JavaDoc[] {new String JavaDoc(searchedType.leafComponentType().readableName())},
3028                new String JavaDoc[] {new String JavaDoc(searchedType.leafComponentType().shortReadableName())},
3029                nameRef.sourceStart,
3030                nameRef.sourceEnd);
3031            return;
3032        case ProblemReasons.NoError : // 0
3033
default :
3034            needImplementation(); // want to fail to see why we were here...
3035
break;
3036    }
3037    String JavaDoc[] arguments = new String JavaDoc[] {CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index + 1))};
3038    this.handle(
3039        id,
3040        arguments,
3041        arguments,
3042        nameRef.sourceStart,
3043        (int) nameRef.sourcePositions[index]);
3044}
3045public void invalidFileNameForPackageAnnotations(Annotation annotation) {
3046    this.handle(
3047            IProblem.InvalidFileNameForPackageAnnotations,
3048            NoArgument,
3049            NoArgument,
3050            annotation.sourceStart,
3051            annotation.sourceEnd);
3052}
3053
3054public void invalidMethod(MessageSend messageSend, MethodBinding method) {
3055    if (isRecoveredName(messageSend.selector)) return;
3056    
3057    int id = IProblem.UndefinedMethod; //default...
3058
MethodBinding shownMethod = method;
3059    switch (method.problemId()) {
3060        case ProblemReasons.NotFound :
3061            id = IProblem.UndefinedMethod;
3062            ProblemMethodBinding problemMethod = (ProblemMethodBinding) method;
3063            if (problemMethod.closestMatch != null) {
3064                    shownMethod = problemMethod.closestMatch;
3065                    String JavaDoc closestParameterTypeNames = typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false);
3066                    String JavaDoc parameterTypeNames = typesAsString(false, problemMethod.parameters, false);
3067                    String JavaDoc closestParameterTypeShortNames = typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true);
3068                    String JavaDoc parameterTypeShortNames = typesAsString(false, problemMethod.parameters, true);
3069                    this.handle(
3070                        IProblem.ParameterMismatch,
3071                        new String JavaDoc[] {
3072                            new String JavaDoc(shownMethod.declaringClass.readableName()),
3073                            new String JavaDoc(shownMethod.selector),
3074                            closestParameterTypeNames,
3075                            parameterTypeNames
3076                        },
3077                        new String JavaDoc[] {
3078                            new String JavaDoc(shownMethod.declaringClass.shortReadableName()),
3079                            new String JavaDoc(shownMethod.selector),
3080                            closestParameterTypeShortNames,
3081                            parameterTypeShortNames
3082                        },
3083                        (int) (messageSend.nameSourcePosition >>> 32),
3084                        (int) messageSend.nameSourcePosition);
3085                    return;
3086            }
3087            break;
3088        case ProblemReasons.NotVisible :
3089            id = IProblem.NotVisibleMethod;
3090            problemMethod = (ProblemMethodBinding) method;
3091            if (problemMethod.closestMatch != null) {
3092                shownMethod = problemMethod.closestMatch.original();
3093            }
3094            break;
3095        case ProblemReasons.Ambiguous :
3096            id = IProblem.AmbiguousMethod;
3097            break;
3098        case ProblemReasons.InheritedNameHidesEnclosingName :
3099            id = IProblem.InheritedMethodHidesEnclosingName;
3100            break;
3101        case ProblemReasons.NonStaticReferenceInConstructorInvocation :
3102            id = IProblem.InstanceMethodDuringConstructorInvocation;
3103            break;
3104        case ProblemReasons.NonStaticReferenceInStaticContext :
3105            id = IProblem.StaticMethodRequested;
3106            break;
3107        case ProblemReasons.ReceiverTypeNotVisible :
3108            this.handle(
3109                IProblem.NotVisibleType, // cannot occur in javadoc comments
3110
new String JavaDoc[] {new String JavaDoc(method.declaringClass.leafComponentType().readableName())},
3111                new String JavaDoc[] {new String JavaDoc(method.declaringClass.leafComponentType().shortReadableName())},
3112                messageSend.receiver.sourceStart,
3113                messageSend.receiver.sourceEnd);
3114            return;
3115        case ProblemReasons.ParameterBoundMismatch :
3116            problemMethod = (ProblemMethodBinding) method;
3117            ParameterizedGenericMethodBinding substitutedMethod = (ParameterizedGenericMethodBinding) problemMethod.closestMatch;
3118            shownMethod = substitutedMethod.original();
3119            int augmentedLength = problemMethod.parameters.length;
3120            TypeBinding inferredTypeArgument = problemMethod.parameters[augmentedLength-2];
3121            TypeVariableBinding typeParameter = (TypeVariableBinding) problemMethod.parameters[augmentedLength-1];
3122            TypeBinding[] invocationArguments = new TypeBinding[augmentedLength-2]; // remove extra info from the end
3123
System.arraycopy(problemMethod.parameters, 0, invocationArguments, 0, augmentedLength-2);
3124            this.handle(
3125                IProblem.GenericMethodTypeArgumentMismatch,
3126                new String JavaDoc[] {
3127                        new String JavaDoc(shownMethod.selector),
3128                        typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false),
3129                        new String JavaDoc(shownMethod.declaringClass.readableName()),
3130                        typesAsString(false, invocationArguments, false),
3131                        new String JavaDoc(inferredTypeArgument.readableName()),
3132                        new String JavaDoc(typeParameter.sourceName),
3133                        parameterBoundAsString(typeParameter, false) },
3134                new String JavaDoc[] {
3135                        new String JavaDoc(shownMethod.selector),
3136                        typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true),
3137                        new String JavaDoc(shownMethod.declaringClass.shortReadableName()),
3138                        typesAsString(false, invocationArguments, true),
3139                        new String JavaDoc(inferredTypeArgument.shortReadableName()),
3140                        new String JavaDoc(typeParameter.sourceName),
3141                        parameterBoundAsString(typeParameter, true) },
3142                (int) (messageSend.nameSourcePosition >>> 32),
3143                (int) messageSend.nameSourcePosition);
3144            return;
3145        case ProblemReasons.TypeParameterArityMismatch :
3146            problemMethod = (ProblemMethodBinding) method;
3147            shownMethod = problemMethod.closestMatch;
3148            if (shownMethod.typeVariables == Binding.NO_TYPE_VARIABLES) {
3149                this.handle(
3150                    IProblem.NonGenericMethod ,
3151                    new String JavaDoc[] {
3152                            new String JavaDoc(shownMethod.selector),
3153                            typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false),
3154                            new String JavaDoc(shownMethod.declaringClass.readableName()),
3155                            typesAsString(method.isVarargs(), method.parameters, false) },
3156                    new String JavaDoc[] {
3157                            new String JavaDoc(shownMethod.selector),
3158                            typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true),
3159                            new String JavaDoc(shownMethod.declaringClass.shortReadableName()),
3160                            typesAsString(method.isVarargs(), method.parameters, true) },
3161                    (int) (messageSend.nameSourcePosition >>> 32),
3162                    (int) messageSend.nameSourcePosition);
3163            } else {
3164                this.handle(
3165                    IProblem.IncorrectArityForParameterizedMethod ,
3166                    new String JavaDoc[] {
3167                            new String JavaDoc(shownMethod.selector),
3168                            typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false),
3169                            new String JavaDoc(shownMethod.declaringClass.readableName()),
3170                            typesAsString(false, shownMethod.typeVariables, false),
3171                            typesAsString(method.isVarargs(), method.parameters, false) },
3172                    new String JavaDoc[] {
3173                            new String JavaDoc(shownMethod.selector),
3174                            typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true),
3175                            new String JavaDoc(shownMethod.declaringClass.shortReadableName()),
3176                            typesAsString(false, shownMethod.typeVariables, true),
3177                            typesAsString(method.isVarargs(), method.parameters, true) },
3178                    (int) (messageSend.nameSourcePosition >>> 32),
3179                    (int) messageSend.nameSourcePosition);
3180            }
3181            return;
3182        case ProblemReasons.ParameterizedMethodTypeMismatch :
3183            problemMethod = (ProblemMethodBinding) method;
3184            shownMethod = problemMethod.closestMatch;
3185            this.handle(
3186                IProblem.ParameterizedMethodArgumentTypeMismatch,
3187                new String JavaDoc[] {
3188                        new String JavaDoc(shownMethod.selector),
3189                        typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false),
3190                        new String JavaDoc(shownMethod.declaringClass.readableName()),
3191                        typesAsString(false, ((ParameterizedGenericMethodBinding)shownMethod).typeArguments, false),
3192                        typesAsString(method.isVarargs(), method.parameters, false) },
3193                new String JavaDoc[] {
3194                        new String JavaDoc(shownMethod.selector),
3195                        typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true),
3196                        new String JavaDoc(shownMethod.declaringClass.shortReadableName()),
3197                        typesAsString(false, ((ParameterizedGenericMethodBinding)shownMethod).typeArguments, true),
3198                        typesAsString(method.isVarargs(), method.parameters, true) },
3199                (int) (messageSend.nameSourcePosition >>> 32),
3200                (int) messageSend.nameSourcePosition);
3201            return;
3202        case ProblemReasons.TypeArgumentsForRawGenericMethod :
3203            problemMethod = (ProblemMethodBinding) method;
3204            shownMethod = problemMethod.closestMatch;
3205            this.handle(
3206                IProblem.TypeArgumentsForRawGenericMethod ,
3207                new String JavaDoc[] {
3208                        new String JavaDoc(shownMethod.selector),
3209                        typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false),
3210                        new String JavaDoc(shownMethod.declaringClass.readableName()),
3211                        typesAsString(method.isVarargs(), method.parameters, false) },
3212                new String JavaDoc[] {
3213                        new String JavaDoc(shownMethod.selector),
3214                        typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true),
3215                        new String JavaDoc(shownMethod.declaringClass.shortReadableName()),
3216                        typesAsString(method.isVarargs(), method.parameters, true) },
3217                (int) (messageSend.nameSourcePosition >>> 32),
3218                (int) messageSend.nameSourcePosition);
3219            return;
3220        case ProblemReasons.NoError : // 0
3221
default :
3222            needImplementation(); // want to fail to see why we were here...
3223
break;
3224    }
3225
3226    this.handle(
3227        id,
3228        new String JavaDoc[] {
3229            new String JavaDoc(method.declaringClass.readableName()),
3230            new String JavaDoc(shownMethod.selector), typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false)},
3231        new String JavaDoc[] {
3232            new String JavaDoc(method.declaringClass.shortReadableName()),
3233            new String JavaDoc(shownMethod.selector), typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true)},
3234        (int) (messageSend.nameSourcePosition >>> 32),
3235        (int) messageSend.nameSourcePosition);
3236}
3237
3238public void invalidNullToSynchronize(Expression expression) {
3239    this.handle(
3240        IProblem.InvalidNullToSynchronized,
3241        NoArgument,
3242        NoArgument,
3243        expression.sourceStart,
3244        expression.sourceEnd);
3245}
3246public void invalidOperator(BinaryExpression expression, TypeBinding leftType, TypeBinding rightType) {
3247    String JavaDoc leftName = new String JavaDoc(leftType.readableName());
3248    String JavaDoc rightName = new String JavaDoc(rightType.readableName());
3249    String JavaDoc leftShortName = new String JavaDoc(leftType.shortReadableName());
3250    String JavaDoc rightShortName = new String JavaDoc(rightType.shortReadableName());
3251    if (leftShortName.equals(rightShortName)){
3252        leftShortName = leftName;
3253        rightShortName = rightName;
3254    }
3255    this.handle(
3256        IProblem.InvalidOperator,
3257        new String JavaDoc[] {
3258            expression.operatorToString(),
3259            leftName + ", " + rightName}, //$NON-NLS-1$
3260
new String JavaDoc[] {
3261            expression.operatorToString(),
3262            leftShortName + ", " + rightShortName}, //$NON-NLS-1$
3263
expression.sourceStart,
3264        expression.sourceEnd);
3265}
3266public void invalidOperator(CompoundAssignment assign, TypeBinding leftType, TypeBinding rightType) {
3267    String JavaDoc leftName = new String JavaDoc(leftType.readableName());
3268    String JavaDoc rightName = new String JavaDoc(rightType.readableName());
3269    String JavaDoc leftShortName = new String JavaDoc(leftType.shortReadableName());
3270    String JavaDoc rightShortName = new String JavaDoc(rightType.shortReadableName());
3271    if (leftShortName.equals(rightShortName)){
3272        leftShortName = leftName;
3273        rightShortName = rightName;
3274    }
3275    this.handle(
3276        IProblem.InvalidOperator,
3277        new String JavaDoc[] {
3278            assign.operatorToString(),
3279            leftName + ", " + rightName}, //$NON-NLS-1$
3280
new String JavaDoc[] {
3281            assign.operatorToString(),
3282            leftShortName + ", " + rightShortName}, //$NON-NLS-1$
3283
assign.sourceStart,
3284        assign.sourceEnd);
3285}
3286public void invalidOperator(UnaryExpression expression, TypeBinding type) {
3287    this.handle(
3288        IProblem.InvalidOperator,
3289        new String JavaDoc[] {expression.operatorToString(), new String JavaDoc(type.readableName())},
3290        new String JavaDoc[] {expression.operatorToString(), new String JavaDoc(type.shortReadableName())},
3291        expression.sourceStart,
3292        expression.sourceEnd);
3293}
3294public void invalidParameterizedExceptionType(TypeBinding exceptionType, ASTNode location) {
3295    this.handle(
3296        IProblem.InvalidParameterizedExceptionType,
3297        new String JavaDoc[] {new String JavaDoc(exceptionType.readableName())},
3298        new String JavaDoc[] {new String JavaDoc(exceptionType.shortReadableName())},
3299        location.sourceStart,
3300        location.sourceEnd);
3301}
3302public void invalidParenthesizedExpression(ASTNode reference) {
3303    this.handle(
3304        IProblem.InvalidParenthesizedExpression,
3305        NoArgument,
3306        NoArgument,
3307        reference.sourceStart,
3308        reference.sourceEnd);
3309}
3310public void invalidType(ASTNode location, TypeBinding type) {
3311    if (type instanceof ReferenceBinding) {
3312        if (isRecoveredName(((ReferenceBinding)type).compoundName)) return;
3313    }
3314    else if (type instanceof ArrayBinding) {
3315        TypeBinding leafType = ((ArrayBinding)type).leafComponentType;
3316        if (leafType instanceof ReferenceBinding) {
3317            if (isRecoveredName(((ReferenceBinding)leafType).compoundName)) return;
3318        }
3319    }
3320    
3321    int id = IProblem.UndefinedType; // default
3322
switch (type.problemId()) {
3323        case ProblemReasons.NotFound :
3324            id = IProblem.UndefinedType;
3325            break;
3326        case ProblemReasons.NotVisible :
3327            id = IProblem.NotVisibleType;
3328            break;
3329        case ProblemReasons.Ambiguous :
3330            id = IProblem.AmbiguousType;
3331            break;
3332        case ProblemReasons.InternalNameProvided :
3333            id = IProblem.InternalTypeNameProvided;
3334            break;
3335        case ProblemReasons.InheritedNameHidesEnclosingName :
3336            id = IProblem.InheritedTypeHidesEnclosingName;
3337            break;
3338        case ProblemReasons.NonStaticReferenceInStaticContext :
3339            id = IProblem.NonStaticTypeFromStaticInvocation;
3340            break;
3341        case ProblemReasons.IllegalSuperTypeVariable :
3342            id = IProblem.IllegalTypeVariableSuperReference;
3343            break;
3344        case ProblemReasons.NoError : // 0
3345
default :
3346            needImplementation(); // want to fail to see why we were here...
3347
break;
3348    }
3349    
3350    int end = location.sourceEnd;
3351    if (location instanceof QualifiedNameReference) {
3352        QualifiedNameReference ref = (QualifiedNameReference) location;
3353        if (isRecoveredName(ref.tokens)) return;
3354        if (ref.indexOfFirstFieldBinding >= 1)
3355            end = (int) ref.sourcePositions[ref.indexOfFirstFieldBinding - 1];
3356    } else if (location instanceof ParameterizedQualifiedTypeReference) {
3357        // must be before instanceof ArrayQualifiedTypeReference
3358
ParameterizedQualifiedTypeReference ref = (ParameterizedQualifiedTypeReference) location;
3359        if (isRecoveredName(ref.tokens)) return;
3360        if (type instanceof ReferenceBinding) {
3361            char[][] name = ((ReferenceBinding) type).compoundName;
3362            end = (int) ref.sourcePositions[name.length - 1];
3363        }
3364    } else if (location instanceof ArrayQualifiedTypeReference) {
3365        ArrayQualifiedTypeReference arrayQualifiedTypeReference = (ArrayQualifiedTypeReference) location;
3366        if (isRecoveredName(arrayQualifiedTypeReference.tokens)) return;
3367        long[] positions = arrayQualifiedTypeReference.sourcePositions;
3368        end = (int) positions[positions.length - 1];
3369    } else if (location instanceof QualifiedTypeReference) {
3370        QualifiedTypeReference ref = (QualifiedTypeReference) location;
3371        if (isRecoveredName(ref.tokens)) return;
3372        if (type instanceof ReferenceBinding) {
3373            char[][] name = ((ReferenceBinding) type).compoundName;
3374            if (name.length <= ref.sourcePositions.length)
3375                end = (int) ref.sourcePositions[name.length - 1];
3376        }
3377    } else if (location instanceof ImportReference) {
3378        ImportReference ref = (ImportReference) location;
3379        if (isRecoveredName(ref.tokens)) return;
3380        if (type instanceof ReferenceBinding) {
3381            char[][] name = ((ReferenceBinding) type).compoundName;
3382            end = (int) ref.sourcePositions[name.length - 1];
3383        }
3384    } else if (location instanceof ArrayTypeReference) {
3385        ArrayTypeReference arrayTypeReference = (ArrayTypeReference) location;
3386        if (isRecoveredName(arrayTypeReference.token)) return;
3387        end = arrayTypeReference.originalSourceEnd;
3388    }
3389    this.handle(
3390        id,
3391        new String JavaDoc[] {new String JavaDoc(type.leafComponentType().readableName()) },
3392        new String JavaDoc[] {new String JavaDoc(type.leafComponentType().shortReadableName())},
3393        location.sourceStart,
3394        end);
3395}
3396public void invalidTypeForCollection(Expression expression) {
3397    this.handle(
3398            IProblem.InvalidTypeForCollection,
3399            NoArgument,
3400            NoArgument,
3401            expression.sourceStart,
3402            expression.sourceEnd);
3403}
3404public void invalidTypeReference(Expression expression) {
3405    this.handle(
3406        IProblem.InvalidTypeExpression,
3407        NoArgument,
3408        NoArgument,
3409        expression.sourceStart,
3410        expression.sourceEnd);
3411}
3412public void invalidTypeToSynchronize(Expression expression, TypeBinding type) {
3413    this.handle(
3414        IProblem.InvalidTypeToSynchronized,
3415        new String JavaDoc[] {new String JavaDoc(type.readableName())},
3416        new String JavaDoc[] {new String JavaDoc(type.shortReadableName())},
3417        expression.sourceStart,
3418        expression.sourceEnd);
3419}
3420public void invalidTypeVariableAsException(TypeBinding exceptionType, ASTNode location) {
3421    this.handle(
3422        IProblem.InvalidTypeVariableExceptionType,
3423        new String JavaDoc[] {new String JavaDoc(exceptionType.readableName())},
3424        new String JavaDoc[] {new String JavaDoc(exceptionType.shortReadableName())},
3425        location.sourceStart,
3426        location.sourceEnd);
3427}
3428public void invalidUnaryExpression(Expression expression) {
3429    this.handle(
3430        IProblem.InvalidUnaryExpression,
3431        NoArgument,
3432        NoArgument,
3433        expression.sourceStart,
3434        expression.sourceEnd);
3435}
3436public void invalidUsageOfAnnotation(Annotation annotation) {
3437    this.handle(
3438        IProblem.InvalidUsageOfAnnotations,
3439        NoArgument,
3440        NoArgument,
3441        annotation.sourceStart,
3442        annotation.sourceEnd);
3443}
3444public void invalidUsageOfAnnotationDeclarations(TypeDeclaration annotationTypeDeclaration) {
3445    this.handle(
3446        IProblem.InvalidUsageOfAnnotationDeclarations,
3447        NoArgument,
3448        NoArgument,
3449        annotationTypeDeclaration.sourceStart,
3450        annotationTypeDeclaration.sourceEnd);
3451}
3452public void invalidUsageOfEnumDeclarations(TypeDeclaration enumDeclaration) {
3453    this.handle(
3454        IProblem.InvalidUsageOfEnumDeclarations,
3455        NoArgument,
3456        NoArgument,
3457        enumDeclaration.sourceStart,
3458        enumDeclaration.sourceEnd);
3459}
3460public void invalidUsageOfForeachStatements(LocalDeclaration elementVariable, Expression collection) {
3461    this.handle(
3462        IProblem.InvalidUsageOfForeachStatements,
3463        NoArgument,
3464        NoArgument,
3465        elementVariable.declarationSourceStart,
3466        collection.sourceEnd);
3467}
3468public void invalidUsageOfStaticImports(ImportReference staticImport) {
3469    this.handle(
3470        IProblem.InvalidUsageOfStaticImports,
3471        NoArgument,
3472        NoArgument,
3473        staticImport.declarationSourceStart,
3474        staticImport.declarationSourceEnd);
3475}
3476public void invalidUsageOfTypeArguments(TypeReference firstTypeReference, TypeReference lastTypeReference) {
3477    this.handle(
3478        IProblem.InvalidUsageOfTypeArguments,
3479        NoArgument,
3480        NoArgument,
3481        firstTypeReference.sourceStart,
3482        lastTypeReference.sourceEnd);
3483}
3484public void invalidUsageOfTypeParameters(TypeParameter firstTypeParameter, TypeParameter lastTypeParameter) {
3485    this.handle(
3486        IProblem.InvalidUsageOfTypeParameters,
3487        NoArgument,
3488        NoArgument,
3489        firstTypeParameter.declarationSourceStart,
3490        lastTypeParameter.declarationSourceEnd);
3491}
3492public void invalidUsageOfVarargs(Argument argument) {
3493    this.handle(
3494        IProblem.InvalidUsageOfVarargs,
3495        NoArgument,
3496        NoArgument,
3497        argument.type.sourceStart,
3498        argument.sourceEnd);
3499}
3500public void illegalUsageOfWildcard(TypeReference wildcard) {
3501    this.handle(
3502        IProblem.InvalidUsageOfWildcard,
3503        NoArgument,
3504        NoArgument,
3505        wildcard.sourceStart,
3506        wildcard.sourceEnd);
3507}
3508public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl, Object JavaDoc location) {
3509    this.referenceContext = compUnitDecl;
3510    String JavaDoc[] arguments = new String JavaDoc[] {CharOperation.toString(wellKnownTypeName)};
3511    int start = 0, end = 0;
3512    if (location != null) {
3513        if (location instanceof InvocationSite) {
3514            InvocationSite site = (InvocationSite) location;
3515            start = site.sourceStart();
3516            end = site.sourceEnd();
3517        } else if (location instanceof ASTNode) {
3518            ASTNode node = (ASTNode) location;
3519            start = node.sourceStart();
3520            end = node.sourceEnd();
3521        }
3522    }
3523    this.handle(
3524        IProblem.IsClassPathCorrect,
3525        arguments,
3526        arguments,
3527        start,
3528        end);
3529}
3530private boolean isIdentifier(int token) {
3531    return token == TerminalTokens.TokenNameIdentifier;
3532}
3533private boolean isKeyword(int token) {
3534    switch(token) {
3535        case TerminalTokens.TokenNameabstract:
3536        case TerminalTokens.TokenNameassert:
3537        case TerminalTokens.TokenNamebyte:
3538        case TerminalTokens.TokenNamebreak:
3539        case TerminalTokens.TokenNameboolean:
3540        case TerminalTokens.TokenNamecase:
3541        case TerminalTokens.TokenNamechar:
3542        case TerminalTokens.TokenNamecatch:
3543        case TerminalTokens.TokenNameclass:
3544        case TerminalTokens.TokenNamecontinue:
3545        case TerminalTokens.TokenNamedo:
3546        case TerminalTokens.TokenNamedouble:
3547        case TerminalTokens.TokenNamedefault:
3548        case TerminalTokens.TokenNameelse:
3549        case TerminalTokens.TokenNameextends:
3550        case TerminalTokens.TokenNamefor:
3551        case TerminalTokens.TokenNamefinal:
3552        case TerminalTokens.TokenNamefloat:
3553        case TerminalTokens.TokenNamefalse:
3554        case TerminalTokens.TokenNamefinally:
3555        case TerminalTokens.TokenNameif:
3556        case TerminalTokens.TokenNameint:
3557        case TerminalTokens.TokenNameimport:
3558        case TerminalTokens.TokenNameinterface:
3559        case TerminalTokens.TokenNameimplements:
3560        case TerminalTokens.TokenNameinstanceof:
3561        case TerminalTokens.TokenNamelong:
3562        case TerminalTokens.TokenNamenew:
3563        case TerminalTokens.TokenNamenull:
3564        case TerminalTokens.TokenNamenative:
3565        case TerminalTokens.TokenNamepublic:
3566        case TerminalTokens.TokenNamepackage:
3567        case TerminalTokens.TokenNameprivate:
3568        case TerminalTokens.TokenNameprotected:
3569        case TerminalTokens.TokenNamereturn:
3570        case TerminalTokens.TokenNameshort:
3571        case TerminalTokens.TokenNamesuper:
3572        case TerminalTokens.TokenNamestatic:
3573        case TerminalTokens.TokenNameswitch:
3574        case TerminalTokens.TokenNamestrictfp:
3575        case TerminalTokens.TokenNamesynchronized:
3576        case TerminalTokens.TokenNametry:
3577        case TerminalTokens.TokenNamethis:
3578        case TerminalTokens.TokenNametrue:
3579        case TerminalTokens.TokenNamethrow:
3580        case TerminalTokens.TokenNamethrows:
3581        case TerminalTokens.TokenNametransient:
3582        case TerminalTokens.TokenNamevoid:
3583        case TerminalTokens.TokenNamevolatile:
3584        case TerminalTokens.TokenNamewhile:
3585            return true;
3586        default:
3587            return false;
3588    }
3589}
3590private boolean isLiteral(int token) {
3591    switch(token) {
3592        case TerminalTokens.TokenNameIntegerLiteral:
3593        case TerminalTokens.TokenNameLongLiteral:
3594        case TerminalTokens.TokenNameFloatingPointLiteral:
3595        case TerminalTokens.TokenNameDoubleLiteral:
3596        case TerminalTokens.TokenNameStringLiteral:
3597        case TerminalTokens.TokenNameCharacterLiteral:
3598            return true;
3599        default:
3600            return false;
3601    }
3602}
3603private boolean isRecoveredName(char[] simpleName) {
3604    return simpleName == RecoveryScanner.FAKE_IDENTIFIER;
3605}
3606private boolean isRecoveredName(char[][] qualifiedName) {
3607    if(qualifiedName == null) return false;
3608    
3609    for (int i = 0; i < qualifiedName.length; i++) {
3610        if(qualifiedName[i] == RecoveryScanner.FAKE_IDENTIFIER) return true;
3611    }
3612    
3613    return false;
3614}
3615public void javadocAmbiguousMethodReference(int sourceStart, int sourceEnd, Binding fieldBinding, int modifiers) {
3616    int severity = computeSeverity(IProblem.JavadocAmbiguousMethodReference);
3617    if (severity == ProblemSeverities.Ignore) return;
3618    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3619        String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(fieldBinding.readableName())};
3620        handle(
3621            IProblem.JavadocAmbiguousMethodReference,
3622            arguments,
3623            arguments,
3624            severity,
3625            sourceStart,
3626            sourceEnd);
3627    }
3628}
3629
3630public void javadocDeprecatedField(FieldBinding field, ASTNode location, int modifiers) {
3631    int severity = computeSeverity(IProblem.JavadocUsingDeprecatedField);
3632    if (severity == ProblemSeverities.Ignore) return;
3633    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3634        this.handle(
3635            IProblem.JavadocUsingDeprecatedField,
3636            new String JavaDoc[] {new String JavaDoc(field.declaringClass.readableName()), new String JavaDoc(field.name)},
3637            new String JavaDoc[] {new String JavaDoc(field.declaringClass.shortReadableName()), new String JavaDoc(field.name)},
3638            severity,
3639            nodeSourceStart(field, location),
3640            nodeSourceEnd(field, location));
3641    }
3642}
3643
3644public void javadocDeprecatedMethod(MethodBinding method, ASTNode location, int modifiers) {
3645    boolean isConstructor = method.isConstructor();
3646    int severity = computeSeverity(isConstructor ? IProblem.JavadocUsingDeprecatedConstructor : IProblem.JavadocUsingDeprecatedMethod);
3647    if (severity == ProblemSeverities.Ignore) return;
3648    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3649        if (isConstructor) {
3650            this.handle(
3651                IProblem.JavadocUsingDeprecatedConstructor,
3652                new String JavaDoc[] {new String JavaDoc(method.declaringClass.readableName()), typesAsString(method.isVarargs(), method.parameters, false)},
3653                new String JavaDoc[] {new String JavaDoc(method.declaringClass.shortReadableName()), typesAsString(method.isVarargs(), method.parameters, true)},
3654                severity,
3655                location.sourceStart,
3656                location.sourceEnd);
3657        } else {
3658            this.handle(
3659                IProblem.JavadocUsingDeprecatedMethod,
3660                new String JavaDoc[] {new String JavaDoc(method.declaringClass.readableName()), new String JavaDoc(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
3661                new String JavaDoc[] {new String JavaDoc(method.declaringClass.shortReadableName()), new String JavaDoc(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
3662                severity,
3663                location.sourceStart,
3664                location.sourceEnd);
3665        }
3666    }
3667}
3668public void javadocDeprecatedType(TypeBinding type, ASTNode location, int modifiers) {
3669    if (location == null) return; // 1G828DN - no type ref for synthetic arguments
3670
int severity = computeSeverity(IProblem.JavadocUsingDeprecatedType);
3671    if (severity == ProblemSeverities.Ignore) return;
3672    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3673        if (type.isMemberType() && type instanceof ReferenceBinding && !javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, ((ReferenceBinding)type).modifiers)) {
3674            this.handle(IProblem.JavadocHiddenReference, NoArgument, NoArgument, location.sourceStart, location.sourceEnd);
3675        } else {
3676            this.handle(
3677                IProblem.JavadocUsingDeprecatedType,
3678                new String JavaDoc[] {new String JavaDoc(type.readableName())},
3679                new String JavaDoc[] {new String JavaDoc(type.shortReadableName())},
3680                severity,
3681                location.sourceStart,
3682                location.sourceEnd);
3683        }
3684    }
3685}
3686public void javadocDuplicatedParamTag(char[] token, int sourceStart, int sourceEnd, int modifiers) {
3687    int severity = computeSeverity(IProblem.JavadocDuplicateParamName);
3688    if (severity == ProblemSeverities.Ignore) return;
3689    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3690        String JavaDoc[] arguments = new String JavaDoc[] {String.valueOf(token)};
3691        this.handle(
3692            IProblem.JavadocDuplicateParamName,
3693            arguments,
3694            arguments,
3695            severity,
3696            sourceStart,
3697            sourceEnd);
3698    }
3699}
3700public void javadocDuplicatedReturnTag(int sourceStart, int sourceEnd){
3701    this.handle(IProblem.JavadocDuplicateReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd);
3702}
3703public void javadocDuplicatedTag(char[] tagName, int sourceStart, int sourceEnd){
3704    String JavaDoc[] arguments = new String JavaDoc[] { new String JavaDoc(tagName) };
3705    this.handle(
3706        IProblem.JavadocDuplicateTag,
3707        arguments,
3708        arguments,
3709        sourceStart,
3710        sourceEnd);
3711}
3712public void javadocDuplicatedThrowsClassName(TypeReference typeReference, int modifiers) {
3713    int severity = computeSeverity(IProblem.JavadocDuplicateThrowsClassName);
3714    if (severity == ProblemSeverities.Ignore) return;
3715    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3716        String JavaDoc[] arguments = new String JavaDoc[] {String.valueOf(typeReference.resolvedType.sourceName())};
3717        this.handle(
3718            IProblem.JavadocDuplicateThrowsClassName,
3719            arguments,
3720            arguments,
3721            severity,
3722            typeReference.sourceStart,
3723            typeReference.sourceEnd);
3724    }
3725}
3726public void javadocEmptyReturnTag(int sourceStart, int sourceEnd, int modifiers) {
3727    int severity = computeSeverity(IProblem.JavadocEmptyReturnTag);
3728    if (severity == ProblemSeverities.Ignore) return;
3729    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3730        this.handle(IProblem.JavadocEmptyReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd);
3731    }
3732}
3733public void javadocErrorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params, int modifiers) {
3734    int id = recType.isArrayType() ? IProblem.JavadocNoMessageSendOnArrayType : IProblem.JavadocNoMessageSendOnBaseType;
3735    int severity = computeSeverity(id);
3736    if (severity == ProblemSeverities.Ignore) return;
3737    StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
3738    StringBuffer JavaDoc shortBuffer = new StringBuffer JavaDoc();
3739    for (int i = 0, length = params.length; i < length; i++) {
3740        if (i != 0){
3741            buffer.append(", "); //$NON-NLS-1$
3742
shortBuffer.append(", "); //$NON-NLS-1$
3743
}
3744        buffer.append(new String JavaDoc(params[i].readableName()));
3745        shortBuffer.append(new String JavaDoc(params[i].shortReadableName()));
3746    }
3747    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3748        this.handle(
3749            id,
3750            new String JavaDoc[] {new String JavaDoc(recType.readableName()), new String JavaDoc(messageSend.selector), buffer.toString()},
3751            new String JavaDoc[] {new String JavaDoc(recType.shortReadableName()), new String JavaDoc(messageSend.selector), shortBuffer.toString()},
3752            severity,
3753            messageSend.sourceStart,
3754            messageSend.sourceEnd);
3755    }
3756}
3757public void javadocHiddenReference(int sourceStart, int sourceEnd, Scope scope, int modifiers) {
3758    Scope currentScope = scope;
3759    while (currentScope.parent.kind != Scope.COMPILATION_UNIT_SCOPE ) {
3760        if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, currentScope.getDeclarationModifiers())) {
3761            return;
3762        }
3763        currentScope = currentScope.parent;
3764    }
3765    String JavaDoc[] arguments = new String JavaDoc[] { this.options.getVisibilityString(this.options.reportInvalidJavadocTagsVisibility), this.options.getVisibilityString(modifiers) };
3766    this.handle(IProblem.JavadocHiddenReference, arguments, arguments, sourceStart, sourceEnd);
3767}
3768public void javadocInvalidConstructor(Statement statement, MethodBinding targetConstructor, int modifiers) {
3769
3770    if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) return;
3771    int sourceStart = statement.sourceStart;
3772    int sourceEnd = statement.sourceEnd;
3773    if (statement instanceof AllocationExpression) {
3774        AllocationExpression allocation = (AllocationExpression)statement;
3775        if (allocation.enumConstant != null) {
3776            sourceStart = allocation.enumConstant.sourceStart;
3777            sourceEnd = allocation.enumConstant.sourceEnd;
3778        }
3779    }
3780    int id = IProblem.JavadocUndefinedConstructor; //default...
3781
ProblemMethodBinding problemConstructor = null;
3782    MethodBinding shownConstructor = null;
3783    switch (targetConstructor.problemId()) {
3784        case ProblemReasons.NotFound :
3785            id = IProblem.JavadocUndefinedConstructor;
3786            break;
3787        case ProblemReasons.NotVisible :
3788            id = IProblem.JavadocNotVisibleConstructor;
3789            break;
3790        case ProblemReasons.Ambiguous :
3791            id = IProblem.JavadocAmbiguousConstructor;
3792            break;
3793        case ProblemReasons.ParameterBoundMismatch :
3794            int severity = computeSeverity(IProblem.JavadocGenericConstructorTypeArgumentMismatch);
3795            if (severity == ProblemSeverities.Ignore) return;
3796            problemConstructor = (ProblemMethodBinding) targetConstructor;
3797            ParameterizedGenericMethodBinding substitutedConstructor = (ParameterizedGenericMethodBinding) problemConstructor.closestMatch;
3798            shownConstructor = substitutedConstructor.original();
3799            
3800            int augmentedLength = problemConstructor.parameters.length;
3801            TypeBinding inferredTypeArgument = problemConstructor.parameters[augmentedLength-2];
3802            TypeVariableBinding typeParameter = (TypeVariableBinding) problemConstructor.parameters[augmentedLength-1];
3803            TypeBinding[] invocationArguments = new TypeBinding[augmentedLength-2]; // remove extra info from the end
3804
System.arraycopy(problemConstructor.parameters, 0, invocationArguments, 0, augmentedLength-2);
3805            
3806            this.handle(
3807                IProblem.JavadocGenericConstructorTypeArgumentMismatch,
3808                new String JavaDoc[] {
3809                        new String JavaDoc(shownConstructor.declaringClass.sourceName()),
3810                        typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false),
3811                        new String JavaDoc(shownConstructor.declaringClass.readableName()),
3812                        typesAsString(false, invocationArguments, false),
3813                        new String JavaDoc(inferredTypeArgument.readableName()),
3814                        new String JavaDoc(typeParameter.sourceName),
3815                        parameterBoundAsString(typeParameter, false) },
3816                new String JavaDoc[] {
3817                        new String JavaDoc(shownConstructor.declaringClass.sourceName()),
3818                        typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true),
3819                        new String JavaDoc(shownConstructor.declaringClass.shortReadableName()),
3820                        typesAsString(false, invocationArguments, true),
3821                        new String JavaDoc(inferredTypeArgument.shortReadableName()),
3822                        new String JavaDoc(typeParameter.sourceName),
3823                        parameterBoundAsString(typeParameter, true) },
3824                severity,
3825                sourceStart,
3826                sourceEnd);
3827            return;
3828            
3829        case ProblemReasons.TypeParameterArityMismatch :
3830            problemConstructor = (ProblemMethodBinding) targetConstructor;
3831            shownConstructor = problemConstructor.closestMatch;
3832            boolean noTypeVariables = shownConstructor.typeVariables == Binding.NO_TYPE_VARIABLES;
3833            severity = computeSeverity(noTypeVariables ? IProblem.JavadocNonGenericConstructor : IProblem.JavadocIncorrectArityForParameterizedConstructor);
3834            if (severity == ProblemSeverities.Ignore) return;
3835            if (noTypeVariables) {
3836                this.handle(
3837                    IProblem.JavadocNonGenericConstructor,
3838                    new String JavaDoc[] {
3839                            new String JavaDoc(shownConstructor.declaringClass.sourceName()),
3840                            typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false),
3841                            new String JavaDoc(shownConstructor.declaringClass.readableName()),
3842                            typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false) },
3843                    new String JavaDoc[] {
3844                            new String JavaDoc(shownConstructor.declaringClass.sourceName()),
3845                            typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true),
3846                            new String JavaDoc(shownConstructor.declaringClass.shortReadableName()),
3847                            typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true) },
3848                    severity,
3849                    sourceStart,
3850                    sourceEnd);
3851            } else {
3852                this.handle(
3853                    IProblem.JavadocIncorrectArityForParameterizedConstructor,
3854                    new String JavaDoc[] {
3855                            new String JavaDoc(shownConstructor.declaringClass.sourceName()),
3856                            typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false),
3857                            new String JavaDoc(shownConstructor.declaringClass.readableName()),
3858                            typesAsString(false, shownConstructor.typeVariables, false),
3859                            typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false) },
3860                    new String JavaDoc[] {
3861                            new String JavaDoc(shownConstructor.declaringClass.sourceName()),
3862                            typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true),
3863                            new String JavaDoc(shownConstructor.declaringClass.shortReadableName()),
3864                            typesAsString(false, shownConstructor.typeVariables, true),
3865                            typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true) },
3866                    severity,
3867                    sourceStart,
3868                    sourceEnd);
3869            }
3870            return;
3871        case ProblemReasons.ParameterizedMethodTypeMismatch :
3872            severity = computeSeverity(IProblem.JavadocParameterizedConstructorArgumentTypeMismatch);
3873            if (severity == ProblemSeverities.Ignore) return;
3874            problemConstructor = (ProblemMethodBinding) targetConstructor;
3875            shownConstructor = problemConstructor.closestMatch;
3876            this.handle(
3877                IProblem.JavadocParameterizedConstructorArgumentTypeMismatch,
3878                new String JavaDoc[] {
3879                        new String JavaDoc(shownConstructor.declaringClass.sourceName()),
3880                        typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false),
3881                        new String JavaDoc(shownConstructor.declaringClass.readableName()),
3882                        typesAsString(false, ((ParameterizedGenericMethodBinding)shownConstructor).typeArguments, false),
3883                        typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false) },
3884                new String JavaDoc[] {
3885                        new String JavaDoc(shownConstructor.declaringClass.sourceName()),
3886                        typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true),
3887                        new String JavaDoc(shownConstructor.declaringClass.shortReadableName()),
3888                        typesAsString(false, ((ParameterizedGenericMethodBinding)shownConstructor).typeArguments, true),
3889                        typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true) },
3890                severity,
3891                sourceStart,
3892                sourceEnd);
3893            return;
3894        case ProblemReasons.TypeArgumentsForRawGenericMethod :
3895            severity = computeSeverity(IProblem.JavadocTypeArgumentsForRawGenericConstructor);
3896            if (severity == ProblemSeverities.Ignore) return;
3897            problemConstructor = (ProblemMethodBinding) targetConstructor;
3898            shownConstructor = problemConstructor.closestMatch;
3899            this.handle(
3900                IProblem.JavadocTypeArgumentsForRawGenericConstructor,
3901                new String JavaDoc[] {
3902                        new String JavaDoc(shownConstructor.declaringClass.sourceName()),
3903                        typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false),
3904                        new String JavaDoc(shownConstructor.declaringClass.readableName()),
3905                        typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false) },
3906                new String JavaDoc[] {
3907                        new String JavaDoc(shownConstructor.declaringClass.sourceName()),
3908                        typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true),
3909                        new String JavaDoc(shownConstructor.declaringClass.shortReadableName()),
3910                        typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true) },
3911                severity,
3912                sourceStart,
3913                sourceEnd);
3914            return;
3915        case ProblemReasons.NoError : // 0
3916
default :
3917            needImplementation(); // want to fail to see why we were here...
3918
break;
3919    }
3920    int severity = computeSeverity(id);
3921    if (severity == ProblemSeverities.Ignore) return;
3922    this.handle(
3923        id,
3924        new String JavaDoc[] {new String JavaDoc(targetConstructor.declaringClass.readableName()), typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false)},
3925        new String JavaDoc[] {new String JavaDoc(targetConstructor.declaringClass.shortReadableName()), typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true)},
3926        severity,
3927        statement.sourceStart,
3928        statement.sourceEnd);
3929}
3930/*
3931 * Similar implementation than invalidField(FieldReference...)
3932 * Note that following problem id cannot occur for Javadoc:
3933 * - NonStaticReferenceInStaticContext :
3934 * - NonStaticReferenceInConstructorInvocation :
3935 * - ReceiverTypeNotVisible :
3936 */

3937public void javadocInvalidField(int sourceStart, int sourceEnd, Binding fieldBinding, TypeBinding searchedType, int modifiers) {
3938    int id = IProblem.JavadocUndefinedField;
3939    switch (fieldBinding.problemId()) {
3940        case ProblemReasons.NotFound :
3941            id = IProblem.JavadocUndefinedField;
3942            break;
3943        case ProblemReasons.NotVisible :
3944            id = IProblem.JavadocNotVisibleField;
3945            break;
3946        case ProblemReasons.Ambiguous :
3947            id = IProblem.JavadocAmbiguousField;
3948            break;
3949        case ProblemReasons.NoError : // 0
3950
default :
3951            needImplementation(); // want to fail to see why we were here...
3952
break;
3953    }
3954    int severity = computeSeverity(id);
3955    if (severity == ProblemSeverities.Ignore) return;
3956    // report issue
3957
if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3958        String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(fieldBinding.readableName())};
3959        handle(
3960            id,
3961            arguments,
3962            arguments,
3963            severity,
3964            sourceStart,
3965            sourceEnd);
3966    }
3967}
3968public void javadocInvalidMemberTypeQualification(int sourceStart, int sourceEnd, int modifiers){
3969    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3970        this.handle(IProblem.JavadocInvalidMemberTypeQualification, NoArgument, NoArgument, sourceStart, sourceEnd);
3971    }
3972}
3973/*
3974 * Similar implementation than invalidMethod(MessageSend...)
3975 * Note that following problem id cannot occur for Javadoc:
3976 * - NonStaticReferenceInStaticContext :
3977 * - NonStaticReferenceInConstructorInvocation :
3978 * - ReceiverTypeNotVisible :
3979 */

3980public void javadocInvalidMethod(MessageSend messageSend, MethodBinding method, int modifiers) {
3981    if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) return;
3982    // set problem id
3983
ProblemMethodBinding problemMethod = null;
3984    MethodBinding shownMethod = null;
3985    int id = IProblem.JavadocUndefinedMethod; //default...
3986
switch (method.problemId()) {
3987        case ProblemReasons.NotFound :
3988            id = IProblem.JavadocUndefinedMethod;
3989            problemMethod = (ProblemMethodBinding) method;
3990            if (problemMethod.closestMatch != null) {
3991                int severity = computeSeverity(IProblem.JavadocParameterMismatch);
3992                if (severity == ProblemSeverities.Ignore) return;
3993                String JavaDoc closestParameterTypeNames = typesAsString(problemMethod.closestMatch.isVarargs(), problemMethod.closestMatch.parameters, false);
3994                String JavaDoc parameterTypeNames = typesAsString(method.isVarargs(), method.parameters, false);
3995                String JavaDoc closestParameterTypeShortNames = typesAsString(problemMethod.closestMatch.isVarargs(), problemMethod.closestMatch.parameters, true);
3996                String JavaDoc parameterTypeShortNames = typesAsString(method.isVarargs(), method.parameters, true);
3997                if (closestParameterTypeShortNames.equals(parameterTypeShortNames)){
3998                    closestParameterTypeShortNames = closestParameterTypeNames;
3999                    parameterTypeShortNames = parameterTypeNames;
4000                }
4001                this.handle(
4002                    IProblem.JavadocParameterMismatch,
4003                    new String JavaDoc[] {
4004                        new String JavaDoc(problemMethod.closestMatch.declaringClass.readableName()),
4005                        new String JavaDoc(problemMethod.closestMatch.selector),
4006                        closestParameterTypeNames,
4007                        parameterTypeNames
4008                    },
4009                    new String JavaDoc[] {
4010                        new String JavaDoc(problemMethod.closestMatch.declaringClass.shortReadableName()),
4011                        new String JavaDoc(problemMethod.closestMatch.selector),
4012                        closestParameterTypeShortNames,
4013                        parameterTypeShortNames
4014                    },
4015                    severity,
4016                    (int) (messageSend.nameSourcePosition >>> 32),
4017                    (int) messageSend.nameSourcePosition);
4018                return;
4019            }
4020            break;
4021        case ProblemReasons.NotVisible :
4022            id = IProblem.JavadocNotVisibleMethod;
4023            break;
4024        case ProblemReasons.Ambiguous :
4025            id = IProblem.JavadocAmbiguousMethod;
4026            break;
4027        case ProblemReasons.ParameterBoundMismatch :
4028            int severity = computeSeverity(IProblem.JavadocGenericMethodTypeArgumentMismatch);
4029            if (severity == ProblemSeverities.Ignore) return;
4030            problemMethod = (ProblemMethodBinding) method;
4031            ParameterizedGenericMethodBinding substitutedMethod = (ParameterizedGenericMethodBinding) problemMethod.closestMatch;
4032            shownMethod = substitutedMethod.original();
4033            int augmentedLength = problemMethod.parameters.length;
4034            TypeBinding inferredTypeArgument = problemMethod.parameters[augmentedLength-2];
4035            TypeVariableBinding typeParameter = (TypeVariableBinding) problemMethod.parameters[augmentedLength-1];
4036            TypeBinding[] invocationArguments = new TypeBinding[augmentedLength-2]; // remove extra info from the end
4037
System.arraycopy(problemMethod.parameters, 0, invocationArguments, 0, augmentedLength-2);
4038            this.handle(
4039                IProblem.JavadocGenericMethodTypeArgumentMismatch,
4040                new String JavaDoc[] {
4041                        new String JavaDoc(shownMethod.selector),
4042                        typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false),
4043                        new String JavaDoc(shownMethod.declaringClass.readableName()),
4044                        typesAsString(false, invocationArguments, false),
4045                        new String JavaDoc(inferredTypeArgument.readableName()),
4046                        new String JavaDoc(typeParameter.sourceName),
4047                        parameterBoundAsString(typeParameter, false) },
4048                new String JavaDoc[] {
4049                        new String JavaDoc(shownMethod.selector),
4050                        typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true),
4051                        new String JavaDoc(shownMethod.declaringClass.shortReadableName()),
4052                        typesAsString(false, invocationArguments, true),
4053                        new String JavaDoc(inferredTypeArgument.shortReadableName()),
4054                        new String JavaDoc(typeParameter.sourceName),
4055                        parameterBoundAsString(typeParameter, true) },
4056                severity,
4057                (int) (messageSend.nameSourcePosition >>> 32),
4058                (int) messageSend.nameSourcePosition);
4059            return;
4060        case ProblemReasons.TypeParameterArityMismatch :
4061            problemMethod = (ProblemMethodBinding) method;
4062            shownMethod = problemMethod.closestMatch;
4063            boolean noTypeVariables = shownMethod.typeVariables == Binding.NO_TYPE_VARIABLES;
4064            severity = computeSeverity(noTypeVariables ? IProblem.JavadocNonGenericMethod : IProblem.JavadocIncorrectArityForParameterizedMethod);
4065            if (severity == ProblemSeverities.Ignore) return;
4066            if (noTypeVariables) {
4067                this.handle(
4068                    IProblem.JavadocNonGenericMethod,
4069                    new String JavaDoc[] {
4070                            new String JavaDoc(shownMethod.selector),
4071                            typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false),
4072                            new String JavaDoc(shownMethod.declaringClass.readableName()),
4073                            typesAsString(method.isVarargs(), method.parameters, false) },
4074                    new String JavaDoc[] {
4075                            new String JavaDoc(shownMethod.selector),
4076                            typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true),
4077                            new String JavaDoc(shownMethod.declaringClass.shortReadableName()),
4078                            typesAsString(method.isVarargs(), method.parameters, true) },
4079                    severity,
4080                    (int) (messageSend.nameSourcePosition >>> 32),
4081                    (int) messageSend.nameSourcePosition);
4082            } else {
4083                this.handle(
4084                    IProblem.JavadocIncorrectArityForParameterizedMethod,
4085                    new String JavaDoc[] {
4086                            new String JavaDoc(shownMethod.selector),
4087                            typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false),
4088                            new String JavaDoc(shownMethod.declaringClass.readableName()),
4089                            typesAsString(false, shownMethod.typeVariables, false),
4090                            typesAsString(method.isVarargs(), method.parameters, false) },
4091                    new String JavaDoc[] {
4092                            new String JavaDoc(shownMethod.selector),
4093                            typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true),
4094                            new String JavaDoc(shownMethod.declaringClass.shortReadableName()),
4095                            typesAsString(false, shownMethod.typeVariables, true),
4096                            typesAsString(method.isVarargs(), method.parameters, true) },
4097                    severity,
4098                    (int) (messageSend.nameSourcePosition >>> 32),
4099                    (int) messageSend.nameSourcePosition);
4100            }
4101            return;
4102        case ProblemReasons.ParameterizedMethodTypeMismatch :
4103            severity = computeSeverity(IProblem.JavadocParameterizedMethodArgumentTypeMismatch);
4104            if (severity == ProblemSeverities.Ignore) return;
4105            problemMethod = (ProblemMethodBinding) method;
4106            shownMethod = problemMethod.closestMatch;
4107            this.handle(
4108                IProblem.JavadocParameterizedMethodArgumentTypeMismatch,
4109                new String JavaDoc[] {
4110                        new String JavaDoc(shownMethod.selector),
4111                        typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false),
4112                        new String JavaDoc(shownMethod.declaringClass.readableName()),
4113                        typesAsString(false, ((ParameterizedGenericMethodBinding)shownMethod).typeArguments, false),
4114                        typesAsString(method.isVarargs(), method.parameters, false) },
4115                new String JavaDoc[] {
4116                        new String JavaDoc(shownMethod.selector),
4117                        typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true),
4118                        new String JavaDoc(shownMethod.declaringClass.shortReadableName()),
4119                        typesAsString(false, ((ParameterizedGenericMethodBinding)shownMethod).typeArguments, true),
4120                        typesAsString(method.isVarargs(), method.parameters, true) },
4121                severity,
4122                (int) (messageSend.nameSourcePosition >>> 32),
4123                (int) messageSend.nameSourcePosition);
4124            return;
4125        case ProblemReasons.TypeArgumentsForRawGenericMethod :
4126            severity = computeSeverity(IProblem.JavadocTypeArgumentsForRawGenericMethod);
4127            if (severity == ProblemSeverities.Ignore) return;
4128            problemMethod = (ProblemMethodBinding) method;
4129            shownMethod = problemMethod.closestMatch;
4130            this.handle(
4131                IProblem.JavadocTypeArgumentsForRawGenericMethod,
4132                new String JavaDoc[] {
4133                        new String JavaDoc(shownMethod.selector),
4134                        typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false),
4135                        new String JavaDoc(shownMethod.declaringClass.readableName()),
4136                        typesAsString(method.isVarargs(), method.parameters, false) },
4137                new String JavaDoc[] {
4138                        new String JavaDoc(shownMethod.selector),
4139                        typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true),
4140                        new String JavaDoc(shownMethod.declaringClass.shortReadableName()),
4141                        typesAsString(method.isVarargs(), method.parameters, true) },
4142                severity,
4143                (int) (messageSend.nameSourcePosition >>> 32),
4144                (int) messageSend.nameSourcePosition);
4145            return;
4146        case ProblemReasons.NoError : // 0
4147
default :
4148            needImplementation(); // want to fail to see why we were here...
4149
break;
4150    }
4151    int severity = computeSeverity(id);
4152    if (severity == ProblemSeverities.Ignore) return;
4153    // report issue
4154
this.handle(
4155        id,
4156        new String JavaDoc[] {
4157            new String JavaDoc(method.declaringClass.readableName()),
4158            new String JavaDoc(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
4159        new String JavaDoc[] {
4160            new String JavaDoc(method.declaringClass.shortReadableName()),
4161            new String JavaDoc(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
4162        severity,
4163        (int) (messageSend.nameSourcePosition >>> 32),
4164        (int) messageSend.nameSourcePosition);
4165}
4166public void javadocInvalidParamTagName(int sourceStart, int sourceEnd) {
4167    this.handle(IProblem.JavadocInvalidParamTagName, NoArgument, NoArgument, sourceStart, sourceEnd);
4168}
4169public void javadocInvalidParamTypeParameter(int sourceStart, int sourceEnd) {
4170    this.handle(IProblem.JavadocInvalidParamTagTypeParameter, NoArgument, NoArgument, sourceStart, sourceEnd);
4171}
4172public void javadocInvalidReference(int sourceStart, int sourceEnd) {
4173    this.handle(IProblem.JavadocInvalidSeeReference, NoArgument, NoArgument, sourceStart, sourceEnd);
4174}
4175public void javadocInvalidSeeReferenceArgs(int sourceStart, int sourceEnd) {
4176    this.handle(IProblem.JavadocInvalidSeeArgs, NoArgument, NoArgument, sourceStart, sourceEnd);
4177}
4178public void javadocInvalidSeeUrlReference(int sourceStart, int sourceEnd) {
4179    this.handle(IProblem.JavadocInvalidSeeHref, NoArgument, NoArgument, sourceStart, sourceEnd);
4180}
4181public void javadocInvalidTag(int sourceStart, int sourceEnd) {
4182    this.handle(IProblem.JavadocInvalidTag, NoArgument, NoArgument, sourceStart, sourceEnd);
4183}
4184public void javadocInvalidThrowsClass(int sourceStart, int sourceEnd) {
4185    this.handle(IProblem.JavadocInvalidThrowsClass, NoArgument, NoArgument, sourceStart, sourceEnd);
4186}
4187public void javadocInvalidThrowsClassName(TypeReference typeReference, int modifiers) {
4188    int severity = computeSeverity(IProblem.JavadocInvalidThrowsClassName);
4189    if (severity == ProblemSeverities.Ignore) return;
4190    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
4191        String JavaDoc[] arguments = new String JavaDoc[] {String.valueOf(typeReference.resolvedType.sourceName())};
4192        this.handle(
4193            IProblem.JavadocInvalidThrowsClassName,
4194            arguments,
4195            arguments,
4196            severity,
4197            typeReference.sourceStart,
4198            typeReference.sourceEnd);
4199    }
4200}
4201public void javadocInvalidType(ASTNode location, TypeBinding type, int modifiers) {
4202    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
4203        int id = IProblem.JavadocUndefinedType; // default
4204
switch (type.problemId()) {
4205            case ProblemReasons.NotFound :
4206                id = IProblem.JavadocUndefinedType;
4207                break;
4208            case ProblemReasons.NotVisible :
4209                id = IProblem.JavadocNotVisibleType;
4210                break;
4211            case ProblemReasons.Ambiguous :
4212                id = IProblem.JavadocAmbiguousType;
4213                break;
4214            case ProblemReasons.InternalNameProvided :
4215                id = IProblem.JavadocInternalTypeNameProvided;
4216                break;
4217            case ProblemReasons.InheritedNameHidesEnclosingName :
4218                id = IProblem.JavadocInheritedNameHidesEnclosingTypeName;
4219                break;
4220            case ProblemReasons.NonStaticReferenceInStaticContext :
4221                id = IProblem.JavadocNonStaticTypeFromStaticInvocation;
4222                break;
4223            case ProblemReasons.NoError : // 0
4224
default :
4225                needImplementation(); // want to fail to see why we were here...
4226
break;
4227        }
4228        int severity = computeSeverity(id);
4229        if (severity == ProblemSeverities.Ignore) return;
4230        this.handle(
4231            id,
4232            new String JavaDoc[] {new String JavaDoc(type.readableName())},
4233            new String JavaDoc[] {new String JavaDoc(type.shortReadableName())},
4234            severity,
4235            location.sourceStart,
4236            location.sourceEnd);
4237    }
4238}
4239public void javadocInvalidValueReference(int sourceStart, int sourceEnd, int modifiers) {
4240    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
4241        this.handle(IProblem.JavadocInvalidValueReference, NoArgument, NoArgument, sourceStart, sourceEnd);
4242}
4243public void javadocMalformedSeeReference(int sourceStart, int sourceEnd) {
4244    this.handle(IProblem.JavadocMalformedSeeReference, NoArgument, NoArgument, sourceStart, sourceEnd);
4245}
4246public void javadocMissing(int sourceStart, int sourceEnd, int modifiers){
4247    int severity = computeSeverity(IProblem.JavadocMissing);
4248    if (severity == ProblemSeverities.Ignore) return;
4249    boolean overriding = (modifiers & (ExtraCompilerModifiers.AccImplementing|ExtraCompilerModifiers.AccOverriding)) != 0;
4250    boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocComments) != ProblemSeverities.Ignore)
4251                    && (!overriding || this.options.reportMissingJavadocCommentsOverriding);
4252    if (report) {
4253        String JavaDoc arg = javadocVisibilityArgument(this.options.reportMissingJavadocCommentsVisibility, modifiers);
4254        if (arg != null) {
4255            String JavaDoc[] arguments = new String JavaDoc[] { arg };
4256            this.handle(
4257                IProblem.JavadocMissing,
4258                arguments,
4259                arguments,
4260                severity,
4261                sourceStart,
4262                sourceEnd);
4263        }
4264    }
4265}
4266public void javadocMissingHashCharacter(int sourceStart, int sourceEnd, String JavaDoc ref){
4267    int severity = computeSeverity(IProblem.JavadocMissingHashCharacter);
4268    if (severity == ProblemSeverities.Ignore) return;
4269    String JavaDoc[] arguments = new String JavaDoc[] { ref };
4270    this.handle(
4271        IProblem.JavadocMissingHashCharacter,
4272        arguments,
4273        arguments,
4274        severity,
4275        sourceStart,
4276        sourceEnd);
4277}
4278public void javadocMissingIdentifier(int sourceStart, int sourceEnd, int modifiers){
4279    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
4280        this.handle(IProblem.JavadocMissingIdentifier, NoArgument, NoArgument, sourceStart, sourceEnd);
4281}
4282public void javadocMissingParamName(int sourceStart, int sourceEnd, int modifiers){
4283    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
4284        this.handle(IProblem.JavadocMissingParamName, NoArgument, NoArgument, sourceStart, sourceEnd);
4285}
4286public void javadocMissingParamTag(char[] name, int sourceStart, int sourceEnd, int modifiers) {
4287    int severity = computeSeverity(IProblem.JavadocMissingParamTag);
4288    if (severity == ProblemSeverities.Ignore) return;
4289    boolean overriding = (modifiers & (ExtraCompilerModifiers.AccImplementing|ExtraCompilerModifiers.AccOverriding)) != 0;
4290    boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore)
4291                    && (!overriding || this.options.reportMissingJavadocTagsOverriding);
4292    if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) {
4293        String JavaDoc[] arguments = new String JavaDoc[] { String.valueOf(name) };
4294        this.handle(
4295            IProblem.JavadocMissingParamTag,
4296            arguments,
4297            arguments,
4298            severity,
4299            sourceStart,
4300            sourceEnd);
4301    }
4302}
4303public void javadocMissingReference(int sourceStart, int sourceEnd, int modifiers){
4304    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
4305        this.handle(IProblem.JavadocMissingSeeReference, NoArgument, NoArgument, sourceStart, sourceEnd);
4306}
4307public void javadocMissingReturnTag(int sourceStart, int sourceEnd, int modifiers){
4308    boolean overriding = (modifiers & (ExtraCompilerModifiers.AccImplementing|ExtraCompilerModifiers.AccOverriding)) != 0;
4309    boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore)
4310                    && (!overriding || this.options.reportMissingJavadocTagsOverriding);
4311    if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) {
4312        this.handle(IProblem.JavadocMissingReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd);
4313    }
4314}
4315public void javadocMissingThrowsClassName(int sourceStart, int sourceEnd, int modifiers){
4316    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
4317        this.handle(IProblem.JavadocMissingThrowsClassName, NoArgument, NoArgument, sourceStart, sourceEnd);
4318}
4319public void javadocMissingThrowsTag(TypeReference typeRef, int modifiers){
4320    int severity = computeSeverity(IProblem.JavadocMissingThrowsTag);
4321    if (severity == ProblemSeverities.Ignore) return;
4322    boolean overriding = (modifiers & (ExtraCompilerModifiers.AccImplementing|ExtraCompilerModifiers.AccOverriding)) != 0;
4323    boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore)
4324                    && (!overriding || this.options.reportMissingJavadocTagsOverriding);
4325    if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) {
4326        String JavaDoc[] arguments = new String JavaDoc[] { String.valueOf(typeRef.resolvedType.sourceName()) };
4327        this.handle(
4328            IProblem.JavadocMissingThrowsTag,
4329            arguments,
4330            arguments,
4331            severity,
4332            typeRef.sourceStart,
4333            typeRef.sourceEnd);
4334    }
4335}
4336public void javadocUndeclaredParamTagName(char[] token, int sourceStart, int sourceEnd, int modifiers) {
4337    int severity = computeSeverity(IProblem.JavadocInvalidParamName);
4338    if (severity == ProblemSeverities.Ignore) return;
4339    if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
4340        String JavaDoc[] arguments = new String JavaDoc[] {String.valueOf(token)};
4341        this.handle(
4342            IProblem.JavadocInvalidParamName,
4343            arguments,
4344            arguments,
4345            severity,
4346            sourceStart,
4347            sourceEnd);
4348    }
4349}
4350public void javadocUnexpectedTag(int sourceStart, int sourceEnd) {
4351    this.handle(IProblem.JavadocUnexpectedTag, NoArgument, NoArgument, sourceStart, sourceEnd);
4352}
4353public void javadocUnexpectedText(int sourceStart, int sourceEnd) {
4354    this.handle(IProblem.JavadocUnexpectedText, NoArgument, NoArgument, sourceStart, sourceEnd);
4355}
4356public void javadocUnterminatedInlineTag(int sourceStart, int sourceEnd) {
4357    this.handle(IProblem.JavadocUnterminatedInlineTag, NoArgument, NoArgument, sourceStart, sourceEnd);
4358}
4359private boolean javadocVisibility(int visibility, int modifiers) {
4360    if (modifiers < 0) return true;
4361    switch (modifiers & ExtraCompilerModifiers.AccVisibilityMASK) {
4362        case ClassFileConstants.AccPublic :
4363            return true;
4364        case ClassFileConstants.AccProtected:
4365            return (visibility != ClassFileConstants.AccPublic);
4366        case ClassFileConstants.AccDefault:
4367            return (visibility == ClassFileConstants.AccDefault || visibility == ClassFileConstants.AccPrivate);
4368        case ClassFileConstants.AccPrivate:
4369            return (visibility == ClassFileConstants.AccPrivate);
4370    }
4371    return true;
4372}
4373private String JavaDoc javadocVisibilityArgument(int visibility, int modifiers) {
4374    String JavaDoc argument = null;
4375    switch (modifiers & ExtraCompilerModifiers.AccVisibilityMASK) {
4376        case ClassFileConstants.AccPublic :
4377            argument = CompilerOptions.PUBLIC;
4378            break;
4379        case ClassFileConstants.AccProtected:
4380            if (visibility != ClassFileConstants.AccPublic) {
4381                argument = CompilerOptions.PROTECTED;
4382            }
4383            break;
4384        case ClassFileConstants.AccDefault:
4385            if (visibility == ClassFileConstants.AccDefault || visibility == ClassFileConstants.AccPrivate) {
4386                argument = CompilerOptions.DEFAULT;
4387            }
4388            break;
4389        case ClassFileConstants.AccPrivate:
4390            if (visibility == ClassFileConstants.AccPrivate) {
4391                argument = CompilerOptions.PRIVATE;
4392            }
4393            break;
4394    }
4395    return argument;
4396}
4397public void localVariableHiding(LocalDeclaration local, Binding hiddenVariable, boolean isSpecialArgHidingField) {
4398    if (hiddenVariable instanceof LocalVariableBinding) {
4399        int id = (local instanceof Argument)
4400                ? IProblem.ArgumentHidingLocalVariable
4401                : IProblem.LocalVariableHidingLocalVariable;
4402        int severity = computeSeverity(id);
4403        if (severity == ProblemSeverities.Ignore) return;
4404        String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(local.name) };
4405        this.handle(
4406            id,
4407            arguments,
4408            arguments,
4409            severity,
4410            nodeSourceStart(hiddenVariable, local),
4411            nodeSourceEnd(hiddenVariable, local));
4412    } else if (hiddenVariable instanceof FieldBinding) {
4413        if (isSpecialArgHidingField && !this.options.reportSpecialParameterHidingField){
4414            return;
4415        }
4416        int id = (local instanceof Argument)
4417                ? IProblem.ArgumentHidingField
4418                : IProblem.LocalVariableHidingField;
4419        int severity = computeSeverity(id);
4420        if (severity == ProblemSeverities.Ignore) return;
4421        FieldBinding field = (FieldBinding) hiddenVariable;
4422        this.handle(
4423            id,
4424            new String JavaDoc[] {new String JavaDoc(local.name) , new String JavaDoc(field.declaringClass.readableName()) },
4425            new String JavaDoc[] {new String JavaDoc(local.name), new String JavaDoc(field.declaringClass.shortReadableName()) },
4426            severity,
4427            local.sourceStart,
4428            local.sourceEnd);
4429    }
4430}
4431public void localVariableNonNullComparedToNull(LocalVariableBinding local, ASTNode location) {
4432    int severity = computeSeverity(IProblem.NonNullLocalVariableComparisonYieldsFalse);
4433    if (severity == ProblemSeverities.Ignore) return;
4434    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(local.name) };
4435    this.handle(
4436        IProblem.NonNullLocalVariableComparisonYieldsFalse,
4437        arguments,
4438        arguments,
4439        severity,
4440        nodeSourceStart(local, location),
4441        nodeSourceEnd(local, location));
4442}
4443public void localVariableNullComparedToNonNull(LocalVariableBinding local, ASTNode location) {
4444    int severity = computeSeverity(IProblem.NullLocalVariableComparisonYieldsFalse);
4445    if (severity == ProblemSeverities.Ignore) return;
4446    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(local.name) };
4447    this.handle(
4448        IProblem.NullLocalVariableComparisonYieldsFalse,
4449        arguments,
4450        arguments,
4451        severity,
4452        nodeSourceStart(local, location),
4453        nodeSourceEnd(local, location));
4454}
4455public void localVariableNullInstanceof(LocalVariableBinding local, ASTNode location) {
4456    int severity = computeSeverity(IProblem.NullLocalVariableInstanceofYieldsFalse);
4457    if (severity == ProblemSeverities.Ignore) return;
4458    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(local.name) };
4459    this.handle(
4460        IProblem.NullLocalVariableInstanceofYieldsFalse,
4461        arguments,
4462        arguments,
4463        severity,
4464        nodeSourceStart(local, location),
4465        nodeSourceEnd(local, location));
4466}
4467public void localVariableNullReference(LocalVariableBinding local, ASTNode location) {
4468    int severity = computeSeverity(IProblem.NullLocalVariableReference);
4469    if (severity == ProblemSeverities.Ignore) return;
4470    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(local.name) };
4471    this.handle(
4472        IProblem.NullLocalVariableReference,
4473        arguments,
4474        arguments,
4475        severity,
4476        nodeSourceStart(local, location),
4477        nodeSourceEnd(local, location));
4478}
4479public void localVariablePotentialNullReference(LocalVariableBinding local, ASTNode location) {
4480    int severity = computeSeverity(IProblem.PotentialNullLocalVariableReference);
4481    if (severity == ProblemSeverities.Ignore) return;
4482    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(local.name)};
4483    this.handle(
4484        IProblem.PotentialNullLocalVariableReference,
4485        arguments,
4486        arguments,
4487        severity,
4488        nodeSourceStart(local, location),
4489        nodeSourceEnd(local, location));
4490}
4491public void localVariableRedundantCheckOnNonNull(LocalVariableBinding local, ASTNode location) {
4492    int severity = computeSeverity(IProblem.RedundantNullCheckOnNonNullLocalVariable);
4493    if (severity == ProblemSeverities.Ignore) return;
4494    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(local.name) };
4495    this.handle(
4496        IProblem.RedundantNullCheckOnNonNullLocalVariable,
4497        arguments,
4498        arguments,
4499        severity,
4500        nodeSourceStart(local, location),
4501        nodeSourceEnd(local, location));
4502}
4503public void localVariableRedundantCheckOnNull(LocalVariableBinding local, ASTNode location) {
4504    int severity = computeSeverity(IProblem.RedundantNullCheckOnNullLocalVariable);
4505    if (severity == ProblemSeverities.Ignore) return;
4506    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(local.name) };
4507    this.handle(
4508        IProblem.RedundantNullCheckOnNullLocalVariable,
4509        arguments,
4510        arguments,
4511        severity,
4512        nodeSourceStart(local, location),
4513        nodeSourceEnd(local, location));
4514}
4515public void localVariableRedundantNullAssignment(LocalVariableBinding local, ASTNode location) {
4516    int severity = computeSeverity(IProblem.RedundantLocalVariableNullAssignment);
4517    if (severity == ProblemSeverities.Ignore) return;
4518    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(local.name) };
4519    this.handle(
4520        IProblem.RedundantLocalVariableNullAssignment,
4521        arguments,
4522        arguments,
4523        severity,
4524        nodeSourceStart(local, location),
4525        nodeSourceEnd(local, location));
4526}
4527public void methodMustOverride(AbstractMethodDeclaration method) {
4528    MethodBinding binding = method.binding;
4529    this.handle(
4530        this.options.sourceLevel == ClassFileConstants.JDK1_5 ? IProblem.MethodMustOverride : IProblem.MethodMustOverrideOrImplement,
4531        new String JavaDoc[] {new String JavaDoc(binding.selector), typesAsString(binding.isVarargs(), binding.parameters, false), new String JavaDoc(binding.declaringClass.readableName()), },
4532        new String JavaDoc[] {new String JavaDoc(binding.selector), typesAsString(binding.isVarargs(), binding.parameters, true), new String JavaDoc(binding.declaringClass.shortReadableName()),},
4533        method.sourceStart,
4534        method.sourceEnd);
4535}
4536public void methodNameClash(MethodBinding currentMethod, MethodBinding inheritedMethod) {
4537    this.handle(
4538        IProblem.MethodNameClash,
4539        new String JavaDoc[] {
4540            new String JavaDoc(currentMethod.selector),
4541            typesAsString(currentMethod.isVarargs(), currentMethod.parameters, false),
4542            new String JavaDoc(currentMethod.declaringClass.readableName()),
4543            typesAsString(inheritedMethod.isVarargs(), inheritedMethod.parameters, false),
4544            new String JavaDoc(inheritedMethod.declaringClass.readableName()),
4545         },
4546        new String JavaDoc[] {
4547            new String JavaDoc(currentMethod.selector),
4548            typesAsString(currentMethod.isVarargs(), currentMethod.parameters, true),
4549            new String JavaDoc(currentMethod.declaringClass.shortReadableName()),
4550            typesAsString(inheritedMethod.isVarargs(), inheritedMethod.parameters, true),
4551            new String JavaDoc(inheritedMethod.declaringClass.shortReadableName()),
4552         },
4553        currentMethod.sourceStart(),
4554        currentMethod.sourceEnd());
4555}
4556public void methodNeedBody(AbstractMethodDeclaration methodDecl) {
4557    this.handle(
4558        IProblem.MethodRequiresBody,
4559        NoArgument,
4560        NoArgument,
4561        methodDecl.sourceStart,
4562        methodDecl.sourceEnd);
4563}
4564public void methodNeedingNoBody(MethodDeclaration methodDecl) {
4565    this.handle(
4566        ((methodDecl.modifiers & ClassFileConstants.AccNative) != 0) ? IProblem.BodyForNativeMethod : IProblem.BodyForAbstractMethod,
4567        NoArgument,
4568        NoArgument,
4569        methodDecl.sourceStart,
4570        methodDecl.sourceEnd);
4571}
4572
4573public void methodWithConstructorName(MethodDeclaration methodDecl) {
4574    this.handle(
4575        IProblem.MethodButWithConstructorName,
4576        NoArgument,
4577        NoArgument,
4578        methodDecl.sourceStart,
4579        methodDecl.sourceEnd);
4580}
4581public void missingDeprecatedAnnotationForField(FieldDeclaration field) {
4582    int severity = computeSeverity(IProblem.FieldMissingDeprecatedAnnotation);
4583    if (severity == ProblemSeverities.Ignore) return;
4584    FieldBinding binding = field.binding;
4585    this.handle(
4586        IProblem.FieldMissingDeprecatedAnnotation,
4587        new String JavaDoc[] {new String JavaDoc(binding.declaringClass.readableName()), new String JavaDoc(binding.name), },
4588        new String JavaDoc[] {new String JavaDoc(binding.declaringClass.shortReadableName()), new String JavaDoc(binding.name), },
4589        severity,
4590        nodeSourceStart(binding, field),
4591        nodeSourceEnd(binding, field));
4592}
4593public void missingDeprecatedAnnotationForMethod(AbstractMethodDeclaration method) {
4594    int severity = computeSeverity(IProblem.MethodMissingDeprecatedAnnotation);
4595    if (severity == ProblemSeverities.Ignore) return;
4596    MethodBinding binding = method.binding;
4597    this.handle(
4598        IProblem.MethodMissingDeprecatedAnnotation,
4599        new String JavaDoc[] {new String JavaDoc(binding.selector), typesAsString(binding.isVarargs(), binding.parameters, false), new String JavaDoc(binding.declaringClass.readableName()), },
4600        new String JavaDoc[] {new String JavaDoc(binding.selector), typesAsString(binding.isVarargs(), binding.parameters, true), new String JavaDoc(binding.declaringClass.shortReadableName()),},
4601        severity,
4602        method.sourceStart,
4603        method.sourceEnd);
4604}
4605public void missingDeprecatedAnnotationForType(TypeDeclaration type) {
4606    int severity = computeSeverity(IProblem.TypeMissingDeprecatedAnnotation);
4607    if (severity == ProblemSeverities.Ignore) return;
4608    TypeBinding binding = type.binding;
4609    this.handle(
4610        IProblem.TypeMissingDeprecatedAnnotation,
4611        new String JavaDoc[] {new String JavaDoc(binding.readableName()), },
4612        new String JavaDoc[] {new String JavaDoc(binding.shortReadableName()),},
4613        severity,
4614        type.sourceStart,
4615        type.sourceEnd);
4616}
4617public void missingEnumConstantCase(SwitchStatement switchStatement, FieldBinding enumConstant) {
4618    this.handle(
4619        IProblem.MissingEnumConstantCase,
4620        new String JavaDoc[] {new String JavaDoc(enumConstant.declaringClass.readableName()), new String JavaDoc(enumConstant.name) },
4621        new String JavaDoc[] {new String JavaDoc(enumConstant.declaringClass.shortReadableName()), new String JavaDoc(enumConstant.name) },
4622        switchStatement.expression.sourceStart,
4623        switchStatement.expression.sourceEnd);
4624}
4625public void missingOverrideAnnotation(AbstractMethodDeclaration method) {
4626    int severity = computeSeverity(IProblem.MissingOverrideAnnotation);
4627    if (severity == ProblemSeverities.Ignore) return;
4628    MethodBinding binding = method.binding;
4629    this.handle(
4630        IProblem.MissingOverrideAnnotation,
4631        new String JavaDoc[] {new String JavaDoc(binding.selector), typesAsString(binding.isVarargs(), binding.parameters, false), new String JavaDoc(binding.declaringClass.readableName()), },
4632        new String JavaDoc[] {new String JavaDoc(binding.selector), typesAsString(binding.isVarargs(), binding.parameters, true), new String JavaDoc(binding.declaringClass.shortReadableName()),},
4633        severity,
4634        method.sourceStart,
4635        method.sourceEnd);
4636}
4637public void missingReturnType(AbstractMethodDeclaration methodDecl) {
4638    this.handle(
4639        IProblem.MissingReturnType,
4640        NoArgument,
4641        NoArgument,
4642        methodDecl.sourceStart,
4643        methodDecl.sourceEnd);
4644}
4645public void missingSemiColon(Expression expression){
4646    this.handle(
4647        IProblem.MissingSemiColon,
4648        NoArgument,
4649        NoArgument,
4650        expression.sourceStart,
4651        expression.sourceEnd);
4652}
4653
4654public void missingSerialVersion(TypeDeclaration typeDecl) {
4655    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(typeDecl.name)};
4656    this.handle(
4657        IProblem.MissingSerialVersion,
4658        arguments,
4659        arguments,
4660        typeDecl.sourceStart,
4661        typeDecl.sourceEnd);
4662}
4663public void missingValueForAnnotationMember(Annotation annotation, char[] memberName) {
4664    String JavaDoc memberString = new String JavaDoc(memberName);
4665    this.handle(
4666        IProblem.MissingValueForAnnotationMember,
4667        new String JavaDoc[] {new String JavaDoc(annotation.resolvedType.readableName()), memberString },
4668        new String JavaDoc[] {new String JavaDoc(annotation.resolvedType.shortReadableName()), memberString},
4669        annotation.sourceStart,
4670        annotation.sourceEnd);
4671}
4672public void mustDefineDimensionsOrInitializer(ArrayAllocationExpression expression) {
4673    this.handle(
4674        IProblem.MustDefineEitherDimensionExpressionsOrInitializer,
4675        NoArgument,
4676        NoArgument,
4677        expression.sourceStart,
4678        expression.sourceEnd);
4679}
4680public void mustSpecifyPackage(CompilationUnitDeclaration compUnitDecl) {
4681    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(compUnitDecl.getFileName())};
4682    this.handle(
4683        IProblem.MustSpecifyPackage,
4684        arguments,
4685        arguments,
4686        compUnitDecl.sourceStart,
4687        compUnitDecl.sourceStart + 1);
4688}
4689public void mustUseAStaticMethod(MessageSend messageSend, MethodBinding method) {
4690    this.handle(
4691        IProblem.StaticMethodRequested,
4692        new String JavaDoc[] {new String JavaDoc(method.declaringClass.readableName()), new String JavaDoc(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
4693        new String JavaDoc[] {new String JavaDoc(method.declaringClass.shortReadableName()), new String JavaDoc(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
4694        messageSend.sourceStart,
4695        messageSend.sourceEnd);
4696}
4697public void nativeMethodsCannotBeStrictfp(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
4698    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName()), new String JavaDoc(methodDecl.selector)};
4699    this.handle(
4700        IProblem.NativeMethodsCannotBeStrictfp,
4701        arguments,
4702        arguments,
4703        methodDecl.sourceStart,
4704        methodDecl.sourceEnd);
4705}
4706public void needImplementation() {
4707    this.abortDueToInternalError(Messages.abort_missingCode);
4708}
4709
4710public void needToEmulateFieldAccess(FieldBinding field, ASTNode location, boolean isReadAccess) {
4711    int id = isReadAccess
4712            ? IProblem.NeedToEmulateFieldReadAccess
4713            : IProblem.NeedToEmulateFieldWriteAccess;
4714    int severity = computeSeverity(id);
4715    if (severity == ProblemSeverities.Ignore) return;
4716    this.handle(
4717        id,
4718        new String JavaDoc[] {new String JavaDoc(field.declaringClass.readableName()), new String JavaDoc(field.name)},
4719        new String JavaDoc[] {new String JavaDoc(field.declaringClass.shortReadableName()), new String JavaDoc(field.name)},
4720        severity,
4721        nodeSourceStart(field, location),
4722        nodeSourceEnd(field, location));
4723}
4724public void needToEmulateMethodAccess(
4725    MethodBinding method,
4726    ASTNode location) {
4727
4728    if (method.isConstructor()) {
4729        int severity = computeSeverity(IProblem.NeedToEmulateConstructorAccess);
4730        if (severity == ProblemSeverities.Ignore) return;
4731        if (method.declaringClass.isEnum())
4732            return; // tolerate emulation for enum constructors, which can only be made private
4733
this.handle(
4734            IProblem.NeedToEmulateConstructorAccess,
4735            new String JavaDoc[] {
4736                new String JavaDoc(method.declaringClass.readableName()),
4737                typesAsString(method.isVarargs(), method.parameters, false)
4738             },
4739            new String JavaDoc[] {
4740                new String JavaDoc(method.declaringClass.shortReadableName()),
4741                typesAsString(method.isVarargs(), method.parameters, true)
4742             },
4743            severity,
4744            location.sourceStart,
4745            location.sourceEnd);
4746        return;
4747    }
4748    int severity = computeSeverity(IProblem.NeedToEmulateMethodAccess);
4749    if (severity == ProblemSeverities.Ignore) return;
4750    this.handle(
4751        IProblem.NeedToEmulateMethodAccess,
4752        new String JavaDoc[] {
4753            new String JavaDoc(method.declaringClass.readableName()),
4754            new String JavaDoc(method.selector),
4755            typesAsString(method.isVarargs(), method.parameters, false)
4756         },
4757        new String JavaDoc[] {
4758            new String JavaDoc(method.declaringClass.shortReadableName()),
4759            new String JavaDoc(method.selector),
4760            typesAsString(method.isVarargs(), method.parameters, true)
4761         },
4762         severity,
4763        location.sourceStart,
4764        location.sourceEnd);
4765}
4766public void noAdditionalBoundAfterTypeVariable(TypeReference boundReference) {
4767    this.handle(
4768        IProblem.NoAdditionalBoundAfterTypeVariable,
4769        new String JavaDoc[] { new String JavaDoc(boundReference.resolvedType.readableName()) },
4770        new String JavaDoc[] { new String JavaDoc(boundReference.resolvedType.shortReadableName()) },
4771        boundReference.sourceStart,
4772        boundReference.sourceEnd);
4773}
4774private int nodeSourceEnd(Binding field, ASTNode node) {
4775    return nodeSourceEnd(field, node, 0);
4776}
4777private int nodeSourceEnd(Binding field, ASTNode node, int index) {
4778    if (node instanceof ArrayTypeReference) {
4779        return ((ArrayTypeReference) node).originalSourceEnd;
4780    } else if (node instanceof QualifiedNameReference) {
4781        QualifiedNameReference ref = (QualifiedNameReference) node;
4782        if (ref.binding == field) {
4783            return (int) (ref.sourcePositions[ref.indexOfFirstFieldBinding-1]);
4784        }
4785        FieldBinding[] otherFields = ref.otherBindings;
4786        if (otherFields != null) {
4787            int offset = ref.indexOfFirstFieldBinding;
4788            for (int i = 0, length = otherFields.length; i < length; i++) {
4789                if (otherFields[i] == field)
4790                    return (int) (ref.sourcePositions[i + offset]);
4791            }
4792        }
4793    } else if (node instanceof ParameterizedQualifiedTypeReference) {
4794        ParameterizedQualifiedTypeReference reference = (ParameterizedQualifiedTypeReference) node;
4795        if (index < reference.sourcePositions.length) {
4796            return (int) reference.sourcePositions[index];
4797        }
4798    } else if (node instanceof ArrayQualifiedTypeReference) {
4799        ArrayQualifiedTypeReference arrayQualifiedTypeReference = (ArrayQualifiedTypeReference) node;
4800        int length = arrayQualifiedTypeReference.sourcePositions.length;
4801        return (int) arrayQualifiedTypeReference.sourcePositions[length - 1];
4802    }
4803    return node.sourceEnd;
4804}
4805private int nodeSourceStart(Binding field, ASTNode node) {
4806    if (node instanceof FieldReference) {
4807        FieldReference fieldReference = (FieldReference) node;
4808        return (int) (fieldReference.nameSourcePosition >> 32);
4809    } else if (node instanceof QualifiedNameReference) {
4810        QualifiedNameReference ref = (QualifiedNameReference) node;
4811        if (ref.binding == field) {
4812            return (int) (ref.sourcePositions[ref.indexOfFirstFieldBinding-1] >> 32);
4813        }
4814        FieldBinding[] otherFields = ref.otherBindings;
4815        if (otherFields != null) {
4816            int offset = ref.indexOfFirstFieldBinding;
4817            for (int i = 0, length = otherFields.length; i < length; i++) {
4818                if (otherFields[i] == field)
4819                    return (int) (ref.sourcePositions[i + offset] >> 32);
4820            }
4821        }
4822    } else if (node instanceof ParameterizedQualifiedTypeReference) {
4823        ParameterizedQualifiedTypeReference reference = (ParameterizedQualifiedTypeReference) node;
4824        return (int) (reference.sourcePositions[0]>>>32);
4825    }
4826    return node.sourceStart;
4827}
4828public void noMoreAvailableSpaceForArgument(LocalVariableBinding local, ASTNode location) {
4829    String JavaDoc[] arguments = new String JavaDoc[]{ new String JavaDoc(local.name) };
4830    this.handle(
4831        local instanceof SyntheticArgumentBinding
4832            ? IProblem.TooManySyntheticArgumentSlots
4833            : IProblem.TooManyArgumentSlots,
4834        arguments,
4835        arguments,
4836        ProblemSeverities.Abort | ProblemSeverities.Error | ProblemSeverities.Fatal,
4837        nodeSourceStart(local, location),
4838        nodeSourceEnd(local, location));
4839}
4840public void noMoreAvailableSpaceForConstant(TypeDeclaration typeDeclaration) {
4841    this.handle(
4842        IProblem.TooManyBytesForStringConstant,
4843        new String JavaDoc[]{ new String JavaDoc(typeDeclaration.binding.readableName())},
4844        new String JavaDoc[]{ new String JavaDoc(typeDeclaration.binding.shortReadableName())},
4845        ProblemSeverities.Abort | ProblemSeverities.Error | ProblemSeverities.Fatal,
4846        typeDeclaration.sourceStart,
4847        typeDeclaration.sourceEnd);
4848}
4849
4850public void noMoreAvailableSpaceForLocal(LocalVariableBinding local, ASTNode location) {
4851    String JavaDoc[] arguments = new String JavaDoc[]{ new String JavaDoc(local.name) };
4852    this.handle(
4853        IProblem.TooManyLocalVariableSlots,
4854        arguments,
4855        arguments,
4856        ProblemSeverities.Abort | ProblemSeverities.Error | ProblemSeverities.Fatal,
4857        nodeSourceStart(local, location),
4858        nodeSourceEnd(local, location));
4859}
4860public void noMoreAvailableSpaceInConstantPool(TypeDeclaration typeDeclaration) {
4861    this.handle(
4862        IProblem.TooManyConstantsInConstantPool,
4863        new String JavaDoc[]{ new String JavaDoc(typeDeclaration.binding.readableName())},
4864        new String JavaDoc[]{ new String JavaDoc(typeDeclaration.binding.shortReadableName())},
4865        ProblemSeverities.Abort | ProblemSeverities.Error | ProblemSeverities.Fatal,
4866        typeDeclaration.sourceStart,
4867        typeDeclaration.sourceEnd);
4868}
4869
4870public void nonExternalizedStringLiteral(ASTNode location) {
4871    this.handle(
4872        IProblem.NonExternalizedStringLiteral,
4873        NoArgument,
4874        NoArgument,
4875        location.sourceStart,
4876        location.sourceEnd);
4877}
4878public void nonGenericTypeCannotBeParameterized(ASTNode location, TypeBinding type, TypeBinding[] argumentTypes) {
4879    this.nonGenericTypeCannotBeParameterized(0, location, type, argumentTypes);
4880}
4881public void nonGenericTypeCannotBeParameterized(int index, ASTNode location, TypeBinding type, TypeBinding[] argumentTypes) {
4882    if (location == null) { // binary case
4883
this.handle(
4884            IProblem.NonGenericType,
4885            new String JavaDoc[] {new String JavaDoc(type.readableName()), typesAsString(false, argumentTypes, false)},
4886            new String JavaDoc[] {new String JavaDoc(type.shortReadableName()), typesAsString(false, argumentTypes, true)},
4887            ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
4888            0,
4889            0);
4890        return;
4891    }
4892    this.handle(
4893        IProblem.NonGenericType,
4894        new String JavaDoc[] {new String JavaDoc(type.readableName()), typesAsString(false, argumentTypes, false)},
4895        new String JavaDoc[] {new String JavaDoc(type.shortReadableName()), typesAsString(false, argumentTypes, true)},
4896        nodeSourceStart(null, location),
4897        nodeSourceEnd(null, location, index));
4898}
4899public void nonStaticAccessToStaticField(ASTNode location, FieldBinding field) {
4900    int severity = computeSeverity(IProblem.NonStaticAccessToStaticField);
4901    if (severity == ProblemSeverities.Ignore) return;
4902    this.handle(
4903        IProblem.NonStaticAccessToStaticField,
4904        new String JavaDoc[] {new String JavaDoc(field.declaringClass.readableName()), new String JavaDoc(field.name)},
4905        new String JavaDoc[] {new String JavaDoc(field.declaringClass.shortReadableName()), new String JavaDoc(field.name)},
4906        severity,
4907        nodeSourceStart(field, location),
4908        nodeSourceEnd(field, location));
4909}
4910public void nonStaticAccessToStaticMethod(ASTNode location, MethodBinding method) {
4911    this.handle(
4912        IProblem.NonStaticAccessToStaticMethod,
4913        new String JavaDoc[] {new String JavaDoc(method.declaringClass.readableName()), new String JavaDoc(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
4914        new String JavaDoc[] {new String JavaDoc(method.declaringClass.shortReadableName()), new String JavaDoc(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
4915        location.sourceStart,
4916        location.sourceEnd);
4917}
4918public void nonStaticContextForEnumMemberType(SourceTypeBinding type) {
4919    String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(type.sourceName())};
4920    this.handle(
4921        IProblem.NonStaticContextForEnumMemberType,
4922        arguments,
4923        arguments,
4924        type.sourceStart(),
4925        type.sourceEnd());
4926}
4927public void noSuchEnclosingInstance(TypeBinding targetType, ASTNode location, boolean isConstructorCall) {
4928
4929    int id;
4930
4931    if (isConstructorCall) {
4932        //28 = No enclosing instance of type {0} is available due to some intermediate constructor invocation
4933
id = IProblem.EnclosingInstanceInConstructorCall;
4934    } else if ((location instanceof ExplicitConstructorCall)
4935                && ((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper) {
4936        //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}).
4937
id = IProblem.MissingEnclosingInstanceForConstructorCall;
4938    } else if (location instanceof AllocationExpression
4939                && (((AllocationExpression) location).binding.declaringClass.isMemberType()
4940                    || (((AllocationExpression) location).binding.declaringClass.isAnonymousType()
4941                        && ((AllocationExpression) location).binding.declaringClass.superclass().isMemberType()))) {
4942        //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}).
4943
id = IProblem.MissingEnclosingInstance;
4944    } else { // default
4945
//22 = No enclosing instance of the type {0} is accessible in scope
4946
id = IProblem.IncorrectEnclosingInstanceReference;
4947    }
4948
4949    this.handle(
4950        id,
4951        new String JavaDoc[] { new String JavaDoc(targetType.readableName())},
4952        new String JavaDoc[] { new String JavaDoc(targetType.shortReadableName())},
4953        location.sourceStart,
4954        location.sourceEnd);
4955}
4956public void notCompatibleTypesError(EqualExpression expression, TypeBinding leftType, TypeBinding rightType) {
4957    String JavaDoc leftName = new String JavaDoc(leftType.readableName());
4958    String JavaDoc rightName = new String JavaDoc(rightType.readableName());
4959    String JavaDoc leftShortName = new String JavaDoc(leftType.shortReadableName());
4960    String JavaDoc rightShortName = new String JavaDoc(rightType.shortReadableName());
4961    if (leftShortName.equals(rightShortName)){
4962        leftShortName = leftName;
4963        rightShortName = rightName;
4964    }
4965    this.handle(
4966        IProblem.IncompatibleTypesInEqualityOperator,
4967        new String JavaDoc[] {leftName, rightName },
4968        new String JavaDoc[] {leftShortName, rightShortName },
4969        expression.sourceStart,
4970        expression.sourceEnd);
4971}
4972public void notCompatibleTypesError(InstanceOfExpression expression, TypeBinding leftType, TypeBinding rightType) {
4973    String JavaDoc leftName = new String JavaDoc(leftType.readableName());
4974    String JavaDoc rightName = new String JavaDoc(rightType.readableName());
4975    String JavaDoc leftShortName = new String JavaDoc(leftType.shortReadableName());
4976    String JavaDoc rightShortName = new String JavaDoc(rightType.shortReadableName());
4977    if (leftShortName.equals(rightShortName)){
4978        leftShortName = leftName;
4979        rightShortName = rightName;
4980    }
4981    this.handle(
4982        IProblem.IncompatibleTypesInConditionalOperator,
4983        new String JavaDoc[] {leftName, rightName },
4984        new String JavaDoc[] {leftShortName, rightShortName },
4985        expression.sourceStart,
4986        expression.sourceEnd);
4987}
4988public void notCompatibleTypesErrorInForeach(Expression expression, TypeBinding leftType, TypeBinding rightType) {
4989    String JavaDoc leftName = new String JavaDoc(leftType.readableName());
4990    String JavaDoc rightName = new String JavaDoc(rightType.readableName());
4991    String JavaDoc leftShortName = new String JavaDoc(leftType.shortReadableName());
4992    String JavaDoc rightShortName = new String JavaDoc(rightType.shortReadableName());
4993    if (leftShortName.equals(rightShortName)){
4994        leftShortName = leftName;
4995        rightShortName = rightName;
4996    }
4997    this.handle(
4998        IProblem.IncompatibleTypesInForeach,
4999        new String JavaDoc[] {leftName, rightName },
5000        new String JavaDoc[] {leftShortName, rightShortName },
5001        expression.sourceStart,
5002        expression.sourceEnd);
5003}
5004public void objectCannotBeGeneric(TypeDeclaration typeDecl) {
5005    this.handle(
5006        IProblem.ObjectCannotBeGeneric,
5007        NoArgument,
5008        NoArgument,
5009        typeDecl.typeParameters[0].sourceStart,
5010        typeDecl.typeParameters[typeDecl.typeParameters.length-1].sourceEnd);
5011}
5012public void objectCannotHaveSuperTypes(SourceTypeBinding type) {
5013    this.handle(
5014        IProblem.ObjectCannotHaveSuperTypes,
5015        NoArgument,
5016        NoArgument,
5017        type.sourceStart(),
5018        type.sourceEnd());
5019}
5020public void objectMustBeClass(SourceTypeBinding type) {
5021    this.handle(
5022        IProblem.ObjectMustBeClass,
5023        NoArgument,
5024        NoArgument,
5025        type.sourceStart(),
5026        type.sourceEnd());
5027}
5028public void operatorOnlyValidOnNumericType(CompoundAssignment assignment, TypeBinding leftType, TypeBinding rightType) {
5029    String JavaDoc leftName = new String JavaDoc(leftType.readableName());
5030    String JavaDoc rightName = new String JavaDoc(rightType.readableName());
5031    String JavaDoc leftShortName = new String JavaDoc(leftType.shortReadableName());
5032    String JavaDoc rightShortName = new String JavaDoc(rightType.shortReadableName());
5033    if (leftShortName.equals(rightShortName)){
5034        leftShortName = leftName;
5035        rightShortName = rightName;
5036    }
5037    this.handle(
5038        IProblem.TypeMismatch,
5039        new String JavaDoc[] {leftName, rightName },
5040        new String JavaDoc[] {leftShortName, rightShortName },
5041        assignment.sourceStart,
5042        assignment.sourceEnd);
5043}
5044public void overridesDeprecatedMethod(MethodBinding localMethod, MethodBinding inheritedMethod) {
5045    this.handle(
5046        IProblem.OverridingDeprecatedMethod,
5047        new String JavaDoc[] {
5048            new String JavaDoc(
5049                    CharOperation.concat(
5050                        localMethod.declaringClass.readableName(),
5051                        localMethod.readableName(),
5052                        '.')),
5053            new String JavaDoc(inheritedMethod.declaringClass.readableName())},
5054        new String JavaDoc[] {
5055            new String JavaDoc(
5056                    CharOperation.concat(
5057                        localMethod.declaringClass.shortReadableName(),
5058                        localMethod.shortReadableName(),
5059                        '.')),
5060            new String JavaDoc(inheritedMethod.declaringClass.shortReadableName())},
5061        localMethod.sourceStart(),
5062        localMethod.sourceEnd());
5063}
5064public void overridesMethodWithoutSuperInvocation(MethodBinding localMethod) {
5065    this.handle(
5066        IProblem.OverridingMethodWithoutSuperInvocation,
5067        new String JavaDoc[] {
5068            new String JavaDoc(
5069                    CharOperation.concat(
5070                        localMethod.declaringClass.readableName(),
5071                        localMethod.readableName(),
5072                        '.'))
5073            },
5074        new String JavaDoc[] {
5075            new String JavaDoc(
5076                    CharOperation.concat(
5077                        localMethod.declaringClass.shortReadableName(),
5078                        localMethod.shortReadableName(),
5079                        '.'))
5080            },
5081        localMethod.sourceStart(),
5082        localMethod.sourceEnd());
5083}
5084public void overridesPackageDefaultMethod(MethodBinding localMethod, MethodBinding inheritedMethod) {
5085    this.handle(
5086        IProblem.OverridingNonVisibleMethod,
5087        new String JavaDoc[] {
5088            new String JavaDoc(
5089                    CharOperation.concat(
5090                        localMethod.declaringClass.readableName(),
5091                        localMethod.readableName(),
5092                        '.')),
5093            new String JavaDoc(inheritedMethod.declaringClass.readableName())},
5094        new String JavaDoc[] {
5095            new String JavaDoc(
5096                    CharOperation.concat(
5097                        localMethod.declaringClass.shortReadableName(),
5098                        localMethod.shortReadableName(),
5099                        '.')),
5100            new String JavaDoc(inheritedMethod.declaringClass.shortReadableName())},
5101        localMethod.sourceStart(),
5102        localMethod.sourceEnd());
5103}
5104public void packageCollidesWithType(CompilationUnitDeclaration compUnitDecl) {
5105    String JavaDoc[] arguments = new String JavaDoc[] {CharOperation.toString(compUnitDecl.currentPackage.tokens)};
5106    this.handle(
5107        IProblem.PackageCollidesWithType,
5108        arguments,
5109        arguments,
5110        compUnitDecl.currentPackage.sourceStart,
5111        compUnitDecl.currentPackage.sourceEnd);
5112}
5113public void packageIsNotExpectedPackage(CompilationUnitDeclaration compUnitDecl) {
5114    String JavaDoc[] arguments = new String JavaDoc[] {
5115        CharOperation.toString(compUnitDecl.compilationResult.compilationUnit.getPackageName()),
5116        compUnitDecl.currentPackage == null ? "" : CharOperation.toString(compUnitDecl.currentPackage.tokens), //$NON-NLS-1$
5117
};
5118    this.handle(
5119        IProblem.PackageIsNotExpectedPackage,
5120        arguments,
5121        arguments,
5122        compUnitDecl.currentPackage == null ? 0 : compUnitDecl.currentPackage.sourceStart,
5123        compUnitDecl.currentPackage == null ? 0 : compUnitDecl.currentPackage.sourceEnd);
5124}
5125public void parameterAssignment(LocalVariableBinding local, ASTNode location) {
5126    int severity = computeSeverity(IProblem.ParameterAssignment);
5127    if (severity == ProblemSeverities.Ignore) return;
5128    String JavaDoc[] arguments = new String JavaDoc[] { new String JavaDoc(local.readableName())};
5129    this.handle(
5130        IProblem.ParameterAssignment,
5131        arguments,
5132        arguments,
5133        severity,
5134        nodeSourceStart(local, location),
5135        nodeSourceEnd(local, location)); // should never be a qualified name reference
5136
}
5137private String JavaDoc parameterBoundAsString(TypeVariableBinding typeVariable, boolean makeShort) {
5138    StringBuffer JavaDoc nameBuffer = new StringBuffer JavaDoc(10);
5139    if (typeVariable.firstBound == typeVariable.superclass) {
5140        nameBuffer.append(makeShort ? typeVariable.superclass.shortReadableName() : typeVariable.superclass.readableName());
5141    }
5142    int length;
5143    if ((length = typeVariable.superInterfaces.length) > 0) {
5144        for (int i = 0; i < length; i++) {
5145            if (i > 0 || typeVariable.firstBound == typeVariable.superclass) nameBuffer.append(" & "); //$NON-NLS-1$
5146
nameBuffer.append(makeShort ? typeVariable.superInterfaces[i].shortReadableName() : typeVariable.superInterfaces[i].readableName());
5147        }
5148    }
5149    return nameBuffer.toString();
5150}
5151public void parameterizedMemberTypeMissingArguments(ASTNode location, TypeBinding type) {
5152    if (location == null) { // binary case
5153
this.handle(
5154            IProblem.MissingArgumentsForParameterizedMemberType,
5155            new String JavaDoc[] {new String JavaDoc(type.readableName())},
5156            new String JavaDoc[] {new String JavaDoc(type.shortReadableName())},
5157            ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
5158            0,
5159            0);
5160        return;
5161    }
5162    this.handle(
5163        IProblem.MissingArgumentsForParameterizedMemberType,
5164        new String JavaDoc[] {new String JavaDoc(type.readableName())},
5165        new String JavaDoc[] {new String JavaDoc(type.shortReadableName())},
5166        location.sourceStart,
5167        location.sourceEnd);
5168}
5169public void parseError(
5170    int startPosition,
5171    int endPosition,
5172    int currentToken,
5173    char[] currentTokenSource,
5174    String JavaDoc errorTokenName,
5175    String JavaDoc[] possibleTokens) {
5176        
5177    if (possibleTokens.length == 0) { //no suggestion available
5178
if (isKeyword(currentToken)) {
5179            String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(currentTokenSource)};
5180            this.handle(
5181                IProblem.ParsingErrorOnKeywordNoSuggestion,
5182                arguments,
5183                arguments,
5184                // this is the current -invalid- token position
5185
startPosition,
5186                endPosition);
5187            return;
5188        } else {
5189            String JavaDoc[] arguments = new String JavaDoc[] {errorTokenName};
5190            this.handle(
5191                IProblem.ParsingErrorNoSuggestion,
5192                arguments,
5193                arguments,
5194                // this is the current -invalid- token position
5195
startPosition,
5196                endPosition);
5197            return;
5198        }
5199    }
5200
5201    //build a list of probable right tokens
5202
StringBuffer JavaDoc list = new StringBuffer JavaDoc(20);
5203    for (int i = 0, max = possibleTokens.length; i < max; i++) {
5204        if (i > 0)
5205            list.append(", "); //$NON-NLS-1$
5206
list.append('"');
5207        list.append(possibleTokens[i]);
5208        list.append('"');
5209    }
5210
5211    if (isKeyword(currentToken)) {
5212        String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(currentTokenSource), list.toString()};
5213        this.handle(
5214            IProblem.ParsingErrorOnKeyword,
5215            arguments,
5216            arguments,
5217            // this is the current -invalid- token position
5218
startPosition,
5219            endPosition);
5220        return;
5221    }
5222    //extract the literal when it's a literal
5223
if (isLiteral(currentToken) ||
5224        isIdentifier(currentToken)) {
5225            errorTokenName = new String JavaDoc(currentTokenSource);
5226    }
5227
5228    String JavaDoc[] arguments = new String JavaDoc[] {errorTokenName, list.toString()};
5229    this.handle(
5230        IProblem.ParsingError,
5231        arguments,
5232        arguments,
5233        // this is the current -invalid- token position
5234
startPosition,
5235        endPosition);
5236}
5237public void parseErrorDeleteToken(
5238    int start,
5239    int end,
5240    int currentKind,
5241    char[] errorTokenSource,
5242    String JavaDoc errorTokenName){
5243    this.syntaxError(
5244        IProblem.ParsingErrorDeleteToken,
5245        start,
5246        end,
5247        currentKind,
5248        errorTokenSource,
5249        errorTokenName,
5250        null);
5251}
5252
5253public void parseErrorDeleteTokens(
5254    int start,
5255    int end){
5256    this.handle(
5257        IProblem.ParsingErrorDeleteTokens,
5258        NoArgument,
5259        NoArgument,
5260        start,
5261        end);
5262}
5263public void parseErrorInsertAfterToken(
5264    int start,
5265    int end,
5266    int currentKind,
5267    char[] errorTokenSource,
5268    String JavaDoc errorTokenName,
5269    String JavaDoc expectedToken){
5270    this.syntaxError(
5271        IProblem.ParsingErrorInsertTokenAfter,
5272        start,
5273        end,
5274        currentKind,
5275        errorTokenSource,
5276        errorTokenName,
5277        expectedToken);
5278}
5279public void parseErrorInsertBeforeToken(
5280    int start,
5281    int end,
5282    int currentKind,
5283    char[] errorTokenSource,
5284    String JavaDoc errorTokenName,
5285    String JavaDoc expectedToken){
5286    this.syntaxError(
5287        IProblem.ParsingErrorInsertTokenBefore,
5288        start,
5289        end,
5290        currentKind,
5291        errorTokenSource,
5292        errorTokenName,
5293        expectedToken);
5294}
5295public void parseErrorInsertToComplete(
5296    int start,
5297    int end,
5298    String JavaDoc inserted,
5299    String JavaDoc completed){
5300    String JavaDoc[] arguments = new String JavaDoc[] {inserted, completed};
5301    this.handle(
5302        IProblem.ParsingErrorInsertToComplete,
5303        arguments,
5304        arguments,
5305        start,
5306        end);
5307}
5308
5309public void parseErrorInsertToCompletePhrase(
5310    int start,
5311    int end,
5312    String JavaDoc inserted){
5313    String JavaDoc[] arguments = new String JavaDoc[] {inserted};
5314    this.handle(
5315        IProblem.ParsingErrorInsertToCompletePhrase,
5316        arguments,
5317        arguments,
5318        start,
5319        end);
5320}
5321public void parseErrorInsertToCompleteScope(
5322    int start,
5323    int end,
5324    String JavaDoc inserted){
5325    String JavaDoc[] arguments = new String JavaDoc[] {inserted};
5326    this.handle(
5327        IProblem.ParsingErrorInsertToCompleteScope,
5328        arguments,
5329        arguments,
5330        start,
5331        end);
5332}
5333public void parseErrorInvalidToken(
5334    int start,
5335    int end,
5336    int currentKind,
5337    char[] errorTokenSource,
5338    String JavaDoc errorTokenName,
5339    String JavaDoc expectedToken){
5340    this.syntaxError(
5341        IProblem.ParsingErrorInvalidToken,
5342        start,
5343        end,
5344        currentKind,
5345        errorTokenSource,
5346        errorTokenName,
5347        expectedToken);
5348}
5349public void parseErrorMergeTokens(
5350    int start,
5351    int end,
5352    String JavaDoc expectedToken){
5353    String JavaDoc[] arguments = new String JavaDoc[] {expectedToken};
5354    this.handle(
5355        IProblem.ParsingErrorMergeTokens,
5356        arguments,
5357        arguments,
5358        start,
5359        end);
5360}
5361public void parseErrorMisplacedConstruct(
5362    int start,
5363    int end){
5364    this.handle(
5365        IProblem.ParsingErrorMisplacedConstruct,
5366        NoArgument,
5367        NoArgument,
5368        start,
5369        end);
5370}
5371public void parseErrorNoSuggestion(
5372    int start,
5373    int end,
5374    int currentKind,
5375    char[] errorTokenSource,
5376    String JavaDoc errorTokenName){
5377    this.syntaxError(
5378        IProblem.ParsingErrorNoSuggestion,
5379        start,
5380        end,
5381        currentKind,
5382        errorTokenSource,
5383        errorTokenName,
5384        null);
5385}
5386public void parseErrorNoSuggestionForTokens(
5387    int start,
5388    int end){
5389    this.handle(
5390        IProblem.ParsingErrorNoSuggestionForTokens,
5391        NoArgument,
5392        NoArgument,
5393        start,
5394        end);
5395}
5396public void parseErrorReplaceToken(
5397    int start,
5398    int end,
5399    int currentKind,
5400    char[] errorTokenSource,
5401    String JavaDoc errorTokenName,
5402    String JavaDoc expectedToken){
5403    this.syntaxError(
5404        IProblem.ParsingError,
5405        start,
5406        end,
5407        currentKind,
5408        errorTokenSource,
5409        errorTokenName,
5410        expectedToken);
5411}
5412public void parseErrorReplaceTokens(
5413    int start,
5414    int end,
5415    String JavaDoc expectedToken){
5416    String JavaDoc[] arguments = new String JavaDoc[] {expectedToken};
5417    this.handle(
5418        IProblem.ParsingErrorReplaceTokens,
5419        arguments,
5420        arguments,
5421        start,
5422        end);
5423}
5424public void parseErrorUnexpectedEnd(
5425    int start,
5426    int end){
5427        
5428    String JavaDoc[] arguments;
5429    if(this.referenceContext instanceof ConstructorDeclaration) {
5430        arguments = new String JavaDoc[] {Messages.parser_endOfConstructor};
5431    } else if(this.referenceContext instanceof MethodDeclaration) {
5432        arguments = new String JavaDoc[] {Messages.parser_endOfMethod};
5433    } else if(this.referenceContext instanceof TypeDeclaration) {
5434        arguments = new String JavaDoc[] {Messages.parser_endOfInitializer};
5435    } else {
5436        arguments = new String JavaDoc[] {Messages.parser_endOfFile};
5437    }
5438    this.handle(
5439        IProblem.ParsingErrorUnexpectedEOF,
5440        arguments,
5441        arguments,
5442        start,
5443        end);
5444}
5445public void possibleAccidentalBooleanAssignment(Assignment assignment) {
5446    this.handle(
5447        IProblem.PossibleAccidentalBooleanAssignment,
5448        NoArgument,
5449        NoArgument,
5450        assignment.sourceStart,
5451        assignment.sourceEnd);
5452}
5453public void possibleFallThroughCase(CaseStatement caseStatement) {
5454    // as long as we consider fake reachable as reachable, better keep 'possible' in the name
5455
this.handle(
5456        IProblem.FallthroughCase,
5457        NoArgument,
5458        NoArgument,
5459        caseStatement.sourceStart,
5460        caseStatement.sourceEnd);
5461}
5462public void publicClassMustMatchFileName(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
5463    this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
5464
String JavaDoc[] arguments = new String JavaDoc[] {new String JavaDoc(compUnitDecl.getFileName()), new String JavaDoc(typeDecl.name)};
5465    this.handle(
5466        IProblem.PublicClassMustMatchFileName,
5467        arguments,
5468        arguments,
5469        typeDecl.sourceStart,
5470        typeDecl.sourceEnd,
5471        compUnitDecl.compilationResult);
5472}
5473public void rawMemberTypeCannotBeParameterized(ASTNode location, ReferenceBinding type, TypeBinding[] argumentTypes) {
5474    if (location == null) { // binary case
5475
this.handle(
5476            IProblem.RawMemberTypeCannotBeParameterized,
5477            new String JavaDoc[] {new String JavaDoc(type.readableName()), typesAsString(false, argumentTypes, false), new String JavaDoc(type.enclosingType().readableName())},
5478            new String JavaDoc[] {new String JavaDoc(type.shortReadableName()), typesAsString(false, argumentTypes, true), new String JavaDoc(type.enclosingType().shortReadableName())},
5479            ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
5480            0,
5481            0);
5482        return;
5483    }
5484    this.handle(
5485        IProblem.RawMemberTypeCannotBeParameterized,
5486        new String JavaDoc[] {new String JavaDoc(type.readableName()), typesAsString(false, argumentTypes, false), new String JavaDoc(type.enclosingType().readableName())},
5487        new String JavaDoc[] {new