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