added -J option to preserve unmodified files in preexisting jarfile
[org.ibex.tool.git] / src / org / eclipse / jdt / internal / compiler / problem / ProblemReporter.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.problem;
12
13 import org.eclipse.jdt.core.compiler.CharOperation;
14 import org.eclipse.jdt.core.compiler.IProblem;
15 import org.eclipse.jdt.internal.compiler.*;
16 import org.eclipse.jdt.internal.compiler.ast.*;
17 import org.eclipse.jdt.internal.compiler.env.IConstants;
18 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
19 import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
20 import org.eclipse.jdt.internal.compiler.lookup.*;
21 import org.eclipse.jdt.internal.compiler.parser.*;
22 import org.eclipse.jdt.internal.compiler.util.Util;
23
24 public class ProblemReporter extends ProblemHandler implements ProblemReasons {
25         
26         public ReferenceContext referenceContext;
27         
28 public ProblemReporter(IErrorHandlingPolicy policy, CompilerOptions options, IProblemFactory problemFactory) {
29         super(policy, options, problemFactory);
30 }
31 public void abortDueToInternalError(String errorMessage) {
32         String[] arguments = new String[] {errorMessage};
33         this.handle(
34                 IProblem.Unclassified,
35                 arguments,
36                 arguments,
37                 Error | Abort,
38                 0,
39                 0);
40 }
41 public void abortDueToInternalError(String errorMessage, ASTNode location) {
42         String[] arguments = new String[] {errorMessage};
43         this.handle(
44                 IProblem.Unclassified,
45                 arguments,
46                 arguments,
47                 Error | Abort,
48                 location.sourceStart,
49                 location.sourceEnd);
50 }
51 public void abstractMethodCannotBeOverridden(SourceTypeBinding type, MethodBinding concreteMethod) {
52
53         this.handle(
54                 // %1 must be abstract since it cannot override the inherited package-private abstract method %2
55                 IProblem.AbstractMethodCannotBeOverridden,
56                 new String[] {
57                         new String(type.sourceName()), 
58                         new String(
59                                         CharOperation.concat(
60                                                 concreteMethod.declaringClass.readableName(),
61                                                 concreteMethod.readableName(),
62                                                 '.'))},
63                 new String[] {
64                         new String(type.sourceName()), 
65                         new String(
66                                         CharOperation.concat(
67                                                 concreteMethod.declaringClass.shortReadableName(),
68                                                 concreteMethod.shortReadableName(),
69                                                 '.'))},
70                 type.sourceStart(),
71                 type.sourceEnd());
72 }
73 public void abstractMethodInAbstractClass(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
74
75         String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
76         this.handle(
77                 IProblem.AbstractMethodInAbstractClass,
78                 arguments,
79                 arguments,
80                 methodDecl.sourceStart,
81                 methodDecl.sourceEnd);
82 }
83 public void abstractMethodMustBeImplemented(SourceTypeBinding type, MethodBinding abstractMethod) {
84         this.handle(
85                 // Must implement the inherited abstract method %1
86                 // 8.4.3 - Every non-abstract subclass of an abstract type, A, must provide a concrete implementation of all of A's methods.
87                 IProblem.AbstractMethodMustBeImplemented,
88                 new String[] { 
89                         new String(abstractMethod.selector),
90                         typesAsString(abstractMethod.isVarargs(), abstractMethod.parameters, false), 
91                         new String(abstractMethod.declaringClass.readableName()), 
92                         new String(type.readableName()), 
93                 },
94                 new String[] { 
95                         new String(abstractMethod.selector),
96                         typesAsString(abstractMethod.isVarargs(), abstractMethod.parameters, true), 
97                         new String(abstractMethod.declaringClass.shortReadableName()), 
98                         new String(type.shortReadableName()), 
99                 },
100                 type.sourceStart(),
101                 type.sourceEnd());
102 }
103 public void abstractMethodNeedingNoBody(AbstractMethodDeclaration method) {
104         this.handle(
105                 IProblem.BodyForAbstractMethod,
106                 NoArgument,
107                 NoArgument,
108                 method.sourceStart,
109                 method.sourceEnd,
110                 method,
111                 method.compilationResult());
112 }
113 public void alreadyDefinedLabel(char[] labelName, ASTNode location) {
114         String[] arguments = new String[] {new String(labelName)};
115         this.handle(
116                 IProblem.DuplicateLabel,
117                 arguments,
118                 arguments,
119                 location.sourceStart,
120                 location.sourceEnd);
121 }
122 public void annotationCircularity(TypeBinding sourceType, TypeBinding otherType, TypeReference reference) {
123         if (sourceType == otherType)
124                 this.handle(
125                         IProblem.AnnotationCircularitySelfReference,
126                         new String[] {new String(sourceType.readableName())},
127                         new String[] {new String(sourceType.shortReadableName())},
128                         reference.sourceStart,
129                         reference.sourceEnd);
130         else
131                 this.handle(
132                         IProblem.AnnotationCircularity,
133                         new String[] {new String(sourceType.readableName()), new String(otherType.readableName())},
134                         new String[] {new String(sourceType.shortReadableName()), new String(otherType.shortReadableName())},
135                         reference.sourceStart,
136                         reference.sourceEnd);
137 }
138 public void annotationCannotOverrideMethod(MethodBinding overrideMethod, MethodBinding inheritedMethod) {
139         ASTNode location = overrideMethod.sourceMethod();
140         this.handle(
141                 IProblem.AnnotationCannotOverrideMethod,
142                 new String[] {
143                                 new String(overrideMethod.declaringClass.readableName()),
144                                 new String(inheritedMethod.declaringClass.readableName()),
145                                 new String(inheritedMethod.selector), 
146                                 typesAsString(inheritedMethod.isVarargs(), inheritedMethod.parameters, false)},
147                 new String[] {
148                                 new String(overrideMethod.declaringClass.shortReadableName()),
149                                 new String(inheritedMethod.declaringClass.shortReadableName()),
150                                 new String(inheritedMethod.selector), 
151                                 typesAsString(inheritedMethod.isVarargs(), inheritedMethod.parameters, true)},
152                 location.sourceStart,
153                 location.sourceEnd);    
154 }
155 public void annotationFieldNeedConstantInitialization(FieldDeclaration fieldDecl) {
156         String str = new String(fieldDecl.name);
157         this.handle(
158                 IProblem.AnnotationFieldNeedConstantInitialization,
159                 new String[] { new String(fieldDecl.binding.declaringClass.readableName()), str },
160                 new String[] { new String(fieldDecl.binding.declaringClass.shortReadableName()), str},
161                 fieldDecl.sourceStart,
162                 fieldDecl.sourceEnd);
163 }
164 public void annotationMembersCannotHaveParameters(AnnotationMethodDeclaration annotationMethodDeclaration) {
165         this.handle(
166                 IProblem.AnnotationMembersCannotHaveParameters,
167                 NoArgument,
168                 NoArgument,
169                 annotationMethodDeclaration.sourceStart,
170                 annotationMethodDeclaration.sourceEnd);
171 }
172 public void annotationMembersCannotHaveTypeParameters(AnnotationMethodDeclaration annotationMethodDeclaration) {
173         this.handle(
174                 IProblem.AnnotationMembersCannotHaveTypeParameters,
175                 NoArgument,
176                 NoArgument,
177                 annotationMethodDeclaration.sourceStart,
178                 annotationMethodDeclaration.sourceEnd);
179 }
180 public void annotationTypeDeclarationCannotHaveConstructor(ConstructorDeclaration constructorDeclaration) {
181         this.handle(
182                 IProblem.AnnotationTypeDeclarationCannotHaveConstructor,
183                 NoArgument,
184                 NoArgument,
185                 constructorDeclaration.sourceStart,
186                 constructorDeclaration.sourceEnd);
187 }
188 public void annotationTypeDeclarationCannotHaveSuperclass(TypeDeclaration typeDeclaration) {
189         this.handle(
190                 IProblem.AnnotationTypeDeclarationCannotHaveSuperclass,
191                 NoArgument,
192                 NoArgument,
193                 typeDeclaration.sourceStart,
194                 typeDeclaration.sourceEnd);
195 }
196 public void annotationTypeDeclarationCannotHaveSuperinterfaces(TypeDeclaration typeDeclaration) {
197         this.handle(
198                 IProblem.AnnotationTypeDeclarationCannotHaveSuperinterfaces,
199                 NoArgument,
200                 NoArgument,
201                 typeDeclaration.sourceStart,
202                 typeDeclaration.sourceEnd);
203 }
204 public void annotationValueMustBeClassLiteral(TypeBinding annotationType, char[] name, Expression value) {
205         String str = new String(name);
206         this.handle(
207                 IProblem.AnnotationValueMustBeClassLiteral,
208                 new String[] { new String(annotationType.readableName()), str },
209                 new String[] { new String(annotationType.shortReadableName()), str},
210                 value.sourceStart,
211                 value.sourceEnd);
212 }
213 public void annotationValueMustBeConstant(TypeBinding annotationType, char[] name, Expression value) {
214         String str =    new String(name);
215         this.handle(
216                 IProblem.AnnotationValueMustBeConstant,
217                 new String[] { new String(annotationType.readableName()), str },
218                 new String[] { new String(annotationType.shortReadableName()), str},
219                 value.sourceStart,
220                 value.sourceEnd);
221 }
222 public void anonymousClassCannotExtendFinalClass(Expression expression, TypeBinding type) {
223         this.handle(
224                 IProblem.AnonymousClassCannotExtendFinalClass,
225                 new String[] {new String(type.readableName())},
226                 new String[] {new String(type.shortReadableName())},
227                 expression.sourceStart,
228                 expression.sourceEnd);
229 }
230 public void argumentTypeCannotBeVoid(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, Argument arg) {
231         String[] arguments = new String[] {new String(methodDecl.selector), new String(arg.name)};
232         this.handle(
233                 IProblem.ArgumentTypeCannotBeVoid,
234                 arguments,
235                 arguments,
236                 methodDecl.sourceStart,
237                 methodDecl.sourceEnd);
238 }
239 public void argumentTypeCannotBeVoidArray(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, Argument arg) {
240         String[] arguments = new String[] {new String(methodDecl.selector), new String(arg.name)};
241         this.handle(
242                 IProblem.ArgumentTypeCannotBeVoidArray,
243                 arguments,
244                 arguments,
245                 methodDecl.sourceStart,
246                 methodDecl.sourceEnd);
247 }
248 public void arrayConstantsOnlyInArrayInitializers(int sourceStart, int sourceEnd) {
249         this.handle(
250                 IProblem.ArrayConstantsOnlyInArrayInitializers,
251                 NoArgument,
252                 NoArgument,
253                 sourceStart,
254                 sourceEnd);
255 }
256 public void assignmentHasNoEffect(Assignment assignment, char[] name){
257         String[] arguments = new String[] { new String(name) }; 
258         this.handle(
259                         IProblem.AssignmentHasNoEffect,
260                         arguments,
261                         arguments,
262                         assignment.sourceStart,
263                         assignment.sourceEnd);
264 }
265 public void attemptToReturnNonVoidExpression(ReturnStatement returnStatement, TypeBinding expectedType) {
266         this.handle(
267                 IProblem.VoidMethodReturnsValue,
268                 new String[] {new String(expectedType.readableName())},
269                 new String[] {new String(expectedType.shortReadableName())},
270                 returnStatement.sourceStart,
271                 returnStatement.sourceEnd);
272 }
273 public void attemptToReturnVoidValue(ReturnStatement returnStatement) {
274         this.handle(
275                 IProblem.MethodReturnsVoid,
276                 NoArgument,
277                 NoArgument,
278                 returnStatement.sourceStart,
279                 returnStatement.sourceEnd);
280 }
281 public void boundHasConflictingArguments(ASTNode location, TypeBinding type) {
282         this.handle(
283                 IProblem.BoundHasConflictingArguments,
284                 new String[] {new String(type.readableName())},
285                 new String[] {new String(type.shortReadableName())},
286                 location.sourceStart,
287                 location.sourceEnd);
288 }
289 public void boundsMustBeAnInterface(ASTNode location, TypeBinding type) {
290         this.handle(
291                 IProblem.BoundsMustBeAnInterface,
292                 new String[] {new String(type.readableName())},
293                 new String[] {new String(type.shortReadableName())},
294                 location.sourceStart,
295                 location.sourceEnd);
296 }
297 public void bytecodeExceeds64KLimit(AbstractMethodDeclaration location) {
298         MethodBinding method = location.binding;
299         if (location.isConstructor()) {
300                 this.handle(
301                         IProblem.BytecodeExceeds64KLimitForConstructor,
302                         new String[] {new String(location.selector), typesAsString(method.isVarargs(), method.parameters, false)},
303                         new String[] {new String(location.selector), typesAsString(method.isVarargs(), method.parameters, true)},
304                         Error | Abort,
305                         location.sourceStart,
306                         location.sourceEnd);
307         } else {
308                 this.handle(
309                         IProblem.BytecodeExceeds64KLimit,
310                         new String[] {new String(location.selector), typesAsString(method.isVarargs(), method.parameters, false)},
311                         new String[] {new String(location.selector), typesAsString(method.isVarargs(), method.parameters, true)},
312                         Error | Abort,
313                         location.sourceStart,
314                         location.sourceEnd);
315         }
316 }
317 public void bytecodeExceeds64KLimit(TypeDeclaration location) {
318         this.handle(
319                 IProblem.BytecodeExceeds64KLimitForClinit,
320                 NoArgument,
321                 NoArgument,
322                 Error | Abort,
323                 location.sourceStart,
324                 location.sourceEnd);
325 }
326 public void cannotAllocateVoidArray(Expression expression) {
327         this.handle(
328                 IProblem.CannotAllocateVoidArray,
329                 NoArgument,
330                 NoArgument,
331                 expression.sourceStart,
332                 expression.sourceEnd);
333 }
334 public void cannotAssignToFinalField(FieldBinding field, ASTNode location) {
335         this.handle(
336                 IProblem.FinalFieldAssignment,
337                 new String[] {
338                         (field.declaringClass == null ? "array" : new String(field.declaringClass.readableName())), //$NON-NLS-1$
339                         new String(field.readableName())},
340                 new String[] {
341                         (field.declaringClass == null ? "array" : new String(field.declaringClass.shortReadableName())), //$NON-NLS-1$
342                         new String(field.shortReadableName())},
343                 location.sourceStart,
344                 location.sourceEnd);
345 }
346 public void cannotAssignToFinalLocal(LocalVariableBinding local, ASTNode location) {
347         String[] arguments = new String[] { new String(local.readableName())};
348         this.handle(
349                 IProblem.NonBlankFinalLocalAssignment,
350                 arguments,
351                 arguments,
352                 location.sourceStart,
353                 location.sourceEnd);
354 }
355 public void cannotAssignToFinalOuterLocal(LocalVariableBinding local, ASTNode location) {
356         String[] arguments = new String[] {new String(local.readableName())};
357         this.handle(
358                 IProblem.FinalOuterLocalAssignment,
359                 arguments,
360                 arguments,
361                 location.sourceStart,
362                 location.sourceEnd);
363 }
364 public void cannotDeclareLocalInterface(char[] interfaceName, int sourceStart, int sourceEnd) {
365         String[] arguments = new String[] {new String(interfaceName)};
366         this.handle(
367                 IProblem.CannotDefineInterfaceInLocalType,
368                 arguments,
369                 arguments,
370                 sourceStart,
371                 sourceEnd);
372 }
373 public void cannotDefineDimensionsAndInitializer(ArrayAllocationExpression expresssion) {
374         this.handle(
375                 IProblem.CannotDefineDimensionExpressionsWithInit,
376                 NoArgument,
377                 NoArgument,
378                 expresssion.sourceStart,
379                 expresssion.sourceEnd);
380 }
381 public void cannotDireclyInvokeAbstractMethod(MessageSend messageSend, MethodBinding method) {
382         this.handle(
383                 IProblem.DirectInvocationOfAbstractMethod,
384                 new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
385                 new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
386                 messageSend.sourceStart,
387                 messageSend.sourceEnd);
388 }
389 public void cannotExtendEnum(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) {
390         String name = new String(type.sourceName());
391         String superTypeFullName = new String(superTypeBinding.readableName());
392         String superTypeShortName = new String(superTypeBinding.shortReadableName());
393         if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName;
394         this.handle(
395                 IProblem.CannotExtendEnum,
396                 new String[] {superTypeFullName, name},
397                 new String[] {superTypeShortName, name},
398                 superclass.sourceStart,
399                 superclass.sourceEnd);
400 }
401 public void cannotImportPackage(ImportReference importRef) {
402         String[] arguments = new String[] {CharOperation.toString(importRef.tokens)};
403         this.handle(
404                 IProblem.CannotImportPackage,
405                 arguments,
406                 arguments,
407                 importRef.sourceStart,
408                 importRef.sourceEnd);
409 }
410 public void cannotInstantiate(TypeReference typeRef, TypeBinding type) {
411         this.handle(
412                 IProblem.InvalidClassInstantiation,
413                 new String[] {new String(type.readableName())},
414                 new String[] {new String(type.shortReadableName())},
415                 typeRef.sourceStart,
416                 typeRef.sourceEnd);
417 }
418 public void cannotReferToNonFinalOuterLocal(LocalVariableBinding local, ASTNode location) {
419         String[] arguments =new String[]{ new String(local.readableName())};
420         this.handle(
421                 IProblem.OuterLocalMustBeFinal,
422                 arguments,
423                 arguments,
424                 location.sourceStart,
425                 location.sourceEnd);
426 }
427 public void cannotReturnInInitializer(ASTNode location) {
428         this.handle(
429                 IProblem.CannotReturnInInitializer,
430                 NoArgument,
431                 NoArgument,
432                 location.sourceStart,
433                 location.sourceEnd);
434 }
435 public void cannotThrowNull(ThrowStatement statement) {
436         this.handle(
437                 IProblem.CannotThrowNull,
438                 NoArgument,
439                 NoArgument,
440                 statement.sourceStart,
441                 statement.sourceEnd);
442 }
443 public void cannotThrowType(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, TypeReference exceptionType, TypeBinding expectedType) {
444         this.handle(
445                 IProblem.CannotThrowType,
446                 new String[] {new String(expectedType.readableName())},
447                 new String[] {new String(expectedType.shortReadableName())},
448                 exceptionType.sourceStart,
449                 exceptionType.sourceEnd);
450 }
451 public void cannotUseSuperInCodeSnippet(int start, int end) {
452         this.handle(
453                 IProblem.CannotUseSuperInCodeSnippet,
454                 NoArgument,
455                 NoArgument,
456                 Error | Abort,
457                 start,
458                 end);
459 }
460 public void cannotUseSuperInJavaLangObject(ASTNode reference) {
461         this.handle(
462                 IProblem.ObjectHasNoSuperclass,
463                 NoArgument,
464                 NoArgument,
465                 reference.sourceStart,
466                 reference.sourceEnd);
467 }
468 public void cannotUseQualifiedEnumConstantInCaseLabel(QualifiedNameReference reference) {
469         String[] arguments = new String[]{ String.valueOf(reference.fieldBinding().name) };
470         this.handle(
471                         IProblem.IllegalQualifiedEnumConstantLabel,
472                         arguments,
473                         arguments,
474                         reference.sourceStart,
475                         reference.sourceEnd);   
476 }
477 public void caseExpressionMustBeConstant(Expression expression) {
478         this.handle(
479                 IProblem.NonConstantExpression,
480                 NoArgument,
481                 NoArgument,
482                 expression.sourceStart,
483                 expression.sourceEnd);
484 }
485 public void classExtendFinalClass(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) {
486         String name = new String(type.sourceName());
487         String superTypeFullName = new String(superTypeBinding.readableName());
488         String superTypeShortName = new String(superTypeBinding.shortReadableName());
489         if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName;
490         this.handle(
491                 IProblem.ClassExtendFinalClass,
492                 new String[] {superTypeFullName, name},
493                 new String[] {superTypeShortName, name},
494                 superclass.sourceStart,
495                 superclass.sourceEnd);
496 }
497 public void codeSnippetMissingClass(String missing, int start, int end) {
498         String[] arguments = new String[]{missing};
499         this.handle(
500                 IProblem.CodeSnippetMissingClass,
501                 arguments,
502                 arguments,
503                 Error | Abort,
504                 start,
505                 end);
506 }
507 public void codeSnippetMissingMethod(String className, String missingMethod, String argumentTypes, int start, int end) {
508         String[] arguments = new String[]{ className, missingMethod, argumentTypes };
509         this.handle(
510                 IProblem.CodeSnippetMissingMethod,
511                 arguments,
512                 arguments,
513                 Error | Abort,
514                 start,
515                 end);
516 }
517 /*
518  * Given the current configuration, answers which category the problem
519  * falls into:
520  *              Error | Warning | Ignore
521  */
522 public int computeSeverity(int problemId){
523
524         // severity can have been preset on the problem
525 //      if ((problem.severity & Fatal) != 0){
526 //              return Error;
527 //      }
528
529         // if not then check whether it is a configurable problem
530         switch(problemId){
531
532                 case IProblem.MaskedCatch : 
533                         return this.options.getSeverity(CompilerOptions.MaskedCatchBlock);
534
535                 case IProblem.UnusedImport :
536                         return this.options.getSeverity(CompilerOptions.UnusedImport);
537                         
538                 case IProblem.MethodButWithConstructorName :
539                         return this.options.getSeverity(CompilerOptions.MethodWithConstructorName);
540                 
541                 case IProblem.OverridingNonVisibleMethod :
542                         return this.options.getSeverity(CompilerOptions.OverriddenPackageDefaultMethod);
543
544                 case IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod :
545                 case IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod :
546                         return this.options.getSeverity(CompilerOptions.IncompatibleNonInheritedInterfaceMethod);
547
548                 case IProblem.OverridingDeprecatedMethod :                              
549                 case IProblem.UsingDeprecatedType :                             
550                 case IProblem.UsingDeprecatedMethod :
551                 case IProblem.UsingDeprecatedConstructor :
552                 case IProblem.UsingDeprecatedField :
553                         return this.options.getSeverity(CompilerOptions.UsingDeprecatedAPI);
554                 
555                 case IProblem.LocalVariableIsNeverUsed :
556                         return this.options.getSeverity(CompilerOptions.UnusedLocalVariable);
557                 
558                 case IProblem.ArgumentIsNeverUsed :
559                         return this.options.getSeverity(CompilerOptions.UnusedArgument);
560
561                 case IProblem.NoImplicitStringConversionForCharArrayExpression :
562                         return this.options.getSeverity(CompilerOptions.NoImplicitStringConversion);
563
564                 case IProblem.NeedToEmulateFieldReadAccess :
565                 case IProblem.NeedToEmulateFieldWriteAccess :
566                 case IProblem.NeedToEmulateMethodAccess :
567                 case IProblem.NeedToEmulateConstructorAccess :                  
568                         return this.options.getSeverity(CompilerOptions.AccessEmulation);
569
570                 case IProblem.NonExternalizedStringLiteral :
571                         return this.options.getSeverity(CompilerOptions.NonExternalizedString);
572
573                 case IProblem.UseAssertAsAnIdentifier :
574                         return this.options.getSeverity(CompilerOptions.AssertUsedAsAnIdentifier);
575                 case IProblem.UseEnumAsAnIdentifier :
576                         return this.options.getSeverity(CompilerOptions.EnumUsedAsAnIdentifier);
577
578                 case IProblem.NonStaticAccessToStaticMethod :
579                 case IProblem.NonStaticAccessToStaticField :
580                         return this.options.getSeverity(CompilerOptions.NonStaticAccessToStatic);
581
582                 case IProblem.IndirectAccessToStaticMethod :
583                 case IProblem.IndirectAccessToStaticField :
584                 case IProblem.IndirectAccessToStaticType :
585                         return this.options.getSeverity(CompilerOptions.IndirectStaticAccess);
586
587                 case IProblem.AssignmentHasNoEffect:
588                         return this.options.getSeverity(CompilerOptions.NoEffectAssignment);
589
590                 case IProblem.UnusedPrivateConstructor:
591                 case IProblem.UnusedPrivateMethod:
592                 case IProblem.UnusedPrivateField:
593                 case IProblem.UnusedPrivateType:
594                         return this.options.getSeverity(CompilerOptions.UnusedPrivateMember);
595
596                 case IProblem.Task :
597                         return Warning;                 
598
599                 case IProblem.LocalVariableHidingLocalVariable:
600                 case IProblem.LocalVariableHidingField:
601                 case IProblem.ArgumentHidingLocalVariable:
602                 case IProblem.ArgumentHidingField:
603                         return this.options.getSeverity(CompilerOptions.LocalVariableHiding);
604
605                 case IProblem.FieldHidingLocalVariable:
606                 case IProblem.FieldHidingField:
607                         return this.options.getSeverity(CompilerOptions.FieldHiding);
608
609                 case IProblem.PossibleAccidentalBooleanAssignment:
610                         return this.options.getSeverity(CompilerOptions.AccidentalBooleanAssign);
611
612                 case IProblem.SuperfluousSemicolon:
613                 case IProblem.EmptyControlFlowStatement:
614                         return this.options.getSeverity(CompilerOptions.EmptyStatement);
615
616                 case IProblem.UndocumentedEmptyBlock:
617                         return this.options.getSeverity(CompilerOptions.UndocumentedEmptyBlock);
618                         
619                 case IProblem.UnnecessaryCast:
620                 case IProblem.UnnecessaryArgumentCast:
621                 case IProblem.UnnecessaryInstanceof:
622                         return this.options.getSeverity(CompilerOptions.UnnecessaryTypeCheck);
623                         
624                 case IProblem.FinallyMustCompleteNormally:
625                         return this.options.getSeverity(CompilerOptions.FinallyBlockNotCompleting);
626                         
627                 case IProblem.UnusedMethodDeclaredThrownException:
628                 case IProblem.UnusedConstructorDeclaredThrownException:
629                         return this.options.getSeverity(CompilerOptions.UnusedDeclaredThrownException);
630
631                 case IProblem.UnqualifiedFieldAccess:
632                         return this.options.getSeverity(CompilerOptions.UnqualifiedFieldAccess);
633                 
634                 case IProblem.UnnecessaryElse:
635                         return this.options.getSeverity(CompilerOptions.UnnecessaryElse);
636
637                 case IProblem.UnsafeRawConstructorInvocation:
638                 case IProblem.UnsafeRawMethodInvocation:
639                 case IProblem.UnsafeRawConversion:
640                 case IProblem.UnsafeRawFieldAssignment:
641                 case IProblem.UnsafeGenericCast:
642                 case IProblem.UnsafeReturnTypeOverride:
643                         return this.options.getSeverity(CompilerOptions.UnsafeTypeOperation);
644
645                 case IProblem.FinalBoundForTypeVariable:
646                     return this.options.getSeverity(CompilerOptions.FinalParameterBound);
647
648                 case IProblem.MissingSerialVersion:
649                         return this.options.getSeverity(CompilerOptions.MissingSerialVersion);
650                 
651                 case IProblem.ForbiddenReference:
652                         return this.options.getSeverity(CompilerOptions.ForbiddenReference);
653
654                 case IProblem.MethodVarargsArgumentNeedCast :
655                 case IProblem.ConstructorVarargsArgumentNeedCast :
656                         return this.options.getSeverity(CompilerOptions.VarargsArgumentNeedCast);
657
658                 case IProblem.LocalVariableCannotBeNull :
659                 case IProblem.LocalVariableCanOnlyBeNull :
660                         return this.options.getSeverity(CompilerOptions.InconsistentNullCheck);
661                         
662                 /*
663                  * Javadoc syntax errors
664                  */
665                 case IProblem.JavadocUnexpectedTag:
666                 case IProblem.JavadocDuplicateReturnTag:
667                 case IProblem.JavadocInvalidThrowsClass:
668                 case IProblem.JavadocInvalidReference:
669                 case IProblem.JavadocInvalidParamTagName:
670                 case IProblem.JavadocInvalidParamTagTypeParameter:
671                 case IProblem.JavadocMalformedSeeReference:
672                 case IProblem.JavadocInvalidSeeHref:
673                 case IProblem.JavadocInvalidSeeArgs:
674                 case IProblem.JavadocInvalidTag:
675                 case IProblem.JavadocUnterminatedInlineTag:
676                 case IProblem.JavadocMissingHashCharacter:
677                 case IProblem.JavadocEmptyReturnTag:
678                 case IProblem.JavadocUnexpectedText:
679                         if (this.options.docCommentSupport) {
680                                 return this.options.getSeverity(CompilerOptions.InvalidJavadoc);
681                         } else {
682                                 return ProblemSeverities.Ignore;
683                         }
684
685                 /*
686                  * Javadoc tags resolved references errors
687                  */
688                 case IProblem.JavadocInvalidParamName:
689                 case IProblem.JavadocDuplicateParamName:
690                 case IProblem.JavadocMissingParamName:
691                 case IProblem.JavadocInvalidThrowsClassName:
692                 case IProblem.JavadocDuplicateThrowsClassName:
693                 case IProblem.JavadocMissingThrowsClassName:
694                 case IProblem.JavadocMissingReference:
695                 case IProblem.JavadocInvalidValueReference:
696                 case IProblem.JavadocUndefinedField:
697                 case IProblem.JavadocAmbiguousField:
698                 case IProblem.JavadocUndefinedConstructor:
699                 case IProblem.JavadocAmbiguousConstructor:
700                 case IProblem.JavadocUndefinedMethod:
701                 case IProblem.JavadocAmbiguousMethod:
702                 case IProblem.JavadocAmbiguousMethodReference:
703                 case IProblem.JavadocParameterMismatch:
704                 case IProblem.JavadocUndefinedType:
705                 case IProblem.JavadocAmbiguousType:
706                 case IProblem.JavadocInternalTypeNameProvided:
707                 case IProblem.JavadocNoMessageSendOnArrayType:
708                 case IProblem.JavadocNoMessageSendOnBaseType:
709                 case IProblem.JavadocInheritedMethodHidesEnclosingName:
710                 case IProblem.JavadocInheritedFieldHidesEnclosingName:
711                 case IProblem.JavadocInheritedNameHidesEnclosingTypeName:
712                         if (this.options.docCommentSupport && this.options.reportInvalidJavadocTags) {
713                                 return this.options.getSeverity(CompilerOptions.InvalidJavadoc);
714                         }
715                         return ProblemSeverities.Ignore;
716
717                 /*
718                  * Javadoc invalid tags due to deprecated references
719                  */
720                 case IProblem.JavadocUsingDeprecatedField:
721                 case IProblem.JavadocUsingDeprecatedConstructor:
722                 case IProblem.JavadocUsingDeprecatedMethod:
723                 case IProblem.JavadocUsingDeprecatedType:
724                         if (this.options.docCommentSupport && this.options.reportInvalidJavadocTags && this.options.reportInvalidJavadocTagsDeprecatedRef) {
725                                 return this.options.getSeverity(CompilerOptions.InvalidJavadoc);
726                         }
727                         return ProblemSeverities.Ignore;
728
729                 /*
730                  * Javadoc invalid tags due to non-visible references
731                  */
732                 case IProblem.JavadocNotVisibleField:
733                 case IProblem.JavadocNotVisibleConstructor:
734                 case IProblem.JavadocNotVisibleMethod:
735                 case IProblem.JavadocNotVisibleType:
736                         if (this.options.docCommentSupport && this.options.reportInvalidJavadocTags && this.options.reportInvalidJavadocTagsNotVisibleRef) {
737                                 return this.options.getSeverity(CompilerOptions.InvalidJavadoc);
738                         }
739                         return ProblemSeverities.Ignore;
740
741                 /*
742                  * Javadoc missing tags errors
743                  */
744                 case IProblem.JavadocMissingParamTag:
745                 case IProblem.JavadocMissingReturnTag:
746                 case IProblem.JavadocMissingThrowsTag:
747                         if (this.options.docCommentSupport) {
748                                 return this.options.getSeverity(CompilerOptions.MissingJavadocTags);
749                         } else {
750                                 return ProblemSeverities.Ignore;
751                         }
752
753                 /*
754                  * Missing Javadoc errors
755                  */
756                 case IProblem.JavadocMissing:
757                         if (this.options.docCommentSupport) {
758                                 return this.options.getSeverity(CompilerOptions.MissingJavadocComments);
759                         } else {
760                                 return ProblemSeverities.Ignore;
761                         }
762                         
763                 // by default problems are errors.
764                 default:
765                         return Error;
766         }
767 }
768 public void conditionalArgumentsIncompatibleTypes(ConditionalExpression expression, TypeBinding trueType, TypeBinding falseType) {
769         this.handle(
770                 IProblem.IncompatibleTypesInConditionalOperator,
771                 new String[] {new String(trueType.readableName()), new String(falseType.readableName())},
772                 new String[] {new String(trueType.sourceName()), new String(falseType.sourceName())},
773                 expression.sourceStart,
774                 expression.sourceEnd);
775 }
776 public void conflictingImport(ImportReference importRef) {
777         String[] arguments = new String[] {CharOperation.toString(importRef.tokens)};
778         this.handle(
779                 IProblem.ConflictingImport,
780                 arguments,
781                 arguments,
782                 importRef.sourceStart,
783                 importRef.sourceEnd);
784 }
785 public void constantOutOfFormat(NumberLiteral literal) {
786         // the literal is not in a correct format
787         // this code is called on IntLiteral and LongLiteral 
788         // example 000811 ...the 8 is uncorrect.
789
790         if ((literal instanceof LongLiteral) || (literal instanceof IntLiteral)) {
791                 char[] source = literal.source();
792                 try {
793                         final String Radix;
794                         final int radix;
795                         if ((source[1] == 'x') || (source[1] == 'X')) {
796                                 radix = 16;
797                                 Radix = "Hex"; //$NON-NLS-1$
798                         } else {
799                                 radix = 8;
800                                 Radix = "Octal"; //$NON-NLS-1$
801                         }
802                         //look for the first digit that is incorrect
803                         int place = -1;
804                         label : for (int i = radix == 8 ? 1 : 2; i < source.length; i++) {
805                                 if (Character.digit(source[i], radix) == -1) {
806                                         place = i;
807                                         break label;
808                                 }
809                         }
810                         String[] arguments = new String[] {
811                                 new String(literal.literalType(null).readableName()), // numeric literals do not need scope to reach type
812                                 Radix + " " + new String(source) + " (digit " + new String(new char[] {source[place]}) + ")"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
813
814                         this.handle(
815                                 IProblem.NumericValueOutOfRange,
816                                 arguments,
817                                 arguments,
818                                 literal.sourceStart,
819                                 literal.sourceEnd);
820                         return;
821                 } catch (IndexOutOfBoundsException ex) {
822                         // should never happen
823                 }
824         
825                 // just in case .... use a predefined error..
826                 // we should never come here...(except if the code changes !)
827                 this.constantOutOfRange(literal, literal.literalType(null)); // numeric literals do not need scope to reach type
828         }
829 }
830 public void constantOutOfRange(Literal literal, TypeBinding literalType) {
831         String[] arguments = new String[] {new String(literalType.readableName()), new String(literal.source())};
832         this.handle(
833                 IProblem.NumericValueOutOfRange,
834                 arguments,
835                 arguments,
836                 literal.sourceStart,
837                 literal.sourceEnd);
838 }
839 public void corruptedSignature(TypeBinding enclosingType, char[] signature, int position) {
840         this.handle(
841                 IProblem.CorruptedSignature,
842                 new String[] { new String(enclosingType.readableName()), new String(signature), String.valueOf(position) },
843                 new String[] { new String(enclosingType.shortReadableName()), new String(signature), String.valueOf(position) },
844                 Error | Abort,
845                 0,
846                 0);
847 }
848 public void deprecatedField(FieldBinding field, ASTNode location) {
849         this.handle(
850                 IProblem.UsingDeprecatedField,
851                 new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
852                 new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
853                 location.sourceStart,
854                 location.sourceEnd);
855 }
856 public void deprecatedMethod(MethodBinding method, ASTNode location) {
857         if (method.isConstructor()) {
858                 this.handle(
859                         IProblem.UsingDeprecatedConstructor,
860                         new String[] {new String(method.declaringClass.readableName()), typesAsString(method.isVarargs(), method.parameters, false)},
861                         new String[] {new String(method.declaringClass.shortReadableName()), typesAsString(method.isVarargs(), method.parameters, true)},
862                         location.sourceStart,
863                         location.sourceEnd);
864         } else {
865                 this.handle(
866                         IProblem.UsingDeprecatedMethod,
867                         new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
868                         new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
869                         location.sourceStart,
870                         location.sourceEnd);
871         }
872 }
873 public void methodMustOverride(AbstractMethodDeclaration method) {
874         MethodBinding binding = method.binding;
875         this.handle(
876                 IProblem.MethodMustOverride,
877                 new String[] {new String(binding.selector), typesAsString(binding.isVarargs(), binding.parameters, false), new String(binding.declaringClass.readableName()), },
878                 new String[] {new String(binding.selector), typesAsString(binding.isVarargs(), binding.parameters, true), new String(binding.declaringClass.shortReadableName()),},
879                 method.sourceStart,
880                 method.sourceEnd);
881 }
882 public void deprecatedType(TypeBinding type, ASTNode location) {
883         if (location == null) return; // 1G828DN - no type ref for synthetic arguments
884         this.handle(
885                 IProblem.UsingDeprecatedType,
886                 new String[] {new String(type.readableName())},
887                 new String[] {new String(type.shortReadableName())},
888                 location.sourceStart,
889                 location.sourceEnd);
890 }
891 public void duplicateAnnotation(Annotation annotation) {
892         this.handle(
893                 IProblem.DuplicateAnnotation,
894                 new String[] {new String(annotation.resolvedType.readableName())},
895                 new String[] {new String(annotation.resolvedType.shortReadableName())},
896                 annotation.sourceStart,
897                 annotation.sourceEnd);
898 }
899 public void duplicateAnnotationValue(TypeBinding annotationType, MemberValuePair memberValuePair) {
900         String name =   new String(memberValuePair.name);
901         this.handle(
902                 IProblem.DuplicateAnnotationMember,
903                 new String[] { name, new String(annotationType.readableName())},
904                 new String[] {  name, new String(annotationType.shortReadableName())},
905                 memberValuePair.sourceStart,
906                 memberValuePair.sourceEnd);
907 }
908 public void duplicateTargetInTargetAnnotation(TypeBinding annotationType, NameReference reference) {
909         String name =   new String(reference.fieldBinding().name);
910         this.handle(
911                 IProblem.DuplicateTargetInTargetAnnotation,
912                 new String[] { name, new String(annotationType.readableName())},
913                 new String[] {  name, new String(annotationType.shortReadableName())},
914                 reference.sourceStart,
915                 reference.sourceEnd);
916 }
917 public void duplicateCase(CaseStatement caseStatement) {
918         this.handle(
919                 IProblem.DuplicateCase,
920                 NoArgument,
921                 NoArgument,
922                 caseStatement.sourceStart,
923                 caseStatement.sourceEnd);
924 }
925 public void duplicateDefaultCase(ASTNode statement) {
926         this.handle(
927                 IProblem.DuplicateDefaultCase,
928                 NoArgument,
929                 NoArgument,
930                 statement.sourceStart,
931                 statement.sourceEnd);
932 }
933 public void duplicateFieldInType(SourceTypeBinding type, FieldDeclaration fieldDecl) {
934         this.handle(
935                 IProblem.DuplicateField,
936                 new String[] {new String(type.sourceName()), new String(fieldDecl.name)},
937                 new String[] {new String(type.shortReadableName()), new String(fieldDecl.name)},
938                 fieldDecl.sourceStart,
939                 fieldDecl.sourceEnd);
940 }
941
942 public void duplicateImport(ImportReference importRef) {
943         String[] arguments = new String[] {CharOperation.toString(importRef.tokens)};
944         this.handle(
945                 IProblem.DuplicateImport,
946                 arguments,
947                 arguments,
948                 importRef.sourceStart,
949                 importRef.sourceEnd);
950 }
951 public void duplicateInheritedMethods(SourceTypeBinding type, MethodBinding inheritedMethod1, MethodBinding inheritedMethod2) {
952         this.handle(
953                 IProblem.DuplicateParameterizedMethods,
954                 new String[] {
955                 new String(inheritedMethod1.selector),
956                         new String(inheritedMethod1.declaringClass.readableName()),
957                         typesAsString(inheritedMethod1.isVarargs(), inheritedMethod1.original().parameters, false),     
958                         typesAsString(inheritedMethod2.isVarargs(), inheritedMethod2.original().parameters, false)},
959                 new String[] {
960                         new String(inheritedMethod1.selector),
961                         new String(inheritedMethod1.declaringClass.shortReadableName()),
962                         typesAsString(inheritedMethod1.isVarargs(), inheritedMethod1.original().parameters, true),      
963                         typesAsString(inheritedMethod2.isVarargs(), inheritedMethod2.original().parameters, true)},
964                 type.sourceStart(),
965                 type.sourceEnd());
966 }
967 public void duplicateInitializationOfBlankFinalField(FieldBinding field, Reference reference) {
968         String[] arguments = new String[]{ new String(field.readableName())};
969         this.handle(
970                 IProblem.DuplicateBlankFinalFieldInitialization,
971                 arguments,
972                 arguments,
973                 reference.sourceStart,
974                 reference.sourceEnd);
975 }
976 public void duplicateInitializationOfFinalLocal(LocalVariableBinding local, ASTNode location) {
977         String[] arguments = new String[] { new String(local.readableName())};
978         this.handle(
979                 IProblem.DuplicateFinalLocalInitialization,
980                 arguments,
981                 arguments,
982                 location.sourceStart,
983                 location.sourceEnd);
984 }
985
986 public void duplicateEnumSpecialMethod(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
987     MethodBinding method = methodDecl.binding;
988         this.handle(
989                 IProblem.CannotDeclareEnumSpecialMethod,
990                 new String[] {
991                 new String(methodDecl.selector),
992                         new String(method.declaringClass.readableName()),
993                         typesAsString(method.isVarargs(), method.parameters, false)},
994                 new String[] {
995                         new String(methodDecl.selector),
996                         new String(method.declaringClass.shortReadableName()),
997                         typesAsString(method.isVarargs(), method.parameters, true)},
998                 methodDecl.sourceStart,
999                 methodDecl.sourceEnd);
1000 }
1001
1002 public void duplicateMethodInType(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
1003     MethodBinding method = methodDecl.binding;
1004     boolean duplicateErasure = false;
1005     if ((method.modifiers & CompilerModifiers.AccGenericSignature) != 0) {
1006         // chech it occurs in parameters (the bit is set for return type | params | thrown exceptions
1007         for (int i = 0, length = method.parameters.length; i < length; i++) {
1008             if ((method.parameters[i].tagBits & TagBits.HasTypeVariable) != 0) {
1009                 duplicateErasure = true;
1010                 break;
1011             }
1012         }
1013     }
1014     if (duplicateErasure) {
1015         int length = method.parameters.length;
1016         TypeBinding[] erasures = new TypeBinding[length];
1017         for (int i = 0; i < length; i++)  {
1018             erasures[i] = method.parameters[i].erasure();
1019         }
1020                 this.handle(
1021                         IProblem.DuplicateMethodErasure,
1022                         new String[] {
1023                         new String(methodDecl.selector),
1024                                 new String(method.declaringClass.readableName()),
1025                                 typesAsString(method.isVarargs(), method.parameters, false),
1026                                 typesAsString(method.isVarargs(), erasures, false) } ,
1027                         new String[] {
1028                                 new String(methodDecl.selector),
1029                                 new String(method.declaringClass.shortReadableName()),
1030                                 typesAsString(method.isVarargs(), method.parameters, true),
1031                                 typesAsString(method.isVarargs(), erasures, true) },
1032                         methodDecl.sourceStart,
1033                         methodDecl.sourceEnd);
1034     } else {
1035                 this.handle(
1036                         IProblem.DuplicateMethod,
1037                         new String[] {
1038                         new String(methodDecl.selector),
1039                                 new String(method.declaringClass.readableName()),
1040                                 typesAsString(method.isVarargs(), method.parameters, false)},
1041                         new String[] {
1042                                 new String(methodDecl.selector),
1043                                 new String(method.declaringClass.shortReadableName()),
1044                                 typesAsString(method.isVarargs(), method.parameters, true)},
1045                         methodDecl.sourceStart,
1046                         methodDecl.sourceEnd);
1047     }
1048 }
1049 public void duplicateModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
1050 /* to highlight modifiers use:
1051         this.handle(
1052                 new Problem(
1053                         DuplicateModifierForField,
1054                         new String[] {new String(fieldDecl.name)},
1055                         fieldDecl.modifiers.sourceStart,
1056                         fieldDecl.modifiers.sourceEnd));
1057 */
1058         String[] arguments = new String[] {new String(fieldDecl.name)};
1059         this.handle(
1060                 IProblem.DuplicateModifierForField,
1061                 arguments,
1062                 arguments,
1063                 fieldDecl.sourceStart,
1064                 fieldDecl.sourceEnd);
1065 }
1066 public void duplicateModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
1067         this.handle(
1068                 IProblem.DuplicateModifierForMethod,
1069                 new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
1070                 new String[] {new String(type.shortReadableName()), new String(methodDecl.selector)},
1071                 methodDecl.sourceStart,
1072                 methodDecl.sourceEnd);
1073 }
1074 public void duplicateModifierForType(SourceTypeBinding type) {
1075         String[] arguments = new String[] {new String(type.sourceName())};
1076         this.handle(
1077                 IProblem.DuplicateModifierForType,
1078                 arguments,
1079                 arguments,
1080                 type.sourceStart(),
1081                 type.sourceEnd());
1082 }
1083 public void duplicateModifierForVariable(LocalDeclaration localDecl, boolean complainForArgument) {
1084         String[] arguments = new String[] {new String(localDecl.name)};
1085         this.handle(
1086                 complainForArgument
1087                         ? IProblem.DuplicateModifierForArgument 
1088                         : IProblem.DuplicateModifierForVariable,
1089                 arguments,
1090                 arguments,
1091                 localDecl.sourceStart,
1092                 localDecl.sourceEnd);
1093 }
1094 public void duplicateNestedType(TypeDeclaration typeDecl) {
1095         String[] arguments = new String[] {new String(typeDecl.name)};
1096         this.handle(
1097                 IProblem.DuplicateNestedType,
1098                 arguments,
1099                 arguments,
1100                 typeDecl.sourceStart,
1101                 typeDecl.sourceEnd);
1102 }
1103 public void duplicateSuperinterface(SourceTypeBinding type, TypeDeclaration typeDecl, ReferenceBinding superType) {
1104         this.handle(
1105                 IProblem.DuplicateSuperInterface,
1106                 new String[] {
1107                         new String(superType.readableName()),
1108                         new String(type.sourceName())},
1109                 new String[] {
1110                         new String(superType.shortReadableName()),
1111                         new String(type.sourceName())},
1112                 typeDecl.sourceStart,
1113                 typeDecl.sourceEnd);
1114 }
1115 public void duplicateTypeParameterInType(TypeParameter typeParameter) {
1116         this.handle(
1117                 IProblem.DuplicateTypeVariable,
1118                 new String[] { new String(typeParameter.name)},
1119                 new String[] { new String(typeParameter.name)},
1120                 typeParameter.sourceStart,
1121                 typeParameter.sourceEnd);
1122 }
1123 public void duplicateTypes(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
1124         String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
1125         this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
1126         this.handle(
1127                 IProblem.DuplicateTypes,
1128                 arguments,
1129                 arguments,
1130                 typeDecl.sourceStart,
1131                 typeDecl.sourceEnd,
1132                 compUnitDecl.compilationResult);
1133 }
1134 public void emptyControlFlowStatement(int sourceStart, int sourceEnd) {
1135         this.handle(
1136                 IProblem.EmptyControlFlowStatement,
1137                 NoArgument,
1138                 NoArgument,
1139                 sourceStart,
1140                 sourceEnd);     
1141 }
1142 public void enumAbstractMethodMustBeImplemented(AbstractMethodDeclaration method) {
1143         MethodBinding abstractMethod = method.binding;
1144         this.handle(
1145                 // Must implement the inherited abstract method %1
1146                 // 8.4.3 - Every non-abstract subclass of an abstract type, A, must provide a concrete implementation of all of A's methods.
1147                 IProblem.EnumAbstractMethodMustBeImplemented,
1148                 new String[] { 
1149                         new String(abstractMethod.selector),
1150                         typesAsString(abstractMethod.isVarargs(), abstractMethod.parameters, false), 
1151                         new String(abstractMethod.declaringClass.readableName()), 
1152                 },
1153                 new String[] { 
1154                         new String(abstractMethod.selector),
1155                         typesAsString(abstractMethod.isVarargs(), abstractMethod.parameters, true), 
1156                         new String(abstractMethod.declaringClass.shortReadableName()), 
1157                 },
1158                 method.sourceStart(),
1159                 method.sourceEnd());
1160 }
1161
1162 public void errorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params) {
1163         StringBuffer buffer = new StringBuffer();
1164         StringBuffer shortBuffer = new StringBuffer();
1165         for (int i = 0, length = params.length; i < length; i++) {
1166                 if (i != 0){
1167                         buffer.append(", "); //$NON-NLS-1$
1168                         shortBuffer.append(", "); //$NON-NLS-1$
1169                 }
1170                 buffer.append(new String(params[i].readableName()));
1171                 shortBuffer.append(new String(params[i].shortReadableName()));
1172         }
1173
1174         int id = recType.isArrayType() ? IProblem.NoMessageSendOnArrayType : IProblem.NoMessageSendOnBaseType;
1175         /*
1176         if ((messageSend.bits & ASTNode.InsideJavadoc) != 0) {
1177                 id |= IProblem.Javadoc;
1178                 if (!reportInvalidJavadocTagsVisibility()) return;
1179         }
1180         */
1181         this.handle(
1182                 id,
1183                 new String[] {new String(recType.readableName()), new String(messageSend.selector), buffer.toString()},
1184                 new String[] {new String(recType.shortReadableName()), new String(messageSend.selector), shortBuffer.toString()},
1185                 messageSend.sourceStart,
1186                 messageSend.sourceEnd);
1187 }
1188 public void errorThisSuperInStatic(ASTNode reference) {
1189         String[] arguments = new String[] {reference.isSuper() ? "super" : "this"}; //$NON-NLS-2$ //$NON-NLS-1$
1190         this.handle(
1191                 IProblem.ThisInStaticContext,
1192                 arguments,
1193                 arguments,
1194                 reference.sourceStart,
1195                 reference.sourceEnd);
1196 }
1197 public void cannotInvokeSuperConstructorInEnum(ExplicitConstructorCall constructorCall, MethodBinding enumConstructor) {
1198         this.handle(
1199                 IProblem.CannotInvokeSuperConstructorInEnum,
1200                 new String[] { 
1201                         new String(enumConstructor.declaringClass.sourceName()),
1202                         typesAsString(enumConstructor.isVarargs(), enumConstructor.parameters, false), 
1203                  },
1204                 new String[] { 
1205                         new String(enumConstructor.declaringClass.sourceName()),
1206                         typesAsString(enumConstructor.isVarargs(), enumConstructor.parameters, true), 
1207                  },
1208                 constructorCall.sourceStart,
1209                 constructorCall.sourceEnd);
1210 }
1211 public void expressionShouldBeAVariable(Expression expression) {
1212         this.handle(
1213                 IProblem.ExpressionShouldBeAVariable,
1214                 NoArgument,
1215                 NoArgument,
1216                 expression.sourceStart,
1217                 expression.sourceEnd);
1218 }
1219 public void fieldHiding(FieldDeclaration fieldDecl, Binding hiddenVariable) {
1220         FieldBinding field = fieldDecl.binding;
1221         if (CharOperation.equals(TypeConstants.SERIALVERSIONUID, field.name)
1222                         && field.isStatic()
1223                         && field.isFinal()
1224                         && BaseTypes.LongBinding == field.type) {
1225                                 return; // do not report unused serialVersionUID field
1226         }
1227         if (CharOperation.equals(TypeConstants.SERIALPERSISTENTFIELDS, field.name)
1228                         && field.isStatic()
1229                         && field.isFinal()
1230                         && field.type.dimensions() == 1
1231                         && CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTSTREAMFIELD, field.type.leafComponentType().readableName())) {
1232                                 return; // do not report unused serialPersistentFields field
1233         }
1234         
1235         if (hiddenVariable instanceof LocalVariableBinding) {
1236                 this.handle(
1237                         IProblem.FieldHidingLocalVariable,
1238                         new String[] {new String(field.declaringClass.readableName()), new String(field.name) },
1239                         new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name) },
1240                         fieldDecl.sourceStart,
1241                         fieldDecl.sourceEnd);
1242         } else if (hiddenVariable instanceof FieldBinding) {
1243                 FieldBinding hiddenField = (FieldBinding) hiddenVariable;
1244                 this.handle(
1245                         IProblem.FieldHidingField,
1246                         new String[] {new String(field.declaringClass.readableName()), new String(field.name) , new String(hiddenField.declaringClass.readableName())  },
1247                         new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name) , new String(hiddenField.declaringClass.shortReadableName()) },
1248                         fieldDecl.sourceStart,
1249                         fieldDecl.sourceEnd);
1250         }
1251 }
1252 private int fieldLocation(FieldBinding field, ASTNode node) {
1253         if (node instanceof QualifiedNameReference) {
1254                 QualifiedNameReference ref = (QualifiedNameReference) node;
1255                 FieldBinding[] bindings = ref.otherBindings;
1256                 if (bindings != null)
1257                         for (int i = bindings.length; --i >= 0;)
1258                                 if (bindings[i] == field)
1259                                         return (int) ref.sourcePositions[i + 1]; // first position is for the primary field
1260         }
1261         return node.sourceEnd;
1262 }
1263 public void fieldsOrThisBeforeConstructorInvocation(ThisReference reference) {
1264         this.handle(
1265                 IProblem.ThisSuperDuringConstructorInvocation,
1266                 NoArgument,
1267                 NoArgument,
1268                 reference.sourceStart,
1269                 reference.sourceEnd);
1270 }
1271 public void finallyMustCompleteNormally(Block finallyBlock) {
1272         this.handle(
1273                 IProblem.FinallyMustCompleteNormally,
1274                 NoArgument,
1275                 NoArgument,
1276                 finallyBlock.sourceStart,
1277                 finallyBlock.sourceEnd);
1278 }
1279 public void finalMethodCannotBeOverridden(MethodBinding currentMethod, MethodBinding inheritedMethod) {
1280         this.handle(
1281                 // Cannot override the final method from %1
1282                 // 8.4.3.3 - Final methods cannot be overridden or hidden.
1283                 IProblem.FinalMethodCannotBeOverridden,
1284                 new String[] {new String(inheritedMethod.declaringClass.readableName())},
1285                 new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
1286                 currentMethod.sourceStart(),
1287                 currentMethod.sourceEnd());
1288 }
1289 public void finalVariableBound(TypeVariableBinding typeVariable, TypeReference typeRef) {
1290         this.handle(
1291                 IProblem.FinalBoundForTypeVariable,
1292                 new String[] { new String(typeVariable.sourceName), new String(typeRef.resolvedType.readableName())},
1293                 new String[] { new String(typeVariable.sourceName), new String(typeRef.resolvedType.shortReadableName())},
1294                 typeRef.sourceStart,
1295                 typeRef.sourceEnd);
1296 }
1297 public void forbiddenReference(TypeBinding type, ASTNode location, String messageTemplate) {
1298         if (location == null) return; 
1299         // this problem has a message template extracted from the access restriction rule
1300         this.handle(
1301                 IProblem.ForbiddenReference,
1302                 new String[] { new String(type.readableName()) }, // distinct from msg arg for quickfix purpose
1303                 new String[] { Util.bindMessage(messageTemplate, new String[]{ new String(type.shortReadableName()) } ) },
1304                 location.sourceStart,
1305                 location.sourceEnd);
1306 }
1307 public void forwardReference(Reference reference, int indexInQualification, TypeBinding type) {
1308         this.handle(
1309                 IProblem.ReferenceToForwardField,
1310                 NoArgument,
1311                 NoArgument,
1312                 reference.sourceStart,
1313                 reference.sourceEnd);
1314 }
1315 public void forwardTypeVariableReference(ASTNode location, TypeVariableBinding type) {
1316         this.handle(
1317                 IProblem.ReferenceToForwardTypeVariable,
1318                 new String[] {new String(type.readableName())},
1319                 new String[] {new String(type.shortReadableName())},
1320                 location.sourceStart,
1321                 location.sourceEnd);
1322 }
1323 public void genericTypeCannotExtendThrowable(TypeDeclaration typeDecl) {
1324         this.handle(
1325                 IProblem.GenericTypeCannotExtendThrowable,
1326                 new String[]{ new String(typeDecl.binding.readableName()) },
1327                 new String[]{ new String(typeDecl.binding.shortReadableName()) },
1328                 typeDecl.superclass.sourceStart,
1329                 typeDecl.superclass.sourceEnd);
1330 }
1331 // use this private API when the compilation unit result can be found through the
1332 // reference context. Otherwise, use the other API taking a problem and a compilation result
1333 // as arguments
1334 private void handle(
1335         int problemId, 
1336         String[] problemArguments,
1337         String[] messageArguments,
1338         int problemStartPosition, 
1339         int problemEndPosition){
1340
1341         this.handle(
1342                         problemId,
1343                         problemArguments,
1344                         messageArguments,
1345                         problemStartPosition,
1346                         problemEndPosition,
1347                         this.referenceContext, 
1348                         this.referenceContext == null ? null : this.referenceContext.compilationResult()); 
1349         this.referenceContext = null;
1350 }
1351 // use this private API when the compilation unit result cannot be found through the
1352 // reference context. 
1353
1354 private void handle(
1355         int problemId, 
1356         String[] problemArguments,
1357         String[] messageArguments,
1358         int problemStartPosition, 
1359         int problemEndPosition,
1360         CompilationResult unitResult){
1361
1362         this.handle(
1363                         problemId,
1364                         problemArguments,
1365                         messageArguments,
1366                         problemStartPosition,
1367                         problemEndPosition,
1368                         this.referenceContext, 
1369                         unitResult); 
1370         this.referenceContext = null;
1371 }
1372 // use this private API when the compilation unit result can be found through the
1373 // reference context. Otherwise, use the other API taking a problem and a compilation result
1374 // as arguments
1375 private void handle(
1376         int problemId, 
1377         String[] problemArguments,
1378         String[] messageArguments,
1379         int severity,
1380         int problemStartPosition, 
1381         int problemEndPosition){
1382
1383         this.handle(
1384                         problemId,
1385                         problemArguments,
1386                         messageArguments,
1387                         severity,
1388                         problemStartPosition,
1389                         problemEndPosition,
1390                         this.referenceContext, 
1391                         this.referenceContext == null ? null : this.referenceContext.compilationResult()); 
1392         this.referenceContext = null;
1393 }
1394 public void hiddenCatchBlock(ReferenceBinding exceptionType, ASTNode location) {
1395         this.handle(
1396                 IProblem.MaskedCatch,
1397                 new String[] {
1398                         new String(exceptionType.readableName()),
1399                  }, 
1400                 new String[] {
1401                         new String(exceptionType.shortReadableName()),
1402                  }, 
1403                 location.sourceStart,
1404                 location.sourceEnd);
1405 }
1406 public void hidingEnclosingType(TypeDeclaration typeDecl) {
1407         String[] arguments = new String[] {new String(typeDecl.name)};
1408         this.handle(
1409                 IProblem.HidingEnclosingType,
1410                 arguments,
1411                 arguments,
1412                 typeDecl.sourceStart,
1413                 typeDecl.sourceEnd);
1414 }
1415 public void hierarchyCircularity(SourceTypeBinding sourceType, ReferenceBinding superType, TypeReference reference) {
1416         int start = 0;
1417         int end = 0;
1418
1419         if (reference == null) {        // can only happen when java.lang.Object is busted
1420                 start = sourceType.sourceStart();
1421                 end = sourceType.sourceEnd();
1422         } else {
1423                 start = reference.sourceStart;
1424                 end = reference.sourceEnd;
1425         }
1426
1427         if (sourceType == superType)
1428                 this.handle(
1429                         IProblem.HierarchyCircularitySelfReference,
1430                         new String[] {new String(sourceType.readableName()) },
1431                         new String[] {new String(sourceType.shortReadableName()) },
1432                         start,
1433                         end);
1434         else
1435                 this.handle(
1436                         IProblem.HierarchyCircularity,
1437                         new String[] {new String(sourceType.readableName()), new String(superType.readableName())},
1438                         new String[] {new String(sourceType.shortReadableName()), new String(superType.shortReadableName())},
1439                         start,
1440                         end);
1441 }
1442 public void hierarchyHasProblems(SourceTypeBinding type) {
1443         String[] arguments = new String[] {new String(type.sourceName())};
1444         this.handle(
1445                 IProblem.HierarchyHasProblems,
1446                 arguments,
1447                 arguments,
1448                 type.sourceStart(),
1449                 type.sourceEnd());
1450 }
1451 public void illegalAbstractModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
1452         String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
1453         this.handle(
1454                 IProblem.IllegalAbstractModifierCombinationForMethod,
1455                 arguments,
1456                 arguments,
1457                 methodDecl.sourceStart,
1458                 methodDecl.sourceEnd);
1459 }
1460 public void illegalClassLiteralForTypeVariable(TypeVariableBinding variable, ASTNode location) {
1461         String[] arguments = new String[] { new String(variable.sourceName) };
1462         this.handle(
1463                 IProblem.IllegalClassLiteralForTypeVariable,
1464                 arguments, 
1465                 arguments,
1466                 location.sourceStart,
1467                 location.sourceEnd);
1468 }
1469 public void illegalExtendedDimensions(AnnotationMethodDeclaration annotationTypeMemberDeclaration) {
1470         this.handle(
1471                 IProblem.IllegalExtendedDimensions,
1472                 NoArgument, 
1473                 NoArgument, 
1474                 annotationTypeMemberDeclaration.sourceStart,
1475                 annotationTypeMemberDeclaration.sourceEnd);
1476 }
1477 public void illegalExtendedDimensions(Argument argument) {
1478         this.handle(
1479                 IProblem.IllegalExtendedDimensionsForVarArgs,
1480                 NoArgument, 
1481                 NoArgument, 
1482                 argument.sourceStart,
1483                 argument.sourceEnd);
1484 }
1485 public void illegalGenericArray(TypeBinding leadtComponentType, ASTNode location) {
1486         this.handle(
1487                 IProblem.IllegalGenericArray,
1488                 new String[]{ new String(leadtComponentType.readableName())},
1489                 new String[]{ new String(leadtComponentType.shortReadableName())},
1490                 location.sourceStart,
1491                 location.sourceEnd);
1492 }
1493 public void illegalInstanceOfGenericType(TypeBinding checkedType, ASTNode location) {
1494         if (checkedType.isTypeVariable()) {
1495                 this.handle(
1496                 IProblem.IllegalInstanceofTypeParameter,
1497                         new String[] { new String(checkedType.readableName()), new String(checkedType.erasure().readableName())},
1498                         new String[] { new String(checkedType.shortReadableName()), new String(checkedType.erasure().shortReadableName())},
1499                         location.sourceStart,
1500                         location.sourceEnd);
1501                 return;
1502         }
1503         this.handle(
1504                 IProblem.IllegalInstanceofParameterizedType,
1505                 new String[] { new String(checkedType.readableName()), new String(checkedType.erasure().sourceName())},
1506                 new String[] { new String(checkedType.shortReadableName()), new String(checkedType.erasure().sourceName())},
1507                 location.sourceStart,
1508                 location.sourceEnd);
1509 }
1510 public void illegalModifierCombinationFinalAbstractForClass(SourceTypeBinding type) {
1511         String[] arguments = new String[] {new String(type.sourceName())};
1512         this.handle(
1513                 IProblem.IllegalModifierCombinationFinalAbstractForClass,
1514                 arguments,
1515                 arguments,
1516                 type.sourceStart(),
1517                 type.sourceEnd());
1518 }
1519 public void illegalModifierCombinationFinalVolatileForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
1520         String[] arguments = new String[] {new String(fieldDecl.name)};
1521
1522         this.handle(
1523                 IProblem.IllegalModifierCombinationFinalVolatileForField,
1524                 arguments,
1525                 arguments,
1526                 fieldDecl.sourceStart,
1527                 fieldDecl.sourceEnd);
1528 }
1529
1530 public void illegalModifierForClass(SourceTypeBinding type) {
1531         String[] arguments = new String[] {new String(type.sourceName())};
1532         this.handle(
1533                 IProblem.IllegalModifierForClass,
1534                 arguments,
1535                 arguments,
1536                 type.sourceStart(),
1537                 type.sourceEnd());
1538 }
1539 public void illegalModifierForEnum(SourceTypeBinding type) {
1540         String[] arguments = new String[] {new String(type.sourceName())};
1541         this.handle(
1542                 IProblem.IllegalModifierForEnum,
1543                 arguments,
1544                 arguments,
1545                 type.sourceStart(),
1546                 type.sourceEnd());
1547 }
1548 public void illegalModifierForLocalEnum(SourceTypeBinding type) {
1549         String[] arguments = new String[] {new String(type.sourceName())};
1550         this.handle(
1551                 IProblem.IllegalModifierForLocalEnum,
1552                 arguments,
1553                 arguments,
1554                 type.sourceStart(),
1555                 type.sourceEnd());
1556 }
1557 public void illegalModifierForMemberEnum(SourceTypeBinding type) {
1558         String[] arguments = new String[] {new String(type.sourceName())};
1559         this.handle(
1560                 IProblem.IllegalModifierForMemberEnum,
1561                 arguments,
1562                 arguments,
1563                 type.sourceStart(),
1564                 type.sourceEnd());
1565 }
1566 public void illegalModifierForEnumConstant(ReferenceBinding type, FieldDeclaration fieldDecl) {
1567         String[] arguments = new String[] {new String(fieldDecl.name)};
1568         this.handle(
1569                 IProblem.IllegalModifierForEnumConstant,
1570                 arguments,
1571                 arguments,
1572                 fieldDecl.sourceStart,
1573                 fieldDecl.sourceEnd);
1574 }
1575 public void illegalModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
1576         String[] arguments = new String[] {new String(fieldDecl.name)};
1577         this.handle(
1578                 IProblem.IllegalModifierForField,
1579                 arguments,
1580                 arguments,
1581                 fieldDecl.sourceStart,
1582                 fieldDecl.sourceEnd);
1583 }
1584 public void illegalModifierForInterface(SourceTypeBinding type) {
1585         String[] arguments = new String[] {new String(type.sourceName())};
1586         this.handle(
1587                 IProblem.IllegalModifierForInterface,
1588                 arguments,
1589                 arguments,
1590                 type.sourceStart(),
1591                 type.sourceEnd());
1592 }
1593 public void illegalModifierForInterfaceField(FieldDeclaration fieldDecl) {
1594         String name = new String(fieldDecl.name);
1595         this.handle(
1596                 IProblem.IllegalModifierForInterfaceField,
1597                 new String[] {
1598                         new String(fieldDecl.binding.declaringClass.readableName()),
1599                         name,
1600                 },              
1601                 new String[] {
1602                         new String(fieldDecl.binding.declaringClass.shortReadableName()),
1603                         name,
1604                 },              
1605                 fieldDecl.sourceStart,
1606                 fieldDecl.sourceEnd);
1607 }
1608 public void illegalModifierForInterfaceMethod(AbstractMethodDeclaration methodDecl) {
1609         this.handle(
1610                 IProblem.IllegalModifierForInterfaceMethod,
1611                 new String[] {
1612                         new String(methodDecl.binding.declaringClass.readableName()),
1613                         new String(methodDecl.selector),
1614                         typesAsString(methodDecl.binding.isVarargs(), methodDecl.binding.parameters, false),
1615                 },              
1616                 new String[] {
1617                         new String(methodDecl.binding.declaringClass.shortReadableName()),
1618                         new String(methodDecl.selector),
1619                         typesAsString(methodDecl.binding.isVarargs(), methodDecl.binding.parameters, true),
1620                 },      
1621                 methodDecl.sourceStart,
1622                 methodDecl.sourceEnd);
1623 }
1624 public void illegalModifierForLocalClass(SourceTypeBinding type) {
1625         String[] arguments = new String[] {new String(type.sourceName())};
1626         this.handle(
1627                 IProblem.IllegalModifierForLocalClass,
1628                 arguments,
1629                 arguments,
1630                 type.sourceStart(),
1631                 type.sourceEnd());
1632 }
1633 public void illegalModifierForMemberClass(SourceTypeBinding type) {
1634         String[] arguments = new String[] {new String(type.sourceName())};
1635         this.handle(
1636                 IProblem.IllegalModifierForMemberClass,
1637                 arguments,
1638                 arguments,
1639                 type.sourceStart(),
1640                 type.sourceEnd());
1641 }
1642 public void illegalModifierForMemberInterface(SourceTypeBinding type) {
1643         String[] arguments = new String[] {new String(type.sourceName())};
1644         this.handle(
1645                 IProblem.IllegalModifierForMemberInterface,
1646                 arguments,
1647                 arguments,
1648                 type.sourceStart(),
1649                 type.sourceEnd());
1650 }
1651 public void illegalModifierForAnnotationType(SourceTypeBinding type) {
1652         String[] arguments = new String[] {new String(type.sourceName())};
1653         this.handle(
1654                 IProblem.IllegalModifierForAnnotationType,
1655                 arguments,
1656                 arguments,
1657                 type.sourceStart(),
1658                 type.sourceEnd());
1659 }
1660 public void illegalModifierForAnnotationMemberType(SourceTypeBinding type) {
1661         String[] arguments = new String[] {new String(type.sourceName())};
1662         this.handle(
1663                 IProblem.IllegalModifierForAnnotationMemberType,
1664                 arguments,
1665                 arguments,
1666                 type.sourceStart(),
1667                 type.sourceEnd());
1668 }
1669 public void illegalModifierForAnnotationField(FieldDeclaration fieldDecl) {
1670         String name = new String(fieldDecl.name);
1671         this.handle(
1672                 IProblem.IllegalModifierForAnnotationField,
1673                 new String[] {
1674                         new String(fieldDecl.binding.declaringClass.readableName()),
1675                         name,
1676                 },              
1677                 new String[] {
1678                         new String(fieldDecl.binding.declaringClass.shortReadableName()),
1679                         name,
1680                 },              
1681                 fieldDecl.sourceStart,
1682                 fieldDecl.sourceEnd);
1683 }
1684
1685 public void illegalModifierForAnnotationMember(AbstractMethodDeclaration methodDecl) {
1686         this.handle(
1687                 IProblem.IllegalModifierForAnnotationMethod,
1688                 new String[] {
1689                         new String(methodDecl.binding.declaringClass.readableName()),
1690                         new String(methodDecl.selector),
1691                 },              
1692                 new String[] {
1693                         new String(methodDecl.binding.declaringClass.shortReadableName()),
1694                         new String(methodDecl.selector),
1695                 },              
1696                 methodDecl.sourceStart,
1697                 methodDecl.sourceEnd);
1698 }
1699 public void illegalModifierForMethod(AbstractMethodDeclaration methodDecl) {
1700         this.handle(
1701                 IProblem.IllegalModifierForMethod,
1702                 new String[] {
1703                         new String(methodDecl.selector),
1704                         typesAsString(methodDecl.binding.isVarargs(), methodDecl.binding.parameters, false),
1705                         new String(methodDecl.binding.declaringClass.readableName()),
1706                 },              
1707                 new String[] {
1708                         new String(methodDecl.selector),
1709                         typesAsString(methodDecl.binding.isVarargs(), methodDecl.binding.parameters, true),
1710                         new String(methodDecl.binding.declaringClass.shortReadableName()),
1711                 },      
1712                 methodDecl.sourceStart,
1713                 methodDecl.sourceEnd);
1714 }
1715 public void illegalModifierForVariable(LocalDeclaration localDecl, boolean complainAsArgument) {
1716         String[] arguments = new String[] {new String(localDecl.name)};
1717         this.handle(
1718                 complainAsArgument
1719                         ? IProblem.IllegalModifierForArgument
1720                         : IProblem.IllegalModifierForVariable,
1721                 arguments,
1722                 arguments,
1723                 localDecl.sourceStart,
1724                 localDecl.sourceEnd);
1725 }
1726 public void illegalPrimitiveOrArrayTypeForEnclosingInstance(TypeBinding enclosingType, ASTNode location) {
1727         this.handle(
1728                 IProblem.IllegalPrimitiveOrArrayTypeForEnclosingInstance,
1729                 new String[] {new String(enclosingType.readableName())},
1730                 new String[] {new String(enclosingType.shortReadableName())},
1731                 location.sourceStart,
1732                 location.sourceEnd);
1733 }
1734 public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
1735         String[] arguments = new String[] {new String(type.sourceName())};
1736         this.handle(
1737                 IProblem.IllegalStaticModifierForMemberType,
1738                 arguments,
1739                 arguments,
1740                 type.sourceStart(),
1741                 type.sourceEnd());
1742 }
1743 public void illegalUsageOfQualifiedTypeReference(QualifiedTypeReference qualifiedTypeReference) {
1744         StringBuffer buffer = new StringBuffer();
1745         char[][] tokens = qualifiedTypeReference.tokens;
1746         for (int i = 0; i < tokens.length; i++) {
1747                 if (i > 0) buffer.append('.');
1748                 buffer.append(tokens[i]);
1749         }
1750         String[] arguments = new String[] { String.valueOf(buffer)};
1751         this.handle(
1752                 IProblem.IllegalUsageOfQualifiedTypeReference,
1753                 arguments,
1754                 arguments,
1755                 qualifiedTypeReference.sourceStart,
1756                 qualifiedTypeReference.sourceEnd);      
1757 }
1758 public void illegalVararg(Argument argType, AbstractMethodDeclaration methodDecl) {
1759         String[] arguments = new String[] {CharOperation.toString(argType.type.getTypeName()), new String(methodDecl.selector)};
1760         this.handle(
1761                 IProblem.IllegalVararg,
1762                 arguments,
1763                 arguments,
1764                 argType.sourceStart,
1765                 argType.sourceEnd);
1766 }
1767 public void illegalVisibilityModifierCombinationForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
1768         String[] arguments = new String[] {new String(fieldDecl.name)};
1769         this.handle(
1770                 IProblem.IllegalVisibilityModifierCombinationForField,
1771                 arguments,
1772                 arguments,
1773                 fieldDecl.sourceStart,
1774                 fieldDecl.sourceEnd);
1775 }
1776 public void illegalVisibilityModifierCombinationForMemberType(SourceTypeBinding type) {
1777         String[] arguments = new String[] {new String(type.sourceName())};
1778         this.handle(
1779                 IProblem.IllegalVisibilityModifierCombinationForMemberType,
1780                 arguments,
1781                 arguments,
1782                 type.sourceStart(),
1783                 type.sourceEnd());
1784 }
1785 public void illegalVisibilityModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
1786         String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
1787         this.handle(
1788                 IProblem.IllegalVisibilityModifierCombinationForMethod,
1789                 arguments,
1790                 arguments,
1791                 methodDecl.sourceStart,
1792                 methodDecl.sourceEnd);
1793 }
1794 public void illegalVisibilityModifierForInterfaceMemberType(SourceTypeBinding type) {
1795         String[] arguments = new String[] {new String(type.sourceName())};
1796         this.handle(
1797                 IProblem.IllegalVisibilityModifierForInterfaceMemberType,
1798                 arguments,
1799                 arguments,
1800                 type.sourceStart(),
1801                 type.sourceEnd());
1802 }
1803 public void illegalVoidExpression(ASTNode location) {
1804         this.handle(
1805                 IProblem.InvalidVoidExpression,
1806                 NoArgument,
1807                 NoArgument,
1808                 location.sourceStart,
1809                 location.sourceEnd);
1810 }
1811 public void importProblem(ImportReference importRef, Binding expectedImport) {
1812         if (expectedImport.problemId() == NotFound) {
1813                 char[][] tokens = expectedImport instanceof ProblemReferenceBinding
1814                         ? ((ProblemReferenceBinding) expectedImport).compoundName
1815                         : importRef.tokens;
1816                 String[] arguments = new String[]{CharOperation.toString(tokens)};
1817                 this.handle(
1818                         IProblem.ImportNotFound, 
1819                         arguments, 
1820                         arguments, 
1821                         importRef.sourceStart, 
1822                         (int) importRef.sourcePositions[tokens.length - 1]);
1823                 return;
1824         }
1825         if (expectedImport.problemId() == InvalidTypeForStaticImport) {
1826                 char[][] tokens = importRef.tokens;
1827                 String[] arguments = new String[]{CharOperation.toString(tokens)};
1828                 this.handle(
1829                         IProblem.InvalidTypeForStaticImport, 
1830                         arguments, 
1831                         arguments, 
1832                         importRef.sourceStart, 
1833                         (int) importRef.sourcePositions[tokens.length - 1]);
1834                 return;
1835         }
1836         invalidType(importRef, (TypeBinding)expectedImport);
1837 }
1838 public void incompatibleExceptionInThrowsClause(SourceTypeBinding type, MethodBinding currentMethod, MethodBinding inheritedMethod, ReferenceBinding exceptionType) {
1839         if (type == currentMethod.declaringClass) {
1840                 int id;
1841                 if (currentMethod.declaringClass.isInterface() 
1842                                 && !inheritedMethod.isPublic()){ // interface inheriting Object protected method
1843                         id = IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod;
1844                 } else {
1845                         id = IProblem.IncompatibleExceptionInThrowsClause;
1846                 }
1847                 this.handle(
1848                         // Exception %1 is not compatible with throws clause in %2
1849                         // 9.4.4 - The type of exception in the throws clause is incompatible.
1850                         id,
1851                         new String[] {
1852                                 new String(exceptionType.sourceName()),
1853                                 new String(
1854                                         CharOperation.concat(
1855                                                 inheritedMethod.declaringClass.readableName(),
1856                                                 inheritedMethod.readableName(),
1857                                                 '.'))},
1858                         new String[] {
1859                                 new String(exceptionType.sourceName()),
1860                                 new String(
1861                                         CharOperation.concat(
1862                                                 inheritedMethod.declaringClass.shortReadableName(),
1863                                                 inheritedMethod.shortReadableName(),
1864                                                 '.'))},
1865                         currentMethod.sourceStart(),
1866                         currentMethod.sourceEnd());
1867         } else  
1868                 this.handle(
1869                         // Exception %1 in throws clause of %2 is not compatible with %3
1870                         // 9.4.4 - The type of exception in the throws clause is incompatible.
1871                         IProblem.IncompatibleExceptionInInheritedMethodThrowsClause,
1872                         new String[] {
1873                                 new String(exceptionType.sourceName()),
1874                                 new String(
1875                                         CharOperation.concat(
1876                                                 currentMethod.declaringClass.sourceName(),
1877                                                 currentMethod.readableName(),
1878                                                 '.')),
1879                                 new String(
1880                                         CharOperation.concat(
1881                                                 inheritedMethod.declaringClass.readableName(),
1882                                                 inheritedMethod.readableName(),
1883                                                 '.'))},
1884                         new String[] {
1885                                 new String(exceptionType.sourceName()),
1886                                 new String(
1887                                         CharOperation.concat(
1888                                                 currentMethod.declaringClass.sourceName(),
1889                                                 currentMethod.shortReadableName(),
1890                                                 '.')),
1891                                 new String(
1892                                         CharOperation.concat(
1893                                                 inheritedMethod.declaringClass.shortReadableName(),
1894                                                 inheritedMethod.shortReadableName(),
1895                                                 '.'))},
1896                         type.sourceStart(),
1897                         type.sourceEnd());
1898 }
1899 public void incompatibleReturnType(MethodBinding currentMethod, MethodBinding inheritedMethod) {
1900         StringBuffer methodSignature = new StringBuffer();
1901         methodSignature
1902                 .append(inheritedMethod.declaringClass.readableName())
1903                 .append('.')
1904                 .append(inheritedMethod.readableName());
1905
1906         StringBuffer shortSignature = new StringBuffer();
1907         shortSignature
1908                 .append(inheritedMethod.declaringClass.shortReadableName())
1909                 .append('.')
1910                 .append(inheritedMethod.shortReadableName());
1911
1912         int id;
1913         if (currentMethod.declaringClass.isInterface() 
1914                         && !inheritedMethod.isPublic()){ // interface inheriting Object protected method
1915                 id = IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod;
1916         } else {
1917                 id = IProblem.IncompatibleReturnType;
1918         }
1919         this.handle(
1920                 id,
1921                 new String[] {methodSignature.toString()},
1922                 new String[] {shortSignature.toString()},
1923                 currentMethod.sourceStart(),
1924                 currentMethod.sourceEnd());
1925 }
1926 public void disallowedTargetForAnnotation(Annotation annotation) {
1927         this.handle(
1928                 IProblem.DisallowedTargetForAnnotation,
1929                 new String[] {new String(annotation.resolvedType.readableName())},
1930                 new String[] {new String(annotation.resolvedType.shortReadableName())},
1931                 annotation.sourceStart,
1932                 annotation.sourceEnd);
1933 }
1934 public void incorrectArityForParameterizedType(ASTNode location, TypeBinding type, TypeBinding[] argumentTypes) {
1935     if (location == null) {
1936                 this.handle(
1937                         IProblem.IncorrectArityForParameterizedType,
1938                         new String[] {new String(type.readableName()), typesAsString(false, argumentTypes, false)},
1939                         new String[] {new String(type.shortReadableName()), typesAsString(false, argumentTypes, true)},
1940                         AbortCompilation | Error,
1941                         0,
1942                         1);        
1943     }
1944         this.handle(
1945                 IProblem.IncorrectArityForParameterizedType,
1946                 new String[] {new String(type.readableName()), typesAsString(false, argumentTypes, false)},
1947                 new String[] {new String(type.shortReadableName()), typesAsString(false, argumentTypes, true)},
1948                 location.sourceStart,
1949                 location.sourceEnd);
1950 }
1951 public void incorrectLocationForNonEmptyDimension(ArrayAllocationExpression expression, int index) {
1952         this.handle(
1953                 IProblem.IllegalDimension,
1954                 NoArgument,
1955                 NoArgument,
1956                 expression.dimensions[index].sourceStart,
1957                 expression.dimensions[index].sourceEnd);
1958 }
1959 public void incorrectSwitchType(Expression expression, TypeBinding testType) {
1960         this.handle(
1961                 IProblem.IncorrectSwitchType,
1962                 new String[] {new String(testType.readableName())},
1963                 new String[] {new String(testType.shortReadableName())},
1964                 expression.sourceStart,
1965                 expression.sourceEnd);
1966 }
1967 public void indirectAccessToStaticField(ASTNode location, FieldBinding field){
1968         this.handle(
1969                 IProblem.IndirectAccessToStaticField,
1970                 new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
1971                 new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
1972                 location.sourceStart,
1973                 fieldLocation(field, location));
1974 }
1975 public void indirectAccessToStaticMethod(ASTNode location, MethodBinding method) {
1976         this.handle(
1977                 IProblem.IndirectAccessToStaticMethod,
1978                 new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
1979                 new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
1980                 location.sourceStart,
1981                 location.sourceEnd);
1982 }
1983 public void indirectAccessToStaticType(ASTNode location, ReferenceBinding type) {
1984         this.handle(
1985                 IProblem.IndirectAccessToStaticMethod,
1986                 new String[] {new String(type.enclosingType().readableName()), new String(type.sourceName) },
1987                 new String[] {new String(type.enclosingType().shortReadableName()), new String(type.sourceName) },
1988                 location.sourceStart,
1989                 location.sourceEnd);
1990 }
1991 public void inheritedMethodsHaveNameClash(SourceTypeBinding type, MethodBinding oneMethod, MethodBinding twoMethod) {
1992         this.handle(
1993                 IProblem.MethodNameClash,
1994                 new String[] {
1995                         new String(oneMethod.selector),
1996                         typesAsString(oneMethod.original().isVarargs(), oneMethod.original().parameters, false),
1997                         new String(oneMethod.declaringClass.readableName()),
1998                         typesAsString(twoMethod.original().isVarargs(), twoMethod.original().parameters, false),
1999                         new String(twoMethod.declaringClass.readableName()),
2000                  }, 
2001                 new String[] {
2002                         new String(oneMethod.selector),
2003                         typesAsString(oneMethod.original().isVarargs(), oneMethod.original().parameters, true),
2004                         new String(oneMethod.declaringClass.shortReadableName()),
2005                         typesAsString(twoMethod.original().isVarargs(), twoMethod.original().parameters, true),
2006                         new String(twoMethod.declaringClass.shortReadableName()),
2007                  }, 
2008                  type.sourceStart(),
2009                  type.sourceEnd());
2010 }       
2011 public void inheritedMethodReducesVisibility(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
2012         StringBuffer concreteSignature = new StringBuffer();
2013         concreteSignature
2014                 .append(concreteMethod.declaringClass.readableName())
2015                 .append('.')
2016                 .append(concreteMethod.readableName());
2017         StringBuffer shortSignature = new StringBuffer();
2018         shortSignature
2019                 .append(concreteMethod.declaringClass.shortReadableName())
2020                 .append('.')
2021                 .append(concreteMethod.shortReadableName());
2022         this.handle(
2023                 // The inherited method %1 cannot hide the public abstract method in %2
2024                 IProblem.InheritedMethodReducesVisibility,
2025                 new String[] {
2026                         concreteSignature.toString(),
2027                         new String(abstractMethods[0].declaringClass.readableName())},
2028                 new String[] {
2029                         new String(shortSignature.toString()),
2030                         new String(abstractMethods[0].declaringClass.shortReadableName())},
2031                 type.sourceStart(),
2032                 type.sourceEnd());
2033 }
2034 public void inheritedMethodsHaveIncompatibleReturnTypes(SourceTypeBinding type, MethodBinding[] inheritedMethods, int length) {
2035         StringBuffer methodSignatures = new StringBuffer();
2036         StringBuffer shortSignatures = new StringBuffer();
2037         for (int i = length; --i >= 0;) {
2038                 methodSignatures
2039                         .append(inheritedMethods[i].declaringClass.readableName())
2040                         .append('.')
2041                         .append(inheritedMethods[i].readableName());
2042                 shortSignatures
2043                         .append(inheritedMethods[i].declaringClass.shortReadableName())
2044                         .append('.')
2045                         .append(inheritedMethods[i].shortReadableName());
2046                 if (i != 0){
2047                         methodSignatures.append(", "); //$NON-NLS-1$
2048                         shortSignatures.append(", "); //$NON-NLS-1$
2049                 }
2050         }
2051
2052         this.handle(
2053                 // Return type is incompatible with %1
2054                 // 9.4.2 - The return type from the method is incompatible with the declaration.
2055                 IProblem.IncompatibleReturnType,
2056                 new String[] {methodSignatures.toString()},
2057                 new String[] {shortSignatures.toString()},
2058                 type.sourceStart(),
2059                 type.sourceEnd());
2060 }
2061 public void initializerMustCompleteNormally(FieldDeclaration fieldDecl) {
2062         this.handle(
2063                 IProblem.InitializerMustCompleteNormally,
2064                 NoArgument,
2065                 NoArgument,
2066                 fieldDecl.sourceStart,
2067                 fieldDecl.sourceEnd);
2068 }
2069 public void innerTypesCannotDeclareStaticInitializers(ReferenceBinding innerType, ASTNode location) {
2070         this.handle(
2071                 IProblem.CannotDefineStaticInitializerInLocalType,
2072                 new String[] {new String(innerType.readableName())},
2073                 new String[] {new String(innerType.shortReadableName())},
2074                 location.sourceStart,
2075                 location.sourceEnd);
2076 }
2077 public void interfaceCannotHaveConstructors(ConstructorDeclaration constructor) {
2078         this.handle(
2079                 IProblem.InterfaceCannotHaveConstructors,
2080                 NoArgument,
2081                 NoArgument,
2082                 constructor.sourceStart,
2083                 constructor.sourceEnd,
2084                 constructor,
2085                 constructor.compilationResult());
2086 }
2087 public void interfaceCannotHaveInitializers(SourceTypeBinding type, FieldDeclaration fieldDecl) {
2088         String[] arguments = new String[] {new String(type.sourceName())};
2089
2090         this.handle(
2091                 IProblem.InterfaceCannotHaveInitializers,
2092                 arguments,
2093                 arguments,
2094                 fieldDecl.sourceStart,
2095                 fieldDecl.sourceEnd);
2096 }
2097 public void invalidAnnotationMemberType(MethodDeclaration methodDecl) {
2098         this.handle(
2099                 IProblem.InvalidAnnotationMemberType,
2100                 new String[] {
2101                         new String(methodDecl.binding.returnType.readableName()),
2102                         new String(methodDecl.selector),
2103                         new String(methodDecl.binding.declaringClass.readableName()),
2104                 },
2105                 new String[] {
2106                         new String(methodDecl.binding.returnType.shortReadableName()),
2107                         new String(methodDecl.selector),
2108                         new String(methodDecl.binding.declaringClass.shortReadableName()),
2109                 },
2110                 methodDecl.returnType.sourceStart,
2111                 methodDecl.returnType.sourceEnd);
2112         
2113 }
2114 public void invalidBreak(ASTNode location) {
2115         this.handle(
2116                 IProblem.InvalidBreak,
2117                 NoArgument,
2118                 NoArgument,
2119                 location.sourceStart,
2120                 location.sourceEnd);
2121 }
2122 public void invalidConstructor(Statement statement, MethodBinding targetConstructor) {
2123
2124         boolean insideDefaultConstructor = 
2125                 (this.referenceContext instanceof ConstructorDeclaration)
2126                         && ((ConstructorDeclaration)this.referenceContext).isDefaultConstructor();
2127         boolean insideImplicitConstructorCall =
2128                 (statement instanceof ExplicitConstructorCall)
2129                         && (((ExplicitConstructorCall) statement).accessMode == ExplicitConstructorCall.ImplicitSuper);
2130
2131         int sourceStart = statement.sourceStart;
2132         int sourceEnd = statement.sourceEnd;
2133         if (statement instanceof AllocationExpression) {
2134                 AllocationExpression allocation = (AllocationExpression)statement;
2135                 if (allocation.enumConstant != null) {
2136                         sourceStart = allocation.enumConstant.sourceStart;
2137                         sourceEnd = allocation.enumConstant.sourceEnd;
2138                 }
2139         }
2140         
2141         int id = IProblem.UndefinedConstructor; //default...
2142     MethodBinding shownConstructor = targetConstructor;
2143         switch (targetConstructor.problemId()) {
2144                 case NotFound :
2145                         if (insideDefaultConstructor){
2146                                 id = IProblem.UndefinedConstructorInDefaultConstructor;
2147                         } else if (insideImplicitConstructorCall){
2148                                 id = IProblem.UndefinedConstructorInImplicitConstructorCall;
2149                         } else {
2150                                 id = IProblem.UndefinedConstructor;
2151                         }
2152                         break;
2153                 case NotVisible :
2154                         if (insideDefaultConstructor){
2155                                 id = IProblem.NotVisibleConstructorInDefaultConstructor;
2156                         } else if (insideImplicitConstructorCall){
2157                                 id = IProblem.NotVisibleConstructorInImplicitConstructorCall;
2158                         } else {
2159                                 id = IProblem.NotVisibleConstructor;
2160                         }
2161                         ProblemMethodBinding problemConstructor = (ProblemMethodBinding) targetConstructor;
2162                         if (problemConstructor.closestMatch != null) {
2163                             shownConstructor = problemConstructor.closestMatch.original();
2164                     }                                   
2165                         break;
2166                 case Ambiguous :
2167                         if (insideDefaultConstructor){
2168                                 id = IProblem.AmbiguousConstructorInDefaultConstructor;
2169                         } else if (insideImplicitConstructorCall){
2170                                 id = IProblem.AmbiguousConstructorInImplicitConstructorCall;
2171                         } else {
2172                                 id = IProblem.AmbiguousConstructor;
2173                         }
2174                         break;
2175                 case ParameterBoundMismatch :
2176                         problemConstructor = (ProblemMethodBinding) targetConstructor;
2177                         ParameterizedGenericMethodBinding substitutedConstructor = (ParameterizedGenericMethodBinding) problemConstructor.closestMatch;
2178                         shownConstructor = substitutedConstructor.original();
2179                         TypeBinding typeArgument = targetConstructor.parameters[0];
2180                         TypeVariableBinding typeParameter = (TypeVariableBinding) targetConstructor.parameters[1];
2181                         this.handle(
2182                                 IProblem.GenericConstructorTypeArgumentMismatch,
2183                                 new String[] { 
2184                                         new String(shownConstructor.declaringClass.sourceName()),
2185                                         typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false), 
2186                                         new String(shownConstructor.declaringClass.readableName()), 
2187                                         typesAsString(substitutedConstructor.isVarargs(), substitutedConstructor.parameters, false), 
2188                                         new String(typeArgument.readableName()), 
2189                                         new String(typeParameter.sourceName), 
2190                                         parameterBoundAsString(typeParameter, false) },
2191                                 new String[] { 
2192                                         new String(shownConstructor.declaringClass.sourceName()),
2193                                         typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true), 
2194                                         new String(shownConstructor.declaringClass.shortReadableName()), 
2195                                         typesAsString(substitutedConstructor.isVarargs(), substitutedConstructor.parameters, true), 
2196                                         new String(typeArgument.shortReadableName()), 
2197                                         new String(typeParameter.sourceName), 
2198                                         parameterBoundAsString(typeParameter, true) },
2199                                 sourceStart,
2200                                 sourceEnd);                 
2201                         return;             
2202                         
2203                 case TypeParameterArityMismatch :
2204                         problemConstructor = (ProblemMethodBinding) targetConstructor;
2205                         shownConstructor = problemConstructor.closestMatch;
2206                         if (shownConstructor.typeVariables == TypeConstants.NoTypeVariables) {
2207                                 this.handle(
2208                                         IProblem.NonGenericConstructor,
2209                                         new String[] { 
2210                                                 new String(shownConstructor.declaringClass.sourceName()),
2211                                                 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false), 
2212                                                 new String(shownConstructor.declaringClass.readableName()), 
2213                                                 typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false) },
2214                                         new String[] { 
2215                                                 new String(shownConstructor.declaringClass.sourceName()),
2216                                                 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true), 
2217                                                 new String(shownConstructor.declaringClass.shortReadableName()), 
2218                                                 typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true) },
2219                                         sourceStart,
2220                                         sourceEnd);                 
2221                         } else {
2222                                 this.handle(
2223                                         IProblem.IncorrectArityForParameterizedConstructor  ,
2224                                         new String[] { 
2225                                                 new String(shownConstructor.declaringClass.sourceName()),
2226                                                 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false), 
2227                                                 new String(shownConstructor.declaringClass.readableName()), 
2228                                                         typesAsString(false, shownConstructor.typeVariables, false),
2229                                                 typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false) },
2230                                         new String[] { 
2231                                                 new String(shownConstructor.declaringClass.sourceName()),
2232                                                 typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true), 
2233                                                 new String(shownConstructor.declaringClass.shortReadableName()), 
2234                                                         typesAsString(false, shownConstructor.typeVariables, true),
2235                                                 typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true) },
2236                                         sourceStart,
2237                                         sourceEnd);                 
2238                         }
2239                         return;
2240                 case ParameterizedMethodTypeMismatch :
2241                         problemConstructor = (ProblemMethodBinding) targetConstructor;
2242                         shownConstructor = problemConstructor.closestMatch;
2243                         this.handle(
2244                                 IProblem.ParameterizedConstructorArgumentTypeMismatch,
2245                                 new String[] { 
2246                                         new String(shownConstructor.declaringClass.sourceName()),
2247                                         typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false), 
2248                                         new String(shownConstructor.declaringClass.readableName()), 
2249                                                 typesAsString(false, ((ParameterizedGenericMethodBinding)shownConstructor).typeArguments, false),
2250                                         typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false) },
2251                                 new String[] { 
2252                                         new String(shownConstructor.declaringClass.sourceName()),
2253                                         typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true), 
2254                                         new String(shownConstructor.declaringClass.shortReadableName()), 
2255                                                 typesAsString(false, ((ParameterizedGenericMethodBinding)shownConstructor).typeArguments, true),
2256                                         typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true) },
2257                                 sourceStart,
2258                                 sourceEnd);                 
2259                         return;
2260                 case TypeArgumentsForRawGenericMethod :
2261                         problemConstructor = (ProblemMethodBinding) targetConstructor;
2262                         shownConstructor = problemConstructor.closestMatch;
2263                         this.handle(
2264                                 IProblem.TypeArgumentsForRawGenericConstructor,
2265                                 new String[] { 
2266                                         new String(shownConstructor.declaringClass.sourceName()),
2267                                         typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false), 
2268                                         new String(shownConstructor.declaringClass.readableName()), 
2269                                         typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false) },
2270                                 new String[] { 
2271                                         new String(shownConstructor.declaringClass.sourceName()),
2272                                         typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true), 
2273                                         new String(shownConstructor.declaringClass.shortReadableName()), 
2274                                         typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true) },
2275                                 sourceStart,
2276                                 sourceEnd);     
2277                         return;
2278                 case NoError : // 0
2279                 default :
2280                         needImplementation(); // want to fail to see why we were here...
2281                         break;
2282         }
2283
2284         this.handle(
2285                 id,
2286                 new String[] {new String(targetConstructor.declaringClass.readableName()), typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, false)},
2287                 new String[] {new String(targetConstructor.declaringClass.shortReadableName()), typesAsString(shownConstructor.isVarargs(), shownConstructor.parameters, true)},
2288                 sourceStart,
2289                 sourceEnd);
2290 }
2291 public void invalidContinue(ASTNode location) {
2292         this.handle(
2293                 IProblem.InvalidContinue,
2294                 NoArgument,
2295                 NoArgument,
2296                 location.sourceStart,
2297                 location.sourceEnd);
2298 }
2299 public void invalidEnclosingType(Expression expression, TypeBinding type, ReferenceBinding enclosingType) {
2300
2301         if (enclosingType.isAnonymousType()) enclosingType = enclosingType.superclass();
2302         int flag = IProblem.UndefinedType; // default
2303         switch (type.problemId()) {
2304                 case NotFound : // 1
2305                         flag = IProblem.UndefinedType;
2306                         break;
2307                 case NotVisible : // 2
2308                         flag = IProblem.NotVisibleType;
2309                         break;
2310                 case Ambiguous : // 3
2311                         flag = IProblem.AmbiguousType;
2312                         break;
2313                 case InternalNameProvided :
2314                         flag = IProblem.InternalTypeNameProvided;
2315                         break;
2316                 case NoError : // 0
2317                 default :
2318                         needImplementation(); // want to fail to see why we were here...
2319                         break;
2320         }
2321
2322         this.handle(
2323                 flag,
2324                 new String[] {new String(enclosingType.readableName()) + "." + new String(type.readableName())}, //$NON-NLS-1$
2325                 new String[] {new String(enclosingType.shortReadableName()) + "." + new String(type.shortReadableName())}, //$NON-NLS-1$
2326                 expression.sourceStart,
2327                 expression.sourceEnd);
2328 }
2329
2330 public void invalidExplicitConstructorCall(ASTNode location) {
2331         
2332         this.handle(
2333                 IProblem.InvalidExplicitConstructorCall,
2334                 NoArgument,
2335                 NoArgument,
2336                 location.sourceStart,
2337                 location.sourceEnd);
2338 }
2339
2340 public void invalidExpressionAsStatement(Expression expression){
2341         this.handle(
2342                 IProblem.InvalidExpressionAsStatement,
2343                 NoArgument,
2344                 NoArgument,
2345                 expression.sourceStart,
2346                 expression.sourceEnd);
2347 }
2348 public void invalidField(FieldReference fieldRef, TypeBinding searchedType) {
2349         int id = IProblem.UndefinedField;
2350         FieldBinding field = fieldRef.binding;
2351         switch (field.problemId()) {
2352                 case NotFound :
2353                         id = IProblem.UndefinedField;
2354 /* also need to check that the searchedType is the receiver type
2355                         if (searchedType.isHierarchyInconsistent())
2356                                 severity = SecondaryError;
2357 */
2358                         break;
2359                 case NotVisible :
2360                         id = IProblem.NotVisibleField;
2361                         break;
2362                 case Ambiguous :
2363                         id = IProblem.AmbiguousField;
2364                         break;
2365                 case NonStaticReferenceInStaticContext :
2366                         id = IProblem.NonStaticFieldFromStaticInvocation;
2367                         break;
2368                 case NonStaticReferenceInConstructorInvocation :
2369                         id = IProblem.InstanceFieldDuringConstructorInvocation;
2370                         break;
2371                 case InheritedNameHidesEnclosingName :
2372                         id = IProblem.InheritedFieldHidesEnclosingName;
2373                         break;
2374                 case ReceiverTypeNotVisible :
2375                         this.handle(
2376                                 IProblem.NotVisibleType, // cannot occur in javadoc comments
2377                                 new String[] {new String(searchedType.leafComponentType().readableName())},
2378                                 new String[] {new String(searchedType.leafComponentType().shortReadableName())},
2379                                 fieldRef.receiver.sourceStart,
2380                                 fieldRef.receiver.sourceEnd);
2381                         return;
2382                         
2383                 case NoError : // 0
2384                 default :
2385                         needImplementation(); // want to fail to see why we were here...
2386                         break;
2387         }
2388
2389         String[] arguments = new String[] {new String(field.readableName())};
2390         this.handle(
2391                 id,
2392                 arguments,
2393                 arguments,
2394                 fieldRef.sourceStart,
2395                 fieldRef.sourceEnd);
2396 }
2397 public void invalidField(NameReference nameRef, FieldBinding field) {
2398         int id = IProblem.UndefinedField;
2399         switch (field.problemId()) {
2400                 case NotFound :
2401                         id = IProblem.UndefinedField;
2402                         break;
2403                 case NotVisible :
2404                         id = IProblem.NotVisibleField;
2405                         break;
2406                 case Ambiguous :
2407                         id = IProblem.AmbiguousField;
2408                         break;
2409                 case NonStaticReferenceInStaticContext :
2410                         id = IProblem.NonStaticFieldFromStaticInvocation;
2411                         break;
2412                 case NonStaticReferenceInConstructorInvocation :
2413                         id = IProblem.InstanceFieldDuringConstructorInvocation;
2414                         break;
2415                 case InheritedNameHidesEnclosingName :
2416                         id = IProblem.InheritedFieldHidesEnclosingName;
2417                         break;
2418                 case ReceiverTypeNotVisible :
2419                         this.handle(
2420                                 IProblem.NotVisibleType,
2421                                 new String[] {new String(field.declaringClass.leafComponentType().readableName())},
2422                                 new String[] {new String(field.declaringClass.leafComponentType().shortReadableName())},
2423                                 nameRef.sourceStart,
2424                                 nameRef.sourceEnd);
2425                         return;
2426                 case NoError : // 0
2427                 default :
2428                         needImplementation(); // want to fail to see why we were here...
2429                         break;
2430         }
2431         String[] arguments = new String[] {new String(field.readableName())};
2432         this.handle(
2433                 id,
2434                 arguments,
2435                 arguments,
2436                 nameRef.sourceStart,
2437                 nameRef.sourceEnd);
2438 }
2439 public void invalidField(QualifiedNameReference nameRef, FieldBinding field, int index, TypeBinding searchedType) {
2440         //the resolution of the index-th field of qname failed
2441         //qname.otherBindings[index] is the binding that has produced the error
2442
2443         //The different targetted errors should be :
2444         //UndefinedField
2445         //NotVisibleField
2446         //AmbiguousField
2447
2448         if (searchedType.isBaseType()) {
2449                 this.handle(
2450                         IProblem.NoFieldOnBaseType,
2451                         new String[] {
2452                                 new String(searchedType.readableName()),
2453                                 CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index)),
2454                                 new String(nameRef.tokens[index])},
2455                         new String[] {
2456                                 new String(searchedType.sourceName()),
2457                                 CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index)),
2458                                 new String(nameRef.tokens[index])},
2459                         nameRef.sourceStart,
2460                         (int) nameRef.sourcePositions[index]);
2461                 return;
2462         }
2463
2464         int id = IProblem.UndefinedField;
2465         switch (field.problemId()) {
2466                 case NotFound :
2467                         id = IProblem.UndefinedField;
2468 /* also need to check that the searchedType is the receiver type
2469                         if (searchedType.isHierarchyInconsistent())
2470                                 severity = SecondaryError;
2471 */
2472                         break;
2473                 case NotVisible :
2474                         id = IProblem.NotVisibleField;
2475                         break;
2476                 case Ambiguous :
2477                         id = IProblem.AmbiguousField;
2478                         break;
2479                 case NonStaticReferenceInStaticContext :
2480                         id = IProblem.NonStaticFieldFromStaticInvocation;
2481                         break;
2482                 case NonStaticReferenceInConstructorInvocation :
2483                         id = IProblem.InstanceFieldDuringConstructorInvocation;
2484                         break;
2485                 case InheritedNameHidesEnclosingName :
2486                         id = IProblem.InheritedFieldHidesEnclosingName;
2487                         break;
2488                 case ReceiverTypeNotVisible :
2489                         this.handle(
2490                                 IProblem.NotVisibleType,
2491                                 new String[] {new String(searchedType.leafComponentType().readableName())},
2492                                 new String[] {new String(searchedType.leafComponentType().shortReadableName())},
2493                                 nameRef.sourceStart,
2494                                 nameRef.sourceEnd);
2495                         return;
2496                 case NoError : // 0
2497                 default :
2498                         needImplementation(); // want to fail to see why we were here...
2499                         break;
2500         }
2501         String[] arguments = new String[] {CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index + 1))};
2502         this.handle(
2503                 id, 
2504                 arguments,
2505                 arguments,
2506                 nameRef.sourceStart, 
2507                 (int) nameRef.sourcePositions[index]);
2508 }
2509 public void invalidFileNameForPackageAnnotations(Annotation annotation) {
2510         this.handle(
2511                         IProblem.InvalidFileNameForPackageAnnotations,
2512                         NoArgument,
2513                         NoArgument,
2514                         annotation.sourceStart,
2515                         annotation.sourceEnd);  
2516 }
2517 public void invalidMethod(MessageSend messageSend, MethodBinding method) {
2518         int id = IProblem.UndefinedMethod; //default...
2519     MethodBinding shownMethod = method;
2520         switch (method.problemId()) {
2521                 case NotFound :
2522                         id = IProblem.UndefinedMethod;
2523                         ProblemMethodBinding problemMethod = (ProblemMethodBinding) method;
2524                         if (problemMethod.closestMatch != null) {
2525                                 shownMethod = problemMethod.closestMatch;
2526                                         String closestParameterTypeNames = typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false);
2527                                         String parameterTypeNames = typesAsString(method.isVarargs(), method.parameters, false);
2528                                         String closestParameterTypeShortNames = typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true);
2529                                         String parameterTypeShortNames = typesAsString(method.isVarargs(), method.parameters, true);
2530                                         if (closestParameterTypeShortNames.equals(parameterTypeShortNames)){
2531                                                 closestParameterTypeShortNames = closestParameterTypeNames;
2532                                                 parameterTypeShortNames = parameterTypeNames;
2533                                         }
2534                                         this.handle(
2535                                                 IProblem.ParameterMismatch,
2536                                                 new String[] {
2537                                                         new String(shownMethod.declaringClass.readableName()),
2538                                                         new String(shownMethod.selector),
2539                                                         closestParameterTypeNames,
2540                                                         parameterTypeNames 
2541                                                 },
2542                                                 new String[] {
2543                                                         new String(shownMethod.declaringClass.shortReadableName()),
2544                                                         new String(shownMethod.selector),
2545                                                         closestParameterTypeShortNames,
2546                                                         parameterTypeShortNames
2547                                                 },
2548                                                 (int) (messageSend.nameSourcePosition >>> 32),
2549                                                 (int) messageSend.nameSourcePosition);
2550                                         return;
2551                         }                       
2552                         break;
2553                 case NotVisible :
2554                         id = IProblem.NotVisibleMethod;
2555                         problemMethod = (ProblemMethodBinding) method;
2556                         if (problemMethod.closestMatch != null) {
2557                             shownMethod = problemMethod.closestMatch.original();
2558                     }                   
2559                         break;
2560                 case Ambiguous :
2561                         id = IProblem.AmbiguousMethod;
2562                         break;
2563                 case InheritedNameHidesEnclosingName :
2564                         id = IProblem.InheritedMethodHidesEnclosingName;
2565                         break;
2566                 case NonStaticReferenceInConstructorInvocation :
2567                         id = IProblem.InstanceMethodDuringConstructorInvocation;
2568                         break;
2569                 case NonStaticReferenceInStaticContext :
2570                         id = IProblem.StaticMethodRequested;
2571                         break;
2572                 case ReceiverTypeNotVisible :
2573                         this.handle(
2574                                 IProblem.NotVisibleType,        // cannot occur in javadoc comments
2575                                 new String[] {new String(method.declaringClass.leafComponentType().readableName())},
2576                                 new String[] {new String(method.declaringClass.leafComponentType().shortReadableName())},
2577                                 messageSend.receiver.sourceStart,
2578                                 messageSend.receiver.sourceEnd);
2579                         return;
2580                 case ParameterBoundMismatch :
2581                         problemMethod = (ProblemMethodBinding) method;
2582                         ParameterizedGenericMethodBinding substitutedMethod = (ParameterizedGenericMethodBinding) problemMethod.closestMatch;
2583                         shownMethod = substitutedMethod.original();
2584                         TypeBinding typeArgument = method.parameters[0];
2585                         TypeVariableBinding typeParameter = (TypeVariableBinding) method.parameters[1];
2586                         this.handle(
2587                                 IProblem.GenericMethodTypeArgumentMismatch,
2588                                 new String[] { 
2589                                         new String(shownMethod.selector),
2590                                         typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false), 
2591                                         new String(shownMethod.declaringClass.readableName()), 
2592                                         typesAsString(substitutedMethod.isVarargs(), substitutedMethod.parameters, false), 
2593                                         new String(typeArgument.readableName()), 
2594                                         new String(typeParameter.sourceName), 
2595                                         parameterBoundAsString(typeParameter, false) },
2596                                 new String[] { 
2597                                         new String(shownMethod.selector),
2598                                         typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true), 
2599                                         new String(shownMethod.declaringClass.shortReadableName()), 
2600                                         typesAsString(substitutedMethod.isVarargs(), substitutedMethod.parameters, true), 
2601                                         new String(typeArgument.shortReadableName()), 
2602                                         new String(typeParameter.sourceName), 
2603                                         parameterBoundAsString(typeParameter, true) },
2604                                 (int) (messageSend.nameSourcePosition >>> 32),
2605                                 (int) messageSend.nameSourcePosition);              
2606                         return;
2607                 case TypeParameterArityMismatch :
2608                         problemMethod = (ProblemMethodBinding) method;
2609                         shownMethod = problemMethod.closestMatch;
2610                         if (shownMethod.typeVariables == TypeConstants.NoTypeVariables) {
2611                                 this.handle(
2612                                         IProblem.NonGenericMethod ,
2613                                         new String[] { 
2614                                                 new String(shownMethod.selector),
2615                                                 typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false), 
2616                                                 new String(shownMethod.declaringClass.readableName()), 
2617                                                 typesAsString(method.isVarargs(), method.parameters, false) },
2618                                         new String[] { 
2619                                                 new String(shownMethod.selector),
2620                                                 typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true), 
2621                                                 new String(shownMethod.declaringClass.shortReadableName()), 
2622                                                 typesAsString(method.isVarargs(), method.parameters, true) },
2623                                         (int) (messageSend.nameSourcePosition >>> 32),
2624                                         (int) messageSend.nameSourcePosition);              
2625                         } else {
2626                                 this.handle(
2627                                         IProblem.IncorrectArityForParameterizedMethod  ,
2628                                         new String[] { 
2629                                                 new String(shownMethod.selector),
2630                                                 typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false), 
2631                                                 new String(shownMethod.declaringClass.readableName()), 
2632                                                         typesAsString(false, shownMethod.typeVariables, false),
2633                                                 typesAsString(method.isVarargs(), method.parameters, false) },
2634                                         new String[] { 
2635                                                 new String(shownMethod.selector),
2636                                                 typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true), 
2637                                                 new String(shownMethod.declaringClass.shortReadableName()), 
2638                                                         typesAsString(false, shownMethod.typeVariables, true),
2639                                                 typesAsString(method.isVarargs(), method.parameters, true) },
2640                                         (int) (messageSend.nameSourcePosition >>> 32),
2641                                         (int) messageSend.nameSourcePosition);              
2642                         }
2643                         return;
2644                 case ParameterizedMethodTypeMismatch :
2645                         problemMethod = (ProblemMethodBinding) method;
2646                         shownMethod = problemMethod.closestMatch;
2647                         this.handle(
2648                                 IProblem.ParameterizedMethodArgumentTypeMismatch,
2649                                 new String[] { 
2650                                         new String(shownMethod.selector),
2651                                         typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false), 
2652                                         new String(shownMethod.declaringClass.readableName()), 
2653                                                 typesAsString(false, ((ParameterizedGenericMethodBinding)shownMethod).typeArguments, false),
2654                                         typesAsString(method.isVarargs(), method.parameters, false) },
2655                                 new String[] { 
2656                                         new String(shownMethod.selector),
2657                                         typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true), 
2658                                         new String(shownMethod.declaringClass.shortReadableName()), 
2659                                                 typesAsString(false, ((ParameterizedGenericMethodBinding)shownMethod).typeArguments, true),
2660                                         typesAsString(method.isVarargs(), method.parameters, true) },
2661                                 (int) (messageSend.nameSourcePosition >>> 32),
2662                                 (int) messageSend.nameSourcePosition);              
2663                         return;
2664                 case TypeArgumentsForRawGenericMethod :
2665                         problemMethod = (ProblemMethodBinding) method;
2666                         shownMethod = problemMethod.closestMatch;
2667                         this.handle(
2668                                 IProblem.TypeArgumentsForRawGenericMethod ,
2669                                 new String[] { 
2670                                         new String(shownMethod.selector),
2671                                         typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false), 
2672                                         new String(shownMethod.declaringClass.readableName()), 
2673                                         typesAsString(method.isVarargs(), method.parameters, false) },
2674                                 new String[] { 
2675                                         new String(shownMethod.selector),
2676                                         typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true), 
2677                                         new String(shownMethod.declaringClass.shortReadableName()), 
2678                                         typesAsString(method.isVarargs(), method.parameters, true) },
2679                                 (int) (messageSend.nameSourcePosition >>> 32),
2680                                 (int) messageSend.nameSourcePosition);                 
2681                         return;
2682                 case NoError : // 0
2683                 default :
2684                         needImplementation(); // want to fail to see why we were here...
2685                         break;
2686         }
2687
2688         this.handle(
2689                 id,
2690                 new String[] {
2691                         new String(method.declaringClass.readableName()),
2692                         new String(shownMethod.selector), typesAsString(shownMethod.isVarargs(), shownMethod.parameters, false)},
2693                 new String[] {
2694                         new String(method.declaringClass.shortReadableName()),
2695                         new String(shownMethod.selector), typesAsString(shownMethod.isVarargs(), shownMethod.parameters, true)},
2696                 (int) (messageSend.nameSourcePosition >>> 32),
2697                 (int) messageSend.nameSourcePosition);
2698 }
2699 public void invalidNullToSynchronize(Expression expression) {
2700         this.handle(
2701                 IProblem.InvalidNullToSynchronized,
2702                 NoArgument,
2703                 NoArgument,
2704                 expression.sourceStart,
2705                 expression.sourceEnd);
2706 }
2707 public void invalidOperator(BinaryExpression expression, TypeBinding leftType, TypeBinding rightType) {
2708         String leftName = new String(leftType.readableName());
2709         String rightName = new String(rightType.readableName());
2710         String leftShortName = new String(leftType.shortReadableName());
2711         String rightShortName = new String(rightType.shortReadableName());
2712         if (leftShortName.equals(rightShortName)){
2713                 leftShortName = leftName;
2714                 rightShortName = rightName;
2715         }
2716         this.handle(
2717                 IProblem.InvalidOperator,
2718                 new String[] {
2719                         expression.operatorToString(),
2720                         leftName + ", " + rightName}, //$NON-NLS-1$
2721                 new String[] {
2722                         expression.operatorToString(),
2723                         leftShortName + ", " + rightShortName}, //$NON-NLS-1$
2724                 expression.sourceStart,
2725                 expression.sourceEnd);
2726 }
2727 public void invalidOperator(CompoundAssignment assign, TypeBinding leftType, TypeBinding rightType) {
2728         String leftName = new String(leftType.readableName());
2729         String rightName = new String(rightType.readableName());
2730         String leftShortName = new String(leftType.shortReadableName());
2731         String rightShortName = new String(rightType.shortReadableName());
2732         if (leftShortName.equals(rightShortName)){
2733                 leftShortName = leftName;
2734                 rightShortName = rightName;
2735         }
2736         this.handle(
2737                 IProblem.InvalidOperator,
2738                 new String[] {
2739                         assign.operatorToString(),
2740                         leftName + ", " + rightName}, //$NON-NLS-1$
2741                 new String[] {
2742                         assign.operatorToString(),
2743                         leftShortName + ", " + rightShortName}, //$NON-NLS-1$
2744                 assign.sourceStart,
2745                 assign.sourceEnd);
2746 }
2747 public void invalidOperator(UnaryExpression expression, TypeBinding type) {
2748         this.handle(
2749                 IProblem.InvalidOperator,
2750                 new String[] {expression.operatorToString(), new String(type.readableName())},
2751                 new String[] {expression.operatorToString(), new String(type.shortReadableName())},
2752                 expression.sourceStart,
2753                 expression.sourceEnd);
2754 }
2755 public void invalidParameterizedExceptionType(TypeBinding exceptionType, ASTNode location) {
2756         this.handle(
2757                 IProblem.InvalidParameterizedExceptionType,
2758                 new String[] {new String(exceptionType.readableName())},
2759                 new String[] {new String(exceptionType.shortReadableName())},
2760                 location.sourceStart,
2761                 location.sourceEnd);
2762 }
2763 public void invalidParenthesizedExpression(ASTNode reference) {
2764         this.handle(
2765                 IProblem.InvalidParenthesizedExpression,
2766                 NoArgument,
2767                 NoArgument,
2768                 reference.sourceStart,
2769                 reference.sourceEnd);
2770 }
2771 public void invalidType(ASTNode location, TypeBinding type) {
2772         int id = IProblem.UndefinedType; // default
2773         switch (type.problemId()) {
2774                 case NotFound :
2775                         id = IProblem.UndefinedType;
2776                         break;
2777                 case NotVisible :
2778                         id = IProblem.NotVisibleType;
2779                         break;
2780                 case Ambiguous :
2781                         id = IProblem.AmbiguousType;
2782                         break;
2783                 case InternalNameProvided :
2784                         id = IProblem.InternalTypeNameProvided;
2785                         break;
2786                 case InheritedNameHidesEnclosingName :
2787                         id = IProblem.InheritedTypeHidesEnclosingName;
2788                         break;
2789                 case NonStaticReferenceInStaticContext :
2790                         id = IProblem.TypeVariableReferenceFromStaticContext;
2791                     break;
2792                 case IllegalSuperTypeVariable : 
2793                     id = IProblem.IllegalTypeVariableSuperReference;
2794                     break;
2795                 case NoError : // 0
2796                 default :
2797                         needImplementation(); // want to fail to see why we were here...
2798                         break;
2799         }
2800         
2801         int end = location.sourceEnd;
2802         if (location instanceof QualifiedNameReference) {
2803                 QualifiedNameReference ref = (QualifiedNameReference) location;
2804                 if (ref.indexOfFirstFieldBinding >= 1)
2805                         end = (int) ref.sourcePositions[ref.indexOfFirstFieldBinding - 1];
2806         } else if (location instanceof ArrayQualifiedTypeReference) {
2807                 if (!(location instanceof ParameterizedQualifiedTypeReference)) {
2808                         ArrayQualifiedTypeReference arrayQualifiedTypeReference = (ArrayQualifiedTypeReference) location;
2809                         long[] positions = arrayQualifiedTypeReference.sourcePositions;
2810                         end = (int) positions[positions.length - 1];
2811                 }
2812         } else if (location instanceof QualifiedTypeReference) {
2813                 QualifiedTypeReference ref = (QualifiedTypeReference) location;
2814                 if (type instanceof ReferenceBinding) {
2815                         char[][] name = ((ReferenceBinding) type).compoundName;
2816                         end = (int) ref.sourcePositions[name.length - 1];
2817                 }
2818         } else if (location instanceof ImportReference) {
2819                 ImportReference ref = (ImportReference) location;
2820                 if (type instanceof ReferenceBinding) {
2821                         char[][] name = ((ReferenceBinding) type).compoundName;
2822                         end = (int) ref.sourcePositions[name.length - 1];
2823                 }
2824         } else if (location instanceof ArrayTypeReference) {
2825                 if (!(location instanceof ParameterizedSingleTypeReference)) {
2826                         ArrayTypeReference arrayTypeReference = (ArrayTypeReference) location;
2827                         end = arrayTypeReference.originalSourceEnd;
2828                 }
2829         }
2830         this.handle(
2831                 id,
2832                 new String[] {new String(type.leafComponentType().readableName()) },    
2833                 new String[] {new String(type.leafComponentType().shortReadableName())},
2834                 location.sourceStart,
2835                 end);
2836 }
2837 public void invalidTypeForCollection(Expression expression) {
2838         this.handle(
2839                         IProblem.InvalidTypeForCollection,
2840                         NoArgument,
2841                         NoArgument,
2842                         expression.sourceStart,
2843                         expression.sourceEnd);
2844 }
2845 public void invalidTypeReference(Expression expression) {
2846         this.handle(
2847                 IProblem.InvalidTypeExpression,
2848                 NoArgument,
2849                 NoArgument,
2850                 expression.sourceStart,
2851                 expression.sourceEnd);
2852 }
2853 public void invalidTypeToSynchronize(Expression expression, TypeBinding type) {
2854         this.handle(
2855                 IProblem.InvalidTypeToSynchronized,
2856                 new String[] {new String(type.readableName())},
2857                 new String[] {new String(type.shortReadableName())},
2858                 expression.sourceStart,
2859                 expression.sourceEnd);
2860 }
2861 public void invalidTypeVariableAsException(TypeBinding exceptionType, ASTNode location) {
2862         this.handle(
2863                 IProblem.InvalidTypeVariableExceptionType,
2864                 new String[] {new String(exceptionType.readableName())},
2865                 new String[] {new String(exceptionType.shortReadableName())},
2866                 location.sourceStart,
2867                 location.sourceEnd);
2868 }
2869 public void invalidUnaryExpression(Expression expression) {
2870         this.handle(
2871                 IProblem.InvalidUnaryExpression,
2872                 NoArgument,
2873                 NoArgument,
2874                 expression.sourceStart,
2875                 expression.sourceEnd);
2876 }
2877 public void invalidUsageOfAnnotation(Annotation annotation) {
2878         this.handle(
2879                 IProblem.InvalidUsageOfAnnotations,
2880                 NoArgument, 
2881                 NoArgument,
2882                 annotation.sourceStart,
2883                 annotation.sourceEnd);  
2884 }
2885 public void invalidUsageOfAnnotationDeclarations(TypeDeclaration annotationTypeDeclaration) {
2886         this.handle(
2887                 IProblem.InvalidUsageOfAnnotationDeclarations,
2888                 NoArgument, 
2889                 NoArgument, 
2890                 annotationTypeDeclaration.sourceStart,
2891                 annotationTypeDeclaration.sourceEnd);
2892 }
2893 public void invalidUsageOfEnumDeclarations(TypeDeclaration enumDeclaration) {
2894         this.handle(
2895                 IProblem.InvalidUsageOfEnumDeclarations,
2896                 NoArgument, 
2897                 NoArgument, 
2898                 enumDeclaration.sourceStart,
2899                 enumDeclaration.sourceEnd);
2900 }
2901 public void invalidUsageOfForeachStatements(LocalDeclaration elementVariable, Expression collection) {
2902         this.handle(
2903                 IProblem.InvalidUsageOfForeachStatements,
2904                 NoArgument, 
2905                 NoArgument, 
2906                 elementVariable.declarationSourceStart,
2907                 collection.sourceEnd);
2908 }
2909 public void invalidUsageOfStaticImports(ImportReference staticImport) {
2910         this.handle(
2911                 IProblem.InvalidUsageOfStaticImports,
2912                 NoArgument, 
2913                 NoArgument, 
2914                 staticImport.declarationSourceStart,
2915                 staticImport.declarationSourceEnd);
2916 }
2917 public void invalidUsageOfTypeArguments(TypeReference firstTypeReference, TypeReference lastTypeReference) {
2918         this.handle(
2919                 IProblem.InvalidUsageOfTypeArguments,
2920                 NoArgument, 
2921                 NoArgument, 
2922                 firstTypeReference.sourceStart,
2923                 lastTypeReference.sourceEnd);
2924 }
2925 public void invalidUsageOfTypeParameters(TypeParameter firstTypeParameter, TypeParameter lastTypeParameter) {
2926         this.handle(
2927                 IProblem.InvalidUsageOfTypeParameters,
2928                 NoArgument, 
2929                 NoArgument, 
2930                 firstTypeParameter.declarationSourceStart,
2931                 lastTypeParameter.declarationSourceEnd);
2932 }
2933 public void invalidUsageOfVarargs(Argument argument) {
2934         this.handle(
2935                 IProblem.InvalidUsageOfVarargs,
2936                 NoArgument, 
2937                 NoArgument, 
2938                 argument.type.sourceStart,
2939                 argument.sourceEnd);
2940 }
2941 public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl) {
2942         this.referenceContext = compUnitDecl;
2943         String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)};
2944         this.handle(
2945                 IProblem.IsClassPathCorrect,
2946                 arguments, 
2947                 arguments,
2948                 AbortCompilation | Error,
2949                 0,
2950                 0);
2951 }
2952
2953 private boolean isIdentifier(int token) {
2954         return token == TerminalTokens.TokenNameIdentifier;
2955 }
2956
2957 private boolean isKeyword(int token) {
2958         switch(token) {
2959                 case TerminalTokens.TokenNameabstract:
2960                 case TerminalTokens.TokenNameassert:
2961                 case TerminalTokens.TokenNamebyte:
2962                 case TerminalTokens.TokenNamebreak:
2963                 case TerminalTokens.TokenNameboolean:
2964                 case TerminalTokens.TokenNamecase:
2965                 case TerminalTokens.TokenNamechar:
2966                 case TerminalTokens.TokenNamecatch:
2967                 case TerminalTokens.TokenNameclass:
2968                 case TerminalTokens.TokenNamecontinue:
2969                 case TerminalTokens.TokenNamedo:
2970                 case TerminalTokens.TokenNamedouble:
2971                 case TerminalTokens.TokenNamedefault:
2972                 case TerminalTokens.TokenNameelse:
2973                 case TerminalTokens.TokenNameextends:
2974                 case TerminalTokens.TokenNamefor:
2975                 case TerminalTokens.TokenNamefinal:
2976                 case TerminalTokens.TokenNamefloat:
2977                 case TerminalTokens.TokenNamefalse:
2978                 case TerminalTokens.TokenNamefinally:
2979                 case TerminalTokens.TokenNameif:
2980                 case TerminalTokens.TokenNameint:
2981                 case TerminalTokens.TokenNameimport:
2982                 case TerminalTokens.TokenNameinterface:
2983                 case TerminalTokens.TokenNameimplements:
2984                 case TerminalTokens.TokenNameinstanceof:
2985                 case TerminalTokens.TokenNamelong:
2986                 case TerminalTokens.TokenNamenew:
2987                 case TerminalTokens.TokenNamenull:
2988                 case TerminalTokens.TokenNamenative:
2989                 case TerminalTokens.TokenNamepublic:
2990                 case TerminalTokens.TokenNamepackage:
2991                 case TerminalTokens.TokenNameprivate:
2992                 case TerminalTokens.TokenNameprotected:
2993                 case TerminalTokens.TokenNamereturn:
2994                 case TerminalTokens.TokenNameshort:
2995                 case TerminalTokens.TokenNamesuper:
2996                 case TerminalTokens.TokenNamestatic:
2997                 case TerminalTokens.TokenNameswitch:
2998                 case TerminalTokens.TokenNamestrictfp:
2999                 case TerminalTokens.TokenNamesynchronized:
3000                 case TerminalTokens.TokenNametry:
3001                 case TerminalTokens.TokenNamethis:
3002                 case TerminalTokens.TokenNametrue:
3003                 case TerminalTokens.TokenNamethrow:
3004                 case TerminalTokens.TokenNamethrows:
3005                 case TerminalTokens.TokenNametransient:
3006                 case TerminalTokens.TokenNamevoid:
3007                 case TerminalTokens.TokenNamevolatile:
3008                 case TerminalTokens.TokenNamewhile:
3009                         return true;
3010                 default: 
3011                         return false;
3012         }
3013 }
3014
3015 private boolean isLiteral(int token) {
3016         switch(token) {
3017                 case TerminalTokens.TokenNameIntegerLiteral:
3018                 case TerminalTokens.TokenNameLongLiteral:
3019                 case TerminalTokens.TokenNameFloatingPointLiteral:
3020                 case TerminalTokens.TokenNameDoubleLiteral:
3021                 case TerminalTokens.TokenNameStringLiteral:
3022                 case TerminalTokens.TokenNameCharacterLiteral:
3023                         return true;
3024                 default: 
3025                         return false;
3026         }
3027 }
3028 public void javadocAmbiguousMethodReference(int sourceStart, int sourceEnd, Binding fieldBinding, int modifiers) {
3029         int id = IProblem.JavadocAmbiguousMethodReference;
3030         if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3031                 String[] arguments = new String[] {new String(fieldBinding.readableName())};
3032                 handle(id, arguments, arguments, sourceStart, sourceEnd);
3033         }
3034 }
3035 public void javadocDeprecatedField(FieldBinding field, ASTNode location, int modifiers) {
3036         if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3037                 this.handle(
3038                         IProblem.JavadocUsingDeprecatedField,
3039                         new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
3040                         new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
3041                         location.sourceStart,
3042                         location.sourceEnd);
3043         }
3044 }
3045 public void javadocDeprecatedMethod(MethodBinding method, ASTNode location, int modifiers) {
3046         if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3047                 if (method.isConstructor()) {
3048                         this.handle(
3049                                 IProblem.JavadocUsingDeprecatedConstructor,
3050                                 new String[] {new String(method.declaringClass.readableName()), typesAsString(method.isVarargs(), method.parameters, false)},
3051                                 new String[] {new String(method.declaringClass.shortReadableName()), typesAsString(method.isVarargs(), method.parameters, true)},
3052                                 location.sourceStart,
3053                                 location.sourceEnd);
3054                 } else {
3055                         this.handle(
3056                                 IProblem.JavadocUsingDeprecatedMethod,
3057                                 new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
3058                                 new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
3059                                 location.sourceStart,
3060                                 location.sourceEnd);
3061                 }
3062         }
3063 }
3064 public void javadocDeprecatedType(TypeBinding type, ASTNode location, int modifiers) {
3065         if (location == null) return; // 1G828DN - no type ref for synthetic arguments
3066         if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3067                 this.handle(
3068                         IProblem.JavadocUsingDeprecatedType,
3069                         new String[] {new String(type.readableName())},
3070                         new String[] {new String(type.shortReadableName())},
3071                         location.sourceStart,
3072                         location.sourceEnd);
3073         }
3074 }
3075 public void javadocDuplicatedParamTag(char[] token, int sourceStart, int sourceEnd, int modifiers) {
3076         if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3077                 String[] arguments = new String[] {String.valueOf(token)};
3078                 this.handle(IProblem.JavadocDuplicateParamName, arguments, arguments, sourceStart, sourceEnd);
3079         }
3080 }
3081 public void javadocDuplicatedReturnTag(int sourceStart, int sourceEnd){
3082         this.handle(IProblem.JavadocDuplicateReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd);
3083 }
3084 public void javadocDuplicatedThrowsClassName(TypeReference typeReference, int modifiers) {
3085         if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3086                 String[] arguments = new String[] {String.valueOf(typeReference.resolvedType.sourceName())};
3087                 this.handle(IProblem.JavadocDuplicateThrowsClassName, arguments, arguments, typeReference.sourceStart, typeReference.sourceEnd);
3088         }
3089 }
3090 public void javadocEmptyReturnTag(int sourceStart, int sourceEnd) {
3091         this.handle(IProblem.JavadocEmptyReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd);
3092 }
3093 public void javadocErrorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params, int modifiers) {
3094         StringBuffer buffer = new StringBuffer();
3095         StringBuffer shortBuffer = new StringBuffer();
3096         for (int i = 0, length = params.length; i < length; i++) {
3097                 if (i != 0){
3098                         buffer.append(", "); //$NON-NLS-1$
3099                         shortBuffer.append(", "); //$NON-NLS-1$
3100                 }
3101                 buffer.append(new String(params[i].readableName()));
3102                 shortBuffer.append(new String(params[i].shortReadableName()));
3103         }
3104
3105         int id = recType.isArrayType() ? IProblem.JavadocNoMessageSendOnArrayType : IProblem.JavadocNoMessageSendOnBaseType;
3106         if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3107                 this.handle(
3108                         id,
3109                         new String[] {new String(recType.readableName()), new String(messageSend.selector), buffer.toString()},
3110                         new String[] {new String(recType.shortReadableName()), new String(messageSend.selector), shortBuffer.toString()},
3111                         messageSend.sourceStart,
3112                         messageSend.sourceEnd);
3113         }
3114 }
3115 public void javadocInvalidConstructor(Statement statement, MethodBinding targetConstructor, int modifiers) {
3116
3117         if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) return;
3118         int id = IProblem.JavadocUndefinedConstructor; //default...
3119         switch (targetConstructor.problemId()) {
3120                 case NotFound :
3121                         id = IProblem.JavadocUndefinedConstructor;
3122                         break;
3123                 case NotVisible :
3124                         id = IProblem.JavadocNotVisibleConstructor;
3125                         break;
3126                 case Ambiguous :
3127                         id = IProblem.JavadocAmbiguousConstructor;
3128                         break;
3129                 case NoError : // 0
3130                 default :
3131                         needImplementation(); // want to fail to see why we were here...
3132                         break;
3133         }
3134         this.handle(
3135                 id,
3136                 new String[] {new String(targetConstructor.declaringClass.readableName()), typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, false)},
3137                 new String[] {new String(targetConstructor.declaringClass.shortReadableName()), typesAsString(targetConstructor.isVarargs(), targetConstructor.parameters, true)},
3138                 statement.sourceStart,
3139                 statement.sourceEnd);
3140 }
3141 /*
3142  * Similar implementation than invalidField(FieldReference...)
3143  * Note that following problem id cannot occur for Javadoc:
3144  *      - NonStaticReferenceInStaticContext :
3145  *      - NonStaticReferenceInConstructorInvocation :
3146  *      - ReceiverTypeNotVisible :
3147  */
3148 public void javadocInvalidField(int sourceStart, int sourceEnd, Binding fieldBinding, TypeBinding searchedType, int modifiers) {
3149         int id = IProblem.JavadocUndefinedField;
3150         switch (fieldBinding.problemId()) {
3151                 case NotFound :
3152                         id = IProblem.JavadocUndefinedField;
3153                         break;
3154                 case NotVisible :
3155                         id = IProblem.JavadocNotVisibleField;
3156                         break;
3157                 case Ambiguous :
3158                         id = IProblem.JavadocAmbiguousField;
3159                         break;
3160                 case InheritedNameHidesEnclosingName :
3161                         id = IProblem.JavadocInheritedFieldHidesEnclosingName;
3162                         break;
3163                 case NoError : // 0
3164                 default :
3165                         needImplementation(); // want to fail to see why we were here...
3166                         break;
3167         }
3168         // report issue
3169         if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3170                 String[] arguments = new String[] {new String(fieldBinding.readableName())};
3171                 handle(id, arguments, arguments, sourceStart, sourceEnd);
3172         }
3173 }
3174 /*
3175  * Similar implementation than invalidMethod(MessageSend...)
3176  * Note that following problem id cannot occur for Javadoc:
3177  *      - NonStaticReferenceInStaticContext :
3178  *      - NonStaticReferenceInConstructorInvocation :
3179  *      - ReceiverTypeNotVisible :
3180  */
3181 public void javadocInvalidMethod(MessageSend messageSend, MethodBinding method, int modifiers) {
3182         if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) return;
3183         // set problem id
3184         int id = IProblem.JavadocUndefinedMethod; //default...
3185         switch (method.problemId()) {
3186                 case NotFound :
3187                         id = IProblem.JavadocUndefinedMethod;
3188                         break;
3189                 case NotVisible :
3190                         id = IProblem.JavadocNotVisibleMethod;
3191                         break;
3192                 case Ambiguous :
3193                         id = IProblem.JavadocAmbiguousMethod;
3194                         break;
3195                 case InheritedNameHidesEnclosingName :
3196                         id = IProblem.JavadocInheritedMethodHidesEnclosingName;
3197                         break;
3198                 case NoError : // 0
3199                 default :
3200                         needImplementation(); // want to fail to see why we were here...
3201                         break;
3202         }
3203         if (id == IProblem.JavadocUndefinedMethod) {
3204                 ProblemMethodBinding problemMethod = (ProblemMethodBinding) method;
3205                 if (problemMethod.closestMatch != null) {
3206                                 String closestParameterTypeNames = typesAsString(problemMethod.closestMatch.isVarargs(), problemMethod.closestMatch.parameters, false);
3207                                 String parameterTypeNames = typesAsString(method.isVarargs(), method.parameters, false);
3208                                 String closestParameterTypeShortNames = typesAsString(problemMethod.closestMatch.isVarargs(), problemMethod.closestMatch.parameters, true);
3209                                 String parameterTypeShortNames = typesAsString(method.isVarargs(), method.parameters, true);
3210                                 if (closestParameterTypeShortNames.equals(parameterTypeShortNames)){
3211                                         closestParameterTypeShortNames = closestParameterTypeNames;
3212                                         parameterTypeShortNames = parameterTypeNames;
3213                                 }
3214                                 this.handle(
3215                                         IProblem.JavadocParameterMismatch,
3216                                         new String[] {
3217                                                 new String(problemMethod.closestMatch.declaringClass.readableName()),
3218                                                 new String(problemMethod.closestMatch.selector),
3219                                                 closestParameterTypeNames,
3220                                                 parameterTypeNames 
3221                                         },
3222                                         new String[] {
3223                                                 new String(problemMethod.closestMatch.declaringClass.shortReadableName()),
3224                                                 new String(problemMethod.closestMatch.selector),
3225                                                 closestParameterTypeShortNames,
3226                                                 parameterTypeShortNames
3227                                         },
3228                                         (int) (messageSend.nameSourcePosition >>> 32),
3229                                         (int) messageSend.nameSourcePosition);
3230                                 return;
3231                 }
3232         }
3233         // report issue
3234         this.handle(
3235                 id,
3236                 new String[] {
3237                         new String(method.declaringClass.readableName()),
3238                         new String(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
3239                 new String[] {
3240                         new String(method.declaringClass.shortReadableName()),
3241                         new String(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
3242                 (int) (messageSend.nameSourcePosition >>> 32),
3243                 (int) messageSend.nameSourcePosition);
3244 }
3245 public void javadocInvalidParamTagName(int sourceStart, int sourceEnd) {
3246         this.handle(IProblem.JavadocInvalidParamTagName, NoArgument, NoArgument, sourceStart, sourceEnd);
3247 }
3248 public void javadocInvalidParamTypeParameter(int sourceStart, int sourceEnd) {
3249         this.handle(IProblem.JavadocInvalidParamTagTypeParameter, NoArgument, NoArgument, sourceStart, sourceEnd);
3250 }
3251 public void javadocInvalidReference(int sourceStart, int sourceEnd) {
3252         this.handle(IProblem.JavadocInvalidReference, NoArgument, NoArgument, sourceStart, sourceEnd);
3253 }
3254 public void javadocInvalidSeeReferenceArgs(int sourceStart, int sourceEnd) {
3255         this.handle(IProblem.JavadocInvalidSeeArgs, NoArgument, NoArgument, sourceStart, sourceEnd);
3256 }
3257 public void javadocInvalidSeeUrlReference(int sourceStart, int sourceEnd) {
3258         this.handle(IProblem.JavadocInvalidSeeHref, NoArgument, NoArgument, sourceStart, sourceEnd);
3259 }
3260 public void javadocInvalidTag(int sourceStart, int sourceEnd) {
3261         this.handle(IProblem.JavadocInvalidTag, NoArgument, NoArgument, sourceStart, sourceEnd);
3262 }
3263 public void javadocInvalidThrowsClass(int sourceStart, int sourceEnd) {
3264         this.handle(IProblem.JavadocInvalidThrowsClass, NoArgument, NoArgument, sourceStart, sourceEnd);
3265 }
3266 public void javadocInvalidThrowsClassName(TypeReference typeReference, int modifiers) {
3267         if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3268                 String[] arguments = new String[] {String.valueOf(typeReference.resolvedType.sourceName())};
3269                 this.handle(IProblem.JavadocInvalidThrowsClassName, arguments, arguments, typeReference.sourceStart, typeReference.sourceEnd);
3270         }
3271 }
3272 public void javadocInvalidType(ASTNode location, TypeBinding type, int modifiers) {
3273         if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3274                 int id = IProblem.JavadocUndefinedType; // default
3275                 switch (type.problemId()) {
3276                         case NotFound :
3277                                 id = IProblem.JavadocUndefinedType;
3278                                 break;
3279                         case NotVisible :
3280                                 id = IProblem.JavadocNotVisibleType;
3281                                 break;
3282                         case Ambiguous :
3283                                 id = IProblem.JavadocAmbiguousType;
3284                                 break;
3285                         case InternalNameProvided :
3286                                 id = IProblem.JavadocInternalTypeNameProvided;
3287                                 break;
3288                         case InheritedNameHidesEnclosingName :
3289                                 id = IProblem.JavadocInheritedNameHidesEnclosingTypeName;
3290                                 break;
3291                         case NoError : // 0
3292                         default :
3293                                 needImplementation(); // want to fail to see why we were here...
3294                                 break;
3295                 }
3296                 this.handle(
3297                         id,
3298                         new String[] {new String(type.readableName())},
3299                         new String[] {new String(type.shortReadableName())},
3300                         location.sourceStart,
3301                         location.sourceEnd);
3302         }
3303 }
3304 public void javadocInvalidValueReference(int sourceStart, int sourceEnd, int modifiers) {
3305         if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
3306                 this.handle(IProblem.JavadocInvalidValueReference, NoArgument, NoArgument, sourceStart, sourceEnd);
3307 }
3308 public void javadocMalformedSeeReference(int sourceStart, int sourceEnd) {
3309         this.handle(IProblem.JavadocMalformedSeeReference, NoArgument, NoArgument, sourceStart, sourceEnd);
3310 }
3311 public void javadocMissing(int sourceStart, int sourceEnd, int modifiers){
3312         boolean overriding = (modifiers & (CompilerModifiers.AccImplementing|CompilerModifiers.AccOverriding)) != 0;
3313         boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocComments) != ProblemSeverities.Ignore)
3314                                         && (!overriding || this.options.reportMissingJavadocCommentsOverriding);
3315         if (report) {
3316                 String arg = javadocVisibilityArgument(this.options.reportMissingJavadocCommentsVisibility, modifiers);
3317                 if (arg != null) {
3318                         String[] arguments = new String[] { arg };
3319                         this.handle(IProblem.JavadocMissing, arguments, arguments, sourceStart, sourceEnd);
3320                 }
3321         }
3322 }
3323 public void javadocMissingHashCharacter(int sourceStart, int sourceEnd, String ref){
3324         String[] arguments = new String[] { ref };
3325         this.handle(IProblem.JavadocMissingHashCharacter, arguments, arguments, sourceStart, sourceEnd);
3326 }
3327 public void javadocMissingParamName(int sourceStart, int sourceEnd, int modifiers){
3328         if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
3329                 this.handle(IProblem.JavadocMissingParamName, NoArgument, NoArgument, sourceStart, sourceEnd);
3330 }
3331 public void javadocMissingParamTag(char[] name, int sourceStart, int sourceEnd, int modifiers) {
3332         boolean overriding = (modifiers & (CompilerModifiers.AccImplementing|CompilerModifiers.AccOverriding)) != 0;
3333         boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore)
3334                                         && (!overriding || this.options.reportMissingJavadocTagsOverriding);
3335         if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) {
3336                 String[] arguments = new String[] { String.valueOf(name) };
3337                 this.handle(IProblem.JavadocMissingParamTag, arguments, arguments, sourceStart, sourceEnd);
3338         }
3339 }
3340 public void javadocMissingReference(int sourceStart, int sourceEnd, int modifiers){
3341         if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
3342                 this.handle(IProblem.JavadocMissingReference, NoArgument, NoArgument, sourceStart, sourceEnd);
3343 }
3344 public void javadocMissingReturnTag(int sourceStart, int sourceEnd, int modifiers){
3345         boolean overriding = (modifiers & (CompilerModifiers.AccImplementing|CompilerModifiers.AccOverriding)) != 0;
3346         boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore)
3347                                         && (!overriding || this.options.reportMissingJavadocTagsOverriding);
3348         if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) {
3349                 this.handle(IProblem.JavadocMissingReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd);
3350         }
3351 }
3352 public void javadocMissingThrowsClassName(int sourceStart, int sourceEnd, int modifiers){
3353         if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
3354                 this.handle(IProblem.JavadocMissingThrowsClassName, NoArgument, NoArgument, sourceStart, sourceEnd);
3355 }
3356 public void javadocMissingThrowsTag(TypeReference typeRef, int modifiers){
3357         boolean overriding = (modifiers & (CompilerModifiers.AccImplementing|CompilerModifiers.AccOverriding)) != 0;
3358         boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore)
3359                                         && (!overriding || this.options.reportMissingJavadocTagsOverriding);
3360         if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) {
3361                 String[] arguments = new String[] { String.valueOf(typeRef.resolvedType.sourceName()) };
3362                 this.handle(IProblem.JavadocMissingThrowsTag, arguments, arguments, typeRef.sourceStart, typeRef.sourceEnd);
3363         }
3364 }
3365 public void javadocUndeclaredParamTagName(char[] token, int sourceStart, int sourceEnd, int modifiers) {
3366         if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
3367                 String[] arguments = new String[] {String.valueOf(token)};
3368                 this.handle(IProblem.JavadocInvalidParamName, arguments, arguments, sourceStart, sourceEnd);
3369         }
3370 }
3371 public void javadocUnexpectedTag(int sourceStart, int sourceEnd) {
3372         this.handle(IProblem.JavadocUnexpectedTag, NoArgument, NoArgument, sourceStart, sourceEnd);
3373 }
3374 public void javadocUnexpectedText(int sourceStart, int sourceEnd) {
3375         this.handle(IProblem.JavadocUnexpectedText, NoArgument, NoArgument, sourceStart, sourceEnd);
3376 }
3377 public void javadocUnterminatedInlineTag(int sourceStart, int sourceEnd) {
3378         this.handle(IProblem.JavadocUnterminatedInlineTag, NoArgument, NoArgument, sourceStart, sourceEnd);
3379 }
3380 private boolean javadocVisibility(int visibility, int modifiers) {
3381         if (modifiers < 0) return true;
3382         switch (modifiers & CompilerModifiers.AccVisibilityMASK) {
3383                 case IConstants.AccPublic :
3384                         return true;
3385                 case IConstants.AccProtected:
3386                         return (visibility != IConstants.AccPublic);
3387                 case IConstants.AccDefault:
3388                         return (visibility == IConstants.AccDefault || visibility == IConstants.AccPrivate);
3389                 case IConstants.AccPrivate:
3390                         return (visibility == IConstants.AccPrivate);
3391         }
3392         return true;
3393 }
3394 private String javadocVisibilityArgument(int visibility, int modifiers) {
3395         String argument = null;
3396         switch (modifiers & CompilerModifiers.AccVisibilityMASK) {
3397                 case IConstants.AccPublic :
3398                         argument = CompilerOptions.PUBLIC;
3399                         break;
3400                 case IConstants.AccProtected:
3401                         if (visibility != IConstants.AccPublic) {
3402                                 argument = CompilerOptions.PROTECTED;
3403                         }
3404                         break;
3405                 case IConstants.AccDefault:
3406                         if (visibility == IConstants.AccDefault || visibility == IConstants.AccPrivate) {
3407                                 argument = CompilerOptions.DEFAULT;
3408                         }
3409                         break;
3410                 case IConstants.AccPrivate:
3411                         if (visibility == IConstants.AccPrivate) {
3412                                 argument = CompilerOptions.PRIVATE;
3413                         }
3414                         break;
3415         }
3416         return argument;
3417 }
3418 public void localVariableCannotBeNull(LocalVariableBinding local, ASTNode location) {
3419         String[] arguments = new String[] {new String(local.name)  };
3420         this.handle(
3421                 IProblem.LocalVariableCannotBeNull,
3422                 arguments,
3423                 arguments,
3424                 location.sourceStart,
3425                 location.sourceEnd);
3426 }
3427 public void localVariableCanOnlyBeNull(LocalVariableBinding local, ASTNode location) {
3428         String[] arguments = new String[] {new String(local.name)  };
3429         this.handle(
3430                 IProblem.LocalVariableCanOnlyBeNull,
3431                 arguments,
3432                 arguments,
3433                 location.sourceStart,
3434                 location.sourceEnd);
3435 }
3436 public void localVariableHiding(LocalDeclaration local, Binding hiddenVariable, boolean  isSpecialArgHidingField) {
3437         if (hiddenVariable instanceof LocalVariableBinding) {
3438                 String[] arguments = new String[] {new String(local.name)  };
3439                 this.handle(
3440                         (local instanceof Argument) 
3441                                 ? IProblem.ArgumentHidingLocalVariable 
3442                                 : IProblem.LocalVariableHidingLocalVariable,
3443                         arguments,
3444                         arguments,
3445                         local.sourceStart,
3446                         local.sourceEnd);
3447         } else if (hiddenVariable instanceof FieldBinding) {
3448                 if (isSpecialArgHidingField && !this.options.reportSpecialParameterHidingField){
3449                         return;
3450                 }
3451                 FieldBinding field = (FieldBinding) hiddenVariable;
3452                 this.handle(
3453                         (local instanceof Argument)
3454                                 ? IProblem.ArgumentHidingField
3455                                 : IProblem.LocalVariableHidingField,
3456                         new String[] {new String(local.name) , new String(field.declaringClass.readableName()) },
3457                         new String[] {new String(local.name), new String(field.declaringClass.shortReadableName()) },
3458                         local.sourceStart,
3459                         local.sourceEnd);
3460         }
3461 }
3462 public void methodNameClash(MethodBinding currentMethod, MethodBinding inheritedMethod) {
3463         this.handle(
3464                 IProblem.MethodNameClash,
3465                 new String[] {
3466                         new String(currentMethod.selector),
3467                         typesAsString(currentMethod.original().isVarargs(), currentMethod.original().parameters, false),
3468                         new String(currentMethod.declaringClass.readableName()),
3469                         typesAsString(inheritedMethod.original().isVarargs(), inheritedMethod.original().parameters, false),
3470                         new String(inheritedMethod.declaringClass.readableName()),
3471                  }, 
3472                 new String[] {
3473                         new String(currentMethod.selector),
3474                         typesAsString(currentMethod.original().isVarargs(), currentMethod.original().parameters, true),
3475                         new String(currentMethod.declaringClass.shortReadableName()),
3476                         typesAsString(inheritedMethod.original().isVarargs(), inheritedMethod.original().parameters, true),
3477                         new String(inheritedMethod.declaringClass.shortReadableName()),
3478                  }, 
3479                 currentMethod.sourceStart(),
3480                 currentMethod.sourceEnd());
3481 }       
3482
3483 public void methodNeedBody(AbstractMethodDeclaration methodDecl) {
3484         this.handle(
3485                 IProblem.MethodRequiresBody,
3486                 NoArgument,
3487                 NoArgument,
3488                 methodDecl.sourceStart,
3489                 methodDecl.sourceEnd);
3490 }
3491 public void methodNeedingNoBody(MethodDeclaration methodDecl) {
3492         this.handle(
3493                 ((methodDecl.modifiers & IConstants.AccNative) != 0) ? IProblem.BodyForNativeMethod : IProblem.BodyForAbstractMethod,
3494                 NoArgument,
3495                 NoArgument,
3496                 methodDecl.sourceStart,
3497                 methodDecl.sourceEnd);
3498 }
3499 public void methodWithConstructorName(MethodDeclaration methodDecl) {
3500         this.handle(
3501                 IProblem.MethodButWithConstructorName,
3502                 NoArgument,
3503                 NoArgument,
3504                 methodDecl.sourceStart,
3505                 methodDecl.sourceEnd);
3506 }
3507 public void parameterizedMemberTypeMissingArguments(ASTNode location, TypeBinding type) {
3508         if (location == null) { // binary case
3509             this.handle(
3510                         IProblem.MissingArgumentsForParameterizedMemberType,
3511                         new String[] {new String(type.readableName())},
3512                         new String[] {new String(type.shortReadableName())},
3513                         AbortCompilation | Error,
3514                         0,
3515                         1);
3516             return;
3517         }
3518     this.handle(
3519                 IProblem.MissingArgumentsForParameterizedMemberType,
3520                 new String[] {new String(type.readableName())},
3521                 new String[] {new String(type.shortReadableName())},
3522                 location.sourceStart,
3523                 location.sourceEnd);
3524 }
3525 public void missingReturnType(AbstractMethodDeclaration methodDecl) {
3526         this.handle(
3527                 IProblem.MissingReturnType,
3528                 NoArgument,
3529                 NoArgument,
3530                 methodDecl.sourceStart,
3531                 methodDecl.sourceEnd);
3532 }
3533 public void missingSemiColon(Expression expression){
3534         this.handle(
3535                 IProblem.MissingSemiColon,
3536                 NoArgument,
3537                 NoArgument,
3538                 expression.sourceStart,
3539                 expression.sourceEnd);
3540 }
3541 public void missingSerialVersion(TypeDeclaration typeDecl) {
3542         String[] arguments = new String[] {new String(typeDecl.name)};
3543         this.handle(
3544                 IProblem.MissingSerialVersion,
3545                 arguments,
3546                 arguments,
3547                 typeDecl.sourceStart,
3548                 typeDecl.sourceEnd);
3549 }
3550 public void missingValueForAnnotationMember(Annotation annotation, char[] memberName) {
3551         String memberString = new String(memberName);
3552         this.handle(
3553                 IProblem.MissingValueForAnnotationMember,
3554                 new String[] {new String(annotation.resolvedType.readableName()), memberString },
3555                 new String[] {new String(annotation.resolvedType.shortReadableName()), memberString},
3556                 annotation.sourceStart,
3557                 annotation.sourceEnd);
3558 }
3559 public void mustDefineDimensionsOrInitializer(ArrayAllocationExpression expression) {
3560         this.handle(
3561                 IProblem.MustDefineEitherDimensionExpressionsOrInitializer,
3562                 NoArgument,
3563                 NoArgument,
3564                 expression.sourceStart,
3565                 expression.sourceEnd);
3566 }
3567 public void mustSpecifyPackage(CompilationUnitDeclaration compUnitDecl) {
3568         String[] arguments = new String[] {new String(compUnitDecl.getFileName())};
3569         this.handle(
3570                 IProblem.MustSpecifyPackage,
3571                 arguments,
3572                 arguments,
3573                 compUnitDecl.sourceStart,
3574                 compUnitDecl.sourceStart + 1);  
3575 }
3576 public void mustUseAStaticMethod(MessageSend messageSend, MethodBinding method) {
3577         this.handle(
3578                 IProblem.StaticMethodRequested,
3579                 new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
3580                 new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
3581                 messageSend.sourceStart,
3582                 messageSend.sourceEnd);
3583 }
3584
3585 public void nativeMethodsCannotBeStrictfp(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
3586         String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
3587         this.handle(
3588                 IProblem.NativeMethodsCannotBeStrictfp,
3589                 arguments,
3590                 arguments,
3591                 methodDecl.sourceStart,
3592                 methodDecl.sourceEnd);
3593 }
3594 public void needImplementation() {
3595         this.abortDueToInternalError(Util.bind("abort.missingCode")); //$NON-NLS-1$
3596 }
3597 public void needToEmulateFieldAccess(FieldBinding field, ASTNode location, boolean isReadAccess) {
3598         this.handle(
3599                 isReadAccess 
3600                         ? IProblem.NeedToEmulateFieldReadAccess
3601                         : IProblem.NeedToEmulateFieldWriteAccess,
3602                 new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
3603                 new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
3604                 location.sourceStart,
3605                 location.sourceEnd);
3606 }
3607 public void needToEmulateMethodAccess(
3608         MethodBinding method, 
3609         ASTNode location) {
3610
3611         if (method.isConstructor())
3612                 this.handle(
3613                         IProblem.NeedToEmulateConstructorAccess, 
3614                         new String[] {
3615                                 new String(method.declaringClass.readableName()), 
3616                                 typesAsString(method.isVarargs(), method.parameters, false)
3617                          }, 
3618                         new String[] {
3619                                 new String(method.declaringClass.shortReadableName()), 
3620                                 typesAsString(method.isVarargs(), method.parameters, true)
3621                          }, 
3622                         location.sourceStart, 
3623                         location.sourceEnd); 
3624         else
3625                 this.handle(
3626                         IProblem.NeedToEmulateMethodAccess, 
3627                         new String[] {
3628                                 new String(method.declaringClass.readableName()), 
3629                                 new String(method.selector), 
3630                                 typesAsString(method.isVarargs(), method.parameters, false)
3631                          }, 
3632                         new String[] {
3633                                 new String(method.declaringClass.shortReadableName()), 
3634                                 new String(method.selector), 
3635                                 typesAsString(method.isVarargs(), method.parameters, true)
3636                          }, 
3637                         location.sourceStart, 
3638                         location.sourceEnd); 
3639 }
3640 public void nestedClassCannotDeclareInterface(TypeDeclaration typeDecl) {
3641         String[] arguments = new String[] {new String(typeDecl.name)};
3642         this.handle(
3643                 IProblem.CannotDefineInterfaceInLocalType,
3644                 arguments,
3645                 arguments,
3646                 typeDecl.sourceStart,
3647                 typeDecl.sourceEnd);
3648 }
3649 public void noMoreAvailableSpaceForArgument(LocalVariableBinding local, ASTNode location) {
3650         String[] arguments = new String[]{ new String(local.name) };
3651         this.handle(
3652                 local instanceof SyntheticArgumentBinding
3653                         ? IProblem.TooManySyntheticArgumentSlots
3654                         : IProblem.TooManyArgumentSlots,
3655                 arguments,
3656                 arguments,
3657                 Abort | Error,
3658                 location.sourceStart,
3659                 location.sourceEnd);
3660 }
3661
3662 public void noMoreAvailableSpaceForConstant(TypeDeclaration typeDeclaration) {
3663         this.handle(
3664                 IProblem.TooManyBytesForStringConstant,
3665                 new String[]{ new String(typeDeclaration.binding.readableName())},
3666                 new String[]{ new String(typeDeclaration.binding.shortReadableName())},
3667                 Abort | Error,
3668                 typeDeclaration.sourceStart,
3669                 typeDeclaration.sourceEnd);
3670 }
3671 public void noMoreAvailableSpaceForLocal(LocalVariableBinding local, ASTNode location) {
3672         String[] arguments = new String[]{ new String(local.name) };
3673         this.handle(
3674                 IProblem.TooManyLocalVariableSlots,
3675                 arguments,
3676                 arguments,
3677                 Abort | Error,
3678                 location.sourceStart,
3679                 location.sourceEnd);
3680 }
3681
3682 public void noMoreAvailableSpaceInConstantPool(TypeDeclaration typeDeclaration) {
3683         this.handle(
3684                 IProblem.TooManyConstantsInConstantPool,
3685                 new String[]{ new String(typeDeclaration.binding.readableName())},
3686                 new String[]{ new String(typeDeclaration.binding.shortReadableName())},
3687                 Abort | Error,
3688                 typeDeclaration.sourceStart,
3689                 typeDeclaration.sourceEnd);
3690 }
3691 public void nonExternalizedStringLiteral(ASTNode location) {
3692         this.handle(
3693                 IProblem.NonExternalizedStringLiteral,
3694                 NoArgument,
3695                 NoArgument,
3696                 location.sourceStart,
3697                 location.sourceEnd);
3698 }
3699 public void nonGenericTypeCannotBeParameterized(ASTNode location, TypeBinding type, TypeBinding[] argumentTypes) {
3700         if (location == null) { // binary case
3701             this.handle(
3702                         IProblem.NonGenericType,
3703                         new String[] {new String(type.readableName()), typesAsString(false, argumentTypes, false)},
3704                         new String[] {new String(type.shortReadableName()), typesAsString(false, argumentTypes, true)},
3705                         AbortCompilation | Error,
3706                         0,
3707                         1);
3708             return;
3709         }
3710     this.handle(
3711                 IProblem.NonGenericType,
3712                 new String[] {new String(type.readableName()), typesAsString(false, argumentTypes, false)},
3713                 new String[] {new String(type.shortReadableName()), typesAsString(false, argumentTypes, true)},
3714                 location.sourceStart,
3715                 location.sourceEnd);
3716 }
3717 public void nonStaticAccessToStaticField(ASTNode location, FieldBinding field) {
3718         this.handle(
3719                 IProblem.NonStaticAccessToStaticField,
3720                 new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
3721                 new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
3722                 location.sourceStart,
3723                 fieldLocation(field, location));
3724 }
3725 public void nonStaticAccessToStaticMethod(ASTNode location, MethodBinding method) {
3726         this.handle(
3727                 IProblem.NonStaticAccessToStaticMethod,
3728                 new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, false)},
3729                 new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, true)},
3730                 location.sourceStart,
3731                 location.sourceEnd);
3732 }
3733 public void noSuchEnclosingInstance(TypeBinding targetType, ASTNode location, boolean isConstructorCall) {
3734
3735         int id;
3736
3737         if (isConstructorCall) {
3738                 //28 = No enclosing instance of type {0} is available due to some intermediate constructor invocation
3739                 id = IProblem.EnclosingInstanceInConstructorCall;
3740         } else if ((location instanceof ExplicitConstructorCall)
3741                                 && ((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper) {
3742                 //20 = No enclosing instance of type {0} is accessible to invoke the super constructor. Must define a constructor and explicitly qualify its super constructor invocation with an instance of {0} (e.g. x.super() where x is an instance of {0}).
3743                 id = IProblem.MissingEnclosingInstanceForConstructorCall;
3744         } else if (location instanceof AllocationExpression 
3745                                 && (((AllocationExpression) location).binding.declaringClass.isMemberType()
3746                                         || (((AllocationExpression) location).binding.declaringClass.isAnonymousType() 
3747                                                 && ((AllocationExpression) location).binding.declaringClass.superclass().isMemberType()))) {
3748                 //21 = No enclosing instance of type {0} is accessible. Must qualify the allocation with an enclosing instance of type {0} (e.g. x.new A() where x is an instance of {0}).
3749                 id = IProblem.MissingEnclosingInstance;
3750         } else { // default
3751                 //22 = No enclosing instance of the type {0} is accessible in scope
3752                 id = IProblem.IncorrectEnclosingInstanceReference;
3753         }
3754
3755         this.handle(
3756                 id,
3757                 new String[] { new String(targetType.readableName())}, 
3758                 new String[] { new String(targetType.shortReadableName())}, 
3759                 location.sourceStart, 
3760                 location.sourceEnd); 
3761 }
3762 public void notCompatibleTypesError(EqualExpression expression, TypeBinding leftType, TypeBinding rightType) {
3763         String leftName = new String(leftType.readableName());
3764         String rightName = new String(rightType.readableName());
3765         String leftShortName = new String(leftType.shortReadableName());
3766         String rightShortName = new String(rightType.shortReadableName());
3767         if (leftShortName.equals(rightShortName)){
3768                 leftShortName = leftName;
3769                 rightShortName = rightName;
3770         }
3771         this.handle(
3772                 IProblem.IncompatibleTypesInEqualityOperator,
3773                 new String[] {leftName, rightName },
3774                 new String[] {leftShortName, rightShortName },
3775                 expression.sourceStart,
3776                 expression.sourceEnd);
3777 }
3778 public void notCompatibleTypesError(InstanceOfExpression expression, TypeBinding leftType, TypeBinding rightType) {
3779         String leftName = new String(leftType.readableName());
3780         String rightName = new String(rightType.readableName());
3781         String leftShortName = new String(leftType.shortReadableName());
3782         String rightShortName = new String(rightType.shortReadableName());
3783         if (leftShortName.equals(rightShortName)){
3784                 leftShortName = leftName;
3785                 rightShortName = rightName;
3786         }
3787         this.handle(
3788                 IProblem.IncompatibleTypesInConditionalOperator,
3789                 new String[] {leftName, rightName },
3790                 new String[] {leftShortName, rightShortName },
3791                 expression.sourceStart,
3792                 expression.sourceEnd);
3793 }
3794 public void notCompatibleTypesErrorInForeach(Expression expression, TypeBinding leftType, TypeBinding rightType) {
3795         String leftName = new String(leftType.readableName());
3796         String rightName = new String(rightType.readableName());
3797         String leftShortName = new String(leftType.shortReadableName());
3798         String rightShortName = new String(rightType.shortReadableName());
3799         if (leftShortName.equals(rightShortName)){
3800                 leftShortName = leftName;
3801                 rightShortName = rightName;
3802         }
3803         this.handle(
3804                 IProblem.IncompatibleTypesInForeach,
3805                 new String[] {leftName, rightName },
3806                 new String[] {leftShortName, rightShortName },
3807                 expression.sourceStart,
3808                 expression.sourceEnd);
3809 }
3810 public void objectCannotBeGeneric(TypeDeclaration typeDecl) {
3811         this.handle(
3812                 IProblem.ObjectCannotBeGeneric,
3813                 NoArgument,
3814                 NoArgument,
3815                 typeDecl.typeParameters[0].sourceStart,
3816                 typeDecl.typeParameters[typeDecl.typeParameters.length-1].sourceEnd);
3817 }
3818 public void objectCannotHaveSuperTypes(SourceTypeBinding type) {
3819         this.handle(
3820                 IProblem.ObjectCannotHaveSuperTypes,
3821                 NoArgument,
3822                 NoArgument,
3823                 type.sourceStart(),
3824                 type.sourceEnd());
3825 }
3826 public void objectMustBeClass(SourceTypeBinding type) {
3827         this.handle(
3828                 IProblem.ObjectMustBeClass,
3829                 NoArgument,
3830                 NoArgument,
3831                 type.sourceStart(),
3832                 type.sourceEnd());
3833 }
3834 public void operatorOnlyValidOnNumericType(CompoundAssignment  assignment, TypeBinding leftType, TypeBinding rightType) {
3835         String leftName = new String(leftType.readableName());
3836         String rightName = new String(rightType.readableName());
3837         String leftShortName = new String(leftType.shortReadableName());
3838         String rightShortName = new String(rightType.shortReadableName());
3839         if (leftShortName.equals(rightShortName)){
3840                 leftShortName = leftName;
3841                 rightShortName = rightName;
3842         }
3843         this.handle(
3844                 IProblem.TypeMismatch,
3845                 new String[] {leftName, rightName },
3846                 new String[] {leftShortName, rightShortName },
3847                 assignment.sourceStart,
3848                 assignment.sourceEnd);
3849 }
3850 public void overridesDeprecatedMethod(MethodBinding localMethod, MethodBinding inheritedMethod) {
3851         this.handle(
3852                 IProblem.OverridingDeprecatedMethod,
3853                 new String[] {
3854                         new String(
3855                                         CharOperation.concat(
3856                                                 localMethod.declaringClass.readableName(),
3857                                                 localMethod.readableName(),
3858                                                 '.')),
3859                         new String(inheritedMethod.declaringClass.readableName())},
3860                 new String[] {
3861                         new String(
3862                                         CharOperation.concat(
3863                                                 localMethod.declaringClass.shortReadableName(),
3864                                                 localMethod.shortReadableName(),
3865                                                 '.')),
3866                         new String(inheritedMethod.declaringClass.shortReadableName())},
3867                 localMethod.sourceStart(),
3868                 localMethod.sourceEnd());
3869 }
3870 public void overridesPackageDefaultMethod(MethodBinding localMethod, MethodBinding inheritedMethod) {
3871         this.handle(
3872                 IProblem.OverridingNonVisibleMethod,
3873                 new String[] {
3874                         new String(
3875                                         CharOperation.concat(
3876                                                 localMethod.declaringClass.readableName(),
3877                                                 localMethod.readableName(),
3878                                                 '.')),
3879                         new String(inheritedMethod.declaringClass.readableName())},
3880                 new String[] {
3881                         new String(
3882                                         CharOperation.concat(
3883                                                 localMethod.declaringClass.shortReadableName(),
3884                                                 localMethod.shortReadableName(),
3885                                                 '.')),
3886                         new String(inheritedMethod.declaringClass.shortReadableName())},
3887                 localMethod.sourceStart(),
3888                 localMethod.sourceEnd());
3889 }
3890 public void packageCollidesWithType(CompilationUnitDeclaration compUnitDecl) {
3891         String[] arguments = new String[] {CharOperation.toString(compUnitDecl.currentPackage.tokens)};
3892         this.handle(
3893                 IProblem.PackageCollidesWithType,
3894                 arguments,
3895                 arguments,
3896                 compUnitDecl.currentPackage.sourceStart,
3897                 compUnitDecl.currentPackage.sourceEnd);
3898 }
3899 public void packageIsNotExpectedPackage(CompilationUnitDeclaration compUnitDecl) {
3900         String[] arguments = new String[] {CharOperation.toString(compUnitDecl.compilationResult.compilationUnit.getPackageName())};
3901         this.handle(
3902                 IProblem.PackageIsNotExpectedPackage,
3903                 arguments,
3904                 arguments,
3905                 compUnitDecl.currentPackage == null ? 0 : compUnitDecl.currentPackage.sourceStart,
3906                 compUnitDecl.currentPackage == null ? 0 : compUnitDecl.currentPackage.sourceEnd);
3907 }
3908 private String parameterBoundAsString(TypeVariableBinding typeVariable, boolean makeShort) {
3909     StringBuffer nameBuffer = new StringBuffer(10);
3910     if (typeVariable.firstBound == typeVariable.superclass) {
3911         nameBuffer.append(makeShort ? typeVariable.superclass.shortReadableName() : typeVariable.superclass.readableName());
3912     }
3913     int length;
3914     if ((length = typeVariable.superInterfaces.length) > 0) {
3915             for (int i = 0; i < length; i++) {
3916                 if (i > 0 || typeVariable.firstBound == typeVariable.superclass) nameBuffer.append(" & "); //$NON-NLS-1$
3917                 nameBuffer.append(makeShort ? typeVariable.superInterfaces[i].shortReadableName() : typeVariable.superInterfaces[i].readableName());
3918             }
3919         }
3920         return nameBuffer.toString();
3921 }
3922
3923 public void parseError(
3924         int startPosition, 
3925         int endPosition, 
3926         int currentToken,
3927         char[] currentTokenSource, 
3928         String errorTokenName, 
3929         String[] possibleTokens) {
3930                 
3931         if (possibleTokens.length == 0) { //no suggestion available
3932                 if (isKeyword(currentToken)) {
3933                         String[] arguments = new String[] {new String(currentTokenSource)};
3934                         this.handle(
3935                                 IProblem.ParsingErrorOnKeywordNoSuggestion,
3936                                 arguments,
3937                                 arguments,
3938                                 // this is the current -invalid- token position
3939                                 startPosition,
3940                                 endPosition);
3941                         return;
3942                 } else {
3943                         String[] arguments = new String[] {errorTokenName};
3944                         this.handle(
3945                                 IProblem.ParsingErrorNoSuggestion,
3946                                 arguments,
3947                                 arguments,
3948                                 // this is the current -invalid- token position
3949                                 startPosition,
3950                                 endPosition);
3951                         return;
3952                 }
3953         }
3954
3955         //build a list of probable right tokens
3956         StringBuffer list = new StringBuffer(20);
3957         for (int i = 0, max = possibleTokens.length; i < max; i++) {
3958                 if (i > 0)
3959                         list.append(", "); //$NON-NLS-1$
3960                 list.append('"');
3961                 list.append(possibleTokens[i]);
3962                 list.append('"');
3963         }
3964
3965         if (isKeyword(currentToken)) {
3966                 String[] arguments = new String[] {new String(currentTokenSource), list.toString()};
3967                 this.handle(
3968                         IProblem.ParsingErrorOnKeyword,
3969                         arguments,
3970                         arguments,
3971                         // this is the current -invalid- token position
3972                         startPosition,
3973                         endPosition);
3974                 return;
3975         }
3976         //extract the literal when it's a literal  
3977         if (isLiteral(currentToken) ||
3978                 isIdentifier(currentToken)) { //$NON-NLS-1$
3979                         errorTokenName = new String(currentTokenSource);
3980         }
3981
3982         String[] arguments = new String[] {errorTokenName, list.toString()};
3983         this.handle(
3984                 IProblem.ParsingError,
3985                 arguments,
3986                 arguments,
3987                 // this is the current -invalid- token position
3988                 startPosition,
3989                 endPosition);
3990 }
3991 public void parseErrorDeleteToken(
3992         int start,
3993         int end,
3994         int currentKind,
3995         char[] errorTokenSource,
3996         String errorTokenName){
3997         this.syntaxError(
3998                 IProblem.ParsingErrorDeleteToken,
3999                 start, 
4000                 end, 
4001                 currentKind,
4002                 errorTokenSource, 
4003                 errorTokenName,
4004                 null); 
4005 }
4006 public void parseErrorDeleteTokens(
4007         int start,
4008         int end){
4009         this.handle(
4010                 IProblem.ParsingErrorDeleteTokens,
4011                 NoArgument,
4012                 NoArgument,
4013                 start,
4014                 end);
4015 }
4016 public void parseErrorInsertAfterToken(
4017         int start,
4018         int end,
4019         int currentKind,
4020         char[] errorTokenSource,
4021         String errorTokenName,
4022         String expectedToken){
4023         this.syntaxError(
4024                 IProblem.ParsingErrorInsertTokenAfter,
4025                 start, 
4026                 end, 
4027                 currentKind,
4028                 errorTokenSource, 
4029                 errorTokenName, 
4030                 expectedToken); 
4031 }
4032
4033 public void parseErrorInsertBeforeToken(
4034         int start,
4035         int end,
4036         int currentKind,
4037         char[] errorTokenSource,
4038         String errorTokenName,
4039         String expectedToken){
4040         this.syntaxError(
4041                 IProblem.ParsingErrorInsertTokenBefore,
4042                 start, 
4043                 end, 
4044                 currentKind,
4045                 errorTokenSource, 
4046                 errorTokenName, 
4047                 expectedToken); 
4048 }
4049 public void parseErrorInsertToComplete(
4050         int start,
4051         int end,
4052         String inserted,
4053         String completed){
4054         String[] arguments = new String[] {inserted, completed};
4055         this.handle(
4056                 IProblem.ParsingErrorInsertToComplete,
4057                 arguments,
4058                 arguments,
4059                 start,
4060                 end);
4061 }
4062 public void parseErrorInsertToCompletePhrase(
4063         int start,
4064         int end,
4065         String inserted){
4066         String[] arguments = new String[] {inserted};
4067         this.handle(
4068                 IProblem.ParsingErrorInsertToCompletePhrase,
4069                 arguments,
4070                 arguments,
4071                 start,
4072                 end);
4073 }
4074 public void parseErrorInsertToCompleteScope(
4075         int start,
4076         int end,
4077         String inserted){
4078         String[] arguments = new String[] {inserted};
4079         this.handle(
4080                 IProblem.ParsingErrorInsertToCompleteScope,
4081                 arguments,
4082                 arguments,
4083                 start,
4084                 end);
4085 }
4086 public void parseErrorInvalidToken(
4087         int start,
4088         int end,
4089         int currentKind,
4090         char[] errorTokenSource,
4091         String errorTokenName,
4092         String expectedToken){
4093         this.syntaxError(
4094                 IProblem.ParsingErrorInvalidToken,
4095                 start, 
4096                 end, 
4097                 currentKind,
4098                 errorTokenSource, 
4099                 errorTokenName, 
4100                 expectedToken); 
4101 }
4102 public void parseErrorMergeTokens(
4103         int start,
4104         int end,
4105         String expectedToken){
4106         String[] arguments = new String[] {expectedToken};
4107         this.handle(
4108                 IProblem.ParsingErrorMergeTokens,
4109                 arguments,
4110                 arguments,
4111                 start,
4112                 end);
4113 }
4114 public void parseErrorMisplacedConstruct(
4115         int start,
4116         int end){
4117         this.handle(
4118                 IProblem.ParsingErrorMisplacedConstruct,
4119                 NoArgument,
4120                 NoArgument,
4121                 start,
4122                 end);
4123 }
4124 public void parseErrorNoSuggestion(
4125         int start,
4126         int end,
4127         int currentKind,
4128         char[] errorTokenSource,
4129         String errorTokenName){
4130         this.syntaxError(
4131                 IProblem.ParsingErrorNoSuggestion,
4132                 start, 
4133                 end, 
4134                 currentKind,
4135                 errorTokenSource, 
4136                 errorTokenName,
4137                 null); 
4138 }
4139 public void parseErrorNoSuggestionForTokens(
4140         int start,
4141         int end){
4142         this.handle(
4143                 IProblem.ParsingErrorNoSuggestionForTokens,
4144                 NoArgument,
4145                 NoArgument,
4146                 start,
4147                 end);
4148 }
4149 public void parseErrorReplaceToken(
4150         int start,
4151         int end,
4152         int currentKind,
4153         char[] errorTokenSource,
4154         String errorTokenName,
4155         String expectedToken){
4156         this.syntaxError(
4157                 IProblem.ParsingError,
4158                 start, 
4159                 end, 
4160                 currentKind,
4161                 errorTokenSource, 
4162                 errorTokenName, 
4163                 expectedToken); 
4164 }
4165 public void parseErrorReplaceTokens(
4166         int start,
4167         int end,
4168         String expectedToken){
4169         String[] arguments = new String[] {expectedToken};
4170         this.handle(
4171                 IProblem.ParsingErrorReplaceTokens,
4172                 arguments,
4173                 arguments,
4174                 start,
4175                 end);
4176 }
4177 public void parseErrorUnexpectedEnd(
4178         int start,
4179         int end){
4180                 
4181         String[] arguments;
4182         if(this.referenceContext instanceof ConstructorDeclaration) {
4183                 arguments = new String[] {Util.bind("parser.endOfConstructor")}; //$NON-NLS-1$
4184         } else if(this.referenceContext instanceof MethodDeclaration) {
4185                 arguments = new String[] {Util.bind("parser.endOfMethod")}; //$NON-NLS-1$
4186         } else if(this.referenceContext instanceof TypeDeclaration) {
4187                 arguments = new String[] {Util.bind("parser.endOfInitializer")}; //$NON-NLS-1$
4188         } else {
4189                 arguments = new String[] {Util.bind("parser.endOfFile")}; //$NON-NLS-1$
4190         }
4191         this.handle(
4192                 IProblem.ParsingErrorUnexpectedEOF,
4193                 arguments,
4194                 arguments,
4195                 start,
4196                 end);
4197 }
4198 public void possibleAccidentalBooleanAssignment(Assignment assignment) {
4199         this.handle(
4200                 IProblem.PossibleAccidentalBooleanAssignment,
4201                 NoArgument,
4202                 NoArgument,
4203                 assignment.sourceStart,
4204                 assignment.sourceEnd);
4205 }
4206 public void publicClassMustMatchFileName(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
4207         this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
4208         String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
4209         this.handle(
4210                 IProblem.PublicClassMustMatchFileName,
4211                 arguments,
4212                 arguments,
4213                 typeDecl.sourceStart,
4214                 typeDecl.sourceEnd,
4215                 compUnitDecl.compilationResult);
4216 }
4217 public void rawMemberTypeCannotBeParameterized(ASTNode location, ReferenceBinding type, TypeBinding[] argumentTypes) {
4218         if (location == null) { // binary case
4219             this.handle(
4220                         IProblem.RawMemberTypeCannotBeParameterized,
4221                         new String[] {new String(type.readableName()), typesAsString(false, argumentTypes, false), new String(type.enclosingType().readableName())},
4222                         new String[] {new String(type.shortReadableName()), typesAsString(false, argumentTypes, true), new String(type.enclosingType().shortReadableName())},
4223                         AbortCompilation | Error,
4224                         0,
4225                         1);
4226             return;
4227         }
4228     this.handle(
4229                 IProblem.RawMemberTypeCannotBeParameterized,
4230                 new String[] {new String(type.readableName()), typesAsString(false, argumentTypes, false), new String(type.enclosingType().readableName())},
4231                 new String[] {new String(type.shortReadableName()), typesAsString(false, argumentTypes, true), new String(type.enclosingType().shortReadableName())},
4232                 location.sourceStart,
4233                 location.sourceEnd);
4234 }
4235 public void recursiveConstructorInvocation(ExplicitConstructorCall constructorCall) {
4236
4237         this.handle(
4238                 IProblem.RecursiveConstructorInvocation,
4239                 new String[] {
4240                         new String(constructorCall.binding.declaringClass.readableName()), 
4241                         typesAsString(constructorCall.binding.isVarargs(), constructorCall.binding.parameters, false)
4242                 },
4243                 new String[] {
4244                         new String(constructorCall.binding.declaringClass.shortReadableName()), 
4245                         typesAsString(constructorCall.binding.isVarargs(), constructorCall.binding.parameters, true)
4246                 },
4247                 constructorCall.sourceStart,
4248                 constructorCall.sourceEnd);
4249 }
4250
4251 public void redefineArgument(Argument arg) {
4252         String[] arguments = new String[] {new String(arg.name)};
4253         this.handle(
4254                 IProblem.RedefinedArgument,
4255                 arguments,
4256                 arguments,
4257                 arg.sourceStart,
4258                 arg.sourceEnd);
4259 }
4260 public void redefineLocal(LocalDeclaration localDecl) {
4261         String[] arguments = new String[] {new String(localDecl.name)};
4262         this.handle(
4263                 IProblem.RedefinedLocal,
4264                 arguments,
4265                 arguments,
4266                 localDecl.sourceStart,
4267                 localDecl.sourceEnd);
4268 }
4269 public void referenceMustBeArrayTypeAt(TypeBinding arrayType, ArrayReference arrayRef) {
4270         this.handle(
4271                 IProblem.ArrayReferenceRequired,
4272                 new String[] {new String(arrayType.readableName())},
4273                 new String[] {new String(arrayType.shortReadableName())},
4274                 arrayRef.sourceStart,
4275                 arrayRef.sourceEnd);
4276 }
4277 public void returnTypeCannotBeVoidArray(SourceTypeBinding type, MethodDeclaration methodDecl) {
4278         String[] arguments = new String[] {new String(methodDecl.selector)};
4279         this.handle(
4280                 IProblem.ReturnTypeCannotBeVoidArray,
4281                 arguments,
4282                 arguments,
4283                 methodDecl.sourceStart,
4284                 methodDecl.sourceEnd);
4285 }
4286
4287 public void scannerError(Parser parser, String errorTokenName) {
4288         Scanner scanner = parser.scanner;
4289
4290         int flag = IProblem.ParsingErrorNoSuggestion;
4291         int startPos = scanner.startPosition;
4292
4293         //special treatment for recognized errors....
4294         if (errorTokenName.equals(Scanner.END_OF_SOURCE))
4295                 flag = IProblem.EndOfSource;
4296         else if (errorTokenName.equals(Scanner.INVALID_HEXA))
4297                 flag = IProblem.InvalidHexa;
4298         else if (errorTokenName.equals(Scanner.INVALID_OCTAL))
4299                 flag = IProblem.InvalidOctal;
4300         else if (errorTokenName.equals(Scanner.INVALID_CHARACTER_CONSTANT))
4301                 flag = IProblem.InvalidCharacterConstant;
4302         else if (errorTokenName.equals(Scanner.INVALID_ESCAPE))
4303                 flag = IProblem.InvalidEscape;
4304         else if (errorTokenName.equals(Scanner.INVALID_UNICODE_ESCAPE)){
4305                 flag = IProblem.InvalidUnicodeEscape;
4306                 // better locate the error message
4307                 char[] source = scanner.source;
4308                 int checkPos = scanner.currentPosition - 1;
4309                 if (checkPos >= source.length) checkPos = source.length - 1;
4310                 while (checkPos >= startPos){
4311                         if (source[checkPos] == '\\') break;
4312                         checkPos --;
4313                 }
4314                 startPos = checkPos;
4315         } else if (errorTokenName.equals(Scanner.INVALID_FLOAT))
4316                 flag = IProblem.InvalidFloat;
4317         else if (errorTokenName.equals(Scanner.UNTERMINATED_STRING))
4318                 flag = IProblem.UnterminatedString;
4319         else if (errorTokenName.equals(Scanner.UNTERMINATED_COMMENT))
4320                 flag = IProblem.UnterminatedComment;
4321         else if (errorTokenName.equals(Scanner.INVALID_CHAR_IN_STRING))
4322                 flag = IProblem.UnterminatedString;
4323         else if (errorTokenName.equals(Scanner.INVALID_DIGIT))
4324                 flag = IProblem.InvalidDigit;
4325
4326         String[] arguments = flag == IProblem.ParsingErrorNoSuggestion 
4327                         ? new String[] {errorTokenName}
4328                         : NoArgument;
4329         this.handle(
4330                 flag, 
4331                 arguments,
4332                 arguments,
4333                 // this is the current -invalid- token position
4334                 startPos, 
4335                 scanner.currentPosition - 1,
4336                 parser.compilationUnit.compilationResult);
4337 }
4338 public void shouldReturn(TypeBinding returnType, ASTNode location) {
4339         this.handle(
4340                 IProblem.ShouldReturnValue,
4341                 new String[] { new String (returnType.readableName())},
4342                 new String[] { new String (returnType.shortReadableName())},
4343                 location.sourceStart,
4344                 location.sourceEnd);
4345 }
4346 public void signalNoImplicitStringConversionForCharArrayExpression(Expression expression) {
4347         this.handle(
4348                 IProblem.NoImplicitStringConversionForCharArrayExpression,
4349                 NoArgument,
4350                 NoArgument,
4351                 expression.sourceStart,
4352                 expression.sourceEnd);
4353 }
4354 public void staticAndInstanceConflict(MethodBinding currentMethod, MethodBinding inheritedMethod) {
4355         if (currentMethod.isStatic())
4356                 this.handle(
4357                         // This static method cannot hide the instance method from %1
4358                         // 8.4.6.4 - If a class inherits more than one method with the same signature a static (non-abstract) method cannot hide an instance method.
4359                         IProblem.CannotHideAnInstanceMethodWithAStaticMethod,
4360                         new String[] {new String(inheritedMethod.declaringClass.readableName())},
4361                         new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
4362                         currentMethod.sourceStart(),
4363                         currentMethod.sourceEnd());
4364         else
4365                 this.handle(
4366                         // This instance method cannot override the static method from %1
4367                         // 8.4.6.4 - If a class inherits more than one method with the same signature an instance (non-abstract) method cannot override a static method.
4368                         IProblem.CannotOverrideAStaticMethodWithAnInstanceMethod,
4369                         new String[] {new String(inheritedMethod.declaringClass.readableName())},
4370                         new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
4371                         currentMethod.sourceStart(),
4372                         currentMethod.sourceEnd());
4373 }
4374 public void staticFieldAccessToNonStaticVariable(ASTNode location, FieldBinding field) {
4375         String[] arguments = new String[] {new String(field.readableName())};
4376         this.handle(
4377                 IProblem.NonStaticFieldFromStaticInvocation,
4378                 arguments,
4379                 arguments,
4380                 location.sourceStart,
4381                 fieldLocation(field, location)); 
4382 }
4383 public void staticInheritedMethodConflicts(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
4384         this.handle(
4385                 // The static method %1 conflicts with the abstract method in %2
4386                 // 8.4.6.4 - If a class inherits more than one method with the same signature it is an error for one to be static (non-abstract) and the other abstract.
4387                 IProblem.StaticInheritedMethodConflicts,
4388                 new String[] {
4389                         new String(concreteMethod.readableName()),
4390                         new String(abstractMethods[0].declaringClass.readableName())},
4391                 new String[] {
4392                         new String(concreteMethod.readableName()),
4393                         new String(abstractMethods[0].declaringClass.shortReadableName())},
4394                 type.sourceStart(),
4395                 type.sourceEnd());
4396 }
4397 public void staticMemberOfParameterizedType(ASTNode location, ReferenceBinding type) {
4398         if (location == null) { // binary case
4399             this.handle(
4400                         IProblem.StaticMemberOfParameterizedType,
4401                         new String[] {new String(type.readableName()), new String(type.enclosingType().readableName()), },
4402                         new String[] {new String(type.shortReadableName()), new String(type.enclosingType().shortReadableName()), },
4403                         AbortCompilation | Error,
4404                         0,
4405                         1);
4406             return;
4407         }
4408     this.handle(
4409                 IProblem.StaticMemberOfParameterizedType,
4410                 new String[] {new String(type.readableName()), new String(type.enclosingType().readableName()), },
4411                 new String[] {new String(type.shortReadableName()), new String(type.enclosingType().shortReadableName()), },
4412                 location.sourceStart,
4413                 location.sourceEnd);
4414 }
4415 public void stringConstantIsExceedingUtf8Limit(ASTNode location) {
4416         this.handle(
4417                 IProblem.StringConstantIsExceedingUtf8Limit,
4418                 NoArgument,
4419                 NoArgument,
4420                 location.sourceStart,
4421                 location.sourceEnd);
4422 }
4423 public void superclassMustBeAClass(SourceTypeBinding type, TypeReference superclassRef, ReferenceBinding superType) {
4424         this.handle(
4425                 IProblem.SuperclassMustBeAClass,
4426                 new String[] {new String(superType.readableName()), new String(type.sourceName())},
4427                 new String[] {new String(superType.shortReadableName()), new String(type.sourceName())},
4428                 superclassRef.sourceStart,
4429                 superclassRef.sourceEnd);
4430 }
4431 public void superfluousSemicolon(int sourceStart, int sourceEnd) {
4432         this.handle(
4433                 IProblem.SuperfluousSemicolon,
4434                 NoArgument,
4435                 NoArgument,
4436                 sourceStart,
4437                 sourceEnd);     
4438 }
4439 public void superinterfaceMustBeAnInterface(SourceTypeBinding type, TypeReference superInterfaceRef, ReferenceBinding superType) {
4440         this.handle(
4441                 IProblem.SuperInterfaceMustBeAnInterface,
4442                 new String[] {new String(superType.readableName()), new String(type.sourceName())},
4443                 new String[] {new String(superType.shortReadableName()), new String(type.sourceName())},
4444                 superInterfaceRef.sourceStart,
4445                 superInterfaceRef.sourceEnd);
4446 }
4447 public void superinterfacesCollide(ReferenceBinding type, TypeDeclaration typeDecl, ReferenceBinding superType, ReferenceBinding inheritedSuperType) {
4448         this.handle(
4449                 IProblem.SuperInterfacesCollide,
4450                 new String[] {new String(superType.readableName()), new String(inheritedSuperType.readableName()), new String(type.sourceName())},
4451                 new String[] {new String(superType.shortReadableName()), new String(inheritedSuperType.shortReadableName()), new String(type.sourceName())},
4452                 typeDecl.sourceStart,
4453                 typeDecl.sourceEnd);
4454 }
4455 public void superTypeCannotUseWildcard(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) {
4456         String name = new String(type.sourceName());
4457         String superTypeFullName = new String(superTypeBinding.readableName());
4458         String superTypeShortName = new String(superTypeBinding.shortReadableName());
4459         if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName;
4460         this.handle(
4461                 IProblem.SuperTypeUsingWildcard,
4462                 new String[] {superTypeFullName, name},
4463                 new String[] {superTypeShortName, name},
4464                 superclass.sourceStart,
4465                 superclass.sourceEnd);
4466 }
4467
4468 private void syntaxError(
4469         int id,
4470         int startPosition, 
4471         int endPosition, 
4472         int currentKind,
4473         char[] currentTokenSource, 
4474         String errorTokenName, 
4475         String expectedToken) {
4476
4477         String eTokenName;
4478         if (isKeyword(currentKind) ||
4479                 isLiteral(currentKind) ||
4480                 isIdentifier(currentKind)) { //$NON-NLS-1$
4481                         eTokenName = new String(currentTokenSource);
4482         } else {
4483                 eTokenName = errorTokenName;
4484         }
4485
4486         String[] arguments;
4487         if(expectedToken != null) {
4488                 arguments = new String[] {eTokenName, expectedToken};
4489         } else {
4490                 arguments = new String[] {eTokenName};
4491         }
4492         this.handle(
4493                 id,
4494                 arguments,
4495                 arguments,
4496                 startPosition,
4497                 endPosition);
4498 }
4499
4500 public void task(String tag, String message, String priority, int start, int end){
4501         this.handle(
4502                 IProblem.Task,
4503                 new String[] { tag, message, priority/*secret argument that is not surfaced in getMessage()*/},
4504                 new String[] { tag, message, priority/*secret argument that is not surfaced in getMessage()*/}, 
4505                 start,
4506                 end);
4507 }
4508 public void tooManyDimensions(ASTNode expression) {
4509         this.handle(
4510                 IProblem.TooManyArrayDimensions,
4511                 NoArgument,
4512                 NoArgument,
4513                 expression.sourceStart,
4514                 expression.sourceEnd);
4515 }
4516 public void tooManyFields(TypeDeclaration typeDeclaration) {
4517         this.handle(
4518                 IProblem.TooManyFields,
4519                 new String[]{ new String(typeDeclaration.binding.readableName())},
4520                 new String[]{ new String(typeDeclaration.binding.shortReadableName())},
4521                 Abort | Error,
4522                 typeDeclaration.sourceStart,
4523                 typeDeclaration.sourceEnd);
4524 }
4525 public void tooManyMethods(TypeDeclaration typeDeclaration) {
4526         this.handle(
4527                 IProblem.TooManyMethods,
4528                 new String[]{ new String(typeDeclaration.binding.readableName())},
4529                 new String[]{ new String(typeDeclaration.binding.shortReadableName())},
4530                 Abort | Error,
4531                 typeDeclaration.sourceStart,
4532                 typeDeclaration.sourceEnd);
4533 }
4534 public void typeCastError(CastExpression expression, TypeBinding leftType, TypeBinding rightType) {
4535         String leftName = new String(leftType.readableName());
4536         String rightName = new String(rightType.readableName());
4537         String leftShortName = new String(leftType.shortReadableName());
4538         String rightShortName = new String(rightType.shortReadableName());
4539         if (leftShortName.equals(rightShortName)){
4540                 leftShortName = leftName;
4541                 rightShortName = rightName;
4542         }
4543         this.handle(
4544                 IProblem.IllegalCast,
4545                 new String[] { rightName, leftName },
4546                 new String[] { rightShortName, leftShortName },
4547                 expression.sourceStart,
4548                 expression.sourceEnd);
4549 }
4550 public void typeCollidesWithPackage(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
4551         this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
4552         String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
4553         this.handle(
4554                 IProblem.TypeCollidesWithPackage,
4555                 arguments,
4556                 arguments,
4557                 typeDecl.sourceStart,
4558                 typeDecl.sourceEnd,
4559                 compUnitDecl.compilationResult);
4560 }
4561 public void typeMismatchError(TypeBinding actualType, TypeBinding expectedType, ASTNode location) {
4562         this.handle(
4563                 IProblem.TypeMismatch,
4564                 new String[] {new String(actualType.readableName()), new String(expectedType.readableName())},
4565                 new String[] {new String(actualType.shortReadableName()), new String(expectedType.shortReadableName())},
4566                 location.sourceStart,
4567                 location.sourceEnd);
4568 }
4569 public void typeMismatchError(TypeBinding typeArgument, TypeVariableBinding typeParameter, ReferenceBinding genericType, ASTNode location) {
4570     if (location == null) { // binary case
4571                 this.handle(
4572                         IProblem.TypeArgumentMismatch,
4573                         new String[] { new String(typeArgument.readableName()), new String(genericType.readableName()), new String(typeParameter.sourceName), parameterBoundAsString(typeParameter, false) },
4574                         new String[] { new String(typeArgument.shortReadableName()), new String(genericType.shortReadableName()), new String(typeParameter.sourceName), parameterBoundAsString(typeParameter, true) },
4575                         AbortCompilation | Error,
4576                         0,
4577                         1);
4578         return;
4579     }
4580         this.handle(
4581                 IProblem.TypeArgumentMismatch,
4582                 new String[] { new String(typeArgument.readableName()), new String(genericType.readableName()), new String(typeParameter.sourceName), parameterBoundAsString(typeParameter, false) },
4583                 new String[] { new String(typeArgument.shortReadableName()), new String(genericType.shortReadableName()), new String(typeParameter.sourceName), parameterBoundAsString(typeParameter, true) },
4584                 location.sourceStart,
4585                 location.sourceEnd);
4586 }
4587 private String typesAsString(boolean isVarargs, TypeBinding[] types, boolean makeShort) {
4588         StringBuffer buffer = new StringBuffer(10);
4589         for (int i = 0, length = types.length; i < length; i++) {
4590                 if (i != 0)
4591                         buffer.append(", "); //$NON-NLS-1$
4592                 TypeBinding type = types[i];
4593                 boolean isVarargType = isVarargs && i == length-1;
4594                 if (isVarargType) type = ((ArrayBinding)type).elementsType();
4595                 buffer.append(new String(makeShort ? type.shortReadableName() : type.readableName()));
4596                 if (isVarargType) buffer.append("..."); //$NON-NLS-1$
4597         }
4598         return buffer.toString();
4599 }
4600 public void undefinedAnnotationValue(TypeBinding annotationType, MemberValuePair memberValuePair) {
4601         String name =   new String(memberValuePair.name);
4602         this.handle(
4603                 IProblem.UndefinedAnnotationMember,
4604                 new String[] { name, new String(annotationType.readableName())},
4605                 new String[] {  name, new String(annotationType.shortReadableName())},
4606                 memberValuePair.sourceStart,
4607                 memberValuePair.sourceEnd);
4608 }
4609 public void undefinedLabel(BranchStatement statement) {
4610         String[] arguments = new String[] {new String(statement.label)};
4611         this.handle(
4612                 IProblem.UndefinedLabel,
4613                 arguments,
4614                 arguments,
4615                 statement.sourceStart,
4616                 statement.sourceEnd);
4617 }
4618 // can only occur inside binaries
4619 public void undefinedTypeVariableSignature(char[] variableName, ReferenceBinding binaryType) {
4620         this.handle(
4621                 IProblem.UndefinedTypeVariable,
4622                 new String[] {new String(variableName), new String(binaryType.readableName()) },        
4623                 new String[] {new String(variableName), new String(binaryType.shortReadableName())},
4624                 AbortCompilation | Error,
4625                 0,
4626                 1);
4627 }
4628 public void undocumentedEmptyBlock(int blockStart, int blockEnd) {
4629         this.handle(
4630                 IProblem.UndocumentedEmptyBlock,
4631                 NoArgument,
4632                 NoArgument,
4633                 blockStart,
4634                 blockEnd);
4635 }
4636 public void unexpectedStaticModifierForField(SourceTypeBinding type, FieldDeclaration fieldDecl) {
4637         String[] arguments = new String[] {new String(fieldDecl.name)};
4638         this.handle(
4639                 IProblem.UnexpectedStaticModifierForField,
4640                 arguments,
4641                 arguments,
4642                 fieldDecl.sourceStart,
4643                 fieldDecl.sourceEnd);
4644 }
4645 public void unexpectedStaticModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
4646         String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
4647         this.handle(
4648                 IProblem.UnexpectedStaticModifierForMethod,
4649                 arguments,
4650                 arguments,
4651                 methodDecl.sourceStart,
4652                 methodDecl.sourceEnd);
4653 }
4654 public void unhandledException(TypeBinding exceptionType, ASTNode location) {
4655
4656         boolean insideDefaultConstructor = 
4657                 (this.referenceContext instanceof ConstructorDeclaration)
4658                         && ((ConstructorDeclaration)this.referenceContext).isDefaultConstructor();
4659         boolean insideImplicitConstructorCall =
4660                 (location instanceof ExplicitConstructorCall)
4661                         && (((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper);
4662
4663         this.handle(
4664                 insideDefaultConstructor
4665                         ? IProblem.UnhandledExceptionInDefaultConstructor
4666                         : (insideImplicitConstructorCall 
4667                                         ? IProblem.UndefinedConstructorInImplicitConstructorCall
4668                                         : IProblem.UnhandledException),
4669                 new String[] {new String(exceptionType.readableName())},
4670                 new String[] {new String(exceptionType.shortReadableName())},
4671                 location.sourceStart,
4672                 location.sourceEnd);
4673 }
4674 public void uninitializedBlankFinalField(FieldBinding binding, ASTNode location) {
4675         String[] arguments = new String[] {new String(binding.readableName())};
4676         this.handle(
4677                 IProblem.UninitializedBlankFinalField,
4678                 arguments,
4679                 arguments,
4680                 location.sourceStart,
4681                 fieldLocation(binding, location));
4682 }
4683 public void uninitializedLocalVariable(LocalVariableBinding binding, ASTNode location) {
4684         String[] arguments = new String[] {new String(binding.readableName())};
4685         this.handle(
4686                 IProblem.UninitializedLocalVariable,
4687                 arguments,
4688                 arguments,
4689                 location.sourceStart,
4690                 location.sourceEnd);
4691 }
4692 public void unmatchedBracket(int position, ReferenceContext context, CompilationResult compilationResult) {
4693         this.handle(
4694                 IProblem.UnmatchedBracket, 
4695                 NoArgument,
4696                 NoArgument,
4697                 position, 
4698                 position,
4699                 context,
4700                 compilationResult);
4701 }
4702 public void unnecessaryCast(CastExpression castExpression) {
4703         TypeBinding castedExpressionType = castExpression.expression.resolvedType;
4704         this.handle(
4705                 IProblem.UnnecessaryCast,
4706                 new String[]{ new String(castedExpressionType.readableName()), new String(castExpression.resolvedType.readableName())},
4707                 new String[]{ new String(castedExpressionType.shortReadableName()), new String(castExpression.resolvedType.shortReadableName())},
4708                 castExpression.sourceStart,
4709                 castExpression.sourceEnd);
4710 }
4711 public void unnecessaryCastForArgument(CastExpression castExpression, TypeBinding parameterType) {
4712         TypeBinding castedExpressionType = castExpression.expression.resolvedType;
4713         this.handle(
4714                 IProblem.UnnecessaryArgumentCast,
4715                 new String[]{ new String(castedExpressionType.readableName()), new String(castExpression.resolvedType.readableName()), new String(parameterType.readableName())},
4716                 new String[]{ new String(castedExpressionType.shortReadableName()), new String(castExpression.resolvedType.shortReadableName()), new String(parameterType.shortReadableName())},
4717                 castExpression.sourceStart,
4718                 castExpression.sourceEnd);
4719 }
4720 public void unnecessaryElse(ASTNode location) {
4721         this.handle(
4722                 IProblem.UnnecessaryElse,
4723                 NoArgument,
4724                 NoArgument,
4725                 location.sourceStart,
4726                 location.sourceEnd);
4727 }
4728 public void unnecessaryEnclosingInstanceSpecification(Expression expression, ReferenceBinding targetType) {
4729         this.handle(
4730                 IProblem.IllegalEnclosingInstanceSpecification,
4731                 new String[]{ new String(targetType.readableName())},
4732                 new String[]{ new String(targetType.shortReadableName())},
4733                 expression.sourceStart,
4734                 expression.sourceEnd);
4735 }
4736 public void unnecessaryInstanceof(InstanceOfExpression instanceofExpression, TypeBinding checkType) {
4737         TypeBinding expressionType = instanceofExpression.expression.resolvedType;
4738         this.handle(
4739                 IProblem.UnnecessaryInstanceof,
4740                 new String[]{ new String(expressionType.readableName()), new String(checkType.readableName())},
4741                 new String[]{ new String(expressionType.shortReadableName()), new String(checkType.shortReadableName())},
4742                 instanceofExpression.sourceStart,
4743                 instanceofExpression.sourceEnd);
4744 }
4745 public void unqualifiedFieldAccess(NameReference reference, FieldBinding field) {
4746         int end = reference.sourceEnd;
4747         if (reference instanceof QualifiedNameReference) {
4748                 QualifiedNameReference qref = (QualifiedNameReference) reference;
4749                 end = (int) qref.sourcePositions[0];
4750         }
4751         this.handle(
4752                 IProblem.UnqualifiedFieldAccess,
4753                 new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
4754                 new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
4755                 reference.sourceStart,
4756                 end);
4757 }
4758 public void unreachableCatchBlock(ReferenceBinding exceptionType, ASTNode location) {
4759         this.handle(
4760                 IProblem.UnreachableCatch,
4761                 new String[] {
4762                         new String(exceptionType.readableName()),
4763                  }, 
4764                 new String[] {
4765                         new String(exceptionType.shortReadableName()),
4766                  }, 
4767                 location.sourceStart,
4768                 location.sourceEnd);
4769 }
4770 public void unreachableCode(Statement statement) {
4771         this.handle(
4772                 IProblem.CodeCannotBeReached,
4773                 NoArgument,
4774                 NoArgument,
4775                 statement.sourceStart,
4776                 statement.sourceEnd);
4777 }
4778 public void unresolvableReference(NameReference nameRef, Binding binding) {
4779         int severity = Error;
4780 /* also need to check that the searchedType is the receiver type
4781         if (binding instanceof ProblemBinding) {
4782                 ProblemBinding problem = (ProblemBinding) binding;
4783                 if (problem.searchType != null && problem.searchType.isHierarchyInconsistent())
4784                         severity = SecondaryError;
4785         }
4786 */
4787         String[] arguments = new String[] {new String(binding.readableName())};
4788         int end = nameRef.sourceEnd;
4789         if (nameRef instanceof QualifiedNameReference) {
4790                 QualifiedNameReference ref = (QualifiedNameReference) nameRef;
4791                 if (ref.indexOfFirstFieldBinding >= 1)
4792                         end = (int) ref.sourcePositions[ref.indexOfFirstFieldBinding - 1];
4793         }
4794         this.handle(
4795                 IProblem.UndefinedName,
4796                 arguments,
4797                 arguments,
4798                 severity,
4799                 nameRef.sourceStart,
4800                 end);
4801 }
4802 public void unsafeCast(CastExpression castExpression) {
4803         TypeBinding castedExpressionType = castExpression.expression.resolvedType;
4804         this.handle(
4805                 IProblem.UnsafeGenericCast,
4806                 new String[]{ new String(castedExpressionType.readableName()), new String(castExpression.resolvedType.readableName())},
4807                 new String[]{ new String(castedExpressionType.shortReadableName()), new String(castExpression.resolvedType.shortReadableName())},
4808                 castExpression.sourceStart,
4809                 castExpression.sourceEnd);
4810 }
4811 public void unsafeRawConversion(Expression expression, TypeBinding expressionType, TypeBinding expectedType) {
4812         this.handle(
4813                 IProblem.UnsafeRawConversion,
4814                 new String[] { new String(expressionType.readableName()), new String(expectedType.readableName()), new String(expectedType.erasure().readableName()) },
4815                 new String[] { new String(expressionType.shortReadableName()), new String(expectedType.shortReadableName()), new String(expectedType.erasure().shortReadableName()) },
4816                 expression.sourceStart,
4817                 expression.sourceEnd);    
4818 }
4819 public void unsafeRawFieldAssignment(FieldBinding rawField, TypeBinding expressionType, ASTNode location) {
4820         this.handle(
4821                 IProblem.UnsafeRawFieldAssignment,
4822                 new String[] { 
4823                         new String(expressionType.readableName()), new String(rawField.name), new String(rawField.declaringClass.readableName()), new String(rawField.declaringClass.erasure().readableName()) },
4824                 new String[] { 
4825                         new String(expressionType.shortReadableName()), new String(rawField.name), new String(rawField.declaringClass.shortReadableName()), new String(rawField.declaringClass.erasure().shortReadableName()) },
4826                 location.sourceStart,
4827                 location.sourceEnd);    
4828 }
4829 public void unsafeRawInvocation(ASTNode location, MethodBinding rawMethod) {
4830     if (rawMethod.isConstructor()) {
4831                 this.handle(
4832                         IProblem.UnsafeRawConstructorInvocation,
4833                         new String[] {
4834                                 new String(rawMethod.declaringClass.readableName()),
4835                                 typesAsString(rawMethod.original().isVarargs(), rawMethod.parameters, false),
4836                                 new String(rawMethod.declaringClass.erasure().readableName()),
4837                          }, 
4838                         new String[] {
4839                                 new String(rawMethod.declaringClass.shortReadableName()),
4840                                 typesAsString(rawMethod.original().isVarargs(), rawMethod.parameters, true),
4841                                 new String(rawMethod.declaringClass.erasure().shortReadableName()),
4842                          }, 
4843                         location.sourceStart,
4844                         location.sourceEnd);    
4845     } else {
4846                 this.handle(
4847                         IProblem.UnsafeRawMethodInvocation,
4848                         new String[] {
4849                                 new String(rawMethod.selector),
4850                                 typesAsString(rawMethod.original().isVarargs(), rawMethod.parameters, false),
4851                                 new String(rawMethod.declaringClass.readableName()),
4852                                 new String(rawMethod.declaringClass.erasure().readableName()),
4853                          }, 
4854                         new String[] {
4855                                 new String(rawMethod.selector),
4856                                 typesAsString(rawMethod.original().isVarargs(), rawMethod.parameters, true),
4857                                 new String(rawMethod.declaringClass.shortReadableName()),
4858                                 new String(rawMethod.declaringClass.erasure().shortReadableName()),
4859                          }, 
4860                         location.sourceStart,
4861                         location.sourceEnd);    
4862     }
4863 }
4864 public void unsafeReturnTypeOverride(MethodBinding currentMethod, MethodBinding inheritedMethod, ASTNode location) {
4865         
4866         this.handle(
4867                         IProblem.UnsafeReturnTypeOverride,
4868                         new String[] {
4869                                 new String(currentMethod.returnType.readableName()),
4870                                 new String(currentMethod.selector),
4871                                 typesAsString(currentMethod.original().isVarargs(), currentMethod.original().parameters, false),
4872                                 new String(currentMethod.declaringClass.readableName()),
4873                                 new String(inheritedMethod.returnType.readableName()),
4874                                 //new String(inheritedMethod.returnType.erasure().readableName()),
4875                          }, 
4876                         new String[] {
4877                                 new String(currentMethod.returnType.shortReadableName()),
4878                                 new String(currentMethod.selector),
4879                                 typesAsString(currentMethod.original().isVarargs(), currentMethod.original().parameters, true),
4880                                 new String(currentMethod.declaringClass.shortReadableName()),
4881                                 new String(inheritedMethod.returnType.shortReadableName()),
4882                                 //new String(inheritedMethod.returnType.erasure().shortReadableName()),
4883                          }, 
4884                         location.sourceStart,
4885                         location.sourceEnd);
4886 }
4887 public void unusedArgument(LocalDeclaration localDecl) {
4888
4889         String[] arguments = new String[] {new String(localDecl.name)};
4890         this.handle(
4891                 IProblem.ArgumentIsNeverUsed,
4892                 arguments,
4893                 arguments,
4894                 localDecl.sourceStart,
4895                 localDecl.sourceEnd);
4896 }
4897 public void unusedDeclaredThrownException(ReferenceBinding exceptionType, AbstractMethodDeclaration method, ASTNode location) {
4898         if (method.isConstructor()) {
4899                 this.handle(
4900                         IProblem.UnusedConstructorDeclaredThrownException,
4901                         new String[] {
4902                                 new String(method.binding.declaringClass.readableName()),
4903                                 typesAsString(method.binding.isVarargs(), method.binding.parameters, false),
4904                                 new String(exceptionType.readableName()),
4905                          }, 
4906                         new String[] {
4907                                 new String(method.binding.declaringClass.shortReadableName()),
4908                                 typesAsString(method.binding.isVarargs(), method.binding.parameters, true),
4909                                 new String(exceptionType.shortReadableName()),
4910                          }, 
4911                         location.sourceStart,
4912                         location.sourceEnd);
4913         } else {
4914                 this.handle(
4915                         IProblem.UnusedMethodDeclaredThrownException,
4916                         new String[] {
4917                                 new String(method.binding.declaringClass.readableName()),
4918                                 new String(method.selector),
4919                                 typesAsString(method.binding.isVarargs(), method.binding.parameters, false),
4920                                 new String(exceptionType.readableName()),
4921                          }, 
4922                         new String[] {
4923                                 new String(method.binding.declaringClass.shortReadableName()),
4924                                 new String(method.selector),
4925                                 typesAsString(method.binding.isVarargs(), method.binding.parameters, true),
4926                                 new String(exceptionType.shortReadableName()),
4927                          }, 
4928                         location.sourceStart,
4929                         location.sourceEnd);
4930         }
4931 }
4932 public void unusedImport(ImportReference importRef) {
4933         String[] arguments = new String[] { CharOperation.toString(importRef.tokens) };
4934         this.handle(
4935                 IProblem.UnusedImport,
4936                 arguments,
4937                 arguments,
4938                 importRef.sourceStart,
4939                 importRef.sourceEnd); 
4940 }
4941 public void unusedLocalVariable(LocalDeclaration localDecl) {
4942         String[] arguments = new String[] {new String(localDecl.name)};
4943         this.handle(
4944                 IProblem.LocalVariableIsNeverUsed,
4945                 arguments,
4946                 arguments,
4947                 localDecl.sourceStart,
4948                 localDecl.sourceEnd);
4949 }
4950 public void unusedPrivateConstructor(ConstructorDeclaration constructorDecl) {
4951         
4952         if (computeSeverity(IProblem.UnusedPrivateConstructor) == Ignore) return;
4953
4954         // no complaint for no-arg constructors (or default ones) - known pattern to block instantiation
4955         if (constructorDecl.arguments == null || constructorDecl.arguments.length == 0) return;
4956                                         
4957         MethodBinding constructor = constructorDecl.binding;
4958         this.handle(
4959                         IProblem.UnusedPrivateConstructor,
4960                 new String[] {
4961                         new String(constructor.declaringClass.readableName()),
4962                         typesAsString(constructor.isVarargs(), constructor.parameters, false)
4963                  }, 
4964                 new String[] {
4965                         new String(constructor.declaringClass.shortReadableName()),
4966                         typesAsString(constructor.isVarargs(), constructor.parameters, true)
4967                  }, 
4968                 constructorDecl.sourceStart,
4969                 constructorDecl.sourceEnd);
4970 }
4971 public void unusedPrivateField(FieldDeclaration fieldDecl) {
4972         
4973         if (computeSeverity(IProblem.UnusedPrivateField) == Ignore) return;
4974
4975         FieldBinding field = fieldDecl.binding;
4976         
4977         if (CharOperation.equals(TypeConstants.SERIALVERSIONUID, field.name)
4978                         && field.isStatic()
4979                         && field.isFinal()
4980                         && BaseTypes.LongBinding == field.type) {
4981                                 return; // do not report unused serialVersionUID field
4982         }
4983         if (CharOperation.equals(TypeConstants.SERIALPERSISTENTFIELDS, field.name)
4984                         && field.isStatic()
4985                         && field.isFinal()
4986                         && field.type.dimensions() == 1
4987                         && CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTSTREAMFIELD, field.type.leafComponentType().readableName())) {
4988                                 return; // do not report unused serialPersistentFields field
4989         }
4990         this.handle(
4991                         IProblem.UnusedPrivateField,
4992                 new String[] {
4993                         new String(field.declaringClass.readableName()),
4994                         new String(field.name),
4995                  }, 
4996                 new String[] {
4997                         new String(field.declaringClass.shortReadableName()),
4998                         new String(field.name),
4999                  }, 
5000                 fieldDecl.sourceStart,
5001                 fieldDecl.sourceEnd);
5002 }
5003 public void unusedPrivateMethod(AbstractMethodDeclaration methodDecl) {
5004
5005         if (computeSeverity(IProblem.UnusedPrivateMethod) == Ignore) return;
5006         
5007         MethodBinding method = methodDecl.binding;
5008         
5009         // no report for serialization support 'void readObject(ObjectInputStream)'
5010         if (!method.isStatic()
5011                         && BaseTypes.VoidBinding == method.returnType
5012                         && method.parameters.length == 1
5013                         && method.parameters[0].dimensions() == 0
5014                         && CharOperation.equals(method.selector, TypeConstants.READOBJECT)
5015                         && CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTINPUTSTREAM, method.parameters[0].readableName())) {
5016                 return;
5017         }
5018         // no report for serialization support 'void writeObject(ObjectOutputStream)'
5019         if (!method.isStatic()
5020                         && BaseTypes.VoidBinding == method.returnType
5021                         && method.parameters.length == 1
5022                         && method.parameters[0].dimensions() == 0
5023                         && CharOperation.equals(method.selector, TypeConstants.WRITEOBJECT)
5024                         && CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTOUTPUTSTREAM, method.parameters[0].readableName())) {
5025                 return;
5026         }
5027         // no report for serialization support 'Object readResolve()'
5028         if (!method.isStatic()
5029                         && TypeIds.T_JavaLangObject == method.returnType.id
5030                         && method.parameters.length == 0
5031                         && CharOperation.equals(method.selector, TypeConstants.READRESOLVE)) {
5032                 return;
5033         }
5034         // no report for serialization support 'Object writeReplace()'
5035         if (!method.isStatic()
5036                         && TypeIds.T_JavaLangObject == method.returnType.id
5037                         && method.parameters.length == 0
5038                         && CharOperation.equals(method.selector, TypeConstants.WRITEREPLACE)) {
5039                 return;
5040         }
5041         this.handle(
5042                         IProblem.UnusedPrivateMethod,
5043                 new String[] {
5044                         new String(method.declaringClass.readableName()),
5045                         new String(method.selector),
5046                         typesAsString(method.isVarargs(), method.parameters, false)
5047                  }, 
5048                 new String[] {
5049                         new String(method.declaringClass.shortReadableName()),
5050                         new String(method.selector),
5051                         typesAsString(method.isVarargs(), method.parameters, true)
5052                  }, 
5053                 methodDecl.sourceStart,
5054                 methodDecl.sourceEnd);
5055 }
5056 public void unusedPrivateType(TypeDeclaration typeDecl) {
5057         
5058         if (computeSeverity(IProblem.UnusedPrivateType) == Ignore) return;
5059
5060         ReferenceBinding type = typeDecl.binding;
5061         this.handle(
5062                         IProblem.UnusedPrivateType,
5063                 new String[] {
5064                         new String(type.readableName()),
5065                  }, 
5066                 new String[] {
5067                         new String(type.shortReadableName()),
5068                  }, 
5069                 typeDecl.sourceStart,
5070                 typeDecl.sourceEnd);
5071 }
5072 public void useAssertAsAnIdentifier(int sourceStart, int sourceEnd) {
5073         this.handle(
5074                 IProblem.UseAssertAsAnIdentifier,
5075                 NoArgument,
5076                 NoArgument,
5077                 sourceStart,
5078                 sourceEnd);     
5079 }
5080 public void useEnumAsAnIdentifier(int sourceStart, int sourceEnd) {
5081         this.handle(
5082                 IProblem.UseEnumAsAnIdentifier,
5083                 NoArgument,
5084                 NoArgument,
5085                 sourceStart,
5086                 sourceEnd);     
5087 }
5088 public void varargsArgumentNeedCast(MethodBinding method, TypeBinding argumentType, InvocationSite location) {
5089         TypeBinding lastParam = method.parameters[method.parameters.length-1];
5090         if (method.isConstructor()) {
5091                 this.handle(
5092                         IProblem.ConstructorVarargsArgumentNeedCast,
5093                         new String[] {new String(argumentType.readableName()), new String(lastParam.readableName()), new String(method.declaringClass.readableName()), typesAsString(method.isVarargs(), method.parameters, false), },
5094                         new String[] {new String(argumentType.shortReadableName()), new String(lastParam.shortReadableName()), new String(method.declaringClass.shortReadableName()), typesAsString(method.isVarargs(), method.parameters, true), },
5095                         location.sourceStart(),
5096                         location.sourceEnd());
5097         } else {
5098                 this.handle(
5099                         IProblem.MethodVarargsArgumentNeedCast,
5100                         new String[] { new String(argumentType.readableName()), new String(lastParam.readableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, false), new String(method.declaringClass.readableName()), },
5101                         new String[] { new String(argumentType.shortReadableName()), new String(lastParam.shortReadableName()), new String(method.selector), typesAsString(method.isVarargs(), method.parameters, true), new String(method.declaringClass.shortReadableName()), },
5102                         location.sourceStart(),
5103                         location.sourceEnd());
5104         }
5105 }
5106 public void variableTypeCannotBeVoid(AbstractVariableDeclaration varDecl) {
5107         String[] arguments = new String[] {new String(varDecl.name)};
5108         this.handle(
5109                 IProblem.VariableTypeCannotBeVoid,
5110                 arguments,
5111                 arguments,
5112                 varDecl.sourceStart,
5113                 varDecl.sourceEnd);
5114 }
5115 public void variableTypeCannotBeVoidArray(AbstractVariableDeclaration varDecl) {
5116         String[] arguments = new String[] {new String(varDecl.name)};
5117         this.handle(
5118                 IProblem.VariableTypeCannotBeVoidArray,
5119                 arguments,
5120                 arguments,
5121                 varDecl.sourceStart,
5122                 varDecl.sourceEnd);
5123 }
5124 public void visibilityConflict(MethodBinding currentMethod, MethodBinding inheritedMethod) {
5125         this.handle(
5126                 //      Cannot reduce the visibility of the inherited method from %1
5127                 // 8.4.6.3 - The access modifier of an hiding method must provide at least as much access as the hidden method.
5128                 // 8.4.6.3 - The access modifier of an overiding method must provide at least as much access as the overriden method.
5129                 IProblem.MethodReducesVisibility,
5130                 new String[] {new String(inheritedMethod.declaringClass.readableName())},
5131                 new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
5132                 currentMethod.sourceStart(),
5133                 currentMethod.sourceEnd());
5134 }
5135 public void wildcardAssignment(TypeBinding variableType, TypeBinding expressionType, ASTNode location) {
5136         this.handle(
5137                 IProblem.WildcardFieldAssignment,
5138                 new String[] { 
5139                         new String(expressionType.readableName()), new String(variableType.readableName()) },
5140                 new String[] { 
5141                         new String(expressionType.shortReadableName()), new String(variableType.shortReadableName()) },
5142                 location.sourceStart,
5143                 location.sourceEnd);    
5144 }
5145 public void wildcardInvocation(ASTNode location, TypeBinding receiverType, MethodBinding method, TypeBinding[] arguments) {
5146         TypeBinding offendingArgument = null;
5147         TypeBinding offendingParameter = null;
5148         for (int i = 0, length = method.parameters.length; i < length; i++) {
5149                 TypeBinding parameter = method.parameters[i];
5150                 if (parameter.isWildcard() && (((WildcardBinding) parameter).kind != Wildcard.SUPER)) {
5151                         offendingParameter = parameter;
5152                         offendingArgument = arguments[i];
5153                         break;
5154                 }
5155         }
5156         
5157     if (method.isConstructor()) {
5158                 this.handle(
5159                         IProblem.WildcardConstructorInvocation,
5160                         new String[] {
5161                                 new String(receiverType.sourceName()),
5162                                 typesAsString(method.isVarargs(), method.parameters, false),
5163                                 new String(receiverType.readableName()),
5164                                 typesAsString(false, arguments, false),
5165                                 new String(offendingArgument.readableName()),
5166                                 new String(offendingParameter.readableName()),
5167                          }, 
5168                         new String[] {
5169                                 new String(receiverType.sourceName()),
5170                                 typesAsString(method.isVarargs(), method.parameters, true),
5171                                 new String(receiverType.shortReadableName()),
5172                                 typesAsString(false, arguments, true),
5173                                 new String(offendingArgument.shortReadableName()),
5174                                 new String(offendingParameter.shortReadableName()),
5175                          }, 
5176                         location.sourceStart,
5177                         location.sourceEnd);    
5178     } else {
5179                 this.handle(
5180                         IProblem.WildcardMethodInvocation,
5181                         new String[] {
5182                                 new String(method.selector),
5183                                 typesAsString(method.isVarargs(), method.parameters, false),
5184                                 new String(receiverType.readableName()),
5185                                 typesAsString(false, arguments, false),
5186                                 new String(offendingArgument.readableName()),
5187                                 new String(offendingParameter.readableName()),
5188                          }, 
5189                         new String[] {
5190                                 new String(method.selector),
5191                                 typesAsString(method.isVarargs(), method.parameters, true),
5192                                 new String(receiverType.shortReadableName()),
5193                                 typesAsString(false, arguments, true),
5194                                 new String(offendingArgument.shortReadableName()),
5195                                 new String(offendingParameter.shortReadableName()),
5196                          }, 
5197                         location.sourceStart,
5198                         location.sourceEnd);    
5199     }
5200 }
5201 public void wrongSequenceOfExceptionTypesError(TryStatement statement, TypeBinding exceptionType, int under, TypeBinding hidingExceptionType) {
5202         //the two catch block under and upper are in an incorrect order.
5203         //under should be define BEFORE upper in the source
5204
5205         TypeReference typeRef = statement.catchArguments[under].type;
5206         this.handle(
5207                 IProblem.InvalidCatchBlockSequence,
5208                 new String[] {
5209                         new String(exceptionType.readableName()),
5210                         new String(hidingExceptionType.readableName()),
5211                  }, 
5212                 new String[] {
5213                         new String(exceptionType.shortReadableName()),
5214                         new String(hidingExceptionType.shortReadableName()),
5215                  }, 
5216                 typeRef.sourceStart,
5217                 typeRef.sourceEnd);
5218 }
5219 }