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