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