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