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