dfb3f18626f7e1842dca6473a5b4f4bb75caaa89
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / problem / ProblemReporter.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 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 net.sourceforge.phpdt.internal.compiler.problem;
12 import net.sourceforge.phpdt.core.compiler.CharOperation;
13 import net.sourceforge.phpdt.core.compiler.IProblem;
14 import net.sourceforge.phpdt.core.compiler.InvalidInputException;
15 import net.sourceforge.phpdt.internal.compiler.CompilationResult;
16 import net.sourceforge.phpdt.internal.compiler.IErrorHandlingPolicy;
17 import net.sourceforge.phpdt.internal.compiler.IProblemFactory;
18 import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
19 import net.sourceforge.phpdt.internal.compiler.impl.Constant;
20 import net.sourceforge.phpdt.internal.compiler.impl.ReferenceContext;
21 import net.sourceforge.phpdt.internal.compiler.lookup.Binding;
22 import net.sourceforge.phpdt.internal.compiler.lookup.FieldBinding;
23 import net.sourceforge.phpdt.internal.compiler.lookup.LocalVariableBinding;
24 import net.sourceforge.phpdt.internal.compiler.lookup.MethodBinding;
25 import net.sourceforge.phpdt.internal.compiler.lookup.ProblemMethodBinding;
26 import net.sourceforge.phpdt.internal.compiler.lookup.ProblemReasons;
27 import net.sourceforge.phpdt.internal.compiler.lookup.ProblemReferenceBinding;
28 import net.sourceforge.phpdt.internal.compiler.lookup.ReferenceBinding;
29 import net.sourceforge.phpdt.internal.compiler.lookup.SourceTypeBinding;
30 import net.sourceforge.phpdt.internal.compiler.lookup.SyntheticArgumentBinding;
31 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
32 import net.sourceforge.phpdt.internal.compiler.lookup.TypeConstants;
33 import net.sourceforge.phpdt.internal.compiler.parser.Parser;
34 import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
35 import net.sourceforge.phpdt.internal.compiler.util.Util;
36 import net.sourceforge.phpeclipse.internal.compiler.ast.AbstractMethodDeclaration;
37 import net.sourceforge.phpeclipse.internal.compiler.ast.AbstractVariableDeclaration;
38 import net.sourceforge.phpeclipse.internal.compiler.ast.AllocationExpression;
39 import net.sourceforge.phpeclipse.internal.compiler.ast.Argument;
40 import net.sourceforge.phpeclipse.internal.compiler.ast.ArrayAllocationExpression;
41 import net.sourceforge.phpeclipse.internal.compiler.ast.ArrayReference;
42 import net.sourceforge.phpeclipse.internal.compiler.ast.Assignment;
43 import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
44 import net.sourceforge.phpeclipse.internal.compiler.ast.BinaryExpression;
45 import net.sourceforge.phpeclipse.internal.compiler.ast.BranchStatement;
46 import net.sourceforge.phpeclipse.internal.compiler.ast.Case;
47 import net.sourceforge.phpeclipse.internal.compiler.ast.CastExpression;
48 import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
49 import net.sourceforge.phpeclipse.internal.compiler.ast.CompoundAssignment;
50 import net.sourceforge.phpeclipse.internal.compiler.ast.ConstructorDeclaration;
51 import net.sourceforge.phpeclipse.internal.compiler.ast.DefaultCase;
52 import net.sourceforge.phpeclipse.internal.compiler.ast.EqualExpression;
53 import net.sourceforge.phpeclipse.internal.compiler.ast.ExplicitConstructorCall;
54 import net.sourceforge.phpeclipse.internal.compiler.ast.Expression;
55 import net.sourceforge.phpeclipse.internal.compiler.ast.FieldDeclaration;
56 import net.sourceforge.phpeclipse.internal.compiler.ast.FieldReference;
57 import net.sourceforge.phpeclipse.internal.compiler.ast.ImportReference;
58 import net.sourceforge.phpeclipse.internal.compiler.ast.InstanceOfExpression;
59 import net.sourceforge.phpeclipse.internal.compiler.ast.IntLiteral;
60 import net.sourceforge.phpeclipse.internal.compiler.ast.Literal;
61 import net.sourceforge.phpeclipse.internal.compiler.ast.LocalDeclaration;
62 import net.sourceforge.phpeclipse.internal.compiler.ast.LongLiteral;
63 import net.sourceforge.phpeclipse.internal.compiler.ast.MessageSend;
64 import net.sourceforge.phpeclipse.internal.compiler.ast.MethodDeclaration;
65 import net.sourceforge.phpeclipse.internal.compiler.ast.NameReference;
66 import net.sourceforge.phpeclipse.internal.compiler.ast.NumberLiteral;
67 import net.sourceforge.phpeclipse.internal.compiler.ast.QualifiedNameReference;
68 import net.sourceforge.phpeclipse.internal.compiler.ast.Reference;
69 import net.sourceforge.phpeclipse.internal.compiler.ast.ReturnStatement;
70 import net.sourceforge.phpeclipse.internal.compiler.ast.SingleNameReference;
71 import net.sourceforge.phpeclipse.internal.compiler.ast.Statement;
72 import net.sourceforge.phpeclipse.internal.compiler.ast.ThisReference;
73 import net.sourceforge.phpeclipse.internal.compiler.ast.ThrowStatement;
74 import net.sourceforge.phpeclipse.internal.compiler.ast.TryStatement;
75 import net.sourceforge.phpeclipse.internal.compiler.ast.TypeDeclaration;
76 import net.sourceforge.phpeclipse.internal.compiler.ast.TypeReference;
77 import net.sourceforge.phpeclipse.internal.compiler.ast.UnaryExpression;
78 public class ProblemReporter extends ProblemHandler implements ProblemReasons {
79   public ReferenceContext referenceContext;
80   public ProblemReporter(IErrorHandlingPolicy policy,
81       CompilerOptions options,
82       IProblemFactory problemFactory) {
83     
84    // IProblemFactory problemFactory) {
85     super(policy, options, problemFactory); //), problemFactory);
86   }
87   public void abortDueToInternalError(String errorMessage) {
88     String[] arguments = new String[]{errorMessage};
89     this.handle(IProblem.Unclassified, arguments, arguments, Error | Abort, 0,
90         0);
91   }
92   public void abortDueToInternalError(String errorMessage, AstNode location) {
93     String[] arguments = new String[]{errorMessage};
94     this.handle(IProblem.Unclassified, arguments, arguments, Error | Abort,
95         location.sourceStart, location.sourceEnd);
96   }
97   public void abstractMethodCannotBeOverridden(SourceTypeBinding type,
98       MethodBinding concreteMethod) {
99     this
100         .handle(
101         // %1 must be abstract since it cannot override the inherited
102             // package-private abstract method %2
103             IProblem.AbstractMethodCannotBeOverridden, new String[]{
104                 new String(type.sourceName()),
105                 new String(CharOperation.concat(concreteMethod.declaringClass
106                     .readableName(), concreteMethod.readableName(), '.'))},
107             new String[]{
108                 new String(type.sourceName()),
109                 new String(CharOperation.concat(concreteMethod.declaringClass
110                     .shortReadableName(), concreteMethod.shortReadableName(),
111                     '.'))}, type.sourceStart(), type.sourceEnd());
112   }
113   public void abstractMethodInAbstractClass(SourceTypeBinding type,
114       AbstractMethodDeclaration methodDecl) {
115     String[] arguments = new String[]{new String(type.sourceName()),
116         new String(methodDecl.selector)};
117     this.handle(IProblem.AbstractMethodInAbstractClass, arguments, arguments,
118         methodDecl.sourceStart, methodDecl.sourceEnd);
119   }
120   public void abstractMethodMustBeImplemented(SourceTypeBinding type,
121       MethodBinding abstractMethod) {
122     this.handle(
123     // Must implement the inherited abstract method %1
124         // 8.4.3 - Every non-abstract subclass of an abstract type, A,
125         // must provide a concrete implementation of all of A's
126         // methods.
127         IProblem.AbstractMethodMustBeImplemented, new String[]{new String(
128             CharOperation.concat(abstractMethod.declaringClass.readableName(),
129                 abstractMethod.readableName(), '.'))},
130         new String[]{new String(CharOperation.concat(
131             abstractMethod.declaringClass.shortReadableName(), abstractMethod
132                 .shortReadableName(), '.'))}, type.sourceStart(), type
133             .sourceEnd());
134   }
135   public void abstractMethodNeedingNoBody(AbstractMethodDeclaration method) {
136     this.handle(IProblem.BodyForAbstractMethod, NoArgument, NoArgument,
137         method.sourceStart, method.sourceEnd, method, method
138             .compilationResult());
139   }
140   public void alreadyDefinedLabel(char[] labelName, AstNode location) {
141     String[] arguments = new String[]{new String(labelName)};
142     this.handle(IProblem.DuplicateLabel, arguments, arguments,
143         location.sourceStart, location.sourceEnd);
144   }
145   public void anonymousClassCannotExtendFinalClass(Expression expression,
146       TypeBinding type) {
147     this.handle(IProblem.AnonymousClassCannotExtendFinalClass,
148         new String[]{new String(type.readableName())}, new String[]{new String(
149             type.shortReadableName())}, expression.sourceStart,
150         expression.sourceEnd);
151   }
152   public void argumentTypeCannotBeVoid(SourceTypeBinding type,
153       AbstractMethodDeclaration methodDecl, Argument arg) {
154     String[] arguments = new String[]{new String(methodDecl.selector),
155         new String(arg.name)};
156     this.handle(IProblem.ArgumentTypeCannotBeVoid, arguments, arguments,
157         methodDecl.sourceStart, methodDecl.sourceEnd);
158   }
159   public void argumentTypeCannotBeVoidArray(SourceTypeBinding type,
160       AbstractMethodDeclaration methodDecl, Argument arg) {
161     String[] arguments = new String[]{new String(methodDecl.selector),
162         new String(arg.name)};
163     this.handle(IProblem.ArgumentTypeCannotBeVoidArray, arguments, arguments,
164         methodDecl.sourceStart, methodDecl.sourceEnd);
165   }
166   public void argumentTypeProblem(SourceTypeBinding type,
167       AbstractMethodDeclaration methodDecl, Argument arg,
168       TypeBinding expectedType) {
169     int problemId = expectedType.problemId();
170     int id;
171     switch (problemId) {
172       case NotFound :
173         // 1
174         id = IProblem.ArgumentTypeNotFound;
175         break;
176       case NotVisible :
177         // 2
178         id = IProblem.ArgumentTypeNotVisible;
179         break;
180       case Ambiguous :
181         // 3
182         id = IProblem.ArgumentTypeAmbiguous;
183         break;
184       case InternalNameProvided :
185         // 4
186         id = IProblem.ArgumentTypeInternalNameProvided;
187         break;
188       case InheritedNameHidesEnclosingName :
189         // 5
190         id = IProblem.ArgumentTypeInheritedNameHidesEnclosingName;
191         break;
192       case NoError :
193       // 0
194       default :
195         needImplementation(); // want to fail to see why we were
196         // here...
197         return;
198     }
199     this.handle(id, new String[]{new String(methodDecl.selector), arg.name(),
200         new String(expectedType.readableName())}, new String[]{
201         new String(methodDecl.selector), arg.name(),
202         new String(expectedType.shortReadableName())}, arg.type.sourceStart,
203         arg.type.sourceEnd);
204   }
205   public void arrayConstantsOnlyInArrayInitializers(int sourceStart,
206       int sourceEnd) {
207     this.handle(IProblem.ArrayConstantsOnlyInArrayInitializers, NoArgument,
208         NoArgument, sourceStart, sourceEnd);
209   }
210   public void assignmentHasNoEffect(Assignment assignment, char[] name) {
211     String[] arguments = new String[]{new String(name)};
212     this.handle(IProblem.AssignmentHasNoEffect, arguments, arguments,
213         assignment.sourceStart, assignment.sourceEnd);
214   }
215   public void attemptToReturnNonVoidExpression(ReturnStatement returnStatement,
216       TypeBinding expectedType) {
217     this.handle(IProblem.VoidMethodReturnsValue, new String[]{new String(
218         expectedType.readableName())}, new String[]{new String(expectedType
219         .shortReadableName())}, returnStatement.sourceStart,
220         returnStatement.sourceEnd);
221   }
222   public void attemptToReturnVoidValue(ReturnStatement returnStatement) {
223     this.handle(IProblem.MethodReturnsVoid, NoArgument, NoArgument,
224         returnStatement.sourceStart, returnStatement.sourceEnd);
225   }
226   //public void bytecodeExceeds64KLimit(AbstractMethodDeclaration location)
227   // {
228   //    String[] arguments = new String[] {new String(location.selector),
229   // parametersAsString(location.binding)};
230   //    if (location.isConstructor()) {
231   //            this.handle(
232   //                    IProblem.BytecodeExceeds64KLimitForConstructor,
233   //                    arguments,
234   //                    arguments,
235   //                    Error | Abort,
236   //                    location.sourceStart,
237   //                    location.sourceEnd);
238   //    } else {
239   //            this.handle(
240   //                    IProblem.BytecodeExceeds64KLimit,
241   //                    arguments,
242   //                    arguments,
243   //                    Error | Abort,
244   //                    location.sourceStart,
245   //                    location.sourceEnd);
246   //    }
247   //}
248   public void bytecodeExceeds64KLimit(TypeDeclaration location) {
249     this.handle(IProblem.BytecodeExceeds64KLimitForClinit, NoArgument,
250         NoArgument, Error | Abort, location.sourceStart, location.sourceEnd);
251   }
252   public void cannotAllocateVoidArray(Expression expression) {
253     this.handle(IProblem.CannotAllocateVoidArray, NoArgument, NoArgument,
254         expression.sourceStart, expression.sourceEnd);
255   }
256   public void cannotAssignToFinalField(FieldBinding field, AstNode location) {
257     this.handle(IProblem.FinalFieldAssignment, new String[]{
258         (field.declaringClass == null ? "array" : new String(
259             field.declaringClass.readableName())), //$NON-NLS-1$
260         new String(field.readableName())}, new String[]{
261         (field.declaringClass == null ? "array" : new String(
262             field.declaringClass.shortReadableName())), //$NON-NLS-1$
263         new String(field.shortReadableName())}, location.sourceStart,
264         location.sourceEnd);
265   }
266   public void cannotAssignToFinalLocal(LocalVariableBinding local,
267       AstNode location) {
268     String[] arguments = new String[]{new String(local.readableName())};
269     this.handle(IProblem.NonBlankFinalLocalAssignment, arguments, arguments,
270         location.sourceStart, location.sourceEnd);
271   }
272   public void cannotAssignToFinalOuterLocal(LocalVariableBinding local,
273       AstNode location) {
274     String[] arguments = new String[]{new String(local.readableName())};
275     this.handle(IProblem.FinalOuterLocalAssignment, arguments, arguments,
276         location.sourceStart, location.sourceEnd);
277   }
278   public void cannotDeclareLocalInterface(char[] interfaceName,
279       int sourceStart, int sourceEnd) {
280     String[] arguments = new String[]{new String(interfaceName)};
281     this.handle(IProblem.CannotDefineInterfaceInLocalType, arguments,
282         arguments, sourceStart, sourceEnd);
283   }
284   public void cannotDefineDimensionsAndInitializer(
285       ArrayAllocationExpression expresssion) {
286     this.handle(IProblem.CannotDefineDimensionExpressionsWithInit, NoArgument,
287         NoArgument, expresssion.sourceStart, expresssion.sourceEnd);
288   }
289   public void cannotDireclyInvokeAbstractMethod(MessageSend messageSend,
290       MethodBinding method) {
291     this.handle(IProblem.DirectInvocationOfAbstractMethod, new String[]{
292         new String(method.declaringClass.readableName()),
293         new String(method.selector), parametersAsString(method)}, new String[]{
294         new String(method.declaringClass.shortReadableName()),
295         new String(method.selector), parametersAsShortString(method)},
296         messageSend.sourceStart, messageSend.sourceEnd);
297   }
298   public void cannotImportPackage(ImportReference importRef) {
299     String[] arguments = new String[]{CharOperation.toString(importRef.tokens)};
300     this.handle(IProblem.CannotImportPackage, arguments, arguments,
301         importRef.sourceStart, importRef.sourceEnd);
302   }
303   public void cannotInstantiate(TypeReference typeRef, TypeBinding type) {
304     this.handle(IProblem.InvalidClassInstantiation, new String[]{new String(
305         type.readableName())},
306         new String[]{new String(type.shortReadableName())},
307         typeRef.sourceStart, typeRef.sourceEnd);
308   }
309   public void cannotReferToNonFinalOuterLocal(LocalVariableBinding local,
310       AstNode location) {
311     String[] arguments = new String[]{new String(local.readableName())};
312     this.handle(IProblem.OuterLocalMustBeFinal, arguments, arguments,
313         location.sourceStart, location.sourceEnd);
314   }
315   public void cannotReturnInInitializer(AstNode location) {
316     this.handle(IProblem.CannotReturnInInitializer, NoArgument, NoArgument,
317         location.sourceStart, location.sourceEnd);
318   }
319   public void cannotThrowNull(ThrowStatement statement) {
320     this.handle(IProblem.CannotThrowNull, NoArgument, NoArgument,
321         statement.sourceStart, statement.sourceEnd);
322   }
323   public void cannotThrowType(SourceTypeBinding type,
324       AbstractMethodDeclaration methodDecl, TypeReference exceptionType,
325       TypeBinding expectedType) {
326     this.handle(IProblem.CannotThrowType, new String[]{new String(expectedType
327         .readableName())}, new String[]{new String(expectedType
328         .shortReadableName())}, exceptionType.sourceStart,
329         exceptionType.sourceEnd);
330   }
331   public void cannotUseSuperInJavaLangObject(AstNode reference) {
332     this.handle(IProblem.ObjectHasNoSuperclass, NoArgument, NoArgument,
333         reference.sourceStart, reference.sourceEnd);
334   }
335   public void cannotUseSuperInCodeSnippet(int start, int end) {
336     this.handle(IProblem.CannotUseSuperInCodeSnippet, NoArgument, NoArgument,
337         Error | Abort, start, end);
338   }
339   public void caseExpressionMustBeConstant(Expression expression) {
340     this.handle(IProblem.NonConstantExpression, NoArgument, NoArgument,
341         expression.sourceStart, expression.sourceEnd);
342   }
343   public void classExtendFinalClass(SourceTypeBinding type,
344       TypeReference superclass, TypeBinding expectedType) {
345     String name = new String(type.sourceName());
346     String expectedFullName = new String(expectedType.readableName());
347     String expectedShortName = new String(expectedType.shortReadableName());
348     if (expectedShortName.equals(name))
349       expectedShortName = expectedFullName;
350     this.handle(IProblem.ClassExtendFinalClass, new String[]{expectedFullName,
351         name}, new String[]{expectedShortName, name}, superclass.sourceStart,
352         superclass.sourceEnd);
353   }
354   public void codeSnippetMissingClass(String missing, int start, int end) {
355     String[] arguments = new String[]{missing};
356     this.handle(IProblem.CodeSnippetMissingClass, arguments, arguments, Error
357         | Abort, start, end);
358   }
359   public void codeSnippetMissingMethod(String className, String missingMethod,
360       String argumentTypes, int start, int end) {
361     String[] arguments = new String[]{className, missingMethod, argumentTypes};
362     this.handle(IProblem.CodeSnippetMissingMethod, arguments, arguments, Error
363         | Abort, start, end);
364   }
365   /*
366    * Given the current configuration, answers which category the problem
367    * falls into:
368    *            Error | Warning | Ignore
369    */
370   public int computeSeverity(int problemId){
371
372         // severity can have been preset on the problem
373 //      if ((problem.severity & Fatal) != 0){
374 //              return Error;
375 //      }
376
377         // if not then check whether it is a configurable problem
378         switch(problemId){
379             case IProblem.PHPVarDeprecatedWarning :
380                   return this.options.getSeverity(CompilerOptions.PHPVarDeprecatedWarning);
381         
382                 case IProblem.MaskedCatch : 
383                         return this.options.getSeverity(CompilerOptions.MaskedCatchBlock);
384
385                 case IProblem.UnusedImport :
386                         return this.options.getSeverity(CompilerOptions.UnusedImport);
387                         
388                 case IProblem.MethodButWithConstructorName :
389                         return this.options.getSeverity(CompilerOptions.MethodWithConstructorName);
390                 
391                 case IProblem.OverridingNonVisibleMethod :
392                         return this.options.getSeverity(CompilerOptions.OverriddenPackageDefaultMethod);
393
394                 case IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod :
395                 case IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod :
396                         return this.options.getSeverity(CompilerOptions.IncompatibleNonInheritedInterfaceMethod);
397
398                 case IProblem.OverridingDeprecatedMethod :                              
399                 case IProblem.UsingDeprecatedType :                             
400                 case IProblem.UsingDeprecatedMethod :
401                 case IProblem.UsingDeprecatedConstructor :
402                 case IProblem.UsingDeprecatedField :
403                         return this.options.getSeverity(CompilerOptions.UsingDeprecatedAPI);
404                 
405                 case IProblem.LocalVariableIsNeverUsed :
406                         return this.options.getSeverity(CompilerOptions.UnusedLocalVariable);
407                 
408                 case IProblem.ArgumentIsNeverUsed :
409                         return this.options.getSeverity(CompilerOptions.UnusedArgument);
410
411                 case IProblem.NoImplicitStringConversionForCharArrayExpression :
412                         return this.options.getSeverity(CompilerOptions.NoImplicitStringConversion);
413
414                 case IProblem.NeedToEmulateFieldReadAccess :
415                 case IProblem.NeedToEmulateFieldWriteAccess :
416                 case IProblem.NeedToEmulateMethodAccess :
417                 case IProblem.NeedToEmulateConstructorAccess :                  
418                         return this.options.getSeverity(CompilerOptions.AccessEmulation);
419
420                 case IProblem.NonExternalizedStringLiteral :
421                         return this.options.getSeverity(CompilerOptions.NonExternalizedString);
422
423                 case IProblem.UseAssertAsAnIdentifier :
424                         return this.options.getSeverity(CompilerOptions.AssertUsedAsAnIdentifier);
425
426                 case IProblem.NonStaticAccessToStaticMethod :
427                 case IProblem.NonStaticAccessToStaticField :
428                         return this.options.getSeverity(CompilerOptions.NonStaticAccessToStatic);
429
430 //              case IProblem.IndirectAccessToStaticMethod :
431 //              case IProblem.IndirectAccessToStaticField :
432 //              case IProblem.IndirectAccessToStaticType :
433 //                      return this.options.getSeverity(CompilerOptions.IndirectStaticAccess);
434
435                 case IProblem.AssignmentHasNoEffect:
436                         return this.options.getSeverity(CompilerOptions.NoEffectAssignment);
437
438                 case IProblem.UnusedPrivateConstructor:
439                 case IProblem.UnusedPrivateMethod:
440                 case IProblem.UnusedPrivateField:
441                 case IProblem.UnusedPrivateType:
442                         return this.options.getSeverity(CompilerOptions.UnusedPrivateMember);
443
444                 case IProblem.Task :
445                         return Warning;                 
446
447 //              case IProblem.LocalVariableHidingLocalVariable:
448 //              case IProblem.LocalVariableHidingField:
449 //              case IProblem.ArgumentHidingLocalVariable:
450 //              case IProblem.ArgumentHidingField:
451 //                      return this.options.getSeverity(CompilerOptions.LocalVariableHiding);
452
453 //              case IProblem.FieldHidingLocalVariable:
454 //              case IProblem.FieldHidingField:
455 //                      return this.options.getSeverity(CompilerOptions.FieldHiding);
456
457 //              case IProblem.PossibleAccidentalBooleanAssignment:
458 //                      return this.options.getSeverity(CompilerOptions.AccidentalBooleanAssign);
459
460 //              case IProblem.SuperfluousSemicolon:
461 //                      return this.options.getSeverity(CompilerOptions.SuperfluousSemicolon);
462 //
463 //              case IProblem.UndocumentedEmptyBlock:
464 //                      return this.options.getSeverity(CompilerOptions.UndocumentedEmptyBlock);
465 //                      
466 //              case IProblem.UnnecessaryCast:
467 //              case IProblem.UnnecessaryArgumentCast:
468 //              case IProblem.UnnecessaryInstanceof:
469 //                      return this.options.getSeverity(CompilerOptions.UnnecessaryTypeCheck);
470 //                      
471 //              case IProblem.FinallyMustCompleteNormally:
472 //                      return this.options.getSeverity(CompilerOptions.FinallyBlockNotCompleting);
473 //                      
474 //              case IProblem.UnusedMethodDeclaredThrownException:
475 //              case IProblem.UnusedConstructorDeclaredThrownException:
476 //                      return this.options.getSeverity(CompilerOptions.UnusedDeclaredThrownException);
477 //
478 //              case IProblem.UnqualifiedFieldAccess:
479 //                      return this.options.getSeverity(CompilerOptions.UnqualifiedFieldAccess);
480
481                 /*
482                  * Javadoc syntax errors
483                  */
484                 // Javadoc explicit IDs
485 //              case IProblem.JavadocUnexpectedTag:
486 //              case IProblem.JavadocDuplicateReturnTag:
487 //              case IProblem.JavadocInvalidThrowsClass:
488 //              case IProblem.JavadocInvalidSeeReference:
489 //              case IProblem.JavadocInvalidSeeHref:
490 //              case IProblem.JavadocInvalidSeeArgs:
491 //              case IProblem.JavadocInvalidTag:
492 //                      return this.options.getSeverity(CompilerOptions.InvalidJavadoc);
493
494                 /*
495                  * Javadoc tags resolved references errors
496                  */
497 //              case IProblem.JavadocInvalidParamName:
498 //              case IProblem.JavadocDuplicateParamName:
499 //              case IProblem.JavadocMissingParamName:
500 //              case IProblem.JavadocInvalidThrowsClassName:
501 //              case IProblem.JavadocDuplicateThrowsClassName:
502 //              case IProblem.JavadocMissingThrowsClassName:
503 //              case IProblem.JavadocMissingSeeReference:
504 //              case IProblem.JavadocUsingDeprecatedField:
505 //              case IProblem.JavadocUsingDeprecatedConstructor:
506 //              case IProblem.JavadocUsingDeprecatedMethod:
507 //              case IProblem.JavadocUsingDeprecatedType:
508 //              case IProblem.JavadocUndefinedField:
509 //              case IProblem.JavadocNotVisibleField:
510 //              case IProblem.JavadocAmbiguousField:
511 //              case IProblem.JavadocUndefinedConstructor:
512 //              case IProblem.JavadocNotVisibleConstructor:
513 //              case IProblem.JavadocAmbiguousConstructor:
514 //              case IProblem.JavadocUndefinedMethod:
515 //              case IProblem.JavadocNotVisibleMethod:
516 //              case IProblem.JavadocAmbiguousMethod:
517 //              case IProblem.JavadocParameterMismatch:
518 //              case IProblem.JavadocUndefinedType:
519 //              case IProblem.JavadocNotVisibleType:
520 //              case IProblem.JavadocAmbiguousType:
521 //              case IProblem.JavadocInternalTypeNameProvided:
522 //              case IProblem.JavadocNoMessageSendOnArrayType:
523 //              case IProblem.JavadocNoMessageSendOnBaseType:
524 //                      if (!this.options.reportInvalidJavadocTags)
525 //                              return ProblemSeverities.Ignore;
526 //                      else
527 //                              return this.options.getSeverity(CompilerOptions.InvalidJavadoc);
528
529                 /*
530                  * Javadoc missing tags errors
531                  */
532 //              case IProblem.JavadocMissingParamTag:
533 //              case IProblem.JavadocMissingReturnTag:
534 //              case IProblem.JavadocMissingThrowsTag:
535 //                      return this.options.getSeverity(CompilerOptions.MissingJavadocTags);
536
537                 /*
538                  * Missing Javadoc errors
539                  */
540 //              case IProblem.JavadocMissing:
541 //                      return this.options.getSeverity(CompilerOptions.MissingJavadocComments);
542
543                 // by default problems are errors.
544                 default:
545                         return Error;
546         }
547   }
548   //public void conditionalArgumentsIncompatibleTypes(ConditionalExpression
549   // expression, TypeBinding trueType, TypeBinding falseType) {
550   //    this.handle(
551   //            IProblem.IncompatibleTypesInConditionalOperator,
552   //            new String[] {new String(trueType.readableName()), new
553   // String(falseType.readableName())},
554   //            new String[] {new String(trueType.sourceName()), new
555   // String(falseType.sourceName())},
556   //            expression.sourceStart,
557   //            expression.sourceEnd);
558   //}
559   public void conflictingImport(ImportReference importRef) {
560     String[] arguments = new String[]{CharOperation.toString(importRef.tokens)};
561     this.handle(IProblem.ConflictingImport, arguments, arguments,
562         importRef.sourceStart, importRef.sourceEnd);
563   }
564   public void constantOutOfFormat(NumberLiteral lit) {
565     // the literal is not in a correct format
566     // this code is called on IntLiteral and LongLiteral
567     // example 000811 ...the 8 is uncorrect.
568     if ((lit instanceof LongLiteral) || (lit instanceof IntLiteral)) {
569       char[] source = lit.source();
570       try {
571         final String Radix;
572         final int radix;
573         if ((source[1] == 'x') || (source[1] == 'X')) {
574           radix = 16;
575           Radix = "Hexa"; //$NON-NLS-1$
576         } else {
577           radix = 8;
578           Radix = "Octal"; //$NON-NLS-1$
579         }
580         //look for the first digit that is incorrect
581         int place = -1;
582         label : for (int i = radix == 8 ? 1 : 2; i < source.length; i++) {
583           if (Character.digit(source[i], radix) == -1) {
584             place = i;
585             break label;
586           }
587         }
588         String[] arguments = new String[]{Radix + " " + new String(source)
589             + " (digit " + new String(new char[]{source[place]}) + ")"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
590         this.handle(IProblem.NumericValueOutOfRange, arguments, arguments,
591             lit.sourceStart, lit.sourceEnd);
592         return;
593       } catch (IndexOutOfBoundsException ex) {
594       }
595       // just in case .... use a predefined error..
596       // we should never come here...(except if the code changes !)
597       this.constantOutOfRange(lit);
598     }
599   }
600   public void constantOutOfRange(Literal lit) {
601     // lit is some how out of range of it declared type
602     // example
603     // 9999999999999999999999999999999999999999999999999999999999999999999
604     String[] arguments = new String[]{new String(lit.source())};
605     this.handle(IProblem.NumericValueOutOfRange, arguments, arguments,
606         lit.sourceStart, lit.sourceEnd);
607   }
608   public void deprecatedField(FieldBinding field, AstNode location) {
609     this.handle(IProblem.UsingDeprecatedField,
610         new String[]{new String(field.declaringClass.readableName()),
611             new String(field.name)}, new String[]{
612             new String(field.declaringClass.shortReadableName()),
613             new String(field.name)}, location.sourceStart, location.sourceEnd);
614   }
615   public void deprecatedMethod(MethodBinding method, AstNode location) {
616     if (method.isConstructor())
617       this.handle(IProblem.UsingDeprecatedConstructor, new String[]{
618           new String(method.declaringClass.readableName()),
619           parametersAsString(method)}, new String[]{
620           new String(method.declaringClass.shortReadableName()),
621           parametersAsShortString(method)}, location.sourceStart,
622           location.sourceEnd);
623     else
624       this.handle(IProblem.UsingDeprecatedMethod, new String[]{
625           new String(method.declaringClass.readableName()),
626           new String(method.selector), parametersAsString(method)},
627           new String[]{new String(method.declaringClass.shortReadableName()),
628               new String(method.selector), parametersAsShortString(method)},
629           location.sourceStart, location.sourceEnd);
630   }
631   public void deprecatedType(TypeBinding type, AstNode location) {
632     if (location == null)
633       return; // 1G828DN - no type ref for synthetic arguments
634     this.handle(IProblem.UsingDeprecatedType, new String[]{new String(type
635         .readableName())}, new String[]{new String(type.shortReadableName())},
636         location.sourceStart, location.sourceEnd);
637   }
638   public void duplicateCase(Case statement, Constant constant) {
639     String[] arguments = new String[]{String.valueOf(constant.intValue())};
640     this.handle(IProblem.DuplicateCase, arguments, arguments,
641         statement.sourceStart, statement.sourceEnd);
642   }
643   public void duplicateDefaultCase(DefaultCase statement) {
644     this.handle(IProblem.DuplicateDefaultCase, NoArgument, NoArgument,
645         statement.sourceStart, statement.sourceEnd);
646   }
647   public void duplicateFieldInType(SourceTypeBinding type,
648       FieldDeclaration fieldDecl) {
649     this.handle(IProblem.DuplicateField, new String[]{
650         new String(type.sourceName()), fieldDecl.name()}, new String[]{
651         new String(type.shortReadableName()), fieldDecl.name()},
652         fieldDecl.sourceStart, fieldDecl.sourceEnd);
653   }
654   public void duplicateImport(ImportReference importRef) {
655     String[] arguments = new String[]{CharOperation.toString(importRef.tokens)};
656     this.handle(IProblem.DuplicateImport, arguments, arguments,
657         importRef.sourceStart, importRef.sourceEnd);
658   }
659   public void duplicateInitializationOfBlankFinalField(FieldBinding field,
660       Reference reference) {
661     String[] arguments = new String[]{new String(field.readableName())};
662     this.handle(IProblem.DuplicateBlankFinalFieldInitialization, arguments,
663         arguments, reference.sourceStart, reference.sourceEnd);
664   }
665   public void duplicateInitializationOfFinalLocal(LocalVariableBinding local,
666       AstNode location) {
667     String[] arguments = new String[]{new String(local.readableName())};
668     this.handle(IProblem.DuplicateFinalLocalInitialization, arguments,
669         arguments, location.sourceStart, location.sourceEnd);
670   }
671   public void duplicateMethodInType(SourceTypeBinding type,
672       AbstractMethodDeclaration methodDecl) {
673     String[] arguments = new String[]{new String(methodDecl.selector),
674         new String(type.sourceName())};
675     this.handle(IProblem.DuplicateMethod, arguments, arguments,
676         methodDecl.sourceStart, methodDecl.sourceEnd);
677   }
678   public void duplicateModifierForField(ReferenceBinding type,
679       FieldDeclaration fieldDecl) {
680     /*
681      * to highlight modifiers use: this.handle( new Problem(
682      * DuplicateModifierForField, new String[] {fieldDecl.name()},
683      * fieldDecl.modifiers.sourceStart, fieldDecl.modifiers.sourceEnd));
684      */
685     String[] arguments = new String[]{fieldDecl.name()};
686     this.handle(IProblem.DuplicateModifierForField, arguments, arguments,
687         fieldDecl.sourceStart, fieldDecl.sourceEnd);
688   }
689   public void duplicateModifierForMethod(ReferenceBinding type,
690       AbstractMethodDeclaration methodDecl) {
691     this.handle(IProblem.DuplicateModifierForMethod, new String[]{
692         new String(type.sourceName()), new String(methodDecl.selector)},
693         new String[]{new String(type.shortReadableName()),
694             new String(methodDecl.selector)}, methodDecl.sourceStart,
695         methodDecl.sourceEnd);
696   }
697   public void duplicateModifierForType(SourceTypeBinding type) {
698     String[] arguments = new String[]{new String(type.sourceName())};
699     this.handle(IProblem.DuplicateModifierForType, arguments, arguments, type
700         .sourceStart(), type.sourceEnd());
701   }
702   public void duplicateModifierForVariable(LocalDeclaration localDecl,
703       boolean complainForArgument) {
704     String[] arguments = new String[]{localDecl.name()};
705     this.handle(complainForArgument
706         ? IProblem.DuplicateModifierForArgument
707         : IProblem.DuplicateModifierForVariable, arguments, arguments,
708         localDecl.sourceStart, localDecl.sourceEnd);
709   }
710   public void duplicateNestedType(TypeDeclaration typeDecl) {
711     String[] arguments = new String[]{new String(typeDecl.name)};
712     this.handle(IProblem.DuplicateNestedType, arguments, arguments,
713         typeDecl.sourceStart, typeDecl.sourceEnd);
714   }
715   public void duplicateSuperinterface(SourceTypeBinding type,
716       TypeDeclaration typeDecl, ReferenceBinding superType) {
717     this.handle(IProblem.DuplicateSuperInterface, new String[]{
718         new String(superType.readableName()), new String(type.sourceName())},
719         new String[]{new String(superType.shortReadableName()),
720             new String(type.sourceName())}, typeDecl.sourceStart,
721         typeDecl.sourceEnd);
722   }
723   public void duplicateTypes(CompilationUnitDeclaration compUnitDecl,
724       TypeDeclaration typeDecl) {
725     String[] arguments = new String[]{new String(compUnitDecl.getFileName()),
726         new String(typeDecl.name)};
727     this.referenceContext = typeDecl; // report the problem against the
728     // type not the entire compilation
729     // unit
730     this.handle(IProblem.DuplicateTypes, arguments, arguments,
731         typeDecl.sourceStart, typeDecl.sourceEnd,
732         compUnitDecl.compilationResult);
733   }
734   public void errorNoMethodFor(MessageSend messageSend, TypeBinding recType,
735       TypeBinding[] params) {
736     StringBuffer buffer = new StringBuffer();
737     StringBuffer shortBuffer = new StringBuffer();
738     for (int i = 0, length = params.length; i < length; i++) {
739       if (i != 0) {
740         buffer.append(", "); //$NON-NLS-1$
741         shortBuffer.append(", "); //$NON-NLS-1$
742       }
743       buffer.append(new String(params[i].readableName()));
744       shortBuffer.append(new String(params[i].shortReadableName()));
745     }
746     this.handle(recType.isArrayType()
747         ? IProblem.NoMessageSendOnArrayType
748         : IProblem.NoMessageSendOnBaseType, new String[]{
749         new String(recType.readableName()), new String(messageSend.selector),
750         buffer.toString()}, new String[]{
751         new String(recType.shortReadableName()),
752         new String(messageSend.selector), shortBuffer.toString()},
753         messageSend.sourceStart, messageSend.sourceEnd);
754   }
755   public void errorThisSuperInStatic(AstNode reference) {
756     String[] arguments = new String[]{reference.isSuper() ? "super" : "this"}; //$NON-NLS-2$ //$NON-NLS-1$
757     this.handle(IProblem.ThisInStaticContext, arguments, arguments,
758         reference.sourceStart, reference.sourceEnd);
759   }
760   public void exceptionTypeProblem(SourceTypeBinding type,
761       AbstractMethodDeclaration methodDecl, TypeReference exceptionType,
762       TypeBinding expectedType) {
763     int problemId = expectedType.problemId();
764     int id;
765     switch (problemId) {
766       case NotFound :
767         // 1
768         id = IProblem.ExceptionTypeNotFound;
769         break;
770       case NotVisible :
771         // 2
772         id = IProblem.ExceptionTypeNotVisible;
773         break;
774       case Ambiguous :
775         // 3
776         id = IProblem.ExceptionTypeAmbiguous;
777         break;
778       case InternalNameProvided :
779         // 4
780         id = IProblem.ExceptionTypeInternalNameProvided;
781         break;
782       case InheritedNameHidesEnclosingName :
783         // 5
784         id = IProblem.ExceptionTypeInheritedNameHidesEnclosingName;
785         break;
786       case NoError :
787       // 0
788       default :
789         needImplementation(); // want to fail to see why we were
790         // here...
791         return;
792     }
793     this.handle(id, new String[]{new String(methodDecl.selector),
794         new String(expectedType.readableName())}, new String[]{
795         new String(methodDecl.selector),
796         new String(expectedType.shortReadableName())},
797         exceptionType.sourceStart, exceptionType.sourceEnd);
798   }
799   public void expressionShouldBeAVariable(Expression expression) {
800     this.handle(IProblem.ExpressionShouldBeAVariable, NoArgument, NoArgument,
801         expression.sourceStart, expression.sourceEnd);
802   }
803   public void fieldsOrThisBeforeConstructorInvocation(ThisReference reference) {
804     this.handle(IProblem.ThisSuperDuringConstructorInvocation, NoArgument,
805         NoArgument, reference.sourceStart, reference.sourceEnd);
806   }
807   public void fieldTypeProblem(SourceTypeBinding type,
808       FieldDeclaration fieldDecl, TypeBinding expectedType) {
809     int problemId = expectedType.problemId();
810     int id;
811     switch (problemId) {
812       case NotFound :
813         // 1
814         id = IProblem.FieldTypeNotFound;
815         break;
816       case NotVisible :
817         // 2
818         id = IProblem.FieldTypeNotVisible;
819         break;
820       case Ambiguous :
821         // 3
822         id = IProblem.FieldTypeAmbiguous;
823         break;
824       case InternalNameProvided :
825         // 4
826         id = IProblem.FieldTypeInternalNameProvided;
827         break;
828       case InheritedNameHidesEnclosingName :
829         // 5
830         id = IProblem.FieldTypeInheritedNameHidesEnclosingName;
831         break;
832       case NoError :
833       // 0
834       default :
835         needImplementation(); // want to fail to see why we were
836         // here...
837         return;
838     }
839     this.handle(id,
840         new String[]{fieldDecl.name(), new String(type.sourceName()),
841             new String(expectedType.readableName())}, new String[]{
842             fieldDecl.name(), new String(type.sourceName()),
843             new String(expectedType.shortReadableName())},
844         fieldDecl.type.sourceStart, fieldDecl.type.sourceEnd);
845   }
846   public void finalMethodCannotBeOverridden(MethodBinding currentMethod,
847       MethodBinding inheritedMethod) {
848     this.handle(
849     // Cannot override the final method from %1
850         // 8.4.3.3 - Final methods cannot be overridden or hidden.
851         IProblem.FinalMethodCannotBeOverridden, new String[]{new String(
852             inheritedMethod.declaringClass.readableName())},
853         new String[]{new String(inheritedMethod.declaringClass
854             .shortReadableName())}, currentMethod.sourceStart(), currentMethod
855             .sourceEnd());
856   }
857   public void forwardReference(Reference reference, int indexInQualification,
858       TypeBinding type) {
859     this.handle(IProblem.ReferenceToForwardField, NoArgument, NoArgument,
860         reference.sourceStart, reference.sourceEnd);
861   }
862   // use this private API when the compilation unit result can be found
863   // through the
864   // reference context. Otherwise, use the other API taking a problem and a
865   // compilation result
866   // as arguments
867   private void handle(int problemId, String[] problemArguments,
868       String[] messageArguments, int problemStartPosition,
869       int problemEndPosition) {
870     this.handle(problemId, problemArguments, messageArguments,
871         problemStartPosition, problemEndPosition, referenceContext,
872         referenceContext == null ? null : referenceContext.compilationResult());
873     referenceContext = null;
874   }
875   // use this private API when the compilation unit result can be found
876   // through the
877   // reference context. Otherwise, use the other API taking a problem and a
878   // compilation result
879   // as arguments
880   private void handle(int problemId, String[] problemArguments,
881       String[] messageArguments, int severity, int problemStartPosition,
882       int problemEndPosition) {
883     this.handle(problemId, problemArguments, messageArguments, severity,
884         problemStartPosition, problemEndPosition, referenceContext,
885         referenceContext == null ? null : referenceContext.compilationResult());
886     referenceContext = null;
887   }
888   // use this private API when the compilation unit result cannot be found
889   // through the
890   // reference context.
891   private void handle(int problemId, String[] problemArguments,
892       String[] messageArguments, int problemStartPosition,
893       int problemEndPosition, CompilationResult unitResult) {
894     this.handle(problemId, problemArguments, messageArguments,
895         problemStartPosition, problemEndPosition, referenceContext, unitResult);
896     referenceContext = null;
897   }
898   public void hidingEnclosingType(TypeDeclaration typeDecl) {
899     String[] arguments = new String[]{new String(typeDecl.name)};
900     this.handle(IProblem.HidingEnclosingType, arguments, arguments,
901         typeDecl.sourceStart, typeDecl.sourceEnd);
902   }
903   public void hierarchyCircularity(SourceTypeBinding sourceType,
904       ReferenceBinding superType, TypeReference reference) {
905     int start = 0;
906     int end = 0;
907     String typeName = ""; //$NON-NLS-1$
908     String shortTypeName = ""; //$NON-NLS-1$
909     if (reference == null) { // can only happen when java.lang.Object is
910       // busted
911       start = sourceType.sourceStart();
912       end = sourceType.sourceEnd();
913       typeName = new String(superType.readableName());
914       shortTypeName = new String(superType.sourceName());
915     } else {
916       start = reference.sourceStart;
917       end = reference.sourceEnd;
918       char[][] qName = reference.getTypeName();
919       typeName = CharOperation.toString(qName);
920       shortTypeName = new String(qName[qName.length - 1]);
921     }
922     if (sourceType == superType)
923       this.handle(IProblem.HierarchyCircularitySelfReference, new String[]{
924           new String(sourceType.sourceName()), typeName}, new String[]{
925           new String(sourceType.sourceName()), shortTypeName}, start, end);
926     else
927       this.handle(IProblem.HierarchyCircularity, new String[]{
928           new String(sourceType.sourceName()), typeName}, new String[]{
929           new String(sourceType.sourceName()), shortTypeName}, start, end);
930   }
931   public void hierarchyHasProblems(SourceTypeBinding type) {
932     String[] arguments = new String[]{new String(type.sourceName())};
933     this.handle(IProblem.HierarchyHasProblems, arguments, arguments, type
934         .sourceStart(), type.sourceEnd());
935   }
936   public void illegalAbstractModifierCombinationForMethod(
937       ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
938     String[] arguments = new String[]{new String(type.sourceName()),
939         new String(methodDecl.selector)};
940     this.handle(IProblem.IllegalAbstractModifierCombinationForMethod,
941         arguments, arguments, methodDecl.sourceStart, methodDecl.sourceEnd);
942   }
943   public void illegalModifierCombinationFinalAbstractForClass(
944       SourceTypeBinding type) {
945     String[] arguments = new String[]{new String(type.sourceName())};
946     this.handle(IProblem.IllegalModifierCombinationFinalAbstractForClass,
947         arguments, arguments, type.sourceStart(), type.sourceEnd());
948   }
949   public void illegalModifierCombinationFinalVolatileForField(
950       ReferenceBinding type, FieldDeclaration fieldDecl) {
951     String[] arguments = new String[]{fieldDecl.name()};
952     this.handle(IProblem.IllegalModifierCombinationFinalVolatileForField,
953         arguments, arguments, fieldDecl.sourceStart, fieldDecl.sourceEnd);
954   }
955   public void illegalModifierForClass(SourceTypeBinding type) {
956     String[] arguments = new String[]{new String(type.sourceName())};
957     this.handle(IProblem.IllegalModifierForClass, arguments, arguments, type
958         .sourceStart(), type.sourceEnd());
959   }
960   public void illegalModifierForField(ReferenceBinding type,
961       FieldDeclaration fieldDecl) {
962     String[] arguments = new String[]{fieldDecl.name()};
963     this.handle(IProblem.IllegalModifierForField, arguments, arguments,
964         fieldDecl.sourceStart, fieldDecl.sourceEnd);
965   }
966   public void illegalModifierForInterface(SourceTypeBinding type) {
967     String[] arguments = new String[]{new String(type.sourceName())};
968     this.handle(IProblem.IllegalModifierForInterface, arguments, arguments,
969         type.sourceStart(), type.sourceEnd());
970   }
971   public void illegalModifierForInterfaceField(ReferenceBinding type,
972       FieldDeclaration fieldDecl) {
973     String[] arguments = new String[]{fieldDecl.name()};
974     this.handle(IProblem.IllegalModifierForInterfaceField, arguments,
975         arguments, fieldDecl.sourceStart, fieldDecl.sourceEnd);
976   }
977   public void illegalModifierForInterfaceMethod(ReferenceBinding type,
978       AbstractMethodDeclaration methodDecl) {
979     String[] arguments = new String[]{new String(type.sourceName()),
980         new String(methodDecl.selector)};
981     this.handle(IProblem.IllegalModifierForInterfaceMethod, arguments,
982         arguments, methodDecl.sourceStart, methodDecl.sourceEnd);
983   }
984   public void illegalModifierForLocalClass(SourceTypeBinding type) {
985     String[] arguments = new String[]{new String(type.sourceName())};
986     this.handle(IProblem.IllegalModifierForLocalClass, arguments, arguments,
987         type.sourceStart(), type.sourceEnd());
988   }
989   public void illegalModifierForMemberClass(SourceTypeBinding type) {
990     String[] arguments = new String[]{new String(type.sourceName())};
991     this.handle(IProblem.IllegalModifierForMemberClass, arguments, arguments,
992         type.sourceStart(), type.sourceEnd());
993   }
994   public void illegalModifierForMemberInterface(SourceTypeBinding type) {
995     String[] arguments = new String[]{new String(type.sourceName())};
996     this.handle(IProblem.IllegalModifierForMemberInterface, arguments,
997         arguments, type.sourceStart(), type.sourceEnd());
998   }
999   public void illegalModifierForMethod(ReferenceBinding type,
1000       AbstractMethodDeclaration methodDecl) {
1001     String[] arguments = new String[]{new String(type.sourceName()),
1002         new String(methodDecl.selector)};
1003     this.handle(IProblem.IllegalModifierForMethod, arguments, arguments,
1004         methodDecl.sourceStart, methodDecl.sourceEnd);
1005   }
1006   public void illegalModifierForVariable(LocalDeclaration localDecl,
1007       boolean complainAsArgument) {
1008     String[] arguments = new String[]{localDecl.name()};
1009     this.handle(complainAsArgument
1010         ? IProblem.IllegalModifierForArgument
1011         : IProblem.IllegalModifierForVariable, arguments, arguments,
1012         localDecl.sourceStart, localDecl.sourceEnd);
1013   }
1014   public void illegalPrimitiveOrArrayTypeForEnclosingInstance(
1015       TypeBinding enclosingType, AstNode location) {
1016     this.handle(IProblem.IllegalPrimitiveOrArrayTypeForEnclosingInstance,
1017         new String[]{new String(enclosingType.readableName())},
1018         new String[]{new String(enclosingType.shortReadableName())},
1019         location.sourceStart, location.sourceEnd);
1020   }
1021   public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
1022     String[] arguments = new String[]{new String(type.sourceName())};
1023     this.handle(IProblem.IllegalStaticModifierForMemberType, arguments,
1024         arguments, type.sourceStart(), type.sourceEnd());
1025   }
1026   public void illegalVisibilityModifierCombinationForField(
1027       ReferenceBinding type, FieldDeclaration fieldDecl) {
1028     String[] arguments = new String[]{new String(fieldDecl.name())};
1029     this.handle(IProblem.IllegalVisibilityModifierCombinationForField,
1030         arguments, arguments, fieldDecl.sourceStart, fieldDecl.sourceEnd);
1031   }
1032   public void illegalVisibilityModifierCombinationForMemberType(
1033       SourceTypeBinding type) {
1034     String[] arguments = new String[]{new String(type.sourceName())};
1035     this.handle(IProblem.IllegalVisibilityModifierCombinationForMemberType,
1036         arguments, arguments, type.sourceStart(), type.sourceEnd());
1037   }
1038   public void illegalVisibilityModifierCombinationForMethod(
1039       ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
1040     String[] arguments = new String[]{new String(type.sourceName()),
1041         new String(methodDecl.selector)};
1042     this.handle(IProblem.IllegalVisibilityModifierCombinationForMethod,
1043         arguments, arguments, methodDecl.sourceStart, methodDecl.sourceEnd);
1044   }
1045   public void illegalVisibilityModifierForInterfaceMemberType(
1046       SourceTypeBinding type) {
1047     String[] arguments = new String[]{new String(type.sourceName())};
1048     this.handle(IProblem.IllegalVisibilityModifierForInterfaceMemberType,
1049         arguments, arguments, type.sourceStart(), type.sourceEnd());
1050   }
1051   public void illegalVoidExpression(AstNode location) {
1052     this.handle(IProblem.InvalidVoidExpression, NoArgument, NoArgument,
1053         location.sourceStart, location.sourceEnd);
1054   }
1055   public void importProblem(ImportReference importRef, Binding expectedImport) {
1056     int problemId = expectedImport.problemId();
1057     int id;
1058     switch (problemId) {
1059       case NotFound :
1060         // 1
1061         id = IProblem.ImportNotFound;
1062         break;
1063       case NotVisible :
1064         // 2
1065         id = IProblem.ImportNotVisible;
1066         break;
1067       case Ambiguous :
1068         // 3
1069         id = IProblem.ImportAmbiguous;
1070         break;
1071       case InternalNameProvided :
1072         // 4
1073         id = IProblem.ImportInternalNameProvided;
1074         break;
1075       case InheritedNameHidesEnclosingName :
1076         // 5
1077         id = IProblem.ImportInheritedNameHidesEnclosingName;
1078         break;
1079       case NoError :
1080       // 0
1081       default :
1082         needImplementation(); // want to fail to see why we were
1083         // here...
1084         return;
1085     }
1086     String argument;
1087     if (expectedImport instanceof ProblemReferenceBinding) {
1088       argument = CharOperation
1089           .toString(((ProblemReferenceBinding) expectedImport).compoundName);
1090     } else {
1091       argument = CharOperation.toString(importRef.tokens);
1092     }
1093     String[] arguments = new String[]{argument};
1094     this.handle(id, arguments, arguments, importRef.sourceStart,
1095         importRef.sourceEnd);
1096   }
1097   public void incompatibleExceptionInThrowsClause(SourceTypeBinding type,
1098       MethodBinding currentMethod, MethodBinding inheritedMethod,
1099       ReferenceBinding exceptionType) {
1100     if (type == currentMethod.declaringClass) {
1101       int id;
1102       if (currentMethod.declaringClass.isInterface()
1103           && !inheritedMethod.isPublic()) { // interface inheriting
1104         // Object protected
1105         // method
1106         id = IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod;
1107       } else {
1108         id = IProblem.IncompatibleExceptionInThrowsClause;
1109       }
1110       this.handle(
1111       // Exception %1 is not compatible with throws
1112           // clause in %2
1113           // 9.4.4 - The type of exception in the throws
1114           // clause is incompatible.
1115           id, new String[]{
1116               new String(exceptionType.sourceName()),
1117               new String(CharOperation.concat(inheritedMethod.declaringClass
1118                   .readableName(), inheritedMethod.readableName(), '.'))},
1119           new String[]{
1120               new String(exceptionType.sourceName()),
1121               new String(CharOperation.concat(inheritedMethod.declaringClass
1122                   .shortReadableName(), inheritedMethod.shortReadableName(),
1123                   '.'))}, currentMethod.sourceStart(), currentMethod
1124               .sourceEnd());
1125     } else
1126       this.handle(
1127       // Exception %1 in throws clause of %2 is not
1128           // compatible with %3
1129           // 9.4.4 - The type of exception in the throws
1130           // clause is incompatible.
1131           IProblem.IncompatibleExceptionInInheritedMethodThrowsClause,
1132           new String[]{
1133               new String(exceptionType.sourceName()),
1134               new String(CharOperation.concat(currentMethod.declaringClass
1135                   .sourceName(), currentMethod.readableName(), '.')),
1136               new String(CharOperation.concat(inheritedMethod.declaringClass
1137                   .readableName(), inheritedMethod.readableName(), '.'))},
1138           new String[]{
1139               new String(exceptionType.sourceName()),
1140               new String(CharOperation.concat(currentMethod.declaringClass
1141                   .sourceName(), currentMethod.shortReadableName(), '.')),
1142               new String(CharOperation.concat(inheritedMethod.declaringClass
1143                   .shortReadableName(), inheritedMethod.shortReadableName(),
1144                   '.'))}, type.sourceStart(), type.sourceEnd());
1145   }
1146   public void incompatibleReturnType(MethodBinding currentMethod,
1147       MethodBinding inheritedMethod) {
1148     StringBuffer methodSignature = new StringBuffer();
1149     methodSignature.append(inheritedMethod.declaringClass.readableName())
1150         .append('.').append(inheritedMethod.readableName());
1151     StringBuffer shortSignature = new StringBuffer();
1152     shortSignature.append(inheritedMethod.declaringClass.shortReadableName())
1153         .append('.').append(inheritedMethod.shortReadableName());
1154     int id;
1155     if (currentMethod.declaringClass.isInterface()
1156         && !inheritedMethod.isPublic()) { // interface inheriting
1157       // Object protected method
1158       id = IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod;
1159     } else {
1160       id = IProblem.IncompatibleReturnType;
1161     }
1162     this.handle(id, new String[]{methodSignature.toString()},
1163         new String[]{shortSignature.toString()}, currentMethod.sourceStart(),
1164         currentMethod.sourceEnd());
1165   }
1166   public void incorrectLocationForEmptyDimension(
1167       ArrayAllocationExpression expression, int index) {
1168     this.handle(IProblem.IllegalDimension, NoArgument, NoArgument,
1169         expression.dimensions[index + 1].sourceStart,
1170         expression.dimensions[index + 1].sourceEnd);
1171   }
1172   public void incorrectSwitchType(Expression expression, TypeBinding testType) {
1173     this.handle(IProblem.IncorrectSwitchType, new String[]{new String(testType
1174         .readableName())},
1175         new String[]{new String(testType.shortReadableName())},
1176         expression.sourceStart, expression.sourceEnd);
1177   }
1178   public void inheritedMethodReducesVisibility(SourceTypeBinding type,
1179       MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
1180     StringBuffer concreteSignature = new StringBuffer();
1181     concreteSignature.append(concreteMethod.declaringClass.readableName())
1182         .append('.').append(concreteMethod.readableName());
1183     StringBuffer shortSignature = new StringBuffer();
1184     shortSignature.append(concreteMethod.declaringClass.shortReadableName())
1185         .append('.').append(concreteMethod.shortReadableName());
1186     this.handle(
1187     // The inherited method %1 cannot hide the public abstract method in %2
1188         IProblem.InheritedMethodReducesVisibility, new String[]{
1189             new String(concreteSignature.toString()),
1190             new String(abstractMethods[0].declaringClass.readableName())},
1191         new String[]{new String(shortSignature.toString()),
1192             new String(abstractMethods[0].declaringClass.shortReadableName())},
1193         type.sourceStart(), type.sourceEnd());
1194   }
1195   public void inheritedMethodsHaveIncompatibleReturnTypes(
1196       SourceTypeBinding type, MethodBinding[] inheritedMethods, int length) {
1197     StringBuffer methodSignatures = new StringBuffer();
1198     StringBuffer shortSignatures = new StringBuffer();
1199     for (int i = length; --i >= 0;) {
1200       methodSignatures
1201           .append(inheritedMethods[i].declaringClass.readableName())
1202           .append('.').append(inheritedMethods[i].readableName());
1203       shortSignatures.append(
1204           inheritedMethods[i].declaringClass.shortReadableName()).append('.')
1205           .append(inheritedMethods[i].shortReadableName());
1206       if (i != 0) {
1207         methodSignatures.append(", "); //$NON-NLS-1$
1208         shortSignatures.append(", "); //$NON-NLS-1$
1209       }
1210     }
1211     this.handle(
1212     // Return type is incompatible with %1
1213         // 9.4.2 - The return type from the method is incompatible with
1214         // the declaration.
1215         IProblem.IncompatibleReturnType, new String[]{methodSignatures
1216             .toString()}, new String[]{shortSignatures.toString()}, type
1217             .sourceStart(), type.sourceEnd());
1218   }
1219   public void initializerMustCompleteNormally(FieldDeclaration fieldDecl) {
1220     this.handle(IProblem.InitializerMustCompleteNormally, NoArgument,
1221         NoArgument, fieldDecl.sourceStart, fieldDecl.sourceEnd);
1222   }
1223   public void innerTypesCannotDeclareStaticInitializers(
1224       ReferenceBinding innerType, AstNode location) {
1225     this.handle(IProblem.CannotDefineStaticInitializerInLocalType,
1226         new String[]{new String(innerType.readableName())},
1227         new String[]{new String(innerType.shortReadableName())},
1228         location.sourceStart, location.sourceEnd);
1229   }
1230   public void interfaceCannotHaveConstructors(ConstructorDeclaration constructor) {
1231     this.handle(IProblem.InterfaceCannotHaveConstructors, NoArgument,
1232         NoArgument, constructor.sourceStart, constructor.sourceEnd,
1233         constructor, constructor.compilationResult());
1234   }
1235   public void interfaceCannotHaveInitializers(SourceTypeBinding type,
1236       FieldDeclaration fieldDecl) {
1237     String[] arguments = new String[]{new String(type.sourceName())};
1238     this.handle(IProblem.InterfaceCannotHaveInitializers, arguments, arguments,
1239         fieldDecl.sourceStart, fieldDecl.sourceEnd);
1240   }
1241   public void invalidBreak(AstNode location) {
1242     this.handle(IProblem.InvalidBreak, NoArgument, NoArgument,
1243         location.sourceStart, location.sourceEnd);
1244   }
1245   public void invalidConstructor(Statement statement,
1246       MethodBinding targetConstructor) {
1247     boolean insideDefaultConstructor = (referenceContext instanceof ConstructorDeclaration)
1248         && ((ConstructorDeclaration) referenceContext).isDefaultConstructor();
1249     boolean insideImplicitConstructorCall = (statement instanceof ExplicitConstructorCall)
1250         && (((ExplicitConstructorCall) statement).accessMode == ExplicitConstructorCall.ImplicitSuper);
1251     int flag = IProblem.UndefinedConstructor; //default...
1252     switch (targetConstructor.problemId()) {
1253       case NotFound :
1254         if (insideDefaultConstructor) {
1255           flag = IProblem.UndefinedConstructorInDefaultConstructor;
1256         } else if (insideImplicitConstructorCall) {
1257           flag = IProblem.UndefinedConstructorInImplicitConstructorCall;
1258         } else {
1259           flag = IProblem.UndefinedConstructor;
1260         }
1261         break;
1262       case NotVisible :
1263         if (insideDefaultConstructor) {
1264           flag = IProblem.NotVisibleConstructorInDefaultConstructor;
1265         } else if (insideImplicitConstructorCall) {
1266           flag = IProblem.NotVisibleConstructorInImplicitConstructorCall;
1267         } else {
1268           flag = IProblem.NotVisibleConstructor;
1269         }
1270         break;
1271       case Ambiguous :
1272         if (insideDefaultConstructor) {
1273           flag = IProblem.AmbiguousConstructorInDefaultConstructor;
1274         } else if (insideImplicitConstructorCall) {
1275           flag = IProblem.AmbiguousConstructorInImplicitConstructorCall;
1276         } else {
1277           flag = IProblem.AmbiguousConstructor;
1278         }
1279         break;
1280       case NoError :
1281       // 0
1282       default :
1283         needImplementation(); // want to fail to see why we were
1284         // here...
1285         break;
1286     }
1287     this.handle(flag, new String[]{
1288         new String(targetConstructor.declaringClass.readableName()),
1289         parametersAsString(targetConstructor)}, new String[]{
1290         new String(targetConstructor.declaringClass.shortReadableName()),
1291         parametersAsShortString(targetConstructor)}, statement.sourceStart,
1292         statement.sourceEnd);
1293   }
1294   public void invalidContinue(AstNode location) {
1295     this.handle(IProblem.InvalidContinue, NoArgument, NoArgument,
1296         location.sourceStart, location.sourceEnd);
1297   }
1298   public void invalidEnclosingType(Expression expression, TypeBinding type,
1299       ReferenceBinding enclosingType) {
1300     if (enclosingType.isAnonymousType())
1301       enclosingType = enclosingType.superclass();
1302     int flag = IProblem.UndefinedType; // default
1303     switch (type.problemId()) {
1304       case NotFound :
1305         // 1
1306         flag = IProblem.UndefinedType;
1307         break;
1308       case NotVisible :
1309         // 2
1310         flag = IProblem.NotVisibleType;
1311         break;
1312       case Ambiguous :
1313         // 3
1314         flag = IProblem.AmbiguousType;
1315         break;
1316       case InternalNameProvided :
1317         flag = IProblem.InternalTypeNameProvided;
1318         break;
1319       case NoError :
1320       // 0
1321       default :
1322         needImplementation(); // want to fail to see why we were
1323         // here...
1324         break;
1325     }
1326     this.handle(flag, new String[]{new String(enclosingType.readableName())
1327         + "." + new String(type.readableName())}, //$NON-NLS-1$
1328         new String[]{new String(enclosingType.shortReadableName()) + "."
1329             + new String(type.shortReadableName())}, //$NON-NLS-1$
1330         expression.sourceStart, expression.sourceEnd);
1331   }
1332   public void invalidExpressionAsStatement(Expression expression) {
1333     this.handle(IProblem.InvalidExpressionAsStatement, NoArgument, NoArgument,
1334         expression.sourceStart, expression.sourceEnd);
1335   }
1336   public void invalidField(FieldReference fieldRef, TypeBinding searchedType) {
1337     int severity = Error;
1338     int flag = IProblem.UndefinedField;
1339     FieldBinding field = fieldRef.binding;
1340     switch (field.problemId()) {
1341       case NotFound :
1342         flag = IProblem.UndefinedField;
1343         /*
1344          * also need to check that the searchedType is the receiver type if
1345          * (searchedType.isHierarchyInconsistent()) severity = SecondaryError;
1346          */
1347         break;
1348       case NotVisible :
1349         flag = IProblem.NotVisibleField;
1350         break;
1351       case Ambiguous :
1352         flag = IProblem.AmbiguousField;
1353         break;
1354       case NonStaticReferenceInStaticContext :
1355         flag = IProblem.NonStaticFieldFromStaticInvocation;
1356         break;
1357       case NonStaticReferenceInConstructorInvocation :
1358         flag = IProblem.InstanceFieldDuringConstructorInvocation;
1359         break;
1360       case InheritedNameHidesEnclosingName :
1361         flag = IProblem.InheritedFieldHidesEnclosingName;
1362         break;
1363       case ReceiverTypeNotVisible :
1364         this.handle(IProblem.NotVisibleType, new String[]{new String(
1365             searchedType.leafComponentType().readableName())},
1366             new String[]{new String(searchedType.leafComponentType()
1367                 .shortReadableName())}, fieldRef.receiver.sourceStart,
1368             fieldRef.receiver.sourceEnd);
1369         return;
1370       case NoError :
1371       // 0
1372       default :
1373         needImplementation(); // want to fail to see why we were
1374         // here...
1375         break;
1376     }
1377     String[] arguments = new String[]{new String(field.readableName())};
1378     this.handle(flag, arguments, arguments, severity, fieldRef.sourceStart,
1379         fieldRef.sourceEnd);
1380   }
1381   public void invalidField(NameReference nameRef, FieldBinding field) {
1382     int flag = IProblem.UndefinedField;
1383     switch (field.problemId()) {
1384       case NotFound :
1385         flag = IProblem.UndefinedField;
1386         break;
1387       case NotVisible :
1388         flag = IProblem.NotVisibleField;
1389         break;
1390       case Ambiguous :
1391         flag = IProblem.AmbiguousField;
1392         break;
1393       case NonStaticReferenceInStaticContext :
1394         flag = IProblem.NonStaticFieldFromStaticInvocation;
1395         break;
1396       case NonStaticReferenceInConstructorInvocation :
1397         flag = IProblem.InstanceFieldDuringConstructorInvocation;
1398         break;
1399       case InheritedNameHidesEnclosingName :
1400         flag = IProblem.InheritedFieldHidesEnclosingName;
1401         break;
1402       case ReceiverTypeNotVisible :
1403         this.handle(IProblem.NotVisibleType, new String[]{new String(
1404             field.declaringClass.leafComponentType().readableName())},
1405             new String[]{new String(field.declaringClass.leafComponentType()
1406                 .shortReadableName())}, nameRef.sourceStart, nameRef.sourceEnd);
1407         return;
1408       case NoError :
1409       // 0
1410       default :
1411         needImplementation(); // want to fail to see why we were
1412         // here...
1413         break;
1414     }
1415     String[] arguments = new String[]{new String(field.readableName())};
1416     this.handle(flag, arguments, arguments, nameRef.sourceStart,
1417         nameRef.sourceEnd);
1418   }
1419   public void invalidField(QualifiedNameReference nameRef, FieldBinding field,
1420       int index, TypeBinding searchedType) {
1421     //the resolution of the index-th field of qname failed
1422     //qname.otherBindings[index] is the binding that has produced the
1423     // error
1424     //The different targetted errors should be :
1425     //UndefinedField
1426     //NotVisibleField
1427     //AmbiguousField
1428     if (searchedType.isBaseType()) {
1429       this.handle(IProblem.NoFieldOnBaseType, new String[]{
1430           new String(searchedType.readableName()),
1431           CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0,
1432               index)), new String(nameRef.tokens[index])}, new String[]{
1433           new String(searchedType.sourceName()),
1434           CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0,
1435               index)), new String(nameRef.tokens[index])}, nameRef.sourceStart,
1436           nameRef.sourceEnd);
1437       return;
1438     }
1439     int flag = IProblem.UndefinedField;
1440     switch (field.problemId()) {
1441       case NotFound :
1442         flag = IProblem.UndefinedField;
1443         /*
1444          * also need to check that the searchedType is the receiver type if
1445          * (searchedType.isHierarchyInconsistent()) severity = SecondaryError;
1446          */
1447         break;
1448       case NotVisible :
1449         flag = IProblem.NotVisibleField;
1450         break;
1451       case Ambiguous :
1452         flag = IProblem.AmbiguousField;
1453         break;
1454       case NonStaticReferenceInStaticContext :
1455         flag = IProblem.NonStaticFieldFromStaticInvocation;
1456         break;
1457       case NonStaticReferenceInConstructorInvocation :
1458         flag = IProblem.InstanceFieldDuringConstructorInvocation;
1459         break;
1460       case InheritedNameHidesEnclosingName :
1461         flag = IProblem.InheritedFieldHidesEnclosingName;
1462         break;
1463       case ReceiverTypeNotVisible :
1464         this.handle(IProblem.NotVisibleType, new String[]{new String(
1465             searchedType.leafComponentType().readableName())},
1466             new String[]{new String(searchedType.leafComponentType()
1467                 .shortReadableName())}, nameRef.sourceStart, nameRef.sourceEnd);
1468         return;
1469       case NoError :
1470       // 0
1471       default :
1472         needImplementation(); // want to fail to see why we were
1473         // here...
1474         break;
1475     }
1476     String[] arguments = new String[]{CharOperation.toString(CharOperation
1477         .subarray(nameRef.tokens, 0, index + 1))};
1478     this.handle(flag, arguments, arguments, nameRef.sourceStart,
1479         nameRef.sourceEnd);
1480   }
1481   public void invalidMethod(MessageSend messageSend, MethodBinding method) {
1482     // CODE should be UPDATED according to error coding in the different
1483     // method binding errors
1484     // The different targetted errors should be :
1485     //  UndefinedMethod
1486     //  NotVisibleMethod
1487     //  AmbiguousMethod
1488     //  InheritedNameHidesEnclosingName
1489     //  InstanceMethodDuringConstructorInvocation
1490     // StaticMethodRequested
1491     int flag = IProblem.UndefinedMethod; //default...
1492     switch (method.problemId()) {
1493       case NotFound :
1494         flag = IProblem.UndefinedMethod;
1495         break;
1496       case NotVisible :
1497         flag = IProblem.NotVisibleMethod;
1498         break;
1499       case Ambiguous :
1500         flag = IProblem.AmbiguousMethod;
1501         break;
1502       case InheritedNameHidesEnclosingName :
1503         flag = IProblem.InheritedMethodHidesEnclosingName;
1504         break;
1505       case NonStaticReferenceInConstructorInvocation :
1506         flag = IProblem.InstanceMethodDuringConstructorInvocation;
1507         break;
1508       case NonStaticReferenceInStaticContext :
1509         flag = IProblem.StaticMethodRequested;
1510         break;
1511       case ReceiverTypeNotVisible :
1512         this.handle(IProblem.NotVisibleType, new String[]{new String(
1513             method.declaringClass.leafComponentType().readableName())},
1514             new String[]{new String(method.declaringClass.leafComponentType()
1515                 .shortReadableName())}, messageSend.receiver.sourceStart,
1516             messageSend.receiver.sourceEnd);
1517         return;
1518       case NoError :
1519       // 0
1520       default :
1521         needImplementation(); // want to fail to see why we were
1522         // here...
1523         break;
1524     }
1525     if (flag == IProblem.UndefinedMethod) {
1526       ProblemMethodBinding problemMethod = (ProblemMethodBinding) method;
1527       if (problemMethod.closestMatch != null) {
1528         String closestParameterTypeNames = parametersAsString(problemMethod.closestMatch);
1529         String parameterTypeNames = parametersAsString(method);
1530         String closestParameterTypeShortNames = parametersAsShortString(problemMethod.closestMatch);
1531         String parameterTypeShortNames = parametersAsShortString(method);
1532         if (closestParameterTypeShortNames.equals(parameterTypeShortNames)) {
1533           closestParameterTypeShortNames = closestParameterTypeNames;
1534           parameterTypeShortNames = parameterTypeNames;
1535         }
1536         this.handle(IProblem.ParameterMismatch,
1537             new String[]{
1538                 new String(problemMethod.closestMatch.declaringClass
1539                     .readableName()),
1540                 new String(problemMethod.closestMatch.selector),
1541                 closestParameterTypeNames, parameterTypeNames}, new String[]{
1542                 new String(problemMethod.closestMatch.declaringClass
1543                     .shortReadableName()),
1544                 new String(problemMethod.closestMatch.selector),
1545                 closestParameterTypeShortNames, parameterTypeShortNames},
1546             (int) (messageSend.nameSourcePosition >>> 32),
1547             (int) messageSend.nameSourcePosition);
1548         return;
1549       }
1550     }
1551     this.handle(flag, new String[]{
1552         new String(method.declaringClass.readableName()),
1553         new String(method.selector), parametersAsString(method)}, new String[]{
1554         new String(method.declaringClass.shortReadableName()),
1555         new String(method.selector), parametersAsShortString(method)},
1556         (int) (messageSend.nameSourcePosition >>> 32),
1557         (int) messageSend.nameSourcePosition);
1558   }
1559   public void invalidNullToSynchronize(Expression expression) {
1560     this.handle(IProblem.InvalidNullToSynchronized, NoArgument, NoArgument,
1561         expression.sourceStart, expression.sourceEnd);
1562   }
1563   public void invalidOperator(BinaryExpression expression,
1564       TypeBinding leftType, TypeBinding rightType) {
1565     String leftName = new String(leftType.readableName());
1566     String rightName = new String(rightType.readableName());
1567     String leftShortName = new String(leftType.shortReadableName());
1568     String rightShortName = new String(rightType.shortReadableName());
1569     if (leftShortName.equals(rightShortName)) {
1570       leftShortName = leftName;
1571       rightShortName = rightName;
1572     }
1573     this.handle(IProblem.InvalidOperator, new String[]{
1574         expression.operatorToString(), leftName + ", " + rightName}, //$NON-NLS-1$
1575         new String[]{expression.operatorToString(),
1576             leftShortName + ", " + rightShortName}, //$NON-NLS-1$
1577         expression.sourceStart, expression.sourceEnd);
1578   }
1579   public void invalidOperator(CompoundAssignment assign, TypeBinding leftType,
1580       TypeBinding rightType) {
1581     String leftName = new String(leftType.readableName());
1582     String rightName = new String(rightType.readableName());
1583     String leftShortName = new String(leftType.shortReadableName());
1584     String rightShortName = new String(rightType.shortReadableName());
1585     if (leftShortName.equals(rightShortName)) {
1586       leftShortName = leftName;
1587       rightShortName = rightName;
1588     }
1589     this.handle(IProblem.InvalidOperator, new String[]{
1590         assign.operatorToString(), leftName + ", " + rightName}, //$NON-NLS-1$
1591         new String[]{assign.operatorToString(),
1592             leftShortName + ", " + rightShortName}, //$NON-NLS-1$
1593         assign.sourceStart, assign.sourceEnd);
1594   }
1595   public void invalidOperator(UnaryExpression expression, TypeBinding type) {
1596     this.handle(IProblem.InvalidOperator, new String[]{
1597         expression.operatorToString(), new String(type.readableName())},
1598         new String[]{expression.operatorToString(),
1599             new String(type.shortReadableName())}, expression.sourceStart,
1600         expression.sourceEnd);
1601   }
1602   public void invalidParenthesizedExpression(AstNode reference) {
1603     this.handle(IProblem.InvalidParenthesizedExpression, NoArgument,
1604         NoArgument, reference.sourceStart, reference.sourceEnd);
1605   }
1606   public void invalidSuperclass(SourceTypeBinding type,
1607       TypeReference superclassRef, ReferenceBinding expectedType) {
1608     int problemId = expectedType.problemId();
1609     int id;
1610     switch (problemId) {
1611       case NotFound :
1612         // 1
1613         id = IProblem.SuperclassNotFound;
1614         break;
1615       case NotVisible :
1616         // 2
1617         id = IProblem.SuperclassNotVisible;
1618         break;
1619       case Ambiguous :
1620         // 3
1621         id = IProblem.SuperclassAmbiguous;
1622         break;
1623       case InternalNameProvided :
1624         // 4
1625         id = IProblem.SuperclassInternalNameProvided;
1626         break;
1627       case InheritedNameHidesEnclosingName :
1628         // 5
1629         id = IProblem.SuperclassInheritedNameHidesEnclosingName;
1630         break;
1631       case NoError :
1632       // 0
1633       default :
1634         needImplementation(); // want to fail to see why we were
1635         // here...
1636         return;
1637     }
1638     this.handle(id, new String[]{new String(expectedType.readableName()),
1639         new String(type.sourceName())}, new String[]{
1640         new String(expectedType.shortReadableName()),
1641         new String(type.sourceName())}, superclassRef.sourceStart,
1642         superclassRef.sourceEnd);
1643   }
1644   public void invalidSuperinterface(SourceTypeBinding type,
1645       TypeReference superinterfaceRef, ReferenceBinding expectedType) {
1646     int problemId = expectedType.problemId();
1647     int id;
1648     switch (problemId) {
1649       case NotFound :
1650         // 1
1651         id = IProblem.InterfaceNotFound;
1652         break;
1653       case NotVisible :
1654         // 2
1655         id = IProblem.InterfaceNotVisible;
1656         break;
1657       case Ambiguous :
1658         // 3
1659         id = IProblem.InterfaceAmbiguous;
1660         break;
1661       case InternalNameProvided :
1662         // 4
1663         id = IProblem.InterfaceInternalNameProvided;
1664         break;
1665       case InheritedNameHidesEnclosingName :
1666         // 5
1667         id = IProblem.InterfaceInheritedNameHidesEnclosingName;
1668         break;
1669       case NoError :
1670       // 0
1671       default :
1672         needImplementation(); // want to fail to see why we were
1673         // here...
1674         return;
1675     }
1676     this.handle(id, new String[]{new String(expectedType.readableName()),
1677         new String(type.sourceName())}, new String[]{
1678         new String(expectedType.shortReadableName()),
1679         new String(type.sourceName())}, superinterfaceRef.sourceStart,
1680         superinterfaceRef.sourceEnd);
1681   }
1682   public void invalidType(AstNode location, TypeBinding type) {
1683     int flag = IProblem.UndefinedType; // default
1684     switch (type.problemId()) {
1685       case NotFound :
1686         flag = IProblem.UndefinedType;
1687         break;
1688       case NotVisible :
1689         flag = IProblem.NotVisibleType;
1690         break;
1691       case Ambiguous :
1692         flag = IProblem.AmbiguousType;
1693         break;
1694       case InternalNameProvided :
1695         flag = IProblem.InternalTypeNameProvided;
1696         break;
1697       case InheritedNameHidesEnclosingName :
1698         flag = IProblem.InheritedTypeHidesEnclosingName;
1699         break;
1700       case NoError :
1701       // 0
1702       default :
1703         needImplementation(); // want to fail to see why we were
1704         // here...
1705         break;
1706     }
1707     this.handle(flag, new String[]{new String(type.readableName())},
1708         new String[]{new String(type.shortReadableName())},
1709         location.sourceStart, location.sourceEnd);
1710   }
1711   public void invalidTypeReference(Expression expression) {
1712     this.handle(IProblem.InvalidTypeExpression, NoArgument, NoArgument,
1713         expression.sourceStart, expression.sourceEnd);
1714   }
1715   public void invalidTypeToSynchronize(Expression expression, TypeBinding type) {
1716     this.handle(IProblem.InvalidTypeToSynchronized, new String[]{new String(
1717         type.readableName())},
1718         new String[]{new String(type.shortReadableName())},
1719         expression.sourceStart, expression.sourceEnd);
1720   }
1721   public void invalidUnaryExpression(Expression expression) {
1722     this.handle(IProblem.InvalidUnaryExpression, NoArgument, NoArgument,
1723         expression.sourceStart, expression.sourceEnd);
1724   }
1725   public void isClassPathCorrect(char[][] wellKnownTypeName,
1726       CompilationUnitDeclaration compUnitDecl) {
1727     referenceContext = compUnitDecl;
1728     String[] arguments = new String[]{CharOperation.toString(wellKnownTypeName)};
1729     this.handle(IProblem.IsClassPathCorrect, arguments, arguments,
1730         AbortCompilation | Error, compUnitDecl == null
1731             ? 0
1732             : compUnitDecl.sourceStart, compUnitDecl == null
1733             ? 1
1734             : compUnitDecl.sourceEnd);
1735   }
1736   public void maskedExceptionHandler(ReferenceBinding exceptionType,
1737       AstNode location) {
1738     this.handle(IProblem.MaskedCatch, NoArgument, NoArgument,
1739         location.sourceStart, location.sourceEnd);
1740   }
1741   public void methodNeedingAbstractModifier(MethodDeclaration methodDecl) {
1742     this.handle(IProblem.MethodRequiresBody, NoArgument, NoArgument,
1743         methodDecl.sourceStart, methodDecl.sourceEnd);
1744   }
1745   public void methodNeedingNoBody(MethodDeclaration methodDecl) {
1746     this.handle(
1747     //          ((methodDecl.modifiers & CompilerModifiers.AccNative) != 0) ?
1748         // IProblem.BodyForNativeMethod : IProblem.BodyForAbstractMethod,
1749         IProblem.BodyForAbstractMethod, NoArgument, NoArgument,
1750         methodDecl.sourceStart, methodDecl.sourceEnd);
1751   }
1752   public void methodWithConstructorName(MethodDeclaration methodDecl) {
1753     this.handle(IProblem.MethodButWithConstructorName, NoArgument, NoArgument,
1754         methodDecl.sourceStart, methodDecl.sourceEnd);
1755   }
1756   //public void missingEnclosingInstanceSpecification(ReferenceBinding
1757   // enclosingType, AstNode location) {
1758   //    boolean insideConstructorCall =
1759   //            (location instanceof ExplicitConstructorCall)
1760   //                    && (((ExplicitConstructorCall) location).accessMode ==
1761   // ExplicitConstructorCall.ImplicitSuper);
1762   //
1763   //    this.handle(
1764   //            insideConstructorCall
1765   //                    ? IProblem.MissingEnclosingInstanceForConstructorCall
1766   //                    : IProblem.MissingEnclosingInstance,
1767   //            new String[] {new String(enclosingType.readableName())},
1768   //            new String[] {new String(enclosingType.shortReadableName())},
1769   //            location.sourceStart,
1770   //            location.sourceEnd);
1771   //}
1772   public void missingReturnType(AbstractMethodDeclaration methodDecl) {
1773     this.handle(IProblem.MissingReturnType, NoArgument, NoArgument,
1774         methodDecl.sourceStart, methodDecl.sourceEnd);
1775   }
1776   public void missingSemiColon(Expression expression) {
1777     this.handle(IProblem.MissingSemiColon, NoArgument, NoArgument,
1778         expression.sourceStart, expression.sourceEnd);
1779   }
1780   public void mustDefineDimensionsOrInitializer(
1781       ArrayAllocationExpression expression) {
1782     this.handle(IProblem.MustDefineEitherDimensionExpressionsOrInitializer,
1783         NoArgument, NoArgument, expression.sourceStart, expression.sourceEnd);
1784   }
1785   public void mustSpecifyPackage(CompilationUnitDeclaration compUnitDecl) {
1786     String[] arguments = new String[]{new String(compUnitDecl.getFileName())};
1787     this.handle(IProblem.MustSpecifyPackage, arguments, arguments,
1788         compUnitDecl.sourceStart, compUnitDecl.sourceStart + 1);
1789   }
1790   public void mustUseAStaticMethod(MessageSend messageSend, MethodBinding method) {
1791     this.handle(IProblem.StaticMethodRequested, new String[]{
1792         new String(method.declaringClass.readableName()),
1793         new String(method.selector), parametersAsString(method)}, new String[]{
1794         new String(method.declaringClass.shortReadableName()),
1795         new String(method.selector), parametersAsShortString(method)},
1796         messageSend.sourceStart, messageSend.sourceEnd);
1797   }
1798   public void nativeMethodsCannotBeStrictfp(ReferenceBinding type,
1799       AbstractMethodDeclaration methodDecl) {
1800     String[] arguments = new String[]{new String(type.sourceName()),
1801         new String(methodDecl.selector)};
1802     this.handle(IProblem.NativeMethodsCannotBeStrictfp, arguments, arguments,
1803         methodDecl.sourceStart, methodDecl.sourceEnd);
1804   }
1805   public void needImplementation() {
1806     this.abortDueToInternalError(Util.bind("abort.missingCode")); //$NON-NLS-1$
1807   }
1808   public void needToEmulateFieldReadAccess(FieldBinding field, AstNode location) {
1809     this.handle(IProblem.NeedToEmulateFieldReadAccess,
1810         new String[]{new String(field.declaringClass.readableName()),
1811             new String(field.name)}, new String[]{
1812             new String(field.declaringClass.shortReadableName()),
1813             new String(field.name)}, location.sourceStart, location.sourceEnd);
1814   }
1815   public void needToEmulateFieldWriteAccess(FieldBinding field, AstNode location) {
1816     this.handle(IProblem.NeedToEmulateFieldWriteAccess,
1817         new String[]{new String(field.declaringClass.readableName()),
1818             new String(field.name)}, new String[]{
1819             new String(field.declaringClass.shortReadableName()),
1820             new String(field.name)}, location.sourceStart, location.sourceEnd);
1821   }
1822   public void needToEmulateMethodAccess(MethodBinding method, AstNode location) {
1823     if (method.isConstructor())
1824       this.handle(IProblem.NeedToEmulateConstructorAccess, new String[]{
1825           new String(method.declaringClass.readableName()),
1826           parametersAsString(method)}, new String[]{
1827           new String(method.declaringClass.shortReadableName()),
1828           parametersAsShortString(method)}, location.sourceStart,
1829           location.sourceEnd);
1830     else
1831       this.handle(IProblem.NeedToEmulateMethodAccess, new String[]{
1832           new String(method.declaringClass.readableName()),
1833           new String(method.selector), parametersAsString(method)},
1834           new String[]{new String(method.declaringClass.shortReadableName()),
1835               new String(method.selector), parametersAsShortString(method)},
1836           location.sourceStart, location.sourceEnd);
1837   }
1838   public void nestedClassCannotDeclareInterface(TypeDeclaration typeDecl) {
1839     String[] arguments = new String[]{new String(typeDecl.name)};
1840     this.handle(IProblem.CannotDefineInterfaceInLocalType, arguments,
1841         arguments, typeDecl.sourceStart, typeDecl.sourceEnd);
1842   }
1843   public void noMoreAvailableSpaceForArgument(LocalVariableBinding local,
1844       AstNode location) {
1845     String[] arguments = new String[]{new String(local.name)};
1846     this.handle(local instanceof SyntheticArgumentBinding
1847         ? IProblem.TooManySyntheticArgumentSlots
1848         : IProblem.TooManyArgumentSlots, arguments, arguments, Abort | Error,
1849         location.sourceStart, location.sourceEnd);
1850   }
1851   public void noMoreAvailableSpaceForLocal(LocalVariableBinding local,
1852       AstNode location) {
1853     String[] arguments = new String[]{new String(local.name)};
1854     this.handle(IProblem.TooManyLocalVariableSlots, arguments, arguments, Abort
1855         | Error, location.sourceStart, location.sourceEnd);
1856   }
1857   public void noSuchEnclosingInstance(TypeBinding targetType, AstNode location,
1858       boolean isConstructorCall) {
1859     int id;
1860     if (isConstructorCall) {
1861       //28 = No enclosing instance of type {0} is available due to some
1862       // intermediate constructor invocation
1863       id = IProblem.EnclosingInstanceInConstructorCall;
1864     } else if ((location instanceof ExplicitConstructorCall)
1865         && ((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper) {
1866       //20 = No enclosing instance of type {0} is accessible to invoke
1867       // the super constructor. Must define a constructor and explicitly
1868       // qualify its super constructor invocation with an instance of {0}
1869       // (e.g. x.super() where x is an instance of {0}).
1870       id = IProblem.MissingEnclosingInstanceForConstructorCall;
1871     } else if (location instanceof AllocationExpression
1872         && (((AllocationExpression) location).binding.declaringClass
1873             .isMemberType() || (((AllocationExpression) location).binding.declaringClass
1874             .isAnonymousType() && ((AllocationExpression) location).binding.declaringClass
1875             .superclass().isMemberType()))) {
1876       //21 = No enclosing instance of type {0} is accessible. Must
1877       // qualify the allocation with an enclosing instance of type {0}
1878       // (e.g. x.new A() where x is an instance of {0}).
1879       id = IProblem.MissingEnclosingInstance;
1880     } else { // default
1881       //22 = No enclosing instance of the type {0} is accessible in
1882       // scope
1883       id = IProblem.IncorrectEnclosingInstanceReference;
1884     }
1885     this.handle(id, new String[]{new String(targetType.readableName())},
1886         new String[]{new String(targetType.shortReadableName())},
1887         location.sourceStart, location.sourceEnd);
1888   }
1889   public void notCompatibleTypesError(EqualExpression expression,
1890       TypeBinding leftType, TypeBinding rightType) {
1891     String leftName = new String(leftType.readableName());
1892     String rightName = new String(rightType.readableName());
1893     String leftShortName = new String(leftType.shortReadableName());
1894     String rightShortName = new String(rightType.shortReadableName());
1895     if (leftShortName.equals(rightShortName)) {
1896       leftShortName = leftName;
1897       rightShortName = rightName;
1898     }
1899     this.handle(IProblem.IncompatibleTypesInEqualityOperator, new String[]{
1900         leftName, rightName}, new String[]{leftShortName, rightShortName},
1901         expression.sourceStart, expression.sourceEnd);
1902   }
1903   public void notCompatibleTypesError(InstanceOfExpression expression,
1904       TypeBinding leftType, TypeBinding rightType) {
1905     String leftName = new String(leftType.readableName());
1906     String rightName = new String(rightType.readableName());
1907     String leftShortName = new String(leftType.shortReadableName());
1908     String rightShortName = new String(rightType.shortReadableName());
1909     if (leftShortName.equals(rightShortName)) {
1910       leftShortName = leftName;
1911       rightShortName = rightName;
1912     }
1913     this.handle(IProblem.IncompatibleTypesInConditionalOperator, new String[]{
1914         leftName, rightName}, new String[]{leftShortName, rightShortName},
1915         expression.sourceStart, expression.sourceEnd);
1916   }
1917   public void objectCannotHaveSuperTypes(SourceTypeBinding type) {
1918     this.handle(IProblem.ObjectCannotHaveSuperTypes, NoArgument, NoArgument,
1919         type.sourceStart(), type.sourceEnd());
1920   }
1921   public void operatorOnlyValidOnNumericType(CompoundAssignment assignment,
1922       TypeBinding leftType, TypeBinding rightType) {
1923     String leftName = new String(leftType.readableName());
1924     String rightName = new String(rightType.readableName());
1925     String leftShortName = new String(leftType.shortReadableName());
1926     String rightShortName = new String(rightType.shortReadableName());
1927     if (leftShortName.equals(rightShortName)) {
1928       leftShortName = leftName;
1929       rightShortName = rightName;
1930     }
1931     this.handle(IProblem.TypeMismatch, new String[]{leftName, rightName},
1932         new String[]{leftShortName, rightShortName}, assignment.sourceStart,
1933         assignment.sourceEnd);
1934   }
1935   public void overridesDeprecatedMethod(MethodBinding localMethod,
1936       MethodBinding inheritedMethod) {
1937     this.handle(IProblem.OverridingDeprecatedMethod, new String[]{
1938         new String(CharOperation.concat(localMethod.declaringClass
1939             .readableName(), localMethod.readableName(), '.')),
1940         new String(inheritedMethod.declaringClass.readableName())},
1941         new String[]{
1942             new String(CharOperation.concat(localMethod.declaringClass
1943                 .shortReadableName(), localMethod.shortReadableName(), '.')),
1944             new String(inheritedMethod.declaringClass.shortReadableName())},
1945         localMethod.sourceStart(), localMethod.sourceEnd());
1946   }
1947   public void overridesPackageDefaultMethod(MethodBinding localMethod,
1948       MethodBinding inheritedMethod) {
1949     this.handle(IProblem.OverridingNonVisibleMethod, new String[]{
1950         new String(CharOperation.concat(localMethod.declaringClass
1951             .readableName(), localMethod.readableName(), '.')),
1952         new String(inheritedMethod.declaringClass.readableName())},
1953         new String[]{
1954             new String(CharOperation.concat(localMethod.declaringClass
1955                 .shortReadableName(), localMethod.shortReadableName(), '.')),
1956             new String(inheritedMethod.declaringClass.shortReadableName())},
1957         localMethod.sourceStart(), localMethod.sourceEnd());
1958   }
1959   public void packageCollidesWithType(CompilationUnitDeclaration compUnitDecl) {
1960     String[] arguments = new String[]{CharOperation
1961         .toString(compUnitDecl.currentPackage.tokens)};
1962     this.handle(IProblem.PackageCollidesWithType, arguments, arguments,
1963         compUnitDecl.currentPackage.sourceStart,
1964         compUnitDecl.currentPackage.sourceEnd);
1965   }
1966   public void packageIsNotExpectedPackage(
1967       CompilationUnitDeclaration compUnitDecl) {
1968     String[] arguments = new String[]{CharOperation
1969         .toString(compUnitDecl.compilationResult.compilationUnit
1970             .getPackageName())};
1971     this.handle(IProblem.PackageIsNotExpectedPackage, arguments, arguments,
1972         compUnitDecl.currentPackage == null
1973             ? 0
1974             : compUnitDecl.currentPackage.sourceStart,
1975         compUnitDecl.currentPackage == null
1976             ? 0
1977             : compUnitDecl.currentPackage.sourceEnd);
1978   }
1979   private String parametersAsString(MethodBinding method) {
1980     TypeBinding[] params = method.parameters;
1981     StringBuffer buffer = new StringBuffer();
1982     for (int i = 0, length = params.length; i < length; i++) {
1983       if (i != 0)
1984         buffer.append(", "); //$NON-NLS-1$
1985       buffer.append(new String(params[i].readableName()));
1986     }
1987     return buffer.toString();
1988   }
1989   private String parametersAsShortString(MethodBinding method) {
1990     TypeBinding[] params = method.parameters;
1991     StringBuffer buffer = new StringBuffer();
1992     for (int i = 0, length = params.length; i < length; i++) {
1993       if (i != 0)
1994         buffer.append(", "); //$NON-NLS-1$
1995       buffer.append(new String(params[i].shortReadableName()));
1996     }
1997     return buffer.toString();
1998   }
1999   public void parseError(int startPosition, int endPosition,
2000       char[] currentTokenSource, String errorTokenName, String[] possibleTokens) {
2001     if (possibleTokens.length == 0) { //no suggestion available
2002       if (isKeyword(currentTokenSource)) {
2003         String[] arguments = new String[]{new String(currentTokenSource)};
2004         this.handle(IProblem.ParsingErrorOnKeywordNoSuggestion, arguments,
2005             arguments, 
2006             // this is the current -invalid- token position
2007             startPosition, endPosition);
2008         return;
2009       } else {
2010         String[] arguments = new String[]{errorTokenName};
2011         this.handle(IProblem.ParsingErrorNoSuggestion, arguments, arguments, 
2012         // this is the current -invalid- token position
2013             startPosition, endPosition);
2014         return;
2015       }
2016     }
2017     //build a list of probable right tokens
2018     StringBuffer list = new StringBuffer(20);
2019     for (int i = 0, max = possibleTokens.length; i < max; i++) {
2020       if (i > 0)
2021         list.append(", "); //$NON-NLS-1$
2022       list.append('"');
2023       list.append(possibleTokens[i]);
2024       list.append('"');
2025     }
2026     if (isKeyword(currentTokenSource)) {
2027       String[] arguments = new String[]{new String(currentTokenSource),
2028           list.toString()};
2029       this.handle(IProblem.ParsingErrorOnKeyword, arguments, arguments, 
2030       // this is the current -invalid- token position
2031           startPosition, endPosition);
2032       return;
2033     }
2034     //extract the literal when it's a literal
2035     if ((errorTokenName.equals("IntegerLiteral")) || //$NON-NLS-1$
2036         (errorTokenName.equals("LongLiteral")) || //$NON-NLS-1$
2037         (errorTokenName.equals("FloatingPointLiteral")) || //$NON-NLS-1$
2038         (errorTokenName.equals("DoubleLiteral")) || //$NON-NLS-1$
2039         (errorTokenName.equals("StringLiteral")) || //$NON-NLS-1$
2040         (errorTokenName.equals("CharacterLiteral")) || //$NON-NLS-1$
2041         (errorTokenName.equals("Identifier"))) { //$NON-NLS-1$
2042       errorTokenName = new String(currentTokenSource);
2043     }
2044     String[] arguments = new String[]{errorTokenName, list.toString()};
2045     this.handle(IProblem.ParsingError, arguments, arguments, 
2046     // this is the current -invalid- token position
2047         startPosition, endPosition);
2048   }
2049   public void publicClassMustMatchFileName(
2050       CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
2051     this.referenceContext = typeDecl; // report the problem against the
2052     // type not the entire compilation
2053     // unit
2054     String[] arguments = new String[]{new String(compUnitDecl.getFileName()),
2055         new String(typeDecl.name)};
2056     this.handle(IProblem.PublicClassMustMatchFileName, arguments, arguments,
2057         typeDecl.sourceStart, typeDecl.sourceEnd,
2058         compUnitDecl.compilationResult);
2059   }
2060   public void recursiveConstructorInvocation(
2061       ExplicitConstructorCall constructorCall) {
2062     this.handle(IProblem.RecursiveConstructorInvocation, new String[]{
2063         new String(constructorCall.binding.declaringClass.readableName()),
2064         parametersAsString(constructorCall.binding)}, new String[]{
2065         new String(constructorCall.binding.declaringClass.shortReadableName()),
2066         parametersAsShortString(constructorCall.binding)},
2067         constructorCall.sourceStart, constructorCall.sourceEnd);
2068   }
2069   public void redefineArgument(Argument arg) {
2070     String[] arguments = new String[]{new String(arg.name)};
2071     this.handle(IProblem.RedefinedArgument, arguments, arguments,
2072         arg.sourceStart, arg.sourceEnd);
2073   }
2074   public void redefineLocal(LocalDeclaration localDecl) {
2075     String[] arguments = new String[]{new String(localDecl.name)};
2076     this.handle(IProblem.RedefinedLocal, arguments, arguments,
2077         localDecl.sourceStart, localDecl.sourceEnd);
2078   }
2079   public void referenceMustBeArrayTypeAt(TypeBinding arrayType,
2080       ArrayReference arrayRef) {
2081     this.handle(IProblem.ArrayReferenceRequired, new String[]{new String(
2082         arrayType.readableName())}, new String[]{new String(arrayType
2083         .shortReadableName())}, arrayRef.sourceStart, arrayRef.sourceEnd);
2084   }
2085   public void returnTypeCannotBeVoidArray(SourceTypeBinding type,
2086       MethodDeclaration methodDecl) {
2087     String[] arguments = new String[]{new String(methodDecl.selector)};
2088     this.handle(IProblem.ReturnTypeCannotBeVoidArray, arguments, arguments,
2089         methodDecl.sourceStart, methodDecl.sourceEnd);
2090   }
2091   public void returnTypeProblem(SourceTypeBinding type,
2092       MethodDeclaration methodDecl, TypeBinding expectedType) {
2093     int problemId = expectedType.problemId();
2094     int id;
2095     switch (problemId) {
2096       case NotFound :
2097         // 1
2098         id = IProblem.ReturnTypeNotFound;
2099         break;
2100       case NotVisible :
2101         // 2
2102         id = IProblem.ReturnTypeNotVisible;
2103         break;
2104       case Ambiguous :
2105         // 3
2106         id = IProblem.ReturnTypeAmbiguous;
2107         break;
2108       case InternalNameProvided :
2109         // 4
2110         id = IProblem.ReturnTypeInternalNameProvided;
2111         break;
2112       case InheritedNameHidesEnclosingName :
2113         // 5
2114         id = IProblem.ReturnTypeInheritedNameHidesEnclosingName;
2115         break;
2116       case NoError :
2117       // 0
2118       default :
2119         needImplementation(); // want to fail to see why we were
2120         // here...
2121         return;
2122     }
2123     this.handle(id, new String[]{new String(methodDecl.selector),
2124         new String(expectedType.readableName())}, new String[]{
2125         new String(methodDecl.selector),
2126         new String(expectedType.shortReadableName())},
2127         methodDecl.returnType.sourceStart, methodDecl.returnType.sourceEnd);
2128   }
2129   public void scannerError(Parser parser, String errorTokenName) {
2130     Scanner scanner = parser.scanner;
2131     int flag = IProblem.ParsingErrorNoSuggestion;
2132     int startPos = scanner.startPosition;
2133     //special treatment for recognized errors....
2134     if (errorTokenName.equals(Scanner.END_OF_SOURCE))
2135       flag = IProblem.EndOfSource;
2136     else if (errorTokenName.equals(Scanner.INVALID_HEXA))
2137       flag = IProblem.InvalidHexa;
2138     else if (errorTokenName.equals(Scanner.INVALID_OCTAL))
2139       flag = IProblem.InvalidOctal;
2140     else if (errorTokenName.equals(Scanner.INVALID_CHARACTER_CONSTANT))
2141       flag = IProblem.InvalidCharacterConstant;
2142     else if (errorTokenName.equals(Scanner.INVALID_ESCAPE))
2143       flag = IProblem.InvalidEscape;
2144     else if (errorTokenName.equals(Scanner.INVALID_UNICODE_ESCAPE)) {
2145       flag = IProblem.InvalidUnicodeEscape;
2146       // better locate the error message
2147       char[] source = scanner.source;
2148       int checkPos = scanner.currentPosition - 1;
2149       if (checkPos >= source.length)
2150         checkPos = source.length - 1;
2151       while (checkPos >= startPos) {
2152         if (source[checkPos] == '\\')
2153           break;
2154         checkPos--;
2155       }
2156       startPos = checkPos;
2157     } else if (errorTokenName.equals(Scanner.INVALID_FLOAT))
2158       flag = IProblem.InvalidFloat;
2159     else if (errorTokenName.equals(Scanner.UNTERMINATED_STRING))
2160       flag = IProblem.UnterminatedString;
2161     else if (errorTokenName.equals(Scanner.UNTERMINATED_COMMENT))
2162       flag = IProblem.UnterminatedComment;
2163     else if (errorTokenName.equals(Scanner.INVALID_CHAR_IN_STRING))
2164       flag = IProblem.UnterminatedString;
2165     String[] arguments = flag == IProblem.ParsingErrorNoSuggestion
2166         ? new String[]{errorTokenName}
2167         : NoArgument;
2168     this.handle(flag, arguments, arguments, 
2169     // this is the current -invalid- token position
2170         startPos, scanner.currentPosition - 1,
2171         parser.compilationUnit.compilationResult);
2172   }
2173   public void shouldReturn(TypeBinding returnType, AstNode location) {
2174     this.handle(IProblem.ShouldReturnValue, new String[]{new String(returnType
2175         .readableName())}, new String[]{new String(returnType
2176         .shortReadableName())}, location.sourceStart, location.sourceEnd);
2177   }
2178   public void signalNoImplicitStringConversionForCharArrayExpression(
2179       Expression expression) {
2180     this.handle(IProblem.NoImplicitStringConversionForCharArrayExpression,
2181         NoArgument, NoArgument, expression.sourceStart, expression.sourceEnd);
2182   }
2183   public void staticAndInstanceConflict(MethodBinding currentMethod,
2184       MethodBinding inheritedMethod) {
2185     if (currentMethod.isStatic())
2186       this
2187           .handle(
2188           // This static method cannot hide the instance method from %1
2189               // 8.4.6.4 - If a class inherits more than one method with
2190               // the same signature a static (non-abstract) method cannot
2191               // hide an instance method.
2192               IProblem.CannotHideAnInstanceMethodWithAStaticMethod,
2193               new String[]{new String(inheritedMethod.declaringClass
2194                   .readableName())}, new String[]{new String(
2195                   inheritedMethod.declaringClass.shortReadableName())},
2196               currentMethod.sourceStart(), currentMethod.sourceEnd());
2197     else
2198       this
2199           .handle(
2200           // This instance method cannot override the static method from %1
2201               // 8.4.6.4 - If a class inherits more than one method with
2202               // the same signature an instance (non-abstract) method
2203               // cannot override a static method.
2204               IProblem.CannotOverrideAStaticMethodWithAnInstanceMethod,
2205               new String[]{new String(inheritedMethod.declaringClass
2206                   .readableName())}, new String[]{new String(
2207                   inheritedMethod.declaringClass.shortReadableName())},
2208               currentMethod.sourceStart(), currentMethod.sourceEnd());
2209   }
2210   public void staticFieldAccessToNonStaticVariable(FieldReference fieldRef,
2211       FieldBinding field) {
2212     String[] arguments = new String[]{new String(field.readableName())};
2213     this.handle(IProblem.NonStaticFieldFromStaticInvocation, arguments,
2214         arguments, fieldRef.sourceStart, fieldRef.sourceEnd);
2215   }
2216   public void staticFieldAccessToNonStaticVariable(
2217       QualifiedNameReference nameRef, FieldBinding field) {
2218     String[] arguments = new String[]{new String(field.readableName())};
2219     this.handle(IProblem.NonStaticFieldFromStaticInvocation, arguments,
2220         arguments, nameRef.sourceStart, nameRef.sourceEnd);
2221   }
2222   public void staticFieldAccessToNonStaticVariable(SingleNameReference nameRef,
2223       FieldBinding field) {
2224     String[] arguments = new String[]{new String(field.readableName())};
2225     this.handle(IProblem.NonStaticFieldFromStaticInvocation, arguments,
2226         arguments, nameRef.sourceStart, nameRef.sourceEnd);
2227   }
2228   public void staticInheritedMethodConflicts(SourceTypeBinding type,
2229       MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
2230     this.handle(
2231     // The static method %1 conflicts with the abstract method in %2
2232         // 8.4.6.4 - If a class inherits more than one method with the
2233         // same signature it is an error for one to be static
2234         // (non-abstract) and the other abstract.
2235         IProblem.StaticInheritedMethodConflicts, new String[]{
2236             new String(concreteMethod.readableName()),
2237             new String(abstractMethods[0].declaringClass.readableName())},
2238         new String[]{new String(concreteMethod.readableName()),
2239             new String(abstractMethods[0].declaringClass.shortReadableName())},
2240         type.sourceStart(), type.sourceEnd());
2241   }
2242   public void stringConstantIsExceedingUtf8Limit(AstNode location) {
2243     this.handle(IProblem.StringConstantIsExceedingUtf8Limit, NoArgument,
2244         NoArgument, location.sourceStart, location.sourceEnd);
2245   }
2246   public void superclassMustBeAClass(SourceTypeBinding type,
2247       TypeReference superclassRef, ReferenceBinding superType) {
2248     this.handle(IProblem.SuperclassMustBeAClass, new String[]{
2249         new String(superType.readableName()), new String(type.sourceName())},
2250         new String[]{new String(superType.shortReadableName()),
2251             new String(type.sourceName())}, superclassRef.sourceStart,
2252         superclassRef.sourceEnd);
2253   }
2254   public void superinterfaceMustBeAnInterface(SourceTypeBinding type,
2255       TypeDeclaration typeDecl, ReferenceBinding superType) {
2256     this.handle(IProblem.SuperInterfaceMustBeAnInterface, new String[]{
2257         new String(superType.readableName()), new String(type.sourceName())},
2258         new String[]{new String(superType.shortReadableName()),
2259             new String(type.sourceName())}, typeDecl.sourceStart,
2260         typeDecl.sourceEnd);
2261   }
2262   public void task(String tag, String message, String priority, int start,
2263       int end) {
2264     this.handle(IProblem.Task, new String[]{tag, message, priority/*
2265                                                                    * secret
2266                                                                    * argument
2267                                                                    * that is
2268                                                                    * not
2269                                                                    * surfaced
2270                                                                    * in
2271                                                                    * getMessage()
2272                                                                    */}, new String[]{tag, message, priority/*
2273                                               * secret argument that is not
2274                                               * surfaced in getMessage()
2275                                               */}, start, end);
2276   }
2277   public void tooManyDimensions(AstNode expression) {
2278     this.handle(IProblem.TooManyArrayDimensions, NoArgument, NoArgument,
2279         expression.sourceStart, expression.sourceEnd);
2280   }
2281   public void tooManyFields(TypeDeclaration typeDeclaration) {
2282     this.handle(IProblem.TooManyFields, new String[]{new String(
2283         typeDeclaration.binding.readableName())}, new String[]{new String(
2284         typeDeclaration.binding.shortReadableName())}, Abort | Error,
2285         typeDeclaration.sourceStart, typeDeclaration.sourceEnd);
2286   }
2287   public void tooManyMethods(TypeDeclaration typeDeclaration) {
2288     this.handle(IProblem.TooManyMethods, new String[]{new String(
2289         typeDeclaration.binding.readableName())}, new String[]{new String(
2290         typeDeclaration.binding.shortReadableName())}, Abort | Error,
2291         typeDeclaration.sourceStart, typeDeclaration.sourceEnd);
2292   }
2293   public void typeCastError(CastExpression expression, TypeBinding leftType,
2294       TypeBinding rightType) {
2295     String leftName = new String(leftType.readableName());
2296     String rightName = new String(rightType.readableName());
2297     String leftShortName = new String(leftType.shortReadableName());
2298     String rightShortName = new String(rightType.shortReadableName());
2299     if (leftShortName.equals(rightShortName)) {
2300       leftShortName = leftName;
2301       rightShortName = rightName;
2302     }
2303     this.handle(IProblem.IllegalCast, new String[]{rightName, leftName},
2304         new String[]{rightShortName, leftShortName}, expression.sourceStart,
2305         expression.sourceEnd);
2306   }
2307   public void typeCollidesWithPackage(CompilationUnitDeclaration compUnitDecl,
2308       TypeDeclaration typeDecl) {
2309     this.referenceContext = typeDecl; // report the problem against the
2310     // type not the entire compilation
2311     // unit
2312     String[] arguments = new String[]{new String(compUnitDecl.getFileName()),
2313         new String(typeDecl.name)};
2314     this.handle(IProblem.TypeCollidesWithPackage, arguments, arguments,
2315         typeDecl.sourceStart, typeDecl.sourceEnd,
2316         compUnitDecl.compilationResult);
2317   }
2318   public void typeMismatchError(TypeBinding resultType,
2319       TypeBinding expectedType, AstNode location) {
2320     String resultTypeName = new String(resultType.readableName());
2321     String expectedTypeName = new String(expectedType.readableName());
2322     String resultTypeShortName = new String(resultType.shortReadableName());
2323     String expectedTypeShortName = new String(expectedType.shortReadableName());
2324     if (resultTypeShortName.equals(expectedTypeShortName)) {
2325       resultTypeShortName = resultTypeName;
2326       expectedTypeShortName = expectedTypeName;
2327     }
2328     this.handle(IProblem.TypeMismatch, new String[]{resultTypeName,
2329         expectedTypeName}, new String[]{resultTypeShortName,
2330         expectedTypeShortName}, location.sourceStart, location.sourceEnd);
2331   }
2332   public void typeMismatchErrorActualTypeExpectedType(Expression expression,
2333       TypeBinding constantType, TypeBinding expectedType) {
2334     String constantTypeName = new String(constantType.readableName());
2335     String expectedTypeName = new String(expectedType.readableName());
2336     String constantTypeShortName = new String(constantType.shortReadableName());
2337     String expectedTypeShortName = new String(expectedType.shortReadableName());
2338     if (constantTypeShortName.equals(expectedTypeShortName)) {
2339       constantTypeShortName = constantTypeName;
2340       expectedTypeShortName = expectedTypeName;
2341     }
2342     this.handle(IProblem.TypeMismatch, new String[]{constantTypeName,
2343         expectedTypeName}, new String[]{constantTypeShortName,
2344         expectedTypeShortName}, expression.sourceStart, expression.sourceEnd);
2345   }
2346   public void undefinedLabel(BranchStatement statement) {
2347     String[] arguments = new String[]{new String(statement.label)};
2348     this.handle(IProblem.UndefinedLabel, arguments, arguments,
2349         statement.sourceStart, statement.sourceEnd);
2350   }
2351   public void unexpectedStaticModifierForField(SourceTypeBinding type,
2352       FieldDeclaration fieldDecl) {
2353     String[] arguments = new String[]{fieldDecl.name()};
2354     this.handle(IProblem.UnexpectedStaticModifierForField, arguments,
2355         arguments, fieldDecl.sourceStart, fieldDecl.sourceEnd);
2356   }
2357   public void unexpectedStaticModifierForMethod(ReferenceBinding type,
2358       AbstractMethodDeclaration methodDecl) {
2359     String[] arguments = new String[]{new String(type.sourceName()),
2360         new String(methodDecl.selector)};
2361     this.handle(IProblem.UnexpectedStaticModifierForMethod, arguments,
2362         arguments, methodDecl.sourceStart, methodDecl.sourceEnd);
2363   }
2364   public void unhandledException(TypeBinding exceptionType, AstNode location) {
2365     boolean insideDefaultConstructor = (referenceContext instanceof ConstructorDeclaration)
2366         && ((ConstructorDeclaration) referenceContext).isDefaultConstructor();
2367     boolean insideImplicitConstructorCall = (location instanceof ExplicitConstructorCall)
2368         && (((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper);
2369     this.handle(insideDefaultConstructor
2370         ? IProblem.UnhandledExceptionInDefaultConstructor
2371         : (insideImplicitConstructorCall
2372             ? IProblem.UndefinedConstructorInImplicitConstructorCall
2373             : IProblem.UnhandledException), new String[]{new String(
2374         exceptionType.readableName())}, new String[]{new String(exceptionType
2375         .shortReadableName())}, location.sourceStart, location.sourceEnd);
2376   }
2377   public void uninitializedBlankFinalField(FieldBinding binding,
2378       AstNode location) {
2379     String[] arguments = new String[]{new String(binding.readableName())};
2380     this.handle(IProblem.UninitializedBlankFinalField, arguments, arguments,
2381         location.sourceStart, location.sourceEnd);
2382   }
2383   public void uninitializedLocalVariable(LocalVariableBinding binding,
2384       AstNode location) {
2385     String[] arguments = new String[]{new String(binding.readableName())};
2386     this.handle(IProblem.UninitializedLocalVariable, arguments, arguments,
2387         location.sourceStart, location.sourceEnd);
2388   }
2389   public void unmatchedBracket(int position, ReferenceContext context,
2390       CompilationResult compilationResult) {
2391     this.handle(IProblem.UnmatchedBracket, NoArgument, NoArgument, position,
2392         position, context, compilationResult);
2393   }
2394   public void unnecessaryEnclosingInstanceSpecification(Expression expression,
2395       ReferenceBinding targetType) {
2396     this.handle(IProblem.IllegalEnclosingInstanceSpecification,
2397         new String[]{new String(targetType.readableName())},
2398         new String[]{new String(targetType.shortReadableName())},
2399         expression.sourceStart, expression.sourceEnd);
2400   }
2401   public void unnecessaryReceiverForStaticMethod(AstNode location,
2402       MethodBinding method) {
2403     this.handle(IProblem.NonStaticAccessToStaticMethod, new String[]{
2404         new String(method.declaringClass.readableName()),
2405         new String(method.selector), parametersAsString(method)}, new String[]{
2406         new String(method.declaringClass.shortReadableName()),
2407         new String(method.selector), parametersAsShortString(method)},
2408         location.sourceStart, location.sourceEnd);
2409   }
2410   public void unnecessaryReceiverForStaticField(AstNode location,
2411       FieldBinding field) {
2412     this.handle(IProblem.NonStaticAccessToStaticField,
2413         new String[]{new String(field.declaringClass.readableName()),
2414             new String(field.name)}, new String[]{
2415             new String(field.declaringClass.shortReadableName()),
2416             new String(field.name)}, location.sourceStart, location.sourceEnd);
2417   }
2418   public void unreachableCode(Statement statement) {
2419     this.handle(IProblem.CodeCannotBeReached, NoArgument, NoArgument,
2420         statement.sourceStart, statement.sourceEnd);
2421   }
2422   public void unreachableExceptionHandler(ReferenceBinding exceptionType,
2423       AstNode location) {
2424     this.handle(IProblem.UnreachableCatch, NoArgument, NoArgument,
2425         location.sourceStart, location.sourceEnd);
2426   }
2427   public void unresolvableReference(NameReference nameRef, Binding binding) {
2428     int severity = Error;
2429     /*
2430      * also need to check that the searchedType is the receiver type if
2431      * (binding instanceof ProblemBinding) { ProblemBinding problem =
2432      * (ProblemBinding) binding; if (problem.searchType != null &&
2433      * problem.searchType.isHierarchyInconsistent()) severity = SecondaryError; }
2434      */
2435     String[] arguments = new String[]{new String(binding.readableName())};
2436     this.handle(IProblem.UndefinedName, arguments, arguments, severity,
2437         nameRef.sourceStart, nameRef.sourceEnd);
2438   }
2439   public void unusedArgument(LocalDeclaration localDecl) {
2440     String[] arguments = new String[]{localDecl.name()};
2441     this.handle(IProblem.ArgumentIsNeverUsed, arguments, arguments,
2442         localDecl.sourceStart, localDecl.sourceEnd);
2443   }
2444   public void unusedImport(ImportReference importRef) {
2445     String[] arguments = new String[]{CharOperation.toString(importRef.tokens)};
2446     this.handle(IProblem.UnusedImport, arguments, arguments,
2447         importRef.sourceStart, importRef.sourceEnd);
2448   }
2449   public void unusedLocalVariable(LocalDeclaration localDecl) {
2450     String[] arguments = new String[]{localDecl.name()};
2451     this.handle(IProblem.LocalVariableIsNeverUsed, arguments, arguments,
2452         localDecl.sourceStart, localDecl.sourceEnd);
2453   }
2454   public void unusedPrivateConstructor(ConstructorDeclaration constructorDecl) {
2455     if (computeSeverity(IProblem.UnusedPrivateConstructor) == Ignore)
2456       return;
2457     // no complaint for no-arg constructors (or default ones) - known
2458     // pattern to block instantiation
2459     if (constructorDecl.arguments == null
2460         || constructorDecl.arguments.length == 0)
2461       return;
2462     MethodBinding constructor = constructorDecl.binding;
2463     this.handle(IProblem.UnusedPrivateConstructor, new String[]{
2464         new String(constructor.declaringClass.readableName()),
2465         parametersAsString(constructor)}, new String[]{
2466         new String(constructor.declaringClass.shortReadableName()),
2467         parametersAsShortString(constructor)}, constructorDecl.sourceStart,
2468         constructorDecl.sourceEnd);
2469   }
2470   public void unusedPrivateField(FieldDeclaration fieldDecl) {
2471     if (computeSeverity(IProblem.UnusedPrivateField) == Ignore)
2472       return;
2473     FieldBinding field = fieldDecl.binding;
2474     if (CharOperation.equals(TypeConstants.SERIALVERSIONUID, field.name)
2475         && field.isStatic() && field.isFinal()
2476         && TypeBinding.LongBinding == field.type) {
2477       return; // do not report unused serialVersionUID field
2478     }
2479     this.handle(IProblem.UnusedPrivateField, new String[]{
2480         new String(field.declaringClass.readableName()),
2481         new String(field.name),}, new String[]{
2482         new String(field.declaringClass.shortReadableName()),
2483         new String(field.name),}, fieldDecl.sourceStart, fieldDecl.sourceEnd);
2484   }
2485   public void unusedPrivateMethod(AbstractMethodDeclaration methodDecl) {
2486     if (computeSeverity(IProblem.UnusedPrivateMethod) == Ignore)
2487       return;
2488     MethodBinding method = methodDecl.binding;
2489     // no report for serialization support 'void
2490     // readObject(ObjectInputStream)'
2491     if (!method.isStatic()
2492         && TypeBinding.VoidBinding == method.returnType
2493         && method.parameters.length == 1
2494         && method.parameters[0].dimensions() == 0
2495         && CharOperation.equals(method.selector, TypeConstants.READOBJECT)
2496         && CharOperation.equals(
2497             TypeConstants.CharArray_JAVA_IO_OBJECTINPUTSTREAM,
2498             method.parameters[0].readableName())) {
2499       return;
2500     }
2501     // no report for serialization support 'void
2502     // writeObject(ObjectOutputStream)'
2503     if (!method.isStatic()
2504         && TypeBinding.VoidBinding == method.returnType
2505         && method.parameters.length == 1
2506         && method.parameters[0].dimensions() == 0
2507         && CharOperation.equals(method.selector, TypeConstants.WRITEOBJECT)
2508         && CharOperation.equals(
2509             TypeConstants.CharArray_JAVA_IO_OBJECTOUTPUTSTREAM,
2510             method.parameters[0].readableName())) {
2511       return;
2512     }
2513     // no report for serialization support 'Object readResolve()'
2514     if (!method.isStatic() && TypeBinding.T_Object == method.returnType.id
2515         && method.parameters.length == 0
2516         && CharOperation.equals(method.selector, TypeConstants.READRESOLVE)) {
2517       return;
2518     }
2519     // no report for serialization support 'Object writeReplace()'
2520     if (!method.isStatic() && TypeBinding.T_Object == method.returnType.id
2521         && method.parameters.length == 0
2522         && CharOperation.equals(method.selector, TypeConstants.WRITEREPLACE)) {
2523       return;
2524     }
2525     this.handle(IProblem.UnusedPrivateMethod, new String[]{
2526         new String(method.declaringClass.readableName()),
2527         new String(method.selector), parametersAsString(method)}, new String[]{
2528         new String(method.declaringClass.shortReadableName()),
2529         new String(method.selector), parametersAsShortString(method)},
2530         methodDecl.sourceStart, methodDecl.sourceEnd);
2531   }
2532   public void unusedPrivateType(TypeDeclaration typeDecl) {
2533     if (computeSeverity(IProblem.UnusedPrivateType) == Ignore)
2534       return;
2535     ReferenceBinding type = typeDecl.binding;
2536     this.handle(IProblem.UnusedPrivateType, new String[]{new String(type
2537         .readableName()),},
2538         new String[]{new String(type.shortReadableName()),},
2539         typeDecl.sourceStart, typeDecl.sourceEnd);
2540   }
2541   public void useAssertAsAnIdentifier(int sourceStart, int sourceEnd) {
2542     this.handle(IProblem.UseAssertAsAnIdentifier, NoArgument, NoArgument,
2543         sourceStart, sourceEnd);
2544   }
2545   public void variableTypeCannotBeVoid(AbstractVariableDeclaration varDecl) {
2546     String[] arguments = new String[]{new String(varDecl.name)};
2547     this.handle(IProblem.VariableTypeCannotBeVoid, arguments, arguments,
2548         varDecl.sourceStart, varDecl.sourceEnd);
2549   }
2550   public void variableTypeCannotBeVoidArray(AbstractVariableDeclaration varDecl) {
2551     String[] arguments = new String[]{new String(varDecl.name)};
2552     this.handle(IProblem.VariableTypeCannotBeVoidArray, arguments, arguments,
2553         varDecl.sourceStart, varDecl.sourceEnd);
2554   }
2555   public void visibilityConflict(MethodBinding currentMethod,
2556       MethodBinding inheritedMethod) {
2557     this.handle(
2558     //  Cannot reduce the visibility of the inherited method from %1
2559         // 8.4.6.3 - The access modifier of an hiding method must
2560         // provide at least as much access as the hidden method.
2561         // 8.4.6.3 - The access modifier of an overiding method must
2562         // provide at least as much access as the overriden method.
2563         IProblem.MethodReducesVisibility, new String[]{new String(
2564             inheritedMethod.declaringClass.readableName())},
2565         new String[]{new String(inheritedMethod.declaringClass
2566             .shortReadableName())}, currentMethod.sourceStart(), currentMethod
2567             .sourceEnd());
2568   }
2569   public void wrongSequenceOfExceptionTypesError(TryStatement statement,
2570       int under, int upper) {
2571     //the two catch block under and upper are in an incorrect order.
2572     //under should be define BEFORE upper in the source
2573     TypeReference typeRef = statement.catchArguments[under].type;
2574     this.handle(IProblem.UnreachableCatch, NoArgument, NoArgument,
2575         typeRef.sourceStart, typeRef.sourceEnd);
2576   }
2577   public void nonExternalizedStringLiteral(AstNode location) {
2578     this.handle(IProblem.NonExternalizedStringLiteral, NoArgument, NoArgument,
2579         location.sourceStart, location.sourceEnd);
2580   }
2581   public void noMoreAvailableSpaceForConstant(TypeDeclaration typeDeclaration) {
2582     this.handle(IProblem.TooManyBytesForStringConstant,
2583         new String[]{new String(typeDeclaration.binding.readableName())},
2584         new String[]{new String(typeDeclaration.binding.shortReadableName())},
2585         Abort | Error, typeDeclaration.sourceStart, typeDeclaration.sourceEnd);
2586   }
2587   public void noMoreAvailableSpaceInConstantPool(TypeDeclaration typeDeclaration) {
2588     this.handle(IProblem.TooManyConstantsInConstantPool,
2589         new String[]{new String(typeDeclaration.binding.readableName())},
2590         new String[]{new String(typeDeclaration.binding.shortReadableName())},
2591         Abort | Error, typeDeclaration.sourceStart, typeDeclaration.sourceEnd);
2592   }
2593   private boolean isKeyword(char[] tokenSource) {
2594     /*
2595      * This code is heavily grammar dependant
2596      */
2597     if (tokenSource == null) {
2598       return false;
2599     }
2600     try {
2601       Scanner scanner = new Scanner();
2602       scanner.setSource(tokenSource);
2603       int token = scanner.getNextToken();
2604       char[] currentKeyword;
2605       try {
2606         currentKeyword = scanner.getCurrentIdentifierSource();
2607       } catch (ArrayIndexOutOfBoundsException e) {
2608         return false;
2609       }
2610       int nextToken = scanner.getNextToken();
2611       if (nextToken == Scanner.TokenNameEOF
2612           && scanner.startPosition == scanner.source.length) { // to
2613         // handle
2614         // case
2615         // where
2616         // we
2617         // had
2618         // an
2619         // ArrayIndexOutOfBoundsException
2620         // while reading the last token
2621         switch (token) {
2622           case Scanner.TokenNameERROR :
2623             if (CharOperation.equals("goto".toCharArray(), currentKeyword)
2624                 || CharOperation.equals("const".toCharArray(), currentKeyword)) { //$NON-NLS-1$ //$NON-NLS-2$
2625               return true;
2626             } else {
2627               return false;
2628             }
2629           case Scanner.TokenNameabstract :
2630           //                            case Scanner.TokenNameassert:
2631           //                            case Scanner.TokenNamebyte:
2632           case Scanner.TokenNamebreak :
2633           //                            case Scanner.TokenNameboolean:
2634           case Scanner.TokenNamecase :
2635           //                            case Scanner.TokenNamechar:
2636           case Scanner.TokenNamecatch :
2637           case Scanner.TokenNameclass :
2638           case Scanner.TokenNamecontinue :
2639           case Scanner.TokenNamedo :
2640           //                            case Scanner.TokenNamedouble:
2641           case Scanner.TokenNamedefault :
2642           case Scanner.TokenNameelse :
2643           case Scanner.TokenNameextends :
2644           case Scanner.TokenNamefor :
2645           //                            case Scanner.TokenNamefinal:
2646           //                            case Scanner.TokenNamefloat:
2647           //                                    case Scanner.TokenNamefalse :
2648           case Scanner.TokenNamefinally :
2649           case Scanner.TokenNameif :
2650           //                            case Scanner.TokenNameint:
2651           //                            case Scanner.TokenNameimport:
2652           case Scanner.TokenNameinterface :
2653           case Scanner.TokenNameimplements :
2654           case Scanner.TokenNameinstanceof :
2655           //                            case Scanner.TokenNamelong:
2656           case Scanner.TokenNamenew :
2657           //                                    case Scanner.TokenNamenull :
2658           //                            case Scanner.TokenNamenative:
2659           case Scanner.TokenNamepublic :
2660           //                            case Scanner.TokenNamepackage:
2661           case Scanner.TokenNameprivate :
2662           case Scanner.TokenNameprotected :
2663           case Scanner.TokenNamereturn :
2664           //                            case Scanner.TokenNameshort:
2665           case Scanner.TokenNamesuper :
2666           case Scanner.TokenNamestatic :
2667           case Scanner.TokenNameswitch :
2668           //                            case Scanner.TokenNamestrictfp:
2669           //                            case Scanner.TokenNamesynchronized:
2670           case Scanner.TokenNametry :
2671 //          case Scanner.TokenNamethis :
2672           //                                    case Scanner.TokenNametrue :
2673           case Scanner.TokenNamethrow :
2674           //                            case Scanner.TokenNamethrows:
2675           //                            case Scanner.TokenNametransient:
2676           //                            case Scanner.TokenNamevoid:
2677           //                            case Scanner.TokenNamevolatile:
2678           case Scanner.TokenNamewhile :
2679             return true;
2680           default :
2681             return false;
2682         }
2683       } else {
2684         return false;
2685       }
2686     } catch (InvalidInputException e) {
2687       return false;
2688     }
2689   }
2690   // jsurfer start
2691   public void phpParsingError(String[] messageArguments,
2692       int problemStartPosition, int problemEndPosition,
2693       ReferenceContext context, CompilationResult compilationResult) {
2694     this.handle(IProblem.PHPParsingError, NoArgument, messageArguments,
2695         problemStartPosition, problemEndPosition, context, compilationResult);
2696   }
2697   public void phpParsingWarning(String[] messageArguments,
2698       int problemStartPosition, int problemEndPosition,
2699       ReferenceContext context, CompilationResult compilationResult) {
2700     this.handle(IProblem.PHPParsingWarning, NoArgument, messageArguments,
2701         problemStartPosition, problemEndPosition, context, compilationResult);
2702   }
2703   public void phpVarDeprecatedWarning(
2704       int problemStartPosition, int problemEndPosition,
2705       ReferenceContext context, CompilationResult compilationResult) {
2706     if (computeSeverity(IProblem.PHPVarDeprecatedWarning) == Ignore)
2707       return;
2708     this.handle(IProblem.PHPVarDeprecatedWarning, NoArgument, new String[]{},
2709         problemStartPosition, problemEndPosition, context, compilationResult);
2710   }
2711 }