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