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