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