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