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