1 /*******************************************************************************
2  * Copyright (c) 2000, 2014 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *     Benjamin Muskalla - Contribution for bug 239066
11  *     Stephan Herrmann  - Contributions for
12  *	     						bug 236385 - [compiler] Warn for potential programming problem if an object is created but not used
13  *  	   						bug 338303 - Warning about Redundant assignment conflicts with definite assignment
14  *								bug 349326 - [1.7] new warning for missing try-with-resources
15  *								bug 186342 - [compiler][null] Using annotations for null checking
16  *								bug 365519 - editorial cleanup after bug 186342 and bug 365387
17  *								bug 365662 - [compiler][null] warn on contradictory and redundant null annotations
18  *								bug 365531 - [compiler][null] investigate alternative strategy for internally encoding nullness defaults
19  *								bug 365859 - [compiler][null] distinguish warnings based on flow analysis vs. null annotations
20  *								bug 374605 - Unreasonable warning for enum-based switch statements
21  *								bug 382353 - [1.8][compiler] Implementation property modifiers should be accepted on default methods.
22  *								bug 382347 - [1.8][compiler] Compiler accepts incorrect default method inheritance
23  *								bug 388281 - [compiler][null] inheritance of null annotations as an option
24  *								bug 376053 - [compiler][resource] Strange potential resource leak problems
25  *								bug 381443 - [compiler][null] Allow parameter widening from @NonNull to unannotated
26  *								bug 393719 - [compiler] inconsistent warnings on iteration variables
27  *								bug 392862 - [1.8][compiler][null] Evaluate null annotations on array types
28  *								bug 388739 - [1.8][compiler] consider default methods when detecting whether a class needs to be declared abstract
29  *								bug 331649 - [compiler][null] consider null annotations for fields
30  *								bug 382789 - [compiler][null] warn when syntactically-nonnull expression is compared against null
31  *								bug 376590 - Private fields with @Inject are ignored by unused field validation
32  *								bug 400761 - [compiler][null] null may be return as boolean without a diagnostic
33  *								bug 402028 - [1.8][compiler] null analysis for reference expressions
34  *								bug 401796 - [1.8][compiler] don't treat default methods as overriding an independent inherited abstract method
35  *								bug 404649 - [1.8][compiler] detect illegal reference to indirect or redundant super
36  *								bug 392384 - [1.8][compiler][null] Restore nullness info from type annotations in class files
37  *								Bug 392099 - [1.8][compiler][null] Apply null annotation on types for null analysis
38  *								Bug 415043 - [1.8][null] Follow-up re null type annotations after bug 392099
39  *								Bug 415291 - [1.8][null] differentiate type incompatibilities due to null annotations
40  *								Bug 415850 - [1.8] Ensure RunJDTCoreTests can cope with null annotations enabled
41  *								Bug 414380 - [compiler][internal] QualifiedNameReference#indexOfFirstFieldBinding does not point to the first field
42  *								Bug 392238 - [1.8][compiler][null] Detect semantically invalid null type annotations
43  *								Bug 416307 - [1.8][compiler][null] subclass with type parameter substitution confuses null checking
44  *								Bug 400874 - [1.8][compiler] Inference infrastructure should evolve to meet JLS8 18.x (Part G of JSR335 spec)
45  *								Bug 424637 - [1.8][compiler][null] AIOOB in ReferenceExpression.resolveType with a method reference to Files::walk
46  *								Bug 428294 - [1.8][compiler] Type mismatch: cannot convert from List<Object> to Collection<Object[]>
47  *								Bug 428366 - [1.8] [compiler] The method valueAt(ObservableList<Object>, int) is ambiguous for the type Bindings
48  *								Bug 416190 - [1.8][null] detect incompatible overrides due to null type annotations
49  *								Bug 392245 - [1.8][compiler][null] Define whether / how @NonNullByDefault applies to TYPE_USE locations
50  *								Bug 390889 - [1.8][compiler] Evaluate options to support 1.7- projects against 1.8 JRE.
51  *								Bug 430150 - [1.8][null] stricter checking against type variables
52  *								Bug 434600 - Incorrect null analysis error reporting on type parameters
53  *								Bug 439298 - [null] "Missing code implementation in the compiler" when using @NonNullByDefault in package-info.java
54  *      Jesper S Moller <jesper@selskabet.org> -  Contributions for
55  *								bug 382701 - [1.8][compiler] Implement semantic analysis of Lambda expressions & Reference expression
56  *								bug 382721 - [1.8][compiler] Effectively final variables needs special treatment
57  *								bug 384567 - [1.5][compiler] Compiler accepts illegal modifiers on package declaration
58  *								bug 412153 - [1.8][compiler] Check validity of annotations which may be repeatable
59  *								bug 412151 - [1.8][compiler] Check repeating annotation's collection type
60  *								bug 419209 - [1.8] Repeating container annotations should be rejected in the presence of annotation it contains
61  *								Bug 429384 - [1.8][null] implement conformance rules for null-annotated lower / upper type bounds
62  *								Bug 416182 - [1.8][compiler][null] Contradictory null annotations not rejected
63  ********************************************************************************/
64 package org.eclipse.jdt.internal.compiler.problem;
65 
66 import java.io.CharConversionException;
67 import java.io.PrintWriter;
68 import java.io.StringWriter;
69 import java.util.Iterator;
70 import java.util.List;
71 
72 import org.eclipse.jdt.core.compiler.CategorizedProblem;
73 import org.eclipse.jdt.core.compiler.CharOperation;
74 import org.eclipse.jdt.core.compiler.IProblem;
75 import org.eclipse.jdt.core.compiler.InvalidInputException;
76 import org.eclipse.jdt.internal.compiler.CompilationResult;
77 import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
78 import org.eclipse.jdt.internal.compiler.IProblemFactory;
79 import org.eclipse.jdt.internal.compiler.ast.ASTNode;
80 import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
81 import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
82 import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
83 import org.eclipse.jdt.internal.compiler.ast.Annotation;
84 import org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration;
85 import org.eclipse.jdt.internal.compiler.ast.Argument;
86 import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression;
87 import org.eclipse.jdt.internal.compiler.ast.ArrayInitializer;
88 import org.eclipse.jdt.internal.compiler.ast.ArrayQualifiedTypeReference;
89 import org.eclipse.jdt.internal.compiler.ast.ArrayReference;
90 import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference;
91 import org.eclipse.jdt.internal.compiler.ast.Assignment;
92 import org.eclipse.jdt.internal.compiler.ast.BinaryExpression;
93 import org.eclipse.jdt.internal.compiler.ast.Block;
94 import org.eclipse.jdt.internal.compiler.ast.BranchStatement;
95 import org.eclipse.jdt.internal.compiler.ast.CaseStatement;
96 import org.eclipse.jdt.internal.compiler.ast.CastExpression;
97 import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess;
98 import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
99 import org.eclipse.jdt.internal.compiler.ast.CompoundAssignment;
100 import org.eclipse.jdt.internal.compiler.ast.ConditionalExpression;
101 import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
102 import org.eclipse.jdt.internal.compiler.ast.EqualExpression;
103 import org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall;
104 import org.eclipse.jdt.internal.compiler.ast.Expression;
105 import org.eclipse.jdt.internal.compiler.ast.FakedTrackingVariable;
106 import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
107 import org.eclipse.jdt.internal.compiler.ast.FieldReference;
108 import org.eclipse.jdt.internal.compiler.ast.FunctionalExpression;
109 import org.eclipse.jdt.internal.compiler.ast.ImportReference;
110 import org.eclipse.jdt.internal.compiler.ast.Initializer;
111 import org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression;
112 import org.eclipse.jdt.internal.compiler.ast.LabeledStatement;
113 import org.eclipse.jdt.internal.compiler.ast.LambdaExpression;
114 import org.eclipse.jdt.internal.compiler.ast.Literal;
115 import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
116 import org.eclipse.jdt.internal.compiler.ast.MemberValuePair;
117 import org.eclipse.jdt.internal.compiler.ast.MessageSend;
118 import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
119 import org.eclipse.jdt.internal.compiler.ast.NameReference;
120 import org.eclipse.jdt.internal.compiler.ast.NullAnnotationMatching;
121 import org.eclipse.jdt.internal.compiler.ast.NullLiteral;
122 import org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference;
123 import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference;
124 import org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression;
125 import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference;
126 import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
127 import org.eclipse.jdt.internal.compiler.ast.Receiver;
128 import org.eclipse.jdt.internal.compiler.ast.Reference;
129 import org.eclipse.jdt.internal.compiler.ast.ReferenceExpression;
130 import org.eclipse.jdt.internal.compiler.ast.ReturnStatement;
131 import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
132 import org.eclipse.jdt.internal.compiler.ast.Statement;
133 import org.eclipse.jdt.internal.compiler.ast.SwitchStatement;
134 import org.eclipse.jdt.internal.compiler.ast.ThisReference;
135 import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
136 import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
137 import org.eclipse.jdt.internal.compiler.ast.TypeReference;
138 import org.eclipse.jdt.internal.compiler.ast.UnaryExpression;
139 import org.eclipse.jdt.internal.compiler.ast.Wildcard;
140 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
141 import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
142 import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
143 import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
144 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
145 import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
146 import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
147 import org.eclipse.jdt.internal.compiler.lookup.Binding;
148 import org.eclipse.jdt.internal.compiler.lookup.CaptureBinding;
149 import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
150 import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
151 import org.eclipse.jdt.internal.compiler.lookup.InferenceContext18;
152 import org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
153 import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
154 import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
155 import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
156 import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
157 import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
158 import org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding;
159 import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding;
160 import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
161 import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
162 import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
163 import org.eclipse.jdt.internal.compiler.lookup.Scope;
164 import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
165 import org.eclipse.jdt.internal.compiler.lookup.SyntheticArgumentBinding;
166 import org.eclipse.jdt.internal.compiler.lookup.TagBits;
167 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
168 import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
169 import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
170 import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
171 import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
172 import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
173 import org.eclipse.jdt.internal.compiler.parser.JavadocTagConstants;
174 import org.eclipse.jdt.internal.compiler.parser.Parser;
175 import org.eclipse.jdt.internal.compiler.parser.RecoveryScanner;
176 import org.eclipse.jdt.internal.compiler.parser.Scanner;
177 import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
178 import org.eclipse.jdt.internal.compiler.util.Messages;
179 import org.eclipse.jdt.internal.compiler.util.Util;
180 
181 @SuppressWarnings("rawtypes")
182 public class ProblemReporter extends ProblemHandler {
183 
184 	public ReferenceContext referenceContext;
185 	private Scanner positionScanner;
186 	private boolean underScoreIsLambdaParameter;
187 	private final static byte
188 	  // TYPE_ACCESS = 0x0,
189 	  FIELD_ACCESS = 0x4,
190 	  CONSTRUCTOR_ACCESS = 0x8,
191 	  METHOD_ACCESS = 0xC;
192 
ProblemReporter(IErrorHandlingPolicy policy, CompilerOptions options, IProblemFactory problemFactory)193 public ProblemReporter(IErrorHandlingPolicy policy, CompilerOptions options, IProblemFactory problemFactory) {
194 	super(policy, options, problemFactory);
195 }
196 
getElaborationId(int leadProblemId, byte elaborationVariant)197 private static int getElaborationId (int leadProblemId, byte elaborationVariant) {
198 	return leadProblemId << 8 | elaborationVariant; // leadProblemId comes into the higher order bytes
199 }
getIrritant(int problemID)200 public static int getIrritant(int problemID) {
201 	switch(problemID){
202 
203 		case IProblem.MaskedCatch :
204 			return CompilerOptions.MaskedCatchBlock;
205 
206 		case IProblem.UnusedImport :
207 			return CompilerOptions.UnusedImport;
208 
209 		case IProblem.MethodButWithConstructorName :
210 			return CompilerOptions.MethodWithConstructorName;
211 
212 		case IProblem.OverridingNonVisibleMethod :
213 			return CompilerOptions.OverriddenPackageDefaultMethod;
214 
215 		case IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod :
216 		case IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod :
217 			return CompilerOptions.IncompatibleNonInheritedInterfaceMethod;
218 
219 		case IProblem.OverridingDeprecatedMethod :
220 		case IProblem.UsingDeprecatedType :
221 		case IProblem.UsingDeprecatedMethod :
222 		case IProblem.UsingDeprecatedConstructor :
223 		case IProblem.UsingDeprecatedField :
224 			return CompilerOptions.UsingDeprecatedAPI;
225 
226 		case IProblem.LocalVariableIsNeverUsed :
227 			return CompilerOptions.UnusedLocalVariable;
228 
229 		case IProblem.ArgumentIsNeverUsed :
230 			return CompilerOptions.UnusedArgument;
231 
232 		case IProblem.NoImplicitStringConversionForCharArrayExpression :
233 			return CompilerOptions.NoImplicitStringConversion;
234 
235 		case IProblem.NeedToEmulateFieldReadAccess :
236 		case IProblem.NeedToEmulateFieldWriteAccess :
237 		case IProblem.NeedToEmulateMethodAccess :
238 		case IProblem.NeedToEmulateConstructorAccess :
239 			return CompilerOptions.AccessEmulation;
240 
241 		case IProblem.NonExternalizedStringLiteral :
242 		case IProblem.UnnecessaryNLSTag :
243 			return CompilerOptions.NonExternalizedString;
244 
245 		case IProblem.UseAssertAsAnIdentifier :
246 			return CompilerOptions.AssertUsedAsAnIdentifier;
247 
248 		case IProblem.UseEnumAsAnIdentifier :
249 			return CompilerOptions.EnumUsedAsAnIdentifier;
250 
251 		case IProblem.NonStaticAccessToStaticMethod :
252 		case IProblem.NonStaticAccessToStaticField :
253 			return CompilerOptions.NonStaticAccessToStatic;
254 
255 		case IProblem.IndirectAccessToStaticMethod :
256 		case IProblem.IndirectAccessToStaticField :
257 		case IProblem.IndirectAccessToStaticType :
258 			return CompilerOptions.IndirectStaticAccess;
259 
260 		case IProblem.AssignmentHasNoEffect:
261 			return CompilerOptions.NoEffectAssignment;
262 
263 		case IProblem.UnusedPrivateConstructor:
264 		case IProblem.UnusedPrivateMethod:
265 		case IProblem.UnusedPrivateField:
266 		case IProblem.UnusedPrivateType:
267 			return CompilerOptions.UnusedPrivateMember;
268 
269 		case IProblem.LocalVariableHidingLocalVariable:
270 		case IProblem.LocalVariableHidingField:
271 		case IProblem.ArgumentHidingLocalVariable:
272 		case IProblem.ArgumentHidingField:
273 			return CompilerOptions.LocalVariableHiding;
274 
275 		case IProblem.FieldHidingLocalVariable:
276 		case IProblem.FieldHidingField:
277 			return CompilerOptions.FieldHiding;
278 
279 		case IProblem.TypeParameterHidingType:
280 		case IProblem.TypeHidingTypeParameterFromType:
281 		case IProblem.TypeHidingTypeParameterFromMethod:
282 		case IProblem.TypeHidingType:
283 			return CompilerOptions.TypeHiding;
284 
285 		case IProblem.PossibleAccidentalBooleanAssignment:
286 			return CompilerOptions.AccidentalBooleanAssign;
287 
288 		case IProblem.SuperfluousSemicolon:
289 		case IProblem.EmptyControlFlowStatement:
290 			return CompilerOptions.EmptyStatement;
291 
292 		case IProblem.UndocumentedEmptyBlock:
293 			return CompilerOptions.UndocumentedEmptyBlock;
294 
295 		case IProblem.UnnecessaryCast:
296 		case IProblem.UnnecessaryInstanceof:
297 			return CompilerOptions.UnnecessaryTypeCheck;
298 
299 		case IProblem.FinallyMustCompleteNormally:
300 			return CompilerOptions.FinallyBlockNotCompleting;
301 
302 		case IProblem.UnusedMethodDeclaredThrownException:
303 		case IProblem.UnusedConstructorDeclaredThrownException:
304 			return CompilerOptions.UnusedDeclaredThrownException;
305 
306 		case IProblem.UnqualifiedFieldAccess:
307 			return CompilerOptions.UnqualifiedFieldAccess;
308 
309 		case IProblem.UnnecessaryElse:
310 			return CompilerOptions.UnnecessaryElse;
311 
312 		case IProblem.UnsafeRawConstructorInvocation:
313 		case IProblem.UnsafeRawMethodInvocation:
314 		case IProblem.UnsafeTypeConversion:
315 		case IProblem.UnsafeElementTypeConversion:
316 		case IProblem.UnsafeRawFieldAssignment:
317 		case IProblem.UnsafeGenericCast:
318 		case IProblem.UnsafeReturnTypeOverride:
319 		case IProblem.UnsafeRawGenericMethodInvocation:
320 		case IProblem.UnsafeRawGenericConstructorInvocation:
321 		case IProblem.UnsafeGenericArrayForVarargs:
322 		case IProblem.PotentialHeapPollutionFromVararg:
323 			return CompilerOptions.UncheckedTypeOperation;
324 
325 		case IProblem.RawTypeReference:
326 			return CompilerOptions.RawTypeReference;
327 
328 		case IProblem.MissingOverrideAnnotation:
329 		case IProblem.MissingOverrideAnnotationForInterfaceMethodImplementation:
330 			return CompilerOptions.MissingOverrideAnnotation;
331 
332 		case IProblem.FieldMissingDeprecatedAnnotation:
333 		case IProblem.MethodMissingDeprecatedAnnotation:
334 		case IProblem.TypeMissingDeprecatedAnnotation:
335 			return CompilerOptions.MissingDeprecatedAnnotation;
336 
337 		case IProblem.FinalBoundForTypeVariable:
338 		    return CompilerOptions.FinalParameterBound;
339 
340 		case IProblem.MissingSerialVersion:
341 			return CompilerOptions.MissingSerialVersion;
342 
343 		case IProblem.ForbiddenReference:
344 			return CompilerOptions.ForbiddenReference;
345 
346 		case IProblem.DiscouragedReference:
347 			return CompilerOptions.DiscouragedReference;
348 
349 		case IProblem.MethodVarargsArgumentNeedCast :
350 		case IProblem.ConstructorVarargsArgumentNeedCast :
351 			return CompilerOptions.VarargsArgumentNeedCast;
352 
353 		case IProblem.NullLocalVariableReference:
354 		case IProblem.NullableFieldReference:
355 		case IProblem.NullExpressionReference:
356 		case IProblem.NullUnboxing:
357 			return CompilerOptions.NullReference;
358 
359 		case IProblem.PotentialNullLocalVariableReference:
360 		case IProblem.PotentialNullMessageSendReference:
361 		case IProblem.ArrayReferencePotentialNullReference:
362 		case IProblem.DereferencingNullableExpression:
363 		case IProblem.PotentialNullExpressionReference:
364 		case IProblem.PotentialNullUnboxing:
365 			return CompilerOptions.PotentialNullReference;
366 
367 		case IProblem.RedundantLocalVariableNullAssignment:
368 		case IProblem.RedundantNullCheckOnNonNullLocalVariable:
369 		case IProblem.RedundantNullCheckOnNullLocalVariable:
370 		case IProblem.NonNullLocalVariableComparisonYieldsFalse:
371 		case IProblem.NullLocalVariableComparisonYieldsFalse:
372 		case IProblem.NullLocalVariableInstanceofYieldsFalse:
373 		case IProblem.RedundantNullCheckOnNonNullExpression:
374 		case IProblem.NonNullExpressionComparisonYieldsFalse:
375 		case IProblem.RedundantNullCheckOnNonNullMessageSend:
376 		case IProblem.RedundantNullCheckOnSpecdNonNullLocalVariable:
377 		case IProblem.SpecdNonNullLocalVariableComparisonYieldsFalse:
378 		case IProblem.NonNullMessageSendComparisonYieldsFalse:
379 		case IProblem.RedundantNullCheckOnNonNullSpecdField:
380 		case IProblem.NonNullSpecdFieldComparisonYieldsFalse:
381 		case IProblem.RedundantNullCheckAgainstNonNullType:
382 		case IProblem.RedundantNullCheckOnField:
383 		case IProblem.FieldComparisonYieldsFalse:
384 			return CompilerOptions.RedundantNullCheck;
385 
386 		case IProblem.RequiredNonNullButProvidedNull:
387 		case IProblem.RequiredNonNullButProvidedSpecdNullable:
388 		case IProblem.IllegalReturnNullityRedefinition:
389 		case IProblem.IllegalRedefinitionToNonNullParameter:
390 		case IProblem.IllegalDefinitionToNonNullParameter:
391 		case IProblem.ParameterLackingNullableAnnotation:
392 		case IProblem.CannotImplementIncompatibleNullness:
393 		case IProblem.ConflictingNullAnnotations:
394 		case IProblem.ConflictingInheritedNullAnnotations:
395 		case IProblem.NullNotCompatibleToFreeTypeVariable:
396 		case IProblem.NullityMismatchAgainstFreeTypeVariable:
397 		case IProblem.NullityMismatchingTypeAnnotation:
398 		case IProblem.NullityMismatchingTypeAnnotationSuperHint:
399 		case IProblem.NullityMismatchTypeArgument:
400 		case IProblem.UninitializedNonNullField:
401 		case IProblem.UninitializedNonNullFieldHintMissingDefault:
402 		case IProblem.ReferenceExpressionParameterNullityMismatch:
403 		case IProblem.ReferenceExpressionReturnNullRedef:
404 			return CompilerOptions.NullSpecViolation;
405 
406 		case IProblem.ParameterLackingNonNullAnnotation:
407 			return CompilerOptions.NonnullParameterAnnotationDropped;
408 
409 		case IProblem.RequiredNonNullButProvidedPotentialNull:
410 			return CompilerOptions.NullAnnotationInferenceConflict;
411 		case IProblem.RequiredNonNullButProvidedUnknown:
412 		case IProblem.NullityUncheckedTypeAnnotationDetail:
413 		case IProblem.NullityUncheckedTypeAnnotationDetailSuperHint:
414 		case IProblem.ReferenceExpressionParameterNullityUnchecked:
415 		case IProblem.ReferenceExpressionReturnNullRedefUnchecked:
416 		case IProblem.UnsafeNullnessCast:
417 			return CompilerOptions.NullUncheckedConversion;
418 		case IProblem.RedundantNullAnnotation:
419 		case IProblem.RedundantNullDefaultAnnotation:
420 		case IProblem.RedundantNullDefaultAnnotationPackage:
421 		case IProblem.RedundantNullDefaultAnnotationType:
422 		case IProblem.RedundantNullDefaultAnnotationMethod:
423 			return CompilerOptions.RedundantNullAnnotation;
424 
425 		case IProblem.BoxingConversion :
426 		case IProblem.UnboxingConversion :
427 			return CompilerOptions.AutoBoxing;
428 
429 		case IProblem.MissingEnumConstantCase :
430 		case IProblem.MissingEnumConstantCaseDespiteDefault :	// this one is further protected by CompilerOptions.reportMissingEnumCaseDespiteDefault
431 			return CompilerOptions.MissingEnumConstantCase;
432 
433 		case IProblem.MissingDefaultCase :
434 		case IProblem.MissingEnumDefaultCase :
435 			return CompilerOptions.MissingDefaultCase;
436 
437 		case IProblem.AnnotationTypeUsedAsSuperInterface :
438 			return CompilerOptions.AnnotationSuperInterface;
439 
440 		case IProblem.UnhandledWarningToken :
441 			return CompilerOptions.UnhandledWarningToken;
442 
443 		case IProblem.UnusedWarningToken :
444 			return CompilerOptions.UnusedWarningToken;
445 
446 		case IProblem.UnusedLabel :
447 			return CompilerOptions.UnusedLabel;
448 
449 		case IProblem.JavadocUnexpectedTag:
450 		case IProblem.JavadocDuplicateTag:
451 		case IProblem.JavadocDuplicateReturnTag:
452 		case IProblem.JavadocInvalidThrowsClass:
453 		case IProblem.JavadocInvalidSeeReference:
454 		case IProblem.JavadocInvalidParamTagName:
455 		case IProblem.JavadocInvalidParamTagTypeParameter:
456 		case IProblem.JavadocMalformedSeeReference:
457 		case IProblem.JavadocInvalidSeeHref:
458 		case IProblem.JavadocInvalidSeeArgs:
459 		case IProblem.JavadocInvalidTag:
460 		case IProblem.JavadocUnterminatedInlineTag:
461 		case IProblem.JavadocMissingHashCharacter:
462 		case IProblem.JavadocEmptyReturnTag:
463 		case IProblem.JavadocUnexpectedText:
464 		case IProblem.JavadocInvalidParamName:
465 		case IProblem.JavadocDuplicateParamName:
466 		case IProblem.JavadocMissingParamName:
467 		case IProblem.JavadocMissingIdentifier:
468 		case IProblem.JavadocInvalidMemberTypeQualification:
469 		case IProblem.JavadocInvalidThrowsClassName:
470 		case IProblem.JavadocDuplicateThrowsClassName:
471 		case IProblem.JavadocMissingThrowsClassName:
472 		case IProblem.JavadocMissingSeeReference:
473 		case IProblem.JavadocInvalidValueReference:
474 		case IProblem.JavadocUndefinedField:
475 		case IProblem.JavadocAmbiguousField:
476 		case IProblem.JavadocUndefinedConstructor:
477 		case IProblem.JavadocAmbiguousConstructor:
478 		case IProblem.JavadocUndefinedMethod:
479 		case IProblem.JavadocAmbiguousMethod:
480 		case IProblem.JavadocAmbiguousMethodReference:
481 		case IProblem.JavadocParameterMismatch:
482 		case IProblem.JavadocUndefinedType:
483 		case IProblem.JavadocAmbiguousType:
484 		case IProblem.JavadocInternalTypeNameProvided:
485 		case IProblem.JavadocNoMessageSendOnArrayType:
486 		case IProblem.JavadocNoMessageSendOnBaseType:
487 		case IProblem.JavadocInheritedMethodHidesEnclosingName:
488 		case IProblem.JavadocInheritedFieldHidesEnclosingName:
489 		case IProblem.JavadocInheritedNameHidesEnclosingTypeName:
490 		case IProblem.JavadocNonStaticTypeFromStaticInvocation:
491 		case IProblem.JavadocGenericMethodTypeArgumentMismatch:
492 		case IProblem.JavadocNonGenericMethod:
493 		case IProblem.JavadocIncorrectArityForParameterizedMethod:
494 		case IProblem.JavadocParameterizedMethodArgumentTypeMismatch:
495 		case IProblem.JavadocTypeArgumentsForRawGenericMethod:
496 		case IProblem.JavadocGenericConstructorTypeArgumentMismatch:
497 		case IProblem.JavadocNonGenericConstructor:
498 		case IProblem.JavadocIncorrectArityForParameterizedConstructor:
499 		case IProblem.JavadocParameterizedConstructorArgumentTypeMismatch:
500 		case IProblem.JavadocTypeArgumentsForRawGenericConstructor:
501 		case IProblem.JavadocNotVisibleField:
502 		case IProblem.JavadocNotVisibleConstructor:
503 		case IProblem.JavadocNotVisibleMethod:
504 		case IProblem.JavadocNotVisibleType:
505 		case IProblem.JavadocUsingDeprecatedField:
506 		case IProblem.JavadocUsingDeprecatedConstructor:
507 		case IProblem.JavadocUsingDeprecatedMethod:
508 		case IProblem.JavadocUsingDeprecatedType:
509 		case IProblem.JavadocHiddenReference:
510 		case IProblem.JavadocMissingTagDescription:
511 		case IProblem.JavadocInvalidSeeUrlReference:
512 			return CompilerOptions.InvalidJavadoc;
513 
514 		case IProblem.JavadocMissingParamTag:
515 		case IProblem.JavadocMissingReturnTag:
516 		case IProblem.JavadocMissingThrowsTag:
517 			return CompilerOptions.MissingJavadocTags;
518 
519 		case IProblem.JavadocMissing:
520 			return CompilerOptions.MissingJavadocComments;
521 
522 		case IProblem.ParameterAssignment:
523 			return CompilerOptions.ParameterAssignment;
524 
525 		case IProblem.FallthroughCase:
526 			return CompilerOptions.FallthroughCase;
527 
528 		case IProblem.OverridingMethodWithoutSuperInvocation:
529 			return CompilerOptions.OverridingMethodWithoutSuperInvocation;
530 
531 		case IProblem.UnusedTypeArgumentsForMethodInvocation:
532 		case IProblem.UnusedTypeArgumentsForConstructorInvocation:
533 			return CompilerOptions.UnusedTypeArguments;
534 
535 		case IProblem.RedundantSuperinterface:
536 			return CompilerOptions.RedundantSuperinterface;
537 
538 		case IProblem.ComparingIdentical:
539 			return CompilerOptions.ComparingIdentical;
540 
541 		case IProblem.MissingSynchronizedModifierInInheritedMethod:
542 			return CompilerOptions.MissingSynchronizedModifierInInheritedMethod;
543 
544 		case IProblem.ShouldImplementHashcode:
545 			return CompilerOptions.ShouldImplementHashcode;
546 
547 		case IProblem.DeadCode:
548 			return CompilerOptions.DeadCode;
549 
550 		case IProblem.Task :
551 			return CompilerOptions.Tasks;
552 
553 		case IProblem.UnusedObjectAllocation:
554 			return CompilerOptions.UnusedObjectAllocation;
555 
556 		case IProblem.MethodCanBeStatic:
557 			return CompilerOptions.MethodCanBeStatic;
558 
559 		case IProblem.MethodCanBePotentiallyStatic:
560 			return CompilerOptions.MethodCanBePotentiallyStatic;
561 
562 		case IProblem.UnclosedCloseable:
563 		case IProblem.UnclosedCloseableAtExit:
564 			return CompilerOptions.UnclosedCloseable;
565 		case IProblem.PotentiallyUnclosedCloseable:
566 		case IProblem.PotentiallyUnclosedCloseableAtExit:
567 			return CompilerOptions.PotentiallyUnclosedCloseable;
568 		case IProblem.ExplicitlyClosedAutoCloseable:
569 			return CompilerOptions.ExplicitlyClosedAutoCloseable;
570 
571 		case IProblem.RedundantSpecificationOfTypeArguments:
572 			return CompilerOptions.RedundantSpecificationOfTypeArguments;
573 
574 		case IProblem.MissingNonNullByDefaultAnnotationOnPackage:
575 		case IProblem.MissingNonNullByDefaultAnnotationOnType:
576 			return CompilerOptions.MissingNonNullByDefaultAnnotation;
577 
578 		case IProblem.UnusedTypeParameter:
579 			return CompilerOptions.UnusedTypeParameter;
580 }
581 	return 0;
582 }
583 /**
584  * Compute problem category ID based on problem ID
585  * @param problemID
586  * @return a category ID
587  * @see CategorizedProblem
588  */
getProblemCategory(int severity, int problemID)589 public static int getProblemCategory(int severity, int problemID) {
590 	categorizeOnIrritant: {
591 		// fatal problems even if optional are all falling into same category (not irritant based)
592 		if ((severity & ProblemSeverities.Fatal) != 0)
593 			break categorizeOnIrritant;
594 		int irritant = getIrritant(problemID);
595 		switch (irritant) {
596 			case CompilerOptions.MethodWithConstructorName :
597 			case CompilerOptions.AccessEmulation :
598 			case CompilerOptions.AssertUsedAsAnIdentifier :
599 			case CompilerOptions.NonStaticAccessToStatic :
600 			case CompilerOptions.UnqualifiedFieldAccess :
601 			case CompilerOptions.UndocumentedEmptyBlock :
602 			case CompilerOptions.IndirectStaticAccess :
603 			case CompilerOptions.FinalParameterBound :
604 			case CompilerOptions.EnumUsedAsAnIdentifier :
605 			case CompilerOptions.AnnotationSuperInterface :
606 			case CompilerOptions.AutoBoxing :
607 			case CompilerOptions.MissingOverrideAnnotation :
608 			case CompilerOptions.MissingDeprecatedAnnotation :
609 			case CompilerOptions.ParameterAssignment :
610 			case CompilerOptions.MethodCanBeStatic :
611 			case CompilerOptions.MethodCanBePotentiallyStatic :
612 			case CompilerOptions.ExplicitlyClosedAutoCloseable :
613 				return CategorizedProblem.CAT_CODE_STYLE;
614 
615 			case CompilerOptions.MaskedCatchBlock :
616 			case CompilerOptions.NoImplicitStringConversion :
617 			case CompilerOptions.NoEffectAssignment :
618 			case CompilerOptions.AccidentalBooleanAssign :
619 			case CompilerOptions.EmptyStatement :
620 			case CompilerOptions.FinallyBlockNotCompleting :
621 			case CompilerOptions.MissingSerialVersion :
622 			case CompilerOptions.VarargsArgumentNeedCast :
623 			case CompilerOptions.NullReference :
624 			case CompilerOptions.PotentialNullReference :
625 			case CompilerOptions.RedundantNullCheck :
626 			case CompilerOptions.MissingEnumConstantCase :
627 			case CompilerOptions.MissingDefaultCase :
628 			case CompilerOptions.FallthroughCase :
629 			case CompilerOptions.OverridingMethodWithoutSuperInvocation :
630 			case CompilerOptions.ComparingIdentical :
631 			case CompilerOptions.MissingSynchronizedModifierInInheritedMethod :
632 			case CompilerOptions.ShouldImplementHashcode :
633 			case CompilerOptions.DeadCode :
634 			case CompilerOptions.UnusedObjectAllocation :
635 			case CompilerOptions.UnclosedCloseable :
636 			case CompilerOptions.PotentiallyUnclosedCloseable :
637 				return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM;
638 
639 			case CompilerOptions.OverriddenPackageDefaultMethod :
640 			case CompilerOptions.IncompatibleNonInheritedInterfaceMethod :
641 			case CompilerOptions.LocalVariableHiding :
642 			case CompilerOptions.FieldHiding :
643 			case CompilerOptions.TypeHiding :
644 				return CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT;
645 
646 			case CompilerOptions.UnusedLocalVariable :
647 			case CompilerOptions.UnusedArgument :
648 			case CompilerOptions.UnusedImport :
649 			case CompilerOptions.UnusedPrivateMember :
650 			case CompilerOptions.UnusedDeclaredThrownException :
651 			case CompilerOptions.UnnecessaryTypeCheck :
652 			case CompilerOptions.UnnecessaryElse :
653 			case CompilerOptions.UnhandledWarningToken :
654 			case CompilerOptions.UnusedWarningToken :
655 			case CompilerOptions.UnusedLabel :
656 			case CompilerOptions.RedundantSuperinterface :
657 			case CompilerOptions.RedundantSpecificationOfTypeArguments :
658 			case CompilerOptions.UnusedTypeParameter:
659 				return CategorizedProblem.CAT_UNNECESSARY_CODE;
660 
661 			case CompilerOptions.UsingDeprecatedAPI :
662 				return CategorizedProblem.CAT_DEPRECATION;
663 
664 			case CompilerOptions.NonExternalizedString :
665 				return CategorizedProblem.CAT_NLS;
666 
667 			case CompilerOptions.Task :
668 				return CategorizedProblem.CAT_UNSPECIFIED; // TODO may want to improve
669 
670 			case CompilerOptions.MissingJavadocComments :
671 			case CompilerOptions.MissingJavadocTags :
672 			case CompilerOptions.InvalidJavadoc :
673 			case CompilerOptions.InvalidJavadoc|CompilerOptions.UsingDeprecatedAPI :
674 				return CategorizedProblem.CAT_JAVADOC;
675 
676 			case CompilerOptions.UncheckedTypeOperation :
677 			case CompilerOptions.RawTypeReference :
678 				return CategorizedProblem.CAT_UNCHECKED_RAW;
679 
680 			case CompilerOptions.ForbiddenReference :
681 			case CompilerOptions.DiscouragedReference :
682 				return CategorizedProblem.CAT_RESTRICTION;
683 
684 			case CompilerOptions.NullSpecViolation :
685 			case CompilerOptions.NullAnnotationInferenceConflict :
686 			case CompilerOptions.NullUncheckedConversion :
687 			case CompilerOptions.MissingNonNullByDefaultAnnotation:
688 			case CompilerOptions.NonnullParameterAnnotationDropped:
689 				return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM;
690 			case CompilerOptions.RedundantNullAnnotation :
691 				return CategorizedProblem.CAT_UNNECESSARY_CODE;
692 
693 			default:
694 				break categorizeOnIrritant;
695 		}
696 	}
697 	// categorize fatal problems per ID
698 	switch (problemID) {
699 		case IProblem.IsClassPathCorrect :
700 		case IProblem.CorruptedSignature :
701 			return CategorizedProblem.CAT_BUILDPATH;
702 
703 		default :
704 			if ((problemID & IProblem.Syntax) != 0)
705 				return CategorizedProblem.CAT_SYNTAX;
706 			if ((problemID & IProblem.ImportRelated) != 0)
707 				return CategorizedProblem.CAT_IMPORT;
708 			if ((problemID & IProblem.TypeRelated) != 0)
709 				return CategorizedProblem.CAT_TYPE;
710 			if ((problemID & (IProblem.FieldRelated|IProblem.MethodRelated|IProblem.ConstructorRelated)) != 0)
711 				return CategorizedProblem.CAT_MEMBER;
712 	}
713 	return CategorizedProblem.CAT_INTERNAL;
714 }
abortDueToInternalError(String errorMessage)715 public void abortDueToInternalError(String errorMessage) {
716 	this.abortDueToInternalError(errorMessage, null);
717 }
abortDueToInternalError(String errorMessage, ASTNode location)718 public void abortDueToInternalError(String errorMessage, ASTNode location) {
719 	String[] arguments = new String[] {errorMessage};
720 	this.handle(
721 		IProblem.Unclassified,
722 		arguments,
723 		arguments,
724 		ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
725 		location == null ? 0 : location.sourceStart,
726 		location == null ? 0 : location.sourceEnd);
727 }
abstractMethodCannotBeOverridden(SourceTypeBinding type, MethodBinding concreteMethod)728 public void abstractMethodCannotBeOverridden(SourceTypeBinding type, MethodBinding concreteMethod) {
729 
730 	this.handle(
731 		// %1 must be abstract since it cannot override the inherited package-private abstract method %2
732 		IProblem.AbstractMethodCannotBeOverridden,
733 		new String[] {
734 			new String(type.sourceName()),
735 			new String(
736 					CharOperation.concat(
737 						concreteMethod.declaringClass.readableName(),
738 						concreteMethod.readableName(),
739 						'.'))},
740 		new String[] {
741 			new String(type.sourceName()),
742 			new String(
743 					CharOperation.concat(
744 						concreteMethod.declaringClass.shortReadableName(),
745 						concreteMethod.shortReadableName(),
746 						'.'))},
747 		type.sourceStart(),
748 		type.sourceEnd());
749 }
abstractMethodInAbstractClass(SourceTypeBinding type, AbstractMethodDeclaration methodDecl)750 public void abstractMethodInAbstractClass(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
751 	if (type.isEnum() && type.isLocalType()) {
752 		FieldBinding field = type.scope.enclosingMethodScope().initializedField;
753 		FieldDeclaration decl = field.sourceField();
754 		String[] arguments = new String[] {new String(decl.name), new String(methodDecl.selector)};
755 		this.handle(
756 			IProblem.AbstractMethodInEnum,
757 			arguments,
758 			arguments,
759 			methodDecl.sourceStart,
760 			methodDecl.sourceEnd);
761 	} else {
762 		String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
763 		this.handle(
764 			IProblem.AbstractMethodInAbstractClass,
765 			arguments,
766 			arguments,
767 			methodDecl.sourceStart,
768 			methodDecl.sourceEnd);
769 	}
770 }
abstractMethodInConcreteClass(SourceTypeBinding type)771 public void abstractMethodInConcreteClass(SourceTypeBinding type) {
772 	if (type.isEnum() && type.isLocalType()) {
773 		FieldBinding field = type.scope.enclosingMethodScope().initializedField;
774 		FieldDeclaration decl = field.sourceField();
775 		String[] arguments = new String[] {new String(decl.name)};
776 		this.handle(
777 			IProblem.EnumConstantCannotDefineAbstractMethod,
778 			arguments,
779 			arguments,
780 			decl.sourceStart(),
781 			decl.sourceEnd());
782 	} else {
783 		String[] arguments = new String[] {new String(type.sourceName())};
784 		this.handle(
785 			IProblem.AbstractMethodsInConcreteClass,
786 			arguments,
787 			arguments,
788 			type.sourceStart(),
789 			type.sourceEnd());
790 	}
791 }
abstractMethodMustBeImplemented(SourceTypeBinding type, MethodBinding abstractMethod)792 public void abstractMethodMustBeImplemented(SourceTypeBinding type, MethodBinding abstractMethod) {
793 	if (type.isEnum() && type.isLocalType()) {
794 		FieldBinding field = type.scope.enclosingMethodScope().initializedField;
795 		FieldDeclaration decl = field.sourceField();
796 		this.handle(
797 			// Must implement the inherited abstract method %1
798 			// 8.4.3 - Every non-abstract subclass of an abstract type, A, must provide a concrete implementation of all of A's methods.
799 			IProblem.EnumConstantMustImplementAbstractMethod,
800 			new String[] {
801 			        new String(abstractMethod.selector),
802 			        typesAsString(abstractMethod, false),
803 			        new String(decl.name),
804 			},
805 			new String[] {
806 			        new String(abstractMethod.selector),
807 			        typesAsString(abstractMethod, true),
808 			        new String(decl.name),
809 			},
810 			decl.sourceStart(),
811 			decl.sourceEnd());
812 	} else {
813 		this.handle(
814 			// Must implement the inherited abstract method %1
815 			// 8.4.3 - Every non-abstract subclass of an abstract type, A, must provide a concrete implementation of all of A's methods.
816 			IProblem.AbstractMethodMustBeImplemented,
817 			new String[] {
818 			        new String(abstractMethod.selector),
819 			        typesAsString(abstractMethod, false),
820 			        new String(abstractMethod.declaringClass.readableName()),
821 			        new String(type.readableName()),
822 			},
823 			new String[] {
824 			        new String(abstractMethod.selector),
825 			        typesAsString(abstractMethod, true),
826 			        new String(abstractMethod.declaringClass.shortReadableName()),
827 			        new String(type.shortReadableName()),
828 			},
829 			type.sourceStart(),
830 			type.sourceEnd());
831 	}
832 }
abstractMethodMustBeImplemented(SourceTypeBinding type, MethodBinding abstractMethod, MethodBinding concreteMethod)833 public void abstractMethodMustBeImplemented(SourceTypeBinding type, MethodBinding abstractMethod, MethodBinding concreteMethod) {
834 	this.handle(
835 		// Must implement the inherited abstract method %1
836 		// 8.4.3 - Every non-abstract subclass of an abstract type, A, must provide a concrete implementation of all of A's methods.
837 		IProblem.AbstractMethodMustBeImplementedOverConcreteMethod,
838 		new String[] {
839 		        new String(abstractMethod.selector),
840 		        typesAsString(abstractMethod, false),
841 		        new String(abstractMethod.declaringClass.readableName()),
842 		        new String(type.readableName()),
843 		        new String(concreteMethod.selector),
844 		        typesAsString(concreteMethod, false),
845 		        new String(concreteMethod.declaringClass.readableName()),
846 		},
847 		new String[] {
848 		        new String(abstractMethod.selector),
849 		        typesAsString(abstractMethod, true),
850 		        new String(abstractMethod.declaringClass.shortReadableName()),
851 		        new String(type.shortReadableName()),
852 		        new String(concreteMethod.selector),
853 		        typesAsString(concreteMethod, true),
854 		        new String(concreteMethod.declaringClass.shortReadableName()),
855 		},
856 		type.sourceStart(),
857 		type.sourceEnd());
858 }
abstractMethodNeedingNoBody(AbstractMethodDeclaration method)859 public void abstractMethodNeedingNoBody(AbstractMethodDeclaration method) {
860 	this.handle(
861 		IProblem.BodyForAbstractMethod,
862 		NoArgument,
863 		NoArgument,
864 		method.sourceStart,
865 		method.sourceEnd,
866 		method,
867 		method.compilationResult());
868 }
alreadyDefinedLabel(char[] labelName, ASTNode location)869 public void alreadyDefinedLabel(char[] labelName, ASTNode location) {
870 	String[] arguments = new String[] {new String(labelName)};
871 	this.handle(
872 		IProblem.DuplicateLabel,
873 		arguments,
874 		arguments,
875 		location.sourceStart,
876 		location.sourceEnd);
877 }
annotationCannotOverrideMethod(MethodBinding overrideMethod, MethodBinding inheritedMethod)878 public void annotationCannotOverrideMethod(MethodBinding overrideMethod, MethodBinding inheritedMethod) {
879 	ASTNode location = overrideMethod.sourceMethod();
880 	this.handle(
881 		IProblem.AnnotationCannotOverrideMethod,
882 		new String[] {
883 				new String(overrideMethod.declaringClass.readableName()),
884 				new String(inheritedMethod.declaringClass.readableName()),
885 				new String(inheritedMethod.selector),
886 				typesAsString(inheritedMethod, false)},
887 		new String[] {
888 				new String(overrideMethod.declaringClass.shortReadableName()),
889 				new String(inheritedMethod.declaringClass.shortReadableName()),
890 				new String(inheritedMethod.selector),
891 				typesAsString(inheritedMethod, true)},
892 		location.sourceStart,
893 		location.sourceEnd);
894 }
annotationCircularity(TypeBinding sourceType, TypeBinding otherType, TypeReference reference)895 public void annotationCircularity(TypeBinding sourceType, TypeBinding otherType, TypeReference reference) {
896 	if (TypeBinding.equalsEquals(sourceType, otherType))
897 		this.handle(
898 			IProblem.AnnotationCircularitySelfReference,
899 			new String[] {new String(sourceType.readableName())},
900 			new String[] {new String(sourceType.shortReadableName())},
901 			reference.sourceStart,
902 			reference.sourceEnd);
903 	else
904 		this.handle(
905 			IProblem.AnnotationCircularity,
906 			new String[] {new String(sourceType.readableName()), new String(otherType.readableName())},
907 			new String[] {new String(sourceType.shortReadableName()), new String(otherType.shortReadableName())},
908 			reference.sourceStart,
909 			reference.sourceEnd);
910 }
annotationMembersCannotHaveParameters(AnnotationMethodDeclaration annotationMethodDeclaration)911 public void annotationMembersCannotHaveParameters(AnnotationMethodDeclaration annotationMethodDeclaration) {
912 	this.handle(
913 		IProblem.AnnotationMembersCannotHaveParameters,
914 		NoArgument,
915 		NoArgument,
916 		annotationMethodDeclaration.sourceStart,
917 		annotationMethodDeclaration.sourceEnd);
918 }
annotationMembersCannotHaveTypeParameters(AnnotationMethodDeclaration annotationMethodDeclaration)919 public void annotationMembersCannotHaveTypeParameters(AnnotationMethodDeclaration annotationMethodDeclaration) {
920 	this.handle(
921 		IProblem.AnnotationMembersCannotHaveTypeParameters,
922 		NoArgument,
923 		NoArgument,
924 		annotationMethodDeclaration.sourceStart,
925 		annotationMethodDeclaration.sourceEnd);
926 }
annotationTypeDeclarationCannotHaveConstructor(ConstructorDeclaration constructorDeclaration)927 public void annotationTypeDeclarationCannotHaveConstructor(ConstructorDeclaration constructorDeclaration) {
928 	this.handle(
929 		IProblem.AnnotationTypeDeclarationCannotHaveConstructor,
930 		NoArgument,
931 		NoArgument,
932 		constructorDeclaration.sourceStart,
933 		constructorDeclaration.sourceEnd);
934 }
annotationTypeDeclarationCannotHaveSuperclass(TypeDeclaration typeDeclaration)935 public void annotationTypeDeclarationCannotHaveSuperclass(TypeDeclaration typeDeclaration) {
936 	this.handle(
937 		IProblem.AnnotationTypeDeclarationCannotHaveSuperclass,
938 		NoArgument,
939 		NoArgument,
940 		typeDeclaration.sourceStart,
941 		typeDeclaration.sourceEnd);
942 }
annotationTypeDeclarationCannotHaveSuperinterfaces(TypeDeclaration typeDeclaration)943 public void annotationTypeDeclarationCannotHaveSuperinterfaces(TypeDeclaration typeDeclaration) {
944 	this.handle(
945 		IProblem.AnnotationTypeDeclarationCannotHaveSuperinterfaces,
946 		NoArgument,
947 		NoArgument,
948 		typeDeclaration.sourceStart,
949 		typeDeclaration.sourceEnd);
950 }
annotationTypeUsedAsSuperinterface(SourceTypeBinding type, TypeReference superInterfaceRef, ReferenceBinding superType)951 public void annotationTypeUsedAsSuperinterface(SourceTypeBinding type, TypeReference superInterfaceRef, ReferenceBinding superType) {
952 	this.handle(
953 		IProblem.AnnotationTypeUsedAsSuperInterface,
954 		new String[] {new String(superType.readableName()), new String(type.sourceName())},
955 		new String[] {new String(superType.shortReadableName()), new String(type.sourceName())},
956 		superInterfaceRef.sourceStart,
957 		superInterfaceRef.sourceEnd);
958 }
annotationValueMustBeAnnotation(TypeBinding annotationType, char[] name, Expression value, TypeBinding expectedType)959 public void annotationValueMustBeAnnotation(TypeBinding annotationType, char[] name, Expression value, TypeBinding expectedType) {
960 	String str = new String(name);
961 	this.handle(
962 		IProblem.AnnotationValueMustBeAnnotation,
963 		new String[] { new String(annotationType.readableName()), str, new String(expectedType.readableName()),  },
964 		new String[] { new String(annotationType.shortReadableName()), str, new String(expectedType.readableName()), },
965 		value.sourceStart,
966 		value.sourceEnd);
967 }
annotationValueMustBeArrayInitializer(TypeBinding annotationType, char[] name, Expression value)968 public void annotationValueMustBeArrayInitializer(TypeBinding annotationType, char[] name, Expression value) {
969 	String str = new String(name);
970 	this.handle(
971     	IProblem.AnnotationValueMustBeArrayInitializer,
972 		new String[] { new String(annotationType.readableName()), str },
973 		new String[] { new String(annotationType.shortReadableName()), str},
974     	value.sourceStart,
975     	value.sourceEnd);
976 }
annotationValueMustBeClassLiteral(TypeBinding annotationType, char[] name, Expression value)977 public void annotationValueMustBeClassLiteral(TypeBinding annotationType, char[] name, Expression value) {
978 	String str = new String(name);
979 	this.handle(
980 		IProblem.AnnotationValueMustBeClassLiteral,
981 		new String[] { new String(annotationType.readableName()), str },
982 		new String[] { new String(annotationType.shortReadableName()), str},
983 		value.sourceStart,
984 		value.sourceEnd);
985 }
annotationValueMustBeConstant(TypeBinding annotationType, char[] name, Expression value, boolean isEnum)986 public void annotationValueMustBeConstant(TypeBinding annotationType, char[] name, Expression value, boolean isEnum) {
987 	String str = new String(name);
988 	if (isEnum) {
989     	this.handle(
990     		IProblem.AnnotationValueMustBeAnEnumConstant,
991     		new String[] { new String(annotationType.readableName()), str },
992     		new String[] { new String(annotationType.shortReadableName()), str},
993     		value.sourceStart,
994     		value.sourceEnd);
995 	} else {
996     	this.handle(
997     		IProblem.AnnotationValueMustBeConstant,
998     		new String[] { new String(annotationType.readableName()), str },
999     		new String[] { new String(annotationType.shortReadableName()), str},
1000     		value.sourceStart,
1001     		value.sourceEnd);
1002     }
1003 }
anonymousClassCannotExtendFinalClass(TypeReference reference, TypeBinding type)1004 public void anonymousClassCannotExtendFinalClass(TypeReference reference, TypeBinding type) {
1005 	this.handle(
1006 		IProblem.AnonymousClassCannotExtendFinalClass,
1007 		new String[] {new String(type.readableName())},
1008 		new String[] {new String(type.shortReadableName())},
1009 		reference.sourceStart,
1010 		reference.sourceEnd);
1011 }
argumentTypeCannotBeVoid(ASTNode methodDecl, Argument arg)1012 public void argumentTypeCannotBeVoid(ASTNode methodDecl, Argument arg) {
1013 	String[] arguments = new String[] { new String(arg.name) };
1014 	this.handle(
1015 		IProblem.ArgumentTypeCannotBeVoid,
1016 		arguments,
1017 		arguments,
1018 		methodDecl.sourceStart,
1019 		methodDecl.sourceEnd);
1020 }
argumentTypeCannotBeVoidArray(Argument arg)1021 public void argumentTypeCannotBeVoidArray(Argument arg) {
1022 	this.handle(
1023 		IProblem.CannotAllocateVoidArray,
1024 		NoArgument,
1025 		NoArgument,
1026 		arg.type.sourceStart,
1027 		arg.type.sourceEnd);
1028 }
arrayConstantsOnlyInArrayInitializers(int sourceStart, int sourceEnd)1029 public void arrayConstantsOnlyInArrayInitializers(int sourceStart, int sourceEnd) {
1030 	this.handle(
1031 		IProblem.ArrayConstantsOnlyInArrayInitializers,
1032 		NoArgument,
1033 		NoArgument,
1034 		sourceStart,
1035 		sourceEnd);
1036 }
assignmentHasNoEffect(AbstractVariableDeclaration location, char[] name)1037 public void assignmentHasNoEffect(AbstractVariableDeclaration location, char[] name){
1038 	int severity = computeSeverity(IProblem.AssignmentHasNoEffect);
1039 	if (severity == ProblemSeverities.Ignore) return;
1040 	String[] arguments = new String[] { new String(name) };
1041 	int start = location.sourceStart;
1042 	int end = location.sourceEnd;
1043 	if (location.initialization != null) {
1044 		end = location.initialization.sourceEnd;
1045 	}
1046 	this.handle(
1047 			IProblem.AssignmentHasNoEffect,
1048 			arguments,
1049 			arguments,
1050 			severity,
1051 			start,
1052 			end);
1053 }
assignmentHasNoEffect(Assignment location, char[] name)1054 public void assignmentHasNoEffect(Assignment location, char[] name){
1055 	int severity = computeSeverity(IProblem.AssignmentHasNoEffect);
1056 	if (severity == ProblemSeverities.Ignore) return;
1057 	String[] arguments = new String[] { new String(name) };
1058 	this.handle(
1059 			IProblem.AssignmentHasNoEffect,
1060 			arguments,
1061 			arguments,
1062 			severity,
1063 			location.sourceStart,
1064 			location.sourceEnd);
1065 }
1066 
attemptToReturnNonVoidExpression(ReturnStatement returnStatement, TypeBinding expectedType)1067 public void attemptToReturnNonVoidExpression(ReturnStatement returnStatement, TypeBinding expectedType) {
1068 	this.handle(
1069 		IProblem.VoidMethodReturnsValue,
1070 		new String[] {new String(expectedType.readableName())},
1071 		new String[] {new String(expectedType.shortReadableName())},
1072 		returnStatement.sourceStart,
1073 		returnStatement.sourceEnd);
1074 }
1075 
1076 
attemptToReturnVoidValue(ReturnStatement returnStatement)1077 public void attemptToReturnVoidValue(ReturnStatement returnStatement) {
1078 	this.handle(
1079 		IProblem.MethodReturnsVoid,
1080 		NoArgument,
1081 		NoArgument,
1082 		returnStatement.sourceStart,
1083 		returnStatement.sourceEnd);
1084 }
autoboxing(Expression expression, TypeBinding originalType, TypeBinding convertedType)1085 public void autoboxing(Expression expression, TypeBinding originalType, TypeBinding convertedType) {
1086 	if (this.options.getSeverity(CompilerOptions.AutoBoxing) == ProblemSeverities.Ignore) return;
1087 	this.handle(
1088 		originalType.isBaseType() ? IProblem.BoxingConversion : IProblem.UnboxingConversion,
1089 		new String[] { new String(originalType.readableName()), new String(convertedType.readableName()), },
1090 		new String[] { new String(originalType.shortReadableName()), new String(convertedType.shortReadableName()), },
1091 		expression.sourceStart,
1092 		expression.sourceEnd);
1093 }
boundCannotBeArray(ASTNode location, TypeBinding type)1094 public void boundCannotBeArray(ASTNode location, TypeBinding type) {
1095 	this.handle(
1096 		IProblem.BoundCannotBeArray,
1097 		new String[] {new String(type.readableName())},
1098 		new String[] {new String(type.shortReadableName())},
1099 		location.sourceStart,
1100 		location.sourceEnd);
1101 }
boundMustBeAnInterface(ASTNode location, TypeBinding type)1102 public void boundMustBeAnInterface(ASTNode location, TypeBinding type) {
1103 	this.handle(
1104 		IProblem.BoundMustBeAnInterface,
1105 		new String[] {new String(type.readableName())},
1106 		new String[] {new String(type.shortReadableName())},
1107 		location.sourceStart,
1108 		location.sourceEnd);
1109 }
bytecodeExceeds64KLimit(AbstractMethodDeclaration location)1110 public void bytecodeExceeds64KLimit(AbstractMethodDeclaration location) {
1111 	MethodBinding method = location.binding;
1112 	if (location.isConstructor()) {
1113 		this.handle(
1114 			IProblem.BytecodeExceeds64KLimitForConstructor,
1115 			new String[] {new String(location.selector), typesAsString(method, false)},
1116 			new String[] {new String(location.selector), typesAsString(method, true)},
1117 			ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
1118 			location.sourceStart,
1119 			location.sourceEnd);
1120 	} else {
1121 		this.handle(
1122 			IProblem.BytecodeExceeds64KLimit,
1123 			new String[] {new String(location.selector), typesAsString(method, false)},
1124 			new String[] {new String(location.selector), typesAsString(method, true)},
1125 			ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
1126 			location.sourceStart,
1127 			location.sourceEnd);
1128 	}
1129 }
bytecodeExceeds64KLimit(LambdaExpression location)1130 public void bytecodeExceeds64KLimit(LambdaExpression location) {
1131 	MethodBinding method = location.binding;
1132 		this.handle(
1133 			IProblem.BytecodeExceeds64KLimit,
1134 			new String[] {new String(method.selector), typesAsString(method, false)},
1135 			new String[] {new String(method.selector), typesAsString(method, true)},
1136 			ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
1137 			location.sourceStart,
1138 			location.diagnosticsSourceEnd());
1139 }
bytecodeExceeds64KLimit(TypeDeclaration location)1140 public void bytecodeExceeds64KLimit(TypeDeclaration location) {
1141 	this.handle(
1142 		IProblem.BytecodeExceeds64KLimitForClinit,
1143 		NoArgument,
1144 		NoArgument,
1145 		ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
1146 		location.sourceStart,
1147 		location.sourceEnd);
1148 }
cannotAllocateVoidArray(Expression expression)1149 public void cannotAllocateVoidArray(Expression expression) {
1150 	this.handle(
1151 		IProblem.CannotAllocateVoidArray,
1152 		NoArgument,
1153 		NoArgument,
1154 		expression.sourceStart,
1155 		expression.sourceEnd);
1156 }
cannotAssignToFinalField(FieldBinding field, ASTNode location)1157 public void cannotAssignToFinalField(FieldBinding field, ASTNode location) {
1158 	this.handle(
1159 		IProblem.FinalFieldAssignment,
1160 		new String[] {
1161 			(field.declaringClass == null ? "array" : new String(field.declaringClass.readableName())), //$NON-NLS-1$
1162 			new String(field.readableName())},
1163 		new String[] {
1164 			(field.declaringClass == null ? "array" : new String(field.declaringClass.shortReadableName())), //$NON-NLS-1$
1165 			new String(field.shortReadableName())},
1166 		nodeSourceStart(field, location),
1167 		nodeSourceEnd(field, location));
1168 }
cannotAssignToFinalLocal(LocalVariableBinding local, ASTNode location)1169 public void cannotAssignToFinalLocal(LocalVariableBinding local, ASTNode location) {
1170 	int problemId = 0;
1171 	if ((local.tagBits & TagBits.MultiCatchParameter) != 0) {
1172 		problemId = IProblem.AssignmentToMultiCatchParameter;
1173 	} else if ((local.tagBits & TagBits.IsResource) != 0) {
1174 		problemId = IProblem.AssignmentToResource;
1175 	} else {
1176 		problemId = IProblem.NonBlankFinalLocalAssignment;
1177 	}
1178 	String[] arguments = new String[] { new String(local.readableName())};
1179 	this.handle(
1180 		problemId,
1181 		arguments,
1182 		arguments,
1183 		nodeSourceStart(local, location),
1184 		nodeSourceEnd(local, location));
1185 }
cannotAssignToFinalOuterLocal(LocalVariableBinding local, ASTNode location)1186 public void cannotAssignToFinalOuterLocal(LocalVariableBinding local, ASTNode location) {
1187 	String[] arguments = new String[] {new String(local.readableName())};
1188 	this.handle(
1189 		IProblem.FinalOuterLocalAssignment,
1190 		arguments,
1191 		arguments,
1192 		nodeSourceStart(local, location),
1193 		nodeSourceEnd(local, location));
1194 }
cannotDefineDimensionsAndInitializer(ArrayAllocationExpression expresssion)1195 public void cannotDefineDimensionsAndInitializer(ArrayAllocationExpression expresssion) {
1196 	this.handle(
1197 		IProblem.CannotDefineDimensionExpressionsWithInit,
1198 		NoArgument,
1199 		NoArgument,
1200 		expresssion.sourceStart,
1201 		expresssion.sourceEnd);
1202 }
cannotDireclyInvokeAbstractMethod(ASTNode invocationSite, MethodBinding method)1203 public void cannotDireclyInvokeAbstractMethod(ASTNode invocationSite, MethodBinding method) {
1204 	this.handle(
1205 		IProblem.DirectInvocationOfAbstractMethod,
1206 		new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method, false)},
1207 		new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method, true)},
1208 		invocationSite.sourceStart,
1209 		invocationSite.sourceEnd);
1210 }
cannotExtendEnum(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding)1211 public void cannotExtendEnum(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) {
1212 	String name = new String(type.sourceName());
1213 	String superTypeFullName = new String(superTypeBinding.readableName());
1214 	String superTypeShortName = new String(superTypeBinding.shortReadableName());
1215 	if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName;
1216 	this.handle(
1217 		IProblem.CannotExtendEnum,
1218 		new String[] {superTypeFullName, name},
1219 		new String[] {superTypeShortName, name},
1220 		superclass.sourceStart,
1221 		superclass.sourceEnd);
1222 }
cannotImportPackage(ImportReference importRef)1223 public void cannotImportPackage(ImportReference importRef) {
1224 	String[] arguments = new String[] {CharOperation.toString(importRef.tokens)};
1225 	this.handle(
1226 		IProblem.CannotImportPackage,
1227 		arguments,
1228 		arguments,
1229 		importRef.sourceStart,
1230 		importRef.sourceEnd);
1231 }
cannotInstantiate(Expression typeRef, TypeBinding type)1232 public void cannotInstantiate(Expression typeRef, TypeBinding type) {
1233 	this.handle(
1234 		IProblem.InvalidClassInstantiation,
1235 		new String[] {new String(type.readableName())},
1236 		new String[] {new String(type.shortReadableName())},
1237 		typeRef.sourceStart,
1238 		typeRef.sourceEnd);
1239 }
cannotInvokeSuperConstructorInEnum(ExplicitConstructorCall constructorCall, MethodBinding enumConstructor)1240 public void cannotInvokeSuperConstructorInEnum(ExplicitConstructorCall constructorCall, MethodBinding enumConstructor) {
1241 	this.handle(
1242 		IProblem.CannotInvokeSuperConstructorInEnum,
1243 		new String[] {
1244 		        new String(enumConstructor.declaringClass.sourceName()),
1245 		        typesAsString(enumConstructor, false),
1246 		 },
1247 		new String[] {
1248 		        new String(enumConstructor.declaringClass.sourceName()),
1249 		        typesAsString(enumConstructor, true),
1250 		 },
1251 		constructorCall.sourceStart,
1252 		constructorCall.sourceEnd);
1253 }
cannotReadSource(CompilationUnitDeclaration unit, AbortCompilationUnit abortException, boolean verbose)1254 public void cannotReadSource(CompilationUnitDeclaration unit, AbortCompilationUnit abortException, boolean verbose) {
1255 	String fileName = new String(unit.compilationResult.fileName);
1256 	if (abortException.exception instanceof CharConversionException) {
1257 		// specific encoding issue
1258 		String encoding = abortException.encoding;
1259 		if (encoding == null) {
1260 			encoding = System.getProperty("file.encoding"); //$NON-NLS-1$
1261 		}
1262 		String[] arguments = new String[]{ fileName, encoding };
1263 		this.handle(
1264 				IProblem.InvalidEncoding,
1265 				arguments,
1266 				arguments,
1267 				0,
1268 				0);
1269 		return;
1270 	}
1271 	StringWriter stringWriter = new StringWriter();
1272 	PrintWriter writer = new PrintWriter(stringWriter);
1273 	if (verbose) {
1274 		abortException.exception.printStackTrace(writer);
1275 		System.err.println(stringWriter.toString());
1276 		stringWriter = new StringWriter();
1277 		writer = new PrintWriter(stringWriter);
1278 	}
1279 	writer.print(abortException.exception.getClass().getName());
1280 	writer.print(':');
1281 	writer.print(abortException.exception.getMessage());
1282 	String exceptionTrace = stringWriter.toString();
1283 	String[] arguments = new String[]{ fileName, exceptionTrace };
1284 	this.handle(
1285 			IProblem.CannotReadSource,
1286 			arguments,
1287 			arguments,
1288 			0,
1289 			0);
1290 }
cannotReferToNonFinalOuterLocal(LocalVariableBinding local, ASTNode location)1291 public void cannotReferToNonFinalOuterLocal(LocalVariableBinding local, ASTNode location) {
1292 	String[] arguments =new String[]{ new String(local.readableName())};
1293 	this.handle(
1294 		IProblem.OuterLocalMustBeFinal,
1295 		arguments,
1296 		arguments,
1297 		nodeSourceStart(local, location),
1298 		nodeSourceEnd(local, location));
1299 }
cannotReferToNonEffectivelyFinalOuterLocal(LocalVariableBinding local, ASTNode location)1300 public void cannotReferToNonEffectivelyFinalOuterLocal(LocalVariableBinding local, ASTNode location) {
1301 	String[] arguments = new String[] { new String(local.readableName()) };
1302 	this.handle(
1303 		IProblem.OuterLocalMustBeEffectivelyFinal,
1304 		arguments,
1305 		arguments,
1306 		nodeSourceStart(local, location),
1307 		nodeSourceEnd(local, location));
1308 }
cannotReturnInInitializer(ASTNode location)1309 public void cannotReturnInInitializer(ASTNode location) {
1310 	this.handle(
1311 		IProblem.CannotReturnInInitializer,
1312 		NoArgument,
1313 		NoArgument,
1314 		location.sourceStart,
1315 		location.sourceEnd);
1316 }
cannotThrowNull(ASTNode expression)1317 public void cannotThrowNull(ASTNode expression) {
1318 	this.handle(
1319 		IProblem.CannotThrowNull,
1320 		NoArgument,
1321 		NoArgument,
1322 		expression.sourceStart,
1323 		expression.sourceEnd);
1324 }
cannotThrowType(ASTNode exception, TypeBinding expectedType)1325 public void cannotThrowType(ASTNode exception, TypeBinding expectedType) {
1326 	this.handle(
1327 		IProblem.CannotThrowType,
1328 		new String[] {new String(expectedType.readableName())},
1329 		new String[] {new String(expectedType.shortReadableName())},
1330 		exception.sourceStart,
1331 		exception.sourceEnd);
1332 }
1333 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=391092
illegalArrayOfUnionType(char[] identifierName, TypeReference typeReference)1334 public void illegalArrayOfUnionType(char[] identifierName, TypeReference typeReference) {
1335 		this.handle(
1336 		IProblem.IllegalArrayOfUnionType,
1337 		NoArgument,
1338 		NoArgument,
1339 		typeReference.sourceStart,
1340 		typeReference.sourceEnd);
1341 }
cannotUseQualifiedEnumConstantInCaseLabel(Reference location, FieldBinding field)1342 public void cannotUseQualifiedEnumConstantInCaseLabel(Reference location, FieldBinding field) {
1343 	this.handle(
1344 		IProblem.IllegalQualifiedEnumConstantLabel,
1345 		new String[]{ String.valueOf(field.declaringClass.readableName()), String.valueOf(field.name) },
1346 		new String[]{ String.valueOf(field.declaringClass.shortReadableName()), String.valueOf(field.name) },
1347 		location.sourceStart(),
1348 		location.sourceEnd());
1349 }
cannotUseSuperInCodeSnippet(int start, int end)1350 public void cannotUseSuperInCodeSnippet(int start, int end) {
1351 	this.handle(
1352 		IProblem.CannotUseSuperInCodeSnippet,
1353 		NoArgument,
1354 		NoArgument,
1355 		ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
1356 		start,
1357 		end);
1358 }
cannotUseSuperInJavaLangObject(ASTNode reference)1359 public void cannotUseSuperInJavaLangObject(ASTNode reference) {
1360 	this.handle(
1361 		IProblem.ObjectHasNoSuperclass,
1362 		NoArgument,
1363 		NoArgument,
1364 		reference.sourceStart,
1365 		reference.sourceEnd);
1366 }
targetTypeIsNotAFunctionalInterface(FunctionalExpression target)1367 public void targetTypeIsNotAFunctionalInterface(FunctionalExpression target) {
1368 	this.handle(
1369 		IProblem.TargetTypeNotAFunctionalInterface,
1370 		NoArgument,
1371 		NoArgument,
1372 		target.sourceStart,
1373 		target.diagnosticsSourceEnd());
1374 }
illFormedParameterizationOfFunctionalInterface(FunctionalExpression target)1375 public void illFormedParameterizationOfFunctionalInterface(FunctionalExpression target) {
1376 	this.handle(
1377 		IProblem.illFormedParameterizationOfFunctionalInterface,
1378 		NoArgument,
1379 		NoArgument,
1380 		target.sourceStart,
1381 		target.diagnosticsSourceEnd());
1382 }
lambdaSignatureMismatched(LambdaExpression target)1383 public void lambdaSignatureMismatched(LambdaExpression target) {
1384 	this.handle(
1385 		IProblem.lambdaSignatureMismatched,
1386 		new String[] { new String(target.descriptor.readableName()) },
1387 		new String[] { new String(target.descriptor.shortReadableName()) },
1388 		target.sourceStart,
1389 		target.diagnosticsSourceEnd());
1390 }
1391 
lambdaParameterTypeMismatched(Argument argument, TypeReference type, TypeBinding expectedParameterType)1392 public void lambdaParameterTypeMismatched(Argument argument, TypeReference type, TypeBinding expectedParameterType) {
1393 	String name = new String(argument.name);
1394 	String expectedTypeFullName = new String(expectedParameterType.readableName());
1395 	String expectedTypeShortName = new String(expectedParameterType.shortReadableName());
1396 	this.handle(
1397 			expectedParameterType.isTypeVariable() ? IProblem.IncompatibleLambdaParameterType : IProblem.lambdaParameterTypeMismatched,
1398 			new String[] { name, expectedTypeFullName },
1399 			new String[] { name, expectedTypeShortName },
1400 			type.sourceStart,
1401 			type.sourceEnd);
1402 }
lambdaExpressionCannotImplementGenericMethod(LambdaExpression lambda, MethodBinding sam)1403 public void lambdaExpressionCannotImplementGenericMethod(LambdaExpression lambda, MethodBinding sam) {
1404 	final String selector = new String(sam.selector);
1405 	this.handle(
1406 			IProblem.NoGenericLambda,
1407 			new String[] { selector, new String(sam.declaringClass.readableName())},
1408 			new String[] { selector, new String(sam.declaringClass.shortReadableName())},
1409 			lambda.sourceStart,
1410 			lambda.diagnosticsSourceEnd());
1411 }
caseExpressionMustBeConstant(Expression expression)1412 public void caseExpressionMustBeConstant(Expression expression) {
1413 	this.handle(
1414 		IProblem.NonConstantExpression,
1415 		NoArgument,
1416 		NoArgument,
1417 		expression.sourceStart,
1418 		expression.sourceEnd);
1419 }
classExtendFinalClass(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding)1420 public void classExtendFinalClass(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) {
1421 	String name = new String(type.sourceName());
1422 	String superTypeFullName = new String(superTypeBinding.readableName());
1423 	String superTypeShortName = new String(superTypeBinding.shortReadableName());
1424 	if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName;
1425 	this.handle(
1426 		IProblem.ClassExtendFinalClass,
1427 		new String[] {superTypeFullName, name},
1428 		new String[] {superTypeShortName, name},
1429 		superclass.sourceStart,
1430 		superclass.sourceEnd);
1431 }
codeSnippetMissingClass(String missing, int start, int end)1432 public void codeSnippetMissingClass(String missing, int start, int end) {
1433 	String[] arguments = new String[]{missing};
1434 	this.handle(
1435 		IProblem.CodeSnippetMissingClass,
1436 		arguments,
1437 		arguments,
1438 		ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
1439 		start,
1440 		end);
1441 }
codeSnippetMissingMethod(String className, String missingMethod, String argumentTypes, int start, int end)1442 public void codeSnippetMissingMethod(String className, String missingMethod, String argumentTypes, int start, int end) {
1443 	String[] arguments = new String[]{ className, missingMethod, argumentTypes };
1444 	this.handle(
1445 		IProblem.CodeSnippetMissingMethod,
1446 		arguments,
1447 		arguments,
1448 		ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
1449 		start,
1450 		end);
1451 }
comparingIdenticalExpressions(Expression comparison)1452 public void comparingIdenticalExpressions(Expression comparison){
1453 	int severity = computeSeverity(IProblem.ComparingIdentical);
1454 	if (severity == ProblemSeverities.Ignore) return;
1455 	this.handle(
1456 			IProblem.ComparingIdentical,
1457 			NoArgument,
1458 			NoArgument,
1459 			severity,
1460 			comparison.sourceStart,
1461 			comparison.sourceEnd);
1462 }
1463 /*
1464  * Given the current configuration, answers which category the problem
1465  * falls into:
1466  *		ProblemSeverities.Error | ProblemSeverities.Warning | ProblemSeverities.Ignore
1467  * when different from Ignore, severity can be coupled with ProblemSeverities.Optional
1468  * to indicate that this problem is configurable through options
1469  */
computeSeverity(int problemID)1470 public int computeSeverity(int problemID){
1471 
1472 	switch (problemID) {
1473 		case IProblem.VarargsConflict :
1474 			return ProblemSeverities.Warning;
1475  		case IProblem.TypeCollidesWithPackage :
1476 			return ProblemSeverities.Warning;
1477 
1478 		/*
1479 		 * Javadoc tags resolved references errors
1480 		 */
1481 		case IProblem.JavadocInvalidParamName:
1482 		case IProblem.JavadocDuplicateParamName:
1483 		case IProblem.JavadocMissingParamName:
1484 		case IProblem.JavadocInvalidMemberTypeQualification:
1485 		case IProblem.JavadocInvalidThrowsClassName:
1486 		case IProblem.JavadocDuplicateThrowsClassName:
1487 		case IProblem.JavadocMissingThrowsClassName:
1488 		case IProblem.JavadocMissingSeeReference:
1489 		case IProblem.JavadocInvalidValueReference:
1490 		case IProblem.JavadocUndefinedField:
1491 		case IProblem.JavadocAmbiguousField:
1492 		case IProblem.JavadocUndefinedConstructor:
1493 		case IProblem.JavadocAmbiguousConstructor:
1494 		case IProblem.JavadocUndefinedMethod:
1495 		case IProblem.JavadocAmbiguousMethod:
1496 		case IProblem.JavadocAmbiguousMethodReference:
1497 		case IProblem.JavadocParameterMismatch:
1498 		case IProblem.JavadocUndefinedType:
1499 		case IProblem.JavadocAmbiguousType:
1500 		case IProblem.JavadocInternalTypeNameProvided:
1501 		case IProblem.JavadocNoMessageSendOnArrayType:
1502 		case IProblem.JavadocNoMessageSendOnBaseType:
1503 		case IProblem.JavadocInheritedMethodHidesEnclosingName:
1504 		case IProblem.JavadocInheritedFieldHidesEnclosingName:
1505 		case IProblem.JavadocInheritedNameHidesEnclosingTypeName:
1506 		case IProblem.JavadocNonStaticTypeFromStaticInvocation:
1507 		case IProblem.JavadocGenericMethodTypeArgumentMismatch:
1508 		case IProblem.JavadocNonGenericMethod:
1509 		case IProblem.JavadocIncorrectArityForParameterizedMethod:
1510 		case IProblem.JavadocParameterizedMethodArgumentTypeMismatch:
1511 		case IProblem.JavadocTypeArgumentsForRawGenericMethod:
1512 		case IProblem.JavadocGenericConstructorTypeArgumentMismatch:
1513 		case IProblem.JavadocNonGenericConstructor:
1514 		case IProblem.JavadocIncorrectArityForParameterizedConstructor:
1515 		case IProblem.JavadocParameterizedConstructorArgumentTypeMismatch:
1516 		case IProblem.JavadocTypeArgumentsForRawGenericConstructor:
1517 			if (!this.options.reportInvalidJavadocTags) {
1518 				return ProblemSeverities.Ignore;
1519 			}
1520 			break;
1521 		/*
1522 		 * Javadoc invalid tags due to deprecated references
1523 		 */
1524 		case IProblem.JavadocUsingDeprecatedField:
1525 		case IProblem.JavadocUsingDeprecatedConstructor:
1526 		case IProblem.JavadocUsingDeprecatedMethod:
1527 		case IProblem.JavadocUsingDeprecatedType:
1528 			if (!(this.options.reportInvalidJavadocTags && this.options.reportInvalidJavadocTagsDeprecatedRef)) {
1529 				return ProblemSeverities.Ignore;
1530 			}
1531 			break;
1532 		/*
1533 		 * Javadoc invalid tags due to non-visible references
1534 		 */
1535 		case IProblem.JavadocNotVisibleField:
1536 		case IProblem.JavadocNotVisibleConstructor:
1537 		case IProblem.JavadocNotVisibleMethod:
1538 		case IProblem.JavadocNotVisibleType:
1539 		case IProblem.JavadocHiddenReference:
1540 			if (!(this.options.reportInvalidJavadocTags && this.options.reportInvalidJavadocTagsNotVisibleRef)) {
1541 				return ProblemSeverities.Ignore;
1542 			}
1543 			break;
1544 		/*
1545 		 * Javadoc missing tag descriptions
1546 		 */
1547 		case IProblem.JavadocEmptyReturnTag:
1548 			if (CompilerOptions.NO_TAG.equals(this.options.reportMissingJavadocTagDescription)) {
1549 				return ProblemSeverities.Ignore;
1550 			}
1551 			break;
1552 		case IProblem.JavadocMissingTagDescription:
1553 			if (! CompilerOptions.ALL_STANDARD_TAGS.equals(this.options.reportMissingJavadocTagDescription)) {
1554 				return ProblemSeverities.Ignore;
1555 			}
1556 			break;
1557 		// For compatibility with javac 8b111 for now.
1558 		case IProblem.RepeatableAnnotationWithRepeatingContainerAnnotation:
1559 		case IProblem.ToleratedMisplacedTypeAnnotations:
1560 			return ProblemSeverities.Warning;
1561 		case IProblem.IllegalUseOfUnderscoreAsAnIdentifier:
1562 			return this.underScoreIsLambdaParameter ? ProblemSeverities.Error : ProblemSeverities.Warning;
1563 	}
1564 	int irritant = getIrritant(problemID);
1565 	if (irritant != 0) {
1566 		if ((problemID & IProblem.Javadoc) != 0 && !this.options.docCommentSupport)
1567 			return ProblemSeverities.Ignore;
1568 		return this.options.getSeverity(irritant);
1569 	}
1570 	return ProblemSeverities.Error | ProblemSeverities.Fatal;
1571 }
conditionalArgumentsIncompatibleTypes(ConditionalExpression expression, TypeBinding trueType, TypeBinding falseType)1572 public void conditionalArgumentsIncompatibleTypes(ConditionalExpression expression, TypeBinding trueType, TypeBinding falseType) {
1573 	this.handle(
1574 		IProblem.IncompatibleTypesInConditionalOperator,
1575 		new String[] {new String(trueType.readableName()), new String(falseType.readableName())},
1576 		new String[] {new String(trueType.shortReadableName()), new String(falseType.shortReadableName())},
1577 		expression.sourceStart,
1578 		expression.sourceEnd);
1579 }
conflictingImport(ImportReference importRef)1580 public void conflictingImport(ImportReference importRef) {
1581 	String[] arguments = new String[] {CharOperation.toString(importRef.tokens)};
1582 	this.handle(
1583 		IProblem.ConflictingImport,
1584 		arguments,
1585 		arguments,
1586 		importRef.sourceStart,
1587 		importRef.sourceEnd);
1588 }
constantOutOfRange(Literal literal, TypeBinding literalType)1589 public void constantOutOfRange(Literal literal, TypeBinding literalType) {
1590 	String[] arguments = new String[] {new String(literalType.readableName()), new String(literal.source())};
1591 	this.handle(
1592 		IProblem.NumericValueOutOfRange,
1593 		arguments,
1594 		arguments,
1595 		literal.sourceStart,
1596 		literal.sourceEnd);
1597 }
corruptedSignature(TypeBinding enclosingType, char[] signature, int position)1598 public void corruptedSignature(TypeBinding enclosingType, char[] signature, int position) {
1599 	this.handle(
1600 		IProblem.CorruptedSignature,
1601 		new String[] { new String(enclosingType.readableName()), new String(signature), String.valueOf(position) },
1602 		new String[] { new String(enclosingType.shortReadableName()), new String(signature), String.valueOf(position) },
1603 		ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
1604 		0,
1605 		0);
1606 }
defaultMethodOverridesObjectMethod(MethodBinding currentMethod)1607 public void defaultMethodOverridesObjectMethod(MethodBinding currentMethod) {
1608 	// Java 8 feature
1609 	AbstractMethodDeclaration method = currentMethod.sourceMethod();
1610 	int sourceStart = 0;
1611 	int sourceEnd = 0;
1612 	if (method != null) {
1613 		sourceStart = method.sourceStart;
1614 		sourceEnd = method.sourceEnd;
1615 	}
1616 	this.handle(
1617 		IProblem.DefaultMethodOverridesObjectMethod,
1618 		NoArgument, NoArgument,
1619 		sourceStart, sourceEnd);
1620 }
1621 
defaultModifierIllegallySpecified(int sourceStart, int sourceEnd)1622 public void defaultModifierIllegallySpecified(int sourceStart, int sourceEnd) {
1623 	this.handle(
1624 		IProblem.IllegalDefaultModifierSpecification,
1625 		NoArgument, NoArgument,
1626 		sourceStart, sourceEnd);
1627 }
1628 
deprecatedField(FieldBinding field, ASTNode location)1629 public void deprecatedField(FieldBinding field, ASTNode location) {
1630 	int severity = computeSeverity(IProblem.UsingDeprecatedField);
1631 	if (severity == ProblemSeverities.Ignore) return;
1632 	this.handle(
1633 		IProblem.UsingDeprecatedField,
1634 		new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
1635 		new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
1636 		severity,
1637 		nodeSourceStart(field, location),
1638 		nodeSourceEnd(field, location));
1639 }
1640 
deprecatedMethod(MethodBinding method, ASTNode location)1641 public void deprecatedMethod(MethodBinding method, ASTNode location) {
1642 	boolean isConstructor = method.isConstructor();
1643 	int severity = computeSeverity(isConstructor ? IProblem.UsingDeprecatedConstructor : IProblem.UsingDeprecatedMethod);
1644 	if (severity == ProblemSeverities.Ignore) return;
1645 	if (isConstructor) {
1646 		int start = -1;
1647 		if(location instanceof AllocationExpression) {
1648 			// omit the new keyword from the warning marker
1649 			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=300031
1650 			AllocationExpression allocationExpression = (AllocationExpression) location;
1651 			if (allocationExpression.enumConstant != null) {
1652 				start = allocationExpression.enumConstant.sourceStart;
1653 			}
1654 			start = allocationExpression.type.sourceStart;
1655 		}
1656 		this.handle(
1657 			IProblem.UsingDeprecatedConstructor,
1658 			new String[] {new String(method.declaringClass.readableName()), typesAsString(method, false)},
1659 			new String[] {new String(method.declaringClass.shortReadableName()), typesAsString(method, true)},
1660 			severity,
1661 			(start == -1) ? location.sourceStart : start,
1662 			location.sourceEnd);
1663 	} else {
1664 		int start = -1;
1665 		if (location instanceof MessageSend) {
1666 			// start the warning marker from the location where the name of the method starts
1667 			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=300031
1668 			start = (int) (((MessageSend)location).nameSourcePosition >>> 32);
1669 		}
1670 		this.handle(
1671 			IProblem.UsingDeprecatedMethod,
1672 			new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method, false)},
1673 			new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method, true)},
1674 			severity,
1675 			(start == -1) ? location.sourceStart : start,
1676 			location.sourceEnd);
1677 	}
1678 }
deprecatedType(TypeBinding type, ASTNode location)1679 public void deprecatedType(TypeBinding type, ASTNode location) {
1680 	deprecatedType(type, location, Integer.MAX_VALUE);
1681 }
1682 // The argument 'index' makes sure that we demarcate partial types correctly while marking off
1683 // a deprecated type in a qualified reference (see bug 292510)
deprecatedType(TypeBinding type, ASTNode location, int index)1684 public void deprecatedType(TypeBinding type, ASTNode location, int index) {
1685 	if (location == null) return; // 1G828DN - no type ref for synthetic arguments
1686 	int severity = computeSeverity(IProblem.UsingDeprecatedType);
1687 	if (severity == ProblemSeverities.Ignore) return;
1688 	type = type.leafComponentType();
1689 	int sourceStart = -1;
1690 	if (location instanceof QualifiedTypeReference) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=300031
1691 		QualifiedTypeReference ref = (QualifiedTypeReference) location;
1692 		if (index < Integer.MAX_VALUE) {
1693 			sourceStart = (int) (ref.sourcePositions[index] >> 32);
1694 		}
1695 	}
1696 	this.handle(
1697 		IProblem.UsingDeprecatedType,
1698 		new String[] {new String(type.readableName())},
1699 		new String[] {new String(type.shortReadableName())},
1700 		severity,
1701 		(sourceStart == -1) ? location.sourceStart : sourceStart,
1702 		nodeSourceEnd(null, location, index));
1703 }
disallowedTargetForAnnotation(Annotation annotation)1704 public void disallowedTargetForAnnotation(Annotation annotation) {
1705 	this.handle(
1706 		IProblem.DisallowedTargetForAnnotation,
1707 		new String[] {new String(annotation.resolvedType.readableName())},
1708 		new String[] {new String(annotation.resolvedType.shortReadableName())},
1709 		annotation.sourceStart,
1710 		annotation.sourceEnd);
1711 }
explitAnnotationTargetRequired(Annotation annotation)1712 public void explitAnnotationTargetRequired(Annotation annotation) {
1713 	this.handle(IProblem.ExplicitAnnotationTargetRequired,
1714 			NoArgument,
1715 			NoArgument,
1716 			annotation.sourceStart,
1717 			annotation.sourceEnd);
1718 }
polymorphicMethodNotBelow17(ASTNode node)1719 public void polymorphicMethodNotBelow17(ASTNode node) {
1720 	this.handle(
1721 			IProblem.PolymorphicMethodNotBelow17,
1722 			NoArgument,
1723 			NoArgument,
1724 			node.sourceStart,
1725 			node.sourceEnd);
1726 }
multiCatchNotBelow17(ASTNode node)1727 public void multiCatchNotBelow17(ASTNode node) {
1728 	this.handle(
1729 			IProblem.MultiCatchNotBelow17,
1730 			NoArgument,
1731 			NoArgument,
1732 			node.sourceStart,
1733 			node.sourceEnd);
1734 }
duplicateAnnotation(Annotation annotation, long sourceLevel)1735 public void duplicateAnnotation(Annotation annotation, long sourceLevel) {
1736 	this.handle(
1737 		sourceLevel >= ClassFileConstants.JDK1_8 ? IProblem.DuplicateAnnotationNotMarkedRepeatable : IProblem.DuplicateAnnotation,
1738 		new String[] {new String(annotation.resolvedType.readableName())},
1739 		new String[] {new String(annotation.resolvedType.shortReadableName())},
1740 		annotation.sourceStart,
1741 		annotation.sourceEnd);
1742 }
duplicateAnnotationValue(TypeBinding annotationType, MemberValuePair memberValuePair)1743 public void duplicateAnnotationValue(TypeBinding annotationType, MemberValuePair memberValuePair) {
1744 	String name = 	new String(memberValuePair.name);
1745 	this.handle(
1746 		IProblem.DuplicateAnnotationMember,
1747 		new String[] { name, new String(annotationType.readableName())},
1748 		new String[] {	name, new String(annotationType.shortReadableName())},
1749 		memberValuePair.sourceStart,
1750 		memberValuePair.sourceEnd);
1751 }
duplicateBounds(ASTNode location, TypeBinding type)1752 public void duplicateBounds(ASTNode location, TypeBinding type) {
1753 	this.handle(
1754 		IProblem.DuplicateBounds,
1755 		new String[] {new String(type.readableName())},
1756 		new String[] {new String(type.shortReadableName())},
1757 		location.sourceStart,
1758 		location.sourceEnd);
1759 }
duplicateCase(CaseStatement caseStatement)1760 public void duplicateCase(CaseStatement caseStatement) {
1761 	this.handle(
1762 		IProblem.DuplicateCase,
1763 		NoArgument,
1764 		NoArgument,
1765 		caseStatement.sourceStart,
1766 		caseStatement.sourceEnd);
1767 }
duplicateDefaultCase(ASTNode statement)1768 public void duplicateDefaultCase(ASTNode statement) {
1769 	this.handle(
1770 		IProblem.DuplicateDefaultCase,
1771 		NoArgument,
1772 		NoArgument,
1773 		statement.sourceStart,
1774 		statement.sourceEnd);
1775 }
duplicateEnumSpecialMethod(SourceTypeBinding type, AbstractMethodDeclaration methodDecl)1776 public void duplicateEnumSpecialMethod(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
1777     MethodBinding method = methodDecl.binding;
1778 	this.handle(
1779 		IProblem.CannotDeclareEnumSpecialMethod,
1780 		new String[] {
1781 	        new String(methodDecl.selector),
1782 			new String(method.declaringClass.readableName()),
1783 			typesAsString(method, false)},
1784 		new String[] {
1785 			new String(methodDecl.selector),
1786 			new String(method.declaringClass.shortReadableName()),
1787 			typesAsString(method, true)},
1788 		methodDecl.sourceStart,
1789 		methodDecl.sourceEnd);
1790 }
1791 
duplicateFieldInType(SourceTypeBinding type, FieldDeclaration fieldDecl)1792 public void duplicateFieldInType(SourceTypeBinding type, FieldDeclaration fieldDecl) {
1793 	this.handle(
1794 		IProblem.DuplicateField,
1795 		new String[] {new String(type.sourceName()), new String(fieldDecl.name)},
1796 		new String[] {new String(type.shortReadableName()), new String(fieldDecl.name)},
1797 		fieldDecl.sourceStart,
1798 		fieldDecl.sourceEnd);
1799 }
duplicateImport(ImportReference importRef)1800 public void duplicateImport(ImportReference importRef) {
1801 	String[] arguments = new String[] {CharOperation.toString(importRef.tokens)};
1802 	this.handle(
1803 		IProblem.DuplicateImport,
1804 		arguments,
1805 		arguments,
1806 		importRef.sourceStart,
1807 		importRef.sourceEnd);
1808 }
1809 
duplicateInheritedMethods(SourceTypeBinding type, MethodBinding inheritedMethod1, MethodBinding inheritedMethod2, boolean isJava8)1810 public void duplicateInheritedMethods(SourceTypeBinding type, MethodBinding inheritedMethod1, MethodBinding inheritedMethod2, boolean isJava8) {
1811 	if (TypeBinding.notEquals(inheritedMethod1.declaringClass, inheritedMethod2.declaringClass)) {
1812 		int problemID = IProblem.DuplicateInheritedMethods;
1813 		if (inheritedMethod1.isDefaultMethod() && inheritedMethod2.isDefaultMethod()) {
1814 			if (isJava8)
1815 				problemID = IProblem.DuplicateInheritedDefaultMethods;
1816 			else
1817 				return; // don't report this error at 1.7-
1818 		}
1819 		this.handle(
1820 			problemID,
1821 			new String[] {
1822 		        new String(inheritedMethod1.selector),
1823 				typesAsString(inheritedMethod1, inheritedMethod1.original().parameters, false),
1824 				typesAsString(inheritedMethod2, inheritedMethod2.original().parameters, false),
1825 				new String(inheritedMethod1.declaringClass.readableName()),
1826 				new String(inheritedMethod2.declaringClass.readableName()),
1827 			},
1828 			new String[] {
1829 				new String(inheritedMethod1.selector),
1830 				typesAsString(inheritedMethod1, inheritedMethod1.original().parameters, true),
1831 				typesAsString(inheritedMethod2, inheritedMethod2.original().parameters, true),
1832 				new String(inheritedMethod1.declaringClass.shortReadableName()),
1833 				new String(inheritedMethod2.declaringClass.shortReadableName()),
1834 			},
1835 			type.sourceStart(),
1836 			type.sourceEnd());
1837 		return;
1838 	}
1839 	// Handle duplicates from same class.
1840 	this.handle(
1841 		IProblem.DuplicateParameterizedMethods,
1842 		new String[] {
1843 	        new String(inheritedMethod1.selector),
1844 			new String(inheritedMethod1.declaringClass.readableName()),
1845 			typesAsString(inheritedMethod1, inheritedMethod1.original().parameters, false),
1846 			typesAsString(inheritedMethod2, inheritedMethod2.original().parameters, false)},
1847 		new String[] {
1848 			new String(inheritedMethod1.selector),
1849 			new String(inheritedMethod1.declaringClass.shortReadableName()),
1850 			typesAsString(inheritedMethod1, inheritedMethod1.original().parameters, true),
1851 			typesAsString(inheritedMethod2, inheritedMethod2.original().parameters, true)},
1852 		type.sourceStart(),
1853 		type.sourceEnd());
1854 }
duplicateInitializationOfBlankFinalField(FieldBinding field, Reference reference)1855 public void duplicateInitializationOfBlankFinalField(FieldBinding field, Reference reference) {
1856 	String[] arguments = new String[]{ new String(field.readableName())};
1857 	this.handle(
1858 		IProblem.DuplicateBlankFinalFieldInitialization,
1859 		arguments,
1860 		arguments,
1861 		nodeSourceStart(field, reference),
1862 		nodeSourceEnd(field, reference));
1863 }
duplicateInitializationOfFinalLocal(LocalVariableBinding local, ASTNode location)1864 public void duplicateInitializationOfFinalLocal(LocalVariableBinding local, ASTNode location) {
1865 	String[] arguments = new String[] { new String(local.readableName())};
1866 	this.handle(
1867 		IProblem.DuplicateFinalLocalInitialization,
1868 		arguments,
1869 		arguments,
1870 		nodeSourceStart(local, location),
1871 		nodeSourceEnd(local, location));
1872 }
duplicateMethodInType(AbstractMethodDeclaration methodDecl, boolean equalParameters, int severity)1873 public void duplicateMethodInType(AbstractMethodDeclaration methodDecl, boolean equalParameters, int severity) {
1874     MethodBinding method = methodDecl.binding;
1875     if (equalParameters) {
1876 		this.handle(
1877 			IProblem.DuplicateMethod,
1878 			new String[] {
1879 		        new String(methodDecl.selector),
1880 				new String(method.declaringClass.readableName()),
1881 				typesAsString(method, false)},
1882 			new String[] {
1883 				new String(methodDecl.selector),
1884 				new String(method.declaringClass.shortReadableName()),
1885 				typesAsString(method, true)},
1886 			severity,
1887 			methodDecl.sourceStart,
1888 			methodDecl.sourceEnd);
1889     } else {
1890 		this.handle(
1891 			IProblem.DuplicateMethodErasure,
1892 			new String[] {
1893 		        new String(methodDecl.selector),
1894 				new String(method.declaringClass.readableName()),
1895 				typesAsString(method, false)},
1896 			new String[] {
1897 				new String(methodDecl.selector),
1898 				new String(method.declaringClass.shortReadableName()),
1899 				typesAsString(method, true)},
1900 			severity,
1901 			methodDecl.sourceStart,
1902 			methodDecl.sourceEnd);
1903     }
1904 }
1905 
duplicateModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl)1906 public void duplicateModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
1907 /* to highlight modifiers use:
1908 	this.handle(
1909 		new Problem(
1910 			DuplicateModifierForField,
1911 			new String[] {new String(fieldDecl.name)},
1912 			fieldDecl.modifiers.sourceStart,
1913 			fieldDecl.modifiers.sourceEnd));
1914 */
1915 	String[] arguments = new String[] {new String(fieldDecl.name)};
1916 	this.handle(
1917 		IProblem.DuplicateModifierForField,
1918 		arguments,
1919 		arguments,
1920 		fieldDecl.sourceStart,
1921 		fieldDecl.sourceEnd);
1922 }
duplicateModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl)1923 public void duplicateModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
1924 	this.handle(
1925 		IProblem.DuplicateModifierForMethod,
1926 		new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
1927 		new String[] {new String(type.shortReadableName()), new String(methodDecl.selector)},
1928 		methodDecl.sourceStart,
1929 		methodDecl.sourceEnd);
1930 }
duplicateModifierForType(SourceTypeBinding type)1931 public void duplicateModifierForType(SourceTypeBinding type) {
1932 	String[] arguments = new String[] {new String(type.sourceName())};
1933 	this.handle(
1934 		IProblem.DuplicateModifierForType,
1935 		arguments,
1936 		arguments,
1937 		type.sourceStart(),
1938 		type.sourceEnd());
1939 }
duplicateModifierForVariable(LocalDeclaration localDecl, boolean complainForArgument)1940 public void duplicateModifierForVariable(LocalDeclaration localDecl, boolean complainForArgument) {
1941 	String[] arguments = new String[] {new String(localDecl.name)};
1942 	this.handle(
1943 		complainForArgument
1944 			? IProblem.DuplicateModifierForArgument
1945 			: IProblem.DuplicateModifierForVariable,
1946 		arguments,
1947 		arguments,
1948 		localDecl.sourceStart,
1949 		localDecl.sourceEnd);
1950 }
duplicateNestedType(TypeDeclaration typeDecl)1951 public void duplicateNestedType(TypeDeclaration typeDecl) {
1952 	String[] arguments = new String[] {new String(typeDecl.name)};
1953 	this.handle(
1954 		IProblem.DuplicateNestedType,
1955 		arguments,
1956 		arguments,
1957 		typeDecl.sourceStart,
1958 		typeDecl.sourceEnd);
1959 }
duplicateSuperinterface(SourceTypeBinding type, TypeReference reference, ReferenceBinding superType)1960 public void duplicateSuperinterface(SourceTypeBinding type, TypeReference reference, ReferenceBinding superType) {
1961 	this.handle(
1962 		IProblem.DuplicateSuperInterface,
1963 		new String[] {
1964 			new String(superType.readableName()),
1965 			new String(type.sourceName())},
1966 		new String[] {
1967 			new String(superType.shortReadableName()),
1968 			new String(type.sourceName())},
1969 		reference.sourceStart,
1970 		reference.sourceEnd);
1971 }
duplicateTargetInTargetAnnotation(TypeBinding annotationType, NameReference reference)1972 public void duplicateTargetInTargetAnnotation(TypeBinding annotationType, NameReference reference) {
1973 	FieldBinding field = reference.fieldBinding();
1974 	String name = 	new String(field.name);
1975 	this.handle(
1976 		IProblem.DuplicateTargetInTargetAnnotation,
1977 		new String[] { name, new String(annotationType.readableName())},
1978 		new String[] {	name, new String(annotationType.shortReadableName())},
1979 		nodeSourceStart(field, reference),
1980 		nodeSourceEnd(field, reference));
1981 }
duplicateTypeParameterInType(TypeParameter typeParameter)1982 public void duplicateTypeParameterInType(TypeParameter typeParameter) {
1983 	this.handle(
1984 		IProblem.DuplicateTypeVariable,
1985 		new String[] { new String(typeParameter.name)},
1986 		new String[] { new String(typeParameter.name)},
1987 		typeParameter.sourceStart,
1988 		typeParameter.sourceEnd);
1989 }
duplicateTypes(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl)1990 public void duplicateTypes(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
1991 	String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
1992 	this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
1993 	int end = typeDecl.sourceEnd;
1994 	if (end <= 0) {
1995 		end = -1;
1996 	}
1997 	this.handle(
1998 		IProblem.DuplicateTypes,
1999 		arguments,
2000 		arguments,
2001 		typeDecl.sourceStart,
2002 		end,
2003 		compUnitDecl.compilationResult);
2004 }
emptyControlFlowStatement(int sourceStart, int sourceEnd)2005 public void emptyControlFlowStatement(int sourceStart, int sourceEnd) {
2006 	this.handle(
2007 		IProblem.EmptyControlFlowStatement,
2008 		NoArgument,
2009 		NoArgument,
2010 		sourceStart,
2011 		sourceEnd);
2012 }
enumAbstractMethodMustBeImplemented(AbstractMethodDeclaration method)2013 public void enumAbstractMethodMustBeImplemented(AbstractMethodDeclaration method) {
2014 	MethodBinding abstractMethod = method.binding;
2015 	this.handle(
2016 		// Must implement the inherited abstract method %1
2017 		// 8.4.3 - Every non-abstract subclass of an abstract type, A, must provide a concrete implementation of all of A's methods.
2018 		IProblem.EnumAbstractMethodMustBeImplemented,
2019 		new String[] {
2020 		        new String(abstractMethod.selector),
2021 		        typesAsString(abstractMethod, false),
2022 		        new String(abstractMethod.declaringClass.readableName()),
2023 		},
2024 		new String[] {
2025 		        new String(abstractMethod.selector),
2026 		        typesAsString(abstractMethod, true),
2027 		        new String(abstractMethod.declaringClass.shortReadableName()),
2028 		},
2029 		method.sourceStart(),
2030 		method.sourceEnd());
2031 }
enumConstantMustImplementAbstractMethod(AbstractMethodDeclaration method, FieldDeclaration field)2032 public void enumConstantMustImplementAbstractMethod(AbstractMethodDeclaration method, FieldDeclaration field) {
2033 	MethodBinding abstractMethod = method.binding;
2034 	this.handle(
2035 		IProblem.EnumConstantMustImplementAbstractMethod,
2036 		new String[] {
2037 		        new String(abstractMethod.selector),
2038 		        typesAsString(abstractMethod, false),
2039 		        new String(field.name),
2040 		},
2041 		new String[] {
2042 		        new String(abstractMethod.selector),
2043 		        typesAsString(abstractMethod, true),
2044 		        new String(field.name),
2045 		},
2046 		field.sourceStart(),
2047 		field.sourceEnd());
2048 }
enumConstantsCannotBeSurroundedByParenthesis(Expression expression)2049 public void enumConstantsCannotBeSurroundedByParenthesis(Expression expression) {
2050 	this.handle(
2051 		IProblem.EnumConstantsCannotBeSurroundedByParenthesis,
2052 		NoArgument,
2053 		NoArgument,
2054 		expression.sourceStart,
2055 		expression.sourceEnd);
2056 }
enumStaticFieldUsedDuringInitialization(FieldBinding field, ASTNode location)2057 public void enumStaticFieldUsedDuringInitialization(FieldBinding field, ASTNode location) {
2058 	this.handle(
2059 		IProblem.EnumStaticFieldInInInitializerContext,
2060 		new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
2061 		new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
2062 		nodeSourceStart(field, location),
2063 		nodeSourceEnd(field, location));
2064 }
enumSwitchCannotTargetField(Reference reference, FieldBinding field)2065 public void enumSwitchCannotTargetField(Reference reference, FieldBinding field) {
2066 	this.handle(
2067 			IProblem.EnumSwitchCannotTargetField,
2068 			new String[]{ String.valueOf(field.declaringClass.readableName()), String.valueOf(field.name) },
2069 			new String[]{ String.valueOf(field.declaringClass.shortReadableName()), String.valueOf(field.name) },
2070 			nodeSourceStart(field, reference),
2071 			nodeSourceEnd(field, reference));
2072 }
errorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params)2073 public void errorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params) {
2074 	StringBuffer buffer = new StringBuffer();
2075 	StringBuffer shortBuffer = new StringBuffer();
2076 	for (int i = 0, length = params.length; i < length; i++) {
2077 		if (i != 0){
2078 			buffer.append(", "); //$NON-NLS-1$
2079 			shortBuffer.append(", "); //$NON-NLS-1$
2080 		}
2081 		buffer.append(new String(params[i].readableName()));
2082 		shortBuffer.append(new String(params[i].shortReadableName()));
2083 	}
2084 
2085 	int id = recType.isArrayType() ? IProblem.NoMessageSendOnArrayType : IProblem.NoMessageSendOnBaseType;
2086 	this.handle(
2087 		id,
2088 		new String[] {new String(recType.readableName()), new String(messageSend.selector), buffer.toString()},
2089 		new String[] {new String(recType.shortReadableName()), new String(messageSend.selector), shortBuffer.toString()},
2090 		messageSend.sourceStart,
2091 		messageSend.sourceEnd);
2092 }
errorNoMethodFor(Expression expression, TypeBinding recType, char [] selector, TypeBinding[] params)2093 public void errorNoMethodFor(Expression expression, TypeBinding recType, char [] selector, TypeBinding[] params) {
2094 	StringBuffer buffer = new StringBuffer();
2095 	StringBuffer shortBuffer = new StringBuffer();
2096 	for (int i = 0, length = params.length; i < length; i++) {
2097 		if (i != 0){
2098 			buffer.append(", "); //$NON-NLS-1$
2099 			shortBuffer.append(", "); //$NON-NLS-1$
2100 		}
2101 		buffer.append(new String(params[i].readableName()));
2102 		shortBuffer.append(new String(params[i].shortReadableName()));
2103 	}
2104 
2105 	int id = recType.isArrayType() ? IProblem.NoMessageSendOnArrayType : IProblem.NoMessageSendOnBaseType;
2106 	this.handle(
2107 		id,
2108 		new String[] { new String(recType.readableName()), new String(selector), buffer.toString() },
2109 		new String[] { new String(recType.shortReadableName()), new String(selector), shortBuffer.toString() },
2110 		expression.sourceStart,
2111 		expression.sourceEnd);
2112 }
errorThisSuperInStatic(ASTNode reference)2113 public void errorThisSuperInStatic(ASTNode reference) {
2114 	String[] arguments = new String[] {reference.isSuper() ? "super" : "this"}; //$NON-NLS-2$ //$NON-NLS-1$
2115 	this.handle(
2116 		IProblem.ThisInStaticContext,
2117 		arguments,
2118 		arguments,
2119 		reference.sourceStart,
2120 		reference.sourceEnd);
2121 }
errorNoSuperInInterface(ASTNode reference)2122 public void errorNoSuperInInterface(ASTNode reference) {
2123 	this.handle(
2124 		IProblem.NoSuperInInterfaceContext,
2125 		NoArgument,
2126 		NoArgument,
2127 		reference.sourceStart,
2128 		reference.sourceEnd);
2129 }
expressionShouldBeAVariable(Expression expression)2130 public void expressionShouldBeAVariable(Expression expression) {
2131 	this.handle(
2132 		IProblem.ExpressionShouldBeAVariable,
2133 		NoArgument,
2134 		NoArgument,
2135 		expression.sourceStart,
2136 		expression.sourceEnd);
2137 }
fakeReachable(ASTNode location)2138 public void fakeReachable(ASTNode location) {
2139 	int sourceStart = location.sourceStart;
2140 	int sourceEnd = location.sourceEnd;
2141 	if (location instanceof LocalDeclaration) {
2142 		LocalDeclaration declaration = (LocalDeclaration) location;
2143 		sourceStart = declaration.declarationSourceStart;
2144 		sourceEnd = declaration.declarationSourceEnd;
2145 	}
2146 	this.handle(
2147 		IProblem.DeadCode,
2148 		NoArgument,
2149 		NoArgument,
2150 		sourceStart,
2151 		sourceEnd);
2152 }
fieldHiding(FieldDeclaration fieldDecl, Binding hiddenVariable)2153 public void fieldHiding(FieldDeclaration fieldDecl, Binding hiddenVariable) {
2154 	FieldBinding field = fieldDecl.binding;
2155 	if (CharOperation.equals(TypeConstants.SERIALVERSIONUID, field.name)
2156 			&& field.isStatic()
2157 			&& field.isPrivate()
2158 			&& field.isFinal()
2159 			&& TypeBinding.equalsEquals(TypeBinding.LONG, field.type)) {
2160 		ReferenceBinding referenceBinding = field.declaringClass;
2161 		if (referenceBinding != null) {
2162 			if (referenceBinding.findSuperTypeOriginatingFrom(TypeIds.T_JavaIoSerializable, false /*Serializable is not a class*/) != null) {
2163 				return; // do not report field hiding for serialVersionUID field for class that implements Serializable
2164 			}
2165 		}
2166 	}
2167 	if (CharOperation.equals(TypeConstants.SERIALPERSISTENTFIELDS, field.name)
2168 			&& field.isStatic()
2169 			&& field.isPrivate()
2170 			&& field.isFinal()
2171 			&& field.type.dimensions() == 1
2172 			&& CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTSTREAMFIELD, field.type.leafComponentType().readableName())) {
2173 		ReferenceBinding referenceBinding = field.declaringClass;
2174 		if (referenceBinding != null) {
2175 			if (referenceBinding.findSuperTypeOriginatingFrom(TypeIds.T_JavaIoSerializable, false /*Serializable is not a class*/) != null) {
2176 				return; // do not report field hiding for serialPersistenFields field for class that implements Serializable
2177 			}
2178 		}
2179 	}
2180 	boolean isLocal = hiddenVariable instanceof LocalVariableBinding;
2181 	int severity = computeSeverity(isLocal ? IProblem.FieldHidingLocalVariable : IProblem.FieldHidingField);
2182 	if (severity == ProblemSeverities.Ignore) return;
2183 	if (isLocal) {
2184 		this.handle(
2185 			IProblem.FieldHidingLocalVariable,
2186 			new String[] {new String(field.declaringClass.readableName()), new String(field.name) },
2187 			new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name) },
2188 			severity,
2189 			nodeSourceStart(hiddenVariable, fieldDecl),
2190 			nodeSourceEnd(hiddenVariable, fieldDecl));
2191 	} else if (hiddenVariable instanceof FieldBinding) {
2192 		FieldBinding hiddenField = (FieldBinding) hiddenVariable;
2193 		this.handle(
2194 			IProblem.FieldHidingField,
2195 			new String[] {new String(field.declaringClass.readableName()), new String(field.name) , new String(hiddenField.declaringClass.readableName())  },
2196 			new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name) , new String(hiddenField.declaringClass.shortReadableName()) },
2197 			severity,
2198 			nodeSourceStart(hiddenField, fieldDecl),
2199 			nodeSourceEnd(hiddenField, fieldDecl));
2200 	}
2201 }
fieldsOrThisBeforeConstructorInvocation(ASTNode reference)2202 public void fieldsOrThisBeforeConstructorInvocation(ASTNode reference) {
2203 	this.handle(
2204 		IProblem.ThisSuperDuringConstructorInvocation,
2205 		NoArgument,
2206 		NoArgument,
2207 		reference.sourceStart,
2208 		reference instanceof LambdaExpression ? ((LambdaExpression) reference).diagnosticsSourceEnd() : reference.sourceEnd);
2209 }
finallyMustCompleteNormally(Block finallyBlock)2210 public void finallyMustCompleteNormally(Block finallyBlock) {
2211 	this.handle(
2212 		IProblem.FinallyMustCompleteNormally,
2213 		NoArgument,
2214 		NoArgument,
2215 		finallyBlock.sourceStart,
2216 		finallyBlock.sourceEnd);
2217 }
finalMethodCannotBeOverridden(MethodBinding currentMethod, MethodBinding inheritedMethod)2218 public void finalMethodCannotBeOverridden(MethodBinding currentMethod, MethodBinding inheritedMethod) {
2219 	this.handle(
2220 		// Cannot override the final method from %1
2221 		// 8.4.3.3 - Final methods cannot be overridden or hidden.
2222 		IProblem.FinalMethodCannotBeOverridden,
2223 		new String[] {new String(inheritedMethod.declaringClass.readableName())},
2224 		new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
2225 		currentMethod.sourceStart(),
2226 		currentMethod.sourceEnd());
2227 }
finalVariableBound(TypeVariableBinding typeVariable, TypeReference typeRef)2228 public void finalVariableBound(TypeVariableBinding typeVariable, TypeReference typeRef) {
2229 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return;
2230 	int severity = computeSeverity(IProblem.FinalBoundForTypeVariable);
2231 	if (severity == ProblemSeverities.Ignore) return;
2232 	this.handle(
2233 		IProblem.FinalBoundForTypeVariable,
2234 		new String[] { new String(typeVariable.sourceName()), new String(typeRef.resolvedType.readableName())},
2235 		new String[] { new String(typeVariable.sourceName()), new String(typeRef.resolvedType.shortReadableName())},
2236 		severity,
2237 		typeRef.sourceStart,
2238 		typeRef.sourceEnd);
2239 }
2240 /** @param classpathEntryType one of {@link AccessRestriction#COMMAND_LINE},
2241  * {@link AccessRestriction#LIBRARY}, {@link AccessRestriction#PROJECT} */
forbiddenReference(FieldBinding field, ASTNode location, byte classpathEntryType, String classpathEntryName, int problemId)2242 public void forbiddenReference(FieldBinding field, ASTNode location,
2243 		 byte classpathEntryType, String classpathEntryName, int problemId) {
2244 	int severity = computeSeverity(problemId);
2245 	if (severity == ProblemSeverities.Ignore) return;
2246 	this.handle(
2247 		problemId,
2248 		new String[] { new String(field.readableName()) }, // distinct from msg arg for quickfix purpose
2249 		getElaborationId(IProblem.ForbiddenReference, (byte) (FIELD_ACCESS | classpathEntryType)),
2250 		new String[] {
2251 			classpathEntryName,
2252 			new String(field.shortReadableName()),
2253 	        new String(field.declaringClass.shortReadableName())},
2254 	    severity,
2255 		nodeSourceStart(field, location),
2256 		nodeSourceEnd(field, location));
2257 }
2258 /** @param classpathEntryType one of {@link AccessRestriction#COMMAND_LINE},
2259  * {@link AccessRestriction#LIBRARY}, {@link AccessRestriction#PROJECT} */
forbiddenReference(MethodBinding method, ASTNode location, byte classpathEntryType, String classpathEntryName, int problemId)2260 public void forbiddenReference(MethodBinding method, ASTNode location,
2261 		byte classpathEntryType, String classpathEntryName, int problemId) {
2262 	int severity = computeSeverity(problemId);
2263 	if (severity == ProblemSeverities.Ignore) return;
2264 	if (method.isConstructor())
2265 		this.handle(
2266 			problemId,
2267 			new String[] { new String(method.readableName()) }, // distinct from msg arg for quickfix purpose
2268 			getElaborationId(IProblem.ForbiddenReference, (byte) (CONSTRUCTOR_ACCESS | classpathEntryType)),
2269 			new String[] {
2270 				classpathEntryName,
2271 				new String(method.shortReadableName())},
2272 			severity,
2273 			location.sourceStart,
2274 			location.sourceEnd);
2275 	else
2276 		this.handle(
2277 			problemId,
2278 			new String[] { new String(method.readableName()) }, // distinct from msg arg for quickfix purpose
2279 			getElaborationId(IProblem.ForbiddenReference, (byte) (METHOD_ACCESS | classpathEntryType)),
2280 			new String[] {
2281 				classpathEntryName,
2282 				new String(method.shortReadableName()),
2283 		        new String(method.declaringClass.shortReadableName())},
2284 		    severity,
2285 			location.sourceStart,
2286 			location.sourceEnd);
2287 }
2288 /** @param classpathEntryType one of {@link AccessRestriction#COMMAND_LINE},
2289  * {@link AccessRestriction#LIBRARY}, {@link AccessRestriction#PROJECT} */
forbiddenReference(TypeBinding type, ASTNode location, byte classpathEntryType, String classpathEntryName, int problemId)2290 public void forbiddenReference(TypeBinding type, ASTNode location,
2291 		byte classpathEntryType, String classpathEntryName, int problemId) {
2292 	if (location == null) return;
2293 	int severity = computeSeverity(problemId);
2294 	if (severity == ProblemSeverities.Ignore) return;
2295 	this.handle(
2296 		problemId,
2297 		new String[] { new String(type.readableName()) }, // distinct from msg arg for quickfix purpose
2298 		getElaborationId(IProblem.ForbiddenReference, /* TYPE_ACCESS | */ classpathEntryType), // TYPE_ACCESS values to 0
2299 		new String[] {
2300 			classpathEntryName,
2301 			new String(type.shortReadableName())},
2302 		severity,
2303 		location.sourceStart,
2304 		location.sourceEnd);
2305 }
forwardReference(Reference reference, int indexInQualification, FieldBinding field)2306 public void forwardReference(Reference reference, int indexInQualification, FieldBinding field) {
2307 	this.handle(
2308 		IProblem.ReferenceToForwardField,
2309 		NoArgument,
2310 		NoArgument,
2311 		nodeSourceStart(field, reference, indexInQualification),
2312 		nodeSourceEnd(field, reference, indexInQualification));
2313 }
forwardTypeVariableReference(ASTNode location, TypeVariableBinding type)2314 public void forwardTypeVariableReference(ASTNode location, TypeVariableBinding type) {
2315 	this.handle(
2316 		IProblem.ReferenceToForwardTypeVariable,
2317 		new String[] {new String(type.readableName())},
2318 		new String[] {new String(type.shortReadableName())},
2319 		location.sourceStart,
2320 		location.sourceEnd);
2321 }
genericTypeCannotExtendThrowable(TypeDeclaration typeDecl)2322 public void genericTypeCannotExtendThrowable(TypeDeclaration typeDecl) {
2323 	ASTNode location = typeDecl.binding.isAnonymousType() ? typeDecl.allocation.type : typeDecl.superclass;
2324 	this.handle(
2325 		IProblem.GenericTypeCannotExtendThrowable,
2326 		new String[]{ new String(typeDecl.binding.readableName()) },
2327 		new String[]{ new String(typeDecl.binding.shortReadableName()) },
2328 		location.sourceStart,
2329 		location.sourceEnd);
2330 }
2331 // use this private API when the compilation unit result can be found through the
2332 // reference context. Otherwise, use the other API taking a problem and a compilation result
2333 // as arguments
handle( int problemId, String[] problemArguments, int elaborationId, String[] messageArguments, int severity, int problemStartPosition, int problemEndPosition)2334 private void handle(
2335 		int problemId,
2336 		String[] problemArguments,
2337 		int elaborationId,
2338 		String[] messageArguments,
2339 		int severity,
2340 		int problemStartPosition,
2341 		int problemEndPosition){
2342 	this.handle(
2343 			problemId,
2344 			problemArguments,
2345 			elaborationId,
2346 			messageArguments,
2347 			severity,
2348 			problemStartPosition,
2349 			problemEndPosition,
2350 			this.referenceContext,
2351 			this.referenceContext == null ? null : this.referenceContext.compilationResult());
2352 	this.referenceContext = null;
2353 }
2354 // use this private API when the compilation unit result can be found through the
2355 // reference context. Otherwise, use the other API taking a problem and a compilation result
2356 // as arguments
handle( int problemId, String[] problemArguments, String[] messageArguments, int problemStartPosition, int problemEndPosition)2357 private void handle(
2358 	int problemId,
2359 	String[] problemArguments,
2360 	String[] messageArguments,
2361 	int problemStartPosition,
2362 	int problemEndPosition){
2363 
2364 	this.handle(
2365 			problemId,
2366 			problemArguments,
2367 			messageArguments,
2368 			problemStartPosition,
2369 			problemEndPosition,
2370 			this.referenceContext,
2371 			this.referenceContext == null ? null : this.referenceContext.compilationResult());
2372 	this.referenceContext = null;
2373 }
2374 // use this private API when the compilation unit result cannot be found through the
2375 // reference context.
handle( int problemId, String[] problemArguments, String[] messageArguments, int problemStartPosition, int problemEndPosition, CompilationResult unitResult)2376 private void handle(
2377 	int problemId,
2378 	String[] problemArguments,
2379 	String[] messageArguments,
2380 	int problemStartPosition,
2381 	int problemEndPosition,
2382 	CompilationResult unitResult){
2383 
2384 	this.handle(
2385 			problemId,
2386 			problemArguments,
2387 			messageArguments,
2388 			problemStartPosition,
2389 			problemEndPosition,
2390 			this.referenceContext,
2391 			unitResult);
2392 	this.referenceContext = null;
2393 }
2394 // use this private API when the compilation unit result can be found through the
2395 // reference context. Otherwise, use the other API taking a problem and a compilation result
2396 // as arguments
handle( int problemId, String[] problemArguments, String[] messageArguments, int severity, int problemStartPosition, int problemEndPosition)2397 private void handle(
2398 	int problemId,
2399 	String[] problemArguments,
2400 	String[] messageArguments,
2401 	int severity,
2402 	int problemStartPosition,
2403 	int problemEndPosition){
2404 
2405 	this.handle(
2406 			problemId,
2407 			problemArguments,
2408 			0, // no elaboration
2409 			messageArguments,
2410 			severity,
2411 			problemStartPosition,
2412 			problemEndPosition);
2413 }
2414 
hiddenCatchBlock(ReferenceBinding exceptionType, ASTNode location)2415 public void hiddenCatchBlock(ReferenceBinding exceptionType, ASTNode location) {
2416 	this.handle(
2417 		IProblem.MaskedCatch,
2418 		new String[] {
2419 			new String(exceptionType.readableName()),
2420 		 },
2421 		new String[] {
2422 			new String(exceptionType.shortReadableName()),
2423 		 },
2424 		location.sourceStart,
2425 		location.sourceEnd);
2426 }
2427 
hierarchyCircularity(SourceTypeBinding sourceType, ReferenceBinding superType, TypeReference reference)2428 public void hierarchyCircularity(SourceTypeBinding sourceType, ReferenceBinding superType, TypeReference reference) {
2429 	int start = 0;
2430 	int end = 0;
2431 
2432 	if (reference == null) {	// can only happen when java.lang.Object is busted
2433 		start = sourceType.sourceStart();
2434 		end = sourceType.sourceEnd();
2435 	} else {
2436 		start = reference.sourceStart;
2437 		end = reference.sourceEnd;
2438 	}
2439 
2440 	if (TypeBinding.equalsEquals(sourceType, superType))
2441 		this.handle(
2442 			IProblem.HierarchyCircularitySelfReference,
2443 			new String[] {new String(sourceType.readableName()) },
2444 			new String[] {new String(sourceType.shortReadableName()) },
2445 			start,
2446 			end);
2447 	else
2448 		this.handle(
2449 			IProblem.HierarchyCircularity,
2450 			new String[] {new String(sourceType.readableName()), new String(superType.readableName())},
2451 			new String[] {new String(sourceType.shortReadableName()), new String(superType.shortReadableName())},
2452 			start,
2453 			end);
2454 }
2455 
hierarchyCircularity(TypeVariableBinding type, ReferenceBinding superType, TypeReference reference)2456 public void hierarchyCircularity(TypeVariableBinding type, ReferenceBinding superType, TypeReference reference) {
2457 	int start = 0;
2458 	int end = 0;
2459 
2460 	start = reference.sourceStart;
2461 	end = reference.sourceEnd;
2462 
2463 	if (TypeBinding.equalsEquals(type, superType))
2464 		this.handle(
2465 			IProblem.HierarchyCircularitySelfReference,
2466 			new String[] {new String(type.readableName()) },
2467 			new String[] {new String(type.shortReadableName()) },
2468 			start,
2469 			end);
2470 	else
2471 		this.handle(
2472 			IProblem.HierarchyCircularity,
2473 			new String[] {new String(type.readableName()), new String(superType.readableName())},
2474 			new String[] {new String(type.shortReadableName()), new String(superType.shortReadableName())},
2475 			start,
2476 			end);
2477 }
2478 
hierarchyHasProblems(SourceTypeBinding type)2479 public void hierarchyHasProblems(SourceTypeBinding type) {
2480 	String[] arguments = new String[] {new String(type.sourceName())};
2481 	this.handle(
2482 		IProblem.HierarchyHasProblems,
2483 		arguments,
2484 		arguments,
2485 		type.sourceStart(),
2486 		type.sourceEnd());
2487 }
illegalAbstractModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl)2488 public void illegalAbstractModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
2489 	String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
2490 	this.handle(
2491 		IProblem.IllegalAbstractModifierCombinationForMethod,
2492 		arguments,
2493 		arguments,
2494 		methodDecl.sourceStart,
2495 		methodDecl.sourceEnd);
2496 }
illegalAbstractModifierCombinationForMethod(AbstractMethodDeclaration methodDecl)2497 public void illegalAbstractModifierCombinationForMethod(AbstractMethodDeclaration methodDecl) {
2498 	String[] arguments = new String[] {new String(methodDecl.selector)};
2499 	this.handle(
2500 		IProblem.IllegalStrictfpForAbstractInterfaceMethod,
2501 		arguments,
2502 		arguments,
2503 		methodDecl.sourceStart,
2504 		methodDecl.sourceEnd);
2505 }
illegalAccessFromTypeVariable(TypeVariableBinding variable, ASTNode location)2506 public void illegalAccessFromTypeVariable(TypeVariableBinding variable, ASTNode location) {
2507 	if ((location.bits & ASTNode.InsideJavadoc)!= 0) {
2508 		javadocInvalidReference(location.sourceStart, location.sourceEnd);
2509 	} else {
2510 		String[] arguments = new String[] { new String(variable.sourceName) };
2511 		this.handle(
2512 				IProblem.IllegalAccessFromTypeVariable,
2513 				arguments,
2514 				arguments,
2515 				location.sourceStart,
2516 				location.sourceEnd);
2517 	}
2518 }
illegalClassLiteralForTypeVariable(TypeVariableBinding variable, ASTNode location)2519 public void illegalClassLiteralForTypeVariable(TypeVariableBinding variable, ASTNode location) {
2520 	String[] arguments = new String[] { new String(variable.sourceName) };
2521 	this.handle(
2522 		IProblem.IllegalClassLiteralForTypeVariable,
2523 		arguments,
2524 		arguments,
2525 		location.sourceStart,
2526 		location.sourceEnd);
2527 }
illegalExtendedDimensions(AnnotationMethodDeclaration annotationTypeMemberDeclaration)2528 public void illegalExtendedDimensions(AnnotationMethodDeclaration annotationTypeMemberDeclaration) {
2529 	this.handle(
2530 		IProblem.IllegalExtendedDimensions,
2531 		NoArgument,
2532 		NoArgument,
2533 		annotationTypeMemberDeclaration.sourceStart,
2534 		annotationTypeMemberDeclaration.sourceEnd);
2535 }
illegalExtendedDimensions(Argument argument)2536 public void illegalExtendedDimensions(Argument argument) {
2537 	this.handle(
2538 		IProblem.IllegalExtendedDimensionsForVarArgs,
2539 		NoArgument,
2540 		NoArgument,
2541 		argument.sourceStart,
2542 		argument.sourceEnd);
2543 }
illegalGenericArray(TypeBinding leafComponentType, ASTNode location)2544 public void illegalGenericArray(TypeBinding leafComponentType, ASTNode location) {
2545 	this.handle(
2546 		IProblem.IllegalGenericArray,
2547 		new String[]{ new String(leafComponentType.readableName())},
2548 		new String[]{ new String(leafComponentType.shortReadableName())},
2549 		location.sourceStart,
2550 		location.sourceEnd);
2551 }
illegalInstanceOfGenericType(TypeBinding checkedType, ASTNode location)2552 public void illegalInstanceOfGenericType(TypeBinding checkedType, ASTNode location) {
2553 	TypeBinding erasedType = checkedType.leafComponentType().erasure();
2554 	StringBuffer recommendedFormBuffer = new StringBuffer(10);
2555 	if (erasedType instanceof ReferenceBinding) {
2556 		ReferenceBinding referenceBinding = (ReferenceBinding) erasedType;
2557 		recommendedFormBuffer.append(referenceBinding.qualifiedSourceName());
2558 	} else {
2559 		recommendedFormBuffer.append(erasedType.sourceName());
2560 	}
2561 	int count = erasedType.typeVariables().length;
2562 	if (count > 0) {
2563 		recommendedFormBuffer.append('<');
2564 		for (int i = 0; i < count; i++) {
2565 			if (i > 0) {
2566 				recommendedFormBuffer.append(',');
2567 			}
2568 			recommendedFormBuffer.append('?');
2569 		}
2570 		recommendedFormBuffer.append('>');
2571 	}
2572 	for (int i = 0, dim = checkedType.dimensions(); i < dim; i++) {
2573 		recommendedFormBuffer.append("[]"); //$NON-NLS-1$
2574 	}
2575 	String recommendedForm = recommendedFormBuffer.toString();
2576 	if (checkedType.leafComponentType().isTypeVariable()) {
2577 		this.handle(
2578 			IProblem.IllegalInstanceofTypeParameter,
2579 			new String[] { new String(checkedType.readableName()), recommendedForm, },
2580 			new String[] { new String(checkedType.shortReadableName()), recommendedForm, },
2581 				location.sourceStart,
2582 				location.sourceEnd);
2583 		return;
2584 	}
2585 	this.handle(
2586 		IProblem.IllegalInstanceofParameterizedType,
2587 		new String[] { new String(checkedType.readableName()), recommendedForm, },
2588 		new String[] { new String(checkedType.shortReadableName()), recommendedForm, },
2589 		location.sourceStart,
2590 		location.sourceEnd);
2591 }
illegalLocalTypeDeclaration(TypeDeclaration typeDeclaration)2592 public void illegalLocalTypeDeclaration(TypeDeclaration typeDeclaration) {
2593 	if (isRecoveredName(typeDeclaration.name)) return;
2594 
2595 	int problemID = 0;
2596 	if ((typeDeclaration.modifiers & ClassFileConstants.AccEnum) != 0) {
2597 		problemID = IProblem.CannotDefineEnumInLocalType;
2598 	} else if ((typeDeclaration.modifiers & ClassFileConstants.AccAnnotation) != 0) {
2599 		problemID = IProblem.CannotDefineAnnotationInLocalType;
2600 	} else if ((typeDeclaration.modifiers & ClassFileConstants.AccInterface) != 0) {
2601 		problemID = IProblem.CannotDefineInterfaceInLocalType;
2602 	}
2603 	if (problemID != 0) {
2604 		String[] arguments = new String[] {new String(typeDeclaration.name)};
2605 		this.handle(
2606 			problemID,
2607 			arguments,
2608 			arguments,
2609 			typeDeclaration.sourceStart,
2610 			typeDeclaration.sourceEnd);
2611 	}
2612 }
illegalModifierCombinationFinalAbstractForClass(SourceTypeBinding type)2613 public void illegalModifierCombinationFinalAbstractForClass(SourceTypeBinding type) {
2614 	String[] arguments = new String[] {new String(type.sourceName())};
2615 	this.handle(
2616 		IProblem.IllegalModifierCombinationFinalAbstractForClass,
2617 		arguments,
2618 		arguments,
2619 		type.sourceStart(),
2620 		type.sourceEnd());
2621 }
illegalModifierCombinationFinalVolatileForField(ReferenceBinding type, FieldDeclaration fieldDecl)2622 public void illegalModifierCombinationFinalVolatileForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
2623 	String[] arguments = new String[] {new String(fieldDecl.name)};
2624 
2625 	this.handle(
2626 		IProblem.IllegalModifierCombinationFinalVolatileForField,
2627 		arguments,
2628 		arguments,
2629 		fieldDecl.sourceStart,
2630 		fieldDecl.sourceEnd);
2631 }
illegalModifierCombinationForInterfaceMethod(AbstractMethodDeclaration methodDecl)2632 public void illegalModifierCombinationForInterfaceMethod(AbstractMethodDeclaration methodDecl) {
2633 	String[] arguments = new String[] {new String(methodDecl.selector)};
2634 	this.handle(
2635 		IProblem.IllegalModifierCombinationForInterfaceMethod,
2636 		arguments,
2637 		arguments,
2638 		methodDecl.sourceStart,
2639 		methodDecl.sourceEnd);
2640 }
2641 
illegalModifierForAnnotationField(FieldDeclaration fieldDecl)2642 public void illegalModifierForAnnotationField(FieldDeclaration fieldDecl) {
2643 	String name = new String(fieldDecl.name);
2644 	this.handle(
2645 		IProblem.IllegalModifierForAnnotationField,
2646 		new String[] {
2647 			new String(fieldDecl.binding.declaringClass.readableName()),
2648 			name,
2649 		},
2650 		new String[] {
2651 			new String(fieldDecl.binding.declaringClass.shortReadableName()),
2652 			name,
2653 		},
2654 		fieldDecl.sourceStart,
2655 		fieldDecl.sourceEnd);
2656 }
illegalModifierForAnnotationMember(AbstractMethodDeclaration methodDecl)2657 public void illegalModifierForAnnotationMember(AbstractMethodDeclaration methodDecl) {
2658 	this.handle(
2659 		IProblem.IllegalModifierForAnnotationMethod,
2660 		new String[] {
2661 			new String(methodDecl.binding.declaringClass.readableName()),
2662 			new String(methodDecl.selector),
2663 		},
2664 		new String[] {
2665 			new String(methodDecl.binding.declaringClass.shortReadableName()),
2666 			new String(methodDecl.selector),
2667 		},
2668 		methodDecl.sourceStart,
2669 		methodDecl.sourceEnd);
2670 }
illegalModifierForAnnotationMemberType(SourceTypeBinding type)2671 public void illegalModifierForAnnotationMemberType(SourceTypeBinding type) {
2672 	String[] arguments = new String[] {new String(type.sourceName())};
2673 	this.handle(
2674 		IProblem.IllegalModifierForAnnotationMemberType,
2675 		arguments,
2676 		arguments,
2677 		type.sourceStart(),
2678 		type.sourceEnd());
2679 }
illegalModifierForAnnotationType(SourceTypeBinding type)2680 public void illegalModifierForAnnotationType(SourceTypeBinding type) {
2681 	String[] arguments = new String[] {new String(type.sourceName())};
2682 	this.handle(
2683 		IProblem.IllegalModifierForAnnotationType,
2684 		arguments,
2685 		arguments,
2686 		type.sourceStart(),
2687 		type.sourceEnd());
2688 }
illegalModifierForClass(SourceTypeBinding type)2689 public void illegalModifierForClass(SourceTypeBinding type) {
2690 	String[] arguments = new String[] {new String(type.sourceName())};
2691 	this.handle(
2692 		IProblem.IllegalModifierForClass,
2693 		arguments,
2694 		arguments,
2695 		type.sourceStart(),
2696 		type.sourceEnd());
2697 }
illegalModifierForEnum(SourceTypeBinding type)2698 public void illegalModifierForEnum(SourceTypeBinding type) {
2699 	String[] arguments = new String[] {new String(type.sourceName())};
2700 	this.handle(
2701 		IProblem.IllegalModifierForEnum,
2702 		arguments,
2703 		arguments,
2704 		type.sourceStart(),
2705 		type.sourceEnd());
2706 }
illegalModifierForEnumConstant(ReferenceBinding type, FieldDeclaration fieldDecl)2707 public void illegalModifierForEnumConstant(ReferenceBinding type, FieldDeclaration fieldDecl) {
2708 	String[] arguments = new String[] {new String(fieldDecl.name)};
2709 	this.handle(
2710 		IProblem.IllegalModifierForEnumConstant,
2711 		arguments,
2712 		arguments,
2713 		fieldDecl.sourceStart,
2714 		fieldDecl.sourceEnd);
2715 }
2716 
illegalModifierForEnumConstructor(AbstractMethodDeclaration constructor)2717 public void illegalModifierForEnumConstructor(AbstractMethodDeclaration constructor) {
2718 	this.handle(
2719 		IProblem.IllegalModifierForEnumConstructor,
2720 		NoArgument,
2721 		NoArgument,
2722 		constructor.sourceStart,
2723 		constructor.sourceEnd);
2724 }
illegalModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl)2725 public void illegalModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
2726 	String[] arguments = new String[] {new String(fieldDecl.name)};
2727 	this.handle(
2728 		IProblem.IllegalModifierForField,
2729 		arguments,
2730 		arguments,
2731 		fieldDecl.sourceStart,
2732 		fieldDecl.sourceEnd);
2733 }
illegalModifierForInterface(SourceTypeBinding type)2734 public void illegalModifierForInterface(SourceTypeBinding type) {
2735 	String[] arguments = new String[] {new String(type.sourceName())};
2736 	this.handle(
2737 		IProblem.IllegalModifierForInterface,
2738 		arguments,
2739 		arguments,
2740 		type.sourceStart(),
2741 		type.sourceEnd());
2742 }
2743 
illegalModifierForInterfaceField(FieldDeclaration fieldDecl)2744 public void illegalModifierForInterfaceField(FieldDeclaration fieldDecl) {
2745 	String name = new String(fieldDecl.name);
2746 	this.handle(
2747 		IProblem.IllegalModifierForInterfaceField,
2748 		new String[] {
2749 			new String(fieldDecl.binding.declaringClass.readableName()),
2750 			name,
2751 		},
2752 		new String[] {
2753 			new String(fieldDecl.binding.declaringClass.shortReadableName()),
2754 			name,
2755 		},
2756 		fieldDecl.sourceStart,
2757 		fieldDecl.sourceEnd);
2758 }
illegalModifierForInterfaceMethod(AbstractMethodDeclaration methodDecl, boolean isJDK18orGreater)2759 public void illegalModifierForInterfaceMethod(AbstractMethodDeclaration methodDecl, boolean isJDK18orGreater) {
2760 	// cannot include parameter types since they are not resolved yet
2761 	// and the error message would be too long
2762 	this.handle(
2763 		isJDK18orGreater
2764 			? IProblem.IllegalModifierForInterfaceMethod18
2765 			: IProblem.IllegalModifierForInterfaceMethod,
2766 		new String[] {
2767 			new String(methodDecl.selector)
2768 		},
2769 		new String[] {
2770 			new String(methodDecl.selector)
2771 		},
2772 		methodDecl.sourceStart,
2773 		methodDecl.sourceEnd);
2774 }
illegalModifierForLocalClass(SourceTypeBinding type)2775 public void illegalModifierForLocalClass(SourceTypeBinding type) {
2776 	String[] arguments = new String[] {new String(type.sourceName())};
2777 	this.handle(
2778 		IProblem.IllegalModifierForLocalClass,
2779 		arguments,
2780 		arguments,
2781 		type.sourceStart(),
2782 		type.sourceEnd());
2783 }
illegalModifierForMemberClass(SourceTypeBinding type)2784 public void illegalModifierForMemberClass(SourceTypeBinding type) {
2785 	String[] arguments = new String[] {new String(type.sourceName())};
2786 	this.handle(
2787 		IProblem.IllegalModifierForMemberClass,
2788 		arguments,
2789 		arguments,
2790 		type.sourceStart(),
2791 		type.sourceEnd());
2792 }
illegalModifierForMemberEnum(SourceTypeBinding type)2793 public void illegalModifierForMemberEnum(SourceTypeBinding type) {
2794 	String[] arguments = new String[] {new String(type.sourceName())};
2795 	this.handle(
2796 		IProblem.IllegalModifierForMemberEnum,
2797 		arguments,
2798 		arguments,
2799 		type.sourceStart(),
2800 		type.sourceEnd());
2801 }
illegalModifierForMemberInterface(SourceTypeBinding type)2802 public void illegalModifierForMemberInterface(SourceTypeBinding type) {
2803 	String[] arguments = new String[] {new String(type.sourceName())};
2804 	this.handle(
2805 		IProblem.IllegalModifierForMemberInterface,
2806 		arguments,
2807 		arguments,
2808 		type.sourceStart(),
2809 		type.sourceEnd());
2810 }
illegalModifierForMethod(AbstractMethodDeclaration methodDecl)2811 public void illegalModifierForMethod(AbstractMethodDeclaration methodDecl) {
2812 	// cannot include parameter types since they are not resolved yet
2813 	// and the error message would be too long
2814 	this.handle(
2815 		methodDecl.isConstructor() ? IProblem.IllegalModifierForConstructor : IProblem.IllegalModifierForMethod,
2816 		new String[] {
2817 			new String(methodDecl.selector)
2818 		},
2819 		new String[] {
2820 			new String(methodDecl.selector)
2821 		},
2822 		methodDecl.sourceStart,
2823 		methodDecl.sourceEnd);
2824 }
illegalModifierForVariable(LocalDeclaration localDecl, boolean complainAsArgument)2825 public void illegalModifierForVariable(LocalDeclaration localDecl, boolean complainAsArgument) {
2826 	String[] arguments = new String[] {new String(localDecl.name)};
2827 	this.handle(
2828 		complainAsArgument
2829 			? IProblem.IllegalModifierForArgument
2830 			: IProblem.IllegalModifierForVariable,
2831 		arguments,
2832 		arguments,
2833 		localDecl.sourceStart,
2834 		localDecl.sourceEnd);
2835 }
illegalPrimitiveOrArrayTypeForEnclosingInstance(TypeBinding enclosingType, ASTNode location)2836 public void illegalPrimitiveOrArrayTypeForEnclosingInstance(TypeBinding enclosingType, ASTNode location) {
2837 	this.handle(
2838 		IProblem.IllegalPrimitiveOrArrayTypeForEnclosingInstance,
2839 		new String[] {new String(enclosingType.readableName())},
2840 		new String[] {new String(enclosingType.shortReadableName())},
2841 		location.sourceStart,
2842 		location.sourceEnd);
2843 }
illegalQualifiedParameterizedTypeAllocation(TypeReference qualifiedTypeReference, TypeBinding allocatedType)2844 public void illegalQualifiedParameterizedTypeAllocation(TypeReference qualifiedTypeReference, TypeBinding allocatedType) {
2845 	this.handle(
2846 		IProblem.IllegalQualifiedParameterizedTypeAllocation,
2847 		new String[] { new String(allocatedType.readableName()), new String(allocatedType.enclosingType().readableName()), },
2848 		new String[] { new String(allocatedType.shortReadableName()), new String(allocatedType.enclosingType().shortReadableName()), },
2849 		qualifiedTypeReference.sourceStart,
2850 		qualifiedTypeReference.sourceEnd);
2851 }
illegalStaticModifierForMemberType(SourceTypeBinding type)2852 public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
2853 	String[] arguments = new String[] {new String(type.sourceName())};
2854 	this.handle(
2855 		IProblem.IllegalStaticModifierForMemberType,
2856 		arguments,
2857 		arguments,
2858 		type.sourceStart(),
2859 		type.sourceEnd());
2860 }
illegalUsageOfQualifiedTypeReference(QualifiedTypeReference qualifiedTypeReference)2861 public void illegalUsageOfQualifiedTypeReference(QualifiedTypeReference qualifiedTypeReference) {
2862 	StringBuffer buffer = new StringBuffer();
2863 	char[][] tokens = qualifiedTypeReference.tokens;
2864 	for (int i = 0; i < tokens.length; i++) {
2865 		if (i > 0) buffer.append('.');
2866 		buffer.append(tokens[i]);
2867 	}
2868 	String[] arguments = new String[] { String.valueOf(buffer)};
2869 	this.handle(
2870 		IProblem.IllegalUsageOfQualifiedTypeReference,
2871 		arguments,
2872 		arguments,
2873 		qualifiedTypeReference.sourceStart,
2874 		qualifiedTypeReference.sourceEnd);
2875 }
illegalUsageOfWildcard(TypeReference wildcard)2876 public void illegalUsageOfWildcard(TypeReference wildcard) {
2877 	this.handle(
2878 		IProblem.InvalidUsageOfWildcard,
2879 		NoArgument,
2880 		NoArgument,
2881 		wildcard.sourceStart,
2882 		wildcard.sourceEnd);
2883 }
illegalVararg(Argument argType, AbstractMethodDeclaration methodDecl)2884 public void illegalVararg(Argument argType, AbstractMethodDeclaration methodDecl) {
2885 	String[] arguments = new String[] {CharOperation.toString(argType.type.getTypeName()), new String(methodDecl.selector)};
2886 	this.handle(
2887 		IProblem.IllegalVararg,
2888 		arguments,
2889 		arguments,
2890 		argType.sourceStart,
2891 		argType.sourceEnd);
2892 }
illegalVarargInLambda(Argument argType)2893 public void illegalVarargInLambda(Argument argType) {
2894 	String[] arguments = new String[] { CharOperation.toString(argType.type.getTypeName())};
2895 	this.handle(
2896 		IProblem.IllegalVarargInLambda,
2897 		arguments,
2898 		arguments,
2899 		argType.sourceStart,
2900 		argType.sourceEnd);
2901 }
illegalThisDeclaration(Argument argument)2902 public void illegalThisDeclaration(Argument argument) {
2903 	String[] arguments = NoArgument;
2904 	this.handle(
2905 		IProblem.IllegalDeclarationOfThisParameter,
2906 		arguments,
2907 		arguments,
2908 		argument.sourceStart,
2909 		argument.sourceEnd);
2910 }
illegalSourceLevelForThis(Argument argument)2911 public void illegalSourceLevelForThis(Argument argument) {
2912 	String[] arguments = NoArgument;
2913 	this.handle(
2914 		IProblem.ExplicitThisParameterNotBelow18,
2915 		arguments,
2916 		arguments,
2917 		argument.sourceStart,
2918 		argument.sourceEnd);
2919 }
disallowedThisParameter(Receiver receiver)2920 public void disallowedThisParameter(Receiver receiver) {
2921 	String[] arguments = NoArgument;
2922 	this.handle(
2923 		IProblem.DisallowedExplicitThisParameter,
2924 		arguments,
2925 		arguments,
2926 		receiver.sourceStart,
2927 		receiver.sourceEnd);
2928 }
illegalQualifierForExplicitThis(Receiver receiver, TypeBinding expectedType)2929 public void illegalQualifierForExplicitThis(Receiver receiver, TypeBinding expectedType) {
2930 	String[] problemArguments = new String[] { new String(expectedType.sourceName())};
2931 	this.handle(
2932 		IProblem.IllegalQualifierForExplicitThis,
2933 		problemArguments,
2934 		problemArguments,
2935 		(receiver.qualifyingName == null) ? receiver.sourceStart : receiver.qualifyingName.sourceStart,
2936 		receiver.sourceEnd);
2937 }
illegalQualifierForExplicitThis2(Receiver receiver)2938 public void illegalQualifierForExplicitThis2(Receiver receiver) {
2939 	this.handle(
2940 		IProblem.IllegalQualifierForExplicitThis2,
2941 		NoArgument,
2942 		NoArgument,
2943 		receiver.qualifyingName.sourceStart,
2944 		receiver.sourceEnd);
2945 }
illegalTypeForExplicitThis(Receiver receiver, TypeBinding expectedType)2946 public void illegalTypeForExplicitThis(Receiver receiver, TypeBinding expectedType) {
2947 	this.handle(
2948 		IProblem.IllegalTypeForExplicitThis,
2949 		new String[] { new String(expectedType.readableName())},
2950 		new String[] { new String(expectedType.shortReadableName())},
2951 		receiver.type.sourceStart,
2952 		receiver.type.sourceEnd);
2953 }
illegalThis(Argument argument)2954 public void illegalThis(Argument argument) {
2955 	String[] arguments = NoArgument;
2956 	this.handle(
2957 		IProblem.ExplicitThisParameterNotInLambda,
2958 		arguments,
2959 		arguments,
2960 		argument.sourceStart,
2961 		argument.sourceEnd);
2962 }
defaultMethodsNotBelow18(MethodDeclaration md)2963 public void defaultMethodsNotBelow18(MethodDeclaration md) {
2964 	this.handle(
2965 			IProblem.DefaultMethodNotBelow18,
2966 			NoArgument,
2967 			NoArgument,
2968 			md.sourceStart,
2969 			md.sourceEnd);
2970 }
staticInterfaceMethodsNotBelow18(MethodDeclaration md)2971 public void staticInterfaceMethodsNotBelow18(MethodDeclaration md) {
2972 	this.handle(
2973 			IProblem.StaticInterfaceMethodNotBelow18,
2974 			NoArgument,
2975 			NoArgument,
2976 			md.sourceStart,
2977 			md.sourceEnd);
2978 }
referenceExpressionsNotBelow18(ReferenceExpression rexp)2979 public void referenceExpressionsNotBelow18(ReferenceExpression rexp) {
2980 	this.handle(
2981 			rexp.isMethodReference() ? IProblem.MethodReferenceNotBelow18 : IProblem.ConstructorReferenceNotBelow18,
2982 			NoArgument,
2983 			NoArgument,
2984 			rexp.sourceStart,
2985 			rexp.sourceEnd);
2986 }
lambdaExpressionsNotBelow18(LambdaExpression lexp)2987 public void lambdaExpressionsNotBelow18(LambdaExpression lexp) {
2988 	this.handle(
2989 			IProblem.LambdaExpressionNotBelow18,
2990 			NoArgument,
2991 			NoArgument,
2992 			lexp.sourceStart,
2993 			lexp.diagnosticsSourceEnd());
2994 }
illegalVisibilityModifierCombinationForField(ReferenceBinding type, FieldDeclaration fieldDecl)2995 public void illegalVisibilityModifierCombinationForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
2996 	String[] arguments = new String[] {new String(fieldDecl.name)};
2997 	this.handle(
2998 		IProblem.IllegalVisibilityModifierCombinationForField,
2999 		arguments,
3000 		arguments,
3001 		fieldDecl.sourceStart,
3002 		fieldDecl.sourceEnd);
3003 }
illegalVisibilityModifierCombinationForMemberType(SourceTypeBinding type)3004 public void illegalVisibilityModifierCombinationForMemberType(SourceTypeBinding type) {
3005 	String[] arguments = new String[] {new String(type.sourceName())};
3006 	this.handle(
3007 		IProblem.IllegalVisibilityModifierCombinationForMemberType,
3008 		arguments,
3009 		arguments,
3010 		type.sourceStart(),
3011 		type.sourceEnd());
3012 }
illegalVisibilityModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl)3013 public void illegalVisibilityModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
3014 	String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
3015 	this.handle(
3016 		IProblem.IllegalVisibilityModifierCombinationForMethod,
3017 		arguments,
3018 		arguments,
3019 		methodDecl.sourceStart,
3020 		methodDecl.sourceEnd);
3021 }
illegalVisibilityModifierForInterfaceMemberType(SourceTypeBinding type)3022 public void illegalVisibilityModifierForInterfaceMemberType(SourceTypeBinding type) {
3023 	String[] arguments = new String[] {new String(type.sourceName())};
3024 	this.handle(
3025 		IProblem.IllegalVisibilityModifierForInterfaceMemberType,
3026 		arguments,
3027 		arguments,
3028 		type.sourceStart(),
3029 		type.sourceEnd());
3030 }
illegalVoidExpression(ASTNode location)3031 public void illegalVoidExpression(ASTNode location) {
3032 	this.handle(
3033 		IProblem.InvalidVoidExpression,
3034 		NoArgument,
3035 		NoArgument,
3036 		location.sourceStart,
3037 		location.sourceEnd);
3038 }
importProblem(ImportReference importRef, Binding expectedImport)3039 public void importProblem(ImportReference importRef, Binding expectedImport) {
3040 	if (expectedImport instanceof FieldBinding) {
3041 		int id = IProblem.UndefinedField;
3042 		FieldBinding field = (FieldBinding) expectedImport;
3043 		String[] readableArguments = null;
3044 		String[] shortArguments = null;
3045 		switch (expectedImport.problemId()) {
3046 			case ProblemReasons.NotVisible :
3047 				id = IProblem.NotVisibleField;
3048 				readableArguments = new String[] {CharOperation.toString(importRef.tokens), new String(field.declaringClass.readableName())};
3049 				shortArguments = new String[] {CharOperation.toString(importRef.tokens), new String(field.declaringClass.shortReadableName())};
3050 				break;
3051 			case ProblemReasons.Ambiguous :
3052 				id = IProblem.AmbiguousField;
3053 				readableArguments = new String[] {new String(field.readableName())};
3054 				shortArguments = new String[] {new String(field.readableName())};
3055 				break;
3056 			case ProblemReasons.ReceiverTypeNotVisible :
3057 				id = IProblem.NotVisibleType;
3058 				readableArguments = new String[] {new String(field.declaringClass.leafComponentType().readableName())};
3059 				shortArguments = new String[] {new String(field.declaringClass.leafComponentType().shortReadableName())};
3060 				break;
3061 		}
3062 		this.handle(
3063 			id,
3064 			readableArguments,
3065 			shortArguments,
3066 			nodeSourceStart(field, importRef),
3067 			nodeSourceEnd(field, importRef));
3068 		return;
3069 	}
3070 
3071 	if (expectedImport.problemId() == ProblemReasons.NotFound) {
3072 		char[][] tokens = expectedImport instanceof ProblemReferenceBinding
3073 			? ((ProblemReferenceBinding) expectedImport).compoundName
3074 			: importRef.tokens;
3075 		String[] arguments = new String[]{CharOperation.toString(tokens)};
3076 		this.handle(
3077 		        IProblem.ImportNotFound,
3078 		        arguments,
3079 		        arguments,
3080 		        importRef.sourceStart,
3081 		        (int) importRef.sourcePositions[tokens.length - 1]);
3082 		return;
3083 	}
3084 	if (expectedImport.problemId() == ProblemReasons.InvalidTypeForStaticImport) {
3085 		char[][] tokens = importRef.tokens;
3086 		String[] arguments = new String[]{CharOperation.toString(tokens)};
3087 		this.handle(
3088 		        IProblem.InvalidTypeForStaticImport,
3089 		        arguments,
3090 		        arguments,
3091 		        importRef.sourceStart,
3092 		        (int) importRef.sourcePositions[tokens.length - 1]);
3093 		return;
3094 	}
3095 	invalidType(importRef, (TypeBinding)expectedImport);
3096 }
incompatibleExceptionInThrowsClause(SourceTypeBinding type, MethodBinding currentMethod, MethodBinding inheritedMethod, ReferenceBinding exceptionType)3097 public void incompatibleExceptionInThrowsClause(SourceTypeBinding type, MethodBinding currentMethod, MethodBinding inheritedMethod, ReferenceBinding exceptionType) {
3098 	if (TypeBinding.equalsEquals(type, currentMethod.declaringClass)) {
3099 		int id;
3100 		if (currentMethod.declaringClass.isInterface()
3101 				&& !inheritedMethod.isPublic()){ // interface inheriting Object protected method
3102 			id = IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod;
3103 		} else {
3104 			id = IProblem.IncompatibleExceptionInThrowsClause;
3105 		}
3106 		this.handle(
3107 			// Exception %1 is not compatible with throws clause in %2
3108 			// 9.4.4 - The type of exception in the throws clause is incompatible.
3109 			id,
3110 			new String[] {
3111 				new String(exceptionType.sourceName()),
3112 				new String(
3113 					CharOperation.concat(
3114 						inheritedMethod.declaringClass.readableName(),
3115 						inheritedMethod.readableName(),
3116 						'.'))},
3117 			new String[] {
3118 				new String(exceptionType.sourceName()),
3119 				new String(
3120 					CharOperation.concat(
3121 						inheritedMethod.declaringClass.shortReadableName(),
3122 						inheritedMethod.shortReadableName(),
3123 						'.'))},
3124 			currentMethod.sourceStart(),
3125 			currentMethod.sourceEnd());
3126 	} else
3127 		this.handle(
3128 			// Exception %1 in throws clause of %2 is not compatible with %3
3129 			// 9.4.4 - The type of exception in the throws clause is incompatible.
3130 			IProblem.IncompatibleExceptionInInheritedMethodThrowsClause,
3131 			new String[] {
3132 				new String(exceptionType.sourceName()),
3133 				new String(
3134 					CharOperation.concat(
3135 						currentMethod.declaringClass.sourceName(),
3136 						currentMethod.readableName(),
3137 						'.')),
3138 				new String(
3139 					CharOperation.concat(
3140 						inheritedMethod.declaringClass.readableName(),
3141 						inheritedMethod.readableName(),
3142 						'.'))},
3143 			new String[] {
3144 				new String(exceptionType.sourceName()),
3145 				new String(
3146 					CharOperation.concat(
3147 						currentMethod.declaringClass.sourceName(),
3148 						currentMethod.shortReadableName(),
3149 						'.')),
3150 				new String(
3151 					CharOperation.concat(
3152 						inheritedMethod.declaringClass.shortReadableName(),
3153 						inheritedMethod.shortReadableName(),
3154 						'.'))},
3155 			type.sourceStart(),
3156 			type.sourceEnd());
3157 }
incompatibleReturnType(MethodBinding currentMethod, MethodBinding inheritedMethod)3158 public void incompatibleReturnType(MethodBinding currentMethod, MethodBinding inheritedMethod) {
3159 	StringBuffer methodSignature = new StringBuffer();
3160 	methodSignature
3161 		.append(inheritedMethod.declaringClass.readableName())
3162 		.append('.')
3163 		.append(inheritedMethod.readableName());
3164 
3165 	StringBuffer shortSignature = new StringBuffer();
3166 	shortSignature
3167 		.append(inheritedMethod.declaringClass.shortReadableName())
3168 		.append('.')
3169 		.append(inheritedMethod.shortReadableName());
3170 
3171 	int id;
3172 	final ReferenceBinding declaringClass = currentMethod.declaringClass;
3173 	if (declaringClass.isInterface()
3174 			&& !inheritedMethod.isPublic()){ // interface inheriting Object protected method
3175 		id = IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod;
3176 	} else {
3177 		id = IProblem.IncompatibleReturnType;
3178 	}
3179 	AbstractMethodDeclaration method = currentMethod.sourceMethod();
3180 	int sourceStart = 0;
3181 	int sourceEnd = 0;
3182 	if (method == null) {
3183 		if (declaringClass instanceof SourceTypeBinding) {
3184 			SourceTypeBinding sourceTypeBinding = (SourceTypeBinding) declaringClass;
3185 			sourceStart = sourceTypeBinding.sourceStart();
3186 			sourceEnd = sourceTypeBinding.sourceEnd();
3187 		}
3188 	} else if (method.isConstructor()){
3189 		sourceStart = method.sourceStart;
3190 		sourceEnd = method.sourceEnd;
3191 	} else {
3192 		TypeReference returnType = ((MethodDeclaration) method).returnType;
3193 		sourceStart = returnType.sourceStart;
3194 		if (returnType instanceof ParameterizedSingleTypeReference) {
3195 			ParameterizedSingleTypeReference typeReference = (ParameterizedSingleTypeReference) returnType;
3196 			TypeReference[] typeArguments = typeReference.typeArguments;
3197 			if (typeArguments[typeArguments.length - 1].sourceEnd > typeReference.sourceEnd) {
3198 				sourceEnd = retrieveClosingAngleBracketPosition(typeReference.sourceEnd);
3199 			} else {
3200 				sourceEnd = returnType.sourceEnd;
3201 			}
3202 		} else if (returnType instanceof ParameterizedQualifiedTypeReference) {
3203 			ParameterizedQualifiedTypeReference typeReference = (ParameterizedQualifiedTypeReference) returnType;
3204 			sourceEnd = retrieveClosingAngleBracketPosition(typeReference.sourceEnd);
3205 		} else {
3206 			sourceEnd = returnType.sourceEnd;
3207 		}
3208 	}
3209 	this.handle(
3210 		id,
3211 		new String[] {methodSignature.toString()},
3212 		new String[] {shortSignature.toString()},
3213 		sourceStart,
3214 		sourceEnd);
3215 }
incorrectArityForParameterizedType(ASTNode location, TypeBinding type, TypeBinding[] argumentTypes)3216 public void incorrectArityForParameterizedType(ASTNode location, TypeBinding type, TypeBinding[] argumentTypes) {
3217 	incorrectArityForParameterizedType(location, type, argumentTypes, Integer.MAX_VALUE);
3218 }
incorrectArityForParameterizedType(ASTNode location, TypeBinding type, TypeBinding[] argumentTypes, int index)3219 public void incorrectArityForParameterizedType(ASTNode location, TypeBinding type, TypeBinding[] argumentTypes, int index) {
3220     if (location == null) {
3221 		this.handle(
3222 			IProblem.IncorrectArityForParameterizedType,
3223 			new String[] {new String(type.readableName()), typesAsString(argumentTypes, false)},
3224 			new String[] {new String(type.shortReadableName()), typesAsString(argumentTypes, true)},
3225 			ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
3226 			0,
3227 			0);
3228 		return; // not reached since aborted above
3229     }
3230 	this.handle(
3231 		IProblem.IncorrectArityForParameterizedType,
3232 		new String[] {new String(type.readableName()), typesAsString(argumentTypes, false)},
3233 		new String[] {new String(type.shortReadableName()), typesAsString(argumentTypes, true)},
3234 		location.sourceStart,
3235 		nodeSourceEnd(null, location, index));
3236 }
diamondNotBelow17(ASTNode location)3237 public void diamondNotBelow17(ASTNode location) {
3238 	diamondNotBelow17(location, Integer.MAX_VALUE);
3239 }
diamondNotBelow17(ASTNode location, int index)3240 public void diamondNotBelow17(ASTNode location, int index) {
3241 	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=348493
3242     if (location == null) {
3243 		this.handle(
3244 			IProblem.DiamondNotBelow17,
3245 			NoArgument,
3246 			NoArgument,
3247 			ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
3248 			0,
3249 			0);
3250 		return; // not reached since aborted above
3251     }
3252 	this.handle(
3253 		IProblem.DiamondNotBelow17,
3254 		NoArgument,
3255 		NoArgument,
3256 		location.sourceStart,
3257 		nodeSourceEnd(null, location, index));
3258 }
incorrectLocationForNonEmptyDimension(ArrayAllocationExpression expression, int index)3259 public void incorrectLocationForNonEmptyDimension(ArrayAllocationExpression expression, int index) {
3260 	this.handle(
3261 		IProblem.IllegalDimension,
3262 		NoArgument,
3263 		NoArgument,
3264 		expression.dimensions[index].sourceStart,
3265 		expression.dimensions[index].sourceEnd);
3266 }
incorrectSwitchType(Expression expression, TypeBinding testType)3267 public void incorrectSwitchType(Expression expression, TypeBinding testType) {
3268 	if (this.options.sourceLevel < ClassFileConstants.JDK1_7) {
3269 		if (testType.id == TypeIds.T_JavaLangString) {
3270 			this.handle(
3271 					IProblem.SwitchOnStringsNotBelow17,
3272 					new String[] {new String(testType.readableName())},
3273 					new String[] {new String(testType.shortReadableName())},
3274 					expression.sourceStart,
3275 					expression.sourceEnd);
3276 		} else {
3277 			if (this.options.sourceLevel < ClassFileConstants.JDK1_5 && testType.isEnum()) {
3278 				this.handle(
3279 						IProblem.SwitchOnEnumNotBelow15,
3280 						new String[] {new String(testType.readableName())},
3281 						new String[] {new String(testType.shortReadableName())},
3282 						expression.sourceStart,
3283 						expression.sourceEnd);
3284 			} else {
3285 				this.handle(
3286 						IProblem.IncorrectSwitchType,
3287 						new String[] {new String(testType.readableName())},
3288 						new String[] {new String(testType.shortReadableName())},
3289 						expression.sourceStart,
3290 						expression.sourceEnd);
3291 			}
3292 		}
3293 	} else {
3294 		this.handle(
3295 				IProblem.IncorrectSwitchType17,
3296 				new String[] {new String(testType.readableName())},
3297 				new String[] {new String(testType.shortReadableName())},
3298 				expression.sourceStart,
3299 				expression.sourceEnd);
3300 	}
3301 }
indirectAccessToStaticField(ASTNode location, FieldBinding field)3302 public void indirectAccessToStaticField(ASTNode location, FieldBinding field){
3303 	int severity = computeSeverity(IProblem.IndirectAccessToStaticField);
3304 	if (severity == ProblemSeverities.Ignore) return;
3305 	this.handle(
3306 		IProblem.IndirectAccessToStaticField,
3307 		new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
3308 		new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
3309 		severity,
3310 		nodeSourceStart(field, location),
3311 		nodeSourceEnd(field, location));
3312 }
indirectAccessToStaticMethod(ASTNode location, MethodBinding method)3313 public void indirectAccessToStaticMethod(ASTNode location, MethodBinding method) {
3314 	int severity = computeSeverity(IProblem.IndirectAccessToStaticMethod);
3315 	if (severity == ProblemSeverities.Ignore) return;
3316 	this.handle(
3317 		IProblem.IndirectAccessToStaticMethod,
3318 		new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method, false)},
3319 		new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method, true)},
3320 		severity,
3321 		location.sourceStart,
3322 		location.sourceEnd);
3323 }
inheritedDefaultMethodConflictsWithOtherInherited(SourceTypeBinding type, MethodBinding defaultMethod, MethodBinding otherMethod)3324 public void inheritedDefaultMethodConflictsWithOtherInherited(SourceTypeBinding type, MethodBinding defaultMethod, MethodBinding otherMethod) {
3325 	TypeDeclaration typeDecl = type.scope.referenceContext;
3326 	String[] problemArguments = new String[] {
3327 			String.valueOf(defaultMethod.readableName()),
3328 			String.valueOf(defaultMethod.declaringClass.readableName()),
3329 			String.valueOf(otherMethod.declaringClass.readableName()) };
3330 	String[] messageArguments = new String[] {
3331 			String.valueOf(defaultMethod.shortReadableName()),
3332 			String.valueOf(defaultMethod.declaringClass.shortReadableName()),
3333 			String.valueOf(otherMethod.declaringClass.shortReadableName()) };
3334 	this.handle(IProblem.InheritedDefaultMethodConflictsWithOtherInherited,
3335 			problemArguments,
3336 			messageArguments,
3337 			typeDecl.sourceStart,
3338 			typeDecl.sourceEnd);
3339 }
inheritedMethodReducesVisibility(int sourceStart, int sourceEnd, MethodBinding concreteMethod, MethodBinding[] abstractMethods)3340 private void inheritedMethodReducesVisibility(int sourceStart, int sourceEnd, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
3341 	StringBuffer concreteSignature = new StringBuffer();
3342 	concreteSignature
3343 		.append(concreteMethod.declaringClass.readableName())
3344 		.append('.')
3345 		.append(concreteMethod.readableName());
3346 	StringBuffer shortSignature = new StringBuffer();
3347 	shortSignature
3348 		.append(concreteMethod.declaringClass.shortReadableName())
3349 		.append('.')
3350 		.append(concreteMethod.shortReadableName());
3351 	this.handle(
3352 		// The inherited method %1 cannot hide the public abstract method in %2
3353 		IProblem.InheritedMethodReducesVisibility,
3354 		new String[] {
3355 			concreteSignature.toString(),
3356 			new String(abstractMethods[0].declaringClass.readableName())},
3357 		new String[] {
3358 			shortSignature.toString(),
3359 			new String(abstractMethods[0].declaringClass.shortReadableName())},
3360 		sourceStart,
3361 		sourceEnd);
3362 }
inheritedMethodReducesVisibility(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods)3363 public void inheritedMethodReducesVisibility(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
3364 	inheritedMethodReducesVisibility(type.sourceStart(), type.sourceEnd(), concreteMethod, abstractMethods);
3365 }
inheritedMethodReducesVisibility(TypeParameter typeParameter, MethodBinding concreteMethod, MethodBinding[] abstractMethods)3366 public void inheritedMethodReducesVisibility(TypeParameter typeParameter, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
3367 	inheritedMethodReducesVisibility(typeParameter.sourceStart(), typeParameter.sourceEnd(), concreteMethod, abstractMethods);
3368 }
inheritedMethodsHaveIncompatibleReturnTypes(ASTNode location, MethodBinding[] inheritedMethods, int length)3369 public void inheritedMethodsHaveIncompatibleReturnTypes(ASTNode location, MethodBinding[] inheritedMethods, int length) {
3370 	StringBuffer methodSignatures = new StringBuffer();
3371 	StringBuffer shortSignatures = new StringBuffer();
3372 	for (int i = length; --i >= 0;) {
3373 		methodSignatures
3374 			.append(inheritedMethods[i].declaringClass.readableName())
3375 			.append('.')
3376 			.append(inheritedMethods[i].readableName());
3377 		shortSignatures
3378 			.append(inheritedMethods[i].declaringClass.shortReadableName())
3379 			.append('.')
3380 			.append(inheritedMethods[i].shortReadableName());
3381 		if (i != 0){
3382 			methodSignatures.append(", "); //$NON-NLS-1$
3383 			shortSignatures.append(", "); //$NON-NLS-1$
3384 		}
3385 	}
3386 
3387 	this.handle(
3388 		// Return type is incompatible with %1
3389 		// 9.4.2 - The return type from the method is incompatible with the declaration.
3390 		IProblem.InheritedIncompatibleReturnType,
3391 		new String[] {methodSignatures.toString()},
3392 		new String[] {shortSignatures.toString()},
3393 		location.sourceStart,
3394 		location.sourceEnd);
3395 }
inheritedMethodsHaveIncompatibleReturnTypes(SourceTypeBinding type, MethodBinding[] inheritedMethods, int length, boolean[] isOverridden)3396 public void inheritedMethodsHaveIncompatibleReturnTypes(SourceTypeBinding type, MethodBinding[] inheritedMethods, int length, boolean[] isOverridden) {
3397 	StringBuffer methodSignatures = new StringBuffer();
3398 	StringBuffer shortSignatures = new StringBuffer();
3399 	for (int i = length; --i >= 0;) {
3400 		if (isOverridden[i]) continue;
3401 		methodSignatures
3402 			.append(inheritedMethods[i].declaringClass.readableName())
3403 			.append('.')
3404 			.append(inheritedMethods[i].readableName());
3405 		shortSignatures
3406 			.append(inheritedMethods[i].declaringClass.shortReadableName())
3407 			.append('.')
3408 			.append(inheritedMethods[i].shortReadableName());
3409 		if (i != 0){
3410 			methodSignatures.append(", "); //$NON-NLS-1$
3411 			shortSignatures.append(", "); //$NON-NLS-1$
3412 		}
3413 	}
3414 
3415 	this.handle(
3416 		// Return type is incompatible with %1
3417 		// 9.4.2 - The return type from the method is incompatible with the declaration.
3418 		IProblem.InheritedIncompatibleReturnType,
3419 		new String[] {methodSignatures.toString()},
3420 		new String[] {shortSignatures.toString()},
3421 		type.sourceStart(),
3422 		type.sourceEnd());
3423 }
inheritedMethodsHaveNameClash(SourceTypeBinding type, MethodBinding oneMethod, MethodBinding twoMethod)3424 public void inheritedMethodsHaveNameClash(SourceTypeBinding type, MethodBinding oneMethod, MethodBinding twoMethod) {
3425 	this.handle(
3426 		IProblem.MethodNameClash,
3427 		new String[] {
3428 			new String(oneMethod.selector),
3429 			typesAsString(oneMethod.original(), false),
3430 			new String(oneMethod.declaringClass.readableName()),
3431 			typesAsString(twoMethod.original(), false),
3432 			new String(twoMethod.declaringClass.readableName()),
3433 		 },
3434 		new String[] {
3435 			new String(oneMethod.selector),
3436 			typesAsString(oneMethod.original(), true),
3437 			new String(oneMethod.declaringClass.shortReadableName()),
3438 			typesAsString(twoMethod.original(), true),
3439 			new String(twoMethod.declaringClass.shortReadableName()),
3440 		 },
3441 		 type.sourceStart(),
3442 		 type.sourceEnd());
3443 }
initializerMustCompleteNormally(FieldDeclaration fieldDecl)3444 public void initializerMustCompleteNormally(FieldDeclaration fieldDecl) {
3445 	this.handle(
3446 		IProblem.InitializerMustCompleteNormally,
3447 		NoArgument,
3448 		NoArgument,
3449 		fieldDecl.sourceStart,
3450 		fieldDecl.sourceEnd);
3451 }
innerTypesCannotDeclareStaticInitializers(ReferenceBinding innerType, Initializer initializer)3452 public void innerTypesCannotDeclareStaticInitializers(ReferenceBinding innerType, Initializer initializer) {
3453 	this.handle(
3454 		IProblem.CannotDefineStaticInitializerInLocalType,
3455 		new String[] {new String(innerType.readableName())},
3456 		new String[] {new String(innerType.shortReadableName())},
3457 		initializer.sourceStart,
3458 		initializer.sourceStart);
3459 }
interfaceCannotHaveConstructors(ConstructorDeclaration constructor)3460 public void interfaceCannotHaveConstructors(ConstructorDeclaration constructor) {
3461 	this.handle(
3462 		IProblem.InterfaceCannotHaveConstructors,
3463 		NoArgument,
3464 		NoArgument,
3465 		constructor.sourceStart,
3466 		constructor.sourceEnd,
3467 		constructor,
3468 		constructor.compilationResult());
3469 }
interfaceCannotHaveInitializers(char [] sourceName, FieldDeclaration fieldDecl)3470 public void interfaceCannotHaveInitializers(char [] sourceName, FieldDeclaration fieldDecl) {
3471 	String[] arguments = new String[] {new String(sourceName)};
3472 
3473 	this.handle(
3474 		IProblem.InterfaceCannotHaveInitializers,
3475 		arguments,
3476 		arguments,
3477 		fieldDecl.sourceStart,
3478 		fieldDecl.sourceEnd);
3479 }
invalidAnnotationMemberType(MethodDeclaration methodDecl)3480 public void invalidAnnotationMemberType(MethodDeclaration methodDecl) {
3481 	this.handle(
3482 		IProblem.InvalidAnnotationMemberType,
3483 		new String[] {
3484 			new String(methodDecl.binding.returnType.readableName()),
3485 			new String(methodDecl.selector),
3486 			new String(methodDecl.binding.declaringClass.readableName()),
3487 		},
3488 		new String[] {
3489 			new String(methodDecl.binding.returnType.shortReadableName()),
3490 			new String(methodDecl.selector),
3491 			new String(methodDecl.binding.declaringClass.shortReadableName()),
3492 		},
3493 		methodDecl.returnType.sourceStart,
3494 		methodDecl.returnType.sourceEnd);
3495 
3496 }
invalidBreak(ASTNode location)3497 public void invalidBreak(ASTNode location) {
3498 	this.handle(
3499 		IProblem.InvalidBreak,
3500 		NoArgument,
3501 		NoArgument,
3502 		location.sourceStart,
3503 		location.sourceEnd);
3504 }
invalidConstructor(Statement statement, MethodBinding targetConstructor)3505 public void invalidConstructor(Statement statement, MethodBinding targetConstructor) {
3506 	boolean insideDefaultConstructor =
3507 		(this.referenceContext instanceof ConstructorDeclaration)
3508 			&& ((ConstructorDeclaration)this.referenceContext).isDefaultConstructor();
3509 	boolean insideImplicitConstructorCall =
3510 		(statement instanceof ExplicitConstructorCall)
3511 			&& (((ExplicitConstructorCall) statement).accessMode == ExplicitConstructorCall.ImplicitSuper);
3512 
3513 	int sourceStart = statement.sourceStart;
3514 	int sourceEnd = statement.sourceEnd;
3515 	if (statement instanceof AllocationExpression) {
3516 		AllocationExpression allocation = (AllocationExpression)statement;
3517 		if (allocation.enumConstant != null) {
3518 			sourceStart = allocation.enumConstant.sourceStart;
3519 			sourceEnd = allocation.enumConstant.sourceEnd;
3520 		}
3521 	}
3522 
3523 	int id = IProblem.UndefinedConstructor; //default...
3524     MethodBinding shownConstructor = targetConstructor;
3525 	switch (targetConstructor.problemId()) {
3526 		case ProblemReasons.NotFound :
3527 			ProblemMethodBinding problemConstructor = (ProblemMethodBinding) targetConstructor;
3528 			if (problemConstructor.closestMatch != null) {
3529 		    	if ((problemConstructor.closestMatch.tagBits & TagBits.HasMissingType) != 0) {
3530 					missingTypeInConstructor(statement, problemConstructor.closestMatch);
3531 					return;
3532 		    	}
3533 		    }
3534 
3535 			if (insideDefaultConstructor){
3536 				id = IProblem.UndefinedConstructorInDefaultConstructor;
3537 			} else if (insideImplicitConstructorCall){
3538 				id = IProblem.UndefinedConstructorInImplicitConstructorCall;
3539 			} else {
3540 				id = IProblem.UndefinedConstructor;
3541 			}
3542 			break;
3543 		case ProblemReasons.NotVisible :
3544 			if (insideDefaultConstructor){
3545 				id = IProblem.NotVisibleConstructorInDefaultConstructor;
3546 			} else if (insideImplicitConstructorCall){
3547 				id = IProblem.NotVisibleConstructorInImplicitConstructorCall;
3548 			} else {
3549 				id = IProblem.NotVisibleConstructor;
3550 			}
3551 			problemConstructor = (ProblemMethodBinding) targetConstructor;
3552 			if (problemConstructor.closestMatch != null) {
3553 			    shownConstructor = problemConstructor.closestMatch.original();
3554 		    }
3555 			break;
3556 		case ProblemReasons.Ambiguous :
3557 			if (insideDefaultConstructor){
3558 				id = IProblem.AmbiguousConstructorInDefaultConstructor;
3559 			} else if (insideImplicitConstructorCall){
3560 				id = IProblem.AmbiguousConstructorInImplicitConstructorCall;
3561 			} else {
3562 				id = IProblem.AmbiguousConstructor;
3563 			}
3564 			break;
3565 		case ProblemReasons.ParameterBoundMismatch :
3566 			problemConstructor = (ProblemMethodBinding) targetConstructor;
3567 			ParameterizedGenericMethodBinding substitutedConstructor = (ParameterizedGenericMethodBinding) problemConstructor.closestMatch;
3568 			shownConstructor = substitutedConstructor.original();
3569 			int augmentedLength = problemConstructor.parameters.length;
3570 			TypeBinding inferredTypeArgument = problemConstructor.parameters[augmentedLength-2];
3571 			TypeVariableBinding typeParameter = (TypeVariableBinding) problemConstructor.parameters[augmentedLength-1];
3572 			TypeBinding[] invocationArguments = new TypeBinding[augmentedLength-2]; // remove extra info from the end
3573 			System.arraycopy(problemConstructor.parameters, 0, invocationArguments, 0, augmentedLength-2);
3574 			this.handle(
3575 				IProblem.GenericConstructorTypeArgumentMismatch,
3576 				new String[] {
3577 				        new String(shownConstructor.declaringClass.sourceName()),
3578 				        typesAsString(shownConstructor, false),
3579 				        new String(shownConstructor.declaringClass.readableName()),
3580 				        typesAsString(invocationArguments, false),
3581 				        new String(inferredTypeArgument.readableName()),
3582 				        new String(typeParameter.sourceName()),
3583 				        parameterBoundAsString(typeParameter, false) },
3584 				new String[] {
3585 				        new String(shownConstructor.declaringClass.sourceName()),
3586 				        typesAsString(shownConstructor, true),
3587 				        new String(shownConstructor.declaringClass.shortReadableName()),
3588 				        typesAsString(invocationArguments, true),
3589 				        new String(inferredTypeArgument.shortReadableName()),
3590 				        new String(typeParameter.sourceName()),
3591 				        parameterBoundAsString(typeParameter, true) },
3592 				sourceStart,
3593 				sourceEnd);
3594 			return;
3595 
3596 		case ProblemReasons.TypeParameterArityMismatch :
3597 			problemConstructor = (ProblemMethodBinding) targetConstructor;
3598 			shownConstructor = problemConstructor.closestMatch;
3599 			if (shownConstructor.typeVariables == Binding.NO_TYPE_VARIABLES) {
3600 				this.handle(
3601 					IProblem.NonGenericConstructor,
3602 					new String[] {
3603 					        new String(shownConstructor.declaringClass.sourceName()),
3604 					        typesAsString(shownConstructor, false),
3605 					        new String(shownConstructor.declaringClass.readableName()),
3606 					        typesAsString(targetConstructor, false) },
3607 					new String[] {
3608 					        new String(shownConstructor.declaringClass.sourceName()),
3609 					        typesAsString(shownConstructor, true),
3610 					        new String(shownConstructor.declaringClass.shortReadableName()),
3611 					        typesAsString(targetConstructor, true) },
3612 					sourceStart,
3613 					sourceEnd);
3614 			} else {
3615 				this.handle(
3616 					IProblem.IncorrectArityForParameterizedConstructor  ,
3617 					new String[] {
3618 					        new String(shownConstructor.declaringClass.sourceName()),
3619 					        typesAsString(shownConstructor, false),
3620 					        new String(shownConstructor.declaringClass.readableName()),
3621 							typesAsString(shownConstructor.typeVariables, false),
3622 					        typesAsString(targetConstructor, false) },
3623 					new String[] {
3624 					        new String(shownConstructor.declaringClass.sourceName()),
3625 					        typesAsString(shownConstructor, true),
3626 					        new String(shownConstructor.declaringClass.shortReadableName()),
3627 							typesAsString(shownConstructor.typeVariables, true),
3628 					        typesAsString(targetConstructor, true) },
3629 					sourceStart,
3630 					sourceEnd);
3631 			}
3632 			return;
3633 		case ProblemReasons.ParameterizedMethodTypeMismatch :
3634 			problemConstructor = (ProblemMethodBinding) targetConstructor;
3635 			shownConstructor = problemConstructor.closestMatch;
3636 			this.handle(
3637 				IProblem.ParameterizedConstructorArgumentTypeMismatch,
3638 				new String[] {
3639 				        new String(shownConstructor.declaringClass.sourceName()),
3640 				        typesAsString(shownConstructor, false),
3641 				        new String(shownConstructor.declaringClass.readableName()),
3642 						typesAsString(((ParameterizedGenericMethodBinding)shownConstructor).typeArguments, false),
3643 				        typesAsString(targetConstructor, false) },
3644 				new String[] {
3645 				        new String(shownConstructor.declaringClass.sourceName()),
3646 				        typesAsString(shownConstructor, true),
3647 				        new String(shownConstructor.declaringClass.shortReadableName()),
3648 						typesAsString(((ParameterizedGenericMethodBinding)shownConstructor).typeArguments, true),
3649 				        typesAsString(targetConstructor, true) },
3650 				sourceStart,
3651 				sourceEnd);
3652 			return;
3653 		case ProblemReasons.TypeArgumentsForRawGenericMethod :
3654 			problemConstructor = (ProblemMethodBinding) targetConstructor;
3655 			shownConstructor = problemConstructor.closestMatch;
3656 			this.handle(
3657 				IProblem.TypeArgumentsForRawGenericConstructor,
3658 				new String[] {
3659 				        new String(shownConstructor.declaringClass.sourceName()),
3660 				        typesAsString(shownConstructor, false),
3661 				        new String(shownConstructor.declaringClass.readableName()),
3662 				        typesAsString(targetConstructor, false) },
3663 				new String[] {
3664 				        new String(shownConstructor.declaringClass.sourceName()),
3665 				        typesAsString(shownConstructor, true),
3666 				        new String(shownConstructor.declaringClass.shortReadableName()),
3667 				        typesAsString(targetConstructor, true) },
3668 				sourceStart,
3669 				sourceEnd);
3670 			return;
3671 		case ProblemReasons.VarargsElementTypeNotVisible :
3672 			problemConstructor = (ProblemMethodBinding) targetConstructor;
3673 			shownConstructor = problemConstructor.closestMatch;
3674 			TypeBinding varargsElementType = shownConstructor.parameters[shownConstructor.parameters.length - 1].leafComponentType();
3675 			this.handle(
3676 				IProblem.VarargsElementTypeNotVisibleForConstructor,
3677 				new String[] {
3678 						new String(shownConstructor.declaringClass.sourceName()),
3679 						typesAsString(shownConstructor, false),
3680 						new String(shownConstructor.declaringClass.readableName()),
3681 						new String(varargsElementType.readableName())
3682 				},
3683 				new String[] {
3684 						new String(shownConstructor.declaringClass.sourceName()),
3685 						typesAsString(shownConstructor, true),
3686 						new String(shownConstructor.declaringClass.shortReadableName()),
3687 						new String(varargsElementType.shortReadableName())
3688 				},
3689 				sourceStart,
3690 				sourceEnd);
3691 			return;
3692 		case ProblemReasons.ParameterizedMethodExpectedTypeProblem:
3693 			// FIXME(stephan): construct suitable message (https://bugs.eclipse.org/404675)
3694 			problemConstructor = (ProblemMethodBinding) targetConstructor;
3695 			shownConstructor = problemConstructor.closestMatch;
3696 			this.handle(
3697 				IProblem.TypeMismatch,
3698 				new String[] {
3699 				        String.valueOf(shownConstructor.returnType.readableName()),
3700 				        (problemConstructor.returnType != null ? String.valueOf(problemConstructor.returnType.readableName()) : "<unknown>")}, //$NON-NLS-1$
3701 				new String[] {
3702 				        String.valueOf(shownConstructor.returnType.shortReadableName()),
3703 				        (problemConstructor.returnType != null ? String.valueOf(problemConstructor.returnType.shortReadableName()) : "<unknown>")}, //$NON-NLS-1$
3704 				statement.sourceStart,
3705 				statement.sourceEnd);
3706 			return;
3707 		case ProblemReasons.ContradictoryNullAnnotations:
3708 			problemConstructor = (ProblemMethodBinding) targetConstructor;
3709 			contradictoryNullAnnotationsInferred(problemConstructor.closestMatch, statement);
3710 			return;
3711 		case ProblemReasons.NoError : // 0
3712 		default :
3713 			needImplementation(statement); // want to fail to see why we were here...
3714 			break;
3715 	}
3716 
3717 	this.handle(
3718 		id,
3719 		new String[] {new String(targetConstructor.declaringClass.readableName()), typesAsString(shownConstructor, false)},
3720 		new String[] {new String(targetConstructor.declaringClass.shortReadableName()), typesAsString(shownConstructor, true)},
3721 		sourceStart,
3722 		sourceEnd);
3723 }
invalidContinue(ASTNode location)3724 public void invalidContinue(ASTNode location) {
3725 	this.handle(
3726 		IProblem.InvalidContinue,
3727 		NoArgument,
3728 		NoArgument,
3729 		location.sourceStart,
3730 		location.sourceEnd);
3731 }
invalidEnclosingType(Expression expression, TypeBinding type, ReferenceBinding enclosingType)3732 public void invalidEnclosingType(Expression expression, TypeBinding type, ReferenceBinding enclosingType) {
3733 
3734 	if (enclosingType.isAnonymousType()) enclosingType = enclosingType.superclass();
3735 	if (enclosingType.sourceName != null && enclosingType.sourceName.length == 0) return;
3736 
3737 	int flag = IProblem.UndefinedType; // default
3738 	switch (type.problemId()) {
3739 		case ProblemReasons.NotFound : // 1
3740 			flag = IProblem.UndefinedType;
3741 			break;
3742 		case ProblemReasons.NotVisible : // 2
3743 			flag = IProblem.NotVisibleType;
3744 			break;
3745 		case ProblemReasons.Ambiguous : // 3
3746 			flag = IProblem.AmbiguousType;
3747 			break;
3748 		case ProblemReasons.InternalNameProvided :
3749 			flag = IProblem.InternalTypeNameProvided;
3750 			break;
3751 		case ProblemReasons.NoError : // 0
3752 		default :
3753 			needImplementation(expression); // want to fail to see why we were here...
3754 			break;
3755 	}
3756 
3757 	this.handle(
3758 		flag,
3759 		new String[] {new String(enclosingType.readableName()) + "." + new String(type.readableName())}, //$NON-NLS-1$
3760 		new String[] {new String(enclosingType.shortReadableName()) + "." + new String(type.shortReadableName())}, //$NON-NLS-1$
3761 		expression.sourceStart,
3762 		expression.sourceEnd);
3763 }
invalidExplicitConstructorCall(ASTNode location)3764 public void invalidExplicitConstructorCall(ASTNode location) {
3765 
3766 	this.handle(
3767 		IProblem.InvalidExplicitConstructorCall,
3768 		NoArgument,
3769 		NoArgument,
3770 		location.sourceStart,
3771 		location.sourceEnd);
3772 }
invalidExpressionAsStatement(Expression expression)3773 public void invalidExpressionAsStatement(Expression expression){
3774 	this.handle(
3775 		IProblem.InvalidExpressionAsStatement,
3776 		NoArgument,
3777 		NoArgument,
3778 		expression.sourceStart,
3779 		expression.sourceEnd);
3780 }
invalidField(FieldReference fieldRef, TypeBinding searchedType)3781 public void invalidField(FieldReference fieldRef, TypeBinding searchedType) {
3782 	if(isRecoveredName(fieldRef.token)) return;
3783 
3784 	int id = IProblem.UndefinedField;
3785 	FieldBinding field = fieldRef.binding;
3786 	switch (field.problemId()) {
3787 		case ProblemReasons.NotFound :
3788 			if ((searchedType.tagBits & TagBits.HasMissingType) != 0) {
3789 				this.handle(
3790 						IProblem.UndefinedType,
3791 						new String[] {new String(searchedType.leafComponentType().readableName())},
3792 						new String[] {new String(searchedType.leafComponentType().shortReadableName())},
3793 						fieldRef.receiver.sourceStart,
3794 						fieldRef.receiver.sourceEnd);
3795 					return;
3796 			}
3797 			id = IProblem.UndefinedField;
3798 /* also need to check that the searchedType is the receiver type
3799 			if (searchedType.isHierarchyInconsistent())
3800 				severity = SecondaryError;
3801 */
3802 			break;
3803 		case ProblemReasons.NotVisible :
3804 			this.handle(
3805 				IProblem.NotVisibleField,
3806 				new String[] {new String(fieldRef.token), new String(field.declaringClass.readableName())},
3807 				new String[] {new String(fieldRef.token), new String(field.declaringClass.shortReadableName())},
3808 				nodeSourceStart(field, fieldRef),
3809 				nodeSourceEnd(field, fieldRef));
3810 			return;
3811 		case ProblemReasons.Ambiguous :
3812 			id = IProblem.AmbiguousField;
3813 			break;
3814 		case ProblemReasons.NonStaticReferenceInStaticContext :
3815 			id = IProblem.NonStaticFieldFromStaticInvocation;
3816 			break;
3817 		case ProblemReasons.NonStaticReferenceInConstructorInvocation :
3818 			id = IProblem.InstanceFieldDuringConstructorInvocation;
3819 			break;
3820 		case ProblemReasons.InheritedNameHidesEnclosingName :
3821 			id = IProblem.InheritedFieldHidesEnclosingName;
3822 			break;
3823 		case ProblemReasons.ReceiverTypeNotVisible :
3824 			this.handle(
3825 				IProblem.NotVisibleType, // cannot occur in javadoc comments
3826 				new String[] {new String(searchedType.leafComponentType().readableName())},
3827 				new String[] {new String(searchedType.leafComponentType().shortReadableName())},
3828 				fieldRef.receiver.sourceStart,
3829 				fieldRef.receiver.sourceEnd);
3830 			return;
3831 
3832 		case ProblemReasons.NoError : // 0
3833 		default :
3834 			needImplementation(fieldRef); // want to fail to see why we were here...
3835 			break;
3836 	}
3837 
3838 	String[] arguments = new String[] {new String(field.readableName())};
3839 	this.handle(
3840 		id,
3841 		arguments,
3842 		arguments,
3843 		nodeSourceStart(field, fieldRef),
3844 		nodeSourceEnd(field, fieldRef));
3845 }
invalidField(NameReference nameRef, FieldBinding field)3846 public void invalidField(NameReference nameRef, FieldBinding field) {
3847 	if (nameRef instanceof QualifiedNameReference) {
3848 		QualifiedNameReference ref = (QualifiedNameReference) nameRef;
3849 		if (isRecoveredName(ref.tokens)) return;
3850 	} else {
3851 		SingleNameReference ref = (SingleNameReference) nameRef;
3852 		if (isRecoveredName(ref.token)) return;
3853 	}
3854 	int id = IProblem.UndefinedField;
3855 	switch (field.problemId()) {
3856 		case ProblemReasons.NotFound :
3857 			TypeBinding declaringClass = field.declaringClass;
3858 			if (declaringClass != null && (declaringClass.tagBits & TagBits.HasMissingType) != 0) {
3859 				this.handle(
3860 						IProblem.UndefinedType,
3861 						new String[] {new String(field.declaringClass.readableName())},
3862 						new String[] {new String(field.declaringClass.shortReadableName())},
3863 						nameRef.sourceStart,
3864 						nameRef.sourceEnd);
3865 					return;
3866 			}
3867 			String[] arguments = new String[] {new String(field.readableName())};
3868 			this.handle(
3869 					id,
3870 					arguments,
3871 					arguments,
3872 					nodeSourceStart(field, nameRef),
3873 					nodeSourceEnd(field, nameRef));
3874 			return;
3875 		case ProblemReasons.NotVisible :
3876 			char[] name = field.readableName();
3877 			name = CharOperation.lastSegment(name, '.');
3878 			this.handle(
3879 				IProblem.NotVisibleField,
3880 				new String[] {new String(name), new String(field.declaringClass.readableName())},
3881 				new String[] {new String(name), new String(field.declaringClass.shortReadableName())},
3882 				nodeSourceStart(field, nameRef),
3883 				nodeSourceEnd(field, nameRef));
3884 			return;
3885 		case ProblemReasons.Ambiguous :
3886 			id = IProblem.AmbiguousField;
3887 			break;
3888 		case ProblemReasons.NonStaticReferenceInStaticContext :
3889 			id = IProblem.NonStaticFieldFromStaticInvocation;
3890 			break;
3891 		case ProblemReasons.NonStaticReferenceInConstructorInvocation :
3892 			id = IProblem.InstanceFieldDuringConstructorInvocation;
3893 			break;
3894 		case ProblemReasons.InheritedNameHidesEnclosingName :
3895 			id = IProblem.InheritedFieldHidesEnclosingName;
3896 			break;
3897 		case ProblemReasons.ReceiverTypeNotVisible :
3898 			this.handle(
3899 				IProblem.NotVisibleType,
3900 				new String[] {new String(field.declaringClass.readableName())},
3901 				new String[] {new String(field.declaringClass.shortReadableName())},
3902 				nameRef.sourceStart,
3903 				nameRef.sourceEnd);
3904 			return;
3905 		case ProblemReasons.NoError : // 0
3906 		default :
3907 			needImplementation(nameRef); // want to fail to see why we were here...
3908 			break;
3909 	}
3910 	String[] arguments = new String[] {new String(field.readableName())};
3911 	this.handle(
3912 		id,
3913 		arguments,
3914 		arguments,
3915 		nameRef.sourceStart,
3916 		nameRef.sourceEnd);
3917 }
invalidField(QualifiedNameReference nameRef, FieldBinding field, int index, TypeBinding searchedType)3918 public void invalidField(QualifiedNameReference nameRef, FieldBinding field, int index, TypeBinding searchedType) {
3919 	//the resolution of the index-th field of qname failed
3920 	//qname.otherBindings[index] is the binding that has produced the error
3921 
3922 	//The different targetted errors should be :
3923 	//UndefinedField
3924 	//NotVisibleField
3925 	//AmbiguousField
3926 
3927 	if (isRecoveredName(nameRef.tokens)) return;
3928 
3929 	if (searchedType.isBaseType()) {
3930 		this.handle(
3931 			IProblem.NoFieldOnBaseType,
3932 			new String[] {
3933 				new String(searchedType.readableName()),
3934 				CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index)),
3935 				new String(nameRef.tokens[index])},
3936 			new String[] {
3937 				new String(searchedType.sourceName()),
3938 				CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index)),
3939 				new String(nameRef.tokens[index])},
3940 			nameRef.sourceStart,
3941 			(int) nameRef.sourcePositions[index]);
3942 		return;
3943 	}
3944 
3945 	int id = IProblem.UndefinedField;
3946 	switch (field.problemId()) {
3947 		case ProblemReasons.NotFound :
3948 			if ((searchedType.tagBits & TagBits.HasMissingType) != 0) {
3949 				this.handle(
3950 						IProblem.UndefinedType,
3951 						new String[] {new String(searchedType.leafComponentType().readableName())},
3952 						new String[] {new String(searchedType.leafComponentType().shortReadableName())},
3953 						nameRef.sourceStart,
3954 						(int) nameRef.sourcePositions[index-1]);
3955 					return;
3956 			}
3957 			String fieldName = new String(nameRef.tokens[index]);
3958 			String[] arguments = new String[] {fieldName };
3959 			this.handle(
3960 					id,
3961 					arguments,
3962 					arguments,
3963 					nodeSourceStart(field, nameRef),
3964 					nodeSourceEnd(field, nameRef));
3965 			return;
3966 		case ProblemReasons.NotVisible :
3967 			fieldName = new String(nameRef.tokens[index]);
3968 			this.handle(
3969 				IProblem.NotVisibleField,
3970 				new String[] {fieldName, new String(field.declaringClass.readableName())},
3971 				new String[] {fieldName, new String(field.declaringClass.shortReadableName())},
3972 				nodeSourceStart(field, nameRef),
3973 				nodeSourceEnd(field, nameRef));
3974 			return;
3975 		case ProblemReasons.Ambiguous :
3976 			id = IProblem.AmbiguousField;
3977 			break;
3978 		case ProblemReasons.NonStaticReferenceInStaticContext :
3979 			id = IProblem.NonStaticFieldFromStaticInvocation;
3980 			break;
3981 		case ProblemReasons.NonStaticReferenceInConstructorInvocation :
3982 			id = IProblem.InstanceFieldDuringConstructorInvocation;
3983 			break;
3984 		case ProblemReasons.InheritedNameHidesEnclosingName :
3985 			id = IProblem.InheritedFieldHidesEnclosingName;
3986 			break;
3987 		case ProblemReasons.ReceiverTypeNotVisible :
3988 			this.handle(
3989 				IProblem.NotVisibleType,
3990 				new String[] {new String(searchedType.leafComponentType().readableName())},
3991 				new String[] {new String(searchedType.leafComponentType().shortReadableName())},
3992 				nameRef.sourceStart,
3993 				(int) nameRef.sourcePositions[index-1]);
3994 			return;
3995 		case ProblemReasons.NoError : // 0
3996 		default :
3997 			needImplementation(nameRef); // want to fail to see why we were here...
3998 			break;
3999 	}
4000 	String[] arguments = new String[] {CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index + 1))};
4001 	this.handle(
4002 		id,
4003 		arguments,
4004 		arguments,
4005 		nameRef.sourceStart,
4006 		(int) nameRef.sourcePositions[index]);
4007 }
4008 
invalidFileNameForPackageAnnotations(Annotation annotation)4009 public void invalidFileNameForPackageAnnotations(Annotation annotation) {
4010 	this.handle(
4011 			IProblem.InvalidFileNameForPackageAnnotations,
4012 			NoArgument,
4013 			NoArgument,
4014 			annotation.sourceStart,
4015 			annotation.sourceEnd);
4016 }
4017 
invalidMethod(MessageSend messageSend, MethodBinding method)4018 public void invalidMethod(MessageSend messageSend, MethodBinding method) {
4019 	if (isRecoveredName(messageSend.selector)) return;
4020 
4021 	int id = IProblem.UndefinedMethod; //default...
4022     MethodBinding shownMethod = method;
4023 	switch (method.problemId()) {
4024 		case ProblemReasons.NoSuchMethodOnArray :
4025 			return; // secondary error.
4026 		case ProblemReasons.NotFound :
4027 			if ((method.declaringClass.tagBits & TagBits.HasMissingType) != 0) {
4028 				this.handle(
4029 						IProblem.UndefinedType,
4030 						new String[] {new String(method.declaringClass.readableName())},
4031 						new String[] {new String(method.declaringClass.shortReadableName())},
4032 						messageSend.receiver.sourceStart,
4033 						messageSend.receiver.sourceEnd);
4034 					return;
4035 			}
4036 			id = IProblem.UndefinedMethod;
4037 			ProblemMethodBinding problemMethod = (ProblemMethodBinding) method;
4038 			if (problemMethod.closestMatch != null) {
4039 			    	shownMethod = problemMethod.closestMatch;
4040 			    	if ((shownMethod.tagBits & TagBits.HasMissingType) != 0) {
4041 						missingTypeInMethod(messageSend, shownMethod);
4042 						return;
4043 			    	}
4044 					String closestParameterTypeNames = typesAsString(shownMethod, false);
4045 					String parameterTypeNames = typesAsString(problemMethod.parameters, false);
4046 					String closestParameterTypeShortNames = typesAsString(shownMethod, true);
4047 					String parameterTypeShortNames = typesAsString(problemMethod.parameters, true);
4048 					if (closestParameterTypeNames.equals(parameterTypeNames)) {
4049 						// include null annotations, maybe they show the difference:
4050 						closestParameterTypeNames = typesAsString(shownMethod, false, true);
4051 						parameterTypeNames = typesAsString(problemMethod.parameters, false, true);
4052 						closestParameterTypeShortNames = typesAsString(shownMethod, true, true);
4053 						parameterTypeShortNames = typesAsString(problemMethod.parameters, true, true);
4054 					}
4055 					if (closestParameterTypeShortNames.equals(parameterTypeShortNames)) {
4056 						closestParameterTypeShortNames = closestParameterTypeNames;
4057 						parameterTypeShortNames = parameterTypeNames;
4058 					}
4059 					this.handle(
4060 						IProblem.ParameterMismatch,
4061 						new String[] {
4062 							new String(shownMethod.declaringClass.readableName()),
4063 							new String(shownMethod.selector),
4064 							closestParameterTypeNames,
4065 							parameterTypeNames
4066 						},
4067 						new String[] {
4068 							new String(shownMethod.declaringClass.shortReadableName()),
4069 							new String(shownMethod.selector),
4070 							closestParameterTypeShortNames,
4071 							parameterTypeShortNames
4072 						},
4073 						(int) (messageSend.nameSourcePosition >>> 32),
4074 						(int) messageSend.nameSourcePosition);
4075 					return;
4076 			}
4077 			break;
4078 		case ProblemReasons.NotVisible :
4079 			id = IProblem.NotVisibleMethod;
4080 			problemMethod = (ProblemMethodBinding) method;
4081 			if (problemMethod.closestMatch != null) {
4082 			    shownMethod = problemMethod.closestMatch.original();
4083 		    }
4084 			break;
4085 		case ProblemReasons.Ambiguous :
4086 			id = IProblem.AmbiguousMethod;
4087 			break;
4088 		case ProblemReasons.InheritedNameHidesEnclosingName :
4089 			id = IProblem.InheritedMethodHidesEnclosingName;
4090 			break;
4091 		case ProblemReasons.NonStaticReferenceInConstructorInvocation :
4092 			id = IProblem.InstanceMethodDuringConstructorInvocation;
4093 			break;
4094 		case ProblemReasons.NonStaticReferenceInStaticContext :
4095 			id = IProblem.StaticMethodRequested;
4096 			break;
4097 		case ProblemReasons.NonStaticOrAlienTypeReceiver:
4098 			this.handle(
4099 					IProblem.NonStaticOrAlienTypeReceiver,
4100 					new String[] {
4101 							new String(method.declaringClass.readableName()),
4102 					        new String(method.selector),
4103 					},
4104 					new String[] {
4105 							new String(method.declaringClass.shortReadableName()),
4106 					        new String(method.selector),
4107 					},
4108 					(int) (messageSend.nameSourcePosition >>> 32),
4109 					(int) messageSend.nameSourcePosition);
4110 			return;
4111 		case ProblemReasons.ReceiverTypeNotVisible :
4112 			this.handle(
4113 				IProblem.NotVisibleType,	// cannot occur in javadoc comments
4114 				new String[] {new String(method.declaringClass.readableName())},
4115 				new String[] {new String(method.declaringClass.shortReadableName())},
4116 				messageSend.receiver.sourceStart,
4117 				messageSend.receiver.sourceEnd);
4118 			return;
4119 		case ProblemReasons.ParameterBoundMismatch :
4120 			problemMethod = (ProblemMethodBinding) method;
4121 			ParameterizedGenericMethodBinding substitutedMethod = (ParameterizedGenericMethodBinding) problemMethod.closestMatch;
4122 			shownMethod = substitutedMethod.original();
4123 			int augmentedLength = problemMethod.parameters.length;
4124 			TypeBinding inferredTypeArgument = problemMethod.parameters[augmentedLength-2];
4125 			TypeVariableBinding typeParameter = (TypeVariableBinding) problemMethod.parameters[augmentedLength-1];
4126 			TypeBinding[] invocationArguments = new TypeBinding[augmentedLength-2]; // remove extra info from the end
4127 			System.arraycopy(problemMethod.parameters, 0, invocationArguments, 0, augmentedLength-2);
4128 			this.handle(
4129 				IProblem.GenericMethodTypeArgumentMismatch,
4130 				new String[] {
4131 				        new String(shownMethod.selector),
4132 				        typesAsString(shownMethod, false),
4133 				        new String(shownMethod.declaringClass.readableName()),
4134 				        typesAsString(invocationArguments, false),
4135 				        new String(inferredTypeArgument.readableName()),
4136 				        new String(typeParameter.sourceName()),
4137 				        parameterBoundAsString(typeParameter, false) },
4138 				new String[] {
4139 				        new String(shownMethod.selector),
4140 				        typesAsString(shownMethod, true),
4141 				        new String(shownMethod.declaringClass.shortReadableName()),
4142 				        typesAsString(invocationArguments, true),
4143 				        new String(inferredTypeArgument.shortReadableName()),
4144 				        new String(typeParameter.sourceName()),
4145 				        parameterBoundAsString(typeParameter, true) },
4146 				(int) (messageSend.nameSourcePosition >>> 32),
4147 				(int) messageSend.nameSourcePosition);
4148 			return;
4149 		case ProblemReasons.TypeParameterArityMismatch :
4150 			problemMethod = (ProblemMethodBinding) method;
4151 			shownMethod = problemMethod.closestMatch;
4152 			if (shownMethod.typeVariables == Binding.NO_TYPE_VARIABLES) {
4153 				this.handle(
4154 					IProblem.NonGenericMethod ,
4155 					new String[] {
4156 					        new String(shownMethod.selector),
4157 					        typesAsString(shownMethod, false),
4158 					        new String(shownMethod.declaringClass.readableName()),
4159 					        typesAsString(method, false) },
4160 					new String[] {
4161 					        new String(shownMethod.selector),
4162 					        typesAsString(shownMethod, true),
4163 					        new String(shownMethod.declaringClass.shortReadableName()),
4164 					        typesAsString(method, true) },
4165 					(int) (messageSend.nameSourcePosition >>> 32),
4166 					(int) messageSend.nameSourcePosition);
4167 			} else {
4168 				this.handle(
4169 					IProblem.IncorrectArityForParameterizedMethod  ,
4170 					new String[] {
4171 					        new String(shownMethod.selector),
4172 					        typesAsString(shownMethod, false),
4173 					        new String(shownMethod.declaringClass.readableName()),
4174 							typesAsString(shownMethod.typeVariables, false),
4175 					        typesAsString(method, false) },
4176 					new String[] {
4177 					        new String(shownMethod.selector),
4178 					        typesAsString(shownMethod, true),
4179 					        new String(shownMethod.declaringClass.shortReadableName()),
4180 							typesAsString(shownMethod.typeVariables, true),
4181 					        typesAsString(method, true) },
4182 					(int) (messageSend.nameSourcePosition >>> 32),
4183 					(int) messageSend.nameSourcePosition);
4184 			}
4185 			return;
4186 		case ProblemReasons.ParameterizedMethodTypeMismatch :
4187 			problemMethod = (ProblemMethodBinding) method;
4188 			shownMethod = problemMethod.closestMatch;
4189 			this.handle(
4190 				IProblem.ParameterizedMethodArgumentTypeMismatch,
4191 				new String[] {
4192 				        new String(shownMethod.selector),
4193 				        typesAsString(shownMethod, false),
4194 				        new String(shownMethod.declaringClass.readableName()),
4195 						typesAsString(((ParameterizedGenericMethodBinding)shownMethod).typeArguments, false),
4196 				        typesAsString(method, false) },
4197 				new String[] {
4198 				        new String(shownMethod.selector),
4199 				        typesAsString(shownMethod, true),
4200 				        new String(shownMethod.declaringClass.shortReadableName()),
4201 						typesAsString(((ParameterizedGenericMethodBinding)shownMethod).typeArguments, true),
4202 				        typesAsString(method, true) },
4203 				(int) (messageSend.nameSourcePosition >>> 32),
4204 				(int) messageSend.nameSourcePosition);
4205 			return;
4206 		case ProblemReasons.TypeArgumentsForRawGenericMethod :
4207 			problemMethod = (ProblemMethodBinding) method;
4208 			shownMethod = problemMethod.closestMatch;
4209 			this.handle(
4210 				IProblem.TypeArgumentsForRawGenericMethod ,
4211 				new String[] {
4212 				        new String(shownMethod.selector),
4213 				        typesAsString(shownMethod, false),
4214 				        new String(shownMethod.declaringClass.readableName()),
4215 				        typesAsString(method, false) },
4216 				new String[] {
4217 				        new String(shownMethod.selector),
4218 				        typesAsString(shownMethod, true),
4219 				        new String(shownMethod.declaringClass.shortReadableName()),
4220 				        typesAsString(method, true) },
4221 				(int) (messageSend.nameSourcePosition >>> 32),
4222 				(int) messageSend.nameSourcePosition);
4223 			return;
4224 		case ProblemReasons.ParameterizedMethodExpectedTypeProblem:
4225 			// FIXME(stephan): construct suitable message (https://bugs.eclipse.org/404675)
4226 			problemMethod = (ProblemMethodBinding) method;
4227 			InferenceContext18 inferenceContext = problemMethod.inferenceContext;
4228 			if (inferenceContext != null && inferenceContext.outerContext != null) {
4229 				// problem relates to a nested inference context, let the outer handle it:
4230 				inferenceContext.outerContext.addProblemMethod(problemMethod);
4231 				return;
4232 			}
4233 			shownMethod = problemMethod.closestMatch;
4234 			this.handle(
4235 				IProblem.TypeMismatch,
4236 				new String[] {
4237 				        String.valueOf(shownMethod.returnType.readableName()),
4238 				        (problemMethod.returnType != null ? String.valueOf(problemMethod.returnType.readableName()) : "<unknown>")}, //$NON-NLS-1$
4239 				new String[] {
4240 				        String.valueOf(shownMethod.returnType.shortReadableName()),
4241 				        (problemMethod.returnType != null ? String.valueOf(problemMethod.returnType.shortReadableName()) : "<unknown>")}, //$NON-NLS-1$
4242 				messageSend.sourceStart,
4243 				messageSend.sourceEnd);
4244 			return;
4245 		case ProblemReasons.VarargsElementTypeNotVisible: // https://bugs.eclipse.org/bugs/show_bug.cgi?id=346042
4246 			problemMethod = (ProblemMethodBinding) method;
4247 			if (problemMethod.closestMatch != null) {
4248 			    shownMethod = problemMethod.closestMatch.original();
4249 		    }
4250 			TypeBinding varargsElementType = shownMethod.parameters[shownMethod.parameters.length - 1].leafComponentType();
4251 			this.handle(
4252 				IProblem.VarargsElementTypeNotVisible,
4253 				new String[] {
4254 				        new String(shownMethod.selector),
4255 				        typesAsString(shownMethod, false),
4256 				        new String(shownMethod.declaringClass.readableName()),
4257 				        new String(varargsElementType.readableName())
4258 				},
4259 				new String[] {
4260 				        new String(shownMethod.selector),
4261 				        typesAsString(shownMethod, true),
4262 				        new String(shownMethod.declaringClass.shortReadableName()),
4263 				        new String(varargsElementType.shortReadableName())
4264 				},
4265 				(int) (messageSend.nameSourcePosition >>> 32),
4266 				(int) messageSend.nameSourcePosition);
4267 			return;
4268 		case ProblemReasons.ApplicableMethodOverriddenByInapplicable:
4269 			problemMethod = (ProblemMethodBinding) method;
4270 			if (problemMethod.closestMatch != null) {
4271 			    shownMethod = problemMethod.closestMatch.original();
4272 		    }
4273 			this.handle(
4274 				IProblem.ApplicableMethodOverriddenByInapplicable,
4275 				new String[] {
4276 				        new String(shownMethod.selector),
4277 				        typesAsString(shownMethod, false),
4278 				        new String(shownMethod.declaringClass.readableName()),
4279 				},
4280 				new String[] {
4281 				        new String(shownMethod.selector),
4282 				        typesAsString(shownMethod, true),
4283 				        new String(shownMethod.declaringClass.shortReadableName()),
4284 				},
4285 				(int) (messageSend.nameSourcePosition >>> 32),
4286 				(int) messageSend.nameSourcePosition);
4287 			return;
4288 		case ProblemReasons.ContradictoryNullAnnotations:
4289 			problemMethod = (ProblemMethodBinding) method;
4290 			contradictoryNullAnnotationsInferred(problemMethod.closestMatch, (ASTNode)messageSend);
4291 			return;
4292 		case ProblemReasons.NoError : // 0
4293 		default :
4294 			needImplementation(messageSend); // want to fail to see why we were here...
4295 			break;
4296 	}
4297 	this.handle(
4298 		id,
4299 		new String[] {
4300 			new String(method.declaringClass.readableName()),
4301 			new String(shownMethod.selector), typesAsString(shownMethod, false)},
4302 		new String[] {
4303 			new String(method.declaringClass.shortReadableName()),
4304 			new String(shownMethod.selector), typesAsString(shownMethod, true)},
4305 		(int) (messageSend.nameSourcePosition >>> 32),
4306 		(int) messageSend.nameSourcePosition);
4307 }
invalidNullToSynchronize(Expression expression)4308 public void invalidNullToSynchronize(Expression expression) {
4309 	this.handle(
4310 		IProblem.InvalidNullToSynchronized,
4311 		NoArgument,
4312 		NoArgument,
4313 		expression.sourceStart,
4314 		expression.sourceEnd);
4315 }
invalidOperator(BinaryExpression expression, TypeBinding leftType, TypeBinding rightType)4316 public void invalidOperator(BinaryExpression expression, TypeBinding leftType, TypeBinding rightType) {
4317 	String leftName = new String(leftType.readableName());
4318 	String rightName = new String(rightType.readableName());
4319 	String leftShortName = new String(leftType.shortReadableName());
4320 	String rightShortName = new String(rightType.shortReadableName());
4321 	if (leftShortName.equals(rightShortName)){
4322 		leftShortName = leftName;
4323 		rightShortName = rightName;
4324 	}
4325 	this.handle(
4326 		IProblem.InvalidOperator,
4327 		new String[] {
4328 			expression.operatorToString(),
4329 			leftName + ", " + rightName}, //$NON-NLS-1$
4330 		new String[] {
4331 			expression.operatorToString(),
4332 			leftShortName + ", " + rightShortName}, //$NON-NLS-1$
4333 		expression.sourceStart,
4334 		expression.sourceEnd);
4335 }
invalidOperator(CompoundAssignment assign, TypeBinding leftType, TypeBinding rightType)4336 public void invalidOperator(CompoundAssignment assign, TypeBinding leftType, TypeBinding rightType) {
4337 	String leftName = new String(leftType.readableName());
4338 	String rightName = new String(rightType.readableName());
4339 	String leftShortName = new String(leftType.shortReadableName());
4340 	String rightShortName = new String(rightType.shortReadableName());
4341 	if (leftShortName.equals(rightShortName)){
4342 		leftShortName = leftName;
4343 		rightShortName = rightName;
4344 	}
4345 	this.handle(
4346 		IProblem.InvalidOperator,
4347 		new String[] {
4348 			assign.operatorToString(),
4349 			leftName + ", " + rightName}, //$NON-NLS-1$
4350 		new String[] {
4351 			assign.operatorToString(),
4352 			leftShortName + ", " + rightShortName}, //$NON-NLS-1$
4353 		assign.sourceStart,
4354 		assign.sourceEnd);
4355 }
invalidOperator(UnaryExpression expression, TypeBinding type)4356 public void invalidOperator(UnaryExpression expression, TypeBinding type) {
4357 	this.handle(
4358 		IProblem.InvalidOperator,
4359 		new String[] {expression.operatorToString(), new String(type.readableName())},
4360 		new String[] {expression.operatorToString(), new String(type.shortReadableName())},
4361 		expression.sourceStart,
4362 		expression.sourceEnd);
4363 }
invalidParameterizedExceptionType(TypeBinding exceptionType, ASTNode location)4364 public void invalidParameterizedExceptionType(TypeBinding exceptionType, ASTNode location) {
4365 	this.handle(
4366 		IProblem.InvalidParameterizedExceptionType,
4367 		new String[] {new String(exceptionType.readableName())},
4368 		new String[] {new String(exceptionType.shortReadableName())},
4369 		location.sourceStart,
4370 		location.sourceEnd);
4371 }
invalidParenthesizedExpression(ASTNode reference)4372 public void invalidParenthesizedExpression(ASTNode reference) {
4373 	this.handle(
4374 		IProblem.InvalidParenthesizedExpression,
4375 		NoArgument,
4376 		NoArgument,
4377 		reference.sourceStart,
4378 		reference.sourceEnd);
4379 }
invalidType(ASTNode location, TypeBinding type)4380 public void invalidType(ASTNode location, TypeBinding type) {
4381 	if (type instanceof ReferenceBinding) {
4382 		if (isRecoveredName(((ReferenceBinding)type).compoundName)) return;
4383 	}
4384 	else if (type instanceof ArrayBinding) {
4385 		TypeBinding leafType = ((ArrayBinding)type).leafComponentType;
4386 		if (leafType instanceof ReferenceBinding) {
4387 			if (isRecoveredName(((ReferenceBinding)leafType).compoundName)) return;
4388 		}
4389 	}
4390 
4391 	if (type.isParameterizedType()) {
4392 		List missingTypes = type.collectMissingTypes(null);
4393 		if (missingTypes != null) {
4394 			ReferenceContext savedContext = this.referenceContext;
4395 			for (Iterator iterator = missingTypes.iterator(); iterator.hasNext(); ) {
4396 				try {
4397 					invalidType(location, (TypeBinding) iterator.next());
4398 				} finally {
4399 					this.referenceContext = savedContext;
4400 				}
4401 			}
4402 			return;
4403 		}
4404 	}
4405 	int id = IProblem.UndefinedType; // default
4406 	switch (type.problemId()) {
4407 		case ProblemReasons.NotFound :
4408 			id = IProblem.UndefinedType;
4409 			break;
4410 		case ProblemReasons.NotVisible :
4411 			id = IProblem.NotVisibleType;
4412 			break;
4413 		case ProblemReasons.Ambiguous :
4414 			id = IProblem.AmbiguousType;
4415 			break;
4416 		case ProblemReasons.InternalNameProvided :
4417 			id = IProblem.InternalTypeNameProvided;
4418 			break;
4419 		case ProblemReasons.InheritedNameHidesEnclosingName :
4420 			id = IProblem.InheritedTypeHidesEnclosingName;
4421 			break;
4422 		case ProblemReasons.NonStaticReferenceInStaticContext :
4423 			id = IProblem.NonStaticTypeFromStaticInvocation;
4424 			break;
4425 		case ProblemReasons.IllegalSuperTypeVariable :
4426 			id = IProblem.IllegalTypeVariableSuperReference;
4427 			break;
4428 		case ProblemReasons.NoError : // 0
4429 		default :
4430 			needImplementation(location); // want to fail to see why we were here...
4431 			break;
4432 	}
4433 
4434 	int end = location.sourceEnd;
4435 	if (location instanceof QualifiedNameReference) {
4436 		QualifiedNameReference ref = (QualifiedNameReference) location;
4437 		if (isRecoveredName(ref.tokens)) return;
4438 		if (ref.indexOfFirstFieldBinding >= 1)
4439 			end = (int) ref.sourcePositions[ref.indexOfFirstFieldBinding - 1];
4440 	} else if (location instanceof ParameterizedQualifiedTypeReference) {
4441 		// must be before instanceof ArrayQualifiedTypeReference
4442 		ParameterizedQualifiedTypeReference ref = (ParameterizedQualifiedTypeReference) location;
4443 		if (isRecoveredName(ref.tokens)) return;
4444 		if (type instanceof ReferenceBinding) {
4445 			char[][] name = ((ReferenceBinding) type).compoundName;
4446 			end = (int) ref.sourcePositions[name.length - 1];
4447 		}
4448 	} else if (location instanceof ArrayQualifiedTypeReference) {
4449 		ArrayQualifiedTypeReference arrayQualifiedTypeReference = (ArrayQualifiedTypeReference) location;
4450 		if (isRecoveredName(arrayQualifiedTypeReference.tokens)) return;
4451 		TypeBinding leafType = type.leafComponentType();
4452 		if (leafType instanceof ReferenceBinding) {
4453 			char[][] name = ((ReferenceBinding) leafType).compoundName; // problem type will tell how much got resolved
4454 			end = (int) arrayQualifiedTypeReference.sourcePositions[name.length-1];
4455 		} else {
4456 			long[] positions = arrayQualifiedTypeReference.sourcePositions;
4457 			end = (int) positions[positions.length - 1];
4458 		}
4459 	} else if (location instanceof QualifiedTypeReference) {
4460 		QualifiedTypeReference ref = (QualifiedTypeReference) location;
4461 		if (isRecoveredName(ref.tokens)) return;
4462 		if (type instanceof ReferenceBinding) {
4463 			char[][] name = ((ReferenceBinding) type).compoundName;
4464 			if (name.length <= ref.sourcePositions.length)
4465 				end = (int) ref.sourcePositions[name.length - 1];
4466 		}
4467 	} else if (location instanceof ImportReference) {
4468 		ImportReference ref = (ImportReference) location;
4469 		if (isRecoveredName(ref.tokens)) return;
4470 		if (type instanceof ReferenceBinding) {
4471 			char[][] name = ((ReferenceBinding) type).compoundName;
4472 			end = (int) ref.sourcePositions[name.length - 1];
4473 		}
4474 	} else if (location instanceof ArrayTypeReference) {
4475 		ArrayTypeReference arrayTypeReference = (ArrayTypeReference) location;
4476 		if (isRecoveredName(arrayTypeReference.token)) return;
4477 		end = arrayTypeReference.originalSourceEnd;
4478 	}
4479 
4480 	int start = location.sourceStart;
4481 	if (location instanceof org.eclipse.jdt.internal.compiler.ast.SingleTypeReference) {
4482 		org.eclipse.jdt.internal.compiler.ast.SingleTypeReference ref =
4483 				(org.eclipse.jdt.internal.compiler.ast.SingleTypeReference) location;
4484 		if (ref.annotations != null)
4485 			start = end - ref.token.length + 1;
4486 	} else if (location instanceof QualifiedTypeReference) {
4487 		QualifiedTypeReference ref = (QualifiedTypeReference) location;
4488 		if (ref.annotations != null)
4489 			start = (int) (ref.sourcePositions[0] & 0x00000000FFFFFFFFL ) - ref.tokens[0].length + 1;
4490 	}
4491 
4492 	this.handle(
4493 		id,
4494 		new String[] {new String(type.leafComponentType().readableName()) },
4495 		new String[] {new String(type.leafComponentType().shortReadableName())},
4496 		start,
4497 		end);
4498 }
invalidTypeForCollection(Expression expression)4499 public void invalidTypeForCollection(Expression expression) {
4500 	this.handle(
4501 			IProblem.InvalidTypeForCollection,
4502 			NoArgument,
4503 			NoArgument,
4504 			expression.sourceStart,
4505 			expression.sourceEnd);
4506 }
invalidTypeForCollectionTarget14(Expression expression)4507 public void invalidTypeForCollectionTarget14(Expression expression) {
4508 	this.handle(
4509 			IProblem.InvalidTypeForCollectionTarget14,
4510 			NoArgument,
4511 			NoArgument,
4512 			expression.sourceStart,
4513 			expression.sourceEnd);
4514 }
invalidTypeToSynchronize(Expression expression, TypeBinding type)4515 public void invalidTypeToSynchronize(Expression expression, TypeBinding type) {
4516 	this.handle(
4517 		IProblem.InvalidTypeToSynchronized,
4518 		new String[] {new String(type.readableName())},
4519 		new String[] {new String(type.shortReadableName())},
4520 		expression.sourceStart,
4521 		expression.sourceEnd);
4522 }
invalidTypeVariableAsException(TypeBinding exceptionType, ASTNode location)4523 public void invalidTypeVariableAsException(TypeBinding exceptionType, ASTNode location) {
4524 	this.handle(
4525 		IProblem.InvalidTypeVariableExceptionType,
4526 		new String[] {new String(exceptionType.readableName())},
4527 		new String[] {new String(exceptionType.shortReadableName())},
4528 		location.sourceStart,
4529 		location.sourceEnd);
4530 }
invalidUnaryExpression(Expression expression)4531 public void invalidUnaryExpression(Expression expression) {
4532 	this.handle(
4533 		IProblem.InvalidUnaryExpression,
4534 		NoArgument,
4535 		NoArgument,
4536 		expression.sourceStart,
4537 		expression.sourceEnd);
4538 }
invalidUsageOfAnnotation(Annotation annotation)4539 public void invalidUsageOfAnnotation(Annotation annotation) {
4540 	this.handle(
4541 		IProblem.InvalidUsageOfAnnotations,
4542 		NoArgument,
4543 		NoArgument,
4544 		annotation.sourceStart,
4545 		annotation.sourceEnd);
4546 }
invalidUsageOfAnnotationDeclarations(TypeDeclaration annotationTypeDeclaration)4547 public void invalidUsageOfAnnotationDeclarations(TypeDeclaration annotationTypeDeclaration) {
4548 	this.handle(
4549 		IProblem.InvalidUsageOfAnnotationDeclarations,
4550 		NoArgument,
4551 		NoArgument,
4552 		annotationTypeDeclaration.sourceStart,
4553 		annotationTypeDeclaration.sourceEnd);
4554 }
invalidUsageOfEnumDeclarations(TypeDeclaration enumDeclaration)4555 public void invalidUsageOfEnumDeclarations(TypeDeclaration enumDeclaration) {
4556 	this.handle(
4557 		IProblem.InvalidUsageOfEnumDeclarations,
4558 		NoArgument,
4559 		NoArgument,
4560 		enumDeclaration.sourceStart,
4561 		enumDeclaration.sourceEnd);
4562 }
invalidUsageOfForeachStatements(LocalDeclaration elementVariable, Expression collection)4563 public void invalidUsageOfForeachStatements(LocalDeclaration elementVariable, Expression collection) {
4564 	this.handle(
4565 		IProblem.InvalidUsageOfForeachStatements,
4566 		NoArgument,
4567 		NoArgument,
4568 		elementVariable.declarationSourceStart,
4569 		collection.sourceEnd);
4570 }
invalidUsageOfStaticImports(ImportReference staticImport)4571 public void invalidUsageOfStaticImports(ImportReference staticImport) {
4572 	this.handle(
4573 		IProblem.InvalidUsageOfStaticImports,
4574 		NoArgument,
4575 		NoArgument,
4576 		staticImport.declarationSourceStart,
4577 		staticImport.declarationSourceEnd);
4578 }
invalidUsageOfTypeArguments(TypeReference firstTypeReference, TypeReference lastTypeReference)4579 public void invalidUsageOfTypeArguments(TypeReference firstTypeReference, TypeReference lastTypeReference) {
4580 	this.handle(
4581 		IProblem.InvalidUsageOfTypeArguments,
4582 		NoArgument,
4583 		NoArgument,
4584 		firstTypeReference.sourceStart,
4585 		lastTypeReference.sourceEnd);
4586 }
invalidUsageOfTypeParameters(TypeParameter firstTypeParameter, TypeParameter lastTypeParameter)4587 public void invalidUsageOfTypeParameters(TypeParameter firstTypeParameter, TypeParameter lastTypeParameter) {
4588 	this.handle(
4589 		IProblem.InvalidUsageOfTypeParameters,
4590 		NoArgument,
4591 		NoArgument,
4592 		firstTypeParameter.declarationSourceStart,
4593 		lastTypeParameter.declarationSourceEnd);
4594 }
invalidUsageOfTypeParametersForAnnotationDeclaration(TypeDeclaration annotationTypeDeclaration)4595 public void invalidUsageOfTypeParametersForAnnotationDeclaration(TypeDeclaration annotationTypeDeclaration) {
4596 	TypeParameter[] parameters = annotationTypeDeclaration.typeParameters;
4597 	int length = parameters.length;
4598 	this.handle(
4599 			IProblem.InvalidUsageOfTypeParametersForAnnotationDeclaration,
4600 			NoArgument,
4601 			NoArgument,
4602 			parameters[0].declarationSourceStart,
4603 			parameters[length - 1].declarationSourceEnd);
4604 }
invalidUsageOfTypeParametersForEnumDeclaration(TypeDeclaration annotationTypeDeclaration)4605 public void invalidUsageOfTypeParametersForEnumDeclaration(TypeDeclaration annotationTypeDeclaration) {
4606 	TypeParameter[] parameters = annotationTypeDeclaration.typeParameters;
4607 	int length = parameters.length;
4608 	this.handle(
4609 			IProblem.InvalidUsageOfTypeParametersForEnumDeclaration,
4610 			NoArgument,
4611 			NoArgument,
4612 			parameters[0].declarationSourceStart,
4613 			parameters[length - 1].declarationSourceEnd);
4614 }
invalidUsageOfVarargs(Argument argument)4615 public void invalidUsageOfVarargs(Argument argument) {
4616 	this.handle(
4617 		IProblem.InvalidUsageOfVarargs,
4618 		NoArgument,
4619 		NoArgument,
4620 		argument.type.sourceStart,
4621 		argument.sourceEnd);
4622 }
4623 
invalidUsageOfTypeAnnotations(Annotation annotation)4624 public void invalidUsageOfTypeAnnotations(Annotation annotation) {
4625 	this.handle(
4626 			IProblem.InvalidUsageOfTypeAnnotations,
4627 			NoArgument,
4628 			NoArgument,
4629 			annotation.sourceStart,
4630 			annotation.sourceEnd);
4631 }
toleratedMisplacedTypeAnnotations(Annotation first, Annotation last)4632 public void toleratedMisplacedTypeAnnotations(Annotation first, Annotation last) {
4633 	this.handle(
4634 			IProblem.ToleratedMisplacedTypeAnnotations,
4635 			NoArgument,
4636 			NoArgument,
4637 			first.sourceStart,
4638 			last.sourceEnd);
4639 }
misplacedTypeAnnotations(Annotation first, Annotation last)4640 public void misplacedTypeAnnotations(Annotation first, Annotation last) {
4641 	this.handle(
4642 			IProblem.MisplacedTypeAnnotations,
4643 			NoArgument,
4644 			NoArgument,
4645 			first.sourceStart,
4646 			last.sourceEnd);
4647 }
illegalUsageOfTypeAnnotations(Annotation annotation)4648 public void illegalUsageOfTypeAnnotations(Annotation annotation) {
4649 	this.handle(
4650 			IProblem.IllegalUsageOfTypeAnnotations,
4651 			NoArgument,
4652 			NoArgument,
4653 			annotation.sourceStart,
4654 			annotation.sourceEnd);
4655 }
illegalTypeAnnotationsInStaticMemberAccess(Annotation first, Annotation last)4656 public void illegalTypeAnnotationsInStaticMemberAccess(Annotation first, Annotation last) {
4657 	this.handle(
4658 			IProblem.IllegalTypeAnnotationsInStaticMemberAccess,
4659 			NoArgument,
4660 			NoArgument,
4661 			first.sourceStart,
4662 			last.sourceEnd);
4663 }
isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl, Object location)4664 public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl, Object location) {
4665 	// ProblemReporter is not designed to be reentrant. Just in case, we discovered a build path problem while we are already
4666 	// in the midst of reporting some other problem, save and restore reference context thereby mimicking a stack.
4667 	// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=442755.
4668 	ReferenceContext savedContext = this.referenceContext;
4669 	this.referenceContext = compUnitDecl;
4670 	String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)};
4671 	int start = 0, end = 0;
4672 	if (location != null) {
4673 		if (location instanceof InvocationSite) {
4674 			InvocationSite site = (InvocationSite) location;
4675 			start = site.sourceStart();
4676 			end = site.sourceEnd();
4677 		} else if (location instanceof ASTNode) {
4678 			ASTNode node = (ASTNode) location;
4679 			start = node.sourceStart();
4680 			end = node.sourceEnd();
4681 		}
4682 	}
4683 	try {
4684 		this.handle(
4685 				IProblem.IsClassPathCorrect,
4686 				arguments,
4687 				arguments,
4688 				start,
4689 				end);
4690 	} finally {
4691 		this.referenceContext = savedContext;
4692 	}
4693 }
isIdentifier(int token)4694 private boolean isIdentifier(int token) {
4695 	return token == TerminalTokens.TokenNameIdentifier;
4696 }
isKeyword(int token)4697 private boolean isKeyword(int token) {
4698 	switch(token) {
4699 		case TerminalTokens.TokenNameabstract:
4700 		case TerminalTokens.TokenNameassert:
4701 		case TerminalTokens.TokenNamebyte:
4702 		case TerminalTokens.TokenNamebreak:
4703 		case TerminalTokens.TokenNameboolean:
4704 		case TerminalTokens.TokenNamecase:
4705 		case TerminalTokens.TokenNamechar:
4706 		case TerminalTokens.TokenNamecatch:
4707 		case TerminalTokens.TokenNameclass:
4708 		case TerminalTokens.TokenNamecontinue:
4709 		case TerminalTokens.TokenNamedo:
4710 		case TerminalTokens.TokenNamedouble:
4711 		case TerminalTokens.TokenNamedefault:
4712 		case TerminalTokens.TokenNameelse:
4713 		case TerminalTokens.TokenNameextends:
4714 		case TerminalTokens.TokenNamefor:
4715 		case TerminalTokens.TokenNamefinal:
4716 		case TerminalTokens.TokenNamefloat:
4717 		case TerminalTokens.TokenNamefalse:
4718 		case TerminalTokens.TokenNamefinally:
4719 		case TerminalTokens.TokenNameif:
4720 		case TerminalTokens.TokenNameint:
4721 		case TerminalTokens.TokenNameimport:
4722 		case TerminalTokens.TokenNameinterface:
4723 		case TerminalTokens.TokenNameimplements:
4724 		case TerminalTokens.TokenNameinstanceof:
4725 		case TerminalTokens.TokenNamelong:
4726 		case TerminalTokens.TokenNamenew:
4727 		case TerminalTokens.TokenNamenull:
4728 		case TerminalTokens.TokenNamenative:
4729 		case TerminalTokens.TokenNamepublic:
4730 		case TerminalTokens.TokenNamepackage:
4731 		case TerminalTokens.TokenNameprivate:
4732 		case TerminalTokens.TokenNameprotected:
4733 		case TerminalTokens.TokenNamereturn:
4734 		case TerminalTokens.TokenNameshort:
4735 		case TerminalTokens.TokenNamesuper:
4736 		case TerminalTokens.TokenNamestatic:
4737 		case TerminalTokens.TokenNameswitch:
4738 		case TerminalTokens.TokenNamestrictfp:
4739 		case TerminalTokens.TokenNamesynchronized:
4740 		case TerminalTokens.TokenNametry:
4741 		case TerminalTokens.TokenNamethis:
4742 		case TerminalTokens.TokenNametrue:
4743 		case TerminalTokens.TokenNamethrow:
4744 		case TerminalTokens.TokenNamethrows:
4745 		case TerminalTokens.TokenNametransient:
4746 		case TerminalTokens.TokenNamevoid:
4747 		case TerminalTokens.TokenNamevolatile:
4748 		case TerminalTokens.TokenNamewhile:
4749 			return true;
4750 		default:
4751 			return false;
4752 	}
4753 }
isLiteral(int token)4754 private boolean isLiteral(int token) {
4755 	return Scanner.isLiteral(token);
4756 }
4757 
isRecoveredName(char[] simpleName)4758 private boolean isRecoveredName(char[] simpleName) {
4759 	return simpleName == RecoveryScanner.FAKE_IDENTIFIER;
4760 }
4761 
isRecoveredName(char[][] qualifiedName)4762 private boolean isRecoveredName(char[][] qualifiedName) {
4763 	if(qualifiedName == null) return false;
4764 	for (int i = 0; i < qualifiedName.length; i++) {
4765 		if(qualifiedName[i] == RecoveryScanner.FAKE_IDENTIFIER) return true;
4766 	}
4767 	return false;
4768 }
4769 
javadocAmbiguousMethodReference(int sourceStart, int sourceEnd, Binding fieldBinding, int modifiers)4770 public void javadocAmbiguousMethodReference(int sourceStart, int sourceEnd, Binding fieldBinding, int modifiers) {
4771 	int severity = computeSeverity(IProblem.JavadocAmbiguousMethodReference);
4772 	if (severity == ProblemSeverities.Ignore) return;
4773 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
4774 		String[] arguments = new String[] {new String(fieldBinding.readableName())};
4775 		handle(
4776 			IProblem.JavadocAmbiguousMethodReference,
4777 			arguments,
4778 			arguments,
4779 			severity,
4780 			sourceStart,
4781 			sourceEnd);
4782 	}
4783 }
4784 
javadocDeprecatedField(FieldBinding field, ASTNode location, int modifiers)4785 public void javadocDeprecatedField(FieldBinding field, ASTNode location, int modifiers) {
4786 	int severity = computeSeverity(IProblem.JavadocUsingDeprecatedField);
4787 	if (severity == ProblemSeverities.Ignore) return;
4788 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
4789 		this.handle(
4790 			IProblem.JavadocUsingDeprecatedField,
4791 			new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
4792 			new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
4793 			severity,
4794 			nodeSourceStart(field, location),
4795 			nodeSourceEnd(field, location));
4796 	}
4797 }
4798 
javadocDeprecatedMethod(MethodBinding method, ASTNode location, int modifiers)4799 public void javadocDeprecatedMethod(MethodBinding method, ASTNode location, int modifiers) {
4800 	boolean isConstructor = method.isConstructor();
4801 	int severity = computeSeverity(isConstructor ? IProblem.JavadocUsingDeprecatedConstructor : IProblem.JavadocUsingDeprecatedMethod);
4802 	if (severity == ProblemSeverities.Ignore) return;
4803 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
4804 		if (isConstructor) {
4805 			this.handle(
4806 				IProblem.JavadocUsingDeprecatedConstructor,
4807 				new String[] {new String(method.declaringClass.readableName()), typesAsString(method, false)},
4808 				new String[] {new String(method.declaringClass.shortReadableName()), typesAsString(method, true)},
4809 				severity,
4810 				location.sourceStart,
4811 				location.sourceEnd);
4812 		} else {
4813 			this.handle(
4814 				IProblem.JavadocUsingDeprecatedMethod,
4815 				new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method, false)},
4816 				new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method, true)},
4817 				severity,
4818 				location.sourceStart,
4819 				location.sourceEnd);
4820 		}
4821 	}
4822 }
javadocDeprecatedType(TypeBinding type, ASTNode location, int modifiers)4823 public void javadocDeprecatedType(TypeBinding type, ASTNode location, int modifiers) {
4824 	javadocDeprecatedType(type, location, modifiers, Integer.MAX_VALUE);
4825 }
javadocDeprecatedType(TypeBinding type, ASTNode location, int modifiers, int index)4826 public void javadocDeprecatedType(TypeBinding type, ASTNode location, int modifiers, int index) {
4827 	if (location == null) return; // 1G828DN - no type ref for synthetic arguments
4828 	int severity = computeSeverity(IProblem.JavadocUsingDeprecatedType);
4829 	if (severity == ProblemSeverities.Ignore) return;
4830 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
4831 		if (type.isMemberType() && type instanceof ReferenceBinding && !javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, ((ReferenceBinding)type).modifiers)) {
4832 			this.handle(IProblem.JavadocHiddenReference, NoArgument, NoArgument, location.sourceStart, location.sourceEnd);
4833 		} else {
4834 			this.handle(
4835 				IProblem.JavadocUsingDeprecatedType,
4836 				new String[] {new String(type.readableName())},
4837 				new String[] {new String(type.shortReadableName())},
4838 				severity,
4839 				location.sourceStart,
4840 				nodeSourceEnd(null, location, index));
4841 		}
4842 	}
4843 }
javadocDuplicatedParamTag(char[] token, int sourceStart, int sourceEnd, int modifiers)4844 public void javadocDuplicatedParamTag(char[] token, int sourceStart, int sourceEnd, int modifiers) {
4845 	int severity = computeSeverity(IProblem.JavadocDuplicateParamName);
4846 	if (severity == ProblemSeverities.Ignore) return;
4847 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
4848 		String[] arguments = new String[] {String.valueOf(token)};
4849 		this.handle(
4850 			IProblem.JavadocDuplicateParamName,
4851 			arguments,
4852 			arguments,
4853 			severity,
4854 			sourceStart,
4855 			sourceEnd);
4856 	}
4857 }
javadocDuplicatedReturnTag(int sourceStart, int sourceEnd)4858 public void javadocDuplicatedReturnTag(int sourceStart, int sourceEnd){
4859 	this.handle(IProblem.JavadocDuplicateReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd);
4860 }
javadocDuplicatedTag(char[] tagName, int sourceStart, int sourceEnd)4861 public void javadocDuplicatedTag(char[] tagName, int sourceStart, int sourceEnd){
4862 	String[] arguments = new String[] { new String(tagName) };
4863 	this.handle(
4864 		IProblem.JavadocDuplicateTag,
4865 		arguments,
4866 		arguments,
4867 		sourceStart,
4868 		sourceEnd);
4869 }
javadocDuplicatedThrowsClassName(TypeReference typeReference, int modifiers)4870 public void javadocDuplicatedThrowsClassName(TypeReference typeReference, int modifiers) {
4871 	int severity = computeSeverity(IProblem.JavadocDuplicateThrowsClassName);
4872 	if (severity == ProblemSeverities.Ignore) return;
4873 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
4874 		String[] arguments = new String[] {String.valueOf(typeReference.resolvedType.sourceName())};
4875 		this.handle(
4876 			IProblem.JavadocDuplicateThrowsClassName,
4877 			arguments,
4878 			arguments,
4879 			severity,
4880 			typeReference.sourceStart,
4881 			typeReference.sourceEnd);
4882 	}
4883 }
javadocEmptyReturnTag(int sourceStart, int sourceEnd, int modifiers)4884 public void javadocEmptyReturnTag(int sourceStart, int sourceEnd, int modifiers) {
4885 	int severity = computeSeverity(IProblem.JavadocEmptyReturnTag);
4886 	if (severity == ProblemSeverities.Ignore) return;
4887 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
4888 		String[] arguments = new String[] { new String(JavadocTagConstants.TAG_RETURN) };
4889 		this.handle(IProblem.JavadocEmptyReturnTag, arguments, arguments, sourceStart, sourceEnd);
4890 	}
4891 }
javadocErrorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params, int modifiers)4892 public void javadocErrorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params, int modifiers) {
4893 	int id = recType.isArrayType() ? IProblem.JavadocNoMessageSendOnArrayType : IProblem.JavadocNoMessageSendOnBaseType;
4894 	int severity = computeSeverity(id);
4895 	if (severity == ProblemSeverities.Ignore) return;
4896 	StringBuffer buffer = new StringBuffer();
4897 	StringBuffer shortBuffer = new StringBuffer();
4898 	for (int i = 0, length = params.length; i < length; i++) {
4899 		if (i != 0){
4900 			buffer.append(", "); //$NON-NLS-1$
4901 			shortBuffer.append(", "); //$NON-NLS-1$
4902 		}
4903 		buffer.append(new String(params[i].readableName()));
4904 		shortBuffer.append(new String(params[i].shortReadableName()));
4905 	}
4906 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
4907 		this.handle(
4908 			id,
4909 			new String[] {new String(recType.readableName()), new String(messageSend.selector), buffer.toString()},
4910 			new String[] {new String(recType.shortReadableName()), new String(messageSend.selector), shortBuffer.toString()},
4911 			severity,
4912 			messageSend.sourceStart,
4913 			messageSend.sourceEnd);
4914 	}
4915 }
javadocHiddenReference(int sourceStart, int sourceEnd, Scope scope, int modifiers)4916 public void javadocHiddenReference(int sourceStart, int sourceEnd, Scope scope, int modifiers) {
4917 	Scope currentScope = scope;
4918 	while (currentScope.parent.kind != Scope.COMPILATION_UNIT_SCOPE ) {
4919 		if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, currentScope.getDeclarationModifiers())) {
4920 			return;
4921 		}
4922 		currentScope = currentScope.parent;
4923 	}
4924 	String[] arguments = new String[] { this.options.getVisibilityString(this.options.reportInvalidJavadocTagsVisibility), this.options.getVisibilityString(modifiers) };
4925 	this.handle(IProblem.JavadocHiddenReference, arguments, arguments, sourceStart, sourceEnd);
4926 }
javadocInvalidConstructor(Statement statement, MethodBinding targetConstructor, int modifiers)4927 public void javadocInvalidConstructor(Statement statement, MethodBinding targetConstructor, int modifiers) {
4928 
4929 	if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) return;
4930 	int sourceStart = statement.sourceStart;
4931 	int sourceEnd = statement.sourceEnd;
4932 	if (statement instanceof AllocationExpression) {
4933 		AllocationExpression allocation = (AllocationExpression)statement;
4934 		if (allocation.enumConstant != null) {
4935 			sourceStart = allocation.enumConstant.sourceStart;
4936 			sourceEnd = allocation.enumConstant.sourceEnd;
4937 		}
4938 	}
4939 	int id = IProblem.JavadocUndefinedConstructor; //default...
4940 	ProblemMethodBinding problemConstructor = null;
4941 	MethodBinding shownConstructor = null;
4942 	switch (targetConstructor.problemId()) {
4943 		case ProblemReasons.NotFound :
4944 			id = IProblem.JavadocUndefinedConstructor;
4945 			break;
4946 		case ProblemReasons.NotVisible :
4947 			id = IProblem.JavadocNotVisibleConstructor;
4948 			break;
4949 		case ProblemReasons.Ambiguous :
4950 			id = IProblem.JavadocAmbiguousConstructor;
4951 			break;
4952 		case ProblemReasons.ParameterBoundMismatch :
4953 			int severity = computeSeverity(IProblem.JavadocGenericConstructorTypeArgumentMismatch);
4954 			if (severity == ProblemSeverities.Ignore) return;
4955 			problemConstructor = (ProblemMethodBinding) targetConstructor;
4956 			ParameterizedGenericMethodBinding substitutedConstructor = (ParameterizedGenericMethodBinding) problemConstructor.closestMatch;
4957 			shownConstructor = substitutedConstructor.original();
4958 
4959 			int augmentedLength = problemConstructor.parameters.length;
4960 			TypeBinding inferredTypeArgument = problemConstructor.parameters[augmentedLength-2];
4961 			TypeVariableBinding typeParameter = (TypeVariableBinding) problemConstructor.parameters[augmentedLength-1];
4962 			TypeBinding[] invocationArguments = new TypeBinding[augmentedLength-2]; // remove extra info from the end
4963 			System.arraycopy(problemConstructor.parameters, 0, invocationArguments, 0, augmentedLength-2);
4964 
4965 			this.handle(
4966 				IProblem.JavadocGenericConstructorTypeArgumentMismatch,
4967 				new String[] {
4968 				        new String(shownConstructor.declaringClass.sourceName()),
4969 				        typesAsString(shownConstructor, false),
4970 				        new String(shownConstructor.declaringClass.readableName()),
4971 				        typesAsString(invocationArguments, false),
4972 				        new String(inferredTypeArgument.readableName()),
4973 				        new String(typeParameter.sourceName()),
4974 				        parameterBoundAsString(typeParameter, false) },
4975 				new String[] {
4976 				        new String(shownConstructor.declaringClass.sourceName()),
4977 				        typesAsString(shownConstructor, true),
4978 				        new String(shownConstructor.declaringClass.shortReadableName()),
4979 				        typesAsString(invocationArguments, true),
4980 				        new String(inferredTypeArgument.shortReadableName()),
4981 				        new String(typeParameter.sourceName()),
4982 				        parameterBoundAsString(typeParameter, true) },
4983 				severity,
4984 				sourceStart,
4985 				sourceEnd);
4986 			return;
4987 
4988 		case ProblemReasons.TypeParameterArityMismatch :
4989 			problemConstructor = (ProblemMethodBinding) targetConstructor;
4990 			shownConstructor = problemConstructor.closestMatch;
4991 			boolean noTypeVariables = shownConstructor.typeVariables == Binding.NO_TYPE_VARIABLES;
4992 			severity = computeSeverity(noTypeVariables ? IProblem.JavadocNonGenericConstructor : IProblem.JavadocIncorrectArityForParameterizedConstructor);
4993 			if (severity == ProblemSeverities.Ignore) return;
4994 			if (noTypeVariables) {
4995 				this.handle(
4996 					IProblem.JavadocNonGenericConstructor,
4997 					new String[] {
4998 					        new String(shownConstructor.declaringClass.sourceName()),
4999 					        typesAsString(shownConstructor, false),
5000 					        new String(shownConstructor.declaringClass.readableName()),
5001 					        typesAsString(targetConstructor, false) },
5002 					new String[] {
5003 					        new String(shownConstructor.declaringClass.sourceName()),
5004 					        typesAsString(shownConstructor, true),
5005 					        new String(shownConstructor.declaringClass.shortReadableName()),
5006 					        typesAsString(targetConstructor, true) },
5007 					severity,
5008 					sourceStart,
5009 					sourceEnd);
5010 			} else {
5011 				this.handle(
5012 					IProblem.JavadocIncorrectArityForParameterizedConstructor,
5013 					new String[] {
5014 					        new String(shownConstructor.declaringClass.sourceName()),
5015 					        typesAsString(shownConstructor, false),
5016 					        new String(shownConstructor.declaringClass.readableName()),
5017 							typesAsString(shownConstructor.typeVariables, false),
5018 					        typesAsString(targetConstructor, false) },
5019 					new String[] {
5020 					        new String(shownConstructor.declaringClass.sourceName()),
5021 					        typesAsString(shownConstructor, true),
5022 					        new String(shownConstructor.declaringClass.shortReadableName()),
5023 							typesAsString(shownConstructor.typeVariables, true),
5024 					        typesAsString(targetConstructor, true) },
5025 					severity,
5026 					sourceStart,
5027 					sourceEnd);
5028 			}
5029 			return;
5030 		case ProblemReasons.ParameterizedMethodTypeMismatch :
5031 			severity = computeSeverity(IProblem.JavadocParameterizedConstructorArgumentTypeMismatch);
5032 			if (severity == ProblemSeverities.Ignore) return;
5033 			problemConstructor = (ProblemMethodBinding) targetConstructor;
5034 			shownConstructor = problemConstructor.closestMatch;
5035 			this.handle(
5036 				IProblem.JavadocParameterizedConstructorArgumentTypeMismatch,
5037 				new String[] {
5038 				        new String(shownConstructor.declaringClass.sourceName()),
5039 				        typesAsString(shownConstructor, false),
5040 				        new String(shownConstructor.declaringClass.readableName()),
5041 						typesAsString(((ParameterizedGenericMethodBinding)shownConstructor).typeArguments, false),
5042 				        typesAsString(targetConstructor, false) },
5043 				new String[] {
5044 				        new String(shownConstructor.declaringClass.sourceName()),
5045 				        typesAsString(shownConstructor, true),
5046 				        new String(shownConstructor.declaringClass.shortReadableName()),
5047 						typesAsString(((ParameterizedGenericMethodBinding)shownConstructor).typeArguments, true),
5048 				        typesAsString(targetConstructor, true) },
5049 				severity,
5050 				sourceStart,
5051 				sourceEnd);
5052 			return;
5053 		case ProblemReasons.TypeArgumentsForRawGenericMethod :
5054 			severity = computeSeverity(IProblem.JavadocTypeArgumentsForRawGenericConstructor);
5055 			if (severity == ProblemSeverities.Ignore) return;
5056 			problemConstructor = (ProblemMethodBinding) targetConstructor;
5057 			shownConstructor = problemConstructor.closestMatch;
5058 			this.handle(
5059 				IProblem.JavadocTypeArgumentsForRawGenericConstructor,
5060 				new String[] {
5061 				        new String(shownConstructor.declaringClass.sourceName()),
5062 				        typesAsString(shownConstructor, false),
5063 				        new String(shownConstructor.declaringClass.readableName()),
5064 				        typesAsString(targetConstructor, false) },
5065 				new String[] {
5066 				        new String(shownConstructor.declaringClass.sourceName()),
5067 				        typesAsString(shownConstructor, true),
5068 				        new String(shownConstructor.declaringClass.shortReadableName()),
5069 				        typesAsString(targetConstructor, true) },
5070 				severity,
5071 				sourceStart,
5072 				sourceEnd);
5073 			return;
5074 		case ProblemReasons.NoError : // 0
5075 		default :
5076 			needImplementation(statement); // want to fail to see why we were here...
5077 			break;
5078 	}
5079 	int severity = computeSeverity(id);
5080 	if (severity == ProblemSeverities.Ignore) return;
5081 	this.handle(
5082 		id,
5083 		new String[] {new String(targetConstructor.declaringClass.readableName()), typesAsString(targetConstructor, false)},
5084 		new String[] {new String(targetConstructor.declaringClass.shortReadableName()), typesAsString(targetConstructor, true)},
5085 		severity,
5086 		statement.sourceStart,
5087 		statement.sourceEnd);
5088 }
5089 /*
5090  * Similar implementation than invalidField(FieldReference...)
5091  * Note that following problem id cannot occur for Javadoc:
5092  * 	- NonStaticReferenceInStaticContext :
5093  * 	- NonStaticReferenceInConstructorInvocation :
5094  * 	- ReceiverTypeNotVisible :
5095  */
javadocInvalidField(FieldReference fieldRef, Binding fieldBinding, TypeBinding searchedType, int modifiers)5096 public void javadocInvalidField(FieldReference fieldRef, Binding fieldBinding, TypeBinding searchedType, int modifiers) {
5097 	int id = IProblem.JavadocUndefinedField;
5098 	switch (fieldBinding.problemId()) {
5099 		case ProblemReasons.NotFound :
5100 			id = IProblem.JavadocUndefinedField;
5101 			break;
5102 		case ProblemReasons.NotVisible :
5103 			id = IProblem.JavadocNotVisibleField;
5104 			break;
5105 		case ProblemReasons.Ambiguous :
5106 			id = IProblem.JavadocAmbiguousField;
5107 			break;
5108 		case ProblemReasons.NoError : // 0
5109 		default :
5110 			needImplementation(fieldRef); // want to fail to see why we were here...
5111 			break;
5112 	}
5113 	int severity = computeSeverity(id);
5114 	if (severity == ProblemSeverities.Ignore) return;
5115 	// report issue
5116 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5117 		String[] arguments = new String[] {new String(fieldBinding.readableName())};
5118 		handle(
5119 			id,
5120 			arguments,
5121 			arguments,
5122 			severity,
5123 			fieldRef.sourceStart,
5124 			fieldRef.sourceEnd);
5125 	}
5126 }
javadocInvalidMemberTypeQualification(int sourceStart, int sourceEnd, int modifiers)5127 public void javadocInvalidMemberTypeQualification(int sourceStart, int sourceEnd, int modifiers){
5128 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5129 		this.handle(IProblem.JavadocInvalidMemberTypeQualification, NoArgument, NoArgument, sourceStart, sourceEnd);
5130 	}
5131 }
5132 /*
5133  * Similar implementation than invalidMethod(MessageSend...)
5134  * Note that following problem id cannot occur for Javadoc:
5135  * 	- NonStaticReferenceInStaticContext :
5136  * 	- NonStaticReferenceInConstructorInvocation :
5137  * 	- ReceiverTypeNotVisible :
5138  */
javadocInvalidMethod(MessageSend messageSend, MethodBinding method, int modifiers)5139 public void javadocInvalidMethod(MessageSend messageSend, MethodBinding method, int modifiers) {
5140 	if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) return;
5141 	// set problem id
5142 	ProblemMethodBinding problemMethod = null;
5143 	MethodBinding shownMethod = null;
5144 	int id = IProblem.JavadocUndefinedMethod; //default...
5145 	switch (method.problemId()) {
5146 		case ProblemReasons.NotFound :
5147 			id = IProblem.JavadocUndefinedMethod;
5148 			problemMethod = (ProblemMethodBinding) method;
5149 			if (problemMethod.closestMatch != null) {
5150 				int severity = computeSeverity(IProblem.JavadocParameterMismatch);
5151 				if (severity == ProblemSeverities.Ignore) return;
5152 				String closestParameterTypeNames = typesAsString(problemMethod.closestMatch, false);
5153 				String parameterTypeNames = typesAsString(method, false);
5154 				String closestParameterTypeShortNames = typesAsString(problemMethod.closestMatch, true);
5155 				String parameterTypeShortNames = typesAsString(method, true);
5156 				if (closestParameterTypeShortNames.equals(parameterTypeShortNames)){
5157 					closestParameterTypeShortNames = closestParameterTypeNames;
5158 					parameterTypeShortNames = parameterTypeNames;
5159 				}
5160 				this.handle(
5161 					IProblem.JavadocParameterMismatch,
5162 					new String[] {
5163 						new String(problemMethod.closestMatch.declaringClass.readableName()),
5164 						new String(problemMethod.closestMatch.selector),
5165 						closestParameterTypeNames,
5166 						parameterTypeNames
5167 					},
5168 					new String[] {
5169 						new String(problemMethod.closestMatch.declaringClass.shortReadableName()),
5170 						new String(problemMethod.closestMatch.selector),
5171 						closestParameterTypeShortNames,
5172 						parameterTypeShortNames
5173 					},
5174 					severity,
5175 					(int) (messageSend.nameSourcePosition >>> 32),
5176 					(int) messageSend.nameSourcePosition);
5177 				return;
5178 			}
5179 			break;
5180 		case ProblemReasons.NotVisible :
5181 			id = IProblem.JavadocNotVisibleMethod;
5182 			break;
5183 		case ProblemReasons.Ambiguous :
5184 			id = IProblem.JavadocAmbiguousMethod;
5185 			break;
5186 		case ProblemReasons.ParameterBoundMismatch :
5187 			int severity = computeSeverity(IProblem.JavadocGenericMethodTypeArgumentMismatch);
5188 			if (severity == ProblemSeverities.Ignore) return;
5189 			problemMethod = (ProblemMethodBinding) method;
5190 			ParameterizedGenericMethodBinding substitutedMethod = (ParameterizedGenericMethodBinding) problemMethod.closestMatch;
5191 			shownMethod = substitutedMethod.original();
5192 			int augmentedLength = problemMethod.parameters.length;
5193 			TypeBinding inferredTypeArgument = problemMethod.parameters[augmentedLength-2];
5194 			TypeVariableBinding typeParameter = (TypeVariableBinding) problemMethod.parameters[augmentedLength-1];
5195 			TypeBinding[] invocationArguments = new TypeBinding[augmentedLength-2]; // remove extra info from the end
5196 			System.arraycopy(problemMethod.parameters, 0, invocationArguments, 0, augmentedLength-2);
5197 			this.handle(
5198 				IProblem.JavadocGenericMethodTypeArgumentMismatch,
5199 				new String[] {
5200 				        new String(shownMethod.selector),
5201 				        typesAsString(shownMethod, false),
5202 				        new String(shownMethod.declaringClass.readableName()),
5203 				        typesAsString(invocationArguments, false),
5204 				        new String(inferredTypeArgument.readableName()),
5205 				        new String(typeParameter.sourceName()),
5206 				        parameterBoundAsString(typeParameter, false) },
5207 				new String[] {
5208 				        new String(shownMethod.selector),
5209 				        typesAsString(shownMethod, true),
5210 				        new String(shownMethod.declaringClass.shortReadableName()),
5211 				        typesAsString(invocationArguments, true),
5212 				        new String(inferredTypeArgument.shortReadableName()),
5213 				        new String(typeParameter.sourceName()),
5214 				        parameterBoundAsString(typeParameter, true) },
5215 				severity,
5216 				(int) (messageSend.nameSourcePosition >>> 32),
5217 				(int) messageSend.nameSourcePosition);
5218 			return;
5219 		case ProblemReasons.TypeParameterArityMismatch :
5220 			problemMethod = (ProblemMethodBinding) method;
5221 			shownMethod = problemMethod.closestMatch;
5222 			boolean noTypeVariables = shownMethod.typeVariables == Binding.NO_TYPE_VARIABLES;
5223 			severity = computeSeverity(noTypeVariables ? IProblem.JavadocNonGenericMethod : IProblem.JavadocIncorrectArityForParameterizedMethod);
5224 			if (severity == ProblemSeverities.Ignore) return;
5225 			if (noTypeVariables) {
5226 				this.handle(
5227 					IProblem.JavadocNonGenericMethod,
5228 					new String[] {
5229 					        new String(shownMethod.selector),
5230 					        typesAsString(shownMethod, false),
5231 					        new String(shownMethod.declaringClass.readableName()),
5232 					        typesAsString(method, false) },
5233 					new String[] {
5234 					        new String(shownMethod.selector),
5235 					        typesAsString(shownMethod, true),
5236 					        new String(shownMethod.declaringClass.shortReadableName()),
5237 					        typesAsString(method, true) },
5238 					severity,
5239 					(int) (messageSend.nameSourcePosition >>> 32),
5240 					(int) messageSend.nameSourcePosition);
5241 			} else {
5242 				this.handle(
5243 					IProblem.JavadocIncorrectArityForParameterizedMethod,
5244 					new String[] {
5245 					        new String(shownMethod.selector),
5246 					        typesAsString(shownMethod, false),
5247 					        new String(shownMethod.declaringClass.readableName()),
5248 							typesAsString(shownMethod.typeVariables, false),
5249 					        typesAsString(method, false) },
5250 					new String[] {
5251 					        new String(shownMethod.selector),
5252 					        typesAsString(shownMethod, true),
5253 					        new String(shownMethod.declaringClass.shortReadableName()),
5254 							typesAsString(shownMethod.typeVariables, true),
5255 					        typesAsString(method, true) },
5256 					severity,
5257 					(int) (messageSend.nameSourcePosition >>> 32),
5258 					(int) messageSend.nameSourcePosition);
5259 			}
5260 			return;
5261 		case ProblemReasons.ParameterizedMethodTypeMismatch :
5262 			severity = computeSeverity(IProblem.JavadocParameterizedMethodArgumentTypeMismatch);
5263 			if (severity == ProblemSeverities.Ignore) return;
5264 			problemMethod = (ProblemMethodBinding) method;
5265 			shownMethod = problemMethod.closestMatch;
5266 			this.handle(
5267 				IProblem.JavadocParameterizedMethodArgumentTypeMismatch,
5268 				new String[] {
5269 				        new String(shownMethod.selector),
5270 				        typesAsString(shownMethod, false),
5271 				        new String(shownMethod.declaringClass.readableName()),
5272 						typesAsString(((ParameterizedGenericMethodBinding)shownMethod).typeArguments, false),
5273 				        typesAsString(method, false) },
5274 				new String[] {
5275 				        new String(shownMethod.selector),
5276 				        typesAsString(shownMethod, true),
5277 				        new String(shownMethod.declaringClass.shortReadableName()),
5278 						typesAsString(((ParameterizedGenericMethodBinding)shownMethod).typeArguments, true),
5279 				        typesAsString(method, true) },
5280 				severity,
5281 				(int) (messageSend.nameSourcePosition >>> 32),
5282 				(int) messageSend.nameSourcePosition);
5283 			return;
5284 		case ProblemReasons.TypeArgumentsForRawGenericMethod :
5285 			severity = computeSeverity(IProblem.JavadocTypeArgumentsForRawGenericMethod);
5286 			if (severity == ProblemSeverities.Ignore) return;
5287 			problemMethod = (ProblemMethodBinding) method;
5288 			shownMethod = problemMethod.closestMatch;
5289 			this.handle(
5290 				IProblem.JavadocTypeArgumentsForRawGenericMethod,
5291 				new String[] {
5292 				        new String(shownMethod.selector),
5293 				        typesAsString(shownMethod, false),
5294 				        new String(shownMethod.declaringClass.readableName()),
5295 				        typesAsString(method, false) },
5296 				new String[] {
5297 				        new String(shownMethod.selector),
5298 				        typesAsString(shownMethod, true),
5299 				        new String(shownMethod.declaringClass.shortReadableName()),
5300 				        typesAsString(method, true) },
5301 				severity,
5302 				(int) (messageSend.nameSourcePosition >>> 32),
5303 				(int) messageSend.nameSourcePosition);
5304 			return;
5305 		case ProblemReasons.NoError : // 0
5306 		default :
5307 			needImplementation(messageSend); // want to fail to see why we were here...
5308 			break;
5309 	}
5310 	int severity = computeSeverity(id);
5311 	if (severity == ProblemSeverities.Ignore) return;
5312 	// report issue
5313 	this.handle(
5314 		id,
5315 		new String[] {
5316 			new String(method.declaringClass.readableName()),
5317 			new String(method.selector), typesAsString(method, false)},
5318 		new String[] {
5319 			new String(method.declaringClass.shortReadableName()),
5320 			new String(method.selector), typesAsString(method, true)},
5321 		severity,
5322 		(int) (messageSend.nameSourcePosition >>> 32),
5323 		(int) messageSend.nameSourcePosition);
5324 }
javadocInvalidParamTagName(int sourceStart, int sourceEnd)5325 public void javadocInvalidParamTagName(int sourceStart, int sourceEnd) {
5326 	this.handle(IProblem.JavadocInvalidParamTagName, NoArgument, NoArgument, sourceStart, sourceEnd);
5327 }
javadocInvalidParamTypeParameter(int sourceStart, int sourceEnd)5328 public void javadocInvalidParamTypeParameter(int sourceStart, int sourceEnd) {
5329 	this.handle(IProblem.JavadocInvalidParamTagTypeParameter, NoArgument, NoArgument, sourceStart, sourceEnd);
5330 }
javadocInvalidReference(int sourceStart, int sourceEnd)5331 public void javadocInvalidReference(int sourceStart, int sourceEnd) {
5332 	this.handle(IProblem.JavadocInvalidSeeReference, NoArgument, NoArgument, sourceStart, sourceEnd);
5333 }
5334 /**
5335  * Report an invalid reference that does not conform to the href syntax.
5336  * Valid syntax example: @see IProblem.JavadocInvalidSeeHref
5337  */
javadocInvalidSeeHref(int sourceStart, int sourceEnd)5338 public void javadocInvalidSeeHref(int sourceStart, int sourceEnd) {
5339 this.handle(IProblem.JavadocInvalidSeeHref, NoArgument, NoArgument, sourceStart, sourceEnd);
5340 }
javadocInvalidSeeReferenceArgs(int sourceStart, int sourceEnd)5341 public void javadocInvalidSeeReferenceArgs(int sourceStart, int sourceEnd) {
5342 	this.handle(IProblem.JavadocInvalidSeeArgs, NoArgument, NoArgument, sourceStart, sourceEnd);
5343 }
5344 /**
5345  * Report a problem on an invalid URL reference.
5346  * Valid syntax example: @see IProblem.JavadocInvalidSeeUrlReference
5347  */
javadocInvalidSeeUrlReference(int sourceStart, int sourceEnd)5348 public void javadocInvalidSeeUrlReference(int sourceStart, int sourceEnd) {
5349 	this.handle(IProblem.JavadocInvalidSeeUrlReference, NoArgument, NoArgument, sourceStart, sourceEnd);
5350 }
javadocInvalidTag(int sourceStart, int sourceEnd)5351 public void javadocInvalidTag(int sourceStart, int sourceEnd) {
5352 	this.handle(IProblem.JavadocInvalidTag, NoArgument, NoArgument, sourceStart, sourceEnd);
5353 }
javadocInvalidThrowsClass(int sourceStart, int sourceEnd)5354 public void javadocInvalidThrowsClass(int sourceStart, int sourceEnd) {
5355 	this.handle(IProblem.JavadocInvalidThrowsClass, NoArgument, NoArgument, sourceStart, sourceEnd);
5356 }
javadocInvalidThrowsClassName(TypeReference typeReference, int modifiers)5357 public void javadocInvalidThrowsClassName(TypeReference typeReference, int modifiers) {
5358 	int severity = computeSeverity(IProblem.JavadocInvalidThrowsClassName);
5359 	if (severity == ProblemSeverities.Ignore) return;
5360 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5361 		String[] arguments = new String[] {String.valueOf(typeReference.resolvedType.sourceName())};
5362 		this.handle(
5363 			IProblem.JavadocInvalidThrowsClassName,
5364 			arguments,
5365 			arguments,
5366 			severity,
5367 			typeReference.sourceStart,
5368 			typeReference.sourceEnd);
5369 	}
5370 }
javadocInvalidType(ASTNode location, TypeBinding type, int modifiers)5371 public void javadocInvalidType(ASTNode location, TypeBinding type, int modifiers) {
5372 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5373 		int id = IProblem.JavadocUndefinedType; // default
5374 		switch (type.problemId()) {
5375 			case ProblemReasons.NotFound :
5376 				id = IProblem.JavadocUndefinedType;
5377 				break;
5378 			case ProblemReasons.NotVisible :
5379 				id = IProblem.JavadocNotVisibleType;
5380 				break;
5381 			case ProblemReasons.Ambiguous :
5382 				id = IProblem.JavadocAmbiguousType;
5383 				break;
5384 			case ProblemReasons.InternalNameProvided :
5385 				id = IProblem.JavadocInternalTypeNameProvided;
5386 				break;
5387 			case ProblemReasons.InheritedNameHidesEnclosingName :
5388 				id = IProblem.JavadocInheritedNameHidesEnclosingTypeName;
5389 				break;
5390 			case ProblemReasons.NonStaticReferenceInStaticContext :
5391 				id = IProblem.JavadocNonStaticTypeFromStaticInvocation;
5392 			    break;
5393 			case ProblemReasons.NoError : // 0
5394 			default :
5395 				needImplementation(location); // want to fail to see why we were here...
5396 				break;
5397 		}
5398 		int severity = computeSeverity(id);
5399 		if (severity == ProblemSeverities.Ignore) return;
5400 		this.handle(
5401 			id,
5402 			new String[] {new String(type.readableName())},
5403 			new String[] {new String(type.shortReadableName())},
5404 			severity,
5405 			location.sourceStart,
5406 			location.sourceEnd);
5407 	}
5408 }
javadocInvalidValueReference(int sourceStart, int sourceEnd, int modifiers)5409 public void javadocInvalidValueReference(int sourceStart, int sourceEnd, int modifiers) {
5410 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
5411 		this.handle(IProblem.JavadocInvalidValueReference, NoArgument, NoArgument, sourceStart, sourceEnd);
5412 }
javadocMalformedSeeReference(int sourceStart, int sourceEnd)5413 public void javadocMalformedSeeReference(int sourceStart, int sourceEnd) {
5414 	this.handle(IProblem.JavadocMalformedSeeReference, NoArgument, NoArgument, sourceStart, sourceEnd);
5415 }
javadocMissing(int sourceStart, int sourceEnd, int modifiers)5416 public void javadocMissing(int sourceStart, int sourceEnd, int modifiers){
5417 	int severity = computeSeverity(IProblem.JavadocMissing);
5418 	this.javadocMissing(sourceStart, sourceEnd, severity, modifiers);
5419 }
javadocMissing(int sourceStart, int sourceEnd, int severity, int modifiers)5420 public void javadocMissing(int sourceStart, int sourceEnd, int severity, int modifiers){
5421 	if (severity == ProblemSeverities.Ignore) return;
5422 	boolean overriding = (modifiers & (ExtraCompilerModifiers.AccImplementing|ExtraCompilerModifiers.AccOverriding)) != 0;
5423 	boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocComments) != ProblemSeverities.Ignore)
5424 					&& (!overriding || this.options.reportMissingJavadocCommentsOverriding);
5425 	if (report) {
5426 		String arg = javadocVisibilityArgument(this.options.reportMissingJavadocCommentsVisibility, modifiers);
5427 		if (arg != null) {
5428 			String[] arguments = new String[] { arg };
5429 			this.handle(
5430 				IProblem.JavadocMissing,
5431 				arguments,
5432 				arguments,
5433 				severity,
5434 				sourceStart,
5435 				sourceEnd);
5436 		}
5437 	}
5438 }
javadocMissingHashCharacter(int sourceStart, int sourceEnd, String ref)5439 public void javadocMissingHashCharacter(int sourceStart, int sourceEnd, String ref){
5440 	int severity = computeSeverity(IProblem.JavadocMissingHashCharacter);
5441 	if (severity == ProblemSeverities.Ignore) return;
5442 	String[] arguments = new String[] { ref };
5443 	this.handle(
5444 		IProblem.JavadocMissingHashCharacter,
5445 		arguments,
5446 		arguments,
5447 		severity,
5448 		sourceStart,
5449 		sourceEnd);
5450 }
javadocMissingIdentifier(int sourceStart, int sourceEnd, int modifiers)5451 public void javadocMissingIdentifier(int sourceStart, int sourceEnd, int modifiers){
5452 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
5453 		this.handle(IProblem.JavadocMissingIdentifier, NoArgument, NoArgument, sourceStart, sourceEnd);
5454 }
javadocMissingParamName(int sourceStart, int sourceEnd, int modifiers)5455 public void javadocMissingParamName(int sourceStart, int sourceEnd, int modifiers){
5456 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
5457 		this.handle(IProblem.JavadocMissingParamName, NoArgument, NoArgument, sourceStart, sourceEnd);
5458 }
javadocMissingParamTag(char[] name, int sourceStart, int sourceEnd, int modifiers)5459 public void javadocMissingParamTag(char[] name, int sourceStart, int sourceEnd, int modifiers) {
5460 	int severity = computeSeverity(IProblem.JavadocMissingParamTag);
5461 	if (severity == ProblemSeverities.Ignore) return;
5462 	boolean overriding = (modifiers & (ExtraCompilerModifiers.AccImplementing|ExtraCompilerModifiers.AccOverriding)) != 0;
5463 	boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore)
5464 					&& (!overriding || this.options.reportMissingJavadocTagsOverriding);
5465 	if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) {
5466 		String[] arguments = new String[] { String.valueOf(name) };
5467 		this.handle(
5468 			IProblem.JavadocMissingParamTag,
5469 			arguments,
5470 			arguments,
5471 			severity,
5472 			sourceStart,
5473 			sourceEnd);
5474 	}
5475 }
javadocMissingReference(int sourceStart, int sourceEnd, int modifiers)5476 public void javadocMissingReference(int sourceStart, int sourceEnd, int modifiers){
5477 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
5478 		this.handle(IProblem.JavadocMissingSeeReference, NoArgument, NoArgument, sourceStart, sourceEnd);
5479 }
javadocMissingReturnTag(int sourceStart, int sourceEnd, int modifiers)5480 public void javadocMissingReturnTag(int sourceStart, int sourceEnd, int modifiers){
5481 	boolean overriding = (modifiers & (ExtraCompilerModifiers.AccImplementing|ExtraCompilerModifiers.AccOverriding)) != 0;
5482 	boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore)
5483 					&& (!overriding || this.options.reportMissingJavadocTagsOverriding);
5484 	if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) {
5485 		this.handle(IProblem.JavadocMissingReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd);
5486 	}
5487 }
javadocMissingTagDescription(char[] tokenName, int sourceStart, int sourceEnd, int modifiers)5488 public void javadocMissingTagDescription(char[] tokenName, int sourceStart, int sourceEnd, int modifiers) {
5489 	int severity = computeSeverity(IProblem.JavadocMissingTagDescription);
5490 	if (severity == ProblemSeverities.Ignore) return;
5491 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5492 		String[] arguments = new String[] { new String(tokenName) };
5493 		// use IProblem.JavadocEmptyReturnTag for all identified tags
5494 		this.handle(IProblem.JavadocEmptyReturnTag, arguments, arguments, sourceStart, sourceEnd);
5495 	}
5496 }
javadocMissingTagDescriptionAfterReference(int sourceStart, int sourceEnd, int modifiers)5497 public void javadocMissingTagDescriptionAfterReference(int sourceStart, int sourceEnd, int modifiers){
5498 	int severity = computeSeverity(IProblem.JavadocMissingTagDescription);
5499 	if (severity == ProblemSeverities.Ignore) return;
5500 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5501 		this.handle(IProblem.JavadocMissingTagDescription, NoArgument, NoArgument, severity, sourceStart, sourceEnd);
5502 	}
5503 }
javadocMissingThrowsClassName(int sourceStart, int sourceEnd, int modifiers)5504 public void javadocMissingThrowsClassName(int sourceStart, int sourceEnd, int modifiers){
5505 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5506 		this.handle(IProblem.JavadocMissingThrowsClassName, NoArgument, NoArgument, sourceStart, sourceEnd);
5507 	}
5508 }
javadocMissingThrowsTag(TypeReference typeRef, int modifiers)5509 public void javadocMissingThrowsTag(TypeReference typeRef, int modifiers){
5510 	int severity = computeSeverity(IProblem.JavadocMissingThrowsTag);
5511 	if (severity == ProblemSeverities.Ignore) return;
5512 	boolean overriding = (modifiers & (ExtraCompilerModifiers.AccImplementing|ExtraCompilerModifiers.AccOverriding)) != 0;
5513 	boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore)
5514 					&& (!overriding || this.options.reportMissingJavadocTagsOverriding);
5515 	if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) {
5516 		String[] arguments = new String[] { String.valueOf(typeRef.resolvedType.sourceName()) };
5517 		this.handle(
5518 			IProblem.JavadocMissingThrowsTag,
5519 			arguments,
5520 			arguments,
5521 			severity,
5522 			typeRef.sourceStart,
5523 			typeRef.sourceEnd);
5524 	}
5525 }
javadocUndeclaredParamTagName(char[] token, int sourceStart, int sourceEnd, int modifiers)5526 public void javadocUndeclaredParamTagName(char[] token, int sourceStart, int sourceEnd, int modifiers) {
5527 	int severity = computeSeverity(IProblem.JavadocInvalidParamName);
5528 	if (severity == ProblemSeverities.Ignore) return;
5529 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5530 		String[] arguments = new String[] {String.valueOf(token)};
5531 		this.handle(
5532 			IProblem.JavadocInvalidParamName,
5533 			arguments,
5534 			arguments,
5535 			severity,
5536 			sourceStart,
5537 			sourceEnd);
5538 	}
5539 }
5540 
javadocUnexpectedTag(int sourceStart, int sourceEnd)5541 public void javadocUnexpectedTag(int sourceStart, int sourceEnd) {
5542 	this.handle(IProblem.JavadocUnexpectedTag, NoArgument, NoArgument, sourceStart, sourceEnd);
5543 }
5544 
javadocUnexpectedText(int sourceStart, int sourceEnd)5545 public void javadocUnexpectedText(int sourceStart, int sourceEnd) {
5546 	this.handle(IProblem.JavadocUnexpectedText, NoArgument, NoArgument, sourceStart, sourceEnd);
5547 }
5548 
javadocUnterminatedInlineTag(int sourceStart, int sourceEnd)5549 public void javadocUnterminatedInlineTag(int sourceStart, int sourceEnd) {
5550 	this.handle(IProblem.JavadocUnterminatedInlineTag, NoArgument, NoArgument, sourceStart, sourceEnd);
5551 }
5552 
javadocVisibility(int visibility, int modifiers)5553 private boolean javadocVisibility(int visibility, int modifiers) {
5554 	if (modifiers < 0) return true;
5555 	switch (modifiers & ExtraCompilerModifiers.AccVisibilityMASK) {
5556 		case ClassFileConstants.AccPublic :
5557 			return true;
5558 		case ClassFileConstants.AccProtected:
5559 			return (visibility != ClassFileConstants.AccPublic);
5560 		case ClassFileConstants.AccDefault:
5561 			return (visibility == ClassFileConstants.AccDefault || visibility == ClassFileConstants.AccPrivate);
5562 		case ClassFileConstants.AccPrivate:
5563 			return (visibility == ClassFileConstants.AccPrivate);
5564 	}
5565 	return true;
5566 }
5567 
javadocVisibilityArgument(int visibility, int modifiers)5568 private String javadocVisibilityArgument(int visibility, int modifiers) {
5569 	String argument = null;
5570 	switch (modifiers & ExtraCompilerModifiers.AccVisibilityMASK) {
5571 		case ClassFileConstants.AccPublic :
5572 			argument = CompilerOptions.PUBLIC;
5573 			break;
5574 		case ClassFileConstants.AccProtected:
5575 			if (visibility != ClassFileConstants.AccPublic) {
5576 				argument = CompilerOptions.PROTECTED;
5577 			}
5578 			break;
5579 		case ClassFileConstants.AccDefault:
5580 			if (visibility == ClassFileConstants.AccDefault || visibility == ClassFileConstants.AccPrivate) {
5581 				argument = CompilerOptions.DEFAULT;
5582 			}
5583 			break;
5584 		case ClassFileConstants.AccPrivate:
5585 			if (visibility == ClassFileConstants.AccPrivate) {
5586 				argument = CompilerOptions.PRIVATE;
5587 			}
5588 			break;
5589 	}
5590 	return argument;
5591 }
5592 
localVariableHiding(LocalDeclaration local, Binding hiddenVariable, boolean isSpecialArgHidingField)5593 public void localVariableHiding(LocalDeclaration local, Binding hiddenVariable, boolean  isSpecialArgHidingField) {
5594 	if (hiddenVariable instanceof LocalVariableBinding) {
5595 		int id = (local instanceof Argument)
5596 				? IProblem.ArgumentHidingLocalVariable
5597 				: IProblem.LocalVariableHidingLocalVariable;
5598 		int severity = computeSeverity(id);
5599 		if (severity == ProblemSeverities.Ignore) return;
5600 		String[] arguments = new String[] {new String(local.name)  };
5601 		this.handle(
5602 			id,
5603 			arguments,
5604 			arguments,
5605 			severity,
5606 			nodeSourceStart(hiddenVariable, local),
5607 			nodeSourceEnd(hiddenVariable, local));
5608 	} else if (hiddenVariable instanceof FieldBinding) {
5609 		if (isSpecialArgHidingField && !this.options.reportSpecialParameterHidingField){
5610 			return;
5611 		}
5612 		int id = (local instanceof Argument)
5613 				? IProblem.ArgumentHidingField
5614 				: IProblem.LocalVariableHidingField;
5615 		int severity = computeSeverity(id);
5616 		if (severity == ProblemSeverities.Ignore) return;
5617 		FieldBinding field = (FieldBinding) hiddenVariable;
5618 		this.handle(
5619 			id,
5620 			new String[] {new String(local.name) , new String(field.declaringClass.readableName()) },
5621 			new String[] {new String(local.name), new String(field.declaringClass.shortReadableName()) },
5622 			severity,
5623 			local.sourceStart,
5624 			local.sourceEnd);
5625 	}
5626 }
5627 
localVariableNonNullComparedToNull(LocalVariableBinding local, ASTNode location)5628 public void localVariableNonNullComparedToNull(LocalVariableBinding local, ASTNode location) {
5629 	int severity = computeSeverity(IProblem.NonNullLocalVariableComparisonYieldsFalse);
5630 	if (severity == ProblemSeverities.Ignore) return;
5631 	String[] arguments;
5632 	int problemId;
5633 	if (local.isNonNull()) {
5634 		char[][] annotationName = this.options.nonNullAnnotationName; // cannot be null if local is declared @NonNull
5635 		arguments = new String[] {new String(local.name), new String(annotationName[annotationName.length-1])  };
5636 		problemId = IProblem.SpecdNonNullLocalVariableComparisonYieldsFalse;
5637 	} else {
5638 		arguments = new String[] {new String(local.name)  };
5639 		problemId = IProblem.NonNullLocalVariableComparisonYieldsFalse;
5640 	}
5641 	this.handle(
5642 		problemId,
5643 		arguments,
5644 		arguments,
5645 		severity,
5646 		nodeSourceStart(local, location),
5647 		nodeSourceEnd(local, location));
5648 }
5649 
localVariableNullComparedToNonNull(LocalVariableBinding local, ASTNode location)5650 public void localVariableNullComparedToNonNull(LocalVariableBinding local, ASTNode location) {
5651 	int severity = computeSeverity(IProblem.NullLocalVariableComparisonYieldsFalse);
5652 	if (severity == ProblemSeverities.Ignore) return;
5653 	String[] arguments = new String[] {new String(local.name)  };
5654 	this.handle(
5655 		IProblem.NullLocalVariableComparisonYieldsFalse,
5656 		arguments,
5657 		arguments,
5658 		severity,
5659 		nodeSourceStart(local, location),
5660 		nodeSourceEnd(local, location));
5661 }
5662 
5663 /**
5664  * @param expr expression being compared for null or nonnull
5665  * @param checkForNull true if checking for null, false if checking for nonnull
5666  */
expressionNonNullComparison(Expression expr, boolean checkForNull)5667 public boolean expressionNonNullComparison(Expression expr, boolean checkForNull) {
5668 	int problemId = 0;
5669 	Binding binding = null;
5670 	String[] arguments = null;
5671 	int start = 0, end = 0;
5672 	Expression location = expr;
5673 
5674 	if (expr.resolvedType != null) {
5675 		long tagBits = expr.resolvedType.tagBits & TagBits.AnnotationNullMASK;
5676 		if (tagBits == TagBits.AnnotationNonNull) {
5677 			problemId = IProblem.RedundantNullCheckAgainstNonNullType;
5678 			arguments = new String[] { String.valueOf(expr.resolvedType.nullAnnotatedReadableName(this.options, true)) };
5679 			start = nodeSourceStart(location);
5680 			end = nodeSourceEnd(location);
5681 			handle(problemId, arguments, arguments, start, end);
5682 			return true;
5683 		}
5684 	}
5685 	// unwrap uninteresting nodes:
5686 	while (true) {
5687 		if (expr instanceof Assignment)
5688 			return false; // don't report against the assignment, but the variable
5689 		else if (expr instanceof CastExpression)
5690 			expr = ((CastExpression) expr).expression;
5691 		else
5692 			break;
5693 	}
5694 	// check all those kinds of expressions that can possible answer NON_NULL from nullStatus():
5695 	if (expr instanceof MessageSend) {
5696 		problemId = checkForNull
5697 				? IProblem.NonNullMessageSendComparisonYieldsFalse
5698 				: IProblem.RedundantNullCheckOnNonNullMessageSend;
5699 		MethodBinding method = ((MessageSend)expr).binding;
5700 		binding = method;
5701 		arguments = new String[] { new String(method.shortReadableName()) };
5702 		start = location.sourceStart;
5703 		end = location.sourceEnd;
5704 	} else if (expr instanceof Reference && !(expr instanceof ThisReference) && !(expr instanceof ArrayReference)) {
5705 		FieldBinding field = ((Reference)expr).lastFieldBinding();
5706 		if (field == null) {
5707 			return false;
5708 		}
5709 		if (field.isNonNull()) {
5710 			problemId = checkForNull
5711 					? IProblem.NonNullSpecdFieldComparisonYieldsFalse
5712 					: IProblem.RedundantNullCheckOnNonNullSpecdField;
5713 			char[][] nonNullName = this.options.nonNullAnnotationName;
5714 			arguments = new String[] { new String(field.name),
5715 									   new String(nonNullName[nonNullName.length-1]) };
5716 		} else {
5717 			// signaling redundancy based on syntactic analysis:
5718 			problemId = checkForNull
5719 					? IProblem.FieldComparisonYieldsFalse
5720 					: IProblem.RedundantNullCheckOnField;
5721 			arguments = new String[] { String.valueOf(field.name)};
5722 		}
5723 		binding = field;
5724 		start = nodeSourceStart(binding, location);
5725 		end = nodeSourceEnd(binding, location);
5726 	} else if (expr instanceof AllocationExpression
5727 			|| expr instanceof ArrayAllocationExpression
5728 			|| expr instanceof ArrayInitializer
5729 			|| expr instanceof ClassLiteralAccess
5730 			|| expr instanceof ThisReference) {
5731 		// fall through to bottom
5732 	} else if (expr instanceof Literal
5733 				|| expr instanceof ConditionalExpression) {
5734 		if (expr instanceof NullLiteral) {
5735 			needImplementation(location); // reported as nonnull??
5736 			return false;
5737 		}
5738 		if (expr.resolvedType != null && expr.resolvedType.isBaseType()) {
5739 			// false alarm, auto(un)boxing is involved
5740 			return false;
5741 		}
5742 		// fall through to bottom
5743 	} else if (expr instanceof BinaryExpression) {
5744 		if ((expr.bits & ASTNode.ReturnTypeIDMASK) != TypeIds.T_JavaLangString) {
5745 			// false alarm, primitive types involved, must be auto(un)boxing?
5746 			return false;
5747 		}
5748 		// fall through to bottom
5749 	} else {
5750 		needImplementation(expr); // want to see if we get here
5751 		return false;
5752 	}
5753 	if (problemId == 0) {
5754 		// standard case, fill in details now
5755 		problemId = checkForNull
5756 				? IProblem.NonNullExpressionComparisonYieldsFalse
5757 				: IProblem.RedundantNullCheckOnNonNullExpression;
5758 		start = location.sourceStart;
5759 		end = location.sourceEnd;
5760 		arguments = NoArgument;
5761 	}
5762 	this.handle(problemId, arguments, arguments, start, end);
5763 	return true;
5764 }
nullAnnotationUnsupportedLocation(Annotation annotation)5765 public void nullAnnotationUnsupportedLocation(Annotation annotation) {
5766 	String[] arguments = new String[] {
5767 		String.valueOf(annotation.resolvedType.readableName())
5768 	};
5769 	String[] shortArguments = new String[] {
5770 		String.valueOf(annotation.resolvedType.shortReadableName())
5771 	};
5772 	handle(IProblem.NullAnnotationUnsupportedLocation,
5773 		arguments, shortArguments, annotation.sourceStart, annotation.sourceEnd);
5774 }
nullAnnotationUnsupportedLocation(TypeReference type)5775 public void nullAnnotationUnsupportedLocation(TypeReference type) {
5776 	int sourceEnd = type.sourceEnd;
5777 	if (type instanceof ParameterizedSingleTypeReference) {
5778 		ParameterizedSingleTypeReference typeReference = (ParameterizedSingleTypeReference) type;
5779 		TypeReference[] typeArguments = typeReference.typeArguments;
5780 		if (typeArguments[typeArguments.length - 1].sourceEnd > typeReference.sourceEnd) {
5781 			sourceEnd = retrieveClosingAngleBracketPosition(typeReference.sourceEnd);
5782 		} else {
5783 			sourceEnd = type.sourceEnd;
5784 		}
5785 	} else if (type instanceof ParameterizedQualifiedTypeReference) {
5786 		ParameterizedQualifiedTypeReference typeReference = (ParameterizedQualifiedTypeReference) type;
5787 		sourceEnd = retrieveClosingAngleBracketPosition(typeReference.sourceEnd);
5788 	} else {
5789 		sourceEnd = type.sourceEnd;
5790 	}
5791 
5792 	handle(IProblem.NullAnnotationUnsupportedLocationAtType,
5793 		NoArgument, NoArgument, type.sourceStart, sourceEnd);
5794 }
localVariableNullInstanceof(LocalVariableBinding local, ASTNode location)5795 public void localVariableNullInstanceof(LocalVariableBinding local, ASTNode location) {
5796 	int severity = computeSeverity(IProblem.NullLocalVariableInstanceofYieldsFalse);
5797 	if (severity == ProblemSeverities.Ignore) return;
5798 	String[] arguments = new String[] {new String(local.name)  };
5799 	this.handle(
5800 		IProblem.NullLocalVariableInstanceofYieldsFalse,
5801 		arguments,
5802 		arguments,
5803 		severity,
5804 		nodeSourceStart(local, location),
5805 		nodeSourceEnd(local, location));
5806 }
5807 
localVariableNullReference(LocalVariableBinding local, ASTNode location)5808 public void localVariableNullReference(LocalVariableBinding local, ASTNode location) {
5809 	if (location instanceof Expression && (((Expression)location).implicitConversion & TypeIds.UNBOXING) != 0) {
5810 		nullUnboxing(location, local.type);
5811 		return;
5812 	}
5813 	int severity = computeSeverity(IProblem.NullLocalVariableReference);
5814 	if (severity == ProblemSeverities.Ignore) return;
5815 	String[] arguments = new String[] {new String(local.name)  };
5816 	this.handle(
5817 		IProblem.NullLocalVariableReference,
5818 		arguments,
5819 		arguments,
5820 		severity,
5821 		nodeSourceStart(local, location),
5822 		nodeSourceEnd(local, location));
5823 }
5824 
localVariablePotentialNullReference(LocalVariableBinding local, ASTNode location)5825 public void localVariablePotentialNullReference(LocalVariableBinding local, ASTNode location) {
5826 	if (location instanceof Expression && (((Expression)location).implicitConversion & TypeIds.UNBOXING) != 0) {
5827 		potentialNullUnboxing(location, local.type);
5828 		return;
5829 	}
5830 	if ((local.type.tagBits & TagBits.AnnotationNullable) != 0 && location instanceof Expression) {
5831 		dereferencingNullableExpression((Expression) location);
5832 		return;
5833 	}
5834 	int severity = computeSeverity(IProblem.PotentialNullLocalVariableReference);
5835 	if (severity == ProblemSeverities.Ignore) return;
5836 	String[] arguments = new String[] {new String(local.name)};
5837 	this.handle(
5838 		IProblem.PotentialNullLocalVariableReference,
5839 		arguments,
5840 		arguments,
5841 		severity,
5842 		nodeSourceStart(local, location),
5843 		nodeSourceEnd(local, location));
5844 }
potentialNullUnboxing(ASTNode expression, TypeBinding boxType)5845 public void potentialNullUnboxing(ASTNode expression, TypeBinding boxType) {
5846 	String[] arguments = new String[] { String.valueOf(boxType.readableName()) };
5847 	String[] argumentsShort = new String[] { String.valueOf(boxType.shortReadableName()) };
5848 	this.handle(IProblem.PotentialNullUnboxing, arguments, argumentsShort, expression.sourceStart, expression.sourceEnd);
5849 }
nullUnboxing(ASTNode expression, TypeBinding boxType)5850 public void nullUnboxing(ASTNode expression, TypeBinding boxType) {
5851 	String[] arguments = new String[] { String.valueOf(boxType.readableName()) };
5852 	String[] argumentsShort = new String[] { String.valueOf(boxType.shortReadableName()) };
5853 	this.handle(IProblem.NullUnboxing, arguments, argumentsShort, expression.sourceStart, expression.sourceEnd);
5854 }
nullableFieldDereference(FieldBinding variable, long position)5855 public void nullableFieldDereference(FieldBinding variable, long position) {
5856 	char[][] nullableName = this.options.nullableAnnotationName;
5857 	String[] arguments = new String[] {new String(variable.name), new String(nullableName[nullableName.length-1])};
5858 	this.handle(
5859 		IProblem.NullableFieldReference,
5860 		arguments,
5861 		arguments,
5862 		(int)(position >>> 32),
5863 		(int)position);
5864 }
5865 
localVariableRedundantCheckOnNonNull(LocalVariableBinding local, ASTNode location)5866 public void localVariableRedundantCheckOnNonNull(LocalVariableBinding local, ASTNode location) {
5867 	int severity = computeSeverity(IProblem.RedundantNullCheckOnNonNullLocalVariable);
5868 	if (severity == ProblemSeverities.Ignore) return;
5869 	String[] arguments;
5870 	int problemId;
5871 	if (local.isNonNull()) {
5872 		char[][] annotationName = this.options.nonNullAnnotationName; // cannot be null if local is declared @NonNull
5873 		arguments = new String[] {new String(local.name), new String(annotationName[annotationName.length-1])  };
5874 		problemId = IProblem.RedundantNullCheckOnSpecdNonNullLocalVariable;
5875 	} else {
5876 		arguments = new String[] {new String(local.name)  };
5877 		problemId = IProblem.RedundantNullCheckOnNonNullLocalVariable;
5878 	}
5879 	this.handle(
5880 		problemId,
5881 		arguments,
5882 		arguments,
5883 		severity,
5884 		nodeSourceStart(local, location),
5885 		nodeSourceEnd(local, location));
5886 }
5887 
localVariableRedundantCheckOnNull(LocalVariableBinding local, ASTNode location)5888 public void localVariableRedundantCheckOnNull(LocalVariableBinding local, ASTNode location) {
5889 	int severity = computeSeverity(IProblem.RedundantNullCheckOnNullLocalVariable);
5890 	if (severity == ProblemSeverities.Ignore) return;
5891 	String[] arguments = new String[] {new String(local.name)  };
5892 	this.handle(
5893 		IProblem.RedundantNullCheckOnNullLocalVariable,
5894 		arguments,
5895 		arguments,
5896 		severity,
5897 		nodeSourceStart(local, location),
5898 		nodeSourceEnd(local, location));
5899 }
5900 
localVariableRedundantNullAssignment(LocalVariableBinding local, ASTNode location)5901 public void localVariableRedundantNullAssignment(LocalVariableBinding local, ASTNode location) {
5902 	if ((location.bits & ASTNode.FirstAssignmentToLocal) != 0) // https://bugs.eclipse.org/338303 - Warning about Redundant assignment conflicts with definite assignment
5903 		return;
5904 	int severity = computeSeverity(IProblem.RedundantLocalVariableNullAssignment);
5905 	if (severity == ProblemSeverities.Ignore) return;
5906 	String[] arguments = new String[] {new String(local.name)  };
5907 	this.handle(
5908 		IProblem.RedundantLocalVariableNullAssignment,
5909 		arguments,
5910 		arguments,
5911 		severity,
5912 		nodeSourceStart(local, location),
5913 		nodeSourceEnd(local, location));
5914 }
5915 
methodMustOverride(AbstractMethodDeclaration method, long complianceLevel)5916 public void methodMustOverride(AbstractMethodDeclaration method, long complianceLevel) {
5917 	MethodBinding binding = method.binding;
5918 	this.handle(
5919 		complianceLevel == ClassFileConstants.JDK1_5 ? IProblem.MethodMustOverride : IProblem.MethodMustOverrideOrImplement,
5920 		new String[] {new String(binding.selector), typesAsString(binding, false), new String(binding.declaringClass.readableName()), },
5921 		new String[] {new String(binding.selector), typesAsString(binding, true), new String(binding.declaringClass.shortReadableName()),},
5922 		method.sourceStart,
5923 		method.sourceEnd);
5924 }
5925 
methodNameClash(MethodBinding currentMethod, MethodBinding inheritedMethod, int severity)5926 public void methodNameClash(MethodBinding currentMethod, MethodBinding inheritedMethod, int severity) {
5927 	this.handle(
5928 		IProblem.MethodNameClash,
5929 		new String[] {
5930 			new String(currentMethod.selector),
5931 			typesAsString(currentMethod, false),
5932 			new String(currentMethod.declaringClass.readableName()),
5933 			typesAsString(inheritedMethod, false),
5934 			new String(inheritedMethod.declaringClass.readableName()),
5935 		 },
5936 		new String[] {
5937 			new String(currentMethod.selector),
5938 			typesAsString(currentMethod, true),
5939 			new String(currentMethod.declaringClass.shortReadableName()),
5940 			typesAsString(inheritedMethod, true),
5941 			new String(inheritedMethod.declaringClass.shortReadableName()),
5942 		 },
5943 		severity,
5944 		currentMethod.sourceStart(),
5945 		currentMethod.sourceEnd());
5946 }
5947 
methodNameClashHidden(MethodBinding currentMethod, MethodBinding inheritedMethod)5948 public void methodNameClashHidden(MethodBinding currentMethod, MethodBinding inheritedMethod) {
5949 	this.handle(
5950 		IProblem.MethodNameClashHidden,
5951 		new String[] {
5952 			new String(currentMethod.selector),
5953 			typesAsString(currentMethod, currentMethod.parameters, false),
5954 			new String(currentMethod.declaringClass.readableName()),
5955 			typesAsString(inheritedMethod, inheritedMethod.parameters, false),
5956 			new String(inheritedMethod.declaringClass.readableName()),
5957 		 },
5958 		new String[] {
5959 			new String(currentMethod.selector),
5960 			typesAsString(currentMethod, currentMethod.parameters, true),
5961 			new String(currentMethod.declaringClass.shortReadableName()),
5962 			typesAsString(inheritedMethod, inheritedMethod.parameters, true),
5963 			new String(inheritedMethod.declaringClass.shortReadableName()),
5964 		 },
5965 		currentMethod.sourceStart(),
5966 		currentMethod.sourceEnd());
5967 }
5968 
methodNeedBody(AbstractMethodDeclaration methodDecl)5969 public void methodNeedBody(AbstractMethodDeclaration methodDecl) {
5970 	this.handle(
5971 		IProblem.MethodRequiresBody,
5972 		NoArgument,
5973 		NoArgument,
5974 		methodDecl.sourceStart,
5975 		methodDecl.sourceEnd);
5976 }
5977 
methodNeedingNoBody(MethodDeclaration methodDecl)5978 public void methodNeedingNoBody(MethodDeclaration methodDecl) {
5979 	this.handle(
5980 		((methodDecl.modifiers & ClassFileConstants.AccNative) != 0) ? IProblem.BodyForNativeMethod : IProblem.BodyForAbstractMethod,
5981 		NoArgument,
5982 		NoArgument,
5983 		methodDecl.sourceStart,
5984 		methodDecl.sourceEnd);
5985 }
5986 
methodWithConstructorName(MethodDeclaration methodDecl)5987 public void methodWithConstructorName(MethodDeclaration methodDecl) {
5988 	this.handle(
5989 		IProblem.MethodButWithConstructorName,
5990 		NoArgument,
5991 		NoArgument,
5992 		methodDecl.sourceStart,
5993 		methodDecl.sourceEnd);
5994 }
5995 
methodCanBeDeclaredStatic(MethodDeclaration methodDecl)5996 public void methodCanBeDeclaredStatic(MethodDeclaration methodDecl) {
5997 	int severity = computeSeverity(IProblem.MethodCanBeStatic);
5998 	if (severity == ProblemSeverities.Ignore) return;
5999 	MethodBinding method = methodDecl.binding;
6000 	this.handle(
6001 			IProblem.MethodCanBeStatic,
6002 		new String[] {
6003 			new String(method.declaringClass.readableName()),
6004 			new String(method.selector),
6005 			typesAsString(method, false)
6006 		 },
6007 		new String[] {
6008 			new String(method.declaringClass.shortReadableName()),
6009 			new String(method.selector),
6010 			typesAsString(method, true)
6011 		 },
6012 		severity,
6013 		methodDecl.sourceStart,
6014 		methodDecl.sourceEnd);
6015 }
6016 
methodCanBePotentiallyDeclaredStatic(MethodDeclaration methodDecl)6017 public void methodCanBePotentiallyDeclaredStatic(MethodDeclaration methodDecl) {
6018 	int severity = computeSeverity(IProblem.MethodCanBePotentiallyStatic);
6019 	if (severity == ProblemSeverities.Ignore) return;
6020 	MethodBinding method = methodDecl.binding;
6021 	this.handle(
6022 			IProblem.MethodCanBePotentiallyStatic,
6023 		new String[] {
6024 			new String(method.declaringClass.readableName()),
6025 			new String(method.selector),
6026 			typesAsString(method, false)
6027 		 },
6028 		new String[] {
6029 			new String(method.declaringClass.shortReadableName()),
6030 			new String(method.selector),
6031 			typesAsString(method, true)
6032 		 },
6033 		severity,
6034 		methodDecl.sourceStart,
6035 		methodDecl.sourceEnd);
6036 }
6037 
missingDeprecatedAnnotationForField(FieldDeclaration field)6038 public void missingDeprecatedAnnotationForField(FieldDeclaration field) {
6039 	int severity = computeSeverity(IProblem.FieldMissingDeprecatedAnnotation);
6040 	if (severity == ProblemSeverities.Ignore) return;
6041 	FieldBinding binding = field.binding;
6042 	this.handle(
6043 		IProblem.FieldMissingDeprecatedAnnotation,
6044 		new String[] {new String(binding.declaringClass.readableName()), new String(binding.name), },
6045 		new String[] {new String(binding.declaringClass.shortReadableName()), new String(binding.name), },
6046 		severity,
6047 		nodeSourceStart(binding, field),
6048 		nodeSourceEnd(binding, field));
6049 }
6050 
missingDeprecatedAnnotationForMethod(AbstractMethodDeclaration method)6051 public void missingDeprecatedAnnotationForMethod(AbstractMethodDeclaration method) {
6052 	int severity = computeSeverity(IProblem.MethodMissingDeprecatedAnnotation);
6053 	if (severity == ProblemSeverities.Ignore) return;
6054 	MethodBinding binding = method.binding;
6055 	this.handle(
6056 		IProblem.MethodMissingDeprecatedAnnotation,
6057 		new String[] {new String(binding.selector), typesAsString(binding, false), new String(binding.declaringClass.readableName()), },
6058 		new String[] {new String(binding.selector), typesAsString(binding, true), new String(binding.declaringClass.shortReadableName()),},
6059 		severity,
6060 		method.sourceStart,
6061 		method.sourceEnd);
6062 }
6063 
missingDeprecatedAnnotationForType(TypeDeclaration type)6064 public void missingDeprecatedAnnotationForType(TypeDeclaration type) {
6065 	int severity = computeSeverity(IProblem.TypeMissingDeprecatedAnnotation);
6066 	if (severity == ProblemSeverities.Ignore) return;
6067 	TypeBinding binding = type.binding;
6068 	this.handle(
6069 		IProblem.TypeMissingDeprecatedAnnotation,
6070 		new String[] {new String(binding.readableName()), },
6071 		new String[] {new String(binding.shortReadableName()),},
6072 		severity,
6073 		type.sourceStart,
6074 		type.sourceEnd);
6075 }
notAFunctionalInterface(TypeDeclaration type)6076 public void notAFunctionalInterface(TypeDeclaration type) {
6077 	TypeBinding binding = type.binding;
6078 	this.handle(
6079 		IProblem.InterfaceNotFunctionalInterface,
6080 		new String[] {new String(binding.readableName()), },
6081 		new String[] {new String(binding.shortReadableName()),},
6082 		type.sourceStart,
6083 		type.sourceEnd);
6084 }
missingEnumConstantCase(SwitchStatement switchStatement, FieldBinding enumConstant)6085 public void missingEnumConstantCase(SwitchStatement switchStatement, FieldBinding enumConstant) {
6086 	this.handle(
6087 		switchStatement.defaultCase == null ? IProblem.MissingEnumConstantCase : IProblem.MissingEnumConstantCaseDespiteDefault,
6088 		new String[] {new String(enumConstant.declaringClass.readableName()), new String(enumConstant.name) },
6089 		new String[] {new String(enumConstant.declaringClass.shortReadableName()), new String(enumConstant.name) },
6090 		switchStatement.expression.sourceStart,
6091 		switchStatement.expression.sourceEnd);
6092 }
missingDefaultCase(SwitchStatement switchStatement, boolean isEnumSwitch, TypeBinding expressionType)6093 public void missingDefaultCase(SwitchStatement switchStatement, boolean isEnumSwitch, TypeBinding expressionType) {
6094 	if (isEnumSwitch) {
6095 		this.handle(
6096 				IProblem.MissingEnumDefaultCase,
6097 				new String[] {new String(expressionType.readableName())},
6098 				new String[] {new String(expressionType.shortReadableName())},
6099 				switchStatement.expression.sourceStart,
6100 				switchStatement.expression.sourceEnd);
6101 	} else {
6102 		this.handle(
6103 				IProblem.MissingDefaultCase,
6104 				NoArgument,
6105 				NoArgument,
6106 				switchStatement.expression.sourceStart,
6107 				switchStatement.expression.sourceEnd);
6108 	}
6109 }
missingOverrideAnnotation(AbstractMethodDeclaration method)6110 public void missingOverrideAnnotation(AbstractMethodDeclaration method) {
6111 	int severity = computeSeverity(IProblem.MissingOverrideAnnotation);
6112 	if (severity == ProblemSeverities.Ignore) return;
6113 	MethodBinding binding = method.binding;
6114 	this.handle(
6115 		IProblem.MissingOverrideAnnotation,
6116 		new String[] {new String(binding.selector), typesAsString(binding, false), new String(binding.declaringClass.readableName()), },
6117 		new String[] {new String(binding.selector), typesAsString(binding, true), new String(binding.declaringClass.shortReadableName()),},
6118 		severity,
6119 		method.sourceStart,
6120 		method.sourceEnd);
6121 }
missingOverrideAnnotationForInterfaceMethodImplementation(AbstractMethodDeclaration method)6122 public void missingOverrideAnnotationForInterfaceMethodImplementation(AbstractMethodDeclaration method) {
6123 	int severity = computeSeverity(IProblem.MissingOverrideAnnotationForInterfaceMethodImplementation);
6124 	if (severity == ProblemSeverities.Ignore) return;
6125 	MethodBinding binding = method.binding;
6126 	this.handle(
6127 		IProblem.MissingOverrideAnnotationForInterfaceMethodImplementation,
6128 		new String[] {new String(binding.selector), typesAsString(binding, false), new String(binding.declaringClass.readableName()), },
6129 		new String[] {new String(binding.selector), typesAsString(binding, true), new String(binding.declaringClass.shortReadableName()),},
6130 		severity,
6131 		method.sourceStart,
6132 		method.sourceEnd);
6133 }
missingReturnType(AbstractMethodDeclaration methodDecl)6134 public void missingReturnType(AbstractMethodDeclaration methodDecl) {
6135 	this.handle(
6136 		IProblem.MissingReturnType,
6137 		NoArgument,
6138 		NoArgument,
6139 		methodDecl.sourceStart,
6140 		methodDecl.sourceEnd);
6141 }
missingSemiColon(Expression expression)6142 public void missingSemiColon(Expression expression){
6143 	this.handle(
6144 		IProblem.MissingSemiColon,
6145 		NoArgument,
6146 		NoArgument,
6147 		expression.sourceStart,
6148 		expression.sourceEnd);
6149 }
missingSerialVersion(TypeDeclaration typeDecl)6150 public void missingSerialVersion(TypeDeclaration typeDecl) {
6151 	String[] arguments = new String[] {new String(typeDecl.name)};
6152 	this.handle(
6153 		IProblem.MissingSerialVersion,
6154 		arguments,
6155 		arguments,
6156 		typeDecl.sourceStart,
6157 		typeDecl.sourceEnd);
6158 }
missingSynchronizedOnInheritedMethod(MethodBinding currentMethod, MethodBinding inheritedMethod)6159 public void missingSynchronizedOnInheritedMethod(MethodBinding currentMethod, MethodBinding inheritedMethod) {
6160 	this.handle(
6161 			IProblem.MissingSynchronizedModifierInInheritedMethod,
6162 			new String[] {
6163 					new String(currentMethod.declaringClass.readableName()),
6164 					new String(currentMethod.selector),
6165 					typesAsString(currentMethod, false),
6166 			},
6167 			new String[] {
6168 					new String(currentMethod.declaringClass.shortReadableName()),
6169 					new String(currentMethod.selector),
6170 					typesAsString(currentMethod, true),
6171 			},
6172 			currentMethod.sourceStart(),
6173 			currentMethod.sourceEnd());
6174 }
missingTypeInConstructor(ASTNode location, MethodBinding constructor)6175 public void missingTypeInConstructor(ASTNode location, MethodBinding constructor) {
6176 	List missingTypes = constructor.collectMissingTypes(null);
6177 	if (missingTypes == null) {
6178 		System.err.println("The constructor " + constructor + " is wrongly tagged as containing missing types"); //$NON-NLS-1$ //$NON-NLS-2$
6179 		return;
6180 	}
6181 	TypeBinding missingType = (TypeBinding) missingTypes.get(0);
6182 	int start = location.sourceStart;
6183 	int end = location.sourceEnd;
6184 	if (location instanceof QualifiedAllocationExpression) {
6185 		QualifiedAllocationExpression qualifiedAllocation = (QualifiedAllocationExpression) location;
6186 		if (qualifiedAllocation.anonymousType != null) {
6187 			start = qualifiedAllocation.anonymousType.sourceStart;
6188 			end = qualifiedAllocation.anonymousType.sourceEnd;
6189 		}
6190 	}
6191 	this.handle(
6192 			IProblem.MissingTypeInConstructor,
6193 			new String[] {
6194 			        new String(constructor.declaringClass.readableName()),
6195 			        typesAsString(constructor, false),
6196 			       	new String(missingType.readableName()),
6197 			},
6198 			new String[] {
6199 			        new String(constructor.declaringClass.shortReadableName()),
6200 			        typesAsString(constructor, true),
6201 			       	new String(missingType.shortReadableName()),
6202 			},
6203 			start,
6204 			end);
6205 }
missingTypeInLambda(LambdaExpression lambda, MethodBinding method)6206 public void missingTypeInLambda(LambdaExpression lambda, MethodBinding method) {
6207 	int nameSourceStart = lambda.sourceStart();
6208 	int nameSourceEnd = lambda.diagnosticsSourceEnd();
6209 	List missingTypes = method.collectMissingTypes(null);
6210 	if (missingTypes == null) {
6211 		System.err.println("The lambda expression " + method + " is wrongly tagged as containing missing types"); //$NON-NLS-1$ //$NON-NLS-2$
6212 		return;
6213 	}
6214 	TypeBinding missingType = (TypeBinding) missingTypes.get(0);
6215 	this.handle(
6216 			IProblem.MissingTypeInLambda,
6217 			new String[] {
6218 			        new String(missingType.readableName()),
6219 			},
6220 			new String[] {
6221 			        new String(missingType.shortReadableName()),
6222 			},
6223 			nameSourceStart,
6224 			nameSourceEnd);
6225 }
missingTypeInMethod(ASTNode astNode, MethodBinding method)6226 public void missingTypeInMethod(ASTNode astNode, MethodBinding method) {
6227 	int nameSourceStart, nameSourceEnd;
6228 	if (astNode instanceof MessageSend) {
6229 		MessageSend messageSend = astNode instanceof MessageSend ? (MessageSend) (astNode) : null;
6230 		nameSourceStart = (int) (messageSend.nameSourcePosition >>> 32);
6231 		nameSourceEnd = (int) messageSend.nameSourcePosition;
6232 	} else {
6233 		nameSourceStart = astNode.sourceStart;
6234 		nameSourceEnd = astNode.sourceEnd;
6235 	}
6236 	List missingTypes = method.collectMissingTypes(null);
6237 	if (missingTypes == null) {
6238 		System.err.println("The method " + method + " is wrongly tagged as containing missing types"); //$NON-NLS-1$ //$NON-NLS-2$
6239 		return;
6240 	}
6241 	TypeBinding missingType = (TypeBinding) missingTypes.get(0);
6242 	this.handle(
6243 			IProblem.MissingTypeInMethod,
6244 			new String[] {
6245 			        new String(method.declaringClass.readableName()),
6246 			        new String(method.selector),
6247 			        typesAsString(method, false),
6248 			       	new String(missingType.readableName()),
6249 			},
6250 			new String[] {
6251 			        new String(method.declaringClass.shortReadableName()),
6252 			        new String(method.selector),
6253 			        typesAsString(method, true),
6254 			       	new String(missingType.shortReadableName()),
6255 			},
6256 			nameSourceStart,
6257 			nameSourceEnd);
6258 }
missingValueForAnnotationMember(Annotation annotation, char[] memberName)6259 public void missingValueForAnnotationMember(Annotation annotation, char[] memberName) {
6260 	String memberString = new String(memberName);
6261 	this.handle(
6262 		IProblem.MissingValueForAnnotationMember,
6263 		new String[] {new String(annotation.resolvedType.readableName()), memberString },
6264 		new String[] {new String(annotation.resolvedType.shortReadableName()), memberString},
6265 		annotation.sourceStart,
6266 		annotation.sourceEnd);
6267 }
mustDefineDimensionsOrInitializer(ArrayAllocationExpression expression)6268 public void mustDefineDimensionsOrInitializer(ArrayAllocationExpression expression) {
6269 	this.handle(
6270 		IProblem.MustDefineEitherDimensionExpressionsOrInitializer,
6271 		NoArgument,
6272 		NoArgument,
6273 		expression.sourceStart,
6274 		expression.sourceEnd);
6275 }
mustUseAStaticMethod(MessageSend messageSend, MethodBinding method)6276 public void mustUseAStaticMethod(MessageSend messageSend, MethodBinding method) {
6277 	this.handle(
6278 		IProblem.StaticMethodRequested,
6279 		new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method, false)},
6280 		new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method, true)},
6281 		messageSend.sourceStart,
6282 		messageSend.sourceEnd);
6283 }
nativeMethodsCannotBeStrictfp(ReferenceBinding type, AbstractMethodDeclaration methodDecl)6284 public void nativeMethodsCannotBeStrictfp(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
6285 	String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
6286 	this.handle(
6287 		IProblem.NativeMethodsCannotBeStrictfp,
6288 		arguments,
6289 		arguments,
6290 		methodDecl.sourceStart,
6291 		methodDecl.sourceEnd);
6292 }
needImplementation(ASTNode location)6293 public void needImplementation(ASTNode location) {
6294 	this.abortDueToInternalError(Messages.abort_missingCode, location);
6295 }
6296 
needToEmulateFieldAccess(FieldBinding field, ASTNode location, boolean isReadAccess)6297 public void needToEmulateFieldAccess(FieldBinding field, ASTNode location, boolean isReadAccess) {
6298 	int id = isReadAccess
6299 			? IProblem.NeedToEmulateFieldReadAccess
6300 			: IProblem.NeedToEmulateFieldWriteAccess;
6301 	int severity = computeSeverity(id);
6302 	if (severity == ProblemSeverities.Ignore) return;
6303 	this.handle(
6304 		id,
6305 		new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
6306 		new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
6307 		severity,
6308 		nodeSourceStart(field, location),
6309 		nodeSourceEnd(field, location));
6310 }
needToEmulateMethodAccess( MethodBinding method, ASTNode location)6311 public void needToEmulateMethodAccess(
6312 	MethodBinding method,
6313 	ASTNode location) {
6314 
6315 	if (method.isConstructor()) {
6316 		int severity = computeSeverity(IProblem.NeedToEmulateConstructorAccess);
6317 		if (severity == ProblemSeverities.Ignore) return;
6318 		if (method.declaringClass.isEnum())
6319 			return; // tolerate emulation for enum constructors, which can only be made private
6320 		this.handle(
6321 			IProblem.NeedToEmulateConstructorAccess,
6322 			new String[] {
6323 				new String(method.declaringClass.readableName()),
6324 				typesAsString(method, false)
6325 			 },
6326 			new String[] {
6327 				new String(method.declaringClass.shortReadableName()),
6328 				typesAsString(method, true)
6329 			 },
6330 			severity,
6331 			location.sourceStart,
6332 			location.sourceEnd);
6333 		return;
6334 	}
6335 	int severity = computeSeverity(IProblem.NeedToEmulateMethodAccess);
6336 	if (severity == ProblemSeverities.Ignore) return;
6337 	this.handle(
6338 		IProblem.NeedToEmulateMethodAccess,
6339 		new String[] {
6340 			new String(method.declaringClass.readableName()),
6341 			new String(method.selector),
6342 			typesAsString(method, false)
6343 		 },
6344 		new String[] {
6345 			new String(method.declaringClass.shortReadableName()),
6346 			new String(method.selector),
6347 			typesAsString(method, true)
6348 		 },
6349 		 severity,
6350 		location.sourceStart,
6351 		location.sourceEnd);
6352 }
noAdditionalBoundAfterTypeVariable(TypeReference boundReference)6353 public void noAdditionalBoundAfterTypeVariable(TypeReference boundReference) {
6354 	this.handle(
6355 		IProblem.NoAdditionalBoundAfterTypeVariable,
6356 		new String[] { new String(boundReference.resolvedType.readableName()) },
6357 		new String[] { new String(boundReference.resolvedType.shortReadableName()) },
6358 		boundReference.sourceStart,
6359 		boundReference.sourceEnd);
6360 }
nodeSourceEnd(ASTNode node)6361 private int nodeSourceEnd(ASTNode node) {
6362 	if (node instanceof Reference) {
6363 		Binding field = ((Reference) node).lastFieldBinding();
6364 		if (field != null)
6365 			return nodeSourceEnd(field, node);
6366 	}
6367 	return node.sourceEnd;
6368 }
nodeSourceEnd(Binding field, ASTNode node)6369 private int nodeSourceEnd(Binding field, ASTNode node) {
6370 	return nodeSourceEnd(field, node, 0);
6371 }
nodeSourceEnd(Binding field, ASTNode node, int index)6372 private int nodeSourceEnd(Binding field, ASTNode node, int index) {
6373 	if (node instanceof ArrayTypeReference) {
6374 		return ((ArrayTypeReference) node).originalSourceEnd;
6375 	} else if (node instanceof QualifiedNameReference) {
6376 		QualifiedNameReference ref = (QualifiedNameReference) node;
6377 		if (ref.binding == field) {
6378 			if (index == 0) {
6379 				return (int) (ref.sourcePositions[ref.indexOfFirstFieldBinding-1]);
6380 			} else {
6381 				int length = ref.sourcePositions.length;
6382 				if (index < length) {
6383 					return (int) (ref.sourcePositions[index]);
6384 				}
6385 				return (int) (ref.sourcePositions[0]);
6386 			}
6387 		}
6388 		FieldBinding[] otherFields = ref.otherBindings;
6389 		if (otherFields != null) {
6390 			int offset = ref.indexOfFirstFieldBinding;
6391 			if (index != 0) {
6392 				for (int i = 0, length = otherFields.length; i < length; i++) {
6393 					if ((otherFields[i] == field) && (i + offset == index)) {
6394 						return (int) (ref.sourcePositions[i + offset]);
6395 					}
6396 				}
6397 			} else {
6398 				for (int i = 0, length = otherFields.length; i < length; i++) {
6399 					if (otherFields[i] == field)
6400 						return (int) (ref.sourcePositions[i + offset]);
6401 				}
6402 			}
6403 		}
6404 	} else if (node instanceof ParameterizedQualifiedTypeReference) {
6405 		ParameterizedQualifiedTypeReference reference = (ParameterizedQualifiedTypeReference) node;
6406 		if (index < reference.sourcePositions.length) {
6407 			return (int) reference.sourcePositions[index];
6408 		}
6409 	} else if (node instanceof ArrayQualifiedTypeReference) {
6410 		ArrayQualifiedTypeReference reference = (ArrayQualifiedTypeReference) node;
6411 		int length = reference.sourcePositions.length;
6412 		if (index < length) {
6413 			return (int) reference.sourcePositions[index];
6414 		}
6415 		return (int) reference.sourcePositions[length - 1];
6416 	} else if (node instanceof QualifiedTypeReference) {
6417 		QualifiedTypeReference reference = (QualifiedTypeReference) node;
6418 		int length = reference.sourcePositions.length;
6419 		if (index < length) {
6420 			return (int) reference.sourcePositions[index];
6421 		}
6422 	}
6423 	return node.sourceEnd;
6424 }
nodeSourceStart(ASTNode node)6425 private int nodeSourceStart(ASTNode node) {
6426 	if (node instanceof Reference) {
6427 		Binding field = ((Reference) node).lastFieldBinding();
6428 		if (field != null)
6429 			return nodeSourceStart(field, node);
6430 	}
6431 	return node.sourceStart;
6432 }
nodeSourceStart(Binding field, ASTNode node)6433 private int nodeSourceStart(Binding field, ASTNode node) {
6434 	return nodeSourceStart(field, node, 0);
6435 }
nodeSourceStart(Binding field, ASTNode node, int index)6436 private int nodeSourceStart(Binding field, ASTNode node, int index) {
6437 	if (node instanceof FieldReference) {
6438 		FieldReference fieldReference = (FieldReference) node;
6439 		return (int) (fieldReference.nameSourcePosition >> 32);
6440 	} else 	if (node instanceof QualifiedNameReference) {
6441 		QualifiedNameReference ref = (QualifiedNameReference) node;
6442 		if (ref.binding == field) {
6443 			if (index == 0) {
6444 				return (int) (ref.sourcePositions[ref.indexOfFirstFieldBinding-1] >> 32);
6445 			} else {
6446 				return (int) (ref.sourcePositions[index] >> 32);
6447 			}
6448 		}
6449 		FieldBinding[] otherFields = ref.otherBindings;
6450 		if (otherFields != null) {
6451 			int offset = ref.indexOfFirstFieldBinding;
6452 			if (index != 0) {
6453 				for (int i = 0, length = otherFields.length; i < length; i++) {
6454 					if ((otherFields[i] == field) && (i + offset == index)) {
6455 						return (int) (ref.sourcePositions[i + offset] >> 32);
6456 					}
6457 				}
6458 			} else {
6459 				for (int i = 0, length = otherFields.length; i < length; i++) {
6460 					if (otherFields[i] == field) {
6461 						return (int) (ref.sourcePositions[i + offset] >> 32);
6462 					}
6463 				}
6464 			}
6465 		}
6466 	} else if (node instanceof ParameterizedQualifiedTypeReference) {
6467 		ParameterizedQualifiedTypeReference reference = (ParameterizedQualifiedTypeReference) node;
6468 		return (int) (reference.sourcePositions[0]>>>32);
6469 	}
6470 	return node.sourceStart;
6471 }
noMoreAvailableSpaceForArgument(LocalVariableBinding local, ASTNode location)6472 public void noMoreAvailableSpaceForArgument(LocalVariableBinding local, ASTNode location) {
6473 	String[] arguments = new String[]{ new String(local.name) };
6474 	this.handle(
6475 		local instanceof SyntheticArgumentBinding
6476 			? IProblem.TooManySyntheticArgumentSlots
6477 			: IProblem.TooManyArgumentSlots,
6478 		arguments,
6479 		arguments,
6480 		ProblemSeverities.Abort | ProblemSeverities.Error | ProblemSeverities.Fatal,
6481 		nodeSourceStart(local, location),
6482 		nodeSourceEnd(local, location));
6483 }
noMoreAvailableSpaceForConstant(TypeDeclaration typeDeclaration)6484 public void noMoreAvailableSpaceForConstant(TypeDeclaration typeDeclaration) {
6485 	this.handle(
6486 		IProblem.TooManyBytesForStringConstant,
6487 		new String[]{ new String(typeDeclaration.binding.readableName())},
6488 		new String[]{ new String(typeDeclaration.binding.shortReadableName())},
6489 		ProblemSeverities.Abort | ProblemSeverities.Error | ProblemSeverities.Fatal,
6490 		typeDeclaration.sourceStart,
6491 		typeDeclaration.sourceEnd);
6492 }
6493 
noMoreAvailableSpaceForLocal(LocalVariableBinding local, ASTNode location)6494 public void noMoreAvailableSpaceForLocal(LocalVariableBinding local, ASTNode location) {
6495 	String[] arguments = new String[]{ new String(local.name) };
6496 	this.handle(
6497 		IProblem.TooManyLocalVariableSlots,
6498 		arguments,
6499 		arguments,
6500 		ProblemSeverities.Abort | ProblemSeverities.Error | ProblemSeverities.Fatal,
6501 		nodeSourceStart(local, location),
6502 		nodeSourceEnd(local, location));
6503 }
noMoreAvailableSpaceInConstantPool(TypeDeclaration typeDeclaration)6504 public void noMoreAvailableSpaceInConstantPool(TypeDeclaration typeDeclaration) {
6505 	this.handle(
6506 		IProblem.TooManyConstantsInConstantPool,
6507 		new String[]{ new String(typeDeclaration.binding.readableName())},
6508 		new String[]{ new String(typeDeclaration.binding.shortReadableName())},
6509 		ProblemSeverities.Abort | ProblemSeverities.Error | ProblemSeverities.Fatal,
6510 		typeDeclaration.sourceStart,
6511 		typeDeclaration.sourceEnd);
6512 }
6513 
nonExternalizedStringLiteral(ASTNode location)6514 public void nonExternalizedStringLiteral(ASTNode location) {
6515 	this.handle(
6516 		IProblem.NonExternalizedStringLiteral,
6517 		NoArgument,
6518 		NoArgument,
6519 		location.sourceStart,
6520 		location.sourceEnd);
6521 }
6522 
nonGenericTypeCannotBeParameterized(int index, ASTNode location, TypeBinding type, TypeBinding[] argumentTypes)6523 public void nonGenericTypeCannotBeParameterized(int index, ASTNode location, TypeBinding type, TypeBinding[] argumentTypes) {
6524 	if (location == null) { // binary case
6525 	    this.handle(
6526 			IProblem.NonGenericType,
6527 			new String[] {new String(type.readableName()), typesAsString(argumentTypes, false)},
6528 			new String[] {new String(type.shortReadableName()), typesAsString(argumentTypes, true)},
6529 			ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
6530 			0,
6531 			0);
6532 	    return;
6533 	}
6534     this.handle(
6535 		IProblem.NonGenericType,
6536 		new String[] {new String(type.readableName()), typesAsString(argumentTypes, false)},
6537 		new String[] {new String(type.shortReadableName()), typesAsString(argumentTypes, true)},
6538 		nodeSourceStart(null, location),
6539 		nodeSourceEnd(null, location, index));
6540 }
nonStaticAccessToStaticField(ASTNode location, FieldBinding field)6541 public void nonStaticAccessToStaticField(ASTNode location, FieldBinding field) {
6542 	nonStaticAccessToStaticField(location, field, -1);
6543 }
nonStaticAccessToStaticField(ASTNode location, FieldBinding field, int index)6544 public void nonStaticAccessToStaticField(ASTNode location, FieldBinding field, int index) {
6545 	int severity = computeSeverity(IProblem.NonStaticAccessToStaticField);
6546 	if (severity == ProblemSeverities.Ignore) return;
6547 	this.handle(
6548 		IProblem.NonStaticAccessToStaticField,
6549 		new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
6550 		new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
6551 		severity,
6552 		nodeSourceStart(field, location, index),
6553 		nodeSourceEnd(field, location, index));
6554 }
nonStaticAccessToStaticMethod(ASTNode location, MethodBinding method)6555 public void nonStaticAccessToStaticMethod(ASTNode location, MethodBinding method) {
6556 	this.handle(
6557 		IProblem.NonStaticAccessToStaticMethod,
6558 		new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method, false)},
6559 		new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method, true)},
6560 		location.sourceStart,
6561 		location.sourceEnd);
6562 }
nonStaticContextForEnumMemberType(SourceTypeBinding type)6563 public void nonStaticContextForEnumMemberType(SourceTypeBinding type) {
6564 	String[] arguments = new String[] {new String(type.sourceName())};
6565 	this.handle(
6566 		IProblem.NonStaticContextForEnumMemberType,
6567 		arguments,
6568 		arguments,
6569 		type.sourceStart(),
6570 		type.sourceEnd());
6571 }
noSuchEnclosingInstance(TypeBinding targetType, ASTNode location, boolean isConstructorCall)6572 public void noSuchEnclosingInstance(TypeBinding targetType, ASTNode location, boolean isConstructorCall) {
6573 
6574 	int id;
6575 
6576 	if (isConstructorCall) {
6577 		//28 = No enclosing instance of type {0} is available due to some intermediate constructor invocation
6578 		id = IProblem.EnclosingInstanceInConstructorCall;
6579 	} else if ((location instanceof ExplicitConstructorCall)
6580 				&& ((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper) {
6581 		//20 = No enclosing instance of type {0} is accessible to invoke the super constructor. Must define a constructor and explicitly qualify its super constructor invocation with an instance of {0} (e.g. x.super() where x is an instance of {0}).
6582 		id = IProblem.MissingEnclosingInstanceForConstructorCall;
6583 	} else if (location instanceof AllocationExpression
6584 				&& (((AllocationExpression) location).binding.declaringClass.isMemberType()
6585 					|| (((AllocationExpression) location).binding.declaringClass.isAnonymousType()
6586 						&& ((AllocationExpression) location).binding.declaringClass.superclass().isMemberType()))) {
6587 		//21 = No enclosing instance of type {0} is accessible. Must qualify the allocation with an enclosing instance of type {0} (e.g. x.new A() where x is an instance of {0}).
6588 		id = IProblem.MissingEnclosingInstance;
6589 	} else { // default
6590 		//22 = No enclosing instance of the type {0} is accessible in scope
6591 		id = IProblem.IncorrectEnclosingInstanceReference;
6592 	}
6593 
6594 	this.handle(
6595 		id,
6596 		new String[] { new String(targetType.readableName())},
6597 		new String[] { new String(targetType.shortReadableName())},
6598 		location.sourceStart,
6599 		location instanceof LambdaExpression ? ((LambdaExpression)location).diagnosticsSourceEnd() : location.sourceEnd);
6600 }
notCompatibleTypesError(EqualExpression expression, TypeBinding leftType, TypeBinding rightType)6601 public void notCompatibleTypesError(EqualExpression expression, TypeBinding leftType, TypeBinding rightType) {
6602 	String leftName = new String(leftType.readableName());
6603 	String rightName = new String(rightType.readableName());
6604 	String leftShortName = new String(leftType.shortReadableName());
6605 	String rightShortName = new String(rightType.shortReadableName());
6606 	if (leftShortName.equals(rightShortName)){
6607 		leftShortName = leftName;
6608 		rightShortName = rightName;
6609 	}
6610 	this.handle(
6611 		IProblem.IncompatibleTypesInEqualityOperator,
6612 		new String[] {leftName, rightName },
6613 		new String[] {leftShortName, rightShortName },
6614 		expression.sourceStart,
6615 		expression.sourceEnd);
6616 }
notCompatibleTypesError(InstanceOfExpression expression, TypeBinding leftType, TypeBinding rightType)6617 public void notCompatibleTypesError(InstanceOfExpression expression, TypeBinding leftType, TypeBinding rightType) {
6618 	String leftName = new String(leftType.readableName());
6619 	String rightName = new String(rightType.readableName());
6620 	String leftShortName = new String(leftType.shortReadableName());
6621 	String rightShortName = new String(rightType.shortReadableName());
6622 	if (leftShortName.equals(rightShortName)){
6623 		leftShortName = leftName;
6624 		rightShortName = rightName;
6625 	}
6626 	this.handle(
6627 		IProblem.IncompatibleTypesInConditionalOperator,
6628 		new String[] {leftName, rightName },
6629 		new String[] {leftShortName, rightShortName },
6630 		expression.sourceStart,
6631 		expression.sourceEnd);
6632 }
notCompatibleTypesErrorInForeach(Expression expression, TypeBinding leftType, TypeBinding rightType)6633 public void notCompatibleTypesErrorInForeach(Expression expression, TypeBinding leftType, TypeBinding rightType) {
6634 	String leftName = new String(leftType.readableName());
6635 	String rightName = new String(rightType.readableName());
6636 	String leftShortName = new String(leftType.shortReadableName());
6637 	String rightShortName = new String(rightType.shortReadableName());
6638 	if (leftShortName.equals(rightShortName)){
6639 		leftShortName = leftName;
6640 		rightShortName = rightName;
6641 	}
6642 	this.handle(
6643 		IProblem.IncompatibleTypesInForeach,
6644 		new String[] {leftName, rightName },
6645 		new String[] {leftShortName, rightShortName },
6646 		expression.sourceStart,
6647 		expression.sourceEnd);
6648 }
objectCannotBeGeneric(TypeDeclaration typeDecl)6649 public void objectCannotBeGeneric(TypeDeclaration typeDecl) {
6650 	this.handle(
6651 		IProblem.ObjectCannotBeGeneric,
6652 		NoArgument,
6653 		NoArgument,
6654 		typeDecl.typeParameters[0].sourceStart,
6655 		typeDecl.typeParameters[typeDecl.typeParameters.length-1].sourceEnd);
6656 }
objectCannotHaveSuperTypes(SourceTypeBinding type)6657 public void objectCannotHaveSuperTypes(SourceTypeBinding type) {
6658 	this.handle(
6659 		IProblem.ObjectCannotHaveSuperTypes,
6660 		NoArgument,
6661 		NoArgument,
6662 		type.sourceStart(),
6663 		type.sourceEnd());
6664 }
objectMustBeClass(SourceTypeBinding type)6665 public void objectMustBeClass(SourceTypeBinding type) {
6666 	this.handle(
6667 		IProblem.ObjectMustBeClass,
6668 		NoArgument,
6669 		NoArgument,
6670 		type.sourceStart(),
6671 		type.sourceEnd());
6672 }
operatorOnlyValidOnNumericType(CompoundAssignment assignment, TypeBinding leftType, TypeBinding rightType)6673 public void operatorOnlyValidOnNumericType(CompoundAssignment  assignment, TypeBinding leftType, TypeBinding rightType) {
6674 	String leftName = new String(leftType.readableName());
6675 	String rightName = new String(rightType.readableName());
6676 	String leftShortName = new String(leftType.shortReadableName());
6677 	String rightShortName = new String(rightType.shortReadableName());
6678 	if (leftShortName.equals(rightShortName)){
6679 		leftShortName = leftName;
6680 		rightShortName = rightName;
6681 	}
6682 	this.handle(
6683 		IProblem.TypeMismatch,
6684 		new String[] {leftName, rightName },
6685 		new String[] {leftShortName, rightShortName },
6686 		assignment.sourceStart,
6687 		assignment.sourceEnd);
6688 }
overridesDeprecatedMethod(MethodBinding localMethod, MethodBinding inheritedMethod)6689 public void overridesDeprecatedMethod(MethodBinding localMethod, MethodBinding inheritedMethod) {
6690 	this.handle(
6691 		IProblem.OverridingDeprecatedMethod,
6692 		new String[] {
6693 			new String(
6694 					CharOperation.concat(
6695 						localMethod.declaringClass.readableName(),
6696 						localMethod.readableName(),
6697 						'.')),
6698 			new String(inheritedMethod.declaringClass.readableName())},
6699 		new String[] {
6700 			new String(
6701 					CharOperation.concat(
6702 						localMethod.declaringClass.shortReadableName(),
6703 						localMethod.shortReadableName(),
6704 						'.')),
6705 			new String(inheritedMethod.declaringClass.shortReadableName())},
6706 		localMethod.sourceStart(),
6707 		localMethod.sourceEnd());
6708 }
overridesMethodWithoutSuperInvocation(MethodBinding localMethod)6709 public void overridesMethodWithoutSuperInvocation(MethodBinding localMethod) {
6710 	this.handle(
6711 		IProblem.OverridingMethodWithoutSuperInvocation,
6712 		new String[] {
6713 			new String(
6714 					CharOperation.concat(
6715 						localMethod.declaringClass.readableName(),
6716 						localMethod.readableName(),
6717 						'.'))
6718 			},
6719 		new String[] {
6720 			new String(
6721 					CharOperation.concat(
6722 						localMethod.declaringClass.shortReadableName(),
6723 						localMethod.shortReadableName(),
6724 						'.'))
6725 			},
6726 		localMethod.sourceStart(),
6727 		localMethod.sourceEnd());
6728 }
overridesPackageDefaultMethod(MethodBinding localMethod, MethodBinding inheritedMethod)6729 public void overridesPackageDefaultMethod(MethodBinding localMethod, MethodBinding inheritedMethod) {
6730 	this.handle(
6731 		IProblem.OverridingNonVisibleMethod,
6732 		new String[] {
6733 			new String(
6734 					CharOperation.concat(
6735 						localMethod.declaringClass.readableName(),
6736 						localMethod.readableName(),
6737 						'.')),
6738 			new String(inheritedMethod.declaringClass.readableName())},
6739 		new String[] {
6740 			new String(
6741 					CharOperation.concat(
6742 						localMethod.declaringClass.shortReadableName(),
6743 						localMethod.shortReadableName(),
6744 						'.')),
6745 			new String(inheritedMethod.declaringClass.shortReadableName())},
6746 		localMethod.sourceStart(),
6747 		localMethod.sourceEnd());
6748 }
packageCollidesWithType(CompilationUnitDeclaration compUnitDecl)6749 public void packageCollidesWithType(CompilationUnitDeclaration compUnitDecl) {
6750 	String[] arguments = new String[] {CharOperation.toString(compUnitDecl.currentPackage.tokens)};
6751 	this.handle(
6752 		IProblem.PackageCollidesWithType,
6753 		arguments,
6754 		arguments,
6755 		compUnitDecl.currentPackage.sourceStart,
6756 		compUnitDecl.currentPackage.sourceEnd);
6757 }
packageIsNotExpectedPackage(CompilationUnitDeclaration compUnitDecl)6758 public void packageIsNotExpectedPackage(CompilationUnitDeclaration compUnitDecl) {
6759 	boolean hasPackageDeclaration = compUnitDecl.currentPackage == null;
6760 	String[] arguments = new String[] {
6761 		CharOperation.toString(compUnitDecl.compilationResult.compilationUnit.getPackageName()),
6762 		hasPackageDeclaration ? "" : CharOperation.toString(compUnitDecl.currentPackage.tokens), //$NON-NLS-1$
6763 	};
6764 	int end;
6765 	if (compUnitDecl.sourceEnd <= 0) {
6766 		end = -1;
6767 	} else {
6768 		end = hasPackageDeclaration ? 0 : compUnitDecl.currentPackage.sourceEnd;
6769 	}
6770 	this.handle(
6771 		IProblem.PackageIsNotExpectedPackage,
6772 		arguments,
6773 		arguments,
6774 		hasPackageDeclaration ? 0 : compUnitDecl.currentPackage.sourceStart,
6775 		end);
6776 }
parameterAssignment(LocalVariableBinding local, ASTNode location)6777 public void parameterAssignment(LocalVariableBinding local, ASTNode location) {
6778 	int severity = computeSeverity(IProblem.ParameterAssignment);
6779 	if (severity == ProblemSeverities.Ignore) return;
6780 	String[] arguments = new String[] { new String(local.readableName())};
6781 	this.handle(
6782 		IProblem.ParameterAssignment,
6783 		arguments,
6784 		arguments,
6785 		severity,
6786 		nodeSourceStart(local, location),
6787 		nodeSourceEnd(local, location)); // should never be a qualified name reference
6788 }
parameterBoundAsString(TypeVariableBinding typeVariable, boolean makeShort)6789 private String parameterBoundAsString(TypeVariableBinding typeVariable, boolean makeShort) {
6790     StringBuffer nameBuffer = new StringBuffer(10);
6791     if (TypeBinding.equalsEquals(typeVariable.firstBound, typeVariable.superclass)) {
6792         nameBuffer.append(makeShort ? typeVariable.superclass.shortReadableName() : typeVariable.superclass.readableName());
6793     }
6794     int length;
6795     if ((length = typeVariable.superInterfaces.length) > 0) {
6796 	    for (int i = 0; i < length; i++) {
6797 	        if (i > 0 || TypeBinding.equalsEquals(typeVariable.firstBound, typeVariable.superclass)) nameBuffer.append(" & "); //$NON-NLS-1$
6798 	        nameBuffer.append(makeShort ? typeVariable.superInterfaces[i].shortReadableName() : typeVariable.superInterfaces[i].readableName());
6799 	    }
6800 	}
6801 	return nameBuffer.toString();
6802 }
parameterizedMemberTypeMissingArguments(ASTNode location, TypeBinding type, int index)6803 public void parameterizedMemberTypeMissingArguments(ASTNode location, TypeBinding type, int index) {
6804 	if (location == null) { // binary case
6805 	    this.handle(
6806 			IProblem.MissingArgumentsForParameterizedMemberType,
6807 			new String[] {new String(type.readableName())},
6808 			new String[] {new String(type.shortReadableName())},
6809 			ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
6810 			0,
6811 			0);
6812 	    return;
6813 	}
6814     this.handle(
6815 		IProblem.MissingArgumentsForParameterizedMemberType,
6816 		new String[] {new String(type.readableName())},
6817 		new String[] {new String(type.shortReadableName())},
6818 		location.sourceStart,
6819 		nodeSourceEnd(null, location, index));
6820 }
parseError( int startPosition, int endPosition, int currentToken, char[] currentTokenSource, String errorTokenName, String[] possibleTokens)6821 public void parseError(
6822 	int startPosition,
6823 	int endPosition,
6824 	int currentToken,
6825 	char[] currentTokenSource,
6826 	String errorTokenName,
6827 	String[] possibleTokens) {
6828 
6829 	if (possibleTokens.length == 0) { //no suggestion available
6830 		if (isKeyword(currentToken)) {
6831 			String[] arguments = new String[] {new String(currentTokenSource)};
6832 			this.handle(
6833 				IProblem.ParsingErrorOnKeywordNoSuggestion,
6834 				arguments,
6835 				arguments,
6836 				// this is the current -invalid- token position
6837 				startPosition,
6838 				endPosition);
6839 			return;
6840 		} else {
6841 			String[] arguments = new String[] {errorTokenName};
6842 			this.handle(
6843 				IProblem.ParsingErrorNoSuggestion,
6844 				arguments,
6845 				arguments,
6846 				// this is the current -invalid- token position
6847 				startPosition,
6848 				endPosition);
6849 			return;
6850 		}
6851 	}
6852 
6853 	//build a list of probable right tokens
6854 	StringBuffer list = new StringBuffer(20);
6855 	for (int i = 0, max = possibleTokens.length; i < max; i++) {
6856 		if (i > 0)
6857 			list.append(", "); //$NON-NLS-1$
6858 		list.append('"');
6859 		list.append(possibleTokens[i]);
6860 		list.append('"');
6861 	}
6862 
6863 	if (isKeyword(currentToken)) {
6864 		String[] arguments = new String[] {new String(currentTokenSource), list.toString()};
6865 		this.handle(
6866 			IProblem.ParsingErrorOnKeyword,
6867 			arguments,
6868 			arguments,
6869 			// this is the current -invalid- token position
6870 			startPosition,
6871 			endPosition);
6872 		return;
6873 	}
6874 	//extract the literal when it's a literal
6875 	if (isLiteral(currentToken) ||
6876 		isIdentifier(currentToken)) {
6877 			errorTokenName = new String(currentTokenSource);
6878 	}
6879 
6880 	String[] arguments = new String[] {errorTokenName, list.toString()};
6881 	this.handle(
6882 		IProblem.ParsingError,
6883 		arguments,
6884 		arguments,
6885 		// this is the current -invalid- token position
6886 		startPosition,
6887 		endPosition);
6888 }
parseErrorDeleteToken( int start, int end, int currentKind, char[] errorTokenSource, String errorTokenName)6889 public void parseErrorDeleteToken(
6890 	int start,
6891 	int end,
6892 	int currentKind,
6893 	char[] errorTokenSource,
6894 	String errorTokenName){
6895 	syntaxError(
6896 		IProblem.ParsingErrorDeleteToken,
6897 		start,
6898 		end,
6899 		currentKind,
6900 		errorTokenSource,
6901 		errorTokenName,
6902 		null);
6903 }
6904 
parseErrorDeleteTokens( int start, int end)6905 public void parseErrorDeleteTokens(
6906 	int start,
6907 	int end){
6908 	this.handle(
6909 		IProblem.ParsingErrorDeleteTokens,
6910 		NoArgument,
6911 		NoArgument,
6912 		start,
6913 		end);
6914 }
parseErrorInsertAfterToken( int start, int end, int currentKind, char[] errorTokenSource, String errorTokenName, String expectedToken)6915 public void parseErrorInsertAfterToken(
6916 	int start,
6917 	int end,
6918 	int currentKind,
6919 	char[] errorTokenSource,
6920 	String errorTokenName,
6921 	String expectedToken){
6922 	syntaxError(
6923 		IProblem.ParsingErrorInsertTokenAfter,
6924 		start,
6925 		end,
6926 		currentKind,
6927 		errorTokenSource,
6928 		errorTokenName,
6929 		expectedToken);
6930 }
parseErrorInsertBeforeToken( int start, int end, int currentKind, char[] errorTokenSource, String errorTokenName, String expectedToken)6931 public void parseErrorInsertBeforeToken(
6932 	int start,
6933 	int end,
6934 	int currentKind,
6935 	char[] errorTokenSource,
6936 	String errorTokenName,
6937 	String expectedToken){
6938 	syntaxError(
6939 		IProblem.ParsingErrorInsertTokenBefore,
6940 		start,
6941 		end,
6942 		currentKind,
6943 		errorTokenSource,
6944 		errorTokenName,
6945 		expectedToken);
6946 }
parseErrorInsertToComplete( int start, int end, String inserted, String completed)6947 public void parseErrorInsertToComplete(
6948 	int start,
6949 	int end,
6950 	String inserted,
6951 	String completed){
6952 	String[] arguments = new String[] {inserted, completed};
6953 	this.handle(
6954 		IProblem.ParsingErrorInsertToComplete,
6955 		arguments,
6956 		arguments,
6957 		start,
6958 		end);
6959 }
6960 
parseErrorInsertToCompletePhrase( int start, int end, String inserted)6961 public void parseErrorInsertToCompletePhrase(
6962 	int start,
6963 	int end,
6964 	String inserted){
6965 	String[] arguments = new String[] {inserted};
6966 	this.handle(
6967 		IProblem.ParsingErrorInsertToCompletePhrase,
6968 		arguments,
6969 		arguments,
6970 		start,
6971 		end);
6972 }
parseErrorInsertToCompleteScope( int start, int end, String inserted)6973 public void parseErrorInsertToCompleteScope(
6974 	int start,
6975 	int end,
6976 	String inserted){
6977 	String[] arguments = new String[] {inserted};
6978 	this.handle(
6979 		IProblem.ParsingErrorInsertToCompleteScope,
6980 		arguments,
6981 		arguments,
6982 		start,
6983 		end);
6984 }
parseErrorInvalidToken( int start, int end, int currentKind, char[] errorTokenSource, String errorTokenName, String expectedToken)6985 public void parseErrorInvalidToken(
6986 	int start,
6987 	int end,
6988 	int currentKind,
6989 	char[] errorTokenSource,
6990 	String errorTokenName,
6991 	String expectedToken){
6992 	syntaxError(
6993 		IProblem.ParsingErrorInvalidToken,
6994 		start,
6995 		end,
6996 		currentKind,
6997 		errorTokenSource,
6998 		errorTokenName,
6999 		expectedToken);
7000 }
parseErrorMergeTokens( int start, int end, String expectedToken)7001 public void parseErrorMergeTokens(
7002 	int start,
7003 	int end,
7004 	String expectedToken){
7005 	String[] arguments = new String[] {expectedToken};
7006 	this.handle(
7007 		IProblem.ParsingErrorMergeTokens,
7008 		arguments,
7009 		arguments,
7010 		start,
7011 		end);
7012 }
parseErrorMisplacedConstruct( int start, int end)7013 public void parseErrorMisplacedConstruct(
7014 	int start,
7015 	int end){
7016 	this.handle(
7017 		IProblem.ParsingErrorMisplacedConstruct,
7018 		NoArgument,
7019 		NoArgument,
7020 		start,
7021 		end);
7022 }
parseErrorNoSuggestion( int start, int end, int currentKind, char[] errorTokenSource, String errorTokenName)7023 public void parseErrorNoSuggestion(
7024 	int start,
7025 	int end,
7026 	int currentKind,
7027 	char[] errorTokenSource,
7028 	String errorTokenName){
7029 	syntaxError(
7030 		IProblem.ParsingErrorNoSuggestion,
7031 		start,
7032 		end,
7033 		currentKind,
7034 		errorTokenSource,
7035 		errorTokenName,
7036 		null);
7037 }
parseErrorNoSuggestionForTokens( int start, int end)7038 public void parseErrorNoSuggestionForTokens(
7039 	int start,
7040 	int end){
7041 	this.handle(
7042 		IProblem.ParsingErrorNoSuggestionForTokens,
7043 		NoArgument,
7044 		NoArgument,
7045 		start,
7046 		end);
7047 }
parseErrorReplaceToken( int start, int end, int currentKind, char[] errorTokenSource, String errorTokenName, String expectedToken)7048 public void parseErrorReplaceToken(
7049 	int start,
7050 	int end,
7051 	int currentKind,
7052 	char[] errorTokenSource,
7053 	String errorTokenName,
7054 	String expectedToken){
7055 	syntaxError(
7056 		IProblem.ParsingError,
7057 		start,
7058 		end,
7059 		currentKind,
7060 		errorTokenSource,
7061 		errorTokenName,
7062 		expectedToken);
7063 }
parseErrorReplaceTokens( int start, int end, String expectedToken)7064 public void parseErrorReplaceTokens(
7065 	int start,
7066 	int end,
7067 	String expectedToken){
7068 	String[] arguments = new String[] {expectedToken};
7069 	this.handle(
7070 		IProblem.ParsingErrorReplaceTokens,
7071 		arguments,
7072 		arguments,
7073 		start,
7074 		end);
7075 }
parseErrorUnexpectedEnd( int start, int end)7076 public void parseErrorUnexpectedEnd(
7077 	int start,
7078 	int end){
7079 
7080 	String[] arguments;
7081 	if(this.referenceContext instanceof ConstructorDeclaration) {
7082 		arguments = new String[] {Messages.parser_endOfConstructor};
7083 	} else if(this.referenceContext instanceof MethodDeclaration) {
7084 		arguments = new String[] {Messages.parser_endOfMethod};
7085 	} else if(this.referenceContext instanceof TypeDeclaration) {
7086 		arguments = new String[] {Messages.parser_endOfInitializer};
7087 	} else {
7088 		arguments = new String[] {Messages.parser_endOfFile};
7089 	}
7090 	this.handle(
7091 		IProblem.ParsingErrorUnexpectedEOF,
7092 		arguments,
7093 		arguments,
7094 		start,
7095 		end);
7096 }
possibleAccidentalBooleanAssignment(Assignment assignment)7097 public void possibleAccidentalBooleanAssignment(Assignment assignment) {
7098 	this.handle(
7099 		IProblem.PossibleAccidentalBooleanAssignment,
7100 		NoArgument,
7101 		NoArgument,
7102 		assignment.sourceStart,
7103 		assignment.sourceEnd);
7104 }
possibleFallThroughCase(CaseStatement caseStatement)7105 public void possibleFallThroughCase(CaseStatement caseStatement) {
7106 	// as long as we consider fake reachable as reachable, better keep 'possible' in the name
7107 	this.handle(
7108 		IProblem.FallthroughCase,
7109 		NoArgument,
7110 		NoArgument,
7111 		caseStatement.sourceStart,
7112 		caseStatement.sourceEnd);
7113 }
publicClassMustMatchFileName(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl)7114 public void publicClassMustMatchFileName(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
7115 	this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
7116 	String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
7117 	this.handle(
7118 		IProblem.PublicClassMustMatchFileName,
7119 		arguments,
7120 		arguments,
7121 		typeDecl.sourceStart,
7122 		typeDecl.sourceEnd,
7123 		compUnitDecl.compilationResult);
7124 }
rawMemberTypeCannotBeParameterized(ASTNode location, ReferenceBinding type, TypeBinding[] argumentTypes)7125 public void rawMemberTypeCannotBeParameterized(ASTNode location, ReferenceBinding type, TypeBinding[] argumentTypes) {
7126 	if (location == null) { // binary case
7127 	    this.handle(
7128 			IProblem.RawMemberTypeCannotBeParameterized,
7129 			new String[] {new String(type.readableName()), typesAsString(argumentTypes, false), new String(type.enclosingType().readableName())},
7130 			new String[] {new String(type.shortReadableName()), typesAsString(argumentTypes, true), new String(type.enclosingType().shortReadableName())},
7131 			ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
7132 			0,
7133 			0);
7134 	    return;
7135 	}
7136     this.handle(
7137 		IProblem.RawMemberTypeCannotBeParameterized,
7138 		new String[] {new String(type.readableName()), typesAsString(argumentTypes, false), new String(type.enclosingType().readableName())},
7139 		new String[] {new String(type.shortReadableName()), typesAsString(argumentTypes, true), new String(type.enclosingType().shortReadableName())},
7140 		location.sourceStart,
7141 		location.sourceEnd);
7142 }
rawTypeReference(ASTNode location, TypeBinding type)7143 public void rawTypeReference(ASTNode location, TypeBinding type) {
7144 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
7145 	type = type.leafComponentType();
7146     this.handle(
7147 		IProblem.RawTypeReference,
7148 		new String[] {new String(type.readableName()), new String(type.erasure().readableName()), },
7149 		new String[] {new String(type.shortReadableName()),new String(type.erasure().shortReadableName()),},
7150 		location.sourceStart,
7151 		nodeSourceEnd(null, location, Integer.MAX_VALUE));
7152 }
recursiveConstructorInvocation(ExplicitConstructorCall constructorCall)7153 public void recursiveConstructorInvocation(ExplicitConstructorCall constructorCall) {
7154 	this.handle(
7155 		IProblem.RecursiveConstructorInvocation,
7156 		new String[] {
7157 			new String(constructorCall.binding.declaringClass.readableName()),
7158 			typesAsString(constructorCall.binding, false)
7159 		},
7160 		new String[] {
7161 			new String(constructorCall.binding.declaringClass.shortReadableName()),
7162 			typesAsString(constructorCall.binding, true)
7163 		},
7164 		constructorCall.sourceStart,
7165 		constructorCall.sourceEnd);
7166 }
redefineArgument(Argument arg)7167 public void redefineArgument(Argument arg) {
7168 	String[] arguments = new String[] {new String(arg.name)};
7169 	this.handle(
7170 		IProblem.RedefinedArgument,
7171 		arguments,
7172 		arguments,
7173 		arg.sourceStart,
7174 		arg.sourceEnd);
7175 }
redefineLocal(LocalDeclaration localDecl)7176 public void redefineLocal(LocalDeclaration localDecl) {
7177 	String[] arguments = new String[] {new String(localDecl.name)};
7178 	this.handle(
7179 		IProblem.RedefinedLocal,
7180 		arguments,
7181 		arguments,
7182 		localDecl.sourceStart,
7183 		localDecl.sourceEnd);
7184 }
redundantSuperInterface(SourceTypeBinding type, TypeReference reference, ReferenceBinding superinterface, ReferenceBinding declaringType)7185 public void redundantSuperInterface(SourceTypeBinding type, TypeReference reference, ReferenceBinding superinterface, ReferenceBinding declaringType) {
7186 	int severity = computeSeverity(IProblem.RedundantSuperinterface);
7187 	if (severity != ProblemSeverities.Ignore) {
7188 		this.handle(
7189 			IProblem.RedundantSuperinterface,
7190 			new String[] {
7191 				new String(superinterface.readableName()),
7192 				new String(type.readableName()),
7193 				new String(declaringType.readableName())},
7194 			new String[] {
7195 				new String(superinterface.shortReadableName()),
7196 				new String(type.shortReadableName()),
7197 				new String(declaringType.shortReadableName())},
7198 			severity,
7199 			reference.sourceStart,
7200 			reference.sourceEnd);
7201 	}
7202 }
referenceMustBeArrayTypeAt(TypeBinding arrayType, ArrayReference arrayRef)7203 public void referenceMustBeArrayTypeAt(TypeBinding arrayType, ArrayReference arrayRef) {
7204 	this.handle(
7205 		IProblem.ArrayReferenceRequired,
7206 		new String[] {new String(arrayType.readableName())},
7207 		new String[] {new String(arrayType.shortReadableName())},
7208 		arrayRef.sourceStart,
7209 		arrayRef.sourceEnd);
7210 }
repeatedAnnotationWithContainer(Annotation annotation, Annotation container)7211 public void repeatedAnnotationWithContainer(Annotation annotation, Annotation container) {
7212 	this.handle(
7213 		IProblem.RepeatedAnnotationWithContainerAnnotation,
7214 		new String[] {new String(annotation.resolvedType.readableName()), new String(container.resolvedType.readableName())},
7215 		new String[] {new String(annotation.resolvedType.shortReadableName()), new String(container.resolvedType.shortReadableName())},
7216 		annotation.sourceStart,
7217 		annotation.sourceEnd);
7218 }
containerAnnotationTypeMustHaveValue(ASTNode markerNode, ReferenceBinding containerAnnotationType)7219 public void containerAnnotationTypeMustHaveValue(ASTNode markerNode, ReferenceBinding containerAnnotationType) {
7220 	this.handle(
7221 		IProblem.ContainerAnnotationTypeMustHaveValue,
7222 		new String[] {new String(containerAnnotationType.readableName())},
7223 		new String[] {new String(containerAnnotationType.shortReadableName())},
7224 		markerNode.sourceStart,
7225 		markerNode.sourceEnd);
7226 }
containerAnnotationTypeHasWrongValueType(ASTNode markerNode, ReferenceBinding containerAnnotationType, ReferenceBinding annotationType, TypeBinding returnType)7227 public void containerAnnotationTypeHasWrongValueType(ASTNode markerNode, ReferenceBinding containerAnnotationType, ReferenceBinding annotationType, TypeBinding returnType) {
7228 	this.handle(
7229 		IProblem.ContainerAnnotationTypeHasWrongValueType,
7230 		new String[] {new String(containerAnnotationType.readableName()), new String(annotationType.readableName()), new String(returnType.readableName())},
7231 		new String[] {new String(containerAnnotationType.shortReadableName()), new String(annotationType.shortReadableName()), new String(returnType.shortReadableName())},
7232 		markerNode.sourceStart,
7233 		markerNode.sourceEnd);
7234 }
containerAnnotationTypeHasNonDefaultMembers(ASTNode markerNode, ReferenceBinding containerAnnotationType, char[] selector)7235 public void containerAnnotationTypeHasNonDefaultMembers(ASTNode markerNode, ReferenceBinding containerAnnotationType, char[] selector) {
7236 	this.handle(
7237 		IProblem.ContainerAnnotationTypeHasNonDefaultMembers,
7238 		new String[] {new String(containerAnnotationType.readableName()), new String(selector)},
7239 		new String[] {new String(containerAnnotationType.shortReadableName()), new String(selector)},
7240 		markerNode.sourceStart,
7241 		markerNode.sourceEnd);
7242 }
containerAnnotationTypeHasShorterRetention(ASTNode markerNode, ReferenceBinding annotationType, String annotationRetention, ReferenceBinding containerAnnotationType, String containerRetention)7243 public void containerAnnotationTypeHasShorterRetention(ASTNode markerNode, ReferenceBinding annotationType, String annotationRetention, ReferenceBinding containerAnnotationType, String containerRetention) {
7244 	this.handle(
7245 		IProblem.ContainerAnnotationTypeHasShorterRetention,
7246 		new String[] {new String(annotationType.readableName()), annotationRetention, new String(containerAnnotationType.readableName()), containerRetention},
7247 		new String[] {new String(annotationType.shortReadableName()), annotationRetention, new String(containerAnnotationType.shortReadableName()), containerRetention},
7248 		markerNode.sourceStart,
7249 		markerNode.sourceEnd);
7250 }
repeatableAnnotationTypeTargetMismatch(ASTNode markerNode, ReferenceBinding annotationType, ReferenceBinding containerAnnotationType, String unmetTargets)7251 public void repeatableAnnotationTypeTargetMismatch(ASTNode markerNode, ReferenceBinding annotationType, ReferenceBinding containerAnnotationType, String unmetTargets) {
7252 	this.handle(
7253 		IProblem.RepeatableAnnotationTypeTargetMismatch,
7254 		new String[] {new String(annotationType.readableName()), new String(containerAnnotationType.readableName()), unmetTargets},
7255 		new String[] {new String(annotationType.shortReadableName()), new String(containerAnnotationType.shortReadableName()), unmetTargets},
7256 		markerNode.sourceStart,
7257 		markerNode.sourceEnd);
7258 }
7259 
repeatableAnnotationTypeIsDocumented(ASTNode markerNode, ReferenceBinding annotationType, ReferenceBinding containerAnnotationType)7260 public void repeatableAnnotationTypeIsDocumented(ASTNode markerNode, ReferenceBinding annotationType, ReferenceBinding containerAnnotationType) {
7261 	this.handle(
7262 		IProblem.RepeatableAnnotationTypeIsDocumented,
7263 		new String[] {new String(annotationType.readableName()), new String(containerAnnotationType.readableName())},
7264 		new String[] {new String(annotationType.shortReadableName()), new String(containerAnnotationType.shortReadableName())},
7265 		markerNode.sourceStart,
7266 		markerNode.sourceEnd);
7267 }
7268 
repeatableAnnotationTypeIsInherited(ASTNode markerNode, ReferenceBinding annotationType, ReferenceBinding containerAnnotationType)7269 public void repeatableAnnotationTypeIsInherited(ASTNode markerNode, ReferenceBinding annotationType, ReferenceBinding containerAnnotationType) {
7270 	this.handle(
7271 		IProblem.RepeatableAnnotationTypeIsInherited,
7272 		new String[] {new String(annotationType.readableName()), new String(containerAnnotationType.readableName())},
7273 		new String[] {new String(annotationType.shortReadableName()), new String(containerAnnotationType.shortReadableName())},
7274 		markerNode.sourceStart,
7275 		markerNode.sourceEnd);
7276 }
7277 
repeatableAnnotationWithRepeatingContainer(Annotation annotation, ReferenceBinding containerType)7278 public void repeatableAnnotationWithRepeatingContainer(Annotation annotation, ReferenceBinding containerType) {
7279 	this.handle(
7280 		IProblem.RepeatableAnnotationWithRepeatingContainerAnnotation,
7281 		new String[] {new String(annotation.resolvedType.readableName()), new String(containerType.readableName())},
7282 		new String[] {new String(annotation.resolvedType.shortReadableName()), new String(containerType.shortReadableName())},
7283 		annotation.sourceStart,
7284 		annotation.sourceEnd);
7285 }
7286 
reset()7287 public void reset() {
7288 	this.positionScanner = null;
7289 }
resourceHasToImplementAutoCloseable(TypeBinding binding, TypeReference typeReference)7290 public void resourceHasToImplementAutoCloseable(TypeBinding binding, TypeReference typeReference) {
7291 	if (this.options.sourceLevel < ClassFileConstants.JDK1_7) {
7292 		return; // Not supported in 1.7 would have been reported. Hence another not required
7293 	}
7294 	this.handle(
7295 			IProblem.ResourceHasToImplementAutoCloseable,
7296 			new String[] {new String(binding.readableName())},
7297 			new String[] {new String(binding.shortReadableName())},
7298 			typeReference.sourceStart,
7299 			typeReference.sourceEnd);
7300 }
retrieveClosingAngleBracketPosition(int start)7301 private int retrieveClosingAngleBracketPosition(int start) {
7302 	if (this.referenceContext == null) return start;
7303 	CompilationResult compilationResult = this.referenceContext.compilationResult();
7304 	if (compilationResult == null) return start;
7305 	ICompilationUnit compilationUnit = compilationResult.getCompilationUnit();
7306 	if (compilationUnit == null) return start;
7307 	char[] contents = compilationUnit.getContents();
7308 	if (contents.length == 0) return start;
7309 	if (this.positionScanner == null) {
7310 		this.positionScanner = new Scanner(false, false, false, this.options.sourceLevel, this.options.complianceLevel, null, null, false);
7311 		this.positionScanner.returnOnlyGreater = true;
7312 	}
7313 	this.positionScanner.setSource(contents);
7314 	this.positionScanner.resetTo(start, contents.length);
7315 	int end = start;
7316 	int count = 0;
7317 	try {
7318 		int token;
7319 		loop: while ((token = this.positionScanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
7320 			switch(token) {
7321 				case TerminalTokens.TokenNameLESS:
7322 					count++;
7323 					break;
7324 				case TerminalTokens.TokenNameGREATER:
7325 					count--;
7326 					if (count == 0) {
7327 						end = this.positionScanner.currentPosition - 1;
7328 						break loop;
7329 					}
7330 					break;
7331 				case TerminalTokens.TokenNameLBRACE :
7332 					break loop;
7333 			}
7334 		}
7335 	} catch(InvalidInputException e) {
7336 		// ignore
7337 	}
7338 	return end;
7339 }
retrieveEndingPositionAfterOpeningParenthesis(int sourceStart, int sourceEnd, int numberOfParen)7340 private int retrieveEndingPositionAfterOpeningParenthesis(int sourceStart, int sourceEnd, int numberOfParen) {
7341 	if (this.referenceContext == null) return sourceEnd;
7342 	CompilationResult compilationResult = this.referenceContext.compilationResult();
7343 	if (compilationResult == null) return sourceEnd;
7344 	ICompilationUnit compilationUnit = compilationResult.getCompilationUnit();
7345 	if (compilationUnit == null) return sourceEnd;
7346 	char[] contents = compilationUnit.getContents();
7347 	if (contents.length == 0) return sourceEnd;
7348 	if (this.positionScanner == null) {
7349 		this.positionScanner = new Scanner(false, false, false, this.options.sourceLevel, this.options.complianceLevel, null, null, false);
7350 	}
7351 	this.positionScanner.setSource(contents);
7352 	this.positionScanner.resetTo(sourceStart, sourceEnd);
7353 	try {
7354 		int token;
7355 		int previousSourceEnd = sourceEnd;
7356 		while ((token = this.positionScanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
7357 			switch(token) {
7358 				case TerminalTokens.TokenNameRPAREN:
7359 					return previousSourceEnd;
7360 				default :
7361 					previousSourceEnd = this.positionScanner.currentPosition - 1;
7362 			}
7363 		}
7364 	} catch(InvalidInputException e) {
7365 		// ignore
7366 	}
7367 	return sourceEnd;
7368 }
retrieveStartingPositionAfterOpeningParenthesis(int sourceStart, int sourceEnd, int numberOfParen)7369 private int retrieveStartingPositionAfterOpeningParenthesis(int sourceStart, int sourceEnd, int numberOfParen) {
7370 	if (this.referenceContext == null) return sourceStart;
7371 	CompilationResult compilationResult = this.referenceContext.compilationResult();
7372 	if (compilationResult == null) return sourceStart;
7373 	ICompilationUnit compilationUnit = compilationResult.getCompilationUnit();
7374 	if (compilationUnit == null) return sourceStart;
7375 	char[] contents = compilationUnit.getContents();
7376 	if (contents.length == 0) return sourceStart;
7377 	if (this.positionScanner == null) {
7378 		this.positionScanner = new Scanner(false, false, false, this.options.sourceLevel, this.options.complianceLevel, null, null, false);
7379 	}
7380 	this.positionScanner.setSource(contents);
7381 	this.positionScanner.resetTo(sourceStart, sourceEnd);
7382 	int count = 0;
7383 	try {
7384 		int token;
7385 		while ((token = this.positionScanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
7386 			switch(token) {
7387 				case TerminalTokens.TokenNameLPAREN:
7388 					count++;
7389 					if (count == numberOfParen) {
7390 						this.positionScanner.getNextToken();
7391 						return this.positionScanner.startPosition;
7392 					}
7393 			}
7394 		}
7395 	} catch(InvalidInputException e) {
7396 		// ignore
7397 	}
7398 	return sourceStart;
7399 }
scannerError(Parser parser, String errorTokenName)7400 public void scannerError(Parser parser, String errorTokenName) {
7401 	Scanner scanner = parser.scanner;
7402 
7403 	int flag = IProblem.ParsingErrorNoSuggestion;
7404 	int startPos = scanner.startPosition;
7405 	int endPos = scanner.currentPosition - 1;
7406 
7407 	//special treatment for recognized errors....
7408 	if (errorTokenName.equals(Scanner.END_OF_SOURCE))
7409 		flag = IProblem.EndOfSource;
7410 	else if (errorTokenName.equals(Scanner.INVALID_HEXA))
7411 		flag = IProblem.InvalidHexa;
7412 	else if (errorTokenName.equals(Scanner.ILLEGAL_HEXA_LITERAL))
7413 		flag = IProblem.IllegalHexaLiteral;
7414 	else if (errorTokenName.equals(Scanner.INVALID_OCTAL))
7415 		flag = IProblem.InvalidOctal;
7416 	else if (errorTokenName.equals(Scanner.INVALID_CHARACTER_CONSTANT))
7417 		flag = IProblem.InvalidCharacterConstant;
7418 	else if (errorTokenName.equals(Scanner.INVALID_ESCAPE))
7419 		flag = IProblem.InvalidEscape;
7420 	else if (errorTokenName.equals(Scanner.INVALID_UNICODE_ESCAPE)){
7421 		flag = IProblem.InvalidUnicodeEscape;
7422 		// better locate the error message
7423 		char[] source = scanner.source;
7424 		int checkPos = scanner.currentPosition - 1;
7425 		if (checkPos >= source.length) checkPos = source.length - 1;
7426 		while (checkPos >= startPos){
7427 			if (source[checkPos] == '\\') break;
7428 			checkPos --;
7429 		}
7430 		startPos = checkPos;
7431 	} else if (errorTokenName.equals(Scanner.INVALID_LOW_SURROGATE)) {
7432 		flag = IProblem.InvalidLowSurrogate;
7433 	} else if (errorTokenName.equals(Scanner.INVALID_HIGH_SURROGATE)) {
7434 		flag = IProblem.InvalidHighSurrogate;
7435 		// better locate the error message
7436 		char[] source = scanner.source;
7437 		int checkPos = scanner.startPosition + 1;
7438 		while (checkPos <= endPos){
7439 			if (source[checkPos] == '\\') break;
7440 			checkPos ++;
7441 		}
7442 		endPos = checkPos - 1;
7443 	} else if (errorTokenName.equals(Scanner.INVALID_FLOAT))
7444 		flag = IProblem.InvalidFloat;
7445 	else if (errorTokenName.equals(Scanner.UNTERMINATED_STRING))
7446 		flag = IProblem.UnterminatedString;
7447 	else if (errorTokenName.equals(Scanner.UNTERMINATED_COMMENT))
7448 		flag = IProblem.UnterminatedComment;
7449 	else if (errorTokenName.equals(Scanner.INVALID_CHAR_IN_STRING))
7450 		flag = IProblem.UnterminatedString;
7451 	else if (errorTokenName.equals(Scanner.INVALID_DIGIT))
7452 		flag = IProblem.InvalidDigit;
7453 	else if (errorTokenName.equals(Scanner.INVALID_BINARY))
7454 		flag = IProblem.InvalidBinary;
7455 	else if (errorTokenName.equals(Scanner.BINARY_LITERAL_NOT_BELOW_17))
7456 		flag = IProblem.BinaryLiteralNotBelow17;
7457 	else if (errorTokenName.equals(Scanner.INVALID_UNDERSCORE))
7458 		flag = IProblem.IllegalUnderscorePosition;
7459 	else if (errorTokenName.equals(Scanner.UNDERSCORES_IN_LITERALS_NOT_BELOW_17))
7460 		flag = IProblem.UnderscoresInLiteralsNotBelow17;
7461 
7462 	String[] arguments = flag == IProblem.ParsingErrorNoSuggestion
7463 			? new String[] {errorTokenName}
7464 			: NoArgument;
7465 	this.handle(
7466 		flag,
7467 		arguments,
7468 		arguments,
7469 		// this is the current -invalid- token position
7470 		startPos,
7471 		endPos,
7472 		parser.compilationUnit.compilationResult);
7473 }
shouldImplementHashcode(SourceTypeBinding type)7474 public void shouldImplementHashcode(SourceTypeBinding type) {
7475 	this.handle(
7476 		IProblem.ShouldImplementHashcode,
7477 		new String[] {new String(type.readableName())},
7478 		new String[] {new String(type.shortReadableName())},
7479 		type.sourceStart(),
7480 		type.sourceEnd());
7481 }
shouldReturn(TypeBinding returnType, ASTNode location)7482 public void shouldReturn(TypeBinding returnType, ASTNode location) {
7483 	int sourceStart = location.sourceStart;
7484 	int sourceEnd = location.sourceEnd;
7485 	if (location instanceof LambdaExpression) {
7486 		LambdaExpression exp = (LambdaExpression) location;
7487 		sourceStart = exp.sourceStart;
7488 		sourceEnd = exp.diagnosticsSourceEnd();
7489 	}
7490 	this.handle(
7491 		methodHasMissingSwitchDefault() ? IProblem.ShouldReturnValueHintMissingDefault : IProblem.ShouldReturnValue,
7492 		new String[] { new String (returnType.readableName())},
7493 		new String[] { new String (returnType.shortReadableName())},
7494 		sourceStart,
7495 		sourceEnd);
7496 }
7497 
signalNoImplicitStringConversionForCharArrayExpression(Expression expression)7498 public void signalNoImplicitStringConversionForCharArrayExpression(Expression expression) {
7499 	this.handle(
7500 		IProblem.NoImplicitStringConversionForCharArrayExpression,
7501 		NoArgument,
7502 		NoArgument,
7503 		expression.sourceStart,
7504 		expression.sourceEnd);
7505 }
staticAndInstanceConflict(MethodBinding currentMethod, MethodBinding inheritedMethod)7506 public void staticAndInstanceConflict(MethodBinding currentMethod, MethodBinding inheritedMethod) {
7507 	if (currentMethod.isStatic())
7508 		this.handle(
7509 			// This static method cannot hide the instance method from %1
7510 			// 8.4.6.4 - If a class inherits more than one method with the same signature a static (non-abstract) method cannot hide an instance method.
7511 			IProblem.CannotHideAnInstanceMethodWithAStaticMethod,
7512 			new String[] {new String(inheritedMethod.declaringClass.readableName())},
7513 			new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
7514 			currentMethod.sourceStart(),
7515 			currentMethod.sourceEnd());
7516 	else
7517 		this.handle(
7518 			// This instance method cannot override the static method from %1
7519 			// 8.4.6.4 - If a class inherits more than one method with the same signature an instance (non-abstract) method cannot override a static method.
7520 			IProblem.CannotOverrideAStaticMethodWithAnInstanceMethod,
7521 			new String[] {new String(inheritedMethod.declaringClass.readableName())},
7522 			new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
7523 			currentMethod.sourceStart(),
7524 			currentMethod.sourceEnd());
7525 }
staticFieldAccessToNonStaticVariable(ASTNode location, FieldBinding field)7526 public void staticFieldAccessToNonStaticVariable(ASTNode location, FieldBinding field) {
7527 	String[] arguments = new String[] {new String(field.readableName())};
7528 	this.handle(
7529 		IProblem.NonStaticFieldFromStaticInvocation,
7530 		arguments,
7531 		arguments,
7532 		nodeSourceStart(field,location),
7533 		nodeSourceEnd(field, location));
7534 }
staticInheritedMethodConflicts(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods)7535 public void staticInheritedMethodConflicts(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
7536 	this.handle(
7537 		// The static method %1 conflicts with the abstract method in %2
7538 		// 8.4.6.4 - If a class inherits more than one method with the same signature it is an error for one to be static (non-abstract) and the other abstract.
7539 		IProblem.StaticInheritedMethodConflicts,
7540 		new String[] {
7541 			new String(concreteMethod.readableName()),
7542 			new String(abstractMethods[0].declaringClass.readableName())},
7543 		new String[] {
7544 			new String(concreteMethod.readableName()),
7545 			new String(abstractMethods[0].declaringClass.shortReadableName())},
7546 		type.sourceStart(),
7547 		type.sourceEnd());
7548 }
staticMemberOfParameterizedType(ASTNode location, ReferenceBinding type, int index)7549 public void staticMemberOfParameterizedType(ASTNode location, ReferenceBinding type, int index) {
7550 	if (location == null) { // binary case
7551 	    this.handle(
7552 			IProblem.StaticMemberOfParameterizedType,
7553 			new String[] {new String(type.readableName()), new String(type.enclosingType().readableName()), },
7554 			new String[] {new String(type.shortReadableName()), new String(type.enclosingType().shortReadableName()), },
7555 			ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
7556 			0,
7557 			0);
7558 	    return;
7559 	}
7560 	/*if (location instanceof ArrayTypeReference) {
7561 		ArrayTypeReference arrayTypeReference = (ArrayTypeReference) location;
7562 		if (arrayTypeReference.token != null && arrayTypeReference.token.length == 0) return;
7563 		end = arrayTypeReference.originalSourceEnd;
7564 	}*/
7565     this.handle(
7566 		IProblem.StaticMemberOfParameterizedType,
7567 		new String[] {new String(type.readableName()), new String(type.enclosingType().readableName()), },
7568 		new String[] {new String(type.shortReadableName()), new String(type.enclosingType().shortReadableName()), },
7569 		location.sourceStart,
7570 		nodeSourceEnd(null, location, index));
7571 }
stringConstantIsExceedingUtf8Limit(ASTNode location)7572 public void stringConstantIsExceedingUtf8Limit(ASTNode location) {
7573 	this.handle(
7574 		IProblem.StringConstantIsExceedingUtf8Limit,
7575 		NoArgument,
7576 		NoArgument,
7577 		location.sourceStart,
7578 		location.sourceEnd);
7579 }
superclassMustBeAClass(SourceTypeBinding type, TypeReference superclassRef, ReferenceBinding superType)7580 public void superclassMustBeAClass(SourceTypeBinding type, TypeReference superclassRef, ReferenceBinding superType) {
7581 	this.handle(
7582 		IProblem.SuperclassMustBeAClass,
7583 		new String[] {new String(superType.readableName()), new String(type.sourceName())},
7584 		new String[] {new String(superType.shortReadableName()), new String(type.sourceName())},
7585 		superclassRef.sourceStart,
7586 		superclassRef.sourceEnd);
7587 }
superfluousSemicolon(int sourceStart, int sourceEnd)7588 public void superfluousSemicolon(int sourceStart, int sourceEnd) {
7589 	this.handle(
7590 		IProblem.SuperfluousSemicolon,
7591 		NoArgument,
7592 		NoArgument,
7593 		sourceStart,
7594 		sourceEnd);
7595 }
superinterfaceMustBeAnInterface(SourceTypeBinding type, TypeReference superInterfaceRef, ReferenceBinding superType)7596 public void superinterfaceMustBeAnInterface(SourceTypeBinding type, TypeReference superInterfaceRef, ReferenceBinding superType) {
7597 	this.handle(
7598 		IProblem.SuperInterfaceMustBeAnInterface,
7599 		new String[] {new String(superType.readableName()), new String(type.sourceName())},
7600 		new String[] {new String(superType.shortReadableName()), new String(type.sourceName())},
7601 		superInterfaceRef.sourceStart,
7602 		superInterfaceRef.sourceEnd);
7603 }
superinterfacesCollide(TypeBinding type, ASTNode decl, TypeBinding superType, TypeBinding inheritedSuperType)7604 public void superinterfacesCollide(TypeBinding type, ASTNode decl, TypeBinding superType, TypeBinding inheritedSuperType) {
7605 	this.handle(
7606 		IProblem.SuperInterfacesCollide,
7607 		new String[] {new String(superType.readableName()), new String(inheritedSuperType.readableName()), new String(type.sourceName())},
7608 		new String[] {new String(superType.shortReadableName()), new String(inheritedSuperType.shortReadableName()), new String(type.sourceName())},
7609 		decl.sourceStart,
7610 		decl.sourceEnd);
7611 }
superTypeCannotUseWildcard(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding)7612 public void superTypeCannotUseWildcard(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) {
7613 	String name = new String(type.sourceName());
7614 	String superTypeFullName = new String(superTypeBinding.readableName());
7615 	String superTypeShortName = new String(superTypeBinding.shortReadableName());
7616 	if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName;
7617 	this.handle(
7618 		IProblem.SuperTypeUsingWildcard,
7619 		new String[] {superTypeFullName, name},
7620 		new String[] {superTypeShortName, name},
7621 		superclass.sourceStart,
7622 		superclass.sourceEnd);
7623 }
syntaxError( int id, int startPosition, int endPosition, int currentKind, char[] currentTokenSource, String errorTokenName, String expectedToken)7624 private void syntaxError(
7625 	int id,
7626 	int startPosition,
7627 	int endPosition,
7628 	int currentKind,
7629 	char[] currentTokenSource,
7630 	String errorTokenName,
7631 	String expectedToken) {
7632 
7633 	if (currentKind == TerminalTokens.TokenNameAT && expectedToken != null && expectedToken.equals("@")) { //$NON-NLS-1$
7634 		// In the diagnose parser case, we don't have the wherewithal to discriminate when we should hand out @308 vs @. So we always answer @.
7635 		// We should silently recover so swallow the message.
7636 		return;
7637 	}
7638 	String eTokenName;
7639 	if (isKeyword(currentKind) ||
7640 		isLiteral(currentKind) ||
7641 		isIdentifier(currentKind)) {
7642 			eTokenName = new String(currentTokenSource);
7643 	} else {
7644 		eTokenName = errorTokenName;
7645 	}
7646 
7647 	String[] arguments;
7648 	if(expectedToken != null) {
7649 		expectedToken = replaceIfSynthetic(expectedToken);
7650 		arguments = new String[] {eTokenName, expectedToken};
7651 	} else {
7652 		arguments = new String[] {eTokenName};
7653 	}
7654 	this.handle(
7655 		id,
7656 		arguments,
7657 		arguments,
7658 		startPosition,
7659 		endPosition);
7660 }
replaceIfSynthetic(String token)7661 private String replaceIfSynthetic(String token) {
7662 	/* Java 8 grammar changes use some synthetic tokens to make the grammar LALR(1). These tokens should not be exposed in messages
7663 	   as it would make no sense to the programmer whatsoever. Replace such artificial tokens with some "suitable"  alternative. At
7664 	   the moment, there are two synthetic tokens that need such massaging viz : "BeginLambda" and "BeginTypeArguments". There is a
7665 	   third synthetic token "ElidedSemicolonAndRightBrace" that we don't expect to show up in messages since it is manufactured by
7666 	   the parser automatically.
7667 	*/
7668 	if (token.equals("BeginTypeArguments")) //$NON-NLS-1$
7669 		return "."; //$NON-NLS-1$
7670 	if (token.equals("BeginLambda")) //$NON-NLS-1$
7671 		return "("; //$NON-NLS-1$
7672 	return token;
7673 }
task(String tag, String message, String priority, int start, int end)7674 public void task(String tag, String message, String priority, int start, int end){
7675 	this.handle(
7676 		IProblem.Task,
7677 		new String[] { tag, message, priority/*secret argument that is not surfaced in getMessage()*/},
7678 		new String[] { tag, message, priority/*secret argument that is not surfaced in getMessage()*/},
7679 		start,
7680 		end);
7681 }
7682 
tooManyDimensions(ASTNode expression)7683 public void tooManyDimensions(ASTNode expression) {
7684 	this.handle(
7685 		IProblem.TooManyArrayDimensions,
7686 		NoArgument,
7687 		NoArgument,
7688 		expression.sourceStart,
7689 		expression.sourceEnd);
7690 }
7691 
tooManyFields(TypeDeclaration typeDeclaration)7692 public void tooManyFields(TypeDeclaration typeDeclaration) {
7693 	this.handle(
7694 		IProblem.TooManyFields,
7695 		new String[]{ new String(typeDeclaration.binding.readableName())},
7696 		new String[]{ new String(typeDeclaration.binding.shortReadableName())},
7697 		ProblemSeverities.Abort | ProblemSeverities.Error | ProblemSeverities.Fatal,
7698 		typeDeclaration.sourceStart,
7699 		typeDeclaration.sourceEnd);
7700 }
tooManyMethods(TypeDeclaration typeDeclaration)7701 public void tooManyMethods(TypeDeclaration typeDeclaration) {
7702 	this.handle(
7703 		IProblem.TooManyMethods,
7704 		new String[]{ new String(typeDeclaration.binding.readableName())},
7705 		new String[]{ new String(typeDeclaration.binding.shortReadableName())},
7706 		ProblemSeverities.Abort | ProblemSeverities.Error | ProblemSeverities.Fatal,
7707 		typeDeclaration.sourceStart,
7708 		typeDeclaration.sourceEnd);
7709 }
tooManyParametersForSyntheticMethod(AbstractMethodDeclaration method)7710 public void tooManyParametersForSyntheticMethod(AbstractMethodDeclaration method) {
7711 	MethodBinding binding = method.binding;
7712 	String selector = null;
7713 	if (binding.isConstructor()) {
7714 		selector = new String(binding.declaringClass.sourceName());
7715 	} else {
7716 		selector = new String(method.selector);
7717 	}
7718 	this.handle(
7719 		IProblem.TooManyParametersForSyntheticMethod,
7720 		new String[] {selector, typesAsString(binding, false), new String(binding.declaringClass.readableName()), },
7721 		new String[] {selector, typesAsString(binding, true), new String(binding.declaringClass.shortReadableName()),},
7722 		ProblemSeverities.AbortMethod | ProblemSeverities.Error | ProblemSeverities.Fatal,
7723 		method.sourceStart,
7724 		method.sourceEnd);
7725 }
typeCastError(CastExpression expression, TypeBinding leftType, TypeBinding rightType)7726 public void typeCastError(CastExpression expression, TypeBinding leftType, TypeBinding rightType) {
7727 	String leftName = new String(leftType.readableName());
7728 	String rightName = new String(rightType.readableName());
7729 	String leftShortName = new String(leftType.shortReadableName());
7730 	String rightShortName = new String(rightType.shortReadableName());
7731 	if (leftShortName.equals(rightShortName)){
7732 		leftShortName = leftName;
7733 		rightShortName = rightName;
7734 	}
7735 	this.handle(
7736 		IProblem.IllegalCast,
7737 		new String[] { rightName, leftName },
7738 		new String[] { rightShortName, leftShortName },
7739 		expression.sourceStart,
7740 		expression.sourceEnd);
7741 }
typeCollidesWithEnclosingType(TypeDeclaration typeDecl)7742 public void typeCollidesWithEnclosingType(TypeDeclaration typeDecl) {
7743 	String[] arguments = new String[] {new String(typeDecl.name)};
7744 	this.handle(
7745 		IProblem.HidingEnclosingType,
7746 		arguments,
7747 		arguments,
7748 		typeDecl.sourceStart,
7749 		typeDecl.sourceEnd);
7750 }
typeCollidesWithPackage(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl)7751 public void typeCollidesWithPackage(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
7752 	this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
7753 	String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
7754 	this.handle(
7755 		IProblem.TypeCollidesWithPackage,
7756 		arguments,
7757 		arguments,
7758 		typeDecl.sourceStart,
7759 		typeDecl.sourceEnd,
7760 		compUnitDecl.compilationResult);
7761 }
typeHiding(TypeDeclaration typeDecl, TypeBinding hiddenType)7762 public void typeHiding(TypeDeclaration typeDecl, TypeBinding hiddenType) {
7763 	int severity = computeSeverity(IProblem.TypeHidingType);
7764 	if (severity == ProblemSeverities.Ignore) return;
7765 	this.handle(
7766 		IProblem.TypeHidingType,
7767 		new String[] { new String(typeDecl.name) , new String(hiddenType.shortReadableName()) },
7768 		new String[] { new String(typeDecl.name) , new String(hiddenType.readableName()) },
7769 		severity,
7770 		typeDecl.sourceStart,
7771 		typeDecl.sourceEnd);
7772 }
typeHiding(TypeDeclaration typeDecl, TypeVariableBinding hiddenTypeParameter)7773 public void typeHiding(TypeDeclaration typeDecl, TypeVariableBinding hiddenTypeParameter) {
7774 	int severity = computeSeverity(IProblem.TypeHidingTypeParameterFromType);
7775 	if (severity == ProblemSeverities.Ignore) return;
7776 	if (hiddenTypeParameter.declaringElement instanceof TypeBinding) {
7777 		TypeBinding declaringType = (TypeBinding) hiddenTypeParameter.declaringElement;
7778 		this.handle(
7779 			IProblem.TypeHidingTypeParameterFromType,
7780 			new String[] { new String(typeDecl.name) , new String(hiddenTypeParameter.readableName()), new String(declaringType.readableName())  },
7781 			new String[] { new String(typeDecl.name) , new String(hiddenTypeParameter.shortReadableName()), new String(declaringType.shortReadableName()) },
7782 			severity,
7783 			typeDecl.sourceStart,
7784 			typeDecl.sourceEnd);
7785 	} else {
7786 		// type parameter of generic method
7787 		MethodBinding declaringMethod = (MethodBinding) hiddenTypeParameter.declaringElement;
7788 		this.handle(
7789 				IProblem.TypeHidingTypeParameterFromMethod,
7790 				new String[] {
7791 						new String(typeDecl.name),
7792 						new String(hiddenTypeParameter.readableName()),
7793 						new String(declaringMethod.selector),
7794 						typesAsString(declaringMethod, false),
7795 						new String(declaringMethod.declaringClass.readableName()),
7796 				},
7797 				new String[] {
7798 						new String(typeDecl.name),
7799 						new String(hiddenTypeParameter.shortReadableName()),
7800 						new String(declaringMethod.selector),
7801 						typesAsString(declaringMethod, true),
7802 						new String(declaringMethod.declaringClass.shortReadableName()),
7803 				},
7804 				severity,
7805 				typeDecl.sourceStart,
7806 				typeDecl.sourceEnd);
7807 	}
7808 }
typeHiding(TypeParameter typeParam, Binding hidden)7809 public void typeHiding(TypeParameter typeParam, Binding hidden) {
7810 	int severity = computeSeverity(IProblem.TypeParameterHidingType);
7811 	if (severity == ProblemSeverities.Ignore) return;
7812 	TypeBinding hiddenType = (TypeBinding) hidden;
7813 	this.handle(
7814 		IProblem.TypeParameterHidingType,
7815 		new String[] { new String(typeParam.name) , new String(hiddenType.readableName())  },
7816 		new String[] { new String(typeParam.name) , new String(hiddenType.shortReadableName()) },
7817 		severity,
7818 		typeParam.sourceStart,
7819 		typeParam.sourceEnd);
7820 }
typeMismatchError(TypeBinding actualType, TypeBinding expectedType, ASTNode location, ASTNode expectingLocation)7821 public void typeMismatchError(TypeBinding actualType, TypeBinding expectedType, ASTNode location, ASTNode expectingLocation) {
7822 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) { // don't expose type variable names, complain on erased types
7823 		if (actualType instanceof TypeVariableBinding)
7824 			actualType = actualType.erasure();
7825 		if (expectedType instanceof TypeVariableBinding)
7826 			expectedType = expectedType.erasure();
7827 	}
7828 	if (actualType != null && (actualType.tagBits & TagBits.HasMissingType) != 0) { // improve secondary error
7829 		if (location instanceof Annotation) {
7830 			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=376977
7831 			return; // Already reported, don't report a secondary error
7832 		}
7833 		this.handle(
7834 				IProblem.UndefinedType,
7835 				new String[] {new String(actualType.leafComponentType().readableName())},
7836 				new String[] {new String(actualType.leafComponentType().shortReadableName())},
7837 				location.sourceStart,
7838 				location.sourceEnd);
7839 			return;
7840 	}
7841 	if (expectingLocation != null && (expectedType.tagBits & TagBits.HasMissingType) != 0) { // improve secondary error
7842 		this.handle(
7843 				IProblem.UndefinedType,
7844 				new String[] {new String(expectedType.leafComponentType().readableName())},
7845 				new String[] {new String(expectedType.leafComponentType().shortReadableName())},
7846 				expectingLocation.sourceStart,
7847 				expectingLocation.sourceEnd);
7848 			return;
7849 	}
7850 
7851 	char[] actualShortReadableName = actualType.shortReadableName();
7852 	char[] expectedShortReadableName = expectedType.shortReadableName();
7853 	char[] actualReadableName = actualType.readableName();
7854 	char[] expectedReadableName = expectedType.readableName();
7855 	if (CharOperation.equals(actualShortReadableName, expectedShortReadableName)) {
7856 		if (CharOperation.equals(actualReadableName, expectedReadableName)) {
7857 			// if full type names are equal, assume the incompatibility is due to mismatching null annotations:
7858 			actualReadableName = actualType.nullAnnotatedReadableName(this.options, false);
7859 			expectedReadableName = expectedType.nullAnnotatedReadableName(this.options, false);
7860 			actualShortReadableName = actualType.nullAnnotatedReadableName(this.options, true);
7861 			expectedShortReadableName = expectedType.nullAnnotatedReadableName(this.options, true);
7862 		} else {
7863 			actualShortReadableName = actualReadableName;
7864 			expectedShortReadableName = expectedReadableName;
7865 		}
7866 	}
7867 	this.handle(
7868 		expectingLocation instanceof ReturnStatement ? IProblem.ReturnTypeMismatch : IProblem.TypeMismatch,
7869 		new String[] {new String(actualReadableName), new String(expectedReadableName)},
7870 		new String[] {new String(actualShortReadableName), new String(expectedShortReadableName)},
7871 		location.sourceStart,
7872 		location.sourceEnd);
7873 }
typeMismatchError(TypeBinding typeArgument, TypeVariableBinding typeParameter, ReferenceBinding genericType, ASTNode location)7874 public void typeMismatchError(TypeBinding typeArgument, TypeVariableBinding typeParameter, ReferenceBinding genericType, ASTNode location) {
7875 	if (location == null) { // binary case
7876 		this.handle(
7877 			IProblem.TypeArgumentMismatch,
7878 			new String[] { new String(typeArgument.readableName()), new String(genericType.readableName()), new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, false) },
7879 			new String[] { new String(typeArgument.shortReadableName()), new String(genericType.shortReadableName()), new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, true) },
7880 			ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
7881 			0,
7882 			0);
7883         return;
7884     }
7885 	this.handle(
7886 		IProblem.TypeArgumentMismatch,
7887 		new String[] { new String(typeArgument.readableName()), new String(genericType.readableName()), new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, false) },
7888 		new String[] { new String(typeArgument.shortReadableName()), new String(genericType.shortReadableName()), new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, true) },
7889 		location.sourceStart,
7890 		location.sourceEnd);
7891 }
typesAsString(MethodBinding methodBinding, boolean makeShort)7892 private String typesAsString(MethodBinding methodBinding, boolean makeShort) {
7893 	return typesAsString(methodBinding, methodBinding.parameters, makeShort);
7894 }
typesAsString(MethodBinding methodBinding, TypeBinding[] parameters, boolean makeShort)7895 private String typesAsString(MethodBinding methodBinding, TypeBinding[] parameters, boolean makeShort) {
7896 	return typesAsString(methodBinding, parameters, makeShort, false);
7897 }
typesAsString(MethodBinding methodBinding, boolean makeShort, boolean showNullAnnotations)7898 private String typesAsString(MethodBinding methodBinding, boolean makeShort, boolean showNullAnnotations) {
7899 	return typesAsString(methodBinding, methodBinding.parameters, makeShort, showNullAnnotations);
7900 }
typesAsString(MethodBinding methodBinding, TypeBinding[] parameters, boolean makeShort, boolean showNullAnnotations)7901 private String typesAsString(MethodBinding methodBinding, TypeBinding[] parameters, boolean makeShort, boolean showNullAnnotations) {
7902 	if (methodBinding.isPolymorphic()) {
7903 		// get the original polymorphicMethod method
7904 		TypeBinding[] types = methodBinding.original().parameters;
7905 		StringBuffer buffer = new StringBuffer(10);
7906 		for (int i = 0, length = types.length; i < length; i++) {
7907 			if (i != 0) {
7908 				buffer.append(", "); //$NON-NLS-1$
7909 			}
7910 			TypeBinding type = types[i];
7911 			boolean isVarargType = i == length-1;
7912 			if (isVarargType) {
7913 				type = ((ArrayBinding)type).elementsType();
7914 			}
7915 			if (showNullAnnotations)
7916 				buffer.append(new String(type.nullAnnotatedReadableName(this.options, makeShort)));
7917 			else
7918 				buffer.append(new String(makeShort ? type.shortReadableName() : type.readableName()));
7919 			if (isVarargType) {
7920 				buffer.append("..."); //$NON-NLS-1$
7921 			}
7922 		}
7923 		return buffer.toString();
7924 	}
7925 	StringBuffer buffer = new StringBuffer(10);
7926 	for (int i = 0, length = parameters.length; i < length; i++) {
7927 		if (i != 0) {
7928 			buffer.append(", "); //$NON-NLS-1$
7929 		}
7930 		TypeBinding type = parameters[i];
7931 		boolean isVarargType = methodBinding.isVarargs() && i == length-1;
7932 		if (isVarargType) {
7933 			type = ((ArrayBinding)type).elementsType();
7934 		}
7935 		if (showNullAnnotations)
7936 			buffer.append(new String(type.nullAnnotatedReadableName(this.options, makeShort)));
7937 		else
7938 			buffer.append(new String(makeShort ? type.shortReadableName() : type.readableName()));
7939 		if (isVarargType) {
7940 			buffer.append("..."); //$NON-NLS-1$
7941 		}
7942 	}
7943 	return buffer.toString();
7944 }
typesAsString(TypeBinding[] types, boolean makeShort)7945 private String typesAsString(TypeBinding[] types, boolean makeShort) {
7946 	return typesAsString(types, makeShort, false);
7947 }
typesAsString(TypeBinding[] types, boolean makeShort, boolean showNullAnnotations)7948 private String typesAsString(TypeBinding[] types, boolean makeShort, boolean showNullAnnotations) {
7949 	StringBuffer buffer = new StringBuffer(10);
7950 	for (int i = 0, length = types.length; i < length; i++) {
7951 		if (i != 0) {
7952 			buffer.append(", "); //$NON-NLS-1$
7953 		}
7954 		TypeBinding type = types[i];
7955 		if (showNullAnnotations)
7956 			buffer.append(new String(type.nullAnnotatedReadableName(this.options, makeShort)));
7957 		else
7958 			buffer.append(new String(makeShort ? type.shortReadableName() : type.readableName()));
7959 	}
7960 	return buffer.toString();
7961 }
7962 
undefinedAnnotationValue(TypeBinding annotationType, MemberValuePair memberValuePair)7963 public void undefinedAnnotationValue(TypeBinding annotationType, MemberValuePair memberValuePair) {
7964 	if (isRecoveredName(memberValuePair.name)) return;
7965 	String name = 	new String(memberValuePair.name);
7966 	this.handle(
7967 		IProblem.UndefinedAnnotationMember,
7968 		new String[] { name, new String(annotationType.readableName())},
7969 		new String[] {	name, new String(annotationType.shortReadableName())},
7970 		memberValuePair.sourceStart,
7971 		memberValuePair.sourceEnd);
7972 }
undefinedLabel(BranchStatement statement)7973 public void undefinedLabel(BranchStatement statement) {
7974 	if (isRecoveredName(statement.label)) return;
7975 	String[] arguments = new String[] {new String(statement.label)};
7976 	this.handle(
7977 		IProblem.UndefinedLabel,
7978 		arguments,
7979 		arguments,
7980 		statement.sourceStart,
7981 		statement.sourceEnd);
7982 }
7983 // can only occur inside binaries
undefinedTypeVariableSignature(char[] variableName, ReferenceBinding binaryType)7984 public void undefinedTypeVariableSignature(char[] variableName, ReferenceBinding binaryType) {
7985 	this.handle(
7986 		IProblem.UndefinedTypeVariable,
7987 		new String[] {new String(variableName), new String(binaryType.readableName()) },
7988 		new String[] {new String(variableName), new String(binaryType.shortReadableName())},
7989 		ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
7990 		0,
7991 		0);
7992 }
undocumentedEmptyBlock(int blockStart, int blockEnd)7993 public void undocumentedEmptyBlock(int blockStart, int blockEnd) {
7994 	this.handle(
7995 		IProblem.UndocumentedEmptyBlock,
7996 		NoArgument,
7997 		NoArgument,
7998 		blockStart,
7999 		blockEnd);
8000 }
unexpectedStaticModifierForField(SourceTypeBinding type, FieldDeclaration fieldDecl)8001 public void unexpectedStaticModifierForField(SourceTypeBinding type, FieldDeclaration fieldDecl) {
8002 	String[] arguments = new String[] {new String(fieldDecl.name)};
8003 	this.handle(
8004 		IProblem.UnexpectedStaticModifierForField,
8005 		arguments,
8006 		arguments,
8007 		fieldDecl.sourceStart,
8008 		fieldDecl.sourceEnd);
8009 }
unexpectedStaticModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl)8010 public void unexpectedStaticModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
8011 	String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
8012 	this.handle(
8013 		IProblem.UnexpectedStaticModifierForMethod,
8014 		arguments,
8015 		arguments,
8016 		methodDecl.sourceStart,
8017 		methodDecl.sourceEnd);
8018 }
unhandledException(TypeBinding exceptionType, ASTNode location)8019 public void unhandledException(TypeBinding exceptionType, ASTNode location) {
8020 
8021 	boolean insideDefaultConstructor =
8022 		(this.referenceContext instanceof ConstructorDeclaration)
8023 			&& ((ConstructorDeclaration)this.referenceContext).isDefaultConstructor();
8024 	boolean insideImplicitConstructorCall =
8025 		(location instanceof ExplicitConstructorCall)
8026 			&& (((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper);
8027 
8028 	int sourceEnd = location.sourceEnd;
8029 	if (location instanceof LocalDeclaration) {
8030 		sourceEnd = ((LocalDeclaration) location).declarationEnd;
8031 	}
8032 	this.handle(
8033 		insideDefaultConstructor
8034 			? IProblem.UnhandledExceptionInDefaultConstructor
8035 			: (insideImplicitConstructorCall
8036 					? IProblem.UndefinedConstructorInImplicitConstructorCall
8037 					: IProblem.UnhandledException),
8038 		new String[] {new String(exceptionType.readableName())},
8039 		new String[] {new String(exceptionType.shortReadableName())},
8040 		location.sourceStart,
8041 		sourceEnd);
8042 }
unhandledExceptionFromAutoClose(TypeBinding exceptionType, ASTNode location)8043 public void unhandledExceptionFromAutoClose (TypeBinding exceptionType, ASTNode location) {
8044 	LocalVariableBinding localBinding = ((LocalDeclaration)location).binding;
8045 	if (localBinding != null) {
8046 		this.handle(
8047 			IProblem.UnhandledExceptionOnAutoClose,
8048 			new String[] {
8049 					new String(exceptionType.readableName()),
8050 					new String(localBinding.readableName())},
8051 			new String[] {
8052 					new String(exceptionType.shortReadableName()),
8053 					new String(localBinding.shortReadableName())},
8054 			location.sourceStart,
8055 			location.sourceEnd);
8056 	}
8057 }
unhandledWarningToken(Expression token)8058 public void unhandledWarningToken(Expression token) {
8059 	String[] arguments = new String[] { token.constant.stringValue() };
8060 	this.handle(
8061 		IProblem.UnhandledWarningToken,
8062 		arguments,
8063 		arguments,
8064 		token.sourceStart,
8065 		token.sourceEnd);
8066 }
uninitializedBlankFinalField(FieldBinding field, ASTNode location)8067 public void uninitializedBlankFinalField(FieldBinding field, ASTNode location) {
8068 	String[] arguments = new String[] {new String(field.readableName())};
8069 	this.handle(
8070 		methodHasMissingSwitchDefault() ? IProblem.UninitializedBlankFinalFieldHintMissingDefault : IProblem.UninitializedBlankFinalField,
8071 		arguments,
8072 		arguments,
8073 		nodeSourceStart(field, location),
8074 		nodeSourceEnd(field, location));
8075 }
uninitializedNonNullField(FieldBinding field, ASTNode location)8076 public void uninitializedNonNullField(FieldBinding field, ASTNode location) {
8077 	char[][] nonNullAnnotationName = this.options.nonNullAnnotationName;
8078 	String[] arguments = new String[] {
8079 			new String(nonNullAnnotationName[nonNullAnnotationName.length-1]),
8080 			new String(field.readableName())
8081 	};
8082 	this.handle(
8083 		methodHasMissingSwitchDefault() ? IProblem.UninitializedNonNullFieldHintMissingDefault : IProblem.UninitializedNonNullField,
8084 		arguments,
8085 		arguments,
8086 		nodeSourceStart(field, location),
8087 		nodeSourceEnd(field, location));
8088 }
uninitializedLocalVariable(LocalVariableBinding binding, ASTNode location)8089 public void uninitializedLocalVariable(LocalVariableBinding binding, ASTNode location) {
8090 	binding.tagBits |= TagBits.NotInitialized;
8091 	String[] arguments = new String[] {new String(binding.readableName())};
8092 	this.handle(
8093 		methodHasMissingSwitchDefault() ? IProblem.UninitializedLocalVariableHintMissingDefault : IProblem.UninitializedLocalVariable,
8094 		arguments,
8095 		arguments,
8096 		nodeSourceStart(binding, location),
8097 		nodeSourceEnd(binding, location));
8098 }
methodHasMissingSwitchDefault()8099 private boolean methodHasMissingSwitchDefault() {
8100 	MethodScope methodScope = null;
8101 	if (this.referenceContext instanceof Block) {
8102 		methodScope = ((Block)this.referenceContext).scope.methodScope();
8103 	} else if (this.referenceContext instanceof AbstractMethodDeclaration) {
8104 		methodScope = ((AbstractMethodDeclaration)this.referenceContext).scope;
8105 	}
8106 	return methodScope != null && methodScope.hasMissingSwitchDefault;
8107 }
unmatchedBracket(int position, ReferenceContext context, CompilationResult compilationResult)8108 public void unmatchedBracket(int position, ReferenceContext context, CompilationResult compilationResult) {
8109 	this.handle(
8110 		IProblem.UnmatchedBracket,
8111 		NoArgument,
8112 		NoArgument,
8113 		position,
8114 		position,
8115 		context,
8116 		compilationResult);
8117 }
unnecessaryCast(CastExpression castExpression)8118 public void unnecessaryCast(CastExpression castExpression) {
8119 	if (castExpression.expression instanceof FunctionalExpression)
8120 		return;
8121 	int severity = computeSeverity(IProblem.UnnecessaryCast);
8122 	if (severity == ProblemSeverities.Ignore) return;
8123 	TypeBinding castedExpressionType = castExpression.expression.resolvedType;
8124 	this.handle(
8125 		IProblem.UnnecessaryCast,
8126 		new String[]{ new String(castedExpressionType.readableName()), new String(castExpression.type.resolvedType.readableName())},
8127 		new String[]{ new String(castedExpressionType.shortReadableName()), new String(castExpression.type.resolvedType.shortReadableName())},
8128 		severity,
8129 		castExpression.sourceStart,
8130 		castExpression.sourceEnd);
8131 }
unnecessaryElse(ASTNode location)8132 public void unnecessaryElse(ASTNode location) {
8133 	this.handle(
8134 		IProblem.UnnecessaryElse,
8135 		NoArgument,
8136 		NoArgument,
8137 		location.sourceStart,
8138 		location.sourceEnd);
8139 }
unnecessaryEnclosingInstanceSpecification(Expression expression, ReferenceBinding targetType)8140 public void unnecessaryEnclosingInstanceSpecification(Expression expression, ReferenceBinding targetType) {
8141 	this.handle(
8142 		IProblem.IllegalEnclosingInstanceSpecification,
8143 		new String[]{ new String(targetType.readableName())},
8144 		new String[]{ new String(targetType.shortReadableName())},
8145 		expression.sourceStart,
8146 		expression.sourceEnd);
8147 }
unnecessaryInstanceof(InstanceOfExpression instanceofExpression, TypeBinding checkType)8148 public void unnecessaryInstanceof(InstanceOfExpression instanceofExpression, TypeBinding checkType) {
8149 	int severity = computeSeverity(IProblem.UnnecessaryInstanceof);
8150 	if (severity == ProblemSeverities.Ignore) return;
8151 	TypeBinding expressionType = instanceofExpression.expression.resolvedType;
8152 	this.handle(
8153 		IProblem.UnnecessaryInstanceof,
8154 		new String[]{ new String(expressionType.readableName()), new String(checkType.readableName())},
8155 		new String[]{ new String(expressionType.shortReadableName()), new String(checkType.shortReadableName())},
8156 		severity,
8157 		instanceofExpression.sourceStart,
8158 		instanceofExpression.sourceEnd);
8159 }
unnecessaryNLSTags(int sourceStart, int sourceEnd)8160 public void unnecessaryNLSTags(int sourceStart, int sourceEnd) {
8161 	this.handle(
8162 		IProblem.UnnecessaryNLSTag,
8163 		NoArgument,
8164 		NoArgument,
8165 		sourceStart,
8166 		sourceEnd);
8167 }
unnecessaryTypeArgumentsForMethodInvocation(MethodBinding method, TypeBinding[] genericTypeArguments, TypeReference[] typeArguments)8168 public void unnecessaryTypeArgumentsForMethodInvocation(MethodBinding method, TypeBinding[] genericTypeArguments, TypeReference[] typeArguments) {
8169 	String methodName = method.isConstructor()
8170 		? new String(method.declaringClass.shortReadableName())
8171 		: new String(method.selector);
8172 	this.handle(
8173 			method.isConstructor()
8174 				? IProblem.UnusedTypeArgumentsForConstructorInvocation
8175 				: IProblem.UnusedTypeArgumentsForMethodInvocation,
8176 		new String[] {
8177 				methodName,
8178 		        typesAsString(method, false),
8179 		        new String(method.declaringClass.readableName()),
8180 		        typesAsString(genericTypeArguments, false) },
8181 		new String[] {
8182 				methodName,
8183 		        typesAsString(method, true),
8184 		        new String(method.declaringClass.shortReadableName()),
8185 		        typesAsString(genericTypeArguments, true) },
8186 		typeArguments[0].sourceStart,
8187 		typeArguments[typeArguments.length-1].sourceEnd);
8188 }
unqualifiedFieldAccess(NameReference reference, FieldBinding field)8189 public void unqualifiedFieldAccess(NameReference reference, FieldBinding field) {
8190 	int sourceStart = reference.sourceStart;
8191 	int sourceEnd = reference.sourceEnd;
8192 	if (reference instanceof SingleNameReference) {
8193 		int numberOfParens = (reference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
8194 		if (numberOfParens != 0) {
8195 			sourceStart = retrieveStartingPositionAfterOpeningParenthesis(sourceStart, sourceEnd, numberOfParens);
8196 			sourceEnd = retrieveEndingPositionAfterOpeningParenthesis(sourceStart, sourceEnd, numberOfParens);
8197 		} else {
8198 			sourceStart = nodeSourceStart(field, reference);
8199 			sourceEnd = nodeSourceEnd(field, reference);
8200 		}
8201 	} else {
8202 		sourceStart = nodeSourceStart(field, reference);
8203 		sourceEnd = nodeSourceEnd(field, reference);
8204 	}
8205 	this.handle(
8206 		IProblem.UnqualifiedFieldAccess,
8207 		new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
8208 		new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
8209 		sourceStart,
8210 		sourceEnd);
8211 }
unreachableCatchBlock(ReferenceBinding exceptionType, ASTNode location)8212 public void unreachableCatchBlock(ReferenceBinding exceptionType, ASTNode location) {
8213 	this.handle(
8214 		IProblem.UnreachableCatch,
8215 		new String[] {
8216 			new String(exceptionType.readableName()),
8217 		 },
8218 		new String[] {
8219 			new String(exceptionType.shortReadableName()),
8220 		 },
8221 		location.sourceStart,
8222 		location.sourceEnd);
8223 }
unreachableCode(Statement statement)8224 public void unreachableCode(Statement statement) {
8225 	int sourceStart = statement.sourceStart;
8226 	int sourceEnd = statement.sourceEnd;
8227 	if (statement instanceof LocalDeclaration) {
8228 		LocalDeclaration declaration = (LocalDeclaration) statement;
8229 		sourceStart = declaration.declarationSourceStart;
8230 		sourceEnd = declaration.declarationSourceEnd;
8231 	} else if (statement instanceof Expression) {
8232 		int statemendEnd = ((Expression) statement).statementEnd;
8233 		if (statemendEnd != -1) sourceEnd = statemendEnd;
8234 	}
8235 	this.handle(
8236 		IProblem.CodeCannotBeReached,
8237 		NoArgument,
8238 		NoArgument,
8239 		sourceStart,
8240 		sourceEnd);
8241 }
unresolvableReference(NameReference nameRef, Binding binding)8242 public void unresolvableReference(NameReference nameRef, Binding binding) {
8243 /* also need to check that the searchedType is the receiver type
8244 	if (binding instanceof ProblemBinding) {
8245 		ProblemBinding problem = (ProblemBinding) binding;
8246 		if (problem.searchType != null && problem.searchType.isHierarchyInconsistent())
8247 			severity = SecondaryError;
8248 	}
8249 */
8250 	String[] arguments = new String[] {new String(binding.readableName())};
8251 	int end = nameRef.sourceEnd;
8252 	int sourceStart = nameRef.sourceStart;
8253 	if (nameRef instanceof QualifiedNameReference) {
8254 		QualifiedNameReference ref = (QualifiedNameReference) nameRef;
8255 		if (isRecoveredName(ref.tokens)) return;
8256 		if (ref.indexOfFirstFieldBinding >= 1)
8257 			end = (int) ref.sourcePositions[ref.indexOfFirstFieldBinding - 1];
8258 	} else {
8259 		SingleNameReference ref = (SingleNameReference) nameRef;
8260 		if (isRecoveredName(ref.token)) return;
8261 		int numberOfParens = (ref.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
8262 		if (numberOfParens != 0) {
8263 			sourceStart = retrieveStartingPositionAfterOpeningParenthesis(sourceStart, end, numberOfParens);
8264 			end = retrieveEndingPositionAfterOpeningParenthesis(sourceStart, end, numberOfParens);
8265 		}
8266 	}
8267 	int problemId = (nameRef.bits & Binding.VARIABLE) != 0 && (nameRef.bits & Binding.TYPE) == 0
8268 		? IProblem.UnresolvedVariable
8269 		: IProblem.UndefinedName;
8270 	this.handle(
8271 		problemId,
8272 		arguments,
8273 		arguments,
8274 		sourceStart,
8275 		end);
8276 }
unsafeCast(CastExpression castExpression, Scope scope)8277 public void unsafeCast(CastExpression castExpression, Scope scope) {
8278 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
8279 	int severity = computeSeverity(IProblem.UnsafeGenericCast);
8280 	if (severity == ProblemSeverities.Ignore) return;
8281 	TypeBinding castedExpressionType = castExpression.expression.resolvedType;
8282 	TypeBinding castExpressionResolvedType = castExpression.resolvedType;
8283 	this.handle(
8284 		IProblem.UnsafeGenericCast,
8285 		new String[]{
8286 			new String(castedExpressionType.readableName()),
8287 			new String(castExpressionResolvedType.readableName())
8288 		},
8289 		new String[]{
8290 			new String(castedExpressionType.shortReadableName()),
8291 			new String(castExpressionResolvedType.shortReadableName())
8292 		},
8293 		severity,
8294 		castExpression.sourceStart,
8295 		castExpression.sourceEnd);
8296 }
unsafeNullnessCast(CastExpression castExpression, Scope scope)8297 public void unsafeNullnessCast(CastExpression castExpression, Scope scope) {
8298 	TypeBinding castedExpressionType = castExpression.expression.resolvedType;
8299 	TypeBinding castExpressionResolvedType = castExpression.resolvedType;
8300 	this.handle(
8301 		IProblem.UnsafeNullnessCast,
8302 		new String[]{
8303 			new String(castedExpressionType.nullAnnotatedReadableName(this.options, false)),
8304 			new String(castExpressionResolvedType.nullAnnotatedReadableName(this.options, false))
8305 		},
8306 		new String[]{
8307 			new String(castedExpressionType.nullAnnotatedReadableName(this.options, true)),
8308 			new String(castExpressionResolvedType.nullAnnotatedReadableName(this.options, true))
8309 		},
8310 		castExpression.sourceStart,
8311 		castExpression.sourceEnd);
8312 }
unsafeGenericArrayForVarargs(TypeBinding leafComponentType, ASTNode location)8313 public void unsafeGenericArrayForVarargs(TypeBinding leafComponentType, ASTNode location) {
8314 	int severity = computeSeverity(IProblem.UnsafeGenericArrayForVarargs);
8315 	if (severity == ProblemSeverities.Ignore) return;
8316 	this.handle(
8317 		IProblem.UnsafeGenericArrayForVarargs,
8318 		new String[]{ new String(leafComponentType.readableName())},
8319 		new String[]{ new String(leafComponentType.shortReadableName())},
8320 		severity,
8321 		location.sourceStart,
8322 		location.sourceEnd);
8323 }
unsafeRawFieldAssignment(FieldBinding field, TypeBinding expressionType, ASTNode location)8324 public void unsafeRawFieldAssignment(FieldBinding field, TypeBinding expressionType, ASTNode location) {
8325 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
8326 	int severity = computeSeverity(IProblem.UnsafeRawFieldAssignment);
8327 	if (severity == ProblemSeverities.Ignore) return;
8328 	this.handle(
8329 		IProblem.UnsafeRawFieldAssignment,
8330 		new String[] {
8331 		        new String(expressionType.readableName()), new String(field.name), new String(field.declaringClass.readableName()), new String(field.declaringClass.erasure().readableName()) },
8332 		new String[] {
8333 		        new String(expressionType.shortReadableName()), new String(field.name), new String(field.declaringClass.shortReadableName()), new String(field.declaringClass.erasure().shortReadableName()) },
8334 		severity,
8335 		nodeSourceStart(field,location),
8336 		nodeSourceEnd(field, location));
8337 }
unsafeRawGenericMethodInvocation(ASTNode location, MethodBinding rawMethod, TypeBinding[] argumentTypes)8338 public void unsafeRawGenericMethodInvocation(ASTNode location, MethodBinding rawMethod, TypeBinding[] argumentTypes) {
8339 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
8340 	boolean isConstructor = rawMethod.isConstructor();
8341 	int severity = computeSeverity(isConstructor ? IProblem.UnsafeRawGenericConstructorInvocation : IProblem.UnsafeRawGenericMethodInvocation);
8342 	if (severity == ProblemSeverities.Ignore) return;
8343     if (isConstructor) {
8344 		this.handle(
8345 			IProblem.UnsafeRawGenericConstructorInvocation, // The generic constructor {0}({1}) of type {2} is applied to non-parameterized type arguments ({3})
8346 			new String[] {
8347 				new String(rawMethod.declaringClass.sourceName()),
8348 				typesAsString(rawMethod.original(), false),
8349 				new String(rawMethod.declaringClass.readableName()),
8350 				typesAsString(argumentTypes, false),
8351 			 },
8352 			new String[] {
8353 				new String(rawMethod.declaringClass.sourceName()),
8354 				typesAsString(rawMethod.original(), true),
8355 				new String(rawMethod.declaringClass.shortReadableName()),
8356 				typesAsString(argumentTypes, true),
8357 			 },
8358 			severity,
8359 			location.sourceStart,
8360 			location.sourceEnd);
8361     } else {
8362 		this.handle(
8363 			IProblem.UnsafeRawGenericMethodInvocation,
8364 			new String[] {
8365 				new String(rawMethod.selector),
8366 				typesAsString(rawMethod.original(), false),
8367 				new String(rawMethod.declaringClass.readableName()),
8368 				typesAsString(argumentTypes, false),
8369 			 },
8370 			new String[] {
8371 				new String(rawMethod.selector),
8372 				typesAsString(rawMethod.original(), true),
8373 				new String(rawMethod.declaringClass.shortReadableName()),
8374 				typesAsString(argumentTypes, true),
8375 			 },
8376 			severity,
8377 			location.sourceStart,
8378 			location.sourceEnd);
8379     }
8380 }
unsafeRawInvocation(ASTNode location, MethodBinding rawMethod)8381 public void unsafeRawInvocation(ASTNode location, MethodBinding rawMethod) {
8382 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
8383 	boolean isConstructor = rawMethod.isConstructor();
8384 	int severity = computeSeverity(isConstructor ? IProblem.UnsafeRawConstructorInvocation : IProblem.UnsafeRawMethodInvocation);
8385 	if (severity == ProblemSeverities.Ignore) return;
8386     if (isConstructor) {
8387 		this.handle(
8388 			IProblem.UnsafeRawConstructorInvocation,
8389 			new String[] {
8390 				new String(rawMethod.declaringClass.readableName()),
8391 				typesAsString(rawMethod.original(), rawMethod.parameters, false),
8392 				new String(rawMethod.declaringClass.erasure().readableName()),
8393 			 },
8394 			new String[] {
8395 				new String(rawMethod.declaringClass.shortReadableName()),
8396 				typesAsString(rawMethod.original(), rawMethod.parameters, true),
8397 				new String(rawMethod.declaringClass.erasure().shortReadableName()),
8398 			 },
8399 			severity,
8400 			location.sourceStart,
8401 			location.sourceEnd);
8402     } else {
8403 		this.handle(
8404 			IProblem.UnsafeRawMethodInvocation,
8405 			new String[] {
8406 				new String(rawMethod.selector),
8407 				typesAsString(rawMethod.original(), rawMethod.parameters, false),
8408 				new String(rawMethod.declaringClass.readableName()),
8409 				new String(rawMethod.declaringClass.erasure().readableName()),
8410 			 },
8411 			new String[] {
8412 				new String(rawMethod.selector),
8413 				typesAsString(rawMethod.original(), rawMethod.parameters, true),
8414 				new String(rawMethod.declaringClass.shortReadableName()),
8415 				new String(rawMethod.declaringClass.erasure().shortReadableName()),
8416 			 },
8417 			severity,
8418 			location.sourceStart,
8419 			location.sourceEnd);
8420     }
8421 }
unsafeReturnTypeOverride(MethodBinding currentMethod, MethodBinding inheritedMethod, SourceTypeBinding type)8422 public void unsafeReturnTypeOverride(MethodBinding currentMethod, MethodBinding inheritedMethod, SourceTypeBinding type) {
8423 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) {
8424 		return;
8425 	}
8426 	int severity = computeSeverity(IProblem.UnsafeReturnTypeOverride);
8427 	if (severity == ProblemSeverities.Ignore) return;
8428 	int start = type.sourceStart();
8429 	int end = type.sourceEnd();
8430 	if (TypeBinding.equalsEquals(currentMethod.declaringClass, type)) {
8431 		ASTNode location = ((MethodDeclaration) currentMethod.sourceMethod()).returnType;
8432 		start = location.sourceStart();
8433 		end = location.sourceEnd();
8434 	}
8435 	this.handle(
8436 			IProblem.UnsafeReturnTypeOverride,
8437 			new String[] {
8438 				new String(currentMethod.returnType.readableName()),
8439 				new String(currentMethod.selector),
8440 				typesAsString(currentMethod.original(), false),
8441 				new String(currentMethod.declaringClass.readableName()),
8442 				new String(inheritedMethod.returnType.readableName()),
8443 				new String(inheritedMethod.declaringClass.readableName()),
8444 				//new String(inheritedMethod.returnType.erasure().readableName()),
8445 			 },
8446 			new String[] {
8447 				new String(currentMethod.returnType.shortReadableName()),
8448 				new String(currentMethod.selector),
8449 				typesAsString(currentMethod.original(), true),
8450 				new String(currentMethod.declaringClass.shortReadableName()),
8451 				new String(inheritedMethod.returnType.shortReadableName()),
8452 				new String(inheritedMethod.declaringClass.shortReadableName()),
8453 				//new String(inheritedMethod.returnType.erasure().shortReadableName()),
8454 			 },
8455 			severity,
8456 			start,
8457 			end);
8458 }
unsafeTypeConversion(Expression expression, TypeBinding expressionType, TypeBinding expectedType)8459 public void unsafeTypeConversion(Expression expression, TypeBinding expressionType, TypeBinding expectedType) {
8460 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
8461 	int severity = computeSeverity(IProblem.UnsafeTypeConversion);
8462 	if (severity == ProblemSeverities.Ignore) return;
8463 	if (!this.options.reportUnavoidableGenericTypeProblems && expression.forcedToBeRaw(this.referenceContext)) {
8464 		return;
8465 	}
8466 	this.handle(
8467 		IProblem.UnsafeTypeConversion,
8468 		new String[] { new String(expressionType.readableName()), new String(expectedType.readableName()), new String(expectedType.erasure().readableName()) },
8469 		new String[] { new String(expressionType.shortReadableName()), new String(expectedType.shortReadableName()), new String(expectedType.erasure().shortReadableName()) },
8470 		severity,
8471 		expression.sourceStart,
8472 		expression.sourceEnd);
8473 }
unsafeElementTypeConversion(Expression expression, TypeBinding expressionType, TypeBinding expectedType)8474 public void unsafeElementTypeConversion(Expression expression, TypeBinding expressionType, TypeBinding expectedType) {
8475 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
8476 	int severity = computeSeverity(IProblem.UnsafeElementTypeConversion);
8477 	if (severity == ProblemSeverities.Ignore) return;
8478 	if (!this.options.reportUnavoidableGenericTypeProblems && expression.forcedToBeRaw(this.referenceContext)) {
8479 		return;
8480 	}
8481 	this.handle(
8482 		IProblem.UnsafeElementTypeConversion,
8483 		new String[] { new String(expressionType.readableName()), new String(expectedType.readableName()), new String(expectedType.erasure().readableName()) },
8484 		new String[] { new String(expressionType.shortReadableName()), new String(expectedType.shortReadableName()), new String(expectedType.erasure().shortReadableName()) },
8485 		severity,
8486 		expression.sourceStart,
8487 		expression.sourceEnd);
8488 }
unusedArgument(LocalDeclaration localDecl)8489 public void unusedArgument(LocalDeclaration localDecl) {
8490 	int severity = computeSeverity(IProblem.ArgumentIsNeverUsed);
8491 	if (severity == ProblemSeverities.Ignore) return;
8492 	String[] arguments = new String[] {new String(localDecl.name)};
8493 	this.handle(
8494 		IProblem.ArgumentIsNeverUsed,
8495 		arguments,
8496 		arguments,
8497 		severity,
8498 		localDecl.sourceStart,
8499 		localDecl.sourceEnd);
8500 }
unusedDeclaredThrownException(ReferenceBinding exceptionType, AbstractMethodDeclaration method, ASTNode location)8501 public void unusedDeclaredThrownException(ReferenceBinding exceptionType, AbstractMethodDeclaration method, ASTNode location) {
8502 	boolean isConstructor = method.isConstructor();
8503 	int severity = computeSeverity(isConstructor ? IProblem.UnusedConstructorDeclaredThrownException : IProblem.UnusedMethodDeclaredThrownException);
8504 	if (severity == ProblemSeverities.Ignore) return;
8505 	if (isConstructor) {
8506 		this.handle(
8507 			IProblem.UnusedConstructorDeclaredThrownException,
8508 			new String[] {
8509 				new String(method.binding.declaringClass.readableName()),
8510 				typesAsString(method.binding, false),
8511 				new String(exceptionType.readableName()),
8512 			 },
8513 			new String[] {
8514 				new String(method.binding.declaringClass.shortReadableName()),
8515 				typesAsString(method.binding, true),
8516 				new String(exceptionType.shortReadableName()),
8517 			 },
8518 			severity,
8519 			location.sourceStart,
8520 			location.sourceEnd);
8521 	} else {
8522 		this.handle(
8523 			IProblem.UnusedMethodDeclaredThrownException,
8524 			new String[] {
8525 				new String(method.binding.declaringClass.readableName()),
8526 				new String(method.selector),
8527 				typesAsString(method.binding, false),
8528 				new String(exceptionType.readableName()),
8529 			 },
8530 			new String[] {
8531 				new String(method.binding.declaringClass.shortReadableName()),
8532 				new String(method.selector),
8533 				typesAsString(method.binding, true),
8534 				new String(exceptionType.shortReadableName()),
8535 			 },
8536 			severity,
8537 			location.sourceStart,
8538 			location.sourceEnd);
8539 	}
8540 }
unusedImport(ImportReference importRef)8541 public void unusedImport(ImportReference importRef) {
8542 	int severity = computeSeverity(IProblem.UnusedImport);
8543 	if (severity == ProblemSeverities.Ignore) return;
8544 	String[] arguments = new String[] { CharOperation.toString(importRef.tokens) };
8545 	this.handle(
8546 		IProblem.UnusedImport,
8547 		arguments,
8548 		arguments,
8549 		severity,
8550 		importRef.sourceStart,
8551 		importRef.sourceEnd);
8552 }
unusedLabel(LabeledStatement statement)8553 public void unusedLabel(LabeledStatement statement) {
8554 	int severity = computeSeverity(IProblem.UnusedLabel);
8555 	if (severity == ProblemSeverities.Ignore) return;
8556 	String[] arguments = new String[] {new String(statement.label)};
8557 	this.handle(
8558 		IProblem.UnusedLabel,
8559 		arguments,
8560 		arguments,
8561 		severity,
8562 		statement.sourceStart,
8563 		statement.labelEnd);
8564 }
unusedLocalVariable(LocalDeclaration localDecl)8565 public void unusedLocalVariable(LocalDeclaration localDecl) {
8566 	int severity = computeSeverity(IProblem.LocalVariableIsNeverUsed);
8567 	if (severity == ProblemSeverities.Ignore) return;
8568 	String[] arguments = new String[] {new String(localDecl.name)};
8569 	this.handle(
8570 		IProblem.LocalVariableIsNeverUsed,
8571 		arguments,
8572 		arguments,
8573 		severity,
8574 		localDecl.sourceStart,
8575 		localDecl.sourceEnd);
8576 }
unusedObjectAllocation(AllocationExpression allocationExpression)8577 public void unusedObjectAllocation(AllocationExpression allocationExpression) {
8578 	this.handle(
8579 		IProblem.UnusedObjectAllocation,
8580 		NoArgument,
8581 		NoArgument,
8582 		allocationExpression.sourceStart,
8583 		allocationExpression.sourceEnd);
8584 }
unusedPrivateConstructor(ConstructorDeclaration constructorDecl)8585 public void unusedPrivateConstructor(ConstructorDeclaration constructorDecl) {
8586 
8587 	int severity = computeSeverity(IProblem.UnusedPrivateConstructor);
8588 	if (severity == ProblemSeverities.Ignore) return;
8589 
8590 	if (excludeDueToAnnotation(constructorDecl.annotations, IProblem.UnusedPrivateConstructor)) return;
8591 
8592 	MethodBinding constructor = constructorDecl.binding;
8593 	this.handle(
8594 			IProblem.UnusedPrivateConstructor,
8595 		new String[] {
8596 			new String(constructor.declaringClass.readableName()),
8597 			typesAsString(constructor, false)
8598 		 },
8599 		new String[] {
8600 			new String(constructor.declaringClass.shortReadableName()),
8601 			typesAsString(constructor, true)
8602 		 },
8603 		severity,
8604 		constructorDecl.sourceStart,
8605 		constructorDecl.sourceEnd);
8606 }
unusedPrivateField(FieldDeclaration fieldDecl)8607 public void unusedPrivateField(FieldDeclaration fieldDecl) {
8608 
8609 	int severity = computeSeverity(IProblem.UnusedPrivateField);
8610 	if (severity == ProblemSeverities.Ignore) return;
8611 
8612 	FieldBinding field = fieldDecl.binding;
8613 
8614 	if (CharOperation.equals(TypeConstants.SERIALVERSIONUID, field.name)
8615 			&& field.isStatic()
8616 			&& field.isFinal()
8617 			&& TypeBinding.equalsEquals(TypeBinding.LONG, field.type)) {
8618 		ReferenceBinding referenceBinding = field.declaringClass;
8619 		if (referenceBinding != null) {
8620 			if (referenceBinding.findSuperTypeOriginatingFrom(TypeIds.T_JavaIoSerializable, false /*Serializable is not a class*/) != null) {
8621 				return; // do not report unused serialVersionUID field for class that implements Serializable
8622 			}
8623 		}
8624 	}
8625 	if (CharOperation.equals(TypeConstants.SERIALPERSISTENTFIELDS, field.name)
8626 			&& field.isStatic()
8627 			&& field.isFinal()
8628 			&& field.type.dimensions() == 1
8629 			&& CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTSTREAMFIELD, field.type.leafComponentType().readableName())) {
8630 		ReferenceBinding referenceBinding = field.declaringClass;
8631 		if (referenceBinding != null) {
8632 			if (referenceBinding.findSuperTypeOriginatingFrom(TypeIds.T_JavaIoSerializable, false /*Serializable is not a class*/) != null) {
8633 				return; // do not report unused serialVersionUID field for class that implements Serializable
8634 			}
8635 		}
8636 	}
8637 	if (excludeDueToAnnotation(fieldDecl.annotations, IProblem.UnusedPrivateField)) return;
8638 	this.handle(
8639 			IProblem.UnusedPrivateField,
8640 		new String[] {
8641 			new String(field.declaringClass.readableName()),
8642 			new String(field.name),
8643 		 },
8644 		new String[] {
8645 			new String(field.declaringClass.shortReadableName()),
8646 			new String(field.name),
8647 		 },
8648 		severity,
8649 		nodeSourceStart(field, fieldDecl),
8650 		nodeSourceEnd(field, fieldDecl));
8651 }
unusedPrivateMethod(AbstractMethodDeclaration methodDecl)8652 public void unusedPrivateMethod(AbstractMethodDeclaration methodDecl) {
8653 
8654 	int severity = computeSeverity(IProblem.UnusedPrivateMethod);
8655 	if (severity == ProblemSeverities.Ignore) return;
8656 
8657 	MethodBinding method = methodDecl.binding;
8658 
8659 	// no report for serialization support 'void readObject(ObjectInputStream)'
8660 	if (!method.isStatic()
8661 			&& TypeBinding.VOID == method.returnType
8662 			&& method.parameters.length == 1
8663 			&& method.parameters[0].dimensions() == 0
8664 			&& CharOperation.equals(method.selector, TypeConstants.READOBJECT)
8665 			&& CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTINPUTSTREAM, method.parameters[0].readableName())) {
8666 		return;
8667 	}
8668 	// no report for serialization support 'void writeObject(ObjectOutputStream)'
8669 	if (!method.isStatic()
8670 			&& TypeBinding.VOID == method.returnType
8671 			&& method.parameters.length == 1
8672 			&& method.parameters[0].dimensions() == 0
8673 			&& CharOperation.equals(method.selector, TypeConstants.WRITEOBJECT)
8674 			&& CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTOUTPUTSTREAM, method.parameters[0].readableName())) {
8675 		return;
8676 	}
8677 	// no report for serialization support 'Object readResolve()'
8678 	if (!method.isStatic()
8679 			&& TypeIds.T_JavaLangObject == method.returnType.id
8680 			&& method.parameters.length == 0
8681 			&& CharOperation.equals(method.selector, TypeConstants.READRESOLVE)) {
8682 		return;
8683 	}
8684 	// no report for serialization support 'Object writeReplace()'
8685 	if (!method.isStatic()
8686 			&& TypeIds.T_JavaLangObject == method.returnType.id
8687 			&& method.parameters.length == 0
8688 			&& CharOperation.equals(method.selector, TypeConstants.WRITEREPLACE)) {
8689 		return;
8690 	}
8691 	if (excludeDueToAnnotation(methodDecl.annotations, IProblem.UnusedPrivateMethod)) return;
8692 
8693 	this.handle(
8694 			IProblem.UnusedPrivateMethod,
8695 		new String[] {
8696 			new String(method.declaringClass.readableName()),
8697 			new String(method.selector),
8698 			typesAsString(method, false)
8699 		 },
8700 		new String[] {
8701 			new String(method.declaringClass.shortReadableName()),
8702 			new String(method.selector),
8703 			typesAsString(method, true)
8704 		 },
8705 		severity,
8706 		methodDecl.sourceStart,
8707 		methodDecl.sourceEnd);
8708 }
8709 
8710 /**
8711  * Returns true if a private member should not be warned as unused if
8712  * annotated with a non-standard annotation.
8713  * https://bugs.eclipse.org/365437
8714  * https://bugs.eclipse.org/376590
8715  */
excludeDueToAnnotation(Annotation[] annotations, int problemId)8716 private boolean excludeDueToAnnotation(Annotation[] annotations, int problemId) {
8717 	int annotationsLen = 0;
8718 	if (annotations != null) {
8719 		annotationsLen = annotations.length;
8720 	} else {
8721 		return false;
8722 	}
8723 	if (annotationsLen == 0) return false;
8724 	for (int i = 0; i < annotationsLen; i++) {
8725 		TypeBinding resolvedType = annotations[i].resolvedType;
8726 		if (resolvedType != null) {
8727 			switch (resolvedType.id) {
8728 				case TypeIds.T_JavaLangSuppressWarnings:
8729 				case TypeIds.T_JavaLangDeprecated:
8730 				case TypeIds.T_JavaLangSafeVarargs:
8731 				case TypeIds.T_ConfiguredAnnotationNonNull:
8732 				case TypeIds.T_ConfiguredAnnotationNullable:
8733 				case TypeIds.T_ConfiguredAnnotationNonNullByDefault:
8734 					break;
8735 				case TypeIds.T_JavaxInjectInject:
8736 				case TypeIds.T_ComGoogleInjectInject:
8737 					if (problemId != IProblem.UnusedPrivateField)
8738 						return true; // @Inject on method/ctor does constitute a relevant use, just on fields it doesn't
8739 					break;
8740 				default:
8741 					// non-standard annotation found, don't warn
8742 					return true;
8743 			}
8744 		}
8745 	}
8746 	return false;
8747 }
unusedPrivateType(TypeDeclaration typeDecl)8748 public void unusedPrivateType(TypeDeclaration typeDecl) {
8749 	int severity = computeSeverity(IProblem.UnusedPrivateType);
8750 	if (severity == ProblemSeverities.Ignore) return;
8751 	if (excludeDueToAnnotation(typeDecl.annotations, IProblem.UnusedPrivateType)) return;
8752 	ReferenceBinding type = typeDecl.binding;
8753 	this.handle(
8754 			IProblem.UnusedPrivateType,
8755 		new String[] {
8756 			new String(type.readableName()),
8757 		 },
8758 		new String[] {
8759 			new String(type.shortReadableName()),
8760 		 },
8761 		severity,
8762 		typeDecl.sourceStart,
8763 		typeDecl.sourceEnd);
8764 }
unusedTypeParameter(TypeParameter typeParameter)8765 public void unusedTypeParameter(TypeParameter typeParameter) {
8766 	int severity = computeSeverity(IProblem.UnusedTypeParameter);
8767 	if (severity == ProblemSeverities.Ignore) return;
8768 	String [] arguments = new String[] {new String(typeParameter.name)};
8769 	this.handle(
8770 			IProblem.UnusedTypeParameter,
8771 			arguments,
8772 			arguments,
8773 			typeParameter.sourceStart,
8774 			typeParameter.sourceEnd);
8775 }
unusedWarningToken(Expression token)8776 public void unusedWarningToken(Expression token) {
8777 	String[] arguments = new String[] { token.constant.stringValue() };
8778 	this.handle(
8779 		IProblem.UnusedWarningToken,
8780 		arguments,
8781 		arguments,
8782 		token.sourceStart,
8783 		token.sourceEnd);
8784 }
useAssertAsAnIdentifier(int sourceStart, int sourceEnd)8785 public void useAssertAsAnIdentifier(int sourceStart, int sourceEnd) {
8786 	this.handle(
8787 		IProblem.UseAssertAsAnIdentifier,
8788 		NoArgument,
8789 		NoArgument,
8790 		sourceStart,
8791 		sourceEnd);
8792 }
useEnumAsAnIdentifier(int sourceStart, int sourceEnd)8793 public void useEnumAsAnIdentifier(int sourceStart, int sourceEnd) {
8794 	this.handle(
8795 		IProblem.UseEnumAsAnIdentifier,
8796 		NoArgument,
8797 		NoArgument,
8798 		sourceStart,
8799 		sourceEnd);
8800 }
illegalUseOfUnderscoreAsAnIdentifier(int sourceStart, int sourceEnd, boolean lambdaParameter)8801 public void illegalUseOfUnderscoreAsAnIdentifier(int sourceStart, int sourceEnd, boolean lambdaParameter) {
8802 	this.underScoreIsLambdaParameter = lambdaParameter;
8803 	try {
8804 		this.handle(
8805 			IProblem.IllegalUseOfUnderscoreAsAnIdentifier,
8806 			NoArgument,
8807 			NoArgument,
8808 			sourceStart,
8809 			sourceEnd);
8810 	} finally {
8811 		this.underScoreIsLambdaParameter = false;
8812 	}
8813 }
varargsArgumentNeedCast(MethodBinding method, TypeBinding argumentType, InvocationSite location)8814 public void varargsArgumentNeedCast(MethodBinding method, TypeBinding argumentType, InvocationSite location) {
8815 	int severity = this.options.getSeverity(CompilerOptions.VarargsArgumentNeedCast);
8816 	if (severity == ProblemSeverities.Ignore) return;
8817 	ArrayBinding varargsType = (ArrayBinding)method.parameters[method.parameters.length-1];
8818 	if (method.isConstructor()) {
8819 		this.handle(
8820 			IProblem.ConstructorVarargsArgumentNeedCast,
8821 			new String[] {
8822 					new String(argumentType.readableName()),
8823 					new String(varargsType.readableName()),
8824 					new String(method.declaringClass.readableName()),
8825 					typesAsString(method, false),
8826 					new String(varargsType.elementsType().readableName()),
8827 			},
8828 			new String[] {
8829 					new String(argumentType.shortReadableName()),
8830 					new String(varargsType.shortReadableName()),
8831 					new String(method.declaringClass.shortReadableName()),
8832 					typesAsString(method, true),
8833 					new String(varargsType.elementsType().shortReadableName()),
8834 			},
8835 			severity,
8836 			location.sourceStart(),
8837 			location.sourceEnd());
8838 	} else {
8839 		this.handle(
8840 			IProblem.MethodVarargsArgumentNeedCast,
8841 			new String[] {
8842 					new String(argumentType.readableName()),
8843 					new String(varargsType.readableName()),
8844 					new String(method.selector),
8845 					typesAsString(method, false),
8846 					new String(method.declaringClass.readableName()),
8847 					new String(varargsType.elementsType().readableName()),
8848 			},
8849 			new String[] {
8850 					new String(argumentType.shortReadableName()),
8851 					new String(varargsType.shortReadableName()),
8852 					new String(method.selector), typesAsString(method, true),
8853 					new String(method.declaringClass.shortReadableName()),
8854 					new String(varargsType.elementsType().shortReadableName()),
8855 			},
8856 			severity,
8857 			location.sourceStart(),
8858 			location.sourceEnd());
8859 	}
8860 }
varargsConflict(MethodBinding method1, MethodBinding method2, SourceTypeBinding type)8861 public void varargsConflict(MethodBinding method1, MethodBinding method2, SourceTypeBinding type) {
8862 	this.handle(
8863 		IProblem.VarargsConflict,
8864 		new String[] {
8865 		        new String(method1.selector),
8866 		        typesAsString(method1, false),
8867 		        new String(method1.declaringClass.readableName()),
8868 		        typesAsString(method2, false),
8869 		        new String(method2.declaringClass.readableName())
8870 		},
8871 		new String[] {
8872 		        new String(method1.selector),
8873 		        typesAsString(method1, true),
8874 		        new String(method1.declaringClass.shortReadableName()),
8875 		        typesAsString(method2, true),
8876 		        new String(method2.declaringClass.shortReadableName())
8877 		},
8878 		TypeBinding.equalsEquals(method1.declaringClass, type) ? method1.sourceStart() : type.sourceStart(),
8879 		TypeBinding.equalsEquals(method1.declaringClass, type) ? method1.sourceEnd() : type.sourceEnd());
8880 }
safeVarargsOnFixedArityMethod(MethodBinding method)8881 public void safeVarargsOnFixedArityMethod(MethodBinding method) {
8882 	String [] arguments = new String[] { new String(method.isConstructor() ? method.declaringClass.shortReadableName() : method.selector)};
8883 	this.handle(
8884 		IProblem.SafeVarargsOnFixedArityMethod,
8885 		arguments,
8886 		arguments,
8887 		method.sourceStart(),
8888 		method.sourceEnd());
8889 }
safeVarargsOnNonFinalInstanceMethod(MethodBinding method)8890 public void safeVarargsOnNonFinalInstanceMethod(MethodBinding method) {
8891 	String [] arguments = new String[] { new String(method.isConstructor() ? method.declaringClass.shortReadableName() : method.selector)};
8892 	this.handle(
8893 		IProblem.SafeVarargsOnNonFinalInstanceMethod,
8894 		arguments,
8895 		arguments,
8896 		method.sourceStart(),
8897 		method.sourceEnd());
8898 }
possibleHeapPollutionFromVararg(AbstractVariableDeclaration vararg)8899 public void possibleHeapPollutionFromVararg(AbstractVariableDeclaration vararg) {
8900 	String[] arguments = new String[] {new String(vararg.name)};
8901 	this.handle(
8902 		IProblem.PotentialHeapPollutionFromVararg,
8903 		arguments,
8904 		arguments,
8905 		vararg.sourceStart,
8906 		vararg.sourceEnd);
8907 }
variableTypeCannotBeVoid(AbstractVariableDeclaration varDecl)8908 public void variableTypeCannotBeVoid(AbstractVariableDeclaration varDecl) {
8909 	String[] arguments = new String[] {new String(varDecl.name)};
8910 	this.handle(
8911 		IProblem.VariableTypeCannotBeVoid,
8912 		arguments,
8913 		arguments,
8914 		varDecl.sourceStart,
8915 		varDecl.sourceEnd);
8916 }
variableTypeCannotBeVoidArray(AbstractVariableDeclaration varDecl)8917 public void variableTypeCannotBeVoidArray(AbstractVariableDeclaration varDecl) {
8918 	this.handle(
8919 		IProblem.CannotAllocateVoidArray,
8920 		NoArgument,
8921 		NoArgument,
8922 		varDecl.type.sourceStart,
8923 		varDecl.type.sourceEnd);
8924 }
visibilityConflict(MethodBinding currentMethod, MethodBinding inheritedMethod)8925 public void visibilityConflict(MethodBinding currentMethod, MethodBinding inheritedMethod) {
8926 	this.handle(
8927 		//	Cannot reduce the visibility of the inherited method from %1
8928 		// 8.4.6.3 - The access modifier of an hiding method must provide at least as much access as the hidden method.
8929 		// 8.4.6.3 - The access modifier of an overiding method must provide at least as much access as the overriden method.
8930 		IProblem.MethodReducesVisibility,
8931 		new String[] {new String(inheritedMethod.declaringClass.readableName())},
8932 		new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
8933 		currentMethod.sourceStart(),
8934 		currentMethod.sourceEnd());
8935 }
wildcardAssignment(TypeBinding variableType, TypeBinding expressionType, ASTNode location)8936 public void wildcardAssignment(TypeBinding variableType, TypeBinding expressionType, ASTNode location) {
8937 	this.handle(
8938 		IProblem.WildcardFieldAssignment,
8939 		new String[] {
8940 		        new String(expressionType.readableName()), new String(variableType.readableName()) },
8941 		new String[] {
8942 		        new String(expressionType.shortReadableName()), new String(variableType.shortReadableName()) },
8943 		location.sourceStart,
8944 		location.sourceEnd);
8945 }
wildcardInvocation(ASTNode location, TypeBinding receiverType, MethodBinding method, TypeBinding[] arguments)8946 public void wildcardInvocation(ASTNode location, TypeBinding receiverType, MethodBinding method, TypeBinding[] arguments) {
8947 	TypeBinding offendingArgument = null;
8948 	TypeBinding offendingParameter = null;
8949 	for (int i = 0, length = method.parameters.length; i < length; i++) {
8950 		TypeBinding parameter = method.parameters[i];
8951 		if (parameter.isWildcard() && (((WildcardBinding) parameter).boundKind != Wildcard.SUPER)) {
8952 			offendingParameter = parameter;
8953 			offendingArgument = arguments[i];
8954 			break;
8955 		}
8956 	}
8957 
8958 	if (method.isConstructor()) {
8959 		this.handle(
8960 			IProblem.WildcardConstructorInvocation,
8961 			new String[] {
8962 				new String(receiverType.sourceName()),
8963 				typesAsString(method, false),
8964 				new String(receiverType.readableName()),
8965 				typesAsString(arguments, false),
8966 				new String(offendingArgument.readableName()),
8967 				new String(offendingParameter.readableName()),
8968 			 },
8969 			new String[] {
8970 				new String(receiverType.sourceName()),
8971 				typesAsString(method, true),
8972 				new String(receiverType.shortReadableName()),
8973 				typesAsString(arguments, true),
8974 				new String(offendingArgument.shortReadableName()),
8975 				new String(offendingParameter.shortReadableName()),
8976 			 },
8977 			location.sourceStart,
8978 			location.sourceEnd);
8979     } else {
8980 		this.handle(
8981 			IProblem.WildcardMethodInvocation,
8982 			new String[] {
8983 				new String(method.selector),
8984 				typesAsString(method, false),
8985 				new String(receiverType.readableName()),
8986 				typesAsString(arguments, false),
8987 				new String(offendingArgument.readableName()),
8988 				new String(offendingParameter.readableName()),
8989 			 },
8990 			new String[] {
8991 				new String(method.selector),
8992 				typesAsString(method, true),
8993 				new String(receiverType.shortReadableName()),
8994 				typesAsString(arguments, true),
8995 				new String(offendingArgument.shortReadableName()),
8996 				new String(offendingParameter.shortReadableName()),
8997 			 },
8998 			location.sourceStart,
8999 			location.sourceEnd);
9000     }
9001 }
wrongSequenceOfExceptionTypesError(TypeReference typeRef, TypeBinding exceptionType, TypeBinding hidingExceptionType)9002 public void wrongSequenceOfExceptionTypesError(TypeReference typeRef, TypeBinding exceptionType, TypeBinding hidingExceptionType) {
9003 	//the two catch block under and upper are in an incorrect order.
9004 	//under should be define BEFORE upper in the source
9005 
9006 	this.handle(
9007 		IProblem.InvalidCatchBlockSequence,
9008 		new String[] {
9009 			new String(exceptionType.readableName()),
9010 			new String(hidingExceptionType.readableName()),
9011 		 },
9012 		new String[] {
9013 			new String(exceptionType.shortReadableName()),
9014 			new String(hidingExceptionType.shortReadableName()),
9015 		 },
9016 		typeRef.sourceStart,
9017 		typeRef.sourceEnd);
9018 }
wrongSequenceOfExceptionTypes(TypeReference typeRef, TypeBinding exceptionType, TypeBinding hidingExceptionType)9019 public void wrongSequenceOfExceptionTypes(TypeReference typeRef, TypeBinding exceptionType, TypeBinding hidingExceptionType) {
9020 	// type references inside a multi-catch block are not of union type
9021 	this.handle(
9022 		IProblem.InvalidUnionTypeReferenceSequence,
9023 		new String[] {
9024 			new String(exceptionType.readableName()),
9025 			new String(hidingExceptionType.readableName()),
9026 		 },
9027 		new String[] {
9028 			new String(exceptionType.shortReadableName()),
9029 			new String(hidingExceptionType.shortReadableName()),
9030 		 },
9031 		typeRef.sourceStart,
9032 		typeRef.sourceEnd);
9033 }
9034 
autoManagedResourcesNotBelow17(LocalDeclaration[] resources)9035 public void autoManagedResourcesNotBelow17(LocalDeclaration[] resources) {
9036 	this.handle(
9037 			IProblem.AutoManagedResourceNotBelow17,
9038 			NoArgument,
9039 			NoArgument,
9040 			resources[0].declarationSourceStart,
9041 			resources[resources.length - 1].declarationSourceEnd);
9042 }
cannotInferElidedTypes(AllocationExpression allocationExpression)9043 public void cannotInferElidedTypes(AllocationExpression allocationExpression) {
9044 	String arguments [] = new String [] { allocationExpression.type.toString() };
9045 	this.handle(
9046 			IProblem.CannotInferElidedTypes,
9047 			arguments,
9048 			arguments,
9049 			allocationExpression.sourceStart,
9050 			allocationExpression.sourceEnd);
9051 }
diamondNotWithExplicitTypeArguments(TypeReference[] typeArguments)9052 public void diamondNotWithExplicitTypeArguments(TypeReference[] typeArguments) {
9053 	this.handle(
9054 			IProblem.CannotUseDiamondWithExplicitTypeArguments,
9055 			NoArgument,
9056 			NoArgument,
9057 			typeArguments[0].sourceStart,
9058 			typeArguments[typeArguments.length - 1].sourceEnd);
9059 }
rawConstructorReferenceNotWithExplicitTypeArguments(TypeReference[] typeArguments)9060 public void rawConstructorReferenceNotWithExplicitTypeArguments(TypeReference[] typeArguments) {
9061 	this.handle(
9062 			IProblem.IllegalTypeArgumentsInRawConstructorReference,
9063 			NoArgument,
9064 			NoArgument,
9065 			typeArguments[0].sourceStart,
9066 			typeArguments[typeArguments.length - 1].sourceEnd);
9067 }
diamondNotWithAnoymousClasses(TypeReference type)9068 public void diamondNotWithAnoymousClasses(TypeReference type) {
9069 	this.handle(
9070 			IProblem.CannotUseDiamondWithAnonymousClasses,
9071 			NoArgument,
9072 			NoArgument,
9073 			type.sourceStart,
9074 			type.sourceEnd);
9075 }
redundantSpecificationOfTypeArguments(ASTNode location, TypeBinding[] argumentTypes)9076 public void redundantSpecificationOfTypeArguments(ASTNode location, TypeBinding[] argumentTypes) {
9077 	int severity = computeSeverity(IProblem.RedundantSpecificationOfTypeArguments);
9078 	if (severity != ProblemSeverities.Ignore) {
9079 		int sourceStart = -1;
9080 		if (location instanceof QualifiedTypeReference) {
9081 			QualifiedTypeReference ref = (QualifiedTypeReference)location;
9082 			sourceStart = (int) (ref.sourcePositions[ref.sourcePositions.length - 1] >> 32);
9083 		} else {
9084 			sourceStart = location.sourceStart;
9085 		}
9086 		this.handle(
9087 			IProblem.RedundantSpecificationOfTypeArguments,
9088 			new String[] {typesAsString(argumentTypes, false)},
9089 			new String[] {typesAsString(argumentTypes, true)},
9090 			severity,
9091 			sourceStart,
9092 			location.sourceEnd);
9093     }
9094 }
potentiallyUnclosedCloseable(FakedTrackingVariable trackVar, ASTNode location)9095 public void potentiallyUnclosedCloseable(FakedTrackingVariable trackVar, ASTNode location) {
9096 	String[] args = { trackVar.nameForReporting(location, this.referenceContext) };
9097 	if (location == null) {
9098 		this.handle(
9099 			IProblem.PotentiallyUnclosedCloseable,
9100 			args,
9101 			args,
9102 			trackVar.sourceStart,
9103 			trackVar.sourceEnd);
9104 	} else {
9105 		this.handle(
9106 			IProblem.PotentiallyUnclosedCloseableAtExit,
9107 			args,
9108 			args,
9109 			location.sourceStart,
9110 			location.sourceEnd);
9111 	}
9112 }
unclosedCloseable(FakedTrackingVariable trackVar, ASTNode location)9113 public void unclosedCloseable(FakedTrackingVariable trackVar, ASTNode location) {
9114 	String[] args = { String.valueOf(trackVar.name) };
9115 	if (location == null) {
9116 		this.handle(
9117 			IProblem.UnclosedCloseable,
9118 			args,
9119 			args,
9120 			trackVar.sourceStart,
9121 			trackVar.sourceEnd);
9122 	} else {
9123 		this.handle(
9124 			IProblem.UnclosedCloseableAtExit,
9125 			args,
9126 			args,
9127 			location.sourceStart,
9128 			location.sourceEnd);
9129 	}
9130 }
explicitlyClosedAutoCloseable(FakedTrackingVariable trackVar)9131 public void explicitlyClosedAutoCloseable(FakedTrackingVariable trackVar) {
9132 	String[] args = { String.valueOf(trackVar.name) };
9133 	this.handle(
9134 		IProblem.ExplicitlyClosedAutoCloseable,
9135 		args,
9136 		args,
9137 		trackVar.sourceStart,
9138 		trackVar.sourceEnd);
9139 }
9140 
nullityMismatch(Expression expression, TypeBinding providedType, TypeBinding requiredType, int nullStatus, char[][] annotationName)9141 public void nullityMismatch(Expression expression, TypeBinding providedType, TypeBinding requiredType, int nullStatus, char[][] annotationName) {
9142 	if ((nullStatus & FlowInfo.NULL) != 0) {
9143 		nullityMismatchIsNull(expression, requiredType);
9144 		return;
9145 	}
9146 	if (expression instanceof MessageSend) {
9147 		if ((((MessageSend) expression).binding.tagBits & TagBits.AnnotationNullable) != 0) {
9148 			nullityMismatchSpecdNullable(expression, requiredType, this.options.nonNullAnnotationName);
9149 			return;
9150 		}
9151 	}
9152 	if ((nullStatus & FlowInfo.POTENTIALLY_NULL) != 0) {
9153 		VariableBinding var = expression.localVariableBinding();
9154 		if (var == null && expression instanceof Reference) {
9155 			var = ((Reference)expression).lastFieldBinding();
9156 		}
9157 		if (var != null && var.isNullable()) {
9158 			nullityMismatchSpecdNullable(expression, requiredType, annotationName);
9159 			return;
9160 		}
9161 		nullityMismatchPotentiallyNull(expression, requiredType, annotationName);
9162 		return;
9163 	}
9164 	if (this.options.sourceLevel < ClassFileConstants.JDK1_8)
9165 		nullityMismatchIsUnknown(expression, providedType, requiredType, annotationName);
9166 	else
9167 		nullityMismatchingTypeAnnotation(expression, providedType, requiredType, NullAnnotationMatching.NULL_ANNOTATIONS_UNCHECKED);
9168 }
nullityMismatchIsNull(Expression expression, TypeBinding requiredType)9169 public void nullityMismatchIsNull(Expression expression, TypeBinding requiredType) {
9170 	int problemId = IProblem.RequiredNonNullButProvidedNull;
9171 	boolean below18 = this.options.sourceLevel < ClassFileConstants.JDK1_8;
9172 	if (!below18 && requiredType.isTypeVariable() && !requiredType.hasNullTypeAnnotations())
9173 		problemId = IProblem.NullNotCompatibleToFreeTypeVariable;
9174 	if (requiredType instanceof CaptureBinding) {
9175 		CaptureBinding capture = (CaptureBinding) requiredType;
9176 		if (capture.wildcard != null)
9177 			requiredType = capture.wildcard;
9178 	}
9179 	String[] arguments;
9180 	String[] argumentsShort;
9181 	if (below18) {
9182 		arguments      = new String[] { annotatedTypeName(requiredType, this.options.nonNullAnnotationName) };
9183 		argumentsShort = new String[] { shortAnnotatedTypeName(requiredType, this.options.nonNullAnnotationName) };
9184 	} else {
9185 		if (problemId == IProblem.NullNotCompatibleToFreeTypeVariable) {
9186 			arguments      = new String[] { new String(requiredType.sourceName()) }; // don't show any bounds
9187 			argumentsShort = new String[] { new String(requiredType.sourceName()) };
9188 		} else {
9189 			arguments      = new String[] { new String(requiredType.nullAnnotatedReadableName(this.options, false)) };
9190 			argumentsShort = new String[] { new String(requiredType.nullAnnotatedReadableName(this.options, true))  };
9191 		}
9192 	}
9193 	this.handle(problemId, arguments, argumentsShort, expression.sourceStart, expression.sourceEnd);
9194 }
9195 public void nullityMismatchSpecdNullable(Expression expression, TypeBinding requiredType, char[][] annotationName) {
9196 	int problemId = IProblem.RequiredNonNullButProvidedSpecdNullable;
9197 	char[][] nullableName = this.options.nullableAnnotationName;
9198 	String[] arguments = new String[] {
9199 			annotatedTypeName(requiredType, annotationName),
9200 			String.valueOf(CharOperation.concatWith(nullableName, '.'))
9201 	};
9202 	String[] argumentsShort = new String[] {
9203 			shortAnnotatedTypeName(requiredType, annotationName),
9204 			String.valueOf(nullableName[nullableName.length-1])
9205 	};
9206 	this.handle(problemId, arguments, argumentsShort, expression.sourceStart, expression.sourceEnd);
9207 }
9208 public void nullityMismatchPotentiallyNull(Expression expression, TypeBinding requiredType, char[][] annotationName) {
9209 	int problemId = IProblem.RequiredNonNullButProvidedPotentialNull;
9210 	char[][] nullableName = this.options.nullableAnnotationName;
9211 	String[] arguments = new String[] {
9212 			annotatedTypeName(requiredType, annotationName),
9213 			String.valueOf(CharOperation.concatWith(nullableName, '.'))
9214 	};
9215 	String[] argumentsShort = new String[] {
9216 			shortAnnotatedTypeName(requiredType, annotationName),
9217 			String.valueOf(nullableName[nullableName.length-1])
9218 	};
9219 	this.handle(problemId, arguments, argumentsShort, expression.sourceStart, expression.sourceEnd);
9220 }
9221 public void nullityMismatchIsUnknown(Expression expression, TypeBinding providedType, TypeBinding requiredType, char[][] annotationName) {
9222 	int problemId = IProblem.RequiredNonNullButProvidedUnknown;
9223 	String[] arguments = new String[] {
9224 			String.valueOf(providedType.readableName()),
9225 			annotatedTypeName(requiredType, annotationName)
9226 	};
9227 	String[] argumentsShort = new String[] {
9228 			String.valueOf(providedType.shortReadableName()),
9229 			shortAnnotatedTypeName(requiredType, annotationName)
9230 	};
9231 	this.handle(problemId, arguments, argumentsShort, expression.sourceStart, expression.sourceEnd);
9232 }
9233 public void illegalRedefinitionToNonNullParameter(Argument argument, ReferenceBinding declaringClass, char[][] inheritedAnnotationName) {
9234 	int sourceStart = argument.type.sourceStart;
9235 	if (argument.annotations != null) {
9236 		for (int i=0; i<argument.annotations.length; i++) {
9237 			Annotation annotation = argument.annotations[i];
9238 			if (   annotation.resolvedType.id == TypeIds.T_ConfiguredAnnotationNullable
9239 				|| annotation.resolvedType.id == TypeIds.T_ConfiguredAnnotationNonNull)
9240 			{
9241 				sourceStart = annotation.sourceStart;
9242 				break;
9243 			}
9244 		}
9245 	}
9246 	if (inheritedAnnotationName == null) {
9247 		this.handle(
9248 			IProblem.IllegalDefinitionToNonNullParameter,
9249 			new String[] { new String(argument.name), new String(declaringClass.readableName()) },
9250 			new String[] { new String(argument.name), new String(declaringClass.shortReadableName()) },
9251 			sourceStart,
9252 			argument.type.sourceEnd);
9253 	} else {
9254 		this.handle(
9255 			IProblem.IllegalRedefinitionToNonNullParameter,
9256 			new String[] { new String(argument.name), new String(declaringClass.readableName()), CharOperation.toString(inheritedAnnotationName)},
9257 			new String[] { new String(argument.name), new String(declaringClass.shortReadableName()), new String(inheritedAnnotationName[inheritedAnnotationName.length-1])},
9258 			sourceStart,
9259 			argument.type.sourceEnd);
9260 	}
9261 }
9262 public void parameterLackingNullableAnnotation(Argument argument, ReferenceBinding declaringClass, char[][] inheritedAnnotationName) {
9263 	this.handle(
9264 		IProblem.ParameterLackingNullableAnnotation,
9265 		new String[] { new String(declaringClass.readableName()), CharOperation.toString(inheritedAnnotationName)},
9266 		new String[] { new String(declaringClass.shortReadableName()), new String(inheritedAnnotationName[inheritedAnnotationName.length-1])},
9267 		argument.type.sourceStart,
9268 		argument.type.sourceEnd);
9269 }
9270 public void parameterLackingNonnullAnnotation(Argument argument, ReferenceBinding declaringClass, char[][] inheritedAnnotationName) {
9271 	int sourceStart = 0, sourceEnd = 0;
9272 	if (argument != null) {
9273 		sourceStart = argument.type.sourceStart;
9274 		sourceEnd = argument.type.sourceEnd;
9275 	} else if (this.referenceContext instanceof TypeDeclaration) {
9276 		sourceStart = ((TypeDeclaration) this.referenceContext).sourceStart;
9277 		sourceEnd =   ((TypeDeclaration) this.referenceContext).sourceEnd;
9278 	}
9279 	this.handle(
9280 		IProblem.ParameterLackingNonNullAnnotation,
9281 		new String[] { new String(declaringClass.readableName()), CharOperation.toString(inheritedAnnotationName)},
9282 		new String[] { new String(declaringClass.shortReadableName()), new String(inheritedAnnotationName[inheritedAnnotationName.length-1])},
9283 		sourceStart,
9284 		sourceEnd);
9285 }
9286 public void illegalReturnRedefinition(AbstractMethodDeclaration abstractMethodDecl, MethodBinding inheritedMethod, char[][] nonNullAnnotationName) {
9287 	MethodDeclaration methodDecl = (MethodDeclaration) abstractMethodDecl;
9288 	StringBuffer methodSignature = new StringBuffer();
9289 	methodSignature
9290 		.append(inheritedMethod.declaringClass.readableName())
9291 		.append('.')
9292 		.append(inheritedMethod.readableName());
9293 
9294 	StringBuffer shortSignature = new StringBuffer();
9295 	shortSignature
9296 		.append(inheritedMethod.declaringClass.shortReadableName())
9297 		.append('.')
9298 		.append(inheritedMethod.shortReadableName());
9299 	int sourceStart = methodDecl.returnType.sourceStart;
9300 	Annotation[] annotations = methodDecl.annotations;
9301 	Annotation annotation = findAnnotation(annotations, TypeIds.T_ConfiguredAnnotationNullable);
9302 	if (annotation != null) {
9303 		sourceStart = annotation.sourceStart;
9304 	}
9305 	this.handle(
9306 		IProblem.IllegalReturnNullityRedefinition,
9307 		new String[] { methodSignature.toString(), CharOperation.toString(nonNullAnnotationName)},
9308 		new String[] { shortSignature.toString(), new String(nonNullAnnotationName[nonNullAnnotationName.length-1])},
9309 		sourceStart,
9310 		methodDecl.returnType.sourceEnd);
9311 }
9312 public void referenceExpressionArgumentNullityMismatch(ReferenceExpression location, TypeBinding requiredType, TypeBinding providedType,
9313 		MethodBinding descriptorMethod, int idx, NullAnnotationMatching status) {
9314 	StringBuffer methodSignature = new StringBuffer();
9315 	methodSignature
9316 		.append(descriptorMethod.declaringClass.readableName())
9317 		.append('.')
9318 		.append(descriptorMethod.readableName());
9319 	StringBuffer shortSignature = new StringBuffer();
9320 	shortSignature
9321 		.append(descriptorMethod.declaringClass.shortReadableName())
9322 		.append('.')
9323 		.append(descriptorMethod.shortReadableName());
9324 	this.handle(
9325 			status.isUnchecked() ? IProblem.ReferenceExpressionParameterNullityUnchecked : IProblem.ReferenceExpressionParameterNullityMismatch,
9326 			new String[] { String.valueOf(idx+1),
9327 							String.valueOf(requiredType.nullAnnotatedReadableName(this.options, false)),
9328 							String.valueOf(providedType.nullAnnotatedReadableName(this.options, false)),
9329 							methodSignature.toString() },
9330 			new String[] { String.valueOf(idx+1),
9331 							String.valueOf(requiredType.nullAnnotatedReadableName(this.options, true)),
9332 							String.valueOf(providedType.nullAnnotatedReadableName(this.options, true)),
9333 							shortSignature.toString() },
9334 			location.sourceStart,
9335 			location.sourceEnd);
9336 }
9337 public void illegalReturnRedefinition(ASTNode location, MethodBinding descriptorMethod,
9338 			char[][] nonNullAnnotationName,
9339 			char/*@Nullable*/[][] providedAnnotationName, TypeBinding providedType) {
9340 	StringBuffer methodSignature = new StringBuffer()
9341 		.append(descriptorMethod.declaringClass.readableName())
9342 		.append('.')
9343 		.append(descriptorMethod.readableName());
9344 	StringBuffer shortSignature = new StringBuffer()
9345 		.append(descriptorMethod.declaringClass.shortReadableName())
9346 		.append('.')
9347 		.append(descriptorMethod.shortReadableName());
9348 	StringBuffer providedPrefix = new StringBuffer();
9349 	StringBuffer providedShortPrefix = new StringBuffer();
9350 	if (providedAnnotationName != null) {
9351 		providedPrefix.append('@').append(CharOperation.toString(providedAnnotationName)).append(' ');
9352 		providedShortPrefix.append('@').append(providedAnnotationName[providedAnnotationName.length-1]).append(' ');
9353 	}
9354 	this.handle(
9355 		providedAnnotationName == null
9356 			? IProblem.ReferenceExpressionReturnNullRedefUnchecked
9357 			: IProblem.ReferenceExpressionReturnNullRedef,
9358 		new String[] { methodSignature.toString(),
9359 						CharOperation.toString(nonNullAnnotationName), String.valueOf(descriptorMethod.returnType.readableName()),
9360 						providedPrefix.toString(), String.valueOf(providedType.readableName())},
9361 		new String[] { shortSignature.toString(),
9362 						String.valueOf(nonNullAnnotationName[nonNullAnnotationName.length-1]), String.valueOf(descriptorMethod.returnType.shortReadableName()),
9363 						providedShortPrefix.toString(), String.valueOf(providedType.shortReadableName())},
9364 		location.sourceStart,
9365 		location.sourceEnd);
9366 }
9367 public void messageSendPotentialNullReference(MethodBinding method, ASTNode location) {
9368 	String[] arguments = new String[] {new String(method.readableName())};
9369 	this.handle(
9370 		IProblem.PotentialNullMessageSendReference,
9371 		arguments,
9372 		arguments,
9373 		location.sourceStart,
9374 		location.sourceEnd);
9375 }
9376 public void messageSendRedundantCheckOnNonNull(MethodBinding method, ASTNode location) {
9377 	String[] arguments = new String[] {new String(method.readableName())  };
9378 	this.handle(
9379 		IProblem.RedundantNullCheckOnNonNullMessageSend,
9380 		arguments,
9381 		arguments,
9382 		location.sourceStart,
9383 		location.sourceEnd);
9384 }
9385 public void expressionNullReference(ASTNode location) {
9386 	this.handle(
9387 		IProblem.NullExpressionReference,
9388 		NoArgument,
9389 		NoArgument,
9390 		location.sourceStart,
9391 		location.sourceEnd);
9392 }
9393 public void expressionPotentialNullReference(ASTNode location) {
9394 	this.handle(
9395 		IProblem.PotentialNullExpressionReference,
9396 		NoArgument,
9397 		NoArgument,
9398 		location.sourceStart,
9399 		location.sourceEnd);
9400 }
9401 
9402 public void cannotImplementIncompatibleNullness(MethodBinding currentMethod, MethodBinding inheritedMethod, boolean showReturn) {
9403 	int sourceStart = 0, sourceEnd = 0;
9404 	if (this.referenceContext instanceof TypeDeclaration) {
9405 		sourceStart = ((TypeDeclaration) this.referenceContext).sourceStart;
9406 		sourceEnd =   ((TypeDeclaration) this.referenceContext).sourceEnd;
9407 	}
9408 	String[] problemArguments = {
9409 			showReturn
9410 				? new String(currentMethod.returnType.nullAnnotatedReadableName(this.options, false))+' '
9411 				: "", //$NON-NLS-1$
9412 			new String(currentMethod.selector),
9413 			typesAsString(currentMethod, false, true),
9414 			new String(currentMethod.declaringClass.readableName()),
9415 			new String(inheritedMethod.declaringClass.readableName())
9416 		};
9417 	String[] messageArguments = {
9418 			showReturn
9419 				? new String(currentMethod.returnType.nullAnnotatedReadableName(this.options, true))+' '
9420 				: "", //$NON-NLS-1$
9421 			new String(currentMethod.selector),
9422 			typesAsString(currentMethod, true, true),
9423 			new String(currentMethod.declaringClass.shortReadableName()),
9424 			new String(inheritedMethod.declaringClass.shortReadableName())
9425 		};
9426 	this.handle(
9427 			IProblem.CannotImplementIncompatibleNullness,
9428 			problemArguments,
9429 			messageArguments,
9430 			sourceStart,
9431 			sourceEnd);
9432 }
9433 
9434 public void nullAnnotationIsRedundant(AbstractMethodDeclaration sourceMethod, int i) {
9435 	int sourceStart, sourceEnd;
9436 	if (i == -1) {
9437 		MethodDeclaration methodDecl = (MethodDeclaration) sourceMethod;
9438 		Annotation annotation = findAnnotation(methodDecl.annotations, TypeIds.T_ConfiguredAnnotationNonNull);
9439 		sourceStart = annotation != null ? annotation.sourceStart : methodDecl.returnType.sourceStart;
9440 		sourceEnd = methodDecl.returnType.sourceEnd;
9441 	} else {
9442 		Argument arg = sourceMethod.arguments[i];
9443 		sourceStart = arg.declarationSourceStart;
9444 		sourceEnd = arg.sourceEnd;
9445 	}
9446 	this.handle(IProblem.RedundantNullAnnotation, ProblemHandler.NoArgument, ProblemHandler.NoArgument, sourceStart, sourceEnd);
9447 }
9448 
9449 public void nullAnnotationIsRedundant(FieldDeclaration sourceField) {
9450 	Annotation annotation = findAnnotation(sourceField.annotations, TypeIds.T_ConfiguredAnnotationNonNull);
9451 	int sourceStart = annotation != null ? annotation.sourceStart : sourceField.type.sourceStart;
9452 	int sourceEnd = sourceField.type.sourceEnd;
9453 	this.handle(IProblem.RedundantNullAnnotation, ProblemHandler.NoArgument, ProblemHandler.NoArgument, sourceStart, sourceEnd);
9454 }
9455 
9456 public void nullDefaultAnnotationIsRedundant(ASTNode location, Annotation[] annotations, Binding outer) {
9457 	Annotation annotation = findAnnotation(annotations, TypeIds.T_ConfiguredAnnotationNonNullByDefault);
9458 	int start = annotation != null ? annotation.sourceStart : location.sourceStart;
9459 	int end = annotation != null ? annotation.sourceEnd : location.sourceStart;
9460 	String[] args = NoArgument;
9461 	String[] shortArgs = NoArgument;
9462 	if (outer != null) {
9463 		args = new String[] { new String(outer.readableName()) };
9464 		shortArgs = new String[] { new String(outer.shortReadableName()) };
9465 	}
9466 	int problemId = IProblem.RedundantNullDefaultAnnotation;
9467 	if (outer instanceof PackageBinding) {
9468 		problemId = IProblem.RedundantNullDefaultAnnotationPackage;
9469 	} else if (outer instanceof ReferenceBinding) {
9470 		problemId = IProblem.RedundantNullDefaultAnnotationType;
9471 	} else if (outer instanceof MethodBinding) {
9472 		problemId = IProblem.RedundantNullDefaultAnnotationMethod;
9473 	}
9474 	this.handle(problemId, args, shortArgs, start, end);
9475 }
9476 
9477 public void contradictoryNullAnnotations(Annotation annotation) {
9478 	contradictoryNullAnnotations(annotation.sourceStart, annotation.sourceEnd);
9479 }
9480 
9481 public void contradictoryNullAnnotations(Annotation[] annotations) {
9482 	contradictoryNullAnnotations(annotations[0].sourceStart, annotations[annotations.length-1].sourceEnd);
9483 }
9484 
9485 public void contradictoryNullAnnotations(int sourceStart, int sourceEnd) {
9486 	// when this error is triggered we can safely assume that both annotations have been configured
9487 	char[][] nonNullAnnotationName = this.options.nonNullAnnotationName;
9488 	char[][] nullableAnnotationName = this.options.nullableAnnotationName;
9489 	String[] arguments = {
9490 		new String(CharOperation.concatWith(nonNullAnnotationName, '.')),
9491 		new String(CharOperation.concatWith(nullableAnnotationName, '.'))
9492 	};
9493 	String[] shortArguments = {
9494 			new String(nonNullAnnotationName[nonNullAnnotationName.length-1]),
9495 			new String(nullableAnnotationName[nullableAnnotationName.length-1])
9496 		};
9497 	this.handle(IProblem.ContradictoryNullAnnotations, arguments, shortArguments, sourceStart, sourceEnd);
9498 }
9499 
9500 public void contradictoryNullAnnotationsInferred(MethodBinding inferredMethod, ASTNode location) {
9501 	contradictoryNullAnnotationsInferred(inferredMethod, location.sourceStart, location.sourceEnd);
9502 }
9503 public void contradictoryNullAnnotationsInferred(MethodBinding inferredMethod, InvocationSite location) {
9504 	contradictoryNullAnnotationsInferred(inferredMethod, location.sourceStart(), location.sourceEnd());
9505 }
9506 public void contradictoryNullAnnotationsInferred(MethodBinding inferredMethod, int sourceStart, int sourceEnd) {
9507 	// when this error is triggered we can safely assume that both annotations have been configured
9508 	char[][] nonNullAnnotationName = this.options.nonNullAnnotationName;
9509 	char[][] nullableAnnotationName = this.options.nullableAnnotationName;
9510 	String[] arguments = {
9511 		new String(CharOperation.concatWith(nonNullAnnotationName, '.')),
9512 		new String(CharOperation.concatWith(nullableAnnotationName, '.')),
9513 		new String(inferredMethod.returnType.nullAnnotatedReadableName(this.options, false)),
9514 		new String(inferredMethod.selector),
9515 		typesAsString(inferredMethod, false, true)
9516 	};
9517 	String[] shortArguments = {
9518 			new String(nonNullAnnotationName[nonNullAnnotationName.length-1]),
9519 			new String(nullableAnnotationName[nullableAnnotationName.length-1]),
9520 			new String(inferredMethod.returnType.nullAnnotatedReadableName(this.options, true)),
9521 			new String(inferredMethod.selector),
9522 			typesAsString(inferredMethod, true, true)
9523 		};
9524 	this.handle(IProblem.ContradictoryNullAnnotationsInferred, arguments, shortArguments, sourceStart, sourceEnd);
9525 }
9526 
9527 public void contradictoryNullAnnotationsOnBounds(Annotation annotation, long previousTagBit) {
9528 	char[][] annotationName = previousTagBit == TagBits.AnnotationNonNull ? this.options.nonNullAnnotationName : this.options.nullableAnnotationName;
9529 	String[] arguments = {
9530 		new String(CharOperation.concatWith(annotationName, '.')),
9531 	};
9532 	String[] shortArguments = {
9533 		new String(annotationName[annotationName.length-1]),
9534 	};
9535 	this.handle(IProblem.ContradictoryNullAnnotationsOnBound, arguments, shortArguments, annotation.sourceStart, annotation.sourceEnd);
9536 }
9537 
9538 // conflict default <-> inherited
9539 public void conflictingNullAnnotations(MethodBinding currentMethod, ASTNode location, MethodBinding inheritedMethod)
9540 {
9541 	char[][] nonNullAnnotationName = this.options.nonNullAnnotationName;
9542 	char[][] nullableAnnotationName = this.options.nullableAnnotationName;
9543 	String[] arguments = {
9544 		new String(CharOperation.concatWith(nonNullAnnotationName, '.')),
9545 		new String(CharOperation.concatWith(nullableAnnotationName, '.')),
9546 		new String(inheritedMethod.declaringClass.readableName())
9547 	};
9548 	String[] shortArguments = {
9549 			new String(nonNullAnnotationName[nonNullAnnotationName.length-1]),
9550 			new String(nullableAnnotationName[nullableAnnotationName.length-1]),
9551 			new String(inheritedMethod.declaringClass.shortReadableName())
9552 		};
9553 	this.handle(IProblem.ConflictingNullAnnotations, arguments, shortArguments, location.sourceStart, location.sourceEnd);
9554 }
9555 
9556 // conflict between different inheriteds
9557 public void conflictingInheritedNullAnnotations(ASTNode location, boolean previousIsNonNull, MethodBinding previousInherited, boolean isNonNull, MethodBinding inheritedMethod)
9558 {
9559 	char[][] previousAnnotationName = previousIsNonNull ? this.options.nonNullAnnotationName : this.options.nullableAnnotationName;
9560 	char[][] annotationName = isNonNull ? this.options.nonNullAnnotationName : this.options.nullableAnnotationName;
9561 	String[] arguments = {
9562 		new String(CharOperation.concatWith(previousAnnotationName, '.')),
9563 		new String(previousInherited.declaringClass.readableName()),
9564 		new String(CharOperation.concatWith(annotationName, '.')),
9565 		new String(inheritedMethod.declaringClass.readableName())
9566 	};
9567 	String[] shortArguments = {
9568 			new String(previousAnnotationName[previousAnnotationName.length-1]),
9569 			new String(previousInherited.declaringClass.shortReadableName()),
9570 			new String(annotationName[annotationName.length-1]),
9571 			new String(inheritedMethod.declaringClass.shortReadableName())
9572 		};
9573 	this.handle(IProblem.ConflictingInheritedNullAnnotations, arguments, shortArguments, location.sourceStart, location.sourceEnd);
9574 }
9575 
9576 public void illegalAnnotationForBaseType(TypeReference type, Annotation[] annotations, long nullAnnotationTagBit)
9577 {
9578 	int typeId = (nullAnnotationTagBit == TagBits.AnnotationNullable)
9579 			? TypeIds.T_ConfiguredAnnotationNullable : TypeIds.T_ConfiguredAnnotationNonNull;
9580 	char[][] annotationNames = (nullAnnotationTagBit == TagBits.AnnotationNonNull)
9581 			? this.options.nonNullAnnotationName
9582 			: this.options.nullableAnnotationName;
9583 	String[] args = new String[] { new String(annotationNames[annotationNames.length-1]), new String(type.getLastToken()) };
9584 	Annotation annotation = findAnnotation(annotations, typeId);
9585 	int start = annotation != null ? annotation.sourceStart : type.sourceStart;
9586 	int end = annotation != null ? annotation.sourceEnd : type.sourceEnd;
9587 	this.handle(IProblem.IllegalAnnotationForBaseType,
9588 			args,
9589 			args,
9590 			start,
9591 			end);
9592 }
9593 
9594 public void illegalAnnotationForBaseType(Annotation annotation, TypeBinding type)
9595 {
9596 	String[] args = new String[] {
9597 		new String(annotation.resolvedType.shortReadableName()),
9598 		new String(type.readableName())
9599 	};
9600 	this.handle(IProblem.IllegalAnnotationForBaseType,
9601 			args,
9602 			args,
9603 			annotation.sourceStart,
9604 			annotation.sourceEnd);
9605 }
9606 
9607 private String annotatedTypeName(TypeBinding type, char[][] annotationName) {
9608 	if ((type.tagBits & TagBits.AnnotationNullMASK) != 0)
9609 		return String.valueOf(type.nullAnnotatedReadableName(this.options, false));
9610 	int dims = 0;
9611 	char[] typeName = type.readableName();
9612 	char[] annotationDisplayName = CharOperation.concatWith(annotationName, '.');
9613 	return internalAnnotatedTypeName(annotationDisplayName, typeName, dims);
9614 }
9615 private String shortAnnotatedTypeName(TypeBinding type, char[][] annotationName) {
9616 	if ((type.tagBits & TagBits.AnnotationNullMASK) != 0)
9617 		return String.valueOf(type.nullAnnotatedReadableName(this.options, true));
9618 	int dims = 0;
9619 	char[] typeName = type.shortReadableName();
9620 	char[] annotationDisplayName = annotationName[annotationName.length-1];
9621 	return internalAnnotatedTypeName(annotationDisplayName, typeName, dims);
9622 }
9623 
9624 String internalAnnotatedTypeName(char[] annotationName, char[] typeName, int dims) {
9625 	char[] fullName;
9626 	if (dims > 0) {
9627 		int plainLen = annotationName.length+typeName.length+2; // adding '@' and ' ' ...
9628 		fullName = new char[plainLen+(2*dims)]; // ... and []*
9629 		System.arraycopy(typeName, 0, fullName, 0, typeName.length);
9630 		fullName[typeName.length] = ' ';
9631 		fullName[typeName.length+1] = '@';
9632 		System.arraycopy(annotationName, 0, fullName, typeName.length+2, annotationName.length);
9633 		for (int i=0; i<dims; i++) {
9634 			fullName[plainLen+i] = '[';
9635 			fullName[plainLen+i+1] = ']';
9636 		}
9637 	} else {
9638 		fullName = new char[annotationName.length+typeName.length+2]; // adding '@' and ' '
9639 		fullName[0] = '@';
9640 		System.arraycopy(annotationName, 0, fullName, 1, annotationName.length);
9641 		fullName[annotationName.length+1] = ' ';
9642 		System.arraycopy(typeName, 0, fullName, annotationName.length+2, typeName.length);
9643 	}
9644 	return String.valueOf(fullName);
9645 }
9646 private Annotation findAnnotation(Annotation[] annotations, int typeId) {
9647 	if (annotations != null) {
9648 		// should have a @NonNull/@Nullable annotation, search for it:
9649 		int length = annotations.length;
9650 		for (int j=0; j<length; j++) {
9651 			if (annotations[j].resolvedType != null && annotations[j].resolvedType.id == typeId) {
9652 				return annotations[j];
9653 			}
9654 		}
9655 	}
9656 	return null;
9657 }
9658 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=372012
9659 public void missingNonNullByDefaultAnnotation(TypeDeclaration type) {
9660 	int severity;
9661 	CompilationUnitDeclaration compUnitDecl = type.getCompilationUnitDeclaration();
9662 	String[] arguments;
9663 	if (compUnitDecl.currentPackage == null) {
9664 		severity = computeSeverity(IProblem.MissingNonNullByDefaultAnnotationOnType);
9665 		if (severity == ProblemSeverities.Ignore) return;
9666 		// Default package
9667 		TypeBinding binding = type.binding;
9668 		this.handle(
9669 				IProblem.MissingNonNullByDefaultAnnotationOnType,
9670 				new String[] {new String(binding.readableName()), },
9671 				new String[] {new String(binding.shortReadableName()),},
9672 				severity,
9673 				type.sourceStart,
9674 				type.sourceEnd);
9675 	} else {
9676 		severity = computeSeverity(IProblem.MissingNonNullByDefaultAnnotationOnPackage);
9677 		if (severity == ProblemSeverities.Ignore) return;
9678 		arguments = new String[] {CharOperation.toString(compUnitDecl.currentPackage.tokens)};
9679 		this.handle(
9680 			IProblem.MissingNonNullByDefaultAnnotationOnPackage,
9681 			arguments,
9682 			arguments,
9683 			severity,
9684 			compUnitDecl.currentPackage.sourceStart,
9685 			compUnitDecl.currentPackage.sourceEnd);
9686 	}
9687 }
9688 
9689 public void illegalModifiersForElidedType(Argument argument) {
9690 	String[] arg = new String[] {new String(argument.name)};
9691 	this.handle(
9692 			IProblem.IllegalModifiersForElidedType,
9693 			arg,
9694 			arg,
9695 			argument.declarationSourceStart,
9696 			argument.declarationSourceEnd);
9697 }
9698 
9699 public void illegalModifiers(int modifierSourceStart, int modifiersSourceEnd) {
9700 	this.handle(
9701 			IProblem.IllegalModifiers,
9702 			NoArgument,
9703 			NoArgument,
9704 			modifierSourceStart,
9705 			modifiersSourceEnd);
9706 }
9707 
9708 public void arrayReferencePotentialNullReference(ArrayReference arrayReference) {
9709 	// TODO(stephan): merge with other expressions
9710 	this.handle(IProblem.ArrayReferencePotentialNullReference, NoArgument, NoArgument, arrayReference.sourceStart, arrayReference.sourceEnd);
9711 
9712 }
9713 public void nullityMismatchingTypeAnnotation(Expression expression, TypeBinding providedType, TypeBinding requiredType, NullAnnotationMatching status)
9714 {
9715 	if (providedType.id == TypeIds.T_null) {
9716 		nullityMismatchIsNull(expression, requiredType);
9717 		return;
9718 	}
9719 	String[] arguments ;
9720 	String[] shortArguments;
9721 
9722 	int problemId = 0;
9723 	String superHint = null;
9724 	String superHintShort = null;
9725 	if (status.superTypeHint != null) {
9726 		problemId = (status.isUnchecked()
9727 			? IProblem.NullityUncheckedTypeAnnotationDetailSuperHint
9728 			: IProblem.NullityMismatchingTypeAnnotationSuperHint);
9729 		superHint = status.superTypeHintName(this.options, false);
9730 		superHintShort = status.superTypeHintName(this.options, true);
9731 	} else {
9732 		problemId = (status.isUnchecked()
9733 			? IProblem.NullityUncheckedTypeAnnotationDetail
9734 			: (requiredType.isTypeVariable() && !requiredType.hasNullTypeAnnotations())
9735 				? IProblem.NullityMismatchAgainstFreeTypeVariable
9736 				: IProblem.NullityMismatchingTypeAnnotation);
9737 		if (problemId == IProblem.NullityMismatchAgainstFreeTypeVariable) {
9738 			arguments      = new String[] { null, null, new String(requiredType.sourceName()) }; // don't show bounds here
9739 			shortArguments = new String[] { null, null, new String(requiredType.sourceName()) };
9740 		} else {
9741 			arguments      = new String[2];
9742 			shortArguments = new String[2];
9743 		}
9744 	}
9745 	String requiredName;
9746 	String requiredNameShort;
9747 	if (problemId == IProblem.NullityMismatchAgainstFreeTypeVariable) {
9748 		requiredName		= new String(requiredType.sourceName()); // don't show bounds here
9749 		requiredNameShort 	= new String(requiredType.sourceName()); // don't show bounds here
9750 	} else {
9751 		requiredName 		= new String(requiredType.nullAnnotatedReadableName(this.options, false));
9752 		requiredNameShort 	= new String(requiredType.nullAnnotatedReadableName(this.options, true));
9753 	}
9754 	String providedName		 = String.valueOf(providedType.nullAnnotatedReadableName(this.options, false));
9755 	String providedNameShort = String.valueOf(providedType.nullAnnotatedReadableName(this.options, true));
9756 	// assemble arguments:
9757 	if (superHint != null) {
9758 		arguments 		= new String[] { requiredName, providedName, superHint };
9759 		shortArguments 	= new String[] { requiredNameShort, providedNameShort, superHintShort };
9760 	} else {
9761 		arguments 		= new String[] { requiredName, providedName };
9762 		shortArguments 	= new String[] { requiredNameShort, providedNameShort };
9763 	}
9764 	this.handle(problemId, arguments, shortArguments, expression.sourceStart, expression.sourceEnd);
9765 }
9766 
9767 public void nullityMismatchTypeArgument(TypeBinding typeVariable, TypeBinding typeArgument, ASTNode location) {
9768 	String[] arguments = {
9769 		String.valueOf(typeVariable.nullAnnotatedReadableName(this.options, false)),
9770 		String.valueOf(typeArgument.nullAnnotatedReadableName(this.options, false))
9771 	};
9772 	String[] shortArguments = {
9773 		String.valueOf(typeVariable.nullAnnotatedReadableName(this.options, true)),
9774 		String.valueOf(typeArgument.nullAnnotatedReadableName(this.options, true))
9775 	};
9776 	this.handle(
9777 			IProblem.NullityMismatchTypeArgument,
9778 			arguments,
9779 			shortArguments,
9780 			location.sourceStart,
9781 			location.sourceEnd);
9782 }
9783 
9784 public void dereferencingNullableExpression(Expression expression) {
9785 	if (expression instanceof MessageSend) {
9786 		MessageSend send = (MessageSend) expression;
9787 		messageSendPotentialNullReference(send.binding, send);
9788 		return;
9789 	}
9790 	char[][] nullableName = this.options.nullableAnnotationName;
9791 	char[] nullableShort = nullableName[nullableName.length-1];
9792 	String[] arguments = { String.valueOf(nullableShort) };
9793 	// TODO(stephan): more sophisticated handling for various kinds of expressions
9794 	int start = nodeSourceStart(expression);
9795 	int end = nodeSourceEnd(expression);
9796 	this.handle(IProblem.DereferencingNullableExpression, arguments, arguments, start, end);
9797 }
9798 public void dereferencingNullableExpression(long positions, LookupEnvironment env) {
9799 	char[][] nullableName = env.getNullableAnnotationName();
9800 	char[] nullableShort = nullableName[nullableName.length-1];
9801 	String[] arguments = { String.valueOf(nullableShort) };
9802 	this.handle(IProblem.DereferencingNullableExpression, arguments, arguments, (int)(positions>>>32), (int)(positions&0xFFFF));
9803 }
onlyReferenceTypesInIntersectionCast(TypeReference typeReference)9804 public void onlyReferenceTypesInIntersectionCast(TypeReference typeReference) {
9805 	this.handle(
9806 			IProblem.IllegalBasetypeInIntersectionCast,
9807 			NoArgument,
9808 			NoArgument,
9809 			typeReference.sourceStart,
9810 			typeReference.sourceEnd);
9811 }
illegalArrayTypeInIntersectionCast(TypeReference typeReference)9812 public void illegalArrayTypeInIntersectionCast(TypeReference typeReference) {
9813 	this.handle(
9814 			IProblem.IllegalArrayTypeInIntersectionCast,
9815 			NoArgument,
9816 			NoArgument,
9817 			typeReference.sourceStart,
9818 			typeReference.sourceEnd);
9819 }
intersectionCastNotBelow18(TypeReference[] typeReferences)9820 public void intersectionCastNotBelow18(TypeReference[] typeReferences) {
9821 	int length = typeReferences.length;
9822 	this.handle(
9823 			IProblem.IntersectionCastNotBelow18,
9824 			NoArgument,
9825 			NoArgument,
9826 			typeReferences[0].sourceStart,
9827 			typeReferences[length -1].sourceEnd);
9828 }
9829 
duplicateBoundInIntersectionCast(TypeReference typeReference)9830 public void duplicateBoundInIntersectionCast(TypeReference typeReference) {
9831 	this.handle(
9832 			IProblem.DuplicateBoundInIntersectionCast,
9833 			NoArgument,
9834 			NoArgument,
9835 			typeReference.sourceStart,
9836 			typeReference.sourceEnd);
9837 }
9838 
multipleFunctionalInterfaces(FunctionalExpression functionalExpression)9839 public void multipleFunctionalInterfaces(FunctionalExpression functionalExpression) {
9840 	this.handle(
9841 			IProblem.MultipleFunctionalInterfaces,
9842 			NoArgument,
9843 			NoArgument,
9844 			functionalExpression.sourceStart,
9845 			functionalExpression.diagnosticsSourceEnd());
9846 }
lambdaRedeclaresArgument(Argument argument)9847 public void lambdaRedeclaresArgument(Argument argument) {
9848 	String[] arguments = new String[] {new String(argument.name)};
9849 	this.handle(
9850 		IProblem.LambdaRedeclaresArgument,
9851 		arguments,
9852 		arguments,
9853 		argument.sourceStart,
9854 		argument.sourceEnd);
9855 }
lambdaRedeclaresLocal(LocalDeclaration local)9856 public void lambdaRedeclaresLocal(LocalDeclaration local) {
9857 	String[] arguments = new String[] {new String(local.name)};
9858 	this.handle(
9859 		IProblem.LambdaRedeclaresLocal,
9860 		arguments,
9861 		arguments,
9862 		local.sourceStart,
9863 		local.sourceEnd);
9864 }
9865 
descriptorHasInvisibleType(FunctionalExpression expression, ReferenceBinding referenceBinding)9866 public void descriptorHasInvisibleType(FunctionalExpression expression, ReferenceBinding referenceBinding) {
9867 	this.handle(
9868 		IProblem.LambdaDescriptorMentionsUnmentionable,
9869 		new String[] { new String(referenceBinding.readableName()) },
9870 		new String[] { new String(referenceBinding.shortReadableName()) },
9871 		expression.sourceStart,
9872 		expression.diagnosticsSourceEnd());
9873 }
9874 
methodReferenceSwingsBothWays(ReferenceExpression expression, MethodBinding instanceMethod, MethodBinding nonInstanceMethod)9875 public void methodReferenceSwingsBothWays(ReferenceExpression expression, MethodBinding instanceMethod, MethodBinding nonInstanceMethod) {
9876 	char [] selector = instanceMethod.selector;
9877 	TypeBinding receiverType = instanceMethod.declaringClass;
9878 	StringBuffer buffer1 = new StringBuffer();
9879 	StringBuffer shortBuffer1 = new StringBuffer();
9880 	TypeBinding [] parameters = instanceMethod.parameters;
9881 	for (int i = 0, length = parameters.length; i < length; i++) {
9882 		if (i != 0){
9883 			buffer1.append(", "); //$NON-NLS-1$
9884 			shortBuffer1.append(", "); //$NON-NLS-1$
9885 		}
9886 		buffer1.append(new String(parameters[i].readableName()));
9887 		shortBuffer1.append(new String(parameters[i].shortReadableName()));
9888 	}
9889 	StringBuffer buffer2 = new StringBuffer();
9890 	StringBuffer shortBuffer2 = new StringBuffer();
9891 	parameters = nonInstanceMethod.parameters;
9892 	for (int i = 0, length = parameters.length; i < length; i++) {
9893 		if (i != 0){
9894 			buffer2.append(", "); //$NON-NLS-1$
9895 			shortBuffer2.append(", "); //$NON-NLS-1$
9896 		}
9897 		buffer2.append(new String(parameters[i].readableName()));
9898 		shortBuffer2.append(new String(parameters[i].shortReadableName()));
9899 	}
9900 
9901 	int id = IProblem.MethodReferenceSwingsBothWays;
9902 	this.handle(
9903 		id,
9904 		new String[] { new String(receiverType.readableName()), new String(selector), buffer1.toString(), new String(selector), buffer2.toString() },
9905 		new String[] { new String(receiverType.shortReadableName()), new String(selector), shortBuffer1.toString(), new String(selector), shortBuffer2.toString() },
9906 		expression.sourceStart,
9907 		expression.sourceEnd);
9908 }
9909 
methodMustBeAccessedStatically(ReferenceExpression expression, MethodBinding nonInstanceMethod)9910 public void methodMustBeAccessedStatically(ReferenceExpression expression, MethodBinding nonInstanceMethod) {
9911 	TypeBinding receiverType = nonInstanceMethod.declaringClass;
9912 	char [] selector = nonInstanceMethod.selector;
9913 	StringBuffer buffer = new StringBuffer();
9914 	StringBuffer shortBuffer = new StringBuffer();
9915 	TypeBinding [] parameters = nonInstanceMethod.parameters;
9916 	for (int i = 0, length = parameters.length; i < length; i++) {
9917 		if (i != 0){
9918 			buffer.append(", "); //$NON-NLS-1$
9919 			shortBuffer.append(", "); //$NON-NLS-1$
9920 		}
9921 		buffer.append(new String(parameters[i].readableName()));
9922 		shortBuffer.append(new String(parameters[i].shortReadableName()));
9923 	}
9924 	int id = IProblem.StaticMethodShouldBeAccessedStatically;
9925 	this.handle(
9926 		id,
9927 		new String[] { new String(receiverType.readableName()), new String(selector), buffer.toString() },
9928 		new String[] { new String(receiverType.shortReadableName()), new String(selector), shortBuffer.toString() },
9929 		expression.sourceStart,
9930 		expression.sourceEnd);
9931 }
9932 
methodMustBeAccessedWithInstance(ReferenceExpression expression, MethodBinding instanceMethod)9933 public void methodMustBeAccessedWithInstance(ReferenceExpression expression, MethodBinding instanceMethod) {
9934 	TypeBinding receiverType = instanceMethod.declaringClass;
9935 	char [] selector = instanceMethod.selector;
9936 	StringBuffer buffer = new StringBuffer();
9937 	StringBuffer shortBuffer = new StringBuffer();
9938 	TypeBinding [] parameters = instanceMethod.parameters;
9939 	for (int i = 0, length = parameters.length; i < length; i++) {
9940 		if (i != 0) {
9941 			buffer.append(", "); //$NON-NLS-1$
9942 			shortBuffer.append(", "); //$NON-NLS-1$
9943 		}
9944 		buffer.append(new String(parameters[i].readableName()));
9945 		shortBuffer.append(new String(parameters[i].shortReadableName()));
9946 	}
9947 	int id = IProblem.StaticMethodRequested;
9948 	this.handle(
9949 		id,
9950 		new String[] { new String(receiverType.readableName()), new String(selector), buffer.toString() },
9951 		new String[] { new String(receiverType.shortReadableName()), new String(selector), shortBuffer.toString() },
9952 		expression.sourceStart,
9953 		expression.sourceEnd);
9954 }
9955 
invalidArrayConstructorReference(ReferenceExpression expression, TypeBinding lhsType, TypeBinding[] parameters)9956 public void invalidArrayConstructorReference(ReferenceExpression expression, TypeBinding lhsType, TypeBinding[] parameters) {
9957 	StringBuffer buffer = new StringBuffer();
9958 	StringBuffer shortBuffer = new StringBuffer();
9959 	for (int i = 0, length = parameters.length; i < length; i++) {
9960 		if (i != 0) {
9961 			buffer.append(", "); //$NON-NLS-1$
9962 			shortBuffer.append(", "); //$NON-NLS-1$
9963 		}
9964 		buffer.append(new String(parameters[i].readableName()));
9965 		shortBuffer.append(new String(parameters[i].shortReadableName()));
9966 	}
9967 	int id = IProblem.InvalidArrayConstructorReference;
9968 	this.handle(
9969 		id,
9970 		new String[] { new String(lhsType.readableName()), buffer.toString() },
9971 		new String[] { new String(lhsType.shortReadableName()), shortBuffer.toString() },
9972 		expression.sourceStart,
9973 		expression.sourceEnd);
9974 }
9975 
constructedArrayIncompatible(ReferenceExpression expression, TypeBinding receiverType, TypeBinding returnType)9976 public void constructedArrayIncompatible(ReferenceExpression expression, TypeBinding receiverType, TypeBinding returnType) {
9977 	this.handle(
9978 			IProblem.ConstructedArrayIncompatible,
9979 			new String[] { new String(receiverType.readableName()), new String(returnType.readableName()) },
9980 			new String[] { new String(receiverType.shortReadableName()), new String(returnType.shortReadableName()) },
9981 			expression.sourceStart,
9982 			expression.sourceEnd);
9983 }
9984 
danglingReference(ReferenceExpression expression, TypeBinding receiverType, char[] selector, TypeBinding[] descriptorParameters)9985 public void danglingReference(ReferenceExpression expression, TypeBinding receiverType, char[] selector, TypeBinding[] descriptorParameters) {
9986 	StringBuffer buffer = new StringBuffer();
9987 	StringBuffer shortBuffer = new StringBuffer();
9988 	TypeBinding [] parameters = descriptorParameters;
9989 	for (int i = 0, length = parameters.length; i < length; i++) {
9990 		if (i != 0) {
9991 			buffer.append(", "); //$NON-NLS-1$
9992 			shortBuffer.append(", "); //$NON-NLS-1$
9993 		}
9994 		buffer.append(new String(parameters[i].readableName()));
9995 		shortBuffer.append(new String(parameters[i].shortReadableName()));
9996 	}
9997 
9998 	int id = IProblem.DanglingReference;
9999 	this.handle(
10000 		id,
10001 		new String[] { new String(receiverType.readableName()), new String(selector), buffer.toString() },
10002 		new String[] { new String(receiverType.shortReadableName()), new String(selector), shortBuffer.toString() },
10003 		expression.sourceStart,
10004 		expression.sourceEnd);
10005 }
unhandledException(TypeBinding exceptionType, ReferenceExpression location)10006 public void unhandledException(TypeBinding exceptionType, ReferenceExpression location) {
10007 	this.handle(IProblem.UnhandledException,
10008 		new String[] {new String(exceptionType.readableName())},
10009 		new String[] {new String(exceptionType.shortReadableName())},
10010 		location.sourceStart,
10011 		location.sourceEnd);
10012 }
10013 
incompatibleReturnType(ReferenceExpression expression, MethodBinding method, TypeBinding returnType)10014 public void incompatibleReturnType(ReferenceExpression expression, MethodBinding method, TypeBinding returnType) {
10015 	if (method.isConstructor()) {
10016 		this.handle(IProblem.ConstructionTypeMismatch,
10017 				new String[] { new String(method.declaringClass.readableName()), new String(returnType.readableName())},
10018 				new String[] { new String(method.declaringClass.shortReadableName()), new String(returnType.shortReadableName())},
10019 				expression.sourceStart,
10020 				expression.sourceEnd);
10021 
10022 	} else {
10023 		StringBuffer buffer = new StringBuffer();
10024 		StringBuffer shortBuffer = new StringBuffer();
10025 		TypeBinding [] parameters = method.parameters;
10026 		for (int i = 0, length = parameters.length; i < length; i++) {
10027 			if (i != 0) {
10028 				buffer.append(", "); //$NON-NLS-1$
10029 				shortBuffer.append(", "); //$NON-NLS-1$
10030 			}
10031 			buffer.append(new String(parameters[i].readableName()));
10032 			shortBuffer.append(new String(parameters[i].shortReadableName()));
10033 		}
10034 		String selector = new String(method.selector);
10035 		this.handle(IProblem.IncompatibleMethodReference,
10036 				new String[] { selector, buffer.toString(), new String(method.declaringClass.readableName()), new String(method.returnType.readableName()), new String(returnType.readableName())},
10037 				new String[] { selector, shortBuffer.toString(), new String(method.declaringClass.shortReadableName()), new String(method.returnType.shortReadableName()), new String(returnType.shortReadableName())},
10038 				expression.sourceStart,
10039 				expression.sourceEnd);
10040 	}
10041 }
10042 
illegalSuperAccess(TypeBinding superType, TypeBinding directSuperType, ASTNode location)10043 public void illegalSuperAccess(TypeBinding superType, TypeBinding directSuperType, ASTNode location) {
10044 	if (directSuperType.problemId() != ProblemReasons.AttemptToBypassDirectSuper)
10045 		needImplementation(location);
10046 	handle(IProblem.SuperAccessCannotBypassDirectSuper,
10047 			new String[] { String.valueOf(superType.readableName()), String.valueOf(directSuperType.readableName()) },
10048 			new String[] { String.valueOf(superType.shortReadableName()), String.valueOf(directSuperType.shortReadableName()) },
10049 			location.sourceStart,
10050 			location.sourceEnd);
10051 }
illegalSuperCallBypassingOverride(InvocationSite location, MethodBinding targetMethod, ReferenceBinding overrider)10052 public void illegalSuperCallBypassingOverride(InvocationSite location, MethodBinding targetMethod, ReferenceBinding overrider) {
10053 	this.handle(IProblem.SuperCallCannotBypassOverride,
10054 			new String[] { 	String.valueOf(targetMethod.readableName()),
10055 							String.valueOf(targetMethod.declaringClass.readableName()),
10056 							String.valueOf(overrider.readableName()) },
10057 			new String[] { 	String.valueOf(targetMethod.shortReadableName()),
10058 							String.valueOf(targetMethod.declaringClass.shortReadableName()),
10059 							String.valueOf(overrider.shortReadableName()) },
10060 			location.sourceStart(),
10061 			location.sourceEnd());
10062 }
disallowedTargetForContainerAnnotation(Annotation annotation, TypeBinding containerAnnotationType)10063 public void disallowedTargetForContainerAnnotation(Annotation annotation, TypeBinding containerAnnotationType) {
10064 	this.handle(
10065 		IProblem.DisallowedTargetForContainerAnnotationType,
10066 		new String[] {new String(annotation.resolvedType.readableName()), new String(containerAnnotationType.readableName())},
10067 		new String[] {new String(annotation.resolvedType.shortReadableName()), new String(containerAnnotationType.shortReadableName())},
10068 		annotation.sourceStart,
10069 		annotation.sourceEnd);
10070 }
genericInferenceError(String message, InvocationSite invocationSite)10071 public void genericInferenceError(String message, InvocationSite invocationSite) {
10072 	genericInferenceProblem(message, invocationSite, ProblemSeverities.Error);
10073 }
genericInferenceProblem(String message, InvocationSite invocationSite, int severity)10074 public void genericInferenceProblem(String message, InvocationSite invocationSite, int severity) {
10075 	String[] args = new String[]{message};
10076 	int start = 0, end = 0;
10077 	if (invocationSite != null) {
10078 		start = invocationSite.sourceStart();
10079 		end = invocationSite.sourceEnd();
10080 	}
10081 	this.handle(IProblem.GenericInferenceError, args, args, severity|ProblemSeverities.InternalError, start, end);
10082 }
uninternedIdentityComparison(EqualExpression expr, TypeBinding lhs, TypeBinding rhs, CompilationUnitDeclaration unit)10083 public void uninternedIdentityComparison(EqualExpression expr, TypeBinding lhs, TypeBinding rhs, CompilationUnitDeclaration unit) {
10084 
10085 	char [] lhsName = lhs.sourceName();
10086 	char [] rhsName = rhs.sourceName();
10087 
10088 	if (CharOperation.equals(lhsName, "VoidTypeBinding".toCharArray())  //$NON-NLS-1$
10089 			|| CharOperation.equals(lhsName, "NullTypeBinding".toCharArray())  //$NON-NLS-1$
10090 			|| CharOperation.equals(lhsName, "ProblemReferenceBinding".toCharArray())) //$NON-NLS-1$
10091 		return;
10092 
10093 	if (CharOperation.equals(rhsName, "VoidTypeBinding".toCharArray())  //$NON-NLS-1$
10094 			|| CharOperation.equals(rhsName, "NullTypeBinding".toCharArray())  //$NON-NLS-1$
10095 			|| CharOperation.equals(rhsName, "ProblemReferenceBinding".toCharArray())) //$NON-NLS-1$
10096 		return;
10097 
10098 	boolean[] validIdentityComparisonLines = unit.validIdentityComparisonLines;
10099 	if (validIdentityComparisonLines != null) {
10100 		int problemStartPosition = expr.left.sourceStart;
10101 		int[] lineEnds;
10102 		int lineNumber = problemStartPosition >= 0
10103 				? Util.getLineNumber(problemStartPosition, lineEnds = unit.compilationResult().getLineSeparatorPositions(), 0, lineEnds.length-1)
10104 						: 0;
10105 		if (lineNumber <= validIdentityComparisonLines.length && validIdentityComparisonLines[lineNumber - 1])
10106 			return;
10107 	}
10108 
10109 	this.handle(
10110 			IProblem.UninternedIdentityComparison,
10111 			new String[] {
10112 					new String(lhs.readableName()),
10113 					new String(rhs.readableName())
10114 			},
10115 			new String[] {
10116 					new String(lhs.shortReadableName()),
10117 					new String(rhs.shortReadableName())
10118 			},
10119 			expr.sourceStart,
10120 			expr.sourceEnd);
10121 }
10122 }
10123