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