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