1 /*******************************************************************************
2  * Copyright (c) 2000, 2020 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *     Benjamin Muskalla - Contribution for bug 239066
14  *     Stephan Herrmann  - Contributions for
15  *	     						bug 236385 - [compiler] Warn for potential programming problem if an object is created but not used
16  *  	   						bug 338303 - Warning about Redundant assignment conflicts with definite assignment
17  *								bug 349326 - [1.7] new warning for missing try-with-resources
18  *								bug 186342 - [compiler][null] Using annotations for null checking
19  *								bug 365519 - editorial cleanup after bug 186342 and bug 365387
20  *								bug 365662 - [compiler][null] warn on contradictory and redundant null annotations
21  *								bug 365531 - [compiler][null] investigate alternative strategy for internally encoding nullness defaults
22  *								bug 365859 - [compiler][null] distinguish warnings based on flow analysis vs. null annotations
23  *								bug 374605 - Unreasonable warning for enum-based switch statements
24  *								bug 382353 - [1.8][compiler] Implementation property modifiers should be accepted on default methods.
25  *								bug 382347 - [1.8][compiler] Compiler accepts incorrect default method inheritance
26  *								bug 388281 - [compiler][null] inheritance of null annotations as an option
27  *								bug 376053 - [compiler][resource] Strange potential resource leak problems
28  *								bug 381443 - [compiler][null] Allow parameter widening from @NonNull to unannotated
29  *								bug 393719 - [compiler] inconsistent warnings on iteration variables
30  *								bug 392862 - [1.8][compiler][null] Evaluate null annotations on array types
31  *								bug 388739 - [1.8][compiler] consider default methods when detecting whether a class needs to be declared abstract
32  *								bug 331649 - [compiler][null] consider null annotations for fields
33  *								bug 382789 - [compiler][null] warn when syntactically-nonnull expression is compared against null
34  *								bug 376590 - Private fields with @Inject are ignored by unused field validation
35  *								bug 400761 - [compiler][null] null may be return as boolean without a diagnostic
36  *								bug 402028 - [1.8][compiler] null analysis for reference expressions
37  *								bug 401796 - [1.8][compiler] don't treat default methods as overriding an independent inherited abstract method
38  *								bug 404649 - [1.8][compiler] detect illegal reference to indirect or redundant super
39  *								bug 392384 - [1.8][compiler][null] Restore nullness info from type annotations in class files
40  *								Bug 392099 - [1.8][compiler][null] Apply null annotation on types for null analysis
41  *								Bug 415043 - [1.8][null] Follow-up re null type annotations after bug 392099
42  *								Bug 415291 - [1.8][null] differentiate type incompatibilities due to null annotations
43  *								Bug 415850 - [1.8] Ensure RunJDTCoreTests can cope with null annotations enabled
44  *								Bug 414380 - [compiler][internal] QualifiedNameReference#indexOfFirstFieldBinding does not point to the first field
45  *								Bug 392238 - [1.8][compiler][null] Detect semantically invalid null type annotations
46  *								Bug 416307 - [1.8][compiler][null] subclass with type parameter substitution confuses null checking
47  *								Bug 400874 - [1.8][compiler] Inference infrastructure should evolve to meet JLS8 18.x (Part G of JSR335 spec)
48  *								Bug 424637 - [1.8][compiler][null] AIOOB in ReferenceExpression.resolveType with a method reference to Files::walk
49  *								Bug 428294 - [1.8][compiler] Type mismatch: cannot convert from List<Object> to Collection<Object[]>
50  *								Bug 428366 - [1.8] [compiler] The method valueAt(ObservableList<Object>, int) is ambiguous for the type Bindings
51  *								Bug 416190 - [1.8][null] detect incompatible overrides due to null type annotations
52  *								Bug 392245 - [1.8][compiler][null] Define whether / how @NonNullByDefault applies to TYPE_USE locations
53  *								Bug 390889 - [1.8][compiler] Evaluate options to support 1.7- projects against 1.8 JRE.
54  *								Bug 430150 - [1.8][null] stricter checking against type variables
55  *								Bug 434600 - Incorrect null analysis error reporting on type parameters
56  *								Bug 439516 - [1.8][null] NonNullByDefault wrongly applied to implicit type bound of binary type
57  *								Bug 438467 - [compiler][null] Better error position for "The method _ cannot implement the corresponding method _ due to incompatible nullness constraints"
58  *								Bug 439298 - [null] "Missing code implementation in the compiler" when using @NonNullByDefault in package-info.java
59  *								Bug 435805 - [1.8][compiler][null] Java 8 compiler does not recognize declaration style null annotations
60  *								Bug 446442 - [1.8] merge null annotations from super methods
61  *								Bug 455723 - Nonnull argument not correctly inferred in loop
62  *								Bug 458361 - [1.8][null] reconciler throws NPE in ProblemReporter.illegalReturnRedefinition()
63  *								Bug 459967 - [null] compiler should know about nullness of special methods like MyEnum.valueOf()
64  *								Bug 461878 - [1.7][1.8][compiler][null] ECJ compiler does not allow to use null annotations on annotations
65  *								Bug 410218 - Optional warning for arguments of "unexpected" types to Map#get(Object), Collection#remove(Object) et al.
66  *      Jesper S Moller <jesper@selskabet.org> -  Contributions for
67  *								bug 382701 - [1.8][compiler] Implement semantic analysis of Lambda expressions & Reference expression
68  *								bug 382721 - [1.8][compiler] Effectively final variables needs special treatment
69  *								bug 384567 - [1.5][compiler] Compiler accepts illegal modifiers on package declaration
70  *								bug 412153 - [1.8][compiler] Check validity of annotations which may be repeatable
71  *								bug 412151 - [1.8][compiler] Check repeating annotation's collection type
72  *								bug 419209 - [1.8] Repeating container annotations should be rejected in the presence of annotation it contains
73  *								Bug 429384 - [1.8][null] implement conformance rules for null-annotated lower / upper type bounds
74  *								Bug 416182 - [1.8][compiler][null] Contradictory null annotations not rejected
75  *								bug 527554 - [18.3] Compiler support for JEP 286 Local-Variable Type
76  *     Ulrich Grave <ulrich.grave@gmx.de> - Contributions for
77  *                              bug 386692 - Missing "unused" warning on "autowired" fields
78  ********************************************************************************/
79 package org.eclipse.jdt.internal.compiler.problem;
80 
81 import java.io.CharConversionException;
82 import java.io.PrintWriter;
83 import java.io.StringWriter;
84 import java.util.Iterator;
85 import java.util.List;
86 import java.util.Set;
87 import java.util.function.Supplier;
88 import java.util.stream.Collectors;
89 
90 import org.eclipse.jdt.core.compiler.CategorizedProblem;
91 import org.eclipse.jdt.core.compiler.CharOperation;
92 import org.eclipse.jdt.core.compiler.IProblem;
93 import org.eclipse.jdt.core.compiler.InvalidInputException;
94 import org.eclipse.jdt.internal.compiler.CompilationResult;
95 import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
96 import org.eclipse.jdt.internal.compiler.IProblemFactory;
97 import org.eclipse.jdt.internal.compiler.ast.ASTNode;
98 import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
99 import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
100 import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
101 import org.eclipse.jdt.internal.compiler.ast.Annotation;
102 import org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration;
103 import org.eclipse.jdt.internal.compiler.ast.Argument;
104 import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression;
105 import org.eclipse.jdt.internal.compiler.ast.ArrayInitializer;
106 import org.eclipse.jdt.internal.compiler.ast.ArrayQualifiedTypeReference;
107 import org.eclipse.jdt.internal.compiler.ast.ArrayReference;
108 import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference;
109 import org.eclipse.jdt.internal.compiler.ast.Assignment;
110 import org.eclipse.jdt.internal.compiler.ast.BinaryExpression;
111 import org.eclipse.jdt.internal.compiler.ast.Block;
112 import org.eclipse.jdt.internal.compiler.ast.BranchStatement;
113 import org.eclipse.jdt.internal.compiler.ast.CaseStatement;
114 import org.eclipse.jdt.internal.compiler.ast.CastExpression;
115 import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess;
116 import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
117 import org.eclipse.jdt.internal.compiler.ast.CompoundAssignment;
118 import org.eclipse.jdt.internal.compiler.ast.ConditionalExpression;
119 import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
120 import org.eclipse.jdt.internal.compiler.ast.EqualExpression;
121 import org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall;
122 import org.eclipse.jdt.internal.compiler.ast.Expression;
123 import org.eclipse.jdt.internal.compiler.ast.ExpressionContext;
124 import org.eclipse.jdt.internal.compiler.ast.FakedTrackingVariable;
125 import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
126 import org.eclipse.jdt.internal.compiler.ast.FieldReference;
127 import org.eclipse.jdt.internal.compiler.ast.FunctionalExpression;
128 import org.eclipse.jdt.internal.compiler.ast.ImportReference;
129 import org.eclipse.jdt.internal.compiler.ast.Initializer;
130 import org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression;
131 import org.eclipse.jdt.internal.compiler.ast.LabeledStatement;
132 import org.eclipse.jdt.internal.compiler.ast.LambdaExpression;
133 import org.eclipse.jdt.internal.compiler.ast.Literal;
134 import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
135 import org.eclipse.jdt.internal.compiler.ast.MemberValuePair;
136 import org.eclipse.jdt.internal.compiler.ast.MessageSend;
137 import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
138 import org.eclipse.jdt.internal.compiler.ast.ModuleDeclaration;
139 import org.eclipse.jdt.internal.compiler.ast.ModuleReference;
140 import org.eclipse.jdt.internal.compiler.ast.NameReference;
141 import org.eclipse.jdt.internal.compiler.ast.NullAnnotationMatching;
142 import org.eclipse.jdt.internal.compiler.ast.NullLiteral;
143 import org.eclipse.jdt.internal.compiler.ast.OpensStatement;
144 import org.eclipse.jdt.internal.compiler.ast.PackageVisibilityStatement;
145 import org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference;
146 import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference;
147 import org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression;
148 import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference;
149 import org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference;
150 import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
151 import org.eclipse.jdt.internal.compiler.ast.Receiver;
152 import org.eclipse.jdt.internal.compiler.ast.RecordComponent;
153 import org.eclipse.jdt.internal.compiler.ast.Reference;
154 import org.eclipse.jdt.internal.compiler.ast.ReferenceExpression;
155 import org.eclipse.jdt.internal.compiler.ast.ReturnStatement;
156 import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
157 import org.eclipse.jdt.internal.compiler.ast.Statement;
158 import org.eclipse.jdt.internal.compiler.ast.SwitchExpression;
159 import org.eclipse.jdt.internal.compiler.ast.SwitchStatement;
160 import org.eclipse.jdt.internal.compiler.ast.ThisReference;
161 import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
162 import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
163 import org.eclipse.jdt.internal.compiler.ast.TypeReference;
164 import org.eclipse.jdt.internal.compiler.ast.UnaryExpression;
165 import org.eclipse.jdt.internal.compiler.ast.Wildcard;
166 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
167 import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
168 import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
169 import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
170 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
171 import org.eclipse.jdt.internal.compiler.impl.Constant;
172 import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
173 import org.eclipse.jdt.internal.compiler.impl.StringConstant;
174 import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
175 import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
176 import org.eclipse.jdt.internal.compiler.lookup.Binding;
177 import org.eclipse.jdt.internal.compiler.lookup.CaptureBinding;
178 import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair;
179 import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
180 import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
181 import org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
182 import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
183 import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
184 import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
185 import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
186 import org.eclipse.jdt.internal.compiler.lookup.ModuleBinding;
187 import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
188 import org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding;
189 import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding;
190 import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
191 import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
192 import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
193 import org.eclipse.jdt.internal.compiler.lookup.Scope;
194 import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
195 import org.eclipse.jdt.internal.compiler.lookup.SplitPackageBinding;
196 import org.eclipse.jdt.internal.compiler.lookup.SyntheticArgumentBinding;
197 import org.eclipse.jdt.internal.compiler.lookup.TagBits;
198 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
199 import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
200 import org.eclipse.jdt.internal.compiler.lookup.TypeConstants.DangerousMethod;
201 import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
202 import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
203 import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
204 import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
205 import org.eclipse.jdt.internal.compiler.parser.JavadocTagConstants;
206 import org.eclipse.jdt.internal.compiler.parser.Parser;
207 import org.eclipse.jdt.internal.compiler.parser.RecoveryScanner;
208 import org.eclipse.jdt.internal.compiler.parser.Scanner;
209 import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
210 import org.eclipse.jdt.internal.compiler.util.Messages;
211 import org.eclipse.jdt.internal.compiler.util.Util;
212 
213 @SuppressWarnings("rawtypes")
214 public class ProblemReporter extends ProblemHandler {
215 
216 	public ReferenceContext referenceContext;
217 	private Scanner positionScanner;
218 	private boolean underScoreIsError;
219 	private final static byte
220 	  // TYPE_ACCESS = 0x0,
221 	  FIELD_ACCESS = 0x4,
222 	  CONSTRUCTOR_ACCESS = 0x8,
223 	  METHOD_ACCESS = 0xC;
224 
225 	private static String RESTRICTED_IDENTIFIER_RECORD = "RestrictedIdentifierrecord"; //$NON-NLS-1$
226 	private static String RECORD = "record"; //$NON-NLS-1$
227 
ProblemReporter(IErrorHandlingPolicy policy, CompilerOptions options, IProblemFactory problemFactory)228 public ProblemReporter(IErrorHandlingPolicy policy, CompilerOptions options, IProblemFactory problemFactory) {
229 	super(policy, options, problemFactory);
230 }
231 
getElaborationId(int leadProblemId, byte elaborationVariant)232 private static int getElaborationId (int leadProblemId, byte elaborationVariant) {
233 	return leadProblemId << 8 | elaborationVariant; // leadProblemId comes into the higher order bytes
234 }
getIrritant(int problemID)235 public static int getIrritant(int problemID) {
236 	switch(problemID){
237 
238 		case IProblem.MaskedCatch :
239 			return CompilerOptions.MaskedCatchBlock;
240 
241 		case IProblem.UnusedImport :
242 			return CompilerOptions.UnusedImport;
243 
244 		case IProblem.MethodButWithConstructorName :
245 			return CompilerOptions.MethodWithConstructorName;
246 
247 		case IProblem.OverridingNonVisibleMethod :
248 			return CompilerOptions.OverriddenPackageDefaultMethod;
249 
250 		case IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod :
251 		case IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod :
252 			return CompilerOptions.IncompatibleNonInheritedInterfaceMethod;
253 
254 		case IProblem.OverridingDeprecatedMethod :
255 		case IProblem.UsingDeprecatedType :
256 		case IProblem.UsingDeprecatedMethod :
257 		case IProblem.UsingDeprecatedConstructor :
258 		case IProblem.UsingDeprecatedField :
259 		case IProblem.UsingDeprecatedModule :
260 		case IProblem.OverridingDeprecatedSinceVersionMethod :
261 		case IProblem.UsingDeprecatedSinceVersionType :
262 		case IProblem.UsingDeprecatedSinceVersionMethod :
263 		case IProblem.UsingDeprecatedSinceVersionConstructor :
264 		case IProblem.UsingDeprecatedSinceVersionField :
265 		case IProblem.UsingDeprecatedSinceVersionModule :
266 			return CompilerOptions.UsingDeprecatedAPI;
267 
268 		case IProblem.OverridingTerminallyDeprecatedMethod :
269 		case IProblem.UsingTerminallyDeprecatedType :
270 		case IProblem.UsingTerminallyDeprecatedMethod :
271 		case IProblem.UsingTerminallyDeprecatedConstructor :
272 		case IProblem.UsingTerminallyDeprecatedField :
273 		case IProblem.UsingTerminallyDeprecatedModule :
274 		case IProblem.OverridingTerminallyDeprecatedSinceVersionMethod :
275 		case IProblem.UsingTerminallyDeprecatedSinceVersionType :
276 		case IProblem.UsingTerminallyDeprecatedSinceVersionMethod :
277 		case IProblem.UsingTerminallyDeprecatedSinceVersionConstructor :
278 		case IProblem.UsingTerminallyDeprecatedSinceVersionField :
279 		case IProblem.UsingTerminallyDeprecatedSinceVersionModule :
280 			return CompilerOptions.UsingTerminallyDeprecatedAPI;
281 
282 		case IProblem.LocalVariableIsNeverUsed :
283 			return CompilerOptions.UnusedLocalVariable;
284 
285 		case IProblem.ArgumentIsNeverUsed :
286 			return CompilerOptions.UnusedArgument;
287 
288 		case IProblem.ExceptionParameterIsNeverUsed :
289 			return CompilerOptions.UnusedExceptionParameter;
290 
291 		case IProblem.NoImplicitStringConversionForCharArrayExpression :
292 			return CompilerOptions.NoImplicitStringConversion;
293 
294 		case IProblem.NeedToEmulateFieldReadAccess :
295 		case IProblem.NeedToEmulateFieldWriteAccess :
296 		case IProblem.NeedToEmulateMethodAccess :
297 		case IProblem.NeedToEmulateConstructorAccess :
298 			return CompilerOptions.AccessEmulation;
299 
300 		case IProblem.NonExternalizedStringLiteral :
301 		case IProblem.UnnecessaryNLSTag :
302 			return CompilerOptions.NonExternalizedString;
303 
304 		case IProblem.UseAssertAsAnIdentifier :
305 			return CompilerOptions.AssertUsedAsAnIdentifier;
306 
307 		case IProblem.UseEnumAsAnIdentifier :
308 			return CompilerOptions.EnumUsedAsAnIdentifier;
309 
310 		case IProblem.NonStaticAccessToStaticMethod :
311 		case IProblem.NonStaticAccessToStaticField :
312 			return CompilerOptions.NonStaticAccessToStatic;
313 
314 		case IProblem.IndirectAccessToStaticMethod :
315 		case IProblem.IndirectAccessToStaticField :
316 		case IProblem.IndirectAccessToStaticType :
317 			return CompilerOptions.IndirectStaticAccess;
318 
319 		case IProblem.AssignmentHasNoEffect:
320 			return CompilerOptions.NoEffectAssignment;
321 
322 		case IProblem.UnusedPrivateConstructor:
323 		case IProblem.UnusedPrivateMethod:
324 		case IProblem.UnusedPrivateField:
325 		case IProblem.UnusedPrivateType:
326 			return CompilerOptions.UnusedPrivateMember;
327 
328 		case IProblem.LocalVariableHidingLocalVariable:
329 		case IProblem.LocalVariableHidingField:
330 		case IProblem.ArgumentHidingLocalVariable:
331 		case IProblem.ArgumentHidingField:
332 			return CompilerOptions.LocalVariableHiding;
333 
334 		case IProblem.FieldHidingLocalVariable:
335 		case IProblem.FieldHidingField:
336 			return CompilerOptions.FieldHiding;
337 
338 		case IProblem.TypeParameterHidingType:
339 		case IProblem.TypeHidingTypeParameterFromType:
340 		case IProblem.TypeHidingTypeParameterFromMethod:
341 		case IProblem.TypeHidingType:
342 			return CompilerOptions.TypeHiding;
343 
344 		case IProblem.PossibleAccidentalBooleanAssignment:
345 			return CompilerOptions.AccidentalBooleanAssign;
346 
347 		case IProblem.SuperfluousSemicolon:
348 		case IProblem.EmptyControlFlowStatement:
349 			return CompilerOptions.EmptyStatement;
350 
351 		case IProblem.UndocumentedEmptyBlock:
352 			return CompilerOptions.UndocumentedEmptyBlock;
353 
354 		case IProblem.UnnecessaryCast:
355 		case IProblem.UnnecessaryInstanceof:
356 			return CompilerOptions.UnnecessaryTypeCheck;
357 
358 		case IProblem.FinallyMustCompleteNormally:
359 			return CompilerOptions.FinallyBlockNotCompleting;
360 
361 		case IProblem.UnusedMethodDeclaredThrownException:
362 		case IProblem.UnusedConstructorDeclaredThrownException:
363 			return CompilerOptions.UnusedDeclaredThrownException;
364 
365 		case IProblem.UnqualifiedFieldAccess:
366 			return CompilerOptions.UnqualifiedFieldAccess;
367 
368 		case IProblem.UnnecessaryElse:
369 			return CompilerOptions.UnnecessaryElse;
370 
371 		case IProblem.UnsafeRawConstructorInvocation:
372 		case IProblem.UnsafeRawMethodInvocation:
373 		case IProblem.UnsafeTypeConversion:
374 		case IProblem.UnsafeElementTypeConversion:
375 		case IProblem.UnsafeRawFieldAssignment:
376 		case IProblem.UnsafeGenericCast:
377 		case IProblem.UnsafeReturnTypeOverride:
378 		case IProblem.UnsafeRawGenericMethodInvocation:
379 		case IProblem.UnsafeRawGenericConstructorInvocation:
380 		case IProblem.UnsafeGenericArrayForVarargs:
381 		case IProblem.PotentialHeapPollutionFromVararg:
382 			return CompilerOptions.UncheckedTypeOperation;
383 
384 		case IProblem.RawTypeReference:
385 			return CompilerOptions.RawTypeReference;
386 
387 		case IProblem.MissingOverrideAnnotation:
388 		case IProblem.MissingOverrideAnnotationForInterfaceMethodImplementation:
389 			return CompilerOptions.MissingOverrideAnnotation;
390 
391 		case IProblem.FieldMissingDeprecatedAnnotation:
392 		case IProblem.MethodMissingDeprecatedAnnotation:
393 		case IProblem.TypeMissingDeprecatedAnnotation:
394 			return CompilerOptions.MissingDeprecatedAnnotation;
395 
396 		case IProblem.FinalBoundForTypeVariable:
397 		    return CompilerOptions.FinalParameterBound;
398 
399 		case IProblem.MissingSerialVersion:
400 			return CompilerOptions.MissingSerialVersion;
401 
402 		case IProblem.ForbiddenReference:
403 			return CompilerOptions.ForbiddenReference;
404 
405 		case IProblem.DiscouragedReference:
406 			return CompilerOptions.DiscouragedReference;
407 
408 		case IProblem.MethodVarargsArgumentNeedCast :
409 		case IProblem.ConstructorVarargsArgumentNeedCast :
410 			return CompilerOptions.VarargsArgumentNeedCast;
411 
412 		case IProblem.NullLocalVariableReference:
413 		case IProblem.NullExpressionReference:
414 		case IProblem.NullUnboxing:
415 			return CompilerOptions.NullReference;
416 
417 		case IProblem.PotentialNullLocalVariableReference:
418 		case IProblem.PotentialNullMessageSendReference:
419 		case IProblem.ArrayReferencePotentialNullReference:
420 		case IProblem.NullableFieldReference:
421 		case IProblem.DereferencingNullableExpression:
422 		case IProblem.PotentialNullExpressionReference:
423 		case IProblem.PotentialNullUnboxing:
424 			return CompilerOptions.PotentialNullReference;
425 
426 		case IProblem.RedundantLocalVariableNullAssignment:
427 		case IProblem.RedundantNullCheckOnNonNullLocalVariable:
428 		case IProblem.RedundantNullCheckOnNullLocalVariable:
429 		case IProblem.NonNullLocalVariableComparisonYieldsFalse:
430 		case IProblem.NullLocalVariableComparisonYieldsFalse:
431 		case IProblem.NullLocalVariableInstanceofYieldsFalse:
432 		case IProblem.RedundantNullCheckOnNonNullExpression:
433 		case IProblem.NonNullExpressionComparisonYieldsFalse:
434 		case IProblem.RedundantNullCheckOnNonNullMessageSend:
435 		case IProblem.RedundantNullCheckOnSpecdNonNullLocalVariable:
436 		case IProblem.SpecdNonNullLocalVariableComparisonYieldsFalse:
437 		case IProblem.NonNullMessageSendComparisonYieldsFalse:
438 		case IProblem.RedundantNullCheckOnNonNullSpecdField:
439 		case IProblem.NonNullSpecdFieldComparisonYieldsFalse:
440 		case IProblem.RedundantNullCheckAgainstNonNullType:
441 		case IProblem.RedundantNullCheckOnField:
442 		case IProblem.RedundantNullCheckOnConstNonNullField:
443 		case IProblem.ConstNonNullFieldComparisonYieldsFalse:
444 		case IProblem.FieldComparisonYieldsFalse:
445 			return CompilerOptions.RedundantNullCheck;
446 
447 		case IProblem.RequiredNonNullButProvidedNull:
448 		case IProblem.RequiredNonNullButProvidedSpecdNullable:
449 		case IProblem.IllegalReturnNullityRedefinition:
450 		case IProblem.IllegalReturnNullityRedefinitionFreeTypeVariable:
451 		case IProblem.IllegalRedefinitionToNonNullParameter:
452 		case IProblem.IllegalRedefinitionOfTypeVariable:
453 		case IProblem.IllegalDefinitionToNonNullParameter:
454 		case IProblem.ParameterLackingNullableAnnotation:
455 		case IProblem.CannotImplementIncompatibleNullness:
456 		case IProblem.ConflictingNullAnnotations:
457 		case IProblem.ConflictingInheritedNullAnnotations:
458 		case IProblem.NullityMismatchingTypeAnnotation:
459 		case IProblem.NullityMismatchingTypeAnnotationSuperHint:
460 		case IProblem.NullityMismatchTypeArgument:
461 		case IProblem.UninitializedNonNullField:
462 		case IProblem.UninitializedNonNullFieldHintMissingDefault:
463 		case IProblem.ReferenceExpressionParameterNullityMismatch:
464 		case IProblem.ReferenceExpressionReturnNullRedef:
465 		case IProblem.ContradictoryNullAnnotations:
466 		case IProblem.ContradictoryNullAnnotationsOnBound:
467 		case IProblem.ContradictoryNullAnnotationsInferred:
468 		case IProblem.ContradictoryNullAnnotationsInferredFunctionType:
469 		case IProblem.IllegalParameterNullityRedefinition:
470 			return CompilerOptions.NullSpecViolation;
471 
472 		case IProblem.NullNotCompatibleToFreeTypeVariable:
473 		case IProblem.NullityMismatchAgainstFreeTypeVariable:
474 		case IProblem.UncheckedAccessOfValueOfFreeTypeVariable:
475 		case IProblem.RequiredNonNullButProvidedFreeTypeVariable:
476 		case IProblem.UninitializedFreeTypeVariableField:
477 		case IProblem.UninitializedFreeTypeVariableFieldHintMissingDefault:
478 			return CompilerOptions.PessimisticNullAnalysisForFreeTypeVariables;
479 
480 		case IProblem.NonNullTypeVariableFromLegacyMethod:
481 		case IProblem.NonNullMethodTypeVariableFromLegacyMethod:
482 			return CompilerOptions.NonNullTypeVariableFromLegacyInvocation;
483 
484 		case IProblem.ParameterLackingNonNullAnnotation:
485 		case IProblem.InheritedParameterLackingNonNullAnnotation:
486 			return CompilerOptions.NonnullParameterAnnotationDropped;
487 
488 		case IProblem.RequiredNonNullButProvidedPotentialNull:
489 			return CompilerOptions.NullAnnotationInferenceConflict;
490 		case IProblem.RequiredNonNullButProvidedUnknown:
491 		case IProblem.NullityUncheckedTypeAnnotationDetail:
492 		case IProblem.NullityUncheckedTypeAnnotationDetailSuperHint:
493 		case IProblem.ReferenceExpressionParameterNullityUnchecked:
494 		case IProblem.ReferenceExpressionReturnNullRedefUnchecked:
495 		case IProblem.UnsafeNullnessCast:
496 			return CompilerOptions.NullUncheckedConversion;
497 		case IProblem.AnnotatedTypeArgumentToUnannotated:
498 		case IProblem.AnnotatedTypeArgumentToUnannotatedSuperHint:
499 			return CompilerOptions.AnnotatedTypeArgumentToUnannotated;
500 		case IProblem.RedundantNullAnnotation:
501 		case IProblem.RedundantNullDefaultAnnotation:
502 		case IProblem.RedundantNullDefaultAnnotationModule:
503 		case IProblem.RedundantNullDefaultAnnotationPackage:
504 		case IProblem.RedundantNullDefaultAnnotationType:
505 		case IProblem.RedundantNullDefaultAnnotationMethod:
506 		case IProblem.RedundantNullDefaultAnnotationLocal:
507 		case IProblem.RedundantNullDefaultAnnotationField:
508 			return CompilerOptions.RedundantNullAnnotation;
509 
510 		case IProblem.BoxingConversion :
511 		case IProblem.UnboxingConversion :
512 			return CompilerOptions.AutoBoxing;
513 
514 		case IProblem.MissingEnumConstantCase :
515 		case IProblem.MissingEnumConstantCaseDespiteDefault :	// this one is further protected by CompilerOptions.reportMissingEnumCaseDespiteDefault
516 			return CompilerOptions.MissingEnumConstantCase;
517 
518 		case IProblem.MissingDefaultCase :
519 		case IProblem.MissingEnumDefaultCase :
520 			return CompilerOptions.MissingDefaultCase;
521 
522 		case IProblem.AnnotationTypeUsedAsSuperInterface :
523 			return CompilerOptions.AnnotationSuperInterface;
524 
525 		case IProblem.UnhandledWarningToken :
526 			return CompilerOptions.UnhandledWarningToken;
527 
528 		case IProblem.UnusedWarningToken :
529 			return CompilerOptions.UnusedWarningToken;
530 
531 		case IProblem.UnusedLabel :
532 			return CompilerOptions.UnusedLabel;
533 
534 		case IProblem.JavadocUnexpectedTag:
535 		case IProblem.JavadocDuplicateTag:
536 		case IProblem.JavadocDuplicateReturnTag:
537 		case IProblem.JavadocInvalidThrowsClass:
538 		case IProblem.JavadocInvalidSeeReference:
539 		case IProblem.JavadocInvalidParamTagName:
540 		case IProblem.JavadocInvalidParamTagTypeParameter:
541 		case IProblem.JavadocMalformedSeeReference:
542 		case IProblem.JavadocInvalidSeeHref:
543 		case IProblem.JavadocInvalidSeeArgs:
544 		case IProblem.JavadocInvalidTag:
545 		case IProblem.JavadocUnterminatedInlineTag:
546 		case IProblem.JavadocMissingHashCharacter:
547 		case IProblem.JavadocEmptyReturnTag:
548 		case IProblem.JavadocUnexpectedText:
549 		case IProblem.JavadocInvalidParamName:
550 		case IProblem.JavadocDuplicateParamName:
551 		case IProblem.JavadocMissingParamName:
552 		case IProblem.JavadocMissingIdentifier:
553 		case IProblem.JavadocInvalidMemberTypeQualification:
554 		case IProblem.JavadocInvalidThrowsClassName:
555 		case IProblem.JavadocDuplicateThrowsClassName:
556 		case IProblem.JavadocMissingThrowsClassName:
557 		case IProblem.JavadocDuplicateProvidesTag:
558 		case IProblem.JavadocDuplicateUsesTag:
559 		case IProblem.JavadocInvalidUsesClass:
560 		case IProblem.JavadocInvalidUsesClassName:
561 		case IProblem.JavadocInvalidProvidesClass:
562 		case IProblem.JavadocInvalidProvidesClassName:
563 		case IProblem.JavadocMissingProvidesClassName:
564 		case IProblem.JavadocMissingUsesClassName:
565 		case IProblem.JavadocMissingSeeReference:
566 		case IProblem.JavadocInvalidValueReference:
567 		case IProblem.JavadocUndefinedField:
568 		case IProblem.JavadocAmbiguousField:
569 		case IProblem.JavadocUndefinedConstructor:
570 		case IProblem.JavadocAmbiguousConstructor:
571 		case IProblem.JavadocUndefinedMethod:
572 		case IProblem.JavadocAmbiguousMethod:
573 		case IProblem.JavadocAmbiguousMethodReference:
574 		case IProblem.JavadocParameterMismatch:
575 		case IProblem.JavadocUndefinedType:
576 		case IProblem.JavadocAmbiguousType:
577 		case IProblem.JavadocInternalTypeNameProvided:
578 		case IProblem.JavadocNoMessageSendOnArrayType:
579 		case IProblem.JavadocNoMessageSendOnBaseType:
580 		case IProblem.JavadocInheritedMethodHidesEnclosingName:
581 		case IProblem.JavadocInheritedFieldHidesEnclosingName:
582 		case IProblem.JavadocInheritedNameHidesEnclosingTypeName:
583 		case IProblem.JavadocNonStaticTypeFromStaticInvocation:
584 		case IProblem.JavadocGenericMethodTypeArgumentMismatch:
585 		case IProblem.JavadocNonGenericMethod:
586 		case IProblem.JavadocIncorrectArityForParameterizedMethod:
587 		case IProblem.JavadocParameterizedMethodArgumentTypeMismatch:
588 		case IProblem.JavadocTypeArgumentsForRawGenericMethod:
589 		case IProblem.JavadocGenericConstructorTypeArgumentMismatch:
590 		case IProblem.JavadocNonGenericConstructor:
591 		case IProblem.JavadocIncorrectArityForParameterizedConstructor:
592 		case IProblem.JavadocParameterizedConstructorArgumentTypeMismatch:
593 		case IProblem.JavadocTypeArgumentsForRawGenericConstructor:
594 		case IProblem.JavadocNotAccessibleType:
595 		case IProblem.JavadocNotVisibleField:
596 		case IProblem.JavadocNotVisibleConstructor:
597 		case IProblem.JavadocNotVisibleMethod:
598 		case IProblem.JavadocNotVisibleType:
599 		case IProblem.JavadocUsingDeprecatedField:
600 		case IProblem.JavadocUsingDeprecatedConstructor:
601 		case IProblem.JavadocUsingDeprecatedMethod:
602 		case IProblem.JavadocUsingDeprecatedType:
603 		case IProblem.JavadocHiddenReference:
604 		case IProblem.JavadocMissingTagDescription:
605 		case IProblem.JavadocInvalidSeeUrlReference:
606 			return CompilerOptions.InvalidJavadoc;
607 
608 		case IProblem.JavadocMissingParamTag:
609 		case IProblem.JavadocMissingProvidesTag:
610 		case IProblem.JavadocMissingReturnTag:
611 		case IProblem.JavadocMissingThrowsTag:
612 		case IProblem.JavadocMissingUsesTag:
613 			return CompilerOptions.MissingJavadocTags;
614 
615 		case IProblem.JavadocMissing:
616 			return CompilerOptions.MissingJavadocComments;
617 
618 		case IProblem.ParameterAssignment:
619 			return CompilerOptions.ParameterAssignment;
620 
621 		case IProblem.FallthroughCase:
622 			return CompilerOptions.FallthroughCase;
623 
624 		case IProblem.OverridingMethodWithoutSuperInvocation:
625 			return CompilerOptions.OverridingMethodWithoutSuperInvocation;
626 
627 		case IProblem.UnusedTypeArgumentsForMethodInvocation:
628 		case IProblem.UnusedTypeArgumentsForConstructorInvocation:
629 			return CompilerOptions.UnusedTypeArguments;
630 
631 		case IProblem.RedundantSuperinterface:
632 			return CompilerOptions.RedundantSuperinterface;
633 
634 		case IProblem.ComparingIdentical:
635 			return CompilerOptions.ComparingIdentical;
636 
637 		case IProblem.MissingSynchronizedModifierInInheritedMethod:
638 			return CompilerOptions.MissingSynchronizedModifierInInheritedMethod;
639 
640 		case IProblem.ShouldImplementHashcode:
641 			return CompilerOptions.ShouldImplementHashcode;
642 
643 		case IProblem.DeadCode:
644 			return CompilerOptions.DeadCode;
645 
646 		case IProblem.Task :
647 			return CompilerOptions.Tasks;
648 
649 		case IProblem.UnusedObjectAllocation:
650 			return CompilerOptions.UnusedObjectAllocation;
651 
652 		case IProblem.MethodCanBeStatic:
653 			return CompilerOptions.MethodCanBeStatic;
654 
655 		case IProblem.MethodCanBePotentiallyStatic:
656 			return CompilerOptions.MethodCanBePotentiallyStatic;
657 
658 		case IProblem.UnclosedCloseable:
659 		case IProblem.UnclosedCloseableAtExit:
660 			return CompilerOptions.UnclosedCloseable;
661 		case IProblem.PotentiallyUnclosedCloseable:
662 		case IProblem.PotentiallyUnclosedCloseableAtExit:
663 			return CompilerOptions.PotentiallyUnclosedCloseable;
664 		case IProblem.ExplicitlyClosedAutoCloseable:
665 			return CompilerOptions.ExplicitlyClosedAutoCloseable;
666 
667 		case IProblem.RedundantSpecificationOfTypeArguments:
668 			return CompilerOptions.RedundantSpecificationOfTypeArguments;
669 
670 		case IProblem.MissingNonNullByDefaultAnnotationOnPackage:
671 		case IProblem.MissingNonNullByDefaultAnnotationOnType:
672 			return CompilerOptions.MissingNonNullByDefaultAnnotation;
673 
674 		case IProblem.UnusedTypeParameter:
675 			return CompilerOptions.UnusedTypeParameter;
676 
677 		case IProblem.UnlikelyCollectionMethodArgumentType:
678 			return CompilerOptions.UnlikelyCollectionMethodArgumentType;
679 		case IProblem.UnlikelyEqualsArgumentType:
680 			return CompilerOptions.UnlikelyEqualsArgumentType;
681 
682 		case IProblem.NonPublicTypeInAPI:
683 		case IProblem.NotExportedTypeInAPI:
684 		case IProblem.MissingRequiresTransitiveForTypeInAPI:
685 			return CompilerOptions.APILeak;
686 		case IProblem.UnstableAutoModuleName:
687 			return CompilerOptions.UnstableAutoModuleName;
688 		case IProblem.PreviewFeatureUsed:
689 			return CompilerOptions.PreviewFeatureUsed;
690 
691 		case IProblem.ProblemNotAnalysed:
692 			return CompilerOptions.SuppressWarningsNotAnalysed;
693 }
694 	return 0;
695 }
696 /**
697  * Compute problem category ID based on problem ID
698  * @param problemID
699  * @return a category ID
700  * @see CategorizedProblem
701  */
getProblemCategory(int severity, int problemID)702 public static int getProblemCategory(int severity, int problemID) {
703 	categorizeOnIrritant: {
704 		// fatal problems even if optional are all falling into same category (not irritant based)
705 		if ((severity & ProblemSeverities.Fatal) != 0)
706 			break categorizeOnIrritant;
707 		int irritant = getIrritant(problemID);
708 		switch (irritant) {
709 			case CompilerOptions.MethodWithConstructorName :
710 			case CompilerOptions.AccessEmulation :
711 			case CompilerOptions.AssertUsedAsAnIdentifier :
712 			case CompilerOptions.NonStaticAccessToStatic :
713 			case CompilerOptions.UnqualifiedFieldAccess :
714 			case CompilerOptions.UndocumentedEmptyBlock :
715 			case CompilerOptions.IndirectStaticAccess :
716 			case CompilerOptions.FinalParameterBound :
717 			case CompilerOptions.EnumUsedAsAnIdentifier :
718 			case CompilerOptions.AnnotationSuperInterface :
719 			case CompilerOptions.AutoBoxing :
720 			case CompilerOptions.MissingOverrideAnnotation :
721 			case CompilerOptions.MissingDeprecatedAnnotation :
722 			case CompilerOptions.ParameterAssignment :
723 			case CompilerOptions.MethodCanBeStatic :
724 			case CompilerOptions.MethodCanBePotentiallyStatic :
725 			case CompilerOptions.ExplicitlyClosedAutoCloseable :
726 				return CategorizedProblem.CAT_CODE_STYLE;
727 
728 			case CompilerOptions.MaskedCatchBlock :
729 			case CompilerOptions.NoImplicitStringConversion :
730 			case CompilerOptions.NoEffectAssignment :
731 			case CompilerOptions.AccidentalBooleanAssign :
732 			case CompilerOptions.EmptyStatement :
733 			case CompilerOptions.FinallyBlockNotCompleting :
734 			case CompilerOptions.MissingSerialVersion :
735 			case CompilerOptions.VarargsArgumentNeedCast :
736 			case CompilerOptions.NullReference :
737 			case CompilerOptions.PotentialNullReference :
738 			case CompilerOptions.RedundantNullCheck :
739 			case CompilerOptions.MissingEnumConstantCase :
740 			case CompilerOptions.MissingDefaultCase :
741 			case CompilerOptions.FallthroughCase :
742 			case CompilerOptions.OverridingMethodWithoutSuperInvocation :
743 			case CompilerOptions.ComparingIdentical :
744 			case CompilerOptions.MissingSynchronizedModifierInInheritedMethod :
745 			case CompilerOptions.ShouldImplementHashcode :
746 			case CompilerOptions.DeadCode :
747 			case CompilerOptions.UnusedObjectAllocation :
748 			case CompilerOptions.UnclosedCloseable :
749 			case CompilerOptions.PotentiallyUnclosedCloseable :
750 			case CompilerOptions.PessimisticNullAnalysisForFreeTypeVariables :
751 			case CompilerOptions.NonNullTypeVariableFromLegacyInvocation :
752 			case CompilerOptions.UnlikelyCollectionMethodArgumentType :
753 			case CompilerOptions.UnlikelyEqualsArgumentType:
754 			case CompilerOptions.APILeak:
755 			case CompilerOptions.UnstableAutoModuleName:
756 				return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM;
757 
758 			case CompilerOptions.OverriddenPackageDefaultMethod :
759 			case CompilerOptions.IncompatibleNonInheritedInterfaceMethod :
760 			case CompilerOptions.LocalVariableHiding :
761 			case CompilerOptions.FieldHiding :
762 			case CompilerOptions.TypeHiding :
763 				return CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT;
764 
765 			case CompilerOptions.UnusedLocalVariable :
766 			case CompilerOptions.UnusedArgument :
767 			case CompilerOptions.UnusedExceptionParameter :
768 			case CompilerOptions.UnusedImport :
769 			case CompilerOptions.UnusedPrivateMember :
770 			case CompilerOptions.UnusedDeclaredThrownException :
771 			case CompilerOptions.UnnecessaryTypeCheck :
772 			case CompilerOptions.UnnecessaryElse :
773 			case CompilerOptions.UnhandledWarningToken :
774 			case CompilerOptions.UnusedWarningToken :
775 			case CompilerOptions.UnusedLabel :
776 			case CompilerOptions.RedundantSuperinterface :
777 			case CompilerOptions.RedundantSpecificationOfTypeArguments :
778 			case CompilerOptions.UnusedTypeParameter:
779 				return CategorizedProblem.CAT_UNNECESSARY_CODE;
780 
781 			case CompilerOptions.UsingDeprecatedAPI :
782 			case CompilerOptions.UsingTerminallyDeprecatedAPI :
783 				return CategorizedProblem.CAT_DEPRECATION;
784 
785 			case CompilerOptions.NonExternalizedString :
786 				return CategorizedProblem.CAT_NLS;
787 
788 			case CompilerOptions.Task :
789 				return CategorizedProblem.CAT_UNSPECIFIED; // TODO may want to improve
790 
791 			case CompilerOptions.MissingJavadocComments :
792 			case CompilerOptions.MissingJavadocTags :
793 			case CompilerOptions.InvalidJavadoc :
794 			case CompilerOptions.InvalidJavadoc|CompilerOptions.UsingDeprecatedAPI :
795 			case CompilerOptions.InvalidJavadoc|CompilerOptions.UsingTerminallyDeprecatedAPI :
796 				return CategorizedProblem.CAT_JAVADOC;
797 
798 			case CompilerOptions.UncheckedTypeOperation :
799 			case CompilerOptions.RawTypeReference :
800 				return CategorizedProblem.CAT_UNCHECKED_RAW;
801 
802 			case CompilerOptions.ForbiddenReference :
803 			case CompilerOptions.DiscouragedReference :
804 				return CategorizedProblem.CAT_RESTRICTION;
805 
806 			case CompilerOptions.NullSpecViolation :
807 			case CompilerOptions.NullAnnotationInferenceConflict :
808 			case CompilerOptions.NullUncheckedConversion :
809 			case CompilerOptions.MissingNonNullByDefaultAnnotation:
810 			case CompilerOptions.NonnullParameterAnnotationDropped:
811 			case CompilerOptions.AnnotatedTypeArgumentToUnannotated:
812 				return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM;
813 			case CompilerOptions.RedundantNullAnnotation :
814 				return CategorizedProblem.CAT_UNNECESSARY_CODE;
815 
816 			default:
817 				break categorizeOnIrritant;
818 		}
819 	}
820 	// categorize fatal problems per ID
821 	switch (problemID) {
822 		case IProblem.IsClassPathCorrect :
823 		case IProblem.CorruptedSignature :
824 		case IProblem.UndefinedModuleAddReads :
825 		case IProblem.MissingNullAnnotationImplicitlyUsed :
826 			return CategorizedProblem.CAT_BUILDPATH;
827 		case IProblem.ProblemNotAnalysed :
828 			return CategorizedProblem.CAT_UNNECESSARY_CODE;
829 		default :
830 			if ((problemID & IProblem.Syntax) != 0)
831 				return CategorizedProblem.CAT_SYNTAX;
832 			if ((problemID & IProblem.ImportRelated) != 0)
833 				return CategorizedProblem.CAT_IMPORT;
834 			if ((problemID & IProblem.TypeRelated) != 0)
835 				return CategorizedProblem.CAT_TYPE;
836 			if ((problemID & (IProblem.FieldRelated|IProblem.MethodRelated|IProblem.ConstructorRelated)) != 0)
837 				return CategorizedProblem.CAT_MEMBER;
838 			if ((problemID & IProblem.ModuleRelated) != 0)
839 				return CategorizedProblem.CAT_MODULE;
840 			if ((problemID & IProblem.Compliance) != 0)
841 				return CategorizedProblem.CAT_COMPLIANCE;
842 			if ((problemID & IProblem.PreviewRelated) != 0)
843 				return CategorizedProblem.CAT_PREVIEW_RELATED;
844 	}
845 	return CategorizedProblem.CAT_INTERNAL;
846 }
abortDueToInternalError(String errorMessage)847 public void abortDueToInternalError(String errorMessage) {
848 	this.abortDueToInternalError(errorMessage, null);
849 }
abortDueToInternalError(String errorMessage, ASTNode location)850 public void abortDueToInternalError(String errorMessage, ASTNode location) {
851 	String[] arguments = new String[] {errorMessage};
852 	this.handle(
853 		IProblem.Unclassified,
854 		arguments,
855 		arguments,
856 		ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
857 		location == null ? 0 : location.sourceStart,
858 		location == null ? 0 : location.sourceEnd);
859 }
abortDueToPreviewEnablingNotAllowed(String sourceLevel, String expectedSourceLevel)860 public void abortDueToPreviewEnablingNotAllowed(String sourceLevel, String expectedSourceLevel) {
861 	String[] args = new String[] {sourceLevel, expectedSourceLevel};
862 	this.handle(
863 			IProblem.PreviewFeaturesNotAllowed,
864 			args,
865 			args,
866 			ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
867 			0,
868 			0);
869 }
abstractMethodCannotBeOverridden(SourceTypeBinding type, MethodBinding concreteMethod)870 public void abstractMethodCannotBeOverridden(SourceTypeBinding type, MethodBinding concreteMethod) {
871 
872 	this.handle(
873 		// %1 must be abstract since it cannot override the inherited package-private abstract method %2
874 		IProblem.AbstractMethodCannotBeOverridden,
875 		new String[] {
876 			new String(type.sourceName()),
877 			new String(
878 					CharOperation.concat(
879 						concreteMethod.declaringClass.readableName(),
880 						concreteMethod.readableName(),
881 						'.'))},
882 		new String[] {
883 			new String(type.sourceName()),
884 			new String(
885 					CharOperation.concat(
886 						concreteMethod.declaringClass.shortReadableName(),
887 						concreteMethod.shortReadableName(),
888 						'.'))},
889 		type.sourceStart(),
890 		type.sourceEnd());
891 }
abstractMethodInAbstractClass(SourceTypeBinding type, AbstractMethodDeclaration methodDecl)892 public void abstractMethodInAbstractClass(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
893 	if (type.isEnum() && type.isLocalType()) {
894 		FieldBinding field = type.scope.enclosingMethodScope().initializedField;
895 		FieldDeclaration decl = field.sourceField();
896 		String[] arguments = new String[] {new String(decl.name), new String(methodDecl.selector)};
897 		this.handle(
898 			IProblem.AbstractMethodInEnum,
899 			arguments,
900 			arguments,
901 			methodDecl.sourceStart,
902 			methodDecl.sourceEnd);
903 	} else {
904 		String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
905 		this.handle(
906 			IProblem.AbstractMethodInAbstractClass,
907 			arguments,
908 			arguments,
909 			methodDecl.sourceStart,
910 			methodDecl.sourceEnd);
911 	}
912 }
abstractMethodInConcreteClass(SourceTypeBinding type)913 public void abstractMethodInConcreteClass(SourceTypeBinding type) {
914 	if (type.isEnum() && type.isLocalType()) {
915 		FieldBinding field = type.scope.enclosingMethodScope().initializedField;
916 		FieldDeclaration decl = field.sourceField();
917 		String[] arguments = new String[] {new String(decl.name)};
918 		this.handle(
919 			IProblem.EnumConstantCannotDefineAbstractMethod,
920 			arguments,
921 			arguments,
922 			decl.sourceStart(),
923 			decl.sourceEnd());
924 	} else {
925 		String[] arguments = new String[] {new String(type.sourceName())};
926 		this.handle(
927 			IProblem.AbstractMethodsInConcreteClass,
928 			arguments,
929 			arguments,
930 			type.sourceStart(),
931 			type.sourceEnd());
932 	}
933 }
abstractMethodMustBeImplemented(SourceTypeBinding type, MethodBinding abstractMethod)934 public void abstractMethodMustBeImplemented(SourceTypeBinding type, MethodBinding abstractMethod) {
935 	if (type.isEnum() && type.isLocalType()) {
936 		FieldBinding field = type.scope.enclosingMethodScope().initializedField;
937 		FieldDeclaration decl = field.sourceField();
938 		this.handle(
939 			// Must implement the inherited abstract method %1
940 			// 8.4.3 - Every non-abstract subclass of an abstract type, A, must provide a concrete implementation of all of A's methods.
941 			IProblem.EnumConstantMustImplementAbstractMethod,
942 			new String[] {
943 			        new String(abstractMethod.selector),
944 			        typesAsString(abstractMethod, false),
945 			        new String(decl.name),
946 			},
947 			new String[] {
948 			        new String(abstractMethod.selector),
949 			        typesAsString(abstractMethod, true),
950 			        new String(decl.name),
951 			},
952 			decl.sourceStart(),
953 			decl.sourceEnd());
954 	} else {
955 		this.handle(
956 			// Must implement the inherited abstract method %1
957 			// 8.4.3 - Every non-abstract subclass of an abstract type, A, must provide a concrete implementation of all of A's methods.
958 			IProblem.AbstractMethodMustBeImplemented,
959 			new String[] {
960 			        new String(abstractMethod.selector),
961 			        typesAsString(abstractMethod, false),
962 			        new String(abstractMethod.declaringClass.readableName()),
963 			        new String(type.readableName()),
964 			},
965 			new String[] {
966 			        new String(abstractMethod.selector),
967 			        typesAsString(abstractMethod, true),
968 			        new String(abstractMethod.declaringClass.shortReadableName()),
969 			        new String(type.shortReadableName()),
970 			},
971 			type.sourceStart(),
972 			type.sourceEnd());
973 	}
974 }
abstractMethodMustBeImplemented(SourceTypeBinding type, MethodBinding abstractMethod, MethodBinding concreteMethod)975 public void abstractMethodMustBeImplemented(SourceTypeBinding type, MethodBinding abstractMethod, MethodBinding concreteMethod) {
976 	this.handle(
977 		// Must implement the inherited abstract method %1
978 		// 8.4.3 - Every non-abstract subclass of an abstract type, A, must provide a concrete implementation of all of A's methods.
979 		IProblem.AbstractMethodMustBeImplementedOverConcreteMethod,
980 		new String[] {
981 		        new String(abstractMethod.selector),
982 		        typesAsString(abstractMethod, false),
983 		        new String(abstractMethod.declaringClass.readableName()),
984 		        new String(type.readableName()),
985 		        new String(concreteMethod.selector),
986 		        typesAsString(concreteMethod, false),
987 		        new String(concreteMethod.declaringClass.readableName()),
988 		},
989 		new String[] {
990 		        new String(abstractMethod.selector),
991 		        typesAsString(abstractMethod, true),
992 		        new String(abstractMethod.declaringClass.shortReadableName()),
993 		        new String(type.shortReadableName()),
994 		        new String(concreteMethod.selector),
995 		        typesAsString(concreteMethod, true),
996 		        new String(concreteMethod.declaringClass.shortReadableName()),
997 		},
998 		type.sourceStart(),
999 		type.sourceEnd());
1000 }
abstractMethodNeedingNoBody(AbstractMethodDeclaration method)1001 public void abstractMethodNeedingNoBody(AbstractMethodDeclaration method) {
1002 	this.handle(
1003 		IProblem.BodyForAbstractMethod,
1004 		NoArgument,
1005 		NoArgument,
1006 		method.sourceStart,
1007 		method.sourceEnd,
1008 		method,
1009 		method.compilationResult());
1010 }
alreadyDefinedLabel(char[] labelName, ASTNode location)1011 public void alreadyDefinedLabel(char[] labelName, ASTNode location) {
1012 	String[] arguments = new String[] {new String(labelName)};
1013 	this.handle(
1014 		IProblem.DuplicateLabel,
1015 		arguments,
1016 		arguments,
1017 		location.sourceStart,
1018 		location.sourceEnd);
1019 }
annotationCannotOverrideMethod(MethodBinding overrideMethod, MethodBinding inheritedMethod)1020 public void annotationCannotOverrideMethod(MethodBinding overrideMethod, MethodBinding inheritedMethod) {
1021 	ASTNode location = overrideMethod.sourceMethod();
1022 	this.handle(
1023 		IProblem.AnnotationCannotOverrideMethod,
1024 		new String[] {
1025 				new String(overrideMethod.declaringClass.readableName()),
1026 				new String(inheritedMethod.declaringClass.readableName()),
1027 				new String(inheritedMethod.selector),
1028 				typesAsString(inheritedMethod, false)},
1029 		new String[] {
1030 				new String(overrideMethod.declaringClass.shortReadableName()),
1031 				new String(inheritedMethod.declaringClass.shortReadableName()),
1032 				new String(inheritedMethod.selector),
1033 				typesAsString(inheritedMethod, true)},
1034 		location.sourceStart,
1035 		location.sourceEnd);
1036 }
annotationCircularity(TypeBinding sourceType, TypeBinding otherType, TypeReference reference)1037 public void annotationCircularity(TypeBinding sourceType, TypeBinding otherType, TypeReference reference) {
1038 	if (TypeBinding.equalsEquals(sourceType, otherType))
1039 		this.handle(
1040 			IProblem.AnnotationCircularitySelfReference,
1041 			new String[] {new String(sourceType.readableName())},
1042 			new String[] {new String(sourceType.shortReadableName())},
1043 			reference.sourceStart,
1044 			reference.sourceEnd);
1045 	else
1046 		this.handle(
1047 			IProblem.AnnotationCircularity,
1048 			new String[] {new String(sourceType.readableName()), new String(otherType.readableName())},
1049 			new String[] {new String(sourceType.shortReadableName()), new String(otherType.shortReadableName())},
1050 			reference.sourceStart,
1051 			reference.sourceEnd);
1052 }
annotationMembersCannotHaveParameters(AnnotationMethodDeclaration annotationMethodDeclaration)1053 public void annotationMembersCannotHaveParameters(AnnotationMethodDeclaration annotationMethodDeclaration) {
1054 	this.handle(
1055 		IProblem.AnnotationMembersCannotHaveParameters,
1056 		NoArgument,
1057 		NoArgument,
1058 		annotationMethodDeclaration.sourceStart,
1059 		annotationMethodDeclaration.sourceEnd);
1060 }
annotationMembersCannotHaveTypeParameters(AnnotationMethodDeclaration annotationMethodDeclaration)1061 public void annotationMembersCannotHaveTypeParameters(AnnotationMethodDeclaration annotationMethodDeclaration) {
1062 	this.handle(
1063 		IProblem.AnnotationMembersCannotHaveTypeParameters,
1064 		NoArgument,
1065 		NoArgument,
1066 		annotationMethodDeclaration.sourceStart,
1067 		annotationMethodDeclaration.sourceEnd);
1068 }
annotationTypeDeclarationCannotHaveConstructor(ConstructorDeclaration constructorDeclaration)1069 public void annotationTypeDeclarationCannotHaveConstructor(ConstructorDeclaration constructorDeclaration) {
1070 	this.handle(
1071 		IProblem.AnnotationTypeDeclarationCannotHaveConstructor,
1072 		NoArgument,
1073 		NoArgument,
1074 		constructorDeclaration.sourceStart,
1075 		constructorDeclaration.sourceEnd);
1076 }
annotationTypeDeclarationCannotHaveSuperclass(TypeDeclaration typeDeclaration)1077 public void annotationTypeDeclarationCannotHaveSuperclass(TypeDeclaration typeDeclaration) {
1078 	this.handle(
1079 		IProblem.AnnotationTypeDeclarationCannotHaveSuperclass,
1080 		NoArgument,
1081 		NoArgument,
1082 		typeDeclaration.sourceStart,
1083 		typeDeclaration.sourceEnd);
1084 }
annotationTypeDeclarationCannotHaveSuperinterfaces(TypeDeclaration typeDeclaration)1085 public void annotationTypeDeclarationCannotHaveSuperinterfaces(TypeDeclaration typeDeclaration) {
1086 	this.handle(
1087 		IProblem.AnnotationTypeDeclarationCannotHaveSuperinterfaces,
1088 		NoArgument,
1089 		NoArgument,
1090 		typeDeclaration.sourceStart,
1091 		typeDeclaration.sourceEnd);
1092 }
annotationTypeUsedAsSuperinterface(SourceTypeBinding type, TypeReference superInterfaceRef, ReferenceBinding superType)1093 public void annotationTypeUsedAsSuperinterface(SourceTypeBinding type, TypeReference superInterfaceRef, ReferenceBinding superType) {
1094 	this.handle(
1095 		IProblem.AnnotationTypeUsedAsSuperInterface,
1096 		new String[] {new String(superType.readableName()), new String(type.sourceName())},
1097 		new String[] {new String(superType.shortReadableName()), new String(type.sourceName())},
1098 		superInterfaceRef.sourceStart,
1099 		superInterfaceRef.sourceEnd);
1100 }
annotationValueMustBeAnnotation(TypeBinding annotationType, char[] name, Expression value, TypeBinding expectedType)1101 public void annotationValueMustBeAnnotation(TypeBinding annotationType, char[] name, Expression value, TypeBinding expectedType) {
1102 	String str = new String(name);
1103 	this.handle(
1104 		IProblem.AnnotationValueMustBeAnnotation,
1105 		new String[] { new String(annotationType.readableName()), str, new String(expectedType.readableName()),  },
1106 		new String[] { new String(annotationType.shortReadableName()), str, new String(expectedType.readableName()), },
1107 		value.sourceStart,
1108 		value.sourceEnd);
1109 }
annotationValueMustBeArrayInitializer(TypeBinding annotationType, char[] name, Expression value)1110 public void annotationValueMustBeArrayInitializer(TypeBinding annotationType, char[] name, Expression value) {
1111 	String str = new String(name);
1112 	this.handle(
1113     	IProblem.AnnotationValueMustBeArrayInitializer,
1114 		new String[] { new String(annotationType.readableName()), str },
1115 		new String[] { new String(annotationType.shortReadableName()), str},
1116     	value.sourceStart,
1117     	value.sourceEnd);
1118 }
annotationValueMustBeClassLiteral(TypeBinding annotationType, char[] name, Expression value)1119 public void annotationValueMustBeClassLiteral(TypeBinding annotationType, char[] name, Expression value) {
1120 	String str = new String(name);
1121 	this.handle(
1122 		IProblem.AnnotationValueMustBeClassLiteral,
1123 		new String[] { new String(annotationType.readableName()), str },
1124 		new String[] { new String(annotationType.shortReadableName()), str},
1125 		value.sourceStart,
1126 		value.sourceEnd);
1127 }
annotationValueMustBeConstant(TypeBinding annotationType, char[] name, Expression value, boolean isEnum)1128 public void annotationValueMustBeConstant(TypeBinding annotationType, char[] name, Expression value, boolean isEnum) {
1129 	String str = new String(name);
1130 	if (isEnum) {
1131     	this.handle(
1132     		IProblem.AnnotationValueMustBeAnEnumConstant,
1133     		new String[] { new String(annotationType.readableName()), str },
1134     		new String[] { new String(annotationType.shortReadableName()), str},
1135     		value.sourceStart,
1136     		value.sourceEnd);
1137 	} else {
1138     	this.handle(
1139     		IProblem.AnnotationValueMustBeConstant,
1140     		new String[] { new String(annotationType.readableName()), str },
1141     		new String[] { new String(annotationType.shortReadableName()), str},
1142     		value.sourceStart,
1143     		value.sourceEnd);
1144     }
1145 }
anonymousClassCannotExtendFinalClass(TypeReference reference, TypeBinding type)1146 public void anonymousClassCannotExtendFinalClass(TypeReference reference, TypeBinding type) {
1147 	this.handle(
1148 		IProblem.AnonymousClassCannotExtendFinalClass,
1149 		new String[] {new String(type.readableName())},
1150 		new String[] {new String(type.shortReadableName())},
1151 		reference.sourceStart,
1152 		reference.sourceEnd);
1153 }
argumentTypeCannotBeVoid(ASTNode methodDecl, Argument arg)1154 public void argumentTypeCannotBeVoid(ASTNode methodDecl, Argument arg) {
1155 	String[] arguments = new String[] { new String(arg.name) };
1156 	this.handle(
1157 		IProblem.ArgumentTypeCannotBeVoid,
1158 		arguments,
1159 		arguments,
1160 		methodDecl.sourceStart,
1161 		methodDecl.sourceEnd);
1162 }
argumentTypeCannotBeVoidArray(Argument arg)1163 public void argumentTypeCannotBeVoidArray(Argument arg) {
1164 	this.handle(
1165 		IProblem.CannotAllocateVoidArray,
1166 		NoArgument,
1167 		NoArgument,
1168 		arg.type.sourceStart,
1169 		arg.type.sourceEnd);
1170 }
arrayConstantsOnlyInArrayInitializers(int sourceStart, int sourceEnd)1171 public void arrayConstantsOnlyInArrayInitializers(int sourceStart, int sourceEnd) {
1172 	this.handle(
1173 		IProblem.ArrayConstantsOnlyInArrayInitializers,
1174 		NoArgument,
1175 		NoArgument,
1176 		sourceStart,
1177 		sourceEnd);
1178 }
assignmentHasNoEffect(AbstractVariableDeclaration location, char[] name)1179 public void assignmentHasNoEffect(AbstractVariableDeclaration location, char[] name){
1180 	int severity = computeSeverity(IProblem.AssignmentHasNoEffect);
1181 	if (severity == ProblemSeverities.Ignore) return;
1182 	String[] arguments = new String[] { new String(name) };
1183 	int start = location.sourceStart;
1184 	int end = location.sourceEnd;
1185 	if (location.initialization != null) {
1186 		end = location.initialization.sourceEnd;
1187 	}
1188 	this.handle(
1189 			IProblem.AssignmentHasNoEffect,
1190 			arguments,
1191 			arguments,
1192 			severity,
1193 			start,
1194 			end);
1195 }
assignmentHasNoEffect(Assignment location, char[] name)1196 public void assignmentHasNoEffect(Assignment location, char[] name){
1197 	int severity = computeSeverity(IProblem.AssignmentHasNoEffect);
1198 	if (severity == ProblemSeverities.Ignore) return;
1199 	String[] arguments = new String[] { new String(name) };
1200 	this.handle(
1201 			IProblem.AssignmentHasNoEffect,
1202 			arguments,
1203 			arguments,
1204 			severity,
1205 			location.sourceStart,
1206 			location.sourceEnd);
1207 }
1208 
attemptToReturnNonVoidExpression(ReturnStatement returnStatement, TypeBinding expectedType)1209 public void attemptToReturnNonVoidExpression(ReturnStatement returnStatement, TypeBinding expectedType) {
1210 	this.handle(
1211 		IProblem.VoidMethodReturnsValue,
1212 		new String[] {new String(expectedType.readableName())},
1213 		new String[] {new String(expectedType.shortReadableName())},
1214 		returnStatement.sourceStart,
1215 		returnStatement.sourceEnd);
1216 }
1217 
1218 
attemptToReturnVoidValue(ReturnStatement returnStatement)1219 public void attemptToReturnVoidValue(ReturnStatement returnStatement) {
1220 	this.handle(
1221 		IProblem.MethodReturnsVoid,
1222 		NoArgument,
1223 		NoArgument,
1224 		returnStatement.sourceStart,
1225 		returnStatement.sourceEnd);
1226 }
autoboxing(Expression expression, TypeBinding originalType, TypeBinding convertedType)1227 public void autoboxing(Expression expression, TypeBinding originalType, TypeBinding convertedType) {
1228 	if (this.options.getSeverity(CompilerOptions.AutoBoxing) == ProblemSeverities.Ignore) return;
1229 	this.handle(
1230 		originalType.isBaseType() ? IProblem.BoxingConversion : IProblem.UnboxingConversion,
1231 		new String[] { new String(originalType.readableName()), new String(convertedType.readableName()), },
1232 		new String[] { new String(originalType.shortReadableName()), new String(convertedType.shortReadableName()), },
1233 		expression.sourceStart,
1234 		expression.sourceEnd);
1235 }
boundCannotBeArray(ASTNode location, TypeBinding type)1236 public void boundCannotBeArray(ASTNode location, TypeBinding type) {
1237 	this.handle(
1238 		IProblem.BoundCannotBeArray,
1239 		new String[] {new String(type.readableName())},
1240 		new String[] {new String(type.shortReadableName())},
1241 		location.sourceStart,
1242 		location.sourceEnd);
1243 }
boundMustBeAnInterface(ASTNode location, TypeBinding type)1244 public void boundMustBeAnInterface(ASTNode location, TypeBinding type) {
1245 	this.handle(
1246 		IProblem.BoundMustBeAnInterface,
1247 		new String[] {new String(type.readableName())},
1248 		new String[] {new String(type.shortReadableName())},
1249 		location.sourceStart,
1250 		location.sourceEnd);
1251 }
bytecodeExceeds64KLimit(SwitchStatement switchStatement)1252 public void bytecodeExceeds64KLimit(SwitchStatement switchStatement) {
1253 	TypeBinding enumType = switchStatement.expression.resolvedType;
1254 	this.handle(
1255 		IProblem.BytecodeExceeds64KLimitForSwitchTable,
1256 		new String[] {new String(enumType.readableName())},
1257 		new String[] {new String(enumType.shortReadableName())},
1258 		ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
1259 		switchStatement.sourceStart(),
1260 		switchStatement.sourceEnd());
1261 }
bytecodeExceeds64KLimit(MethodBinding method, int start, int end)1262 public void bytecodeExceeds64KLimit(MethodBinding method, int start, int end) {
1263 	this.handle(
1264 		IProblem.BytecodeExceeds64KLimit,
1265 		new String[] {new String(method.selector), typesAsString(method, false)},
1266 		new String[] {new String(method.selector), typesAsString(method, true)},
1267 		ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
1268 		start,
1269 		end);
1270 }
bytecodeExceeds64KLimit(AbstractMethodDeclaration location)1271 public void bytecodeExceeds64KLimit(AbstractMethodDeclaration location) {
1272 	MethodBinding method = location.binding;
1273 	if (location.isConstructor()) {
1274 		this.handle(
1275 			IProblem.BytecodeExceeds64KLimitForConstructor,
1276 			new String[] {new String(location.selector), typesAsString(method, false)},
1277 			new String[] {new String(location.selector), typesAsString(method, true)},
1278 			ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
1279 			location.sourceStart,
1280 			location.sourceEnd);
1281 	} else {
1282 		bytecodeExceeds64KLimit(method,	location.sourceStart, location.sourceEnd);
1283 	}
1284 }
bytecodeExceeds64KLimit(LambdaExpression location)1285 public void bytecodeExceeds64KLimit(LambdaExpression location) {
1286 	bytecodeExceeds64KLimit(location.binding, location.sourceStart, location.diagnosticsSourceEnd());
1287 }
bytecodeExceeds64KLimit(TypeDeclaration location)1288 public void bytecodeExceeds64KLimit(TypeDeclaration location) {
1289 	this.handle(
1290 		IProblem.BytecodeExceeds64KLimitForClinit,
1291 		NoArgument,
1292 		NoArgument,
1293 		ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
1294 		location.sourceStart,
1295 		location.sourceEnd);
1296 }
cannotAllocateVoidArray(Expression expression)1297 public void cannotAllocateVoidArray(Expression expression) {
1298 	this.handle(
1299 		IProblem.CannotAllocateVoidArray,
1300 		NoArgument,
1301 		NoArgument,
1302 		expression.sourceStart,
1303 		expression.sourceEnd);
1304 }
cannotAssignToFinalField(FieldBinding field, ASTNode location)1305 public void cannotAssignToFinalField(FieldBinding field, ASTNode location) {
1306 	this.handle(
1307 		IProblem.FinalFieldAssignment,
1308 		new String[] {
1309 			(field.declaringClass == null ? "array" : new String(field.declaringClass.readableName())), //$NON-NLS-1$
1310 			new String(field.readableName())},
1311 		new String[] {
1312 			(field.declaringClass == null ? "array" : new String(field.declaringClass.shortReadableName())), //$NON-NLS-1$
1313 			new String(field.shortReadableName())},
1314 		nodeSourceStart(field, location),
1315 		nodeSourceEnd(field, location));
1316 }
cannotAssignToFinalLocal(LocalVariableBinding local, ASTNode location)1317 public void cannotAssignToFinalLocal(LocalVariableBinding local, ASTNode location) {
1318 	int problemId = 0;
1319 	if ((local.tagBits & TagBits.MultiCatchParameter) != 0) {
1320 		problemId = IProblem.AssignmentToMultiCatchParameter;
1321 	} else if ((local.tagBits & TagBits.IsResource) != 0) {
1322 		problemId = IProblem.AssignmentToResource;
1323 	} else {
1324 		problemId = IProblem.NonBlankFinalLocalAssignment;
1325 	}
1326 	String[] arguments = new String[] { new String(local.readableName())};
1327 	this.handle(
1328 		problemId,
1329 		arguments,
1330 		arguments,
1331 		nodeSourceStart(local, location),
1332 		nodeSourceEnd(local, location));
1333 }
cannotAssignToFinalOuterLocal(LocalVariableBinding local, ASTNode location)1334 public void cannotAssignToFinalOuterLocal(LocalVariableBinding local, ASTNode location) {
1335 	String[] arguments = new String[] {new String(local.readableName())};
1336 	this.handle(
1337 		IProblem.FinalOuterLocalAssignment,
1338 		arguments,
1339 		arguments,
1340 		nodeSourceStart(local, location),
1341 		nodeSourceEnd(local, location));
1342 }
cannotDefineDimensionsAndInitializer(ArrayAllocationExpression expresssion)1343 public void cannotDefineDimensionsAndInitializer(ArrayAllocationExpression expresssion) {
1344 	this.handle(
1345 		IProblem.CannotDefineDimensionExpressionsWithInit,
1346 		NoArgument,
1347 		NoArgument,
1348 		expresssion.sourceStart,
1349 		expresssion.sourceEnd);
1350 }
cannotDireclyInvokeAbstractMethod(ASTNode invocationSite, MethodBinding method)1351 public void cannotDireclyInvokeAbstractMethod(ASTNode invocationSite, MethodBinding method) {
1352 	this.handle(
1353 		IProblem.DirectInvocationOfAbstractMethod,
1354 		new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method, false)},
1355 		new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method, true)},
1356 		invocationSite.sourceStart,
1357 		invocationSite.sourceEnd);
1358 }
cannotExtendEnum(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding)1359 public void cannotExtendEnum(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) {
1360 	String name = new String(type.sourceName());
1361 	String superTypeFullName = new String(superTypeBinding.readableName());
1362 	String superTypeShortName = new String(superTypeBinding.shortReadableName());
1363 	if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName;
1364 	this.handle(
1365 		IProblem.CannotExtendEnum,
1366 		new String[] {superTypeFullName, name},
1367 		new String[] {superTypeShortName, name},
1368 		superclass.sourceStart,
1369 		superclass.sourceEnd);
1370 }
cannotImportPackage(ImportReference importRef)1371 public void cannotImportPackage(ImportReference importRef) {
1372 	String[] arguments = new String[] {CharOperation.toString(importRef.tokens)};
1373 	this.handleUntagged(
1374 		IProblem.CannotImportPackage,
1375 		arguments,
1376 		arguments,
1377 		importRef.sourceStart,
1378 		importRef.sourceEnd);
1379 }
cannotInstantiate(Expression typeRef, TypeBinding type)1380 public void cannotInstantiate(Expression typeRef, TypeBinding type) {
1381 	this.handle(
1382 		IProblem.InvalidClassInstantiation,
1383 		new String[] {new String(type.readableName())},
1384 		new String[] {new String(type.shortReadableName())},
1385 		typeRef.sourceStart,
1386 		typeRef.sourceEnd);
1387 }
cannotInvokeSuperConstructorInEnum(ExplicitConstructorCall constructorCall, MethodBinding enumConstructor)1388 public void cannotInvokeSuperConstructorInEnum(ExplicitConstructorCall constructorCall, MethodBinding enumConstructor) {
1389 	this.handle(
1390 		IProblem.CannotInvokeSuperConstructorInEnum,
1391 		new String[] {
1392 		        new String(enumConstructor.declaringClass.sourceName()),
1393 		        typesAsString(enumConstructor, false),
1394 		 },
1395 		new String[] {
1396 		        new String(enumConstructor.declaringClass.sourceName()),
1397 		        typesAsString(enumConstructor, true),
1398 		 },
1399 		constructorCall.sourceStart,
1400 		constructorCall.sourceEnd);
1401 }
cannotReadSource(CompilationUnitDeclaration unit, AbortCompilationUnit abortException, boolean verbose)1402 public void cannotReadSource(CompilationUnitDeclaration unit, AbortCompilationUnit abortException, boolean verbose) {
1403 	String fileName = new String(unit.compilationResult.fileName);
1404 	if (abortException.exception instanceof CharConversionException) {
1405 		// specific encoding issue
1406 		String encoding = abortException.encoding;
1407 		if (encoding == null) {
1408 			encoding = System.getProperty("file.encoding"); //$NON-NLS-1$
1409 		}
1410 		String[] arguments = new String[]{ fileName, encoding };
1411 		this.handle(
1412 				IProblem.InvalidEncoding,
1413 				arguments,
1414 				arguments,
1415 				0,
1416 				0);
1417 		return;
1418 	}
1419 	StringWriter stringWriter = new StringWriter();
1420 	PrintWriter writer = new PrintWriter(stringWriter);
1421 	if (verbose) {
1422 		abortException.exception.printStackTrace(writer);
1423 		System.err.println(stringWriter.toString());
1424 		stringWriter = new StringWriter();
1425 		writer = new PrintWriter(stringWriter);
1426 	}
1427 	writer.print(abortException.exception.getClass().getName());
1428 	writer.print(':');
1429 	writer.print(abortException.exception.getMessage());
1430 	String exceptionTrace = stringWriter.toString();
1431 	String[] arguments = new String[]{ fileName, exceptionTrace };
1432 	this.handle(
1433 			IProblem.CannotReadSource,
1434 			arguments,
1435 			arguments,
1436 			0,
1437 			0);
1438 }
cannotReferToNonFinalOuterLocal(LocalVariableBinding local, ASTNode location)1439 public void cannotReferToNonFinalOuterLocal(LocalVariableBinding local, ASTNode location) {
1440 	String[] arguments =new String[]{ new String(local.readableName())};
1441 	this.handle(
1442 		IProblem.OuterLocalMustBeFinal,
1443 		arguments,
1444 		arguments,
1445 		nodeSourceStart(local, location),
1446 		nodeSourceEnd(local, location));
1447 }
cannotReferToNonEffectivelyFinalOuterLocal(VariableBinding local, ASTNode location)1448 public void cannotReferToNonEffectivelyFinalOuterLocal(VariableBinding local, ASTNode location) {
1449 	String[] arguments = new String[] { new String(local.readableName()) };
1450 	this.handle(
1451 		IProblem.OuterLocalMustBeEffectivelyFinal,
1452 		arguments,
1453 		arguments,
1454 		nodeSourceStart(local, location),
1455 		nodeSourceEnd(local, location));
1456 }
cannotReferToNonFinalField(VariableBinding local, ASTNode location)1457 public void cannotReferToNonFinalField(VariableBinding local, ASTNode location) {
1458 	String[] arguments = new String[] { new String(local.readableName()) };
1459 	this.handle(
1460 		IProblem.FieldMustBeFinal,
1461 		arguments,
1462 		arguments,
1463 		nodeSourceStart(local, location),
1464 		nodeSourceEnd(local, location));
1465 }
cannotReturnInInitializer(ASTNode location)1466 public void cannotReturnInInitializer(ASTNode location) {
1467 	this.handle(
1468 		IProblem.CannotReturnInInitializer,
1469 		NoArgument,
1470 		NoArgument,
1471 		location.sourceStart,
1472 		location.sourceEnd);
1473 }
cannotThrowNull(ASTNode expression)1474 public void cannotThrowNull(ASTNode expression) {
1475 	this.handle(
1476 		IProblem.CannotThrowNull,
1477 		NoArgument,
1478 		NoArgument,
1479 		expression.sourceStart,
1480 		expression.sourceEnd);
1481 }
cannotThrowType(ASTNode exception, TypeBinding expectedType)1482 public void cannotThrowType(ASTNode exception, TypeBinding expectedType) {
1483 	this.handle(
1484 		IProblem.CannotThrowType,
1485 		new String[] {new String(expectedType.readableName())},
1486 		new String[] {new String(expectedType.shortReadableName())},
1487 		exception.sourceStart,
1488 		exception.sourceEnd);
1489 }
1490 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=391092
illegalArrayOfUnionType(char[] identifierName, TypeReference typeReference)1491 public void illegalArrayOfUnionType(char[] identifierName, TypeReference typeReference) {
1492 		this.handle(
1493 		IProblem.IllegalArrayOfUnionType,
1494 		NoArgument,
1495 		NoArgument,
1496 		typeReference.sourceStart,
1497 		typeReference.sourceEnd);
1498 }
cannotUseQualifiedEnumConstantInCaseLabel(Reference location, FieldBinding field)1499 public void cannotUseQualifiedEnumConstantInCaseLabel(Reference location, FieldBinding field) {
1500 	this.handle(
1501 		IProblem.IllegalQualifiedEnumConstantLabel,
1502 		new String[]{ String.valueOf(field.declaringClass.readableName()), String.valueOf(field.name) },
1503 		new String[]{ String.valueOf(field.declaringClass.shortReadableName()), String.valueOf(field.name) },
1504 		location.sourceStart(),
1505 		location.sourceEnd());
1506 }
cannotUseSuperInCodeSnippet(int start, int end)1507 public void cannotUseSuperInCodeSnippet(int start, int end) {
1508 	this.handle(
1509 		IProblem.CannotUseSuperInCodeSnippet,
1510 		NoArgument,
1511 		NoArgument,
1512 		ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
1513 		start,
1514 		end);
1515 }
cannotUseSuperInJavaLangObject(ASTNode reference)1516 public void cannotUseSuperInJavaLangObject(ASTNode reference) {
1517 	this.handle(
1518 		IProblem.ObjectHasNoSuperclass,
1519 		NoArgument,
1520 		NoArgument,
1521 		reference.sourceStart,
1522 		reference.sourceEnd);
1523 }
targetTypeIsNotAFunctionalInterface(FunctionalExpression target)1524 public void targetTypeIsNotAFunctionalInterface(FunctionalExpression target) {
1525 	this.handle(
1526 		IProblem.TargetTypeNotAFunctionalInterface,
1527 		NoArgument,
1528 		NoArgument,
1529 		target.sourceStart,
1530 		target.diagnosticsSourceEnd());
1531 }
illFormedParameterizationOfFunctionalInterface(FunctionalExpression target)1532 public void illFormedParameterizationOfFunctionalInterface(FunctionalExpression target) {
1533 	this.handle(
1534 		IProblem.illFormedParameterizationOfFunctionalInterface,
1535 		NoArgument,
1536 		NoArgument,
1537 		target.sourceStart,
1538 		target.diagnosticsSourceEnd());
1539 }
lambdaSignatureMismatched(LambdaExpression target)1540 public void lambdaSignatureMismatched(LambdaExpression target) {
1541 	this.handle(
1542 		IProblem.lambdaSignatureMismatched,
1543 		new String[] { new String(target.descriptor.readableName()) },
1544 		new String[] { new String(target.descriptor.shortReadableName()) },
1545 		target.sourceStart,
1546 		target.diagnosticsSourceEnd());
1547 }
1548 
lambdaParameterTypeMismatched(Argument argument, TypeReference type, TypeBinding expectedParameterType)1549 public void lambdaParameterTypeMismatched(Argument argument, TypeReference type, TypeBinding expectedParameterType) {
1550 	String name = new String(argument.name);
1551 	String expectedTypeFullName = new String(expectedParameterType.readableName());
1552 	String expectedTypeShortName = new String(expectedParameterType.shortReadableName());
1553 	this.handle(
1554 			expectedParameterType.isTypeVariable() ? IProblem.IncompatibleLambdaParameterType : IProblem.lambdaParameterTypeMismatched,
1555 			new String[] { name, expectedTypeFullName },
1556 			new String[] { name, expectedTypeShortName },
1557 			type.sourceStart,
1558 			type.sourceEnd);
1559 }
lambdaExpressionCannotImplementGenericMethod(LambdaExpression lambda, MethodBinding sam)1560 public void lambdaExpressionCannotImplementGenericMethod(LambdaExpression lambda, MethodBinding sam) {
1561 	final String selector = new String(sam.selector);
1562 	this.handle(
1563 			IProblem.NoGenericLambda,
1564 			new String[] { selector, new String(sam.declaringClass.readableName())},
1565 			new String[] { selector, new String(sam.declaringClass.shortReadableName())},
1566 			lambda.sourceStart,
1567 			lambda.diagnosticsSourceEnd());
1568 }
missingValueFromLambda(LambdaExpression lambda, TypeBinding returnType)1569 public void missingValueFromLambda(LambdaExpression lambda, TypeBinding returnType) {
1570 	this.handle(IProblem.MissingValueFromLambda,
1571 			new String[] {new String(returnType.readableName())},
1572 			new String[] {new String(returnType.shortReadableName())},
1573 			lambda.sourceStart,
1574 			lambda.diagnosticsSourceEnd());
1575 }
caseExpressionMustBeConstant(Expression expression)1576 public void caseExpressionMustBeConstant(Expression expression) {
1577 	this.handle(
1578 		IProblem.NonConstantExpression,
1579 		NoArgument,
1580 		NoArgument,
1581 		expression.sourceStart,
1582 		expression.sourceEnd);
1583 }
classExtendFinalClass(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding)1584 public void classExtendFinalClass(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) {
1585 	String name = new String(type.sourceName());
1586 	String superTypeFullName = new String(superTypeBinding.readableName());
1587 	String superTypeShortName = new String(superTypeBinding.shortReadableName());
1588 	if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName;
1589 	this.handle(
1590 		IProblem.ClassExtendFinalClass,
1591 		new String[] {superTypeFullName, name},
1592 		new String[] {superTypeShortName, name},
1593 		superclass.sourceStart,
1594 		superclass.sourceEnd);
1595 }
codeSnippetMissingClass(String missing, int start, int end)1596 public void codeSnippetMissingClass(String missing, int start, int end) {
1597 	String[] arguments = new String[]{missing};
1598 	this.handle(
1599 		IProblem.CodeSnippetMissingClass,
1600 		arguments,
1601 		arguments,
1602 		ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
1603 		start,
1604 		end);
1605 }
codeSnippetMissingMethod(String className, String missingMethod, String argumentTypes, int start, int end)1606 public void codeSnippetMissingMethod(String className, String missingMethod, String argumentTypes, int start, int end) {
1607 	String[] arguments = new String[]{ className, missingMethod, argumentTypes };
1608 	this.handle(
1609 		IProblem.CodeSnippetMissingMethod,
1610 		arguments,
1611 		arguments,
1612 		ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
1613 		start,
1614 		end);
1615 }
comparingIdenticalExpressions(Expression comparison)1616 public void comparingIdenticalExpressions(Expression comparison){
1617 	int severity = computeSeverity(IProblem.ComparingIdentical);
1618 	if (severity == ProblemSeverities.Ignore) return;
1619 	this.handle(
1620 			IProblem.ComparingIdentical,
1621 			NoArgument,
1622 			NoArgument,
1623 			severity,
1624 			comparison.sourceStart,
1625 			comparison.sourceEnd);
1626 }
1627 /*
1628  * Given the current configuration, answers which category the problem
1629  * falls into:
1630  *		ProblemSeverities.Error | ProblemSeverities.Warning | ProblemSeverities.Ignore
1631  * when different from Ignore, severity can be coupled with ProblemSeverities.Optional
1632  * to indicate that this problem is configurable through options
1633  */
1634 @Override
computeSeverity(int problemID)1635 public int computeSeverity(int problemID){
1636 
1637 	switch (problemID) {
1638 		case IProblem.VarargsConflict :
1639  		case IProblem.SwitchExpressionsYieldUnqualifiedMethodWarning:
1640  		case IProblem.SwitchExpressionsYieldRestrictedGeneralWarning:
1641  		case IProblem.SwitchExpressionsYieldTypeDeclarationWarning:
1642  			return ProblemSeverities.Warning;
1643  		case IProblem.TypeCollidesWithPackage :
1644 			return ProblemSeverities.Error;
1645 
1646 		/*
1647 		 * Javadoc tags resolved references errors
1648 		 */
1649 		case IProblem.JavadocInvalidParamName:
1650 		case IProblem.JavadocDuplicateParamName:
1651 		case IProblem.JavadocMissingParamName:
1652 		case IProblem.JavadocInvalidMemberTypeQualification:
1653 		case IProblem.JavadocInvalidThrowsClassName:
1654 		case IProblem.JavadocDuplicateThrowsClassName:
1655 		case IProblem.JavadocMissingThrowsClassName:
1656 		case IProblem.JavadocMissingSeeReference:
1657 		case IProblem.JavadocInvalidValueReference:
1658 		case IProblem.JavadocUndefinedField:
1659 		case IProblem.JavadocAmbiguousField:
1660 		case IProblem.JavadocUndefinedConstructor:
1661 		case IProblem.JavadocAmbiguousConstructor:
1662 		case IProblem.JavadocUndefinedMethod:
1663 		case IProblem.JavadocAmbiguousMethod:
1664 		case IProblem.JavadocAmbiguousMethodReference:
1665 		case IProblem.JavadocParameterMismatch:
1666 		case IProblem.JavadocUndefinedType:
1667 		case IProblem.JavadocAmbiguousType:
1668 		case IProblem.JavadocInternalTypeNameProvided:
1669 		case IProblem.JavadocNoMessageSendOnArrayType:
1670 		case IProblem.JavadocNoMessageSendOnBaseType:
1671 		case IProblem.JavadocInheritedMethodHidesEnclosingName:
1672 		case IProblem.JavadocInheritedFieldHidesEnclosingName:
1673 		case IProblem.JavadocInheritedNameHidesEnclosingTypeName:
1674 		case IProblem.JavadocNonStaticTypeFromStaticInvocation:
1675 		case IProblem.JavadocGenericMethodTypeArgumentMismatch:
1676 		case IProblem.JavadocNonGenericMethod:
1677 		case IProblem.JavadocIncorrectArityForParameterizedMethod:
1678 		case IProblem.JavadocParameterizedMethodArgumentTypeMismatch:
1679 		case IProblem.JavadocTypeArgumentsForRawGenericMethod:
1680 		case IProblem.JavadocGenericConstructorTypeArgumentMismatch:
1681 		case IProblem.JavadocNonGenericConstructor:
1682 		case IProblem.JavadocIncorrectArityForParameterizedConstructor:
1683 		case IProblem.JavadocParameterizedConstructorArgumentTypeMismatch:
1684 		case IProblem.JavadocTypeArgumentsForRawGenericConstructor:
1685 			if (!this.options.reportInvalidJavadocTags) {
1686 				return ProblemSeverities.Ignore;
1687 			}
1688 			break;
1689 		/*
1690 		 * Javadoc invalid tags due to deprecated references
1691 		 */
1692 		case IProblem.JavadocUsingDeprecatedField:
1693 		case IProblem.JavadocUsingDeprecatedConstructor:
1694 		case IProblem.JavadocUsingDeprecatedMethod:
1695 		case IProblem.JavadocUsingDeprecatedType:
1696 			if (!(this.options.reportInvalidJavadocTags && this.options.reportInvalidJavadocTagsDeprecatedRef)) {
1697 				return ProblemSeverities.Ignore;
1698 			}
1699 			break;
1700 		/*
1701 		 * Javadoc invalid tags due to non-visible references
1702 		 */
1703 		case IProblem.JavadocNotVisibleField:
1704 		case IProblem.JavadocNotVisibleConstructor:
1705 		case IProblem.JavadocNotVisibleMethod:
1706 		case IProblem.JavadocNotVisibleType:
1707 		case IProblem.JavadocHiddenReference:
1708 			if (!(this.options.reportInvalidJavadocTags && this.options.reportInvalidJavadocTagsNotVisibleRef)) {
1709 				return ProblemSeverities.Ignore;
1710 			}
1711 			break;
1712 		/*
1713 		 * Javadoc missing tag descriptions
1714 		 */
1715 		case IProblem.JavadocEmptyReturnTag:
1716 			if (CompilerOptions.NO_TAG.equals(this.options.reportMissingJavadocTagDescription)) {
1717 				return ProblemSeverities.Ignore;
1718 			}
1719 			break;
1720 		case IProblem.JavadocMissingTagDescription:
1721 			if (! CompilerOptions.ALL_STANDARD_TAGS.equals(this.options.reportMissingJavadocTagDescription)) {
1722 				return ProblemSeverities.Ignore;
1723 			}
1724 			break;
1725 		// For compatibility with javac 8b111 for now.
1726 		case IProblem.RepeatableAnnotationWithRepeatingContainerAnnotation:
1727 		case IProblem.ToleratedMisplacedTypeAnnotations:
1728 			return ProblemSeverities.Warning;
1729 		case IProblem.IllegalUseOfUnderscoreAsAnIdentifier:
1730 			return this.underScoreIsError ? ProblemSeverities.Error : ProblemSeverities.Warning;
1731 	}
1732 	int irritant = getIrritant(problemID);
1733 	if (irritant != 0) {
1734 		if ((problemID & IProblem.Javadoc) != 0 && !this.options.docCommentSupport)
1735 			return ProblemSeverities.Ignore;
1736 		return this.options.getSeverity(irritant);
1737 	}
1738 	return ProblemSeverities.Error | ProblemSeverities.Fatal;
1739 }
conditionalArgumentsIncompatibleTypes(ConditionalExpression expression, TypeBinding trueType, TypeBinding falseType)1740 public void conditionalArgumentsIncompatibleTypes(ConditionalExpression expression, TypeBinding trueType, TypeBinding falseType) {
1741 	this.handle(
1742 		IProblem.IncompatibleTypesInConditionalOperator,
1743 		new String[] {new String(trueType.readableName()), new String(falseType.readableName())},
1744 		new String[] {new String(trueType.shortReadableName()), new String(falseType.shortReadableName())},
1745 		expression.sourceStart,
1746 		expression.sourceEnd);
1747 }
conflictingImport(ImportReference importRef)1748 public void conflictingImport(ImportReference importRef) {
1749 	String[] arguments = new String[] {CharOperation.toString(importRef.tokens)};
1750 	this.handleUntagged(
1751 		IProblem.ConflictingImport,
1752 		arguments,
1753 		arguments,
1754 		importRef.sourceStart,
1755 		importRef.sourceEnd);
1756 }
constantOutOfRange(Literal literal, TypeBinding literalType)1757 public void constantOutOfRange(Literal literal, TypeBinding literalType) {
1758 	String[] arguments = new String[] {new String(literalType.readableName()), new String(literal.source())};
1759 	this.handle(
1760 		IProblem.NumericValueOutOfRange,
1761 		arguments,
1762 		arguments,
1763 		literal.sourceStart,
1764 		literal.sourceEnd);
1765 }
corruptedSignature(TypeBinding enclosingType, char[] signature, int position)1766 public void corruptedSignature(TypeBinding enclosingType, char[] signature, int position) {
1767 	this.handle(
1768 		IProblem.CorruptedSignature,
1769 		new String[] { new String(enclosingType.readableName()), new String(signature), String.valueOf(position) },
1770 		new String[] { new String(enclosingType.shortReadableName()), new String(signature), String.valueOf(position) },
1771 		ProblemSeverities.Error | ProblemSeverities.Abort | ProblemSeverities.Fatal,
1772 		0,
1773 		0);
1774 }
defaultMethodOverridesObjectMethod(MethodBinding currentMethod)1775 public void defaultMethodOverridesObjectMethod(MethodBinding currentMethod) {
1776 	// Java 8 feature
1777 	AbstractMethodDeclaration method = currentMethod.sourceMethod();
1778 	int sourceStart = 0;
1779 	int sourceEnd = 0;
1780 	if (method != null) {
1781 		sourceStart = method.sourceStart;
1782 		sourceEnd = method.sourceEnd;
1783 	}
1784 	this.handle(
1785 		IProblem.DefaultMethodOverridesObjectMethod,
1786 		NoArgument, NoArgument,
1787 		sourceStart, sourceEnd);
1788 }
1789 
defaultModifierIllegallySpecified(int sourceStart, int sourceEnd)1790 public void defaultModifierIllegallySpecified(int sourceStart, int sourceEnd) {
1791 	this.handle(
1792 		IProblem.IllegalDefaultModifierSpecification,
1793 		NoArgument, NoArgument,
1794 		sourceStart, sourceEnd);
1795 }
1796 
deprecatedField(final FieldBinding field, ASTNode location)1797 public void deprecatedField(final FieldBinding field, ASTNode location) {
1798 	String fieldName = new String(field.name);
1799 	int sourceStart = nodeSourceStart(field, location);
1800 	int sourceEnd = nodeSourceEnd(field, location);
1801 	String sinceValue = deprecatedSinceValue(() -> field.getAnnotations());
1802 	if (sinceValue != null) {
1803 		this.handle(
1804 			(field.tagBits & TagBits.AnnotationTerminallyDeprecated) == 0 ? IProblem.UsingDeprecatedSinceVersionField : IProblem.UsingTerminallyDeprecatedSinceVersionField,
1805 			new String[] {new String(field.declaringClass.readableName()), fieldName, sinceValue},
1806 			new String[] {new String(field.declaringClass.shortReadableName()), fieldName, sinceValue},
1807 			sourceStart, sourceEnd);
1808 	} else {
1809 		this.handle(
1810 			(field.tagBits & TagBits.AnnotationTerminallyDeprecated) == 0 ? IProblem.UsingDeprecatedField : IProblem.UsingTerminallyDeprecatedField,
1811 			new String[] {new String(field.declaringClass.readableName()), fieldName},
1812 			new String[] {new String(field.declaringClass.shortReadableName()), fieldName},
1813 			sourceStart, sourceEnd);
1814 	}
1815 }
1816 
deprecatedMethod(final MethodBinding method, ASTNode location)1817 public void deprecatedMethod(final MethodBinding method, ASTNode location) {
1818 	// common arguments:
1819 	String readableClassName = new String(method.declaringClass.readableName());
1820 	String shortReadableClassName = new String(method.declaringClass.shortReadableName());
1821 	String selector = new String(method.selector);
1822 	String signature = typesAsString(method, false);
1823 	String shortSignature = typesAsString(method, true);
1824 
1825 	boolean isConstructor = method.isConstructor();
1826 	int start = -1;
1827 	if (isConstructor) {
1828 		if(location instanceof AllocationExpression) {
1829 			// omit the new keyword from the warning marker
1830 			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=300031
1831 			AllocationExpression allocationExpression = (AllocationExpression) location;
1832 			start = allocationExpression.nameSourceStart();
1833 		}
1834 	} else {
1835 		if (location instanceof MessageSend) {
1836 			// start the warning marker from the location where the name of the method starts
1837 			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=300031
1838 			start = (int) (((MessageSend)location).nameSourcePosition >>> 32);
1839 		}
1840 	}
1841 	int sourceStart = (start == -1) ? location.sourceStart : start;
1842 	int sourceEnd = location.sourceEnd;
1843 
1844 	// discriminate:
1845 	boolean terminally = (method.tagBits & TagBits.AnnotationTerminallyDeprecated) != 0;
1846 	String sinceValue = deprecatedSinceValue(() -> method.getAnnotations());
1847 	if (sinceValue == null && method.isConstructor()) {
1848 		sinceValue = deprecatedSinceValue(() -> method.declaringClass.getAnnotations()); // for default ctor
1849 	}
1850 	if (sinceValue != null) {
1851 		if (isConstructor) {
1852 			this.handle(
1853 				terminally ? IProblem.UsingTerminallyDeprecatedSinceVersionConstructor : IProblem.UsingDeprecatedSinceVersionConstructor,
1854 				new String[] {readableClassName, signature, sinceValue},
1855 				new String[] {shortReadableClassName, shortSignature, sinceValue},
1856 				sourceStart, sourceEnd);
1857 		} else {
1858 			this.handle(
1859 				terminally ? IProblem.UsingTerminallyDeprecatedSinceVersionMethod : IProblem.UsingDeprecatedSinceVersionMethod,
1860 				new String[] {readableClassName, selector, signature, sinceValue},
1861 				new String[] {shortReadableClassName, selector, shortSignature, sinceValue},
1862 				sourceStart, sourceEnd);
1863 		}
1864 	} else {
1865 		if (isConstructor) {
1866 			this.handle(
1867 				terminally ? IProblem.UsingTerminallyDeprecatedConstructor : IProblem.UsingDeprecatedConstructor,
1868 				new String[] {readableClassName, signature},
1869 				new String[] {shortReadableClassName, shortSignature},
1870 				sourceStart, sourceEnd);
1871 		} else {
1872 			this.handle(
1873 				terminally ? IProblem.UsingTerminallyDeprecatedMethod : IProblem.UsingDeprecatedMethod,
1874 				new String[] {readableClassName, selector, signature},
1875 				new String[] {shortReadableClassName, selector, shortSignature},
1876 				sourceStart, sourceEnd);
1877 		}
1878 	}
1879 }
deprecatedType(TypeBinding type, ASTNode location)1880 public void deprecatedType(TypeBinding type, ASTNode location) {
1881 	deprecatedType(type, location, Integer.MAX_VALUE);
1882 }
1883 // The argument 'index' makes sure that we demarcate partial types correctly while marking off
1884 // a deprecated type in a qualified reference (see bug 292510)
deprecatedType(TypeBinding type, ASTNode location, int index)1885 public void deprecatedType(TypeBinding type, ASTNode location, int index) {
1886 	if (location == null) return; // 1G828DN - no type ref for synthetic arguments
1887 	final TypeBinding leafType = type.leafComponentType();
1888 	int sourceStart = -1;
1889 	if (location instanceof QualifiedTypeReference) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=300031
1890 		QualifiedTypeReference ref = (QualifiedTypeReference) location;
1891 		if (index < Integer.MAX_VALUE) {
1892 			sourceStart = (int) (ref.sourcePositions[index] >> 32);
1893 		}
1894 	}
1895 	String sinceValue = deprecatedSinceValue(() -> leafType.getAnnotations());
1896 	if (sinceValue != null) {
1897 		this.handle(
1898 			((leafType.tagBits & TagBits.AnnotationTerminallyDeprecated) == 0) ? IProblem.UsingDeprecatedSinceVersionType : IProblem.UsingTerminallyDeprecatedSinceVersionType,
1899 			new String[] {new String(leafType.readableName()), sinceValue},
1900 			new String[] {new String(leafType.shortReadableName()), sinceValue},
1901 			(sourceStart == -1) ? location.sourceStart : sourceStart,
1902 			nodeSourceEnd(null, location, index));
1903 	} else {
1904 		this.handle(
1905 			((leafType.tagBits & TagBits.AnnotationTerminallyDeprecated) == 0) ? IProblem.UsingDeprecatedType : IProblem.UsingTerminallyDeprecatedType,
1906 			new String[] {new String(leafType.readableName())},
1907 			new String[] {new String(leafType.shortReadableName())},
1908 			(sourceStart == -1) ? location.sourceStart : sourceStart,
1909 			nodeSourceEnd(null, location, index));
1910 	}
1911 }
deprecatedModule(ModuleReference moduleReference, ModuleBinding requiredModule)1912 public void deprecatedModule(ModuleReference moduleReference, ModuleBinding requiredModule) {
1913 	String sinceValue = deprecatedSinceValue(() -> requiredModule.getAnnotations());
1914 	boolean isTerminally = (requiredModule.tagBits & TagBits.AnnotationTerminallyDeprecated) != 0;
1915 	if (sinceValue != null) {
1916 		String[] args = { String.valueOf(requiredModule.name()), sinceValue };
1917 		handle( isTerminally ? IProblem.UsingTerminallyDeprecatedSinceVersionModule : IProblem.UsingDeprecatedSinceVersionModule,
1918 				args,
1919 				args,
1920 				moduleReference.sourceStart,
1921 				moduleReference.sourceEnd);
1922 	} else {
1923 		String[] args = { String.valueOf(requiredModule.name()) };
1924 		handle( isTerminally ? IProblem.UsingTerminallyDeprecatedModule : IProblem.UsingDeprecatedModule,
1925 				args,
1926 				args,
1927 				moduleReference.sourceStart,
1928 				moduleReference.sourceEnd);
1929 	}
1930 }
deprecatedSinceValue(Supplier<AnnotationBinding[]> annotations)1931 String deprecatedSinceValue(Supplier<AnnotationBinding[]> annotations) {
1932 	if (this.options != null && this.options.complianceLevel >= ClassFileConstants.JDK9) {
1933 		ReferenceContext contextSave = this.referenceContext;
1934 		try {
1935 			for (AnnotationBinding annotationBinding : annotations.get()) {
1936 				if (annotationBinding.getAnnotationType().id == TypeIds.T_JavaLangDeprecated) {
1937 					for (ElementValuePair elementValuePair : annotationBinding.getElementValuePairs()) {
1938 						if (CharOperation.equals(elementValuePair.getName(), TypeConstants.SINCE) && elementValuePair.value instanceof StringConstant)
1939 							return ((StringConstant) elementValuePair.value).stringValue();
1940 					}
1941 					break;
1942 				}
1943 			}
1944 		} finally {
1945 			this.referenceContext = contextSave;
1946 		}
1947 	}
1948 	return null;
1949 }
disallowedTargetForAnnotation(Annotation annotation)1950 public void disallowedTargetForAnnotation(Annotation annotation) {
1951 	this.handle(
1952 		IProblem.DisallowedTargetForAnnotation,
1953 		new String[] {new String(annotation.resolvedType.readableName())},
1954 		new String[] {new String(annotation.resolvedType.shortReadableName())},
1955 		annotation.sourceStart,
1956 		annotation.sourceEnd);
1957 }
polymorphicMethodNotBelow17(ASTNode node)1958 public void polymorphicMethodNotBelow17(ASTNode node) {
1959 	this.handle(
1960 			IProblem.PolymorphicMethodNotBelow17,
1961 			NoArgument,
1962 			NoArgument,
1963 			node.sourceStart,
1964 			node.sourceEnd);
1965 }
multiCatchNotBelow17(ASTNode node)1966 public void multiCatchNotBelow17(ASTNode node) {
1967 	this.handle(
1968 			IProblem.MultiCatchNotBelow17,
1969 			NoArgument,
1970 			NoArgument,
1971 			node.sourceStart,
1972 			node.sourceEnd);
1973 }
duplicateAnnotation(Annotation annotation, long sourceLevel)1974 public void duplicateAnnotation(Annotation annotation, long sourceLevel) {
1975 	this.handle(
1976 		sourceLevel >= ClassFileConstants.JDK1_8 ? IProblem.DuplicateAnnotationNotMarkedRepeatable : IProblem.DuplicateAnnotation,
1977 		new String[] {new String(annotation.resolvedType.readableName())},
1978 		new String[] {new String(annotation.resolvedType.shortReadableName())},
1979 		annotation.sourceStart,
1980 		annotation.sourceEnd);
1981 }
duplicateAnnotationValue(TypeBinding annotationType, MemberValuePair memberValuePair)1982 public void duplicateAnnotationValue(TypeBinding annotationType, MemberValuePair memberValuePair) {
1983 	String name = 	new String(memberValuePair.name);
1984 	this.handle(
1985 		IProblem.DuplicateAnnotationMember,
1986 		new String[] { name, new String(annotationType.readableName())},
1987 		new String[] {	name, new String(annotationType.shortReadableName())},
1988 		memberValuePair.sourceStart,
1989 		memberValuePair.sourceEnd);
1990 }
duplicateBounds(ASTNode location, TypeBinding type)1991 public void duplicateBounds(ASTNode location, TypeBinding type) {
1992 	this.handle(
1993 		IProblem.DuplicateBounds,
1994 		new String[] {new String(type.readableName())},
1995 		new String[] {new String(type.shortReadableName())},
1996 		location.sourceStart,
1997 		location.sourceEnd);
1998 }
duplicateCase(CaseStatement caseStatement)1999 public void duplicateCase(CaseStatement caseStatement) {
2000 	this.handle(
2001 		IProblem.DuplicateCase,
2002 		NoArgument,
2003 		NoArgument,
2004 		caseStatement.sourceStart,
2005 		caseStatement.sourceEnd);
2006 }
duplicateDefaultCase(ASTNode statement)2007 public void duplicateDefaultCase(ASTNode statement) {
2008 	this.handle(
2009 		IProblem.DuplicateDefaultCase,
2010 		NoArgument,
2011 		NoArgument,
2012 		statement.sourceStart,
2013 		statement.sourceEnd);
2014 }
duplicateEnumSpecialMethod(SourceTypeBinding type, AbstractMethodDeclaration methodDecl)2015 public void duplicateEnumSpecialMethod(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
2016     MethodBinding method = methodDecl.binding;
2017 	this.handle(
2018 		IProblem.CannotDeclareEnumSpecialMethod,
2019 		new String[] {
2020 	        new String(methodDecl.selector),
2021 			new String(method.declaringClass.readableName()),
2022 			typesAsString(method, false)},
2023 		new String[] {
2024 			new String(methodDecl.selector),
2025 			new String(method.declaringClass.shortReadableName()),
2026 			typesAsString(method, true)},
2027 		methodDecl.sourceStart,
2028 		methodDecl.sourceEnd);
2029 }
2030 
duplicateFieldInType(SourceTypeBinding type, FieldDeclaration fieldDecl)2031 public void duplicateFieldInType(SourceTypeBinding type, FieldDeclaration fieldDecl) {
2032 	this.handle(
2033 		IProblem.DuplicateField,
2034 		new String[] {new String(type.sourceName()), new String(fieldDecl.name)},
2035 		new String[] {new String(type.shortReadableName()), new String(fieldDecl.name)},
2036 		fieldDecl.sourceStart,
2037 		fieldDecl.sourceEnd);
2038 }
duplicateImport(ImportReference importRef)2039 public void duplicateImport(ImportReference importRef) {
2040 	String[] arguments = new String[] {CharOperation.toString(importRef.tokens)};
2041 	this.handleUntagged(
2042 		IProblem.DuplicateImport,
2043 		arguments,
2044 		arguments,
2045 		importRef.sourceStart,
2046 		importRef.sourceEnd);
2047 }
2048 
duplicateInheritedMethods(SourceTypeBinding type, MethodBinding inheritedMethod1, MethodBinding inheritedMethod2, boolean isJava8)2049 public void duplicateInheritedMethods(SourceTypeBinding type, MethodBinding inheritedMethod1, MethodBinding inheritedMethod2, boolean isJava8) {
2050 	if (TypeBinding.notEquals(inheritedMethod1.declaringClass, inheritedMethod2.declaringClass)) {
2051 		int problemID = IProblem.DuplicateInheritedMethods;
2052 		if (inheritedMethod1.isDefaultMethod() && inheritedMethod2.isDefaultMethod()) {
2053 			if (isJava8)
2054 				problemID = IProblem.DuplicateInheritedDefaultMethods;
2055 			else
2056 				return; // don't report this error at 1.7-
2057 		}
2058 		this.handle(
2059 			problemID,
2060 			new String[] {
2061 		        new String(inheritedMethod1.selector),
2062 				typesAsString(inheritedMethod1, inheritedMethod1.original().parameters, false),
2063 				typesAsString(inheritedMethod2, inheritedMethod2.original().parameters, false),
2064 				new String(inheritedMethod1.declaringClass.readableName()),
2065 				new String(inheritedMethod2.declaringClass.readableName()),
2066 			},
2067 			new String[] {
2068 				new String(inheritedMethod1.selector),
2069 				typesAsString(inheritedMethod1, inheritedMethod1.original().parameters, true),
2070 				typesAsString(inheritedMethod2, inheritedMethod2.original().parameters, true),
2071 				new String(inheritedMethod1.declaringClass.shortReadableName()),
2072 				new String(inheritedMethod2.declaringClass.shortReadableName()),
2073 			},
2074 			type.sourceStart(),
2075 			type.sourceEnd());
2076 		return;
2077 	}
2078 	// Handle duplicates from same class.
2079 	this.handle(
2080 		IProblem.DuplicateParameterizedMethods,
2081 		new String[] {
2082 	        new String(inheritedMethod1.selector),
2083 			new String(inheritedMethod1.declaringClass.readableName()),
2084 			typesAsString(inheritedMethod1, inheritedMethod1.original().parameters, false),
2085 			typesAsString(inheritedMethod2, inheritedMethod2.original().parameters, false)},
2086 		new String[] {
2087 			new String(inheritedMethod1.selector),
2088 			new String(inheritedMethod1.declaringClass.shortReadableName()),
2089 			typesAsString(inheritedMethod1, inheritedMethod1.original().parameters, true),
2090 			typesAsString(inheritedMethod2, inheritedMethod2.original().parameters, true)},
2091 		type.sourceStart(),
2092 		type.sourceEnd());
2093 }
duplicateInitializationOfBlankFinalField(FieldBinding field, Reference reference)2094 public void duplicateInitializationOfBlankFinalField(FieldBinding field, Reference reference) {
2095 	String[] arguments = new String[]{ new String(field.readableName())};
2096 	this.handle(
2097 		IProblem.DuplicateBlankFinalFieldInitialization,
2098 		arguments,
2099 		arguments,
2100 		nodeSourceStart(field, reference),
2101 		nodeSourceEnd(field, reference));
2102 }
duplicateInitializationOfFinalLocal(LocalVariableBinding local, ASTNode location)2103 public void duplicateInitializationOfFinalLocal(LocalVariableBinding local, ASTNode location) {
2104 	String[] arguments = new String[] { new String(local.readableName())};
2105 	if ((local.modifiers & ExtraCompilerModifiers.AccPatternVariable) == 0) {
2106 		this.handle(
2107 			IProblem.DuplicateFinalLocalInitialization,
2108 			arguments,
2109 			arguments,
2110 			nodeSourceStart(local, location),
2111 			nodeSourceEnd(local, location));
2112 	} else {
2113 		this.handle(IProblem.PatternVariableNotInScope,
2114 			arguments,
2115 			arguments,
2116 			nodeSourceStart(local, location),
2117 			nodeSourceEnd(local, location));
2118 	}
2119 }
duplicateMethodInType(AbstractMethodDeclaration methodDecl, boolean equalParameters, int severity)2120 public void duplicateMethodInType(AbstractMethodDeclaration methodDecl, boolean equalParameters, int severity) {
2121     MethodBinding method = methodDecl.binding;
2122     if (equalParameters) {
2123 		this.handle(
2124 			IProblem.DuplicateMethod,
2125 			new String[] {
2126 		        new String(methodDecl.selector),
2127 				new String(method.declaringClass.readableName()),
2128 				typesAsString(method, false)},
2129 			new String[] {
2130 				new String(methodDecl.selector),
2131 				new String(method.declaringClass.shortReadableName()),
2132 				typesAsString(method, true)},
2133 			severity,
2134 			methodDecl.sourceStart,
2135 			methodDecl.sourceEnd);
2136     } else {
2137 		this.handle(
2138 			IProblem.DuplicateMethodErasure,
2139 			new String[] {
2140 		        new String(methodDecl.selector),
2141 				new String(method.declaringClass.readableName()),
2142 				typesAsString(method, false)},
2143 			new String[] {
2144 				new String(methodDecl.selector),
2145 				new String(method.declaringClass.shortReadableName()),
2146 				typesAsString(method, true)},
2147 			severity,
2148 			methodDecl.sourceStart,
2149 			methodDecl.sourceEnd);
2150     }
2151 }
2152 
duplicateModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl)2153 public void duplicateModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
2154 /* to highlight modifiers use:
2155 	this.handle(
2156 		new Problem(
2157 			DuplicateModifierForField,
2158 			new String[] {new String(fieldDecl.name)},
2159 			fieldDecl.modifiers.sourceStart,
2160 			fieldDecl.modifiers.sourceEnd));
2161 */
2162 	String[] arguments = new String[] {new String(fieldDecl.name)};
2163 	this.handle(
2164 		IProblem.DuplicateModifierForField,
2165 		arguments,
2166 		arguments,
2167 		fieldDecl.sourceStart,
2168 		fieldDecl.sourceEnd);
2169 }
duplicateModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl)2170 public void duplicateModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
2171 	this.handle(
2172 		IProblem.DuplicateModifierForMethod,
2173 		new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
2174 		new String[] {new String(type.shortReadableName()), new String(methodDecl.selector)},
2175 		methodDecl.sourceStart,
2176 		methodDecl.sourceEnd);
2177 }
duplicateModifierForType(SourceTypeBinding type)2178 public void duplicateModifierForType(SourceTypeBinding type) {
2179 	String[] arguments = new String[] {new String(type.sourceName())};
2180 	this.handle(
2181 		IProblem.DuplicateModifierForType,
2182 		arguments,
2183 		arguments,
2184 		type.sourceStart(),
2185 		type.sourceEnd());
2186 }
duplicateModifierForVariable(LocalDeclaration localDecl, boolean complainForArgument)2187 public void duplicateModifierForVariable(LocalDeclaration localDecl, boolean complainForArgument) {
2188 	String[] arguments = new String[] {new String(localDecl.name)};
2189 	this.handle(
2190 		complainForArgument
2191 			? IProblem.DuplicateModifierForArgument
2192 			: IProblem.DuplicateModifierForVariable,
2193 		arguments,
2194 		arguments,
2195 		localDecl.sourceStart,
2196 		localDecl.sourceEnd);
2197 }
duplicateNestedType(TypeDeclaration typeDecl)2198 public void duplicateNestedType(TypeDeclaration typeDecl) {
2199 	String[] arguments = new String[] {new String(typeDecl.name)};
2200 	this.handle(
2201 		IProblem.DuplicateNestedType,
2202 		arguments,
2203 		arguments,
2204 		typeDecl.sourceStart,
2205 		typeDecl.sourceEnd);
2206 }
duplicateSuperinterface(SourceTypeBinding type, TypeReference reference, ReferenceBinding superType)2207 public void duplicateSuperinterface(SourceTypeBinding type, TypeReference reference, ReferenceBinding superType) {
2208 	this.handle(
2209 		IProblem.DuplicateSuperInterface,
2210 		new String[] {
2211 			new String(superType.readableName()),
2212 			new String(type.sourceName())},
2213 		new String[] {
2214 			new String(superType.shortReadableName()),
2215 			new String(type.sourceName())},
2216 		reference.sourceStart,
2217 		reference.sourceEnd);
2218 }
duplicateTargetInTargetAnnotation(TypeBinding annotationType, NameReference reference)2219 public void duplicateTargetInTargetAnnotation(TypeBinding annotationType, NameReference reference) {
2220 	FieldBinding field = reference.fieldBinding();
2221 	String name = 	new String(field.name);
2222 	this.handle(
2223 		IProblem.DuplicateTargetInTargetAnnotation,
2224 		new String[] { name, new String(annotationType.readableName())},
2225 		new String[] {	name, new String(annotationType.shortReadableName())},
2226 		nodeSourceStart(field, reference),
2227 		nodeSourceEnd(field, reference));
2228 }
duplicateTypeParameterInType(TypeParameter typeParameter)2229 public void duplicateTypeParameterInType(TypeParameter typeParameter) {
2230 	this.handle(
2231 		IProblem.DuplicateTypeVariable,
2232 		new String[] { new String(typeParameter.name)},
2233 		new String[] { new String(typeParameter.name)},
2234 		typeParameter.sourceStart,
2235 		typeParameter.sourceEnd);
2236 }
duplicateTypes(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl)2237 public void duplicateTypes(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
2238 	String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
2239 	this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
2240 	int end = typeDecl.sourceEnd;
2241 	if (end <= 0) {
2242 		end = -1;
2243 	}
2244 	this.handle(
2245 		IProblem.DuplicateTypes,
2246 		arguments,
2247 		arguments,
2248 		typeDecl.sourceStart,
2249 		end,
2250 		compUnitDecl.compilationResult);
2251 }
emptyControlFlowStatement(int sourceStart, int sourceEnd)2252 public void emptyControlFlowStatement(int sourceStart, int sourceEnd) {
2253 	this.handle(
2254 		IProblem.EmptyControlFlowStatement,
2255 		NoArgument,
2256 		NoArgument,
2257 		sourceStart,
2258 		sourceEnd);
2259 }
enumAbstractMethodMustBeImplemented(AbstractMethodDeclaration method)2260 public void enumAbstractMethodMustBeImplemented(AbstractMethodDeclaration method) {
2261 	MethodBinding abstractMethod = method.binding;
2262 	this.handle(
2263 		// Must implement the inherited abstract method %1
2264 		// 8.4.3 - Every non-abstract subclass of an abstract type, A, must provide a concrete implementation of all of A's methods.
2265 		IProblem.EnumAbstractMethodMustBeImplemented,
2266 		new String[] {
2267 		        new String(abstractMethod.selector),
2268 		        typesAsString(abstractMethod, false),
2269 		        new String(abstractMethod.declaringClass.readableName()),
2270 		},
2271 		new String[] {
2272 		        new String(abstractMethod.selector),
2273 		        typesAsString(abstractMethod, true),
2274 		        new String(abstractMethod.declaringClass.shortReadableName()),
2275 		},
2276 		method.sourceStart(),
2277 		method.sourceEnd());
2278 }
enumConstantMustImplementAbstractMethod(AbstractMethodDeclaration method, FieldDeclaration field)2279 public void enumConstantMustImplementAbstractMethod(AbstractMethodDeclaration method, FieldDeclaration field) {
2280 	MethodBinding abstractMethod = method.binding;
2281 	this.handle(
2282 		IProblem.EnumConstantMustImplementAbstractMethod,
2283 		new String[] {
2284 		        new String(abstractMethod.selector),
2285 		        typesAsString(abstractMethod, false),
2286 		        new String(field.name),
2287 		},
2288 		new String[] {
2289 		        new String(abstractMethod.selector),
2290 		        typesAsString(abstractMethod, true),
2291 		        new String(field.name),
2292 		},
2293 		field.sourceStart(),
2294 		field.sourceEnd());
2295 }
enumConstantsCannotBeSurroundedByParenthesis(Expression expression)2296 public void enumConstantsCannotBeSurroundedByParenthesis(Expression expression) {
2297 	this.handle(
2298 		IProblem.EnumConstantsCannotBeSurroundedByParenthesis,
2299 		NoArgument,
2300 		NoArgument,
2301 		expression.sourceStart,
2302 		expression.sourceEnd);
2303 }
enumStaticFieldUsedDuringInitialization(FieldBinding field, ASTNode location)2304 public void enumStaticFieldUsedDuringInitialization(FieldBinding field, ASTNode location) {
2305 	this.handle(
2306 		IProblem.EnumStaticFieldInInInitializerContext,
2307 		new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
2308 		new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
2309 		nodeSourceStart(field, location),
2310 		nodeSourceEnd(field, location));
2311 }
enumSwitchCannotTargetField(Reference reference, FieldBinding field)2312 public void enumSwitchCannotTargetField(Reference reference, FieldBinding field) {
2313 	this.handle(
2314 			IProblem.EnumSwitchCannotTargetField,
2315 			new String[]{ String.valueOf(field.declaringClass.readableName()), String.valueOf(field.name) },
2316 			new String[]{ String.valueOf(field.declaringClass.shortReadableName()), String.valueOf(field.name) },
2317 			nodeSourceStart(field, reference),
2318 			nodeSourceEnd(field, reference));
2319 }
errorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params)2320 public void errorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params) {
2321 	StringBuffer buffer = new StringBuffer();
2322 	StringBuffer shortBuffer = new StringBuffer();
2323 	for (int i = 0, length = params.length; i < length; i++) {
2324 		if (i != 0){
2325 			buffer.append(", "); //$NON-NLS-1$
2326 			shortBuffer.append(", "); //$NON-NLS-1$
2327 		}
2328 		buffer.append(new String(params[i].readableName()));
2329 		shortBuffer.append(new String(params[i].shortReadableName()));
2330 	}
2331 
2332 	int id = recType.isArrayType() ? IProblem.NoMessageSendOnArrayType : IProblem.NoMessageSendOnBaseType;
2333 	this.handle(
2334 		id,
2335 		new String[] {new String(recType.readableName()), new String(messageSend.selector), buffer.toString()},
2336 		new String[] {new String(recType.shortReadableName()), new String(messageSend.selector), shortBuffer.toString()},
2337 		messageSend.sourceStart,
2338 		messageSend.sourceEnd);
2339 }
errorNoMethodFor(Expression expression, TypeBinding recType, char [] selector, TypeBinding[] params)2340 public void errorNoMethodFor(Expression expression, TypeBinding recType, char [] selector, TypeBinding[] params) {
2341 	StringBuffer buffer = new StringBuffer();
2342 	StringBuffer shortBuffer = new StringBuffer();
2343 	for (int i = 0, length = params.length; i < length; i++) {
2344 		if (i != 0){
2345 			buffer.append(", "); //$NON-NLS-1$
2346 			shortBuffer.append(", "); //$NON-NLS-1$
2347 		}
2348 		buffer.append(new String(params[i].readableName()));
2349 		shortBuffer.append(new String(params[i].shortReadableName()));
2350 	}
2351 
2352 	int id = recType.isArrayType() ? IProblem.NoMessageSendOnArrayType : IProblem.NoMessageSendOnBaseType;
2353 	this.handle(
2354 		id,
2355 		new String[] { new String(recType.readableName()), new String(selector), buffer.toString() },
2356 		new String[] { new String(recType.shortReadableName()), new String(selector), shortBuffer.toString() },
2357 		expression.sourceStart,
2358 		expression.sourceEnd);
2359 }
errorThisSuperInStatic(ASTNode reference)2360 public void errorThisSuperInStatic(ASTNode reference) {
2361 	String[] arguments = new String[] {reference.isSuper() ? "super" : "this"}; //$NON-NLS-2$ //$NON-NLS-1$
2362 	this.handle(
2363 		IProblem.ThisInStaticContext,
2364 		arguments,
2365 		arguments,
2366 		reference.sourceStart,
2367 		reference.sourceEnd);
2368 }
errorNoSuperInInterface(ASTNode reference)2369 public void errorNoSuperInInterface(ASTNode reference) {
2370 	this.handle(
2371 		IProblem.NoSuperInInterfaceContext,
2372 		NoArgument,
2373 		NoArgument,
2374 		reference.sourceStart,
2375 		reference.sourceEnd);
2376 }
expressionShouldBeAVariable(Expression expression)2377 public void expressionShouldBeAVariable(Expression expression) {
2378 	this.handle(
2379 		IProblem.ExpressionShouldBeAVariable,
2380 		NoArgument,
2381 		NoArgument,
2382 		expression.sourceStart,
2383 		expression.sourceEnd);
2384 }
fakeReachable(ASTNode location)2385 public void fakeReachable(ASTNode location) {
2386 	int sourceStart = location.sourceStart;
2387 	int sourceEnd = location.sourceEnd;
2388 	if (location instanceof LocalDeclaration) {
2389 		LocalDeclaration declaration = (LocalDeclaration) location;
2390 		sourceStart = declaration.declarationSourceStart;
2391 		sourceEnd = declaration.declarationSourceEnd;
2392 	}
2393 	this.handle(
2394 		IProblem.DeadCode,
2395 		NoArgument,
2396 		NoArgument,
2397 		sourceStart,
2398 		sourceEnd);
2399 }
fieldHiding(FieldDeclaration fieldDecl, Binding hiddenVariable)2400 public void fieldHiding(FieldDeclaration fieldDecl, Binding hiddenVariable) {
2401 	FieldBinding field = fieldDecl.binding;
2402 	if (CharOperation.equals(TypeConstants.SERIALVERSIONUID, field.name)
2403 			&& field.isStatic()
2404 			&& field.isPrivate()
2405 			&& field.isFinal()
2406 			&& TypeBinding.equalsEquals(TypeBinding.LONG, field.type)) {
2407 		ReferenceBinding referenceBinding = field.declaringClass;
2408 		if (referenceBinding != null) {
2409 			if (referenceBinding.findSuperTypeOriginatingFrom(TypeIds.T_JavaIoSerializable, false /*Serializable is not a class*/) != null) {
2410 				return; // do not report field hiding for serialVersionUID field for class that implements Serializable
2411 			}
2412 		}
2413 	}
2414 	if (CharOperation.equals(TypeConstants.SERIALPERSISTENTFIELDS, field.name)
2415 			&& field.isStatic()
2416 			&& field.isPrivate()
2417 			&& field.isFinal()
2418 			&& field.type.dimensions() == 1
2419 			&& CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTSTREAMFIELD, field.type.leafComponentType().readableName())) {
2420 		ReferenceBinding referenceBinding = field.declaringClass;
2421 		if (referenceBinding != null) {
2422 			if (referenceBinding.findSuperTypeOriginatingFrom(TypeIds.T_JavaIoSerializable, false /*Serializable is not a class*/) != null) {
2423 				return; // do not report field hiding for serialPersistenFields field for class that implements Serializable
2424 			}
2425 		}
2426 	}
2427 	boolean isLocal = hiddenVariable instanceof LocalVariableBinding;
2428 	int severity = computeSeverity(isLocal ? IProblem.FieldHidingLocalVariable : IProblem.FieldHidingField);
2429 	if (severity == ProblemSeverities.Ignore) return;
2430 	if (isLocal) {
2431 		this.handle(
2432 			IProblem.FieldHidingLocalVariable,
2433 			new String[] {new String(field.declaringClass.readableName()), new String(field.name) },
2434 			new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name) },
2435 			severity,
2436 			nodeSourceStart(hiddenVariable, fieldDecl),
2437 			nodeSourceEnd(hiddenVariable, fieldDecl));
2438 	} else if (hiddenVariable instanceof FieldBinding) {
2439 		FieldBinding hiddenField = (FieldBinding) hiddenVariable;
2440 		this.handle(
2441 			IProblem.FieldHidingField,
2442 			new String[] {new String(field.declaringClass.readableName()), new String(field.name) , new String(hiddenField.declaringClass.readableName())  },
2443 			new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name) , new String(hiddenField.declaringClass.shortReadableName()) },
2444 			severity,
2445 			nodeSourceStart(hiddenField, fieldDecl),
2446 			nodeSourceEnd(hiddenField, fieldDecl));
2447 	}
2448 }
fieldsOrThisBeforeConstructorInvocation(ASTNode reference)2449 public void fieldsOrThisBeforeConstructorInvocation(ASTNode reference) {
2450 	this.handle(
2451 		IProblem.ThisSuperDuringConstructorInvocation,
2452 		NoArgument,
2453 		NoArgument,
2454 		reference.sourceStart,
2455 		reference instanceof LambdaExpression ? ((LambdaExpression) reference).diagnosticsSourceEnd() : reference.sourceEnd);
2456 }
finallyMustCompleteNormally(Block finallyBlock)2457 public void finallyMustCompleteNormally(Block finallyBlock) {
2458 	this.handle(
2459 		IProblem.FinallyMustCompleteNormally,
2460 		NoArgument,
2461 		NoArgument,
2462 		finallyBlock.sourceStart,
2463 		finallyBlock.sourceEnd);
2464 }
finalMethodCannotBeOverridden(MethodBinding currentMethod, MethodBinding inheritedMethod)2465 public void finalMethodCannotBeOverridden(MethodBinding currentMethod, MethodBinding inheritedMethod) {
2466 	this.handle(
2467 		// Cannot override the final method from %1
2468 		// 8.4.3.3 - Final methods cannot be overridden or hidden.
2469 		IProblem.FinalMethodCannotBeOverridden,
2470 		new String[] {new String(inheritedMethod.declaringClass.readableName())},
2471 		new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
2472 		currentMethod.sourceStart(),
2473 		currentMethod.sourceEnd());
2474 }
finalVariableBound(TypeVariableBinding typeVariable, TypeReference typeRef)2475 public void finalVariableBound(TypeVariableBinding typeVariable, TypeReference typeRef) {
2476 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return;
2477 	int severity = computeSeverity(IProblem.FinalBoundForTypeVariable);
2478 	if (severity == ProblemSeverities.Ignore) return;
2479 	this.handle(
2480 		IProblem.FinalBoundForTypeVariable,
2481 		new String[] { new String(typeVariable.sourceName()), new String(typeRef.resolvedType.readableName())},
2482 		new String[] { new String(typeVariable.sourceName()), new String(typeRef.resolvedType.shortReadableName())},
2483 		severity,
2484 		typeRef.sourceStart,
2485 		typeRef.sourceEnd);
2486 }
2487 /** @param classpathEntryType one of {@link AccessRestriction#COMMAND_LINE},
2488  * {@link AccessRestriction#LIBRARY}, {@link AccessRestriction#PROJECT} */
forbiddenReference(FieldBinding field, ASTNode location, byte classpathEntryType, String classpathEntryName, int problemId)2489 public void forbiddenReference(FieldBinding field, ASTNode location,
2490 		 byte classpathEntryType, String classpathEntryName, int problemId) {
2491 	int severity = computeSeverity(problemId);
2492 	if (severity == ProblemSeverities.Ignore) return;
2493 	this.handle(
2494 		problemId,
2495 		new String[] { new String(field.readableName()) }, // distinct from msg arg for quickfix purpose
2496 		getElaborationId(IProblem.ForbiddenReference, (byte) (FIELD_ACCESS | classpathEntryType)),
2497 		new String[] {
2498 			classpathEntryName,
2499 			new String(field.shortReadableName()),
2500 	        new String(field.declaringClass.shortReadableName())},
2501 	    severity,
2502 		nodeSourceStart(field, location),
2503 		nodeSourceEnd(field, location));
2504 }
2505 /** @param classpathEntryType one of {@link AccessRestriction#COMMAND_LINE},
2506  * {@link AccessRestriction#LIBRARY}, {@link AccessRestriction#PROJECT} */
forbiddenReference(MethodBinding method, InvocationSite location, byte classpathEntryType, String classpathEntryName, int problemId)2507 public void forbiddenReference(MethodBinding method, InvocationSite location,
2508 		byte classpathEntryType, String classpathEntryName, int problemId) {
2509 	int severity = computeSeverity(problemId);
2510 	if (severity == ProblemSeverities.Ignore) return;
2511 	if (method.isConstructor())
2512 		this.handle(
2513 			problemId,
2514 			new String[] { new String(method.readableName()) }, // distinct from msg arg for quickfix purpose
2515 			getElaborationId(IProblem.ForbiddenReference, (byte) (CONSTRUCTOR_ACCESS | classpathEntryType)),
2516 			new String[] {
2517 				classpathEntryName,
2518 				new String(method.shortReadableName())},
2519 			severity,
2520 			location.nameSourceStart(),
2521 			location.nameSourceEnd());
2522 	else
2523 		this.handle(
2524 			problemId,
2525 			new String[] { new String(method.readableName()) }, // distinct from msg arg for quickfix purpose
2526 			getElaborationId(IProblem.ForbiddenReference, (byte) (METHOD_ACCESS | classpathEntryType)),
2527 			new String[] {
2528 				classpathEntryName,
2529 				new String(method.shortReadableName()),
2530 		        new String(method.declaringClass.shortReadableName())},
2531 		    severity,
2532 		    location.nameSourceStart(),
2533 			location.nameSourceEnd());
2534 }
2535 /** @param classpathEntryType one of {@link AccessRestriction#COMMAND_LINE},
2536  * {@link AccessRestriction#LIBRARY}, {@link AccessRestriction#PROJECT} */
forbiddenReference(TypeBinding type, ASTNode location, byte classpathEntryType, String classpathEntryName, int problemId)2537 public void forbiddenReference(TypeBinding type, ASTNode location,
2538 		byte classpathEntryType, String classpathEntryName, int problemId) {
2539 	if (location == null) return;
2540 	int severity = computeSeverity(problemId);
2541 	if (severity == ProblemSeverities.Ignore) return;
2542 	this.handle(
2543 		problemId,
2544 		new String[] { new String(type.readableName()) }, // distinct from msg arg for quickfix purpose
2545 		getElaborationId(IProblem.ForbiddenReference, /* TYPE_ACCESS | */ classpathEntryType), // TYPE_ACCESS values to 0
2546 		new String[] {
2547 			classpathEntryName,
2548 			new String(type.shortReadableName())},
2549 		severity,
2550 		location.sourceStart,
2551 		location.sourceEnd);
2552 }
forwardReference(Reference reference, int indexInQualification, FieldBinding field)2553 public void forwardReference(Reference reference, int indexInQualification, FieldBinding field) {
2554 	this.handle(
2555 		IProblem.ReferenceToForwardField,
2556 		NoArgument,
2557 		NoArgument,
2558 		nodeSourceStart(field, reference, indexInQualification),
2559 		nodeSourceEnd(field, reference, indexInQualification));
2560 }
forwardTypeVariableReference(ASTNode location, TypeVariableBinding type)2561 public void forwardTypeVariableReference(ASTNode location, TypeVariableBinding type) {
2562 	this.handle(
2563 		IProblem.ReferenceToForwardTypeVariable,
2564 		new String[] {new String(type.readableName())},
2565 		new String[] {new String(type.shortReadableName())},
2566 		location.sourceStart,
2567 		location.sourceEnd);
2568 }
genericTypeCannotExtendThrowable(TypeDeclaration typeDecl)2569 public void genericTypeCannotExtendThrowable(TypeDeclaration typeDecl) {
2570 	ASTNode location = typeDecl.binding.isAnonymousType() ? typeDecl.allocation.type : typeDecl.superclass;
2571 	this.handle(
2572 		IProblem.GenericTypeCannotExtendThrowable,
2573 		new String[]{ new String(typeDecl.binding.readableName()) },
2574 		new String[]{ new String(typeDecl.binding.shortReadableName()) },
2575 		location.sourceStart,
2576 		location.sourceEnd);
2577 }
2578 // use this private API when the compilation unit result can be found through the
2579 // reference context. Otherwise, use the other API taking a problem and a compilation result
2580 // as arguments
handle( int problemId, String[] problemArguments, int elaborationId, String[] messageArguments, int severity, int problemStartPosition, int problemEndPosition)2581 private void handle(
2582 		int problemId,
2583 		String[] problemArguments,
2584 		int elaborationId,
2585 		String[] messageArguments,
2586 		int severity,
2587 		int problemStartPosition,
2588 		int problemEndPosition){
2589 	this.handle(
2590 			problemId,
2591 			problemArguments,
2592 			elaborationId,
2593 			messageArguments,
2594 			severity,
2595 			problemStartPosition,
2596 			problemEndPosition,
2597 			this.referenceContext,
2598 			this.referenceContext == null ? null : this.referenceContext.compilationResult());
2599 	this.referenceContext = null;
2600 }
2601 // use this private API when the compilation unit result can be found through the
2602 // reference context. Otherwise, use the other API taking a problem and a compilation result
2603 // as arguments
handle( int problemId, String[] problemArguments, String[] messageArguments, int problemStartPosition, int problemEndPosition)2604 private void handle(
2605 	int problemId,
2606 	String[] problemArguments,
2607 	String[] messageArguments,
2608 	int problemStartPosition,
2609 	int problemEndPosition){
2610 
2611 	this.handle(
2612 			problemId,
2613 			problemArguments,
2614 			messageArguments,
2615 			problemStartPosition,
2616 			problemEndPosition,
2617 			this.referenceContext,
2618 			this.referenceContext == null ? null : this.referenceContext.compilationResult());
2619 	this.referenceContext = null;
2620 }
2621 // use this private API when the compilation unit result cannot be found through the
2622 // reference context.
handle( int problemId, String[] problemArguments, String[] messageArguments, int problemStartPosition, int problemEndPosition, CompilationResult unitResult)2623 private void handle(
2624 	int problemId,
2625 	String[] problemArguments,
2626 	String[] messageArguments,
2627 	int problemStartPosition,
2628 	int problemEndPosition,
2629 	CompilationResult unitResult){
2630 
2631 	this.handle(
2632 			problemId,
2633 			problemArguments,
2634 			messageArguments,
2635 			problemStartPosition,
2636 			problemEndPosition,
2637 			this.referenceContext,
2638 			unitResult);
2639 	this.referenceContext = null;
2640 }
2641 // use this private API when the compilation unit result can be found through the
2642 // reference context. Otherwise, use the other API taking a problem and a compilation result
2643 // as arguments
handle( int problemId, String[] problemArguments, String[] messageArguments, int severity, int problemStartPosition, int problemEndPosition)2644 private void handle(
2645 	int problemId,
2646 	String[] problemArguments,
2647 	String[] messageArguments,
2648 	int severity,
2649 	int problemStartPosition,
2650 	int problemEndPosition){
2651 
2652 	this.handle(
2653 			problemId,
2654 			problemArguments,
2655 			0, // no elaboration
2656 			messageArguments,
2657 			severity,
2658 			problemStartPosition,
2659 			problemEndPosition);
2660 }
2661 
handleUntagged( int problemId, String[] problemArguments, String[] messageArguments, int problemStartPosition, int problemEndPosition)2662 protected void handleUntagged(
2663 			int problemId,
2664 			String[] problemArguments,
2665 			String[] messageArguments,
2666 			int problemStartPosition,
2667 			int problemEndPosition) {
2668 	boolean oldSuppressing = this.suppressTagging;
2669 	this.suppressTagging = true;
2670 	try {
2671 		this.handle(problemId, problemArguments, messageArguments, problemStartPosition, problemEndPosition);
2672 	} finally {
2673 		this.suppressTagging = oldSuppressing;
2674 	}
2675 }
hiddenCatchBlock(ReferenceBinding exceptionType, ASTNode location)2676 public void hiddenCatchBlock(ReferenceBinding exceptionType, ASTNode location) {
2677 	this.handle(
2678 		IProblem.MaskedCatch,
2679 		new String[] {
2680 			new String(exceptionType.readableName()),
2681 		 },
2682 		new String[] {
2683 			new String(exceptionType.shortReadableName()),
2684 		 },
2685 		location.sourceStart,
2686 		location.sourceEnd);
2687 }
2688 
hierarchyCircularity(SourceTypeBinding sourceType, ReferenceBinding superType, TypeReference reference)2689 public void hierarchyCircularity(SourceTypeBinding sourceType, ReferenceBinding superType, TypeReference reference) {
2690 	int start = 0;
2691 	int end = 0;
2692 
2693 	if (reference == null) {	// can only happen when java.lang.Object is busted
2694 		start = sourceType.sourceStart();
2695 		end = sourceType.sourceEnd();
2696 	} else {
2697 		start = reference.sourceStart;
2698 		end = reference.sourceEnd;
2699 	}
2700 
2701 	if (TypeBinding.equalsEquals(sourceType, superType))
2702 		this.handle(
2703 			IProblem.HierarchyCircularitySelfReference,
2704 			new String[] {new String(sourceType.readableName()) },
2705 			new String[] {new String(sourceType.shortReadableName()) },
2706 			start,
2707 			end);
2708 	else
2709 		this.handle(
2710 			IProblem.HierarchyCircularity,
2711 			new String[] {new String(sourceType.readableName()), new String(superType.readableName())},
2712 			new String[] {new String(sourceType.shortReadableName()), new String(superType.shortReadableName())},
2713 			start,
2714 			end);
2715 }
2716 
hierarchyCircularity(TypeVariableBinding type, ReferenceBinding superType, TypeReference reference)2717 public void hierarchyCircularity(TypeVariableBinding type, ReferenceBinding superType, TypeReference reference) {
2718 	int start = 0;
2719 	int end = 0;
2720 
2721 	start = reference.sourceStart;
2722 	end = reference.sourceEnd;
2723 
2724 	if (TypeBinding.equalsEquals(type, superType))
2725 		this.handle(
2726 			IProblem.HierarchyCircularitySelfReference,
2727 			new String[] {new String(type.readableName()) },
2728 			new String[] {new String(type.shortReadableName()) },
2729 			start,
2730 			end);
2731 	else
2732 		this.handle(
2733 			IProblem.HierarchyCircularity,
2734 			new String[] {new String(type.readableName()), new String(superType.readableName())},
2735 			new String[] {new String(type.shortReadableName()), new String(superType.shortReadableName())},
2736 			start,
2737 			end);
2738 }
2739 
hierarchyHasProblems(SourceTypeBinding type)2740 public void hierarchyHasProblems(SourceTypeBinding type) {
2741 	String[] arguments = new String[] {new String(type.sourceName())};
2742 	this.handle(
2743 		IProblem.HierarchyHasProblems,
2744 		arguments,
2745 		arguments,
2746 		type.sourceStart(),
2747 		type.sourceEnd());
2748 }
illegalAbstractModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl)2749 public void illegalAbstractModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
2750 	String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
2751 	this.handle(
2752 		IProblem.IllegalAbstractModifierCombinationForMethod,
2753 		arguments,
2754 		arguments,
2755 		methodDecl.sourceStart,
2756 		methodDecl.sourceEnd);
2757 }
illegalAbstractModifierCombinationForMethod(AbstractMethodDeclaration methodDecl)2758 public void illegalAbstractModifierCombinationForMethod(AbstractMethodDeclaration methodDecl) {
2759 	String[] arguments = new String[] {new String(methodDecl.selector)};
2760 	this.handle(
2761 		IProblem.IllegalStrictfpForAbstractInterfaceMethod,
2762 		arguments,
2763 		arguments,
2764 		methodDecl.sourceStart,
2765 		methodDecl.sourceEnd);
2766 }
illegalAccessFromTypeVariable(TypeVariableBinding variable, ASTNode location)2767 public void illegalAccessFromTypeVariable(TypeVariableBinding variable, ASTNode location) {
2768 	if ((location.bits & ASTNode.InsideJavadoc)!= 0) {
2769 		javadocInvalidReference(location.sourceStart, location.sourceEnd);
2770 	} else {
2771 		String[] arguments = new String[] { new String(variable.sourceName) };
2772 		this.handle(
2773 				IProblem.IllegalAccessFromTypeVariable,
2774 				arguments,
2775 				arguments,
2776 				location.sourceStart,
2777 				location.sourceEnd);
2778 	}
2779 }
illegalClassLiteralForTypeVariable(TypeVariableBinding variable, ASTNode location)2780 public void illegalClassLiteralForTypeVariable(TypeVariableBinding variable, ASTNode location) {
2781 	String[] arguments = new String[] { new String(variable.sourceName) };
2782 	this.handle(
2783 		IProblem.IllegalClassLiteralForTypeVariable,
2784 		arguments,
2785 		arguments,
2786 		location.sourceStart,
2787 		location.sourceEnd);
2788 }
illegalExtendedDimensions(AnnotationMethodDeclaration annotationTypeMemberDeclaration)2789 public void illegalExtendedDimensions(AnnotationMethodDeclaration annotationTypeMemberDeclaration) {
2790 	this.handle(
2791 		IProblem.IllegalExtendedDimensions,
2792 		NoArgument,
2793 		NoArgument,
2794 		annotationTypeMemberDeclaration.sourceStart,
2795 		annotationTypeMemberDeclaration.sourceEnd);
2796 }
illegalExtendedDimensions(AbstractVariableDeclaration aVarDecl)2797 public void illegalExtendedDimensions(AbstractVariableDeclaration aVarDecl) {
2798 	this.handle(
2799 		IProblem.IllegalExtendedDimensionsForVarArgs,
2800 		NoArgument,
2801 		NoArgument,
2802 		aVarDecl.sourceStart,
2803 		aVarDecl.sourceEnd);
2804 }
illegalGenericArray(TypeBinding leafComponentType, ASTNode location)2805 public void illegalGenericArray(TypeBinding leafComponentType, ASTNode location) {
2806 	this.handle(
2807 		IProblem.IllegalGenericArray,
2808 		new String[]{ new String(leafComponentType.readableName())},
2809 		new String[]{ new String(leafComponentType.shortReadableName())},
2810 		location.sourceStart,
2811 		location.sourceEnd);
2812 }
illegalInstanceOfGenericType(TypeBinding checkedType, ASTNode location)2813 public void illegalInstanceOfGenericType(TypeBinding checkedType, ASTNode location) {
2814 	TypeBinding erasedType = checkedType.leafComponentType().erasure();
2815 	StringBuffer recommendedFormBuffer = new StringBuffer(10);
2816 	if (erasedType instanceof ReferenceBinding) {
2817 		ReferenceBinding referenceBinding = (ReferenceBinding) erasedType;
2818 		recommendedFormBuffer.append(referenceBinding.qualifiedSourceName());
2819 	} else {
2820 		recommendedFormBuffer.append(erasedType.sourceName());
2821 	}
2822 	int count = erasedType.typeVariables().length;
2823 	if (count > 0) {
2824 		recommendedFormBuffer.append('<');
2825 		for (int i = 0; i < count; i++) {
2826 			if (i > 0) {
2827 				recommendedFormBuffer.append(',');
2828 			}
2829 			recommendedFormBuffer.append('?');
2830 		}
2831 		recommendedFormBuffer.append('>');
2832 	}
2833 	for (int i = 0, dim = checkedType.dimensions(); i < dim; i++) {
2834 		recommendedFormBuffer.append("[]"); //$NON-NLS-1$
2835 	}
2836 	String recommendedForm = recommendedFormBuffer.toString();
2837 	if (checkedType.leafComponentType().isTypeVariable()) {
2838 		this.handle(
2839 			IProblem.IllegalInstanceofTypeParameter,
2840 			new String[] { new String(checkedType.readableName()), recommendedForm, },
2841 			new String[] { new String(checkedType.shortReadableName()), recommendedForm, },
2842 				location.sourceStart,
2843 				location.sourceEnd);
2844 		return;
2845 	}
2846 	this.handle(
2847 		IProblem.IllegalInstanceofParameterizedType,
2848 		new String[] { new String(checkedType.readableName()), recommendedForm, },
2849 		new String[] { new String(checkedType.shortReadableName()), recommendedForm, },
2850 		location.sourceStart,
2851 		location.sourceEnd);
2852 }
illegalLocalTypeDeclaration(TypeDeclaration typeDeclaration)2853 public void illegalLocalTypeDeclaration(TypeDeclaration typeDeclaration) {
2854 	if (isRecoveredName(typeDeclaration.name)) return;
2855 
2856 	int problemID = 0;
2857 	if ((typeDeclaration.modifiers & ClassFileConstants.AccEnum) != 0) {
2858 		problemID = IProblem.CannotDefineEnumInLocalType;
2859 	} else if ((typeDeclaration.modifiers & ClassFileConstants.AccAnnotation) != 0) {
2860 		problemID = IProblem.CannotDefineAnnotationInLocalType;
2861 	} else if ((typeDeclaration.modifiers & ClassFileConstants.AccInterface) != 0) {
2862 		problemID = IProblem.CannotDefineInterfaceInLocalType;
2863 	} else if (typeDeclaration.isRecord()) {
2864 		problemID = IProblem.RecordCannotDefineRecordInLocalType;
2865 	}
2866 	if (problemID != 0) {
2867 		String[] arguments = new String[] {new String(typeDeclaration.name)};
2868 		this.handle(
2869 			problemID,
2870 			arguments,
2871 			arguments,
2872 			typeDeclaration.sourceStart,
2873 			typeDeclaration.sourceEnd);
2874 	}
2875 }
illegalModifierCombinationFinalAbstractForClass(SourceTypeBinding type)2876 public void illegalModifierCombinationFinalAbstractForClass(SourceTypeBinding type) {
2877 	String[] arguments = new String[] {new String(type.sourceName())};
2878 	this.handle(
2879 		IProblem.IllegalModifierCombinationFinalAbstractForClass,
2880 		arguments,
2881 		arguments,
2882 		type.sourceStart(),
2883 		type.sourceEnd());
2884 }
illegalModifierCombinationFinalVolatileForField(ReferenceBinding type, FieldDeclaration fieldDecl)2885 public void illegalModifierCombinationFinalVolatileForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
2886 	String[] arguments = new String[] {new String(fieldDecl.name)};
2887 
2888 	this.handle(
2889 		IProblem.IllegalModifierCombinationFinalVolatileForField,
2890 		arguments,
2891 		arguments,
2892 		fieldDecl.sourceStart,
2893 		fieldDecl.sourceEnd);
2894 }
illegalModifierCombinationForInterfaceMethod(AbstractMethodDeclaration methodDecl)2895 public void illegalModifierCombinationForInterfaceMethod(AbstractMethodDeclaration methodDecl) {
2896 	String[] arguments = new String[] {new String(methodDecl.selector)};
2897 	this.handle(
2898 		IProblem.IllegalModifierCombinationForInterfaceMethod,
2899 		arguments,
2900 		arguments,
2901 		methodDecl.sourceStart,
2902 		methodDecl.sourceEnd);
2903 }
illegalModifierCombinationForPrivateInterfaceMethod(AbstractMethodDeclaration methodDecl)2904 public void illegalModifierCombinationForPrivateInterfaceMethod(AbstractMethodDeclaration methodDecl) {
2905 	String[] arguments = new String[] {new String(methodDecl.selector)};
2906 	this.handle(
2907 		IProblem.IllegalModifierCombinationForPrivateInterfaceMethod9,
2908 		arguments,
2909 		arguments,
2910 		methodDecl.sourceStart,
2911 		methodDecl.sourceEnd);
2912 }
2913 
illegalModifierForAnnotationField(FieldDeclaration fieldDecl)2914 public void illegalModifierForAnnotationField(FieldDeclaration fieldDecl) {
2915 	String name = new String(fieldDecl.name);
2916 	this.handle(
2917 		IProblem.IllegalModifierForAnnotationField,
2918 		new String[] {
2919 			new String(fieldDecl.binding.declaringClass.readableName()),
2920 			name,
2921 		},
2922 		new String[] {
2923 			new String(fieldDecl.binding.declaringClass.shortReadableName()),
2924 			name,
2925 		},
2926 		fieldDecl.sourceStart,
2927 		fieldDecl.sourceEnd);
2928 }
illegalModifierForAnnotationMember(AbstractMethodDeclaration methodDecl)2929 public void illegalModifierForAnnotationMember(AbstractMethodDeclaration methodDecl) {
2930 	this.handle(
2931 		IProblem.IllegalModifierForAnnotationMethod,
2932 		new String[] {
2933 			new String(methodDecl.binding.declaringClass.readableName()),
2934 			new String(methodDecl.selector),
2935 		},
2936 		new String[] {
2937 			new String(methodDecl.binding.declaringClass.shortReadableName()),
2938 			new String(methodDecl.selector),
2939 		},
2940 		methodDecl.sourceStart,
2941 		methodDecl.sourceEnd);
2942 }
illegalModifierForAnnotationMemberType(SourceTypeBinding type)2943 public void illegalModifierForAnnotationMemberType(SourceTypeBinding type) {
2944 	String[] arguments = new String[] {new String(type.sourceName())};
2945 	this.handle(
2946 		IProblem.IllegalModifierForAnnotationMemberType,
2947 		arguments,
2948 		arguments,
2949 		type.sourceStart(),
2950 		type.sourceEnd());
2951 }
illegalModifierForAnnotationType(SourceTypeBinding type)2952 public void illegalModifierForAnnotationType(SourceTypeBinding type) {
2953 	String[] arguments = new String[] {new String(type.sourceName())};
2954 	this.handle(
2955 		IProblem.IllegalModifierForAnnotationType,
2956 		arguments,
2957 		arguments,
2958 		type.sourceStart(),
2959 		type.sourceEnd());
2960 }
illegalModifierForClass(SourceTypeBinding type)2961 public void illegalModifierForClass(SourceTypeBinding type) {
2962 	String[] arguments = new String[] {new String(type.sourceName())};
2963 	this.handle(
2964 		IProblem.IllegalModifierForClass,
2965 		arguments,
2966 		arguments,
2967 		type.sourceStart(),
2968 		type.sourceEnd());
2969 }
illegalModifierForModule(ModuleDeclaration module)2970 public void illegalModifierForModule(ModuleDeclaration module) {
2971 	String[] arguments = new String[] {new String(module.moduleName)};
2972 	this.handle(
2973 		IProblem.IllegalModifierForModule,
2974 		arguments,
2975 		arguments,
2976 		module.sourceStart(),
2977 		module.sourceEnd());
2978 }
illegalModifierForEnum(SourceTypeBinding type)2979 public void illegalModifierForEnum(SourceTypeBinding type) {
2980 	String[] arguments = new String[] {new String(type.sourceName())};
2981 	this.handle(
2982 		IProblem.IllegalModifierForEnum,
2983 		arguments,
2984 		arguments,
2985 		type.sourceStart(),
2986 		type.sourceEnd());
2987 }
illegalModifierForEnumConstant(ReferenceBinding type, FieldDeclaration fieldDecl)2988 public void illegalModifierForEnumConstant(ReferenceBinding type, FieldDeclaration fieldDecl) {
2989 	String[] arguments = new String[] {new String(fieldDecl.name)};
2990 	this.handle(
2991 		IProblem.IllegalModifierForEnumConstant,
2992 		arguments,
2993 		arguments,
2994 		fieldDecl.sourceStart,
2995 		fieldDecl.sourceEnd);
2996 }
2997 
illegalModifierForEnumConstructor(AbstractMethodDeclaration constructor)2998 public void illegalModifierForEnumConstructor(AbstractMethodDeclaration constructor) {
2999 	this.handle(
3000 		IProblem.IllegalModifierForEnumConstructor,
3001 		NoArgument,
3002 		NoArgument,
3003 		constructor.sourceStart,
3004 		constructor.sourceEnd);
3005 }
illegalModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl)3006 public void illegalModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
3007 	String[] arguments = new String[] {new String(fieldDecl.name)};
3008 	this.handle(
3009 		IProblem.IllegalModifierForField,
3010 		arguments,
3011 		arguments,
3012 		fieldDecl.sourceStart,
3013 		fieldDecl.sourceEnd);
3014 }
illegalModifierForInterface(SourceTypeBinding type)3015 public void illegalModifierForInterface(SourceTypeBinding type) {
3016 	String[] arguments = new String[] {new String(type.sourceName())};
3017 	this.handle(
3018 		IProblem.IllegalModifierForInterface,
3019 		arguments,
3020 		arguments,
3021 		type.sourceStart(),
3022 		type.sourceEnd());
3023 }
3024 
illegalModifierForInterfaceField(FieldDeclaration fieldDecl)3025 public void illegalModifierForInterfaceField(FieldDeclaration fieldDecl) {
3026 	String name = new String(fieldDecl.name);
3027 	this.handle(
3028 		IProblem.IllegalModifierForInterfaceField,
3029 		new String[] {
3030 			new String(fieldDecl.binding.declaringClass.readableName()),
3031 			name,
3032 		},
3033 		new String[] {
3034 			new String(fieldDecl.binding.declaringClass.shortReadableName()),
3035 			name,
3036 		},
3037 		fieldDecl.sourceStart,
3038 		fieldDecl.sourceEnd);
3039 }
illegalModifierForInterfaceMethod(AbstractMethodDeclaration methodDecl, long level)3040 public void illegalModifierForInterfaceMethod(AbstractMethodDeclaration methodDecl, long  level) {
3041 
3042 	int problem = level < ClassFileConstants.JDK1_8 ? IProblem.IllegalModifierForInterfaceMethod :
3043 		level < ClassFileConstants.JDK9 ? IProblem.IllegalModifierForInterfaceMethod18 : IProblem.IllegalModifierForInterfaceMethod9;
3044 	// cannot include parameter types since they are not resolved yet
3045 	// and the error message would be too long
3046 	this.handle(
3047 		problem,
3048 		new String[] {
3049 			new String(methodDecl.selector)
3050 		},
3051 		new String[] {
3052 			new String(methodDecl.selector)
3053 		},
3054 		methodDecl.sourceStart,
3055 		methodDecl.sourceEnd);
3056 }
3057 public void illegalModifierForLocalClass(SourceTypeBinding type) {
3058 	String[] arguments = new String[] {new String(type.sourceName())};
3059 	this.handle(
3060 		IProblem.IllegalModifierForLocalClass,
3061 		arguments,
3062 		arguments,
3063 		type.sourceStart(),
3064 		type.sourceEnd());
3065 }
3066 public void illegalModifierForMemberClass(SourceTypeBinding type) {
3067 	String[] arguments = new String[] {new String(type.sourceName())};
3068 	this.handle(
3069 		IProblem.IllegalModifierForMemberClass,
3070 		arguments,
3071 		arguments,
3072 		type.sourceStart(),
3073 		type.sourceEnd());
3074 }
3075 public void illegalModifierForMemberEnum(SourceTypeBinding type) {
3076 	String[] arguments = new String[] {new String(type.sourceName())};
3077 	this.handle(
3078 		IProblem.IllegalModifierForMemberEnum,
3079 		arguments,
3080 		arguments,
3081 		type.sourceStart(),
3082 		type.sourceEnd());
3083 }
3084 public void illegalModifierForMemberInterface(SourceTypeBinding type) {
3085 	String[] arguments = new String[] {new String(type.sourceName())};
3086 	this.handle(
3087 		IProblem.IllegalModifierForMemberInterface,
3088 		arguments,
3089 		arguments,
3090 		type.sourceStart(),
3091 		type.sourceEnd());
3092 }
3093 public void illegalModifierForMethod(AbstractMethodDeclaration methodDecl) {
3094 	// cannot include parameter types since they are not resolved yet
3095 	// and the error message would be too long
3096 	this.handle(
3097 		methodDecl.isConstructor() ? IProblem.IllegalModifierForConstructor : IProblem.IllegalModifierForMethod,
3098 		new String[] {
3099 			new String(methodDecl.selector)
3100 		},
3101 		new String[] {
3102 			new String(methodDecl.selector)
3103 		},
3104 		methodDecl.sourceStart,
3105 		methodDecl.sourceEnd);
3106 }
3107 public void illegalModifierForVariable(LocalDeclaration localDecl, boolean complainAsArgument) {
3108 	String[] arguments = new String[] {new String(localDecl.name)};
3109 	this.handle(
3110 		complainAsArgument
3111 			? IProblem.IllegalModifierForArgument
3112 			: IProblem.IllegalModifierForVariable,
3113 		arguments,
3114 		arguments,
3115 		localDecl.sourceStart,
3116 		localDecl.sourceEnd);
3117 }
3118 public void illegalPrimitiveOrArrayTypeForEnclosingInstance(TypeBinding enclosingType, ASTNode location) {
3119 	this.handle(
3120 		IProblem.IllegalPrimitiveOrArrayTypeForEnclosingInstance,
3121 		new String[] {new String(enclosingType.readableName())},
3122 		new String[] {new String(enclosingType.shortReadableName())},
3123 		location.sourceStart,
3124 		location.sourceEnd);
3125 }
3126 public void illegalQualifiedParameterizedTypeAllocation(TypeReference qualifiedTypeReference, TypeBinding allocatedType) {
3127 	this.handle(
3128 		IProblem.IllegalQualifiedParameterizedTypeAllocation,
3129 		new String[] { new String(allocatedType.readableName()), new String(allocatedType.enclosingType().readableName()), },
3130 		new String[] { new String(allocatedType.shortReadableName()), new String(allocatedType.enclosingType().shortReadableName()), },
3131 		qualifiedTypeReference.sourceStart,
3132 		qualifiedTypeReference.sourceEnd);
3133 }
3134 public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
3135 	String[] arguments = new String[] {new String(type.sourceName())};
3136 	this.handle(
3137 		IProblem.IllegalStaticModifierForMemberType,
3138 		arguments,
3139 		arguments,
3140 		type.sourceStart(),
3141 		type.sourceEnd());
3142 }
3143 public void illegalUsageOfQualifiedTypeReference(QualifiedTypeReference qualifiedTypeReference) {
3144 	StringBuffer buffer = new StringBuffer();
3145 	char[][] tokens = qualifiedTypeReference.tokens;
3146 	for (int i = 0; i < tokens.length; i++) {
3147 		if (i > 0) buffer.append('.');
3148 		buffer.append(tokens[i]);
3149 	}
3150 	String[] arguments = new String[] { String.valueOf(buffer)};
3151 	this.handle(
3152 		IProblem.IllegalUsageOfQualifiedTypeReference,
3153 		arguments,
3154 		arguments,
3155 		qualifiedTypeReference.sourceStart,
3156 		qualifiedTypeReference.sourceEnd);
3157 }
3158 public void illegalUsageOfWildcard(TypeReference wildcard) {
3159 	this.handle(
3160 		IProblem.InvalidUsageOfWildcard,
3161 		NoArgument,
3162 		NoArgument,
3163 		wildcard.sourceStart,
3164 		wildcard.sourceEnd);
3165 }
3166 public void illegalVararg(Argument argType, AbstractMethodDeclaration methodDecl) {
3167 	String[] arguments = new String[] {CharOperation.toString(argType.type.getTypeName()), new String(methodDecl.selector)};
3168 	this.handle(
3169 		IProblem.IllegalVararg,
3170 		arguments,
3171 		arguments,
3172 		argType.sourceStart,
3173 		argType.sourceEnd);
3174 }
3175 public void illegalVarargInLambda(Argument argType) {
3176 	String[] arguments = new String[] { CharOperation.toString(argType.type.getTypeName())};
3177 	this.handle(
3178 		IProblem.IllegalVarargInLambda,
3179 		arguments,
3180 		arguments,
3181 		argType.sourceStart,
3182 		argType.sourceEnd);
3183 }
3184 public void illegalThisDeclaration(Argument argument) {
3185 	String[] arguments = NoArgument;
3186 	this.handle(
3187 		IProblem.IllegalDeclarationOfThisParameter,
3188 		arguments,
3189 		arguments,
3190 		argument.sourceStart,
3191 		argument.sourceEnd);
3192 }
3193 public void illegalSourceLevelForThis(Argument argument) {
3194 	String[] arguments = NoArgument;
3195 	this.handle(
3196 		IProblem.ExplicitThisParameterNotBelow18,
3197 		arguments,
3198 		arguments,
3199 		argument.sourceStart,
3200 		argument.sourceEnd);
3201 }
3202 public void disallowedThisParameter(Receiver receiver) {
3203 	String[] arguments = NoArgument;
3204 	this.handle(
3205 		IProblem.DisallowedExplicitThisParameter,
3206 		arguments,
3207 		arguments,
3208 		receiver.sourceStart,
3209 		receiver.sourceEnd);
3210 }
3211 public void illegalQualifierForExplicitThis(Receiver receiver, TypeBinding expectedType) {
3212 	String[] problemArguments = new String[] { new String(expectedType.sourceName())};
3213 	this.handle(
3214 		IProblem.IllegalQualifierForExplicitThis,
3215 		problemArguments,
3216 		problemArguments,
3217 		(receiver.qualifyingName == null) ? receiver.sourceStart : receiver.qualifyingName.sourceStart,
3218 		receiver.sourceEnd);
3219 }
3220 public void illegalQualifierForExplicitThis2(Receiver receiver) {
3221 	this.handle(
3222 		IProblem.IllegalQualifierForExplicitThis2,
3223 		NoArgument,
3224 		NoArgument,
3225 		receiver.qualifyingName.sourceStart,
3226 		receiver.sourceEnd);
3227 }
3228 public void illegalTypeForExplicitThis(Receiver receiver, TypeBinding expectedType) {
3229 	this.handle(
3230 		IProblem.IllegalTypeForExplicitThis,
3231 		new String[] { new String(expectedType.readableName())},
3232 		new String[] { new String(expectedType.shortReadableName())},
3233 		receiver.type.sourceStart,
3234 		receiver.type.sourceEnd);
3235 }
3236 public void illegalThis(Argument argument) {
3237 	String[] arguments = NoArgument;
3238 	this.handle(
3239 		IProblem.ExplicitThisParameterNotInLambda,
3240 		arguments,
3241 		arguments,
3242 		argument.sourceStart,
3243 		argument.sourceEnd);
3244 }
3245 public void defaultMethodsNotBelow18(MethodDeclaration md) {
3246 	this.handle(
3247 			IProblem.DefaultMethodNotBelow18,
3248 			NoArgument,
3249 			NoArgument,
3250 			md.sourceStart,
3251 			md.sourceEnd);
3252 }
3253 public void interfaceSuperInvocationNotBelow18(QualifiedSuperReference qualifiedSuperReference) {
3254 	this.handle(
3255 			IProblem.InterfaceSuperInvocationNotBelow18,
3256 			NoArgument,
3257 			NoArgument,
3258 			qualifiedSuperReference.sourceStart,
3259 			qualifiedSuperReference.sourceEnd);
3260 }
3261 public void staticInterfaceMethodsNotBelow18(MethodDeclaration md) {
3262 	this.handle(
3263 			IProblem.StaticInterfaceMethodNotBelow18,
3264 			NoArgument,
3265 			NoArgument,
3266 			md.sourceStart,
3267 			md.sourceEnd);
3268 }
3269 public void referenceExpressionsNotBelow18(ReferenceExpression rexp) {
3270 	this.handle(
3271 			rexp.isMethodReference() ? IProblem.MethodReferenceNotBelow18 : IProblem.ConstructorReferenceNotBelow18,
3272 			NoArgument,
3273 			NoArgument,
3274 			rexp.sourceStart,
3275 			rexp.sourceEnd);
3276 }
3277 public void lambdaExpressionsNotBelow18(LambdaExpression lexp) {
3278 	this.handle(
3279 			IProblem.LambdaExpressionNotBelow18,
3280 			NoArgument,
3281 			NoArgument,
3282 			lexp.sourceStart,
3283 			lexp.diagnosticsSourceEnd());
3284 }
3285 public void illegalVisibilityModifierCombinationForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
3286 	String[] arguments = new String[] {new String(fieldDecl.name)};
3287 	this.handle(
3288 		IProblem.IllegalVisibilityModifierCombinationForField,
3289 		arguments,
3290 		arguments,
3291 		fieldDecl.sourceStart,
3292 		fieldDecl.sourceEnd);
3293 }
3294 public void illegalVisibilityModifierCombinationForMemberType(SourceTypeBinding type) {
3295 	String[] arguments = new String[] {new String(type.sourceName())};
3296 	this.handle(
3297 		IProblem.IllegalVisibilityModifierCombinationForMemberType,
3298 		arguments,
3299 		arguments,
3300 		type.sourceStart(),
3301 		type.sourceEnd());
3302 }
3303 public void illegalVisibilityModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
3304 	String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
3305 	this.handle(
3306 		IProblem.IllegalVisibilityModifierCombinationForMethod,
3307 		arguments,
3308 		arguments,
3309 		methodDecl.sourceStart,
3310 		methodDecl.sourceEnd);
3311 }
3312 public void illegalVisibilityModifierForInterfaceMemberType(SourceTypeBinding type) {
3313 	String[] arguments = new String[] {new String(type.sourceName())};
3314 	this.handle(
3315 		IProblem.IllegalVisibilityModifierForInterfaceMemberType,
3316 		arguments,
3317 		arguments,
3318 		type.sourceStart(),
3319 		type.sourceEnd());
3320 }
3321 public void illegalVoidExpression(ASTNode location) {
3322 	this.handle(
3323 		IProblem.InvalidVoidExpression,
3324 		NoArgument,
3325 		NoArgument,
3326 		location.sourceStart,
3327 		location.sourceEnd);
3328 }
3329 public void importProblem(ImportReference importRef, Binding expectedImport) {
3330 	if (expectedImport instanceof FieldBinding) {
3331 		int id = IProblem.UndefinedField;
3332 		FieldBinding field = (FieldBinding) expectedImport;
3333 		String[] readableArguments = null;
3334 		String[] shortArguments = null;
3335 		switch (expectedImport.problemId()) {
3336 			case ProblemReasons.NotVisible :
3337 			case ProblemReasons.NotAccessible :
3338 				id = (expectedImport.problemId() == ProblemReasons.NotVisible) ? IProblem.NotVisibleField : IProblem.NotAccessibleField;
3339 				readableArguments = new String[] {CharOperation.toString(importRef.tokens), new String(field.declaringClass.readableName())};
3340 				shortArguments = new String[] {CharOperation.toString(importRef.tokens), new String(field.declaringClass.shortReadableName())};
3341 				break;
3342 			case ProblemReasons.Ambiguous :
3343 				id = IProblem.AmbiguousField;
3344 				readableArguments = new String[] {new String(field.readableName())};
3345 				shortArguments = new String[] {new String(field.readableName())};
3346 				break;
3347 			case ProblemReasons.ReceiverTypeNotVisible :
3348 				id = IProblem.NotVisibleType;
3349 				readableArguments = new String[] {new String(field.declaringClass.leafComponentType().readableName())};
3350 				shortArguments = new String[] {new String(field.declaringClass.leafComponentType().shortReadableName())};
3351 				break;
3352 		}
3353 		this.handleUntagged(
3354 			id,
3355 			readableArguments,
3356 			shortArguments,
3357 			nodeSourceStart(field, importRef),
3358 			nodeSourceEnd(field, importRef));
3359 		return;
3360 	}
3361 
3362 	if (expectedImport instanceof PackageBinding && expectedImport.problemId() == ProblemReasons.NotAccessible) {
3363 		char[][] compoundName = ((PackageBinding)expectedImport).compoundName;
3364 		String[] arguments = new String[] {CharOperation.toString(compoundName)};
3365 		this.handleUntagged(
3366 		        IProblem.NotAccessiblePackage,
3367 		        arguments,
3368 		        arguments,
3369 		        importRef.sourceStart,
3370 		        (int) importRef.sourcePositions[compoundName.length - 1]);
3371 		return;
3372 	}
3373 
3374 	if (expectedImport.problemId() == ProblemReasons.NotFound) {
3375 		char[][] tokens = expectedImport instanceof ProblemReferenceBinding
3376 			? ((ProblemReferenceBinding) expectedImport).compoundName
3377 			: importRef.tokens;
3378 		String[] arguments = new String[]{CharOperation.toString(tokens)};
3379 		this.handleUntagged(
3380 		        IProblem.ImportNotFound,
3381 		        arguments,
3382 		        arguments,
3383 		        importRef.sourceStart,
3384 		        (int) importRef.sourcePositions[tokens.length - 1]);
3385 		return;
3386 	}
3387 	if (expectedImport.problemId() == ProblemReasons.InvalidTypeForStaticImport) {
3388 		char[][] tokens = importRef.tokens;
3389 		String[] arguments = new String[]{CharOperation.toString(tokens)};
3390 		this.handleUntagged(
3391 		        IProblem.InvalidTypeForStaticImport,
3392 		        arguments,
3393 		        arguments,
3394 		        importRef.sourceStart,
3395 		        (int) importRef.sourcePositions[tokens.length - 1]);
3396 		return;
3397 	}
3398 	invalidType(importRef, (TypeBinding)expectedImport);
3399 }
3400 public void conflictingPackagesFromModules(SplitPackageBinding splitPackage, ModuleBinding focusModule, int sourceStart, int sourceEnd) {
3401 	String modules = splitPackage.incarnations.stream()
3402 						.filter(focusModule::canAccess)
3403 						.map(p -> String.valueOf(p.enclosingModule.readableName()))
3404 						.sorted()
3405 						.collect(Collectors.joining(", ")); //$NON-NLS-1$
3406 	String[] arguments = new String[] {
3407 						CharOperation.toString(splitPackage.compoundName),
3408 						modules };
3409 	this.handle(
3410 			IProblem.ConflictingPackageFromModules,
3411 			arguments,
3412 			arguments,
3413 			sourceStart,
3414 			sourceEnd);
3415 }
3416 public void conflictingPackagesFromModules(PackageBinding pack, Set<ModuleBinding> modules, int sourceStart, int sourceEnd) {
3417 	String moduleNames = modules.stream()
3418 						.map(p -> String.valueOf(p.name()))
3419 						.sorted()
3420 						.collect(Collectors.joining(", ")); //$NON-NLS-1$
3421 	String[] arguments = new String[] {
3422 						CharOperation.toString(pack.compoundName),
3423 						moduleNames };
3424 	this.handle(
3425 			IProblem.ConflictingPackageFromModules,
3426 			arguments,
3427 			arguments,
3428 			sourceStart,
3429 			sourceEnd);
3430 }
conflictingPackagesFromOtherModules(ImportReference currentPackage, Set<ModuleBinding> declaringModules)3431 public void conflictingPackagesFromOtherModules(ImportReference currentPackage, Set<ModuleBinding> declaringModules) {
3432 		String moduleNames = declaringModules.stream()
3433 								.map(p -> String.valueOf(p.name()))
3434 								.sorted()
3435 								.collect(Collectors.joining(", ")); //$NON-NLS-1$
3436 		String[] arguments = new String[] { CharOperation.toString(currentPackage.tokens), moduleNames };
3437 		this.handle(IProblem.ConflictingPackageFromOtherModules, arguments, arguments, currentPackage.sourceStart, currentPackage.sourceEnd);
3438 }
incompatibleExceptionInThrowsClause(SourceTypeBinding type, MethodBinding currentMethod, MethodBinding inheritedMethod, ReferenceBinding exceptionType)3439 public void incompatibleExceptionInThrowsClause(SourceTypeBinding type, MethodBinding currentMethod, MethodBinding inheritedMethod, ReferenceBinding exceptionType) {
3440 	if (TypeBinding.equalsEquals(type, currentMethod.declaringClass)) {
3441 		int id;
3442 		if (currentMethod.declaringClass.isInterface()
3443 				&& !inheritedMethod.isPublic()){ // interface inheriting Object protected method
3444 			id = IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod;
3445 		} else {
3446 			id = IProblem.IncompatibleExceptionInThrowsClause;
3447 		}
3448 		this.handle(
3449 			// Exception %1 is not compatible with throws clause in %2
3450 			// 9.4.4 - The type of exception in the throws clause is incompatible.
3451 			id,
3452 			new String[] {
3453 				new String(exceptionType.sourceName()),
3454 				new String(
3455 					CharOperation.concat(
3456 						inheritedMethod.declaringClass.readableName(),
3457 						inheritedMethod.readableName(),
3458 						'.'))},
3459 			new String[] {
3460 				new String(exceptionType.sourceName()),
3461 				new String(
3462 					CharOperation.concat(
3463 						inheritedMethod.declaringClass.shortReadableName(),
3464 						inheritedMethod.shortReadableName(),
3465 						'.'))},
3466 			currentMethod.sourceStart(),
3467 			currentMethod.sourceEnd());
3468 	} else
3469 		this.handle(
3470 			// Exception %1 in throws clause of %2 is not compatible with %3
3471 			// 9.4.4 - The type of exception in the throws clause is incompatible.
3472 			IProblem.IncompatibleExceptionInInheritedMethodThrowsClause,
3473 			new String[] {
3474 				new String(exceptionType.sourceName()),
3475 				new String(
3476 					CharOperation.concat(
3477 						currentMethod.declaringClass.sourceName(),
3478 						currentMethod.readableName(),
3479 						'.')),
3480 				new String(
3481 					CharOperation.concat(
3482 						inheritedMethod.declaringClass.readableName(),
3483 						inheritedMethod.readableName(),
3484 						'.'))},
3485 			new String[] {
3486 				new String(exceptionType.sourceName()),
3487 				new String(
3488 					CharOperation.concat(
3489 						currentMethod.declaringClass.sourceName(),
3490 						currentMethod.shortReadableName(),
3491 						'.')),
3492 				new String(
3493 					CharOperation.concat(
3494 						inheritedMethod.declaringClass.shortReadableName(),
3495 						inheritedMethod.shortReadableName(),
3496 						'.'))},
3497 			type.sourceStart(),
3498 			type.sourceEnd());
3499 }
incompatibleReturnType(MethodBinding currentMethod, MethodBinding inheritedMethod)3500 public void incompatibleReturnType(MethodBinding currentMethod, MethodBinding inheritedMethod) {
3501 	StringBuffer methodSignature = new StringBuffer();
3502 	methodSignature
3503 		.append(inheritedMethod.declaringClass.readableName())
3504 		.append('.')
3505 		.append(inheritedMethod.readableName());
3506 
3507 	StringBuffer shortSignature = new StringBuffer();
3508 	shortSignature
3509 		.append(inheritedMethod.declaringClass.shortReadableName())
3510 		.append('.')
3511 		.append(inheritedMethod.shortReadableName());
3512 
3513 	int id;
3514 	final ReferenceBinding declaringClass = currentMethod.declaringClass;
3515 	if (declaringClass.isInterface()
3516 			&& !inheritedMethod.isPublic()){ // interface inheriting Object protected method
3517 		id = IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod;
3518 	} else {
3519 		id = IProblem.IncompatibleReturnType;
3520 	}
3521 	AbstractMethodDeclaration method = currentMethod.sourceMethod();
3522 	int sourceStart = 0;
3523 	int sourceEnd = 0;
3524 	if (method == null) {
3525 		if (declaringClass instanceof SourceTypeBinding) {
3526 			SourceTypeBinding sourceTypeBinding = (SourceTypeBinding) declaringClass;
3527 			sourceStart = sourceTypeBinding.sourceStart();
3528 			sourceEnd = sourceTypeBinding.sourceEnd();
3529 		}
3530 	} else if (method.isConstructor()){
3531 		sourceStart = method.sourceStart;
3532 		sourceEnd = method.sourceEnd;
3533 	} else {
3534 		TypeReference returnType = ((MethodDeclaration) method).returnType;
3535 		sourceStart = returnType.sourceStart;
3536 		if (returnType instanceof ParameterizedSingleTypeReference) {
3537 			ParameterizedSingleTypeReference typeReference = (ParameterizedSingleTypeReference) returnType;
3538 			TypeReference[] typeArguments = typeReference.typeArguments;
3539 			if (typeArguments[typeArguments.length - 1].sourceEnd > typeReference.sourceEnd) {
3540 				sourceEnd = retrieveClosingAngleBracketPosition(typeReference.sourceEnd);
3541 			} else {
3542 				sourceEnd = returnType.sourceEnd;
3543 			}
3544 		} else if (returnType instanceof ParameterizedQualifiedTypeReference) {
3545 			ParameterizedQualifiedTypeReference typeReference = (ParameterizedQualifiedTypeReference) returnType;
3546 			sourceEnd = retrieveClosingAngleBracketPosition(typeReference.sourceEnd);
3547 		} else {
3548 			sourceEnd = returnType.sourceEnd;
3549 		}
3550 	}
3551 	this.handle(
3552 		id,
3553 		new String[] {methodSignature.toString()},
3554 		new String[] {shortSignature.toString()},
3555 		sourceStart,
3556 		sourceEnd);
3557 }
incorrectArityForParameterizedType(ASTNode location, TypeBinding type, TypeBinding[] argumentTypes)3558 public void incorrectArityForParameterizedType(ASTNode location, TypeBinding type, TypeBinding[] argumentTypes) {
3559 	incorrectArityForParameterizedType(location, type, argumentTypes, Integer.MAX_VALUE);
3560 }
incorrectArityForParameterizedType(ASTNode location, TypeBinding type, TypeBinding[] argumentTypes, int index)3561 public void incorrectArityForParameterizedType(ASTNode location, TypeBinding type, TypeBinding[] argumentTypes, int index) {
3562     if (location == null) {
3563 		this.handle(
3564 			IProblem.IncorrectArityForParameterizedType,
3565 			new String[] {new String(type.readableName()), typesAsString(argumentTypes, false)},
3566 			new String[] {new String(type.shortReadableName()), typesAsString(argumentTypes, true)},
3567 			ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
3568 			0,
3569 			0);
3570 		return; // not reached since aborted above
3571     }
3572 	this.handle(
3573 		IProblem.IncorrectArityForParameterizedType,
3574 		new String[] {new String(type.readableName()), typesAsString(argumentTypes, false)},
3575 		new String[] {new String(type.shortReadableName()), typesAsString(argumentTypes, true)},
3576 		location.sourceStart,
3577 		nodeSourceEnd(null, location, index));
3578 }
diamondNotBelow17(ASTNode location)3579 public void diamondNotBelow17(ASTNode location) {
3580 	diamondNotBelow17(location, Integer.MAX_VALUE);
3581 }
diamondNotBelow17(ASTNode location, int index)3582 public void diamondNotBelow17(ASTNode location, int index) {
3583 	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=348493
3584     if (location == null) {
3585 		this.handle(
3586 			IProblem.DiamondNotBelow17,
3587 			NoArgument,
3588 			NoArgument,
3589 			ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
3590 			0,
3591 			0);
3592 		return; // not reached since aborted above
3593     }
3594 	this.handle(
3595 		IProblem.DiamondNotBelow17,
3596 		NoArgument,
3597 		NoArgument,
3598 		location.sourceStart,
3599 		nodeSourceEnd(null, location, index));
3600 }
incorrectLocationForNonEmptyDimension(ArrayAllocationExpression expression, int index)3601 public void incorrectLocationForNonEmptyDimension(ArrayAllocationExpression expression, int index) {
3602 	this.handle(
3603 		IProblem.IllegalDimension,
3604 		NoArgument,
3605 		NoArgument,
3606 		expression.dimensions[index].sourceStart,
3607 		expression.dimensions[index].sourceEnd);
3608 }
incorrectSwitchType(Expression expression, TypeBinding testType)3609 public void incorrectSwitchType(Expression expression, TypeBinding testType) {
3610 	if (this.options.sourceLevel < ClassFileConstants.JDK1_7) {
3611 		if (testType.id == TypeIds.T_JavaLangString) {
3612 			this.handle(
3613 					IProblem.SwitchOnStringsNotBelow17,
3614 					new String[] {new String(testType.readableName())},
3615 					new String[] {new String(testType.shortReadableName())},
3616 					expression.sourceStart,
3617 					expression.sourceEnd);
3618 		} else {
3619 			if (this.options.sourceLevel < ClassFileConstants.JDK1_5 && testType.isEnum()) {
3620 				this.handle(
3621 						IProblem.SwitchOnEnumNotBelow15,
3622 						new String[] {new String(testType.readableName())},
3623 						new String[] {new String(testType.shortReadableName())},
3624 						expression.sourceStart,
3625 						expression.sourceEnd);
3626 			} else {
3627 				this.handle(
3628 						IProblem.IncorrectSwitchType,
3629 						new String[] {new String(testType.readableName())},
3630 						new String[] {new String(testType.shortReadableName())},
3631 						expression.sourceStart,
3632 						expression.sourceEnd);
3633 			}
3634 		}
3635 	} else {
3636 		this.handle(
3637 				IProblem.IncorrectSwitchType17,
3638 				new String[] {new String(testType.readableName())},
3639 				new String[] {new String(testType.shortReadableName())},
3640 				expression.sourceStart,
3641 				expression.sourceEnd);
3642 	}
3643 }
indirectAccessToStaticField(ASTNode location, FieldBinding field)3644 public void indirectAccessToStaticField(ASTNode location, FieldBinding field){
3645 	int severity = computeSeverity(IProblem.IndirectAccessToStaticField);
3646 	if (severity == ProblemSeverities.Ignore) return;
3647 	this.handle(
3648 		IProblem.IndirectAccessToStaticField,
3649 		new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
3650 		new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
3651 		severity,
3652 		nodeSourceStart(field, location),
3653 		nodeSourceEnd(field, location));
3654 }
indirectAccessToStaticMethod(ASTNode location, MethodBinding method)3655 public void indirectAccessToStaticMethod(ASTNode location, MethodBinding method) {
3656 	int severity = computeSeverity(IProblem.IndirectAccessToStaticMethod);
3657 	if (severity == ProblemSeverities.Ignore) return;
3658 	this.handle(
3659 		IProblem.IndirectAccessToStaticMethod,
3660 		new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method, false)},
3661 		new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method, true)},
3662 		severity,
3663 		location.sourceStart,
3664 		location.sourceEnd);
3665 }
inheritedDefaultMethodConflictsWithOtherInherited(SourceTypeBinding type, MethodBinding defaultMethod, MethodBinding otherMethod)3666 public void inheritedDefaultMethodConflictsWithOtherInherited(SourceTypeBinding type, MethodBinding defaultMethod, MethodBinding otherMethod) {
3667 	TypeDeclaration typeDecl = type.scope.referenceContext;
3668 	String[] problemArguments = new String[] {
3669 			String.valueOf(defaultMethod.readableName()),
3670 			String.valueOf(defaultMethod.declaringClass.readableName()),
3671 			String.valueOf(otherMethod.declaringClass.readableName()) };
3672 	String[] messageArguments = new String[] {
3673 			String.valueOf(defaultMethod.shortReadableName()),
3674 			String.valueOf(defaultMethod.declaringClass.shortReadableName()),
3675 			String.valueOf(otherMethod.declaringClass.shortReadableName()) };
3676 	this.handle(IProblem.InheritedDefaultMethodConflictsWithOtherInherited,
3677 			problemArguments,
3678 			messageArguments,
3679 			typeDecl.sourceStart,
3680 			typeDecl.sourceEnd);
3681 }
inheritedMethodReducesVisibility(int sourceStart, int sourceEnd, MethodBinding concreteMethod, MethodBinding[] abstractMethods)3682 private void inheritedMethodReducesVisibility(int sourceStart, int sourceEnd, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
3683 	StringBuffer concreteSignature = new StringBuffer();
3684 	concreteSignature
3685 		.append(concreteMethod.declaringClass.readableName())
3686 		.append('.')
3687 		.append(concreteMethod.readableName());
3688 	StringBuffer shortSignature = new StringBuffer();
3689 	shortSignature
3690 		.append(concreteMethod.declaringClass.shortReadableName())
3691 		.append('.')
3692 		.append(concreteMethod.shortReadableName());
3693 	this.handle(
3694 		// The inherited method %1 cannot hide the public abstract method in %2
3695 		IProblem.InheritedMethodReducesVisibility,
3696 		new String[] {
3697 			concreteSignature.toString(),
3698 			new String(abstractMethods[0].declaringClass.readableName())},
3699 		new String[] {
3700 			shortSignature.toString(),
3701 			new String(abstractMethods[0].declaringClass.shortReadableName())},
3702 		sourceStart,
3703 		sourceEnd);
3704 }
inheritedMethodReducesVisibility(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods)3705 public void inheritedMethodReducesVisibility(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
3706 	inheritedMethodReducesVisibility(type.sourceStart(), type.sourceEnd(), concreteMethod, abstractMethods);
3707 }
inheritedMethodReducesVisibility(TypeParameter typeParameter, MethodBinding concreteMethod, MethodBinding[] abstractMethods)3708 public void inheritedMethodReducesVisibility(TypeParameter typeParameter, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
3709 	inheritedMethodReducesVisibility(typeParameter.sourceStart(), typeParameter.sourceEnd(), concreteMethod, abstractMethods);
3710 }
inheritedMethodsHaveIncompatibleReturnTypes(ASTNode location, MethodBinding[] inheritedMethods, int length)3711 public void inheritedMethodsHaveIncompatibleReturnTypes(ASTNode location, MethodBinding[] inheritedMethods, int length) {
3712 	StringBuffer methodSignatures = new StringBuffer();
3713 	StringBuffer shortSignatures = new StringBuffer();
3714 	for (int i = length; --i >= 0;) {
3715 		methodSignatures
3716 			.append(inheritedMethods[i].declaringClass.readableName())
3717 			.append('.')
3718 			.append(inheritedMethods[i].readableName());
3719 		shortSignatures
3720 			.append(inheritedMethods[i].declaringClass.shortReadableName())
3721 			.append('.')
3722 			.append(inheritedMethods[i].shortReadableName());
3723 		if (i != 0){
3724 			methodSignatures.append(", "); //$NON-NLS-1$
3725 			shortSignatures.append(", "); //$NON-NLS-1$
3726 		}
3727 	}
3728 
3729 	this.handle(
3730 		// Return type is incompatible with %1
3731 		// 9.4.2 - The return type from the method is incompatible with the declaration.
3732 		IProblem.InheritedIncompatibleReturnType,
3733 		new String[] {methodSignatures.toString()},
3734 		new String[] {shortSignatures.toString()},
3735 		location.sourceStart,
3736 		location.sourceEnd);
3737 }
inheritedMethodsHaveIncompatibleReturnTypes(SourceTypeBinding type, MethodBinding[] inheritedMethods, int length, boolean[] isOverridden)3738 public void inheritedMethodsHaveIncompatibleReturnTypes(SourceTypeBinding type, MethodBinding[] inheritedMethods, int length, boolean[] isOverridden) {
3739 	StringBuffer methodSignatures = new StringBuffer();
3740 	StringBuffer shortSignatures = new StringBuffer();
3741 	for (int i = length; --i >= 0;) {
3742 		if (isOverridden[i]) continue;
3743 		methodSignatures
3744 			.append(inheritedMethods[i].declaringClass.readableName())
3745 			.append('.')
3746 			.append(inheritedMethods[i].readableName());
3747 		shortSignatures
3748 			.append(inheritedMethods[i].declaringClass.shortReadableName())
3749 			.append('.')
3750 			.append(inheritedMethods[i].shortReadableName());
3751 		if (i != 0){
3752 			methodSignatures.append(", "); //$NON-NLS-1$
3753 			shortSignatures.append(", "); //$NON-NLS-1$
3754 		}
3755 	}
3756 
3757 	this.handle(
3758 		// Return type is incompatible with %1
3759 		// 9.4.2 - The return type from the method is incompatible with the declaration.
3760 		IProblem.InheritedIncompatibleReturnType,
3761 		new String[] {methodSignatures.toString()},
3762 		new String[] {shortSignatures.toString()},
3763 		type.sourceStart(),
3764 		type.sourceEnd());
3765 }
inheritedMethodsHaveNameClash(SourceTypeBinding type, MethodBinding oneMethod, MethodBinding twoMethod)3766 public void inheritedMethodsHaveNameClash(SourceTypeBinding type, MethodBinding oneMethod, MethodBinding twoMethod) {
3767 	this.handle(
3768 		IProblem.MethodNameClash,
3769 		new String[] {
3770 			new String(oneMethod.selector),
3771 			typesAsString(oneMethod.original(), false),
3772 			new String(oneMethod.declaringClass.readableName()),
3773 			typesAsString(twoMethod.original(), false),
3774 			new String(twoMethod.declaringClass.readableName()),
3775 		 },
3776 		new String[] {
3777 			new String(oneMethod.selector),
3778 			typesAsString(oneMethod.original(), true),
3779 			new String(oneMethod.declaringClass.shortReadableName()),
3780 			typesAsString(twoMethod.original(), true),
3781 			new String(twoMethod.declaringClass.shortReadableName()),
3782 		 },
3783 		 type.sourceStart(),
3784 		 type.sourceEnd());
3785 }
initializerMustCompleteNormally(FieldDeclaration fieldDecl)3786 public void initializerMustCompleteNormally(FieldDeclaration fieldDecl) {
3787 	this.handle(
3788 		IProblem.InitializerMustCompleteNormally,
3789 		NoArgument,
3790 		NoArgument,
3791 		fieldDecl.sourceStart,
3792 		fieldDecl.sourceEnd);
3793 }
innerTypesCannotDeclareStaticInitializers(ReferenceBinding innerType, Initializer initializer)3794 public void innerTypesCannotDeclareStaticInitializers(ReferenceBinding innerType, Initializer initializer) {
3795 	this.handle(
3796 		IProblem.CannotDefineStaticInitializerInLocalType,
3797 		new String[] {new String(innerType.readableName())},
3798 		new String[] {new String(innerType.shortReadableName())},
3799 		initializer.sourceStart,
3800 		initializer.sourceStart);
3801 }
interfaceCannotHaveConstructors(ConstructorDeclaration constructor)3802 public void interfaceCannotHaveConstructors(ConstructorDeclaration constructor) {
3803 	this.handle(
3804 		IProblem.InterfaceCannotHaveConstructors,
3805 		NoArgument,
3806 		NoArgument,
3807 		constructor.sourceStart,
3808 		constructor.sourceEnd,
3809 		constructor,
3810 		constructor.compilationResult());
3811 }
interfaceCannotHaveInitializers(char [] sourceName, FieldDeclaration fieldDecl)3812 public void interfaceCannotHaveInitializers(char [] sourceName, FieldDeclaration fieldDecl) {
3813 	String[] arguments = new String[] {new String(sourceName)};
3814 
3815 	this.handle(
3816 		IProblem.InterfaceCannotHaveInitializers,
3817 		arguments,
3818 		arguments,
3819 		fieldDecl.sourceStart,
3820 		fieldDecl.sourceEnd);
3821 }
invalidAnnotationMemberType(MethodDeclaration methodDecl)3822 public void invalidAnnotationMemberType(MethodDeclaration methodDecl) {
3823 	this.handle(
3824 		IProblem.InvalidAnnotationMemberType,
3825 		new String[] {
3826 			new String(methodDecl.binding.returnType.readableName()),
3827 			new String(methodDecl.selector),
3828 			new String(methodDecl.binding.declaringClass.readableName()),
3829 		},
3830 		new String[] {
3831 			new String(methodDecl.binding.returnType.shortReadableName()),
3832 			new String(methodDecl.selector),
3833 			new String(methodDecl.binding.declaringClass.shortReadableName()),
3834 		},
3835 		methodDecl.returnType.sourceStart,
3836 		methodDecl.returnType.sourceEnd);
3837 
3838 }
invalidBreak(ASTNode location)3839 public void invalidBreak(ASTNode location) {
3840 	this.handle(
3841 		IProblem.InvalidBreak,
3842 		NoArgument,
3843 		NoArgument,
3844 		location.sourceStart,
3845 		location.sourceEnd);
3846 }
invalidConstructor(Statement statement, MethodBinding targetConstructor)3847 public void invalidConstructor(Statement statement, MethodBinding targetConstructor) {
3848 	boolean insideDefaultConstructor =
3849 		(this.referenceContext instanceof ConstructorDeclaration)
3850 			&& ((ConstructorDeclaration)this.referenceContext).isDefaultConstructor();
3851 	boolean insideImplicitConstructorCall =
3852 		(statement instanceof ExplicitConstructorCall)
3853 			&& (((ExplicitConstructorCall) statement).accessMode == ExplicitConstructorCall.ImplicitSuper);
3854 
3855 	int sourceStart = statement.sourceStart;
3856 	int sourceEnd = statement.sourceEnd;
3857 	if (statement instanceof AllocationExpression) {
3858 		AllocationExpression allocation = (AllocationExpression)statement;
3859 		if (allocation.enumConstant != null) {
3860 			sourceStart = allocation.enumConstant.sourceStart;
3861 			sourceEnd = allocation.enumConstant.sourceEnd;
3862 		}
3863 	}
3864 
3865 	int id = IProblem.UndefinedConstructor; //default...
3866     MethodBinding shownConstructor = targetConstructor;
3867 	switch (targetConstructor.problemId()) {
3868 		case ProblemReasons.NotFound :
3869 			ProblemMethodBinding problemConstructor = (ProblemMethodBinding) targetConstructor;
3870 			if (problemConstructor.closestMatch != null) {
3871 		    	if ((problemConstructor.closestMatch.tagBits & TagBits.HasMissingType) != 0) {
3872 					missingTypeInConstructor(statement, problemConstructor.closestMatch);
3873 					return;
3874 		    	}
3875 		    }
3876 
3877 			if (insideDefaultConstructor){
3878 				id = IProblem.UndefinedConstructorInDefaultConstructor;
3879 			} else if (insideImplicitConstructorCall){
3880 				id = IProblem.UndefinedConstructorInImplicitConstructorCall;
3881 			} else {
3882 				id = IProblem.UndefinedConstructor;
3883 			}
3884 			break;
3885 		case ProblemReasons.NotVisible :
3886 			if (insideDefaultConstructor){
3887 				id = IProblem.NotVisibleConstructorInDefaultConstructor;
3888 			} else if (insideImplicitConstructorCall){
3889 				id = IProblem.NotVisibleConstructorInImplicitConstructorCall;
3890 			} else {
3891 				id = IProblem.NotVisibleConstructor;
3892 			}
3893 			problemConstructor = (ProblemMethodBinding) targetConstructor;
3894 			if (problemConstructor.closestMatch != null) {
3895 			    shownConstructor = problemConstructor.closestMatch.original();
3896 		    }
3897 			break;
3898 		case ProblemReasons.NotAccessible :
3899 			id = IProblem.NotAccessibleConstructor;
3900 			problemConstructor = (ProblemMethodBinding) targetConstructor;
3901 			if (problemConstructor.closestMatch != null) {
3902 			    shownConstructor = problemConstructor.closestMatch.original();
3903 		    }
3904 			break;
3905 		case ProblemReasons.Ambiguous :
3906 			if (insideDefaultConstructor){
3907 				id = IProblem.AmbiguousConstructorInDefaultConstructor;
3908 			} else if (insideImplicitConstructorCall){
3909 				id = IProblem.AmbiguousConstructorInImplicitConstructorCall;
3910 			} else {
3911 				id = IProblem.AmbiguousConstructor;
3912 			}
3913 			break;
3914 		case ProblemReasons.ParameterBoundMismatch :
3915 			problemConstructor = (ProblemMethodBinding) targetConstructor;
3916 			ParameterizedGenericMethodBinding substitutedConstructor = (ParameterizedGenericMethodBinding) problemConstructor.closestMatch;
3917 			shownConstructor = substitutedConstructor.original();
3918 			int augmentedLength = problemConstructor.parameters.length;
3919 			TypeBinding inferredTypeArgument = problemConstructor.parameters[augmentedLength-2];
3920 			TypeVariableBinding typeParameter = (TypeVariableBinding) problemConstructor.parameters[augmentedLength-1];
3921 			TypeBinding[] invocationArguments = new TypeBinding[augmentedLength-2]; // remove extra info from the end
3922 			System.arraycopy(problemConstructor.parameters, 0, invocationArguments, 0, augmentedLength-2);
3923 			this.handle(
3924 				IProblem.GenericConstructorTypeArgumentMismatch,
3925 				new String[] {
3926 				        new String(shownConstructor.declaringClass.sourceName()),
3927 				        typesAsString(shownConstructor, false),
3928 				        new String(shownConstructor.declaringClass.readableName()),
3929 				        typesAsString(invocationArguments, false),
3930 				        new String(inferredTypeArgument.readableName()),
3931 				        new String(typeParameter.sourceName()),
3932 				        parameterBoundAsString(typeParameter, false) },
3933 				new String[] {
3934 				        new String(shownConstructor.declaringClass.sourceName()),
3935 				        typesAsString(shownConstructor, true),
3936 				        new String(shownConstructor.declaringClass.shortReadableName()),
3937 				        typesAsString(invocationArguments, true),
3938 				        new String(inferredTypeArgument.shortReadableName()),
3939 				        new String(typeParameter.sourceName()),
3940 				        parameterBoundAsString(typeParameter, true) },
3941 				sourceStart,
3942 				sourceEnd);
3943 			return;
3944 
3945 		case ProblemReasons.TypeParameterArityMismatch :
3946 			problemConstructor = (ProblemMethodBinding) targetConstructor;
3947 			shownConstructor = problemConstructor.closestMatch;
3948 			if (shownConstructor.typeVariables == Binding.NO_TYPE_VARIABLES) {
3949 				this.handle(
3950 					IProblem.NonGenericConstructor,
3951 					new String[] {
3952 					        new String(shownConstructor.declaringClass.sourceName()),
3953 					        typesAsString(shownConstructor, false),
3954 					        new String(shownConstructor.declaringClass.readableName()),
3955 					        typesAsString(targetConstructor, false) },
3956 					new String[] {
3957 					        new String(shownConstructor.declaringClass.sourceName()),
3958 					        typesAsString(shownConstructor, true),
3959 					        new String(shownConstructor.declaringClass.shortReadableName()),
3960 					        typesAsString(targetConstructor, true) },
3961 					sourceStart,
3962 					sourceEnd);
3963 			} else {
3964 				this.handle(
3965 					IProblem.IncorrectArityForParameterizedConstructor  ,
3966 					new String[] {
3967 					        new String(shownConstructor.declaringClass.sourceName()),
3968 					        typesAsString(shownConstructor, false),
3969 					        new String(shownConstructor.declaringClass.readableName()),
3970 							typesAsString(shownConstructor.typeVariables, false),
3971 					        typesAsString(targetConstructor, false) },
3972 					new String[] {
3973 					        new String(shownConstructor.declaringClass.sourceName()),
3974 					        typesAsString(shownConstructor, true),
3975 					        new String(shownConstructor.declaringClass.shortReadableName()),
3976 							typesAsString(shownConstructor.typeVariables, true),
3977 					        typesAsString(targetConstructor, true) },
3978 					sourceStart,
3979 					sourceEnd);
3980 			}
3981 			return;
3982 		case ProblemReasons.ParameterizedMethodTypeMismatch :
3983 			problemConstructor = (ProblemMethodBinding) targetConstructor;
3984 			shownConstructor = problemConstructor.closestMatch;
3985 			this.handle(
3986 				IProblem.ParameterizedConstructorArgumentTypeMismatch,
3987 				new String[] {
3988 				        new String(shownConstructor.declaringClass.sourceName()),
3989 				        typesAsString(shownConstructor, false),
3990 				        new String(shownConstructor.declaringClass.readableName()),
3991 						typesAsString(((ParameterizedGenericMethodBinding)shownConstructor).typeArguments, false),
3992 				        typesAsString(targetConstructor, false) },
3993 				new String[] {
3994 				        new String(shownConstructor.declaringClass.sourceName()),
3995 				        typesAsString(shownConstructor, true),
3996 				        new String(shownConstructor.declaringClass.shortReadableName()),
3997 						typesAsString(((ParameterizedGenericMethodBinding)shownConstructor).typeArguments, true),
3998 				        typesAsString(targetConstructor, true) },
3999 				sourceStart,
4000 				sourceEnd);
4001 			return;
4002 		case ProblemReasons.TypeArgumentsForRawGenericMethod :
4003 			problemConstructor = (ProblemMethodBinding) targetConstructor;
4004 			shownConstructor = problemConstructor.closestMatch;
4005 			this.handle(
4006 				IProblem.TypeArgumentsForRawGenericConstructor,
4007 				new String[] {
4008 				        new String(shownConstructor.declaringClass.sourceName()),
4009 				        typesAsString(shownConstructor, false),
4010 				        new String(shownConstructor.declaringClass.readableName()),
4011 				        typesAsString(targetConstructor, false) },
4012 				new String[] {
4013 				        new String(shownConstructor.declaringClass.sourceName()),
4014 				        typesAsString(shownConstructor, true),
4015 				        new String(shownConstructor.declaringClass.shortReadableName()),
4016 				        typesAsString(targetConstructor, true) },
4017 				sourceStart,
4018 				sourceEnd);
4019 			return;
4020 		case ProblemReasons.VarargsElementTypeNotVisible :
4021 			problemConstructor = (ProblemMethodBinding) targetConstructor;
4022 			shownConstructor = problemConstructor.closestMatch;
4023 			TypeBinding varargsElementType = shownConstructor.parameters[shownConstructor.parameters.length - 1].leafComponentType();
4024 			this.handle(
4025 				IProblem.VarargsElementTypeNotVisibleForConstructor,
4026 				new String[] {
4027 						new String(shownConstructor.declaringClass.sourceName()),
4028 						typesAsString(shownConstructor, false),
4029 						new String(shownConstructor.declaringClass.readableName()),
4030 						new String(varargsElementType.readableName())
4031 				},
4032 				new String[] {
4033 						new String(shownConstructor.declaringClass.sourceName()),
4034 						typesAsString(shownConstructor, true),
4035 						new String(shownConstructor.declaringClass.shortReadableName()),
4036 						new String(varargsElementType.shortReadableName())
4037 				},
4038 				sourceStart,
4039 				sourceEnd);
4040 			return;
4041 		case ProblemReasons.InferredApplicableMethodInapplicable:
4042 		case ProblemReasons.InvocationTypeInferenceFailure:
4043 			// FIXME(stephan): construct suitable message (https://bugs.eclipse.org/404675)
4044 			problemConstructor = (ProblemMethodBinding) targetConstructor;
4045 			shownConstructor = problemConstructor.closestMatch;
4046 			this.handle(
4047 				IProblem.TypeMismatch,
4048 				new String[] {
4049 				        String.valueOf(shownConstructor.returnType.readableName()),
4050 				        (problemConstructor.returnType != null ? String.valueOf(problemConstructor.returnType.readableName()) : "<unknown>")}, //$NON-NLS-1$
4051 				new String[] {
4052 				        String.valueOf(shownConstructor.returnType.shortReadableName()),
4053 				        (problemConstructor.returnType != null ? String.valueOf(problemConstructor.returnType.shortReadableName()) : "<unknown>")}, //$NON-NLS-1$
4054 				statement.sourceStart,
4055 				statement.sourceEnd);
4056 			return;
4057 		case ProblemReasons.ContradictoryNullAnnotations:
4058 			problemConstructor = (ProblemMethodBinding) targetConstructor;
4059 			contradictoryNullAnnotationsInferred(problemConstructor.closestMatch, statement);
4060 			return;
4061 		case ProblemReasons.NoError : // 0
4062 		default :
4063 			needImplementation(statement); // want to fail to see why we were here...
4064 			break;
4065 	}
4066 
4067 	this.handle(
4068 		id,
4069 		new String[] {new String(targetConstructor.declaringClass.readableName()), typesAsString(shownConstructor, false)},
4070 		new String[] {new String(targetConstructor.declaringClass.shortReadableName()), typesAsString(shownConstructor, true)},
4071 		sourceStart,
4072 		sourceEnd);
4073 }
invalidContinue(ASTNode location)4074 public void invalidContinue(ASTNode location) {
4075 	this.handle(
4076 		IProblem.InvalidContinue,
4077 		NoArgument,
4078 		NoArgument,
4079 		location.sourceStart,
4080 		location.sourceEnd);
4081 }
invalidEnclosingType(Expression expression, TypeBinding type, ReferenceBinding enclosingType)4082 public void invalidEnclosingType(Expression expression, TypeBinding type, ReferenceBinding enclosingType) {
4083 
4084 	if (enclosingType.isAnonymousType()) enclosingType = enclosingType.superclass();
4085 	if (enclosingType.sourceName != null && enclosingType.sourceName.length == 0) return;
4086 
4087 	int flag = IProblem.UndefinedType; // default
4088 	switch (type.problemId()) {
4089 		case ProblemReasons.NotFound : // 1
4090 			flag = IProblem.UndefinedType;
4091 			break;
4092 		case ProblemReasons.NotVisible : // 2
4093 			flag = IProblem.NotVisibleType;
4094 			break;
4095 		case ProblemReasons.Ambiguous : // 3
4096 			flag = IProblem.AmbiguousType;
4097 			break;
4098 		case ProblemReasons.InternalNameProvided :
4099 			flag = IProblem.InternalTypeNameProvided;
4100 			break;
4101 		case ProblemReasons.NoError : // 0
4102 		default :
4103 			needImplementation(expression); // want to fail to see why we were here...
4104 			break;
4105 	}
4106 
4107 	this.handle(
4108 		flag,
4109 		new String[] {new String(enclosingType.readableName()) + "." + new String(type.readableName())}, //$NON-NLS-1$
4110 		new String[] {new String(enclosingType.shortReadableName()) + "." + new String(type.shortReadableName())}, //$NON-NLS-1$
4111 		expression.sourceStart,
4112 		expression.sourceEnd);
4113 }
invalidExplicitConstructorCall(ASTNode location)4114 public void invalidExplicitConstructorCall(ASTNode location) {
4115 
4116 	this.handle(
4117 		IProblem.InvalidExplicitConstructorCall,
4118 		NoArgument,
4119 		NoArgument,
4120 		location.sourceStart,
4121 		location.sourceEnd);
4122 }
invalidExpressionAsStatement(Expression expression)4123 public void invalidExpressionAsStatement(Expression expression){
4124 	this.handle(
4125 		IProblem.InvalidExpressionAsStatement,
4126 		NoArgument,
4127 		NoArgument,
4128 		expression.sourceStart,
4129 		expression.sourceEnd);
4130 }
invalidField(FieldReference fieldRef, TypeBinding searchedType)4131 public void invalidField(FieldReference fieldRef, TypeBinding searchedType) {
4132 	if(isRecoveredName(fieldRef.token)) return;
4133 
4134 	int id = IProblem.UndefinedField;
4135 	FieldBinding field = fieldRef.binding;
4136 	switch (field.problemId()) {
4137 		case ProblemReasons.NotFound :
4138 			if ((searchedType.tagBits & TagBits.HasMissingType) != 0) {
4139 				this.handle(
4140 						IProblem.UndefinedType,
4141 						new String[] {new String(searchedType.leafComponentType().readableName())},
4142 						new String[] {new String(searchedType.leafComponentType().shortReadableName())},
4143 						fieldRef.receiver.sourceStart,
4144 						fieldRef.receiver.sourceEnd);
4145 					return;
4146 			}
4147 			id = IProblem.UndefinedField;
4148 /* also need to check that the searchedType is the receiver type
4149 			if (searchedType.isHierarchyInconsistent())
4150 				severity = SecondaryError;
4151 */
4152 			break;
4153 		case ProblemReasons.NotVisible :
4154 		case ProblemReasons.NotAccessible :
4155 			this.handle(
4156 				(field.problemId() == ProblemReasons.NotVisible) ? IProblem.NotVisibleField : IProblem.NotAccessibleField,
4157 				new String[] {new String(fieldRef.token), new String(field.declaringClass.readableName())},
4158 				new String[] {new String(fieldRef.token), new String(field.declaringClass.shortReadableName())},
4159 				nodeSourceStart(field, fieldRef),
4160 				nodeSourceEnd(field, fieldRef));
4161 			return;
4162 		case ProblemReasons.Ambiguous :
4163 			id = IProblem.AmbiguousField;
4164 			break;
4165 		case ProblemReasons.NoProperEnclosingInstance:
4166 			noSuchEnclosingInstance(fieldRef.actualReceiverType, fieldRef.receiver, false);
4167 			return;
4168 		case ProblemReasons.NonStaticReferenceInStaticContext :
4169 			id = IProblem.NonStaticFieldFromStaticInvocation;
4170 			break;
4171 		case ProblemReasons.NonStaticReferenceInConstructorInvocation :
4172 			id = IProblem.InstanceFieldDuringConstructorInvocation;
4173 			break;
4174 		case ProblemReasons.InheritedNameHidesEnclosingName :
4175 			id = IProblem.InheritedFieldHidesEnclosingName;
4176 			break;
4177 		case ProblemReasons.ReceiverTypeNotVisible :
4178 			this.handle(
4179 				IProblem.NotVisibleType, // cannot occur in javadoc comments
4180 				new String[] {new String(searchedType.leafComponentType().readableName())},
4181 				new String[] {new String(searchedType.leafComponentType().shortReadableName())},
4182 				fieldRef.receiver.sourceStart,
4183 				fieldRef.receiver.sourceEnd);
4184 			return;
4185 
4186 		case ProblemReasons.NoError : // 0
4187 		default :
4188 			needImplementation(fieldRef); // want to fail to see why we were here...
4189 			break;
4190 	}
4191 
4192 	String[] arguments = new String[] {new String(field.readableName())};
4193 	this.handle(
4194 		id,
4195 		arguments,
4196 		arguments,
4197 		nodeSourceStart(field, fieldRef),
4198 		nodeSourceEnd(field, fieldRef));
4199 }
invalidField(NameReference nameRef, FieldBinding field)4200 public void invalidField(NameReference nameRef, FieldBinding field) {
4201 	if (nameRef instanceof QualifiedNameReference) {
4202 		QualifiedNameReference ref = (QualifiedNameReference) nameRef;
4203 		if (isRecoveredName(ref.tokens)) return;
4204 	} else {
4205 		SingleNameReference ref = (SingleNameReference) nameRef;
4206 		if (isRecoveredName(ref.token)) return;
4207 	}
4208 	int id = IProblem.UndefinedField;
4209 	switch (field.problemId()) {
4210 		case ProblemReasons.NotFound :
4211 			TypeBinding declaringClass = field.declaringClass;
4212 			if (declaringClass != null && (declaringClass.tagBits & TagBits.HasMissingType) != 0) {
4213 				this.handle(
4214 						IProblem.UndefinedType,
4215 						new String[] {new String(field.declaringClass.readableName())},
4216 						new String[] {new String(field.declaringClass.shortReadableName())},
4217 						nameRef.sourceStart,
4218 						nameRef.sourceEnd);
4219 					return;
4220 			}
4221 			String[] arguments = new String[] {new String(field.readableName())};
4222 			this.handle(
4223 					id,
4224 					arguments,
4225 					arguments,
4226 					nodeSourceStart(field, nameRef),
4227 					nodeSourceEnd(field, nameRef));
4228 			return;
4229 		case ProblemReasons.NotVisible :
4230 		case ProblemReasons.NotAccessible :
4231 			char[] name = field.readableName();
4232 			name = CharOperation.lastSegment(name, '.');
4233 			this.handle(
4234 				(field.problemId() == ProblemReasons.NotVisible) ? IProblem.NotVisibleField : IProblem.NotAccessibleField,
4235 				new String[] {new String(name), new String(field.declaringClass.readableName())},
4236 				new String[] {new String(name), new String(field.declaringClass.shortReadableName())},
4237 				nodeSourceStart(field, nameRef),
4238 				nodeSourceEnd(field, nameRef));
4239 			return;
4240 		case ProblemReasons.Ambiguous :
4241 			id = IProblem.AmbiguousField;
4242 			break;
4243 		case ProblemReasons.NonStaticReferenceInStaticContext :
4244 			id = IProblem.NonStaticFieldFromStaticInvocation;
4245 			break;
4246 		case ProblemReasons.NonStaticReferenceInConstructorInvocation :
4247 			id = IProblem.InstanceFieldDuringConstructorInvocation;
4248 			break;
4249 		case ProblemReasons.InheritedNameHidesEnclosingName :
4250 			id = IProblem.InheritedFieldHidesEnclosingName;
4251 			break;
4252 		case ProblemReasons.ReceiverTypeNotVisible :
4253 			this.handle(
4254 				IProblem.NotVisibleType,
4255 				new String[] {new String(field.declaringClass.readableName())},
4256 				new String[] {new String(field.declaringClass.shortReadableName())},
4257 				nameRef.sourceStart,
4258 				nameRef.sourceEnd);
4259 			return;
4260 		case ProblemReasons.NoError : // 0
4261 		default :
4262 			needImplementation(nameRef); // want to fail to see why we were here...
4263 			break;
4264 	}
4265 	String[] arguments = new String[] {new String(field.readableName())};
4266 	this.handle(
4267 		id,
4268 		arguments,
4269 		arguments,
4270 		nameRef.sourceStart,
4271 		nameRef.sourceEnd);
4272 }
invalidField(QualifiedNameReference nameRef, FieldBinding field, int index, TypeBinding searchedType)4273 public void invalidField(QualifiedNameReference nameRef, FieldBinding field, int index, TypeBinding searchedType) {
4274 	//the resolution of the index-th field of qname failed
4275 	//qname.otherBindings[index] is the binding that has produced the error
4276 
4277 	//The different targetted errors should be :
4278 	//UndefinedField
4279 	//NotVisibleField
4280 	//AmbiguousField
4281 
4282 	if (isRecoveredName(nameRef.tokens)) return;
4283 
4284 	if (searchedType.isBaseType()) {
4285 		this.handle(
4286 			IProblem.NoFieldOnBaseType,
4287 			new String[] {
4288 				new String(searchedType.readableName()),
4289 				CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index)),
4290 				new String(nameRef.tokens[index])},
4291 			new String[] {
4292 				new String(searchedType.sourceName()),
4293 				CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index)),
4294 				new String(nameRef.tokens[index])},
4295 			nameRef.sourceStart,
4296 			(int) nameRef.sourcePositions[index]);
4297 		return;
4298 	}
4299 
4300 	int id = IProblem.UndefinedField;
4301 	switch (field.problemId()) {
4302 		case ProblemReasons.NotFound :
4303 			if ((searchedType.tagBits & TagBits.HasMissingType) != 0) {
4304 				this.handle(
4305 						IProblem.UndefinedType,
4306 						new String[] {new String(searchedType.leafComponentType().readableName())},
4307 						new String[] {new String(searchedType.leafComponentType().shortReadableName())},
4308 						nameRef.sourceStart,
4309 						(int) nameRef.sourcePositions[index-1]);
4310 					return;
4311 			}
4312 			String fieldName = new String(nameRef.tokens[index]);
4313 			String[] arguments = new String[] {fieldName };
4314 			this.handle(
4315 					id,
4316 					arguments,
4317 					arguments,
4318 					nodeSourceStart(field, nameRef),
4319 					nodeSourceEnd(field, nameRef));
4320 			return;
4321 		case ProblemReasons.NotVisible :
4322 		case ProblemReasons.NotAccessible :
4323 			fieldName = new String(nameRef.tokens[index]);
4324 			this.handle(
4325 				(field.problemId() == ProblemReasons.NotVisible) ? IProblem.NotVisibleField : IProblem.NotAccessibleField,
4326 				new String[] {fieldName, new String(field.declaringClass.readableName())},
4327 				new String[] {fieldName, new String(field.declaringClass.shortReadableName())},
4328 				nodeSourceStart(field, nameRef),
4329 				nodeSourceEnd(field, nameRef));
4330 			return;
4331 		case ProblemReasons.Ambiguous :
4332 			id = IProblem.AmbiguousField;
4333 			break;
4334 		case ProblemReasons.NonStaticReferenceInStaticContext :
4335 			id = IProblem.NonStaticFieldFromStaticInvocation;
4336 			break;
4337 		case ProblemReasons.NonStaticReferenceInConstructorInvocation :
4338 			id = IProblem.InstanceFieldDuringConstructorInvocation;
4339 			break;
4340 		case ProblemReasons.InheritedNameHidesEnclosingName :
4341 			id = IProblem.InheritedFieldHidesEnclosingName;
4342 			break;
4343 		case ProblemReasons.ReceiverTypeNotVisible :
4344 			this.handle(
4345 				IProblem.NotVisibleType,
4346 				new String[] {new String(searchedType.leafComponentType().readableName())},
4347 				new String[] {new String(searchedType.leafComponentType().shortReadableName())},
4348 				nameRef.sourceStart,
4349 				(int) nameRef.sourcePositions[index-1]);
4350 			return;
4351 		case ProblemReasons.NoError : // 0
4352 		default :
4353 			needImplementation(nameRef); // want to fail to see why we were here...
4354 			break;
4355 	}
4356 	String[] arguments = new String[] {CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index + 1))};
4357 	this.handle(
4358 		id,
4359 		arguments,
4360 		arguments,
4361 		nameRef.sourceStart,
4362 		(int) nameRef.sourcePositions[index]);
4363 }
4364 
invalidFileNameForPackageAnnotations(Annotation annotation)4365 public void invalidFileNameForPackageAnnotations(Annotation annotation) {
4366 	this.handle(
4367 			IProblem.InvalidFileNameForPackageAnnotations,
4368 			NoArgument,
4369 			NoArgument,
4370 			annotation.sourceStart,
4371 			annotation.sourceEnd);
4372 }
4373 
nonStaticOrAlienTypeReceiver(MessageSend messageSend, MethodBinding method)4374 public void nonStaticOrAlienTypeReceiver(MessageSend messageSend, MethodBinding method) {
4375 	this.handle(
4376 			IProblem.NonStaticOrAlienTypeReceiver,
4377 			new String[] {
4378 					new String(method.declaringClass.readableName()),
4379 			        new String(method.selector),
4380 			},
4381 			new String[] {
4382 					new String(method.declaringClass.shortReadableName()),
4383 			        new String(method.selector),
4384 			},
4385 			(int) (messageSend.nameSourcePosition >>> 32),
4386 			(int) messageSend.nameSourcePosition);
4387 }
invalidMethod(MessageSend messageSend, MethodBinding method, Scope scope)4388 public void invalidMethod(MessageSend messageSend, MethodBinding method, Scope scope) {
4389 	if (isRecoveredName(messageSend.selector)) return;
4390 
4391 	int id = IProblem.UndefinedMethod; //default...
4392     MethodBinding shownMethod = method;
4393 	switch (method.problemId()) {
4394 		case ProblemReasons.ErrorAlreadyReported:
4395 			return;
4396 		case ProblemReasons.NoSuchMethodOnArray :
4397 			return; // secondary error.
4398 		case ProblemReasons.NotFound :
4399 			if ((method.declaringClass.tagBits & TagBits.HasMissingType) != 0) {
4400 				this.handle(
4401 						IProblem.UndefinedType,
4402 						new String[] {new String(method.declaringClass.readableName())},
4403 						new String[] {new String(method.declaringClass.shortReadableName())},
4404 						messageSend.receiver.sourceStart,
4405 						messageSend.receiver.sourceEnd);
4406 					return;
4407 			}
4408 			id = IProblem.UndefinedMethod;
4409 			ProblemMethodBinding problemMethod = (ProblemMethodBinding) method;
4410 			if (problemMethod.closestMatch != null) {
4411 			    	shownMethod = problemMethod.closestMatch;
4412 			    	if ((shownMethod.tagBits & TagBits.HasMissingType) != 0) {
4413 						missingTypeInMethod(messageSend, shownMethod);
4414 						return;
4415 			    	}
4416 					String closestParameterTypeNames = typesAsString(shownMethod, false);
4417 					String parameterTypeNames = typesAsString(problemMethod.parameters, false);
4418 					String closestParameterTypeShortNames = typesAsString(shownMethod, true);
4419 					String parameterTypeShortNames = typesAsString(problemMethod.parameters, true);
4420 					if (closestParameterTypeNames.equals(parameterTypeNames)) {
4421 						// include null annotations, maybe they show the difference:
4422 						closestParameterTypeNames = typesAsString(shownMethod, false, true);
4423 						parameterTypeNames = typesAsString(problemMethod.parameters, false, true);
4424 						closestParameterTypeShortNames = typesAsString(shownMethod, true, true);
4425 						parameterTypeShortNames = typesAsString(problemMethod.parameters, true, true);
4426 					}
4427 					if (closestParameterTypeShortNames.equals(parameterTypeShortNames)) {
4428 						closestParameterTypeShortNames = closestParameterTypeNames;
4429 						parameterTypeShortNames = parameterTypeNames;
4430 					}
4431 					this.handle(
4432 						IProblem.ParameterMismatch,
4433 						new String[] {
4434 							new String(shownMethod.declaringClass.readableName()),
4435 							new String(shownMethod.selector),
4436 							closestParameterTypeNames,
4437 							parameterTypeNames
4438 						},
4439 						new String[] {
4440 							new String(shownMethod.declaringClass.shortReadableName()),
4441 							new String(shownMethod.selector),
4442 							closestParameterTypeShortNames,
4443 							parameterTypeShortNames
4444 						},
4445 						(int) (messageSend.nameSourcePosition >>> 32),
4446 						(int) messageSend.nameSourcePosition);
4447 					return;
4448 			}
4449 			break;
4450 		case ProblemReasons.NotVisible :
4451 		case ProblemReasons.NotAccessible :
4452 			id = (method.problemId() == ProblemReasons.NotVisible) ? IProblem.NotVisibleMethod : IProblem.NotAccessibleMethod;
4453 			problemMethod = (ProblemMethodBinding) method;
4454 			if (problemMethod.closestMatch != null) {
4455 			    shownMethod = problemMethod.closestMatch.original();
4456 		    }
4457 			break;
4458 		case ProblemReasons.Ambiguous :
4459 			id = IProblem.AmbiguousMethod;
4460 			break;
4461 		case ProblemReasons.InheritedNameHidesEnclosingName :
4462 			id = IProblem.InheritedMethodHidesEnclosingName;
4463 			break;
4464 		case ProblemReasons.NonStaticReferenceInConstructorInvocation :
4465 			id = IProblem.InstanceMethodDuringConstructorInvocation;
4466 			break;
4467 		case ProblemReasons.NonStaticReferenceInStaticContext :
4468 			id = IProblem.StaticMethodRequested;
4469 			break;
4470 		case ProblemReasons.NonStaticOrAlienTypeReceiver:
4471 			nonStaticOrAlienTypeReceiver(messageSend, method);
4472 			return;
4473 		case ProblemReasons.InterfaceMethodInvocationNotBelow18:
4474 			this.handle(
4475 					IProblem.InterfaceStaticMethodInvocationNotBelow18,
4476 					new String[] {
4477 							new String(method.declaringClass.readableName()),
4478 					        new String(method.selector),
4479 					},
4480 					new String[] {
4481 							new String(method.declaringClass.shortReadableName()),
4482 					        new String(method.selector),
4483 					},
4484 					(int) (messageSend.nameSourcePosition >>> 32),
4485 					(int) messageSend.nameSourcePosition);
4486 			return;
4487 		case ProblemReasons.ReceiverTypeNotVisible :
4488 			this.handle(
4489 				IProblem.NotVisibleType,	// cannot occur in javadoc comments
4490 				new String[] {new String(method.declaringClass.readableName())},
4491 				new String[] {new String(method.declaringClass.shortReadableName())},
4492 				messageSend.receiver.sourceStart,
4493 				messageSend.receiver.sourceEnd);
4494 			return;
4495 		case ProblemReasons.ParameterBoundMismatch :
4496 			problemMethod = (ProblemMethodBinding) method;
4497 			ParameterizedGenericMethodBinding substitutedMethod = (ParameterizedGenericMethodBinding) problemMethod.closestMatch;
4498 			shownMethod = substitutedMethod.original();
4499 			int augmentedLength = problemMethod.parameters.length;
4500 			TypeBinding inferredTypeArgument = problemMethod.parameters[augmentedLength-2];
4501 			TypeVariableBinding typeParameter = (TypeVariableBinding) problemMethod.parameters[augmentedLength-1];
4502 			TypeBinding[] invocationArguments = new TypeBinding[augmentedLength-2]; // remove extra info from the end
4503 			System.arraycopy(problemMethod.parameters, 0, invocationArguments, 0, augmentedLength-2);
4504 			this.handle(
4505 				IProblem.GenericMethodTypeArgumentMismatch,
4506 				new String[] {
4507 				        new String(shownMethod.selector),
4508 				        typesAsString(shownMethod, false),
4509 				        new String(shownMethod.declaringClass.readableName()),
4510 				        typesAsString(invocationArguments, false),
4511 				        new String(inferredTypeArgument.readableName()),
4512 				        new String(typeParameter.sourceName()),
4513 				        parameterBoundAsString(typeParameter, false) },
4514 				new String[] {
4515 				        new String(shownMethod.selector),
4516 				        typesAsString(shownMethod, true),
4517 				        new String(shownMethod.declaringClass.shortReadableName()),
4518 				        typesAsString(invocationArguments, true),
4519 				        new String(inferredTypeArgument.shortReadableName()),
4520 				        new String(typeParameter.sourceName()),
4521 				        parameterBoundAsString(typeParameter, true) },
4522 				(int) (messageSend.nameSourcePosition >>> 32),
4523 				(int) messageSend.nameSourcePosition);
4524 			return;
4525 		case ProblemReasons.TypeParameterArityMismatch :
4526 			problemMethod = (ProblemMethodBinding) method;
4527 			shownMethod = problemMethod.closestMatch;
4528 			if (shownMethod.typeVariables == Binding.NO_TYPE_VARIABLES) {
4529 				this.handle(
4530 					IProblem.NonGenericMethod ,
4531 					new String[] {
4532 					        new String(shownMethod.selector),
4533 					        typesAsString(shownMethod, false),
4534 					        new String(shownMethod.declaringClass.readableName()),
4535 					        typesAsString(method, false) },
4536 					new String[] {
4537 					        new String(shownMethod.selector),
4538 					        typesAsString(shownMethod, true),
4539 					        new String(shownMethod.declaringClass.shortReadableName()),
4540 					        typesAsString(method, true) },
4541 					(int) (messageSend.nameSourcePosition >>> 32),
4542 					(int) messageSend.nameSourcePosition);
4543 			} else {
4544 				this.handle(
4545 					IProblem.IncorrectArityForParameterizedMethod  ,
4546 					new String[] {
4547 					        new String(shownMethod.selector),
4548 					        typesAsString(shownMethod, false),
4549 					        new String(shownMethod.declaringClass.readableName()),
4550 							typesAsString(shownMethod.typeVariables, false),
4551 					        typesAsString(method, false) },
4552 					new String[] {
4553 					        new String(shownMethod.selector),
4554 					        typesAsString(shownMethod, true),
4555 					        new String(shownMethod.declaringClass.shortReadableName()),
4556 							typesAsString(shownMethod.typeVariables, true),
4557 					        typesAsString(method, true) },
4558 					(int) (messageSend.nameSourcePosition >>> 32),
4559 					(int) messageSend.nameSourcePosition);
4560 			}
4561 			return;
4562 		case ProblemReasons.ParameterizedMethodTypeMismatch :
4563 			problemMethod = (ProblemMethodBinding) method;
4564 			shownMethod = problemMethod.closestMatch;
4565 			this.handle(
4566 				IProblem.ParameterizedMethodArgumentTypeMismatch,
4567 				new String[] {
4568 				        new String(shownMethod.selector),
4569 				        typesAsString(shownMethod, false),
4570 				        new String(shownMethod.declaringClass.readableName()),
4571 						typesAsString(((ParameterizedGenericMethodBinding)shownMethod).typeArguments, false),
4572 				        typesAsString(method, false) },
4573 				new String[] {
4574 				        new String(shownMethod.selector),
4575 				        typesAsString(shownMethod, true),
4576 				        new String(shownMethod.declaringClass.shortReadableName()),
4577 						typesAsString(((ParameterizedGenericMethodBinding)shownMethod).typeArguments, true),
4578 				        typesAsString(method, true) },
4579 				(int) (messageSend.nameSourcePosition >>> 32),
4580 				(int) messageSend.nameSourcePosition);
4581 			return;
4582 		case ProblemReasons.TypeArgumentsForRawGenericMethod :
4583 			problemMethod = (ProblemMethodBinding) method;
4584 			shownMethod = problemMethod.closestMatch;
4585 			this.handle(
4586 				IProblem.TypeArgumentsForRawGenericMethod ,
4587 				new String[] {
4588 				        new String(shownMethod.selector),
4589 				        typesAsString(shownMethod, false),
4590 				        new String(shownMethod.declaringClass.readableName()),
4591 				        typesAsString(method, false) },
4592 				new String[] {
4593 				        new String(shownMethod.selector),
4594 				        typesAsString(shownMethod, true),
4595 				        new String(shownMethod.declaringClass.shortReadableName()),
4596 				        typesAsString(method, true) },
4597 				(int) (messageSend.nameSourcePosition >>> 32),
4598 				(int) messageSend.nameSourcePosition);
4599 			return;
4600 		case ProblemReasons.InferredApplicableMethodInapplicable:
4601 		case ProblemReasons.InvocationTypeInferenceFailure:
4602 			problemMethod = (ProblemMethodBinding) method;
4603 			shownMethod = problemMethod.closestMatch;
4604 			if (problemMethod.returnType == shownMethod.returnType) { //$IDENTITY-COMPARISON$
4605 				if (messageSend.expressionContext == ExpressionContext.VANILLA_CONTEXT) {
4606 					TypeVariableBinding[] typeVariables = method.shallowOriginal().typeVariables;
4607 					String typeArguments = typesAsString(typeVariables, false);
4608 					this.handle(IProblem.CannotInferInvocationType,
4609 							new String[] { typeArguments, String.valueOf(shownMethod.original().readableName()) },
4610 							new String[] { typeArguments, String.valueOf(shownMethod.original().shortReadableName()) },
4611 							messageSend.sourceStart,
4612 							messageSend.sourceEnd);
4613 				} else {
4614 					// FIXME(stephan): turn into an exception once we are sure about this
4615 					this.handle(IProblem.GenericInferenceError,
4616 						new String[] { "Unknown error at invocation of "+String.valueOf(shownMethod.readableName())}, //$NON-NLS-1$
4617 						new String[] { "Unknown error at invocation of "+String.valueOf(shownMethod.shortReadableName())}, //$NON-NLS-1$
4618 						messageSend.sourceStart,
4619 						messageSend.sourceEnd);
4620 				}
4621 				return;
4622 			}
4623 			TypeBinding shownMethodReturnType = shownMethod.returnType.capture(scope, messageSend.sourceStart, messageSend.sourceEnd);
4624 			this.handle(
4625 				IProblem.TypeMismatch,
4626 				new String[] {
4627 				        String.valueOf(shownMethodReturnType.readableName()),
4628 				        (problemMethod.returnType != null ? String.valueOf(problemMethod.returnType.readableName()) : "<unknown>")}, //$NON-NLS-1$
4629 				new String[] {
4630 				        String.valueOf(shownMethodReturnType.shortReadableName()),
4631 				        (problemMethod.returnType != null ? String.valueOf(problemMethod.returnType.shortReadableName()) : "<unknown>")}, //$NON-NLS-1$
4632 				messageSend.sourceStart,
4633 				messageSend.sourceEnd);
4634 			return;
4635 		case ProblemReasons.VarargsElementTypeNotVisible: // https://bugs.eclipse.org/bugs/show_bug.cgi?id=346042
4636 			problemMethod = (ProblemMethodBinding) method;
4637 			if (problemMethod.closestMatch != null) {
4638 			    shownMethod = problemMethod.closestMatch.original();
4639 		    }
4640 			TypeBinding varargsElementType = shownMethod.parameters[shownMethod.parameters.length - 1].leafComponentType();
4641 			this.handle(
4642 				IProblem.VarargsElementTypeNotVisible,
4643 				new String[] {
4644 				        new String(shownMethod.selector),
4645 				        typesAsString(shownMethod, false),
4646 				        new String(shownMethod.declaringClass.readableName()),
4647 				        new String(varargsElementType.readableName())
4648 				},
4649 				new String[] {
4650 				        new String(shownMethod.selector),
4651 				        typesAsString(shownMethod, true),
4652 				        new String(shownMethod.declaringClass.shortReadableName()),
4653 				        new String(varargsElementType.shortReadableName())
4654 				},
4655 				(int) (messageSend.nameSourcePosition >>> 32),
4656 				(int) messageSend.nameSourcePosition);
4657 			return;
4658 		case ProblemReasons.ApplicableMethodOverriddenByInapplicable:
4659 			problemMethod = (ProblemMethodBinding) method;
4660 			if (problemMethod.closestMatch != null) {
4661 			    shownMethod = problemMethod.closestMatch.original();
4662 		    }
4663 			this.handle(
4664 				IProblem.ApplicableMethodOverriddenByInapplicable,
4665 				new String[] {
4666 				        new String(shownMethod.selector),
4667 				        typesAsString(shownMethod, false),
4668 				        new String(shownMethod.declaringClass.readableName()),
4669 				},
4670 				new String[] {
4671 				        new String(shownMethod.selector),
4672 				        typesAsString(shownMethod, true),
4673 				        new String(shownMethod.declaringClass.shortReadableName()),
4674 				},
4675 				(int) (messageSend.nameSourcePosition >>> 32),
4676 				(int) messageSend.nameSourcePosition);
4677 			return;
4678 		case ProblemReasons.ContradictoryNullAnnotations:
4679 			problemMethod = (ProblemMethodBinding) method;
4680 			contradictoryNullAnnotationsInferred(problemMethod.closestMatch, messageSend);
4681 			return;
4682 		case ProblemReasons.NoError : // 0
4683 		default :
4684 			needImplementation(messageSend); // want to fail to see why we were here...
4685 			break;
4686 	}
4687 	this.handle(
4688 		id,
4689 		new String[] {
4690 			new String(method.declaringClass.readableName()),
4691 			new String(shownMethod.selector), typesAsString(shownMethod, false)},
4692 		new String[] {
4693 			new String(method.declaringClass.shortReadableName()),
4694 			new String(shownMethod.selector), typesAsString(shownMethod, true)},
4695 		(int) (messageSend.nameSourcePosition >>> 32),
4696 		(int) messageSend.nameSourcePosition);
4697 }
invalidNullToSynchronize(Expression expression)4698 public void invalidNullToSynchronize(Expression expression) {
4699 	this.handle(
4700 		IProblem.InvalidNullToSynchronized,
4701 		NoArgument,
4702 		NoArgument,
4703 		expression.sourceStart,
4704 		expression.sourceEnd);
4705 }
invalidOperator(BinaryExpression expression, TypeBinding leftType, TypeBinding rightType)4706 public void invalidOperator(BinaryExpression expression, TypeBinding leftType, TypeBinding rightType) {
4707 	String leftName = new String(leftType.readableName());
4708 	String rightName = new String(rightType.readableName());
4709 	String leftShortName = new String(leftType.shortReadableName());
4710 	String rightShortName = new String(rightType.shortReadableName());
4711 	if (leftShortName.equals(rightShortName)){
4712 		leftShortName = leftName;
4713 		rightShortName = rightName;
4714 	}
4715 	this.handle(
4716 		IProblem.InvalidOperator,
4717 		new String[] {
4718 			expression.operatorToString(),
4719 			leftName + ", " + rightName}, //$NON-NLS-1$
4720 		new String[] {
4721 			expression.operatorToString(),
4722 			leftShortName + ", " + rightShortName}, //$NON-NLS-1$
4723 		expression.sourceStart,
4724 		expression.sourceEnd);
4725 }
invalidOperator(CompoundAssignment assign, TypeBinding leftType, TypeBinding rightType)4726 public void invalidOperator(CompoundAssignment assign, TypeBinding leftType, TypeBinding rightType) {
4727 	String leftName = new String(leftType.readableName());
4728 	String rightName = new String(rightType.readableName());
4729 	String leftShortName = new String(leftType.shortReadableName());
4730 	String rightShortName = new String(rightType.shortReadableName());
4731 	if (leftShortName.equals(rightShortName)){
4732 		leftShortName = leftName;
4733 		rightShortName = rightName;
4734 	}
4735 	this.handle(
4736 		IProblem.InvalidOperator,
4737 		new String[] {
4738 			assign.operatorToString(),
4739 			leftName + ", " + rightName}, //$NON-NLS-1$
4740 		new String[] {
4741 			assign.operatorToString(),
4742 			leftShortName + ", " + rightShortName}, //$NON-NLS-1$
4743 		assign.sourceStart,
4744 		assign.sourceEnd);
4745 }
invalidOperator(UnaryExpression expression, TypeBinding type)4746 public void invalidOperator(UnaryExpression expression, TypeBinding type) {
4747 	this.handle(
4748 		IProblem.InvalidOperator,
4749 		new String[] {expression.operatorToString(), new String(type.readableName())},
4750 		new String[] {expression.operatorToString(), new String(type.shortReadableName())},
4751 		expression.sourceStart,
4752 		expression.sourceEnd);
4753 }
invalidParameterizedExceptionType(TypeBinding exceptionType, ASTNode location)4754 public void invalidParameterizedExceptionType(TypeBinding exceptionType, ASTNode location) {
4755 	this.handle(
4756 		IProblem.InvalidParameterizedExceptionType,
4757 		new String[] {new String(exceptionType.readableName())},
4758 		new String[] {new String(exceptionType.shortReadableName())},
4759 		location.sourceStart,
4760 		location.sourceEnd);
4761 }
invalidParenthesizedExpression(ASTNode reference)4762 public void invalidParenthesizedExpression(ASTNode reference) {
4763 	this.handle(
4764 		IProblem.InvalidParenthesizedExpression,
4765 		NoArgument,
4766 		NoArgument,
4767 		reference.sourceStart,
4768 		reference.sourceEnd);
4769 }
invalidType(ASTNode location, TypeBinding type)4770 public void invalidType(ASTNode location, TypeBinding type) {
4771 	if (type instanceof ReferenceBinding) {
4772 		if (isRecoveredName(((ReferenceBinding)type).compoundName)) return;
4773 	}
4774 	else if (type instanceof ArrayBinding) {
4775 		TypeBinding leafType = ((ArrayBinding)type).leafComponentType;
4776 		if (leafType instanceof ReferenceBinding) {
4777 			if (isRecoveredName(((ReferenceBinding)leafType).compoundName)) return;
4778 		}
4779 	}
4780 
4781 	if (type.isParameterizedType()) {
4782 		List missingTypes = type.collectMissingTypes(null);
4783 		if (missingTypes != null) {
4784 			ReferenceContext savedContext = this.referenceContext;
4785 			for (Iterator iterator = missingTypes.iterator(); iterator.hasNext(); ) {
4786 				try {
4787 					invalidType(location, (TypeBinding) iterator.next());
4788 				} finally {
4789 					this.referenceContext = savedContext;
4790 				}
4791 			}
4792 			return;
4793 		}
4794 	}
4795 	int id = IProblem.UndefinedType; // default
4796 	switch (type.problemId()) {
4797 		case ProblemReasons.NotFound :
4798 			id = IProblem.UndefinedType;
4799 			break;
4800 		case ProblemReasons.NotVisible :
4801 			id = IProblem.NotVisibleType;
4802 			break;
4803 		case ProblemReasons.NotAccessible :
4804 			id = IProblem.NotAccessibleType;
4805 			break;
4806 		case ProblemReasons.Ambiguous :
4807 			id = IProblem.AmbiguousType;
4808 			break;
4809 		case ProblemReasons.InternalNameProvided :
4810 			id = IProblem.InternalTypeNameProvided;
4811 			break;
4812 		case ProblemReasons.InheritedNameHidesEnclosingName :
4813 			id = IProblem.InheritedTypeHidesEnclosingName;
4814 			break;
4815 		case ProblemReasons.NonStaticReferenceInStaticContext :
4816 			id = IProblem.NonStaticTypeFromStaticInvocation;
4817 			break;
4818 		case ProblemReasons.IllegalSuperTypeVariable :
4819 			id = IProblem.IllegalTypeVariableSuperReference;
4820 			break;
4821 		case ProblemReasons.NoError : // 0
4822 		default :
4823 			needImplementation(location); // want to fail to see why we were here...
4824 			break;
4825 	}
4826 
4827 	int end = location.sourceEnd;
4828 	if (location instanceof QualifiedNameReference) {
4829 		QualifiedNameReference ref = (QualifiedNameReference) location;
4830 		if (isRecoveredName(ref.tokens)) return;
4831 		if (ref.indexOfFirstFieldBinding >= 1)
4832 			end = (int) ref.sourcePositions[ref.indexOfFirstFieldBinding - 1];
4833 	} else if (location instanceof ParameterizedQualifiedTypeReference) {
4834 		// must be before instanceof ArrayQualifiedTypeReference
4835 		ParameterizedQualifiedTypeReference ref = (ParameterizedQualifiedTypeReference) location;
4836 		if (isRecoveredName(ref.tokens)) return;
4837 		if (type instanceof ReferenceBinding) {
4838 			char[][] name = ((ReferenceBinding) type).compoundName;
4839 			end = (int) ref.sourcePositions[name.length - 1];
4840 		}
4841 	} else if (location instanceof ArrayQualifiedTypeReference) {
4842 		ArrayQualifiedTypeReference arrayQualifiedTypeReference = (ArrayQualifiedTypeReference) location;
4843 		if (isRecoveredName(arrayQualifiedTypeReference.tokens)) return;
4844 		TypeBinding leafType = type.leafComponentType();
4845 		if (leafType instanceof ReferenceBinding) {
4846 			char[][] name = ((ReferenceBinding) leafType).compoundName; // problem type will tell how much got resolved
4847 			end = (int) arrayQualifiedTypeReference.sourcePositions[name.length-1];
4848 		} else {
4849 			long[] positions = arrayQualifiedTypeReference.sourcePositions;
4850 			end = (int) positions[positions.length - 1];
4851 		}
4852 	} else if (location instanceof QualifiedTypeReference) {
4853 		QualifiedTypeReference ref = (QualifiedTypeReference) location;
4854 		if (isRecoveredName(ref.tokens)) return;
4855 		if (type instanceof ReferenceBinding) {
4856 			char[][] name = ((ReferenceBinding) type).compoundName;
4857 			if (name.length <= ref.sourcePositions.length)
4858 				end = (int) ref.sourcePositions[name.length - 1];
4859 		}
4860 	} else if (location instanceof ImportReference) {
4861 		ImportReference ref = (ImportReference) location;
4862 		if (isRecoveredName(ref.tokens)) return;
4863 		if (type instanceof ReferenceBinding) {
4864 			char[][] name = ((ReferenceBinding) type).compoundName;
4865 			end = (int) ref.sourcePositions[name.length - 1];
4866 		}
4867 	} else if (location instanceof ArrayTypeReference) {
4868 		ArrayTypeReference arrayTypeReference = (ArrayTypeReference) location;
4869 		if (isRecoveredName(arrayTypeReference.token)) return;
4870 		end = arrayTypeReference.originalSourceEnd;
4871 	}
4872 
4873 	int start = location.sourceStart;
4874 	if (location instanceof org.eclipse.jdt.internal.compiler.ast.SingleTypeReference) {
4875 		org.eclipse.jdt.internal.compiler.ast.SingleTypeReference ref =
4876 				(org.eclipse.jdt.internal.compiler.ast.SingleTypeReference) location;
4877 		if (ref.annotations != null)
4878 			start = end - ref.token.length + 1;
4879 	} else if (location instanceof QualifiedTypeReference) {
4880 		QualifiedTypeReference ref = (QualifiedTypeReference) location;
4881 		if (ref.annotations != null)
4882 			start = (int) (ref.sourcePositions[0] & 0x00000000FFFFFFFFL ) - ref.tokens[0].length + 1;
4883 	}
4884 
4885 	this.handle(
4886 		id,
4887 		new String[] {new String(type.leafComponentType().readableName()) },
4888 		new String[] {new String(type.leafComponentType().shortReadableName())},
4889 		start,
4890 		end);
4891 }
invalidTypeForCollection(Expression expression)4892 public void invalidTypeForCollection(Expression expression) {
4893 	this.handle(
4894 			IProblem.InvalidTypeForCollection,
4895 			NoArgument,
4896 			NoArgument,
4897 			expression.sourceStart,
4898 			expression.sourceEnd);
4899 }
invalidTypeForCollectionTarget14(Expression expression)4900 public void invalidTypeForCollectionTarget14(Expression expression) {
4901 	this.handle(
4902 			IProblem.InvalidTypeForCollectionTarget14,
4903 			NoArgument,
4904 			NoArgument,
4905 			expression.sourceStart,
4906 			expression.sourceEnd);
4907 }
invalidTypeToSynchronize(Expression expression, TypeBinding type)4908 public void invalidTypeToSynchronize(Expression expression, TypeBinding type) {
4909 	this.handle(
4910 		IProblem.InvalidTypeToSynchronized,
4911 		new String[] {new String(type.readableName())},
4912 		new String[] {new String(type.shortReadableName())},
4913 		expression.sourceStart,
4914 		expression.sourceEnd);
4915 }
invalidTypeVariableAsException(TypeBinding exceptionType, ASTNode location)4916 public void invalidTypeVariableAsException(TypeBinding exceptionType, ASTNode location) {
4917 	this.handle(
4918 		IProblem.InvalidTypeVariableExceptionType,
4919 		new String[] {new String(exceptionType.readableName())},
4920 		new String[] {new String(exceptionType.shortReadableName())},
4921 		location.sourceStart,
4922 		location.sourceEnd);
4923 }
invalidUnaryExpression(Expression expression)4924 public void invalidUnaryExpression(Expression expression) {
4925 	this.handle(
4926 		IProblem.InvalidUnaryExpression,
4927 		NoArgument,
4928 		NoArgument,
4929 		expression.sourceStart,
4930 		expression.sourceEnd);
4931 }
invalidUsageOfAnnotation(Annotation annotation)4932 public void invalidUsageOfAnnotation(Annotation annotation) {
4933 	this.handle(
4934 		IProblem.InvalidUsageOfAnnotations,
4935 		NoArgument,
4936 		NoArgument,
4937 		annotation.sourceStart,
4938 		annotation.sourceEnd);
4939 }
invalidUsageOfAnnotationDeclarations(TypeDeclaration annotationTypeDeclaration)4940 public void invalidUsageOfAnnotationDeclarations(TypeDeclaration annotationTypeDeclaration) {
4941 	this.handle(
4942 		IProblem.InvalidUsageOfAnnotationDeclarations,
4943 		NoArgument,
4944 		NoArgument,
4945 		annotationTypeDeclaration.sourceStart,
4946 		annotationTypeDeclaration.sourceEnd);
4947 }
invalidUsageOfEnumDeclarations(TypeDeclaration enumDeclaration)4948 public void invalidUsageOfEnumDeclarations(TypeDeclaration enumDeclaration) {
4949 	this.handle(
4950 		IProblem.InvalidUsageOfEnumDeclarations,
4951 		NoArgument,
4952 		NoArgument,
4953 		enumDeclaration.sourceStart,
4954 		enumDeclaration.sourceEnd);
4955 }
invalidUsageOfForeachStatements(LocalDeclaration elementVariable, Expression collection)4956 public void invalidUsageOfForeachStatements(LocalDeclaration elementVariable, Expression collection) {
4957 	this.handle(
4958 		IProblem.InvalidUsageOfForeachStatements,
4959 		NoArgument,
4960 		NoArgument,
4961 		elementVariable.declarationSourceStart,
4962 		collection.sourceEnd);
4963 }
invalidUsageOfStaticImports(ImportReference staticImport)4964 public void invalidUsageOfStaticImports(ImportReference staticImport) {
4965 	this.handle(
4966 		IProblem.InvalidUsageOfStaticImports,
4967 		NoArgument,
4968 		NoArgument,
4969 		staticImport.declarationSourceStart,
4970 		staticImport.declarationSourceEnd);
4971 }
invalidUsageOfTypeArguments(TypeReference firstTypeReference, TypeReference lastTypeReference)4972 public void invalidUsageOfTypeArguments(TypeReference firstTypeReference, TypeReference lastTypeReference) {
4973 	this.handle(
4974 		IProblem.InvalidUsageOfTypeArguments,
4975 		NoArgument,
4976 		NoArgument,
4977 		firstTypeReference.sourceStart,
4978 		lastTypeReference.sourceEnd);
4979 }
invalidUsageOfTypeParameters(TypeParameter firstTypeParameter, TypeParameter lastTypeParameter)4980 public void invalidUsageOfTypeParameters(TypeParameter firstTypeParameter, TypeParameter lastTypeParameter) {
4981 	this.handle(
4982 		IProblem.InvalidUsageOfTypeParameters,
4983 		NoArgument,
4984 		NoArgument,
4985 		firstTypeParameter.declarationSourceStart,
4986 		lastTypeParameter.declarationSourceEnd);
4987 }
invalidUsageOfTypeParametersForAnnotationDeclaration(TypeDeclaration annotationTypeDeclaration)4988 public void invalidUsageOfTypeParametersForAnnotationDeclaration(TypeDeclaration annotationTypeDeclaration) {
4989 	TypeParameter[] parameters = annotationTypeDeclaration.typeParameters;
4990 	int length = parameters.length;
4991 	this.handle(
4992 			IProblem.InvalidUsageOfTypeParametersForAnnotationDeclaration,
4993 			NoArgument,
4994 			NoArgument,
4995 			parameters[0].declarationSourceStart,
4996 			parameters[length - 1].declarationSourceEnd);
4997 }
invalidUsageOfTypeParametersForEnumDeclaration(TypeDeclaration annotationTypeDeclaration)4998 public void invalidUsageOfTypeParametersForEnumDeclaration(TypeDeclaration annotationTypeDeclaration) {
4999 	TypeParameter[] parameters = annotationTypeDeclaration.typeParameters;
5000 	int length = parameters.length;
5001 	this.handle(
5002 			IProblem.InvalidUsageOfTypeParametersForEnumDeclaration,
5003 			NoArgument,
5004 			NoArgument,
5005 			parameters[0].declarationSourceStart,
5006 			parameters[length - 1].declarationSourceEnd);
5007 }
invalidUsageOfVarargs(AbstractVariableDeclaration aVarDecl)5008 public void invalidUsageOfVarargs(AbstractVariableDeclaration aVarDecl) {
5009 	this.handle(
5010 		IProblem.InvalidUsageOfVarargs,
5011 		NoArgument,
5012 		NoArgument,
5013 		aVarDecl.type.sourceStart,
5014 		aVarDecl.sourceEnd);
5015 }
invalidUsageOfTypeAnnotations(Annotation annotation)5016 public void invalidUsageOfTypeAnnotations(Annotation annotation) {
5017 	this.handle(
5018 			IProblem.InvalidUsageOfTypeAnnotations,
5019 			NoArgument,
5020 			NoArgument,
5021 			annotation.sourceStart,
5022 			annotation.sourceEnd);
5023 }
misplacedTypeAnnotations(Annotation first, Annotation last)5024 public void misplacedTypeAnnotations(Annotation first, Annotation last) {
5025 	this.handle(
5026 			IProblem.MisplacedTypeAnnotations,
5027 			NoArgument,
5028 			NoArgument,
5029 			first.sourceStart,
5030 			last.sourceEnd);
5031 }
illegalUsageOfTypeAnnotations(Annotation annotation)5032 public void illegalUsageOfTypeAnnotations(Annotation annotation) {
5033 	this.handle(
5034 			IProblem.IllegalUsageOfTypeAnnotations,
5035 			NoArgument,
5036 			NoArgument,
5037 			annotation.sourceStart,
5038 			annotation.sourceEnd);
5039 }
illegalTypeAnnotationsInStaticMemberAccess(Annotation first, Annotation last)5040 public void illegalTypeAnnotationsInStaticMemberAccess(Annotation first, Annotation last) {
5041 	this.handle(
5042 			IProblem.IllegalTypeAnnotationsInStaticMemberAccess,
5043 			NoArgument,
5044 			NoArgument,
5045 			first.sourceStart,
5046 			last.sourceEnd);
5047 }
isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl, Object location, boolean implicitAnnotationUse)5048 public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl, Object location, boolean implicitAnnotationUse) {
5049 	// ProblemReporter is not designed to be reentrant. Just in case, we discovered a build path problem while we are already
5050 	// in the midst of reporting some other problem, save and restore reference context thereby mimicking a stack.
5051 	// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=442755.
5052 	ReferenceContext savedContext = this.referenceContext;
5053 	this.referenceContext = compUnitDecl;
5054 	String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)};
5055 	int start = 0, end = 0;
5056 	if (location != null) {
5057 		if (location instanceof InvocationSite) {
5058 			InvocationSite site = (InvocationSite) location;
5059 			start = site.sourceStart();
5060 			end = site.sourceEnd();
5061 		} else if (location instanceof ASTNode) {
5062 			ASTNode node = (ASTNode) location;
5063 			start = node.sourceStart();
5064 			end = node.sourceEnd();
5065 		}
5066 	}
5067 	try {
5068 		this.handle(
5069 				implicitAnnotationUse ? IProblem.MissingNullAnnotationImplicitlyUsed : IProblem.IsClassPathCorrect,
5070 				arguments,
5071 				arguments,
5072 				start,
5073 				end);
5074 	} finally {
5075 		this.referenceContext = savedContext;
5076 	}
5077 }
isIdentifier(int token)5078 private boolean isIdentifier(int token) {
5079 	return token == TerminalTokens.TokenNameIdentifier;
5080 }
isKeyword(int token)5081 private boolean isKeyword(int token) {
5082 	switch(token) {
5083 		case TerminalTokens.TokenNameabstract:
5084 		case TerminalTokens.TokenNameassert:
5085 		case TerminalTokens.TokenNamebyte:
5086 		case TerminalTokens.TokenNamebreak:
5087 		case TerminalTokens.TokenNameboolean:
5088 		case TerminalTokens.TokenNamecase:
5089 		case TerminalTokens.TokenNamechar:
5090 		case TerminalTokens.TokenNamecatch:
5091 		case TerminalTokens.TokenNameclass:
5092 		case TerminalTokens.TokenNamecontinue:
5093 		case TerminalTokens.TokenNamedo:
5094 		case TerminalTokens.TokenNamedouble:
5095 		case TerminalTokens.TokenNamedefault:
5096 		case TerminalTokens.TokenNameelse:
5097 		case TerminalTokens.TokenNameextends:
5098 		case TerminalTokens.TokenNamefor:
5099 		case TerminalTokens.TokenNamefinal:
5100 		case TerminalTokens.TokenNamefloat:
5101 		case TerminalTokens.TokenNamefalse:
5102 		case TerminalTokens.TokenNamefinally:
5103 		case TerminalTokens.TokenNameif:
5104 		case TerminalTokens.TokenNameint:
5105 		case TerminalTokens.TokenNameimport:
5106 		case TerminalTokens.TokenNameinterface:
5107 		case TerminalTokens.TokenNameimplements:
5108 		case TerminalTokens.TokenNameinstanceof:
5109 		case TerminalTokens.TokenNamelong:
5110 		case TerminalTokens.TokenNamenew:
5111 		case TerminalTokens.TokenNamenull:
5112 		case TerminalTokens.TokenNamenative:
5113 		case TerminalTokens.TokenNamepublic:
5114 		case TerminalTokens.TokenNamepackage:
5115 		case TerminalTokens.TokenNameprivate:
5116 		case TerminalTokens.TokenNameprotected:
5117 		case TerminalTokens.TokenNamereturn:
5118 		case TerminalTokens.TokenNameshort:
5119 		case TerminalTokens.TokenNamesuper:
5120 		case TerminalTokens.TokenNamestatic:
5121 		case TerminalTokens.TokenNameswitch:
5122 		case TerminalTokens.TokenNamestrictfp:
5123 		case TerminalTokens.TokenNamesynchronized:
5124 		case TerminalTokens.TokenNametry:
5125 		case TerminalTokens.TokenNamethis:
5126 		case TerminalTokens.TokenNametrue:
5127 		case TerminalTokens.TokenNamethrow:
5128 		case TerminalTokens.TokenNamethrows:
5129 		case TerminalTokens.TokenNametransient:
5130 		case TerminalTokens.TokenNamevoid:
5131 		case TerminalTokens.TokenNamevolatile:
5132 		case TerminalTokens.TokenNamewhile:
5133 			return true;
5134 		case TerminalTokens.TokenNameRestrictedIdentifierYield:
5135 		case TerminalTokens.TokenNameRestrictedIdentifierrecord:
5136 			// making explicit - not a (restricted) keyword but restricted identifier.
5137 			//$FALL-THROUGH$
5138 		default:
5139 			return false;
5140 	}
5141 }
isLiteral(int token)5142 private boolean isLiteral(int token) {
5143 	return Scanner.isLiteral(token);
5144 }
5145 
isRecoveredName(char[] simpleName)5146 private boolean isRecoveredName(char[] simpleName) {
5147 	return simpleName == RecoveryScanner.FAKE_IDENTIFIER;
5148 }
5149 
isRecoveredName(char[][] qualifiedName)5150 private boolean isRecoveredName(char[][] qualifiedName) {
5151 	if(qualifiedName == null) return false;
5152 	for (int i = 0; i < qualifiedName.length; i++) {
5153 		if(qualifiedName[i] == RecoveryScanner.FAKE_IDENTIFIER) return true;
5154 	}
5155 	return false;
5156 }
5157 
javadocAmbiguousMethodReference(int sourceStart, int sourceEnd, Binding fieldBinding, int modifiers)5158 public void javadocAmbiguousMethodReference(int sourceStart, int sourceEnd, Binding fieldBinding, int modifiers) {
5159 	int severity = computeSeverity(IProblem.JavadocAmbiguousMethodReference);
5160 	if (severity == ProblemSeverities.Ignore) return;
5161 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5162 		String[] arguments = new String[] {new String(fieldBinding.readableName())};
5163 		handle(
5164 			IProblem.JavadocAmbiguousMethodReference,
5165 			arguments,
5166 			arguments,
5167 			severity,
5168 			sourceStart,
5169 			sourceEnd);
5170 	}
5171 }
5172 
javadocDeprecatedField(FieldBinding field, ASTNode location, int modifiers)5173 public void javadocDeprecatedField(FieldBinding field, ASTNode location, int modifiers) {
5174 	int severity = computeSeverity(IProblem.JavadocUsingDeprecatedField);
5175 	if (severity == ProblemSeverities.Ignore) return;
5176 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5177 		this.handle(
5178 			IProblem.JavadocUsingDeprecatedField,
5179 			new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
5180 			new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
5181 			severity,
5182 			nodeSourceStart(field, location),
5183 			nodeSourceEnd(field, location));
5184 	}
5185 }
5186 
javadocDeprecatedMethod(MethodBinding method, ASTNode location, int modifiers)5187 public void javadocDeprecatedMethod(MethodBinding method, ASTNode location, int modifiers) {
5188 	boolean isConstructor = method.isConstructor();
5189 	int severity = computeSeverity(isConstructor ? IProblem.JavadocUsingDeprecatedConstructor : IProblem.JavadocUsingDeprecatedMethod);
5190 	if (severity == ProblemSeverities.Ignore) return;
5191 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5192 		if (isConstructor) {
5193 			this.handle(
5194 				IProblem.JavadocUsingDeprecatedConstructor,
5195 				new String[] {new String(method.declaringClass.readableName()), typesAsString(method, false)},
5196 				new String[] {new String(method.declaringClass.shortReadableName()), typesAsString(method, true)},
5197 				severity,
5198 				location.sourceStart,
5199 				location.sourceEnd);
5200 		} else {
5201 			this.handle(
5202 				IProblem.JavadocUsingDeprecatedMethod,
5203 				new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method, false)},
5204 				new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method, true)},
5205 				severity,
5206 				location.sourceStart,
5207 				location.sourceEnd);
5208 		}
5209 	}
5210 }
javadocDeprecatedType(TypeBinding type, ASTNode location, int modifiers)5211 public void javadocDeprecatedType(TypeBinding type, ASTNode location, int modifiers) {
5212 	javadocDeprecatedType(type, location, modifiers, Integer.MAX_VALUE);
5213 }
javadocDeprecatedType(TypeBinding type, ASTNode location, int modifiers, int index)5214 public void javadocDeprecatedType(TypeBinding type, ASTNode location, int modifiers, int index) {
5215 	if (location == null) return; // 1G828DN - no type ref for synthetic arguments
5216 	int severity = computeSeverity(IProblem.JavadocUsingDeprecatedType);
5217 	if (severity == ProblemSeverities.Ignore) return;
5218 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5219 		if (type.isMemberType() && type instanceof ReferenceBinding && !javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, ((ReferenceBinding)type).modifiers)) {
5220 			this.handle(IProblem.JavadocHiddenReference, NoArgument, NoArgument, location.sourceStart, location.sourceEnd);
5221 		} else {
5222 			this.handle(
5223 				IProblem.JavadocUsingDeprecatedType,
5224 				new String[] {new String(type.readableName())},
5225 				new String[] {new String(type.shortReadableName())},
5226 				severity,
5227 				location.sourceStart,
5228 				nodeSourceEnd(null, location, index));
5229 		}
5230 	}
5231 }
javadocDuplicatedParamTag(char[] token, int sourceStart, int sourceEnd, int modifiers)5232 public void javadocDuplicatedParamTag(char[] token, int sourceStart, int sourceEnd, int modifiers) {
5233 	int severity = computeSeverity(IProblem.JavadocDuplicateParamName);
5234 	if (severity == ProblemSeverities.Ignore) return;
5235 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5236 		String[] arguments = new String[] {String.valueOf(token)};
5237 		this.handle(
5238 			IProblem.JavadocDuplicateParamName,
5239 			arguments,
5240 			arguments,
5241 			severity,
5242 			sourceStart,
5243 			sourceEnd);
5244 	}
5245 }
javadocDuplicatedProvidesTag(int sourceStart, int sourceEnd)5246 public void javadocDuplicatedProvidesTag(int sourceStart, int sourceEnd){
5247 	this.handle(IProblem.JavadocDuplicateProvidesTag, NoArgument, NoArgument, sourceStart, sourceEnd);
5248 }
javadocDuplicatedReturnTag(int sourceStart, int sourceEnd)5249 public void javadocDuplicatedReturnTag(int sourceStart, int sourceEnd){
5250 	this.handle(IProblem.JavadocDuplicateReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd);
5251 }
javadocDuplicatedTag(char[] tagName, int sourceStart, int sourceEnd)5252 public void javadocDuplicatedTag(char[] tagName, int sourceStart, int sourceEnd){
5253 	String[] arguments = new String[] { new String(tagName) };
5254 	this.handle(
5255 		IProblem.JavadocDuplicateTag,
5256 		arguments,
5257 		arguments,
5258 		sourceStart,
5259 		sourceEnd);
5260 }
javadocDuplicatedThrowsClassName(TypeReference typeReference, int modifiers)5261 public void javadocDuplicatedThrowsClassName(TypeReference typeReference, int modifiers) {
5262 	int severity = computeSeverity(IProblem.JavadocDuplicateThrowsClassName);
5263 	if (severity == ProblemSeverities.Ignore) return;
5264 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5265 		String[] arguments = new String[] {String.valueOf(typeReference.resolvedType.sourceName())};
5266 		this.handle(
5267 			IProblem.JavadocDuplicateThrowsClassName,
5268 			arguments,
5269 			arguments,
5270 			severity,
5271 			typeReference.sourceStart,
5272 			typeReference.sourceEnd);
5273 	}
5274 }
javadocDuplicatedUsesTag( int sourceStart, int sourceEnd)5275 public void javadocDuplicatedUsesTag(
5276 
5277 		int sourceStart, int sourceEnd){
5278 	this.handle(IProblem.JavadocDuplicateUsesTag, NoArgument, NoArgument, sourceStart, sourceEnd);
5279 }
javadocEmptyReturnTag(int sourceStart, int sourceEnd, int modifiers)5280 public void javadocEmptyReturnTag(int sourceStart, int sourceEnd, int modifiers) {
5281 	int severity = computeSeverity(IProblem.JavadocEmptyReturnTag);
5282 	if (severity == ProblemSeverities.Ignore) return;
5283 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5284 		String[] arguments = new String[] { new String(JavadocTagConstants.TAG_RETURN) };
5285 		this.handle(IProblem.JavadocEmptyReturnTag, arguments, arguments, sourceStart, sourceEnd);
5286 	}
5287 }
javadocErrorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params, int modifiers)5288 public void javadocErrorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params, int modifiers) {
5289 	int id = recType.isArrayType() ? IProblem.JavadocNoMessageSendOnArrayType : IProblem.JavadocNoMessageSendOnBaseType;
5290 	int severity = computeSeverity(id);
5291 	if (severity == ProblemSeverities.Ignore) return;
5292 	StringBuffer buffer = new StringBuffer();
5293 	StringBuffer shortBuffer = new StringBuffer();
5294 	for (int i = 0, length = params.length; i < length; i++) {
5295 		if (i != 0){
5296 			buffer.append(", "); //$NON-NLS-1$
5297 			shortBuffer.append(", "); //$NON-NLS-1$
5298 		}
5299 		buffer.append(new String(params[i].readableName()));
5300 		shortBuffer.append(new String(params[i].shortReadableName()));
5301 	}
5302 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5303 		this.handle(
5304 			id,
5305 			new String[] {new String(recType.readableName()), new String(messageSend.selector), buffer.toString()},
5306 			new String[] {new String(recType.shortReadableName()), new String(messageSend.selector), shortBuffer.toString()},
5307 			severity,
5308 			messageSend.sourceStart,
5309 			messageSend.sourceEnd);
5310 	}
5311 }
javadocHiddenReference(int sourceStart, int sourceEnd, Scope scope, int modifiers)5312 public void javadocHiddenReference(int sourceStart, int sourceEnd, Scope scope, int modifiers) {
5313 	Scope currentScope = scope;
5314 	while (currentScope.parent.kind != Scope.COMPILATION_UNIT_SCOPE ) {
5315 		if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, currentScope.getDeclarationModifiers())) {
5316 			return;
5317 		}
5318 		currentScope = currentScope.parent;
5319 	}
5320 	String[] arguments = new String[] { this.options.getVisibilityString(this.options.reportInvalidJavadocTagsVisibility), this.options.getVisibilityString(modifiers) };
5321 	this.handle(IProblem.JavadocHiddenReference, arguments, arguments, sourceStart, sourceEnd);
5322 }
javadocInvalidConstructor(Statement statement, MethodBinding targetConstructor, int modifiers)5323 public void javadocInvalidConstructor(Statement statement, MethodBinding targetConstructor, int modifiers) {
5324 
5325 	if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) return;
5326 	int sourceStart = statement.sourceStart;
5327 	int sourceEnd = statement.sourceEnd;
5328 	if (statement instanceof AllocationExpression) {
5329 		AllocationExpression allocation = (AllocationExpression)statement;
5330 		if (allocation.enumConstant != null) {
5331 			sourceStart = allocation.enumConstant.sourceStart;
5332 			sourceEnd = allocation.enumConstant.sourceEnd;
5333 		}
5334 	}
5335 	int id = IProblem.JavadocUndefinedConstructor; //default...
5336 	ProblemMethodBinding problemConstructor = null;
5337 	MethodBinding shownConstructor = null;
5338 	switch (targetConstructor.problemId()) {
5339 		case ProblemReasons.NotFound :
5340 			id = IProblem.JavadocUndefinedConstructor;
5341 			break;
5342 		case ProblemReasons.NotVisible :
5343 			id = IProblem.JavadocNotVisibleConstructor;
5344 			break;
5345 		case ProblemReasons.Ambiguous :
5346 			id = IProblem.JavadocAmbiguousConstructor;
5347 			break;
5348 		case ProblemReasons.ParameterBoundMismatch :
5349 			int severity = computeSeverity(IProblem.JavadocGenericConstructorTypeArgumentMismatch);
5350 			if (severity == ProblemSeverities.Ignore) return;
5351 			problemConstructor = (ProblemMethodBinding) targetConstructor;
5352 			ParameterizedGenericMethodBinding substitutedConstructor = (ParameterizedGenericMethodBinding) problemConstructor.closestMatch;
5353 			shownConstructor = substitutedConstructor.original();
5354 
5355 			int augmentedLength = problemConstructor.parameters.length;
5356 			TypeBinding inferredTypeArgument = problemConstructor.parameters[augmentedLength-2];
5357 			TypeVariableBinding typeParameter = (TypeVariableBinding) problemConstructor.parameters[augmentedLength-1];
5358 			TypeBinding[] invocationArguments = new TypeBinding[augmentedLength-2]; // remove extra info from the end
5359 			System.arraycopy(problemConstructor.parameters, 0, invocationArguments, 0, augmentedLength-2);
5360 
5361 			this.handle(
5362 				IProblem.JavadocGenericConstructorTypeArgumentMismatch,
5363 				new String[] {
5364 				        new String(shownConstructor.declaringClass.sourceName()),
5365 				        typesAsString(shownConstructor, false),
5366 				        new String(shownConstructor.declaringClass.readableName()),
5367 				        typesAsString(invocationArguments, false),
5368 				        new String(inferredTypeArgument.readableName()),
5369 				        new String(typeParameter.sourceName()),
5370 				        parameterBoundAsString(typeParameter, false) },
5371 				new String[] {
5372 				        new String(shownConstructor.declaringClass.sourceName()),
5373 				        typesAsString(shownConstructor, true),
5374 				        new String(shownConstructor.declaringClass.shortReadableName()),
5375 				        typesAsString(invocationArguments, true),
5376 				        new String(inferredTypeArgument.shortReadableName()),
5377 				        new String(typeParameter.sourceName()),
5378 				        parameterBoundAsString(typeParameter, true) },
5379 				severity,
5380 				sourceStart,
5381 				sourceEnd);
5382 			return;
5383 
5384 		case ProblemReasons.TypeParameterArityMismatch :
5385 			problemConstructor = (ProblemMethodBinding) targetConstructor;
5386 			shownConstructor = problemConstructor.closestMatch;
5387 			boolean noTypeVariables = shownConstructor.typeVariables == Binding.NO_TYPE_VARIABLES;
5388 			severity = computeSeverity(noTypeVariables ? IProblem.JavadocNonGenericConstructor : IProblem.JavadocIncorrectArityForParameterizedConstructor);
5389 			if (severity == ProblemSeverities.Ignore) return;
5390 			if (noTypeVariables) {
5391 				this.handle(
5392 					IProblem.JavadocNonGenericConstructor,
5393 					new String[] {
5394 					        new String(shownConstructor.declaringClass.sourceName()),
5395 					        typesAsString(shownConstructor, false),
5396 					        new String(shownConstructor.declaringClass.readableName()),
5397 					        typesAsString(targetConstructor, false) },
5398 					new String[] {
5399 					        new String(shownConstructor.declaringClass.sourceName()),
5400 					        typesAsString(shownConstructor, true),
5401 					        new String(shownConstructor.declaringClass.shortReadableName()),
5402 					        typesAsString(targetConstructor, true) },
5403 					severity,
5404 					sourceStart,
5405 					sourceEnd);
5406 			} else {
5407 				this.handle(
5408 					IProblem.JavadocIncorrectArityForParameterizedConstructor,
5409 					new String[] {
5410 					        new String(shownConstructor.declaringClass.sourceName()),
5411 					        typesAsString(shownConstructor, false),
5412 					        new String(shownConstructor.declaringClass.readableName()),
5413 							typesAsString(shownConstructor.typeVariables, false),
5414 					        typesAsString(targetConstructor, false) },
5415 					new String[] {
5416 					        new String(shownConstructor.declaringClass.sourceName()),
5417 					        typesAsString(shownConstructor, true),
5418 					        new String(shownConstructor.declaringClass.shortReadableName()),
5419 							typesAsString(shownConstructor.typeVariables, true),
5420 					        typesAsString(targetConstructor, true) },
5421 					severity,
5422 					sourceStart,
5423 					sourceEnd);
5424 			}
5425 			return;
5426 		case ProblemReasons.ParameterizedMethodTypeMismatch :
5427 			severity = computeSeverity(IProblem.JavadocParameterizedConstructorArgumentTypeMismatch);
5428 			if (severity == ProblemSeverities.Ignore) return;
5429 			problemConstructor = (ProblemMethodBinding) targetConstructor;
5430 			shownConstructor = problemConstructor.closestMatch;
5431 			this.handle(
5432 				IProblem.JavadocParameterizedConstructorArgumentTypeMismatch,
5433 				new String[] {
5434 				        new String(shownConstructor.declaringClass.sourceName()),
5435 				        typesAsString(shownConstructor, false),
5436 				        new String(shownConstructor.declaringClass.readableName()),
5437 						typesAsString(((ParameterizedGenericMethodBinding)shownConstructor).typeArguments, false),
5438 				        typesAsString(targetConstructor, false) },
5439 				new String[] {
5440 				        new String(shownConstructor.declaringClass.sourceName()),
5441 				        typesAsString(shownConstructor, true),
5442 				        new String(shownConstructor.declaringClass.shortReadableName()),
5443 						typesAsString(((ParameterizedGenericMethodBinding)shownConstructor).typeArguments, true),
5444 				        typesAsString(targetConstructor, true) },
5445 				severity,
5446 				sourceStart,
5447 				sourceEnd);
5448 			return;
5449 		case ProblemReasons.TypeArgumentsForRawGenericMethod :
5450 			severity = computeSeverity(IProblem.JavadocTypeArgumentsForRawGenericConstructor);
5451 			if (severity == ProblemSeverities.Ignore) return;
5452 			problemConstructor = (ProblemMethodBinding) targetConstructor;
5453 			shownConstructor = problemConstructor.closestMatch;
5454 			this.handle(
5455 				IProblem.JavadocTypeArgumentsForRawGenericConstructor,
5456 				new String[] {
5457 				        new String(shownConstructor.declaringClass.sourceName()),
5458 				        typesAsString(shownConstructor, false),
5459 				        new String(shownConstructor.declaringClass.readableName()),
5460 				        typesAsString(targetConstructor, false) },
5461 				new String[] {
5462 				        new String(shownConstructor.declaringClass.sourceName()),
5463 				        typesAsString(shownConstructor, true),
5464 				        new String(shownConstructor.declaringClass.shortReadableName()),
5465 				        typesAsString(targetConstructor, true) },
5466 				severity,
5467 				sourceStart,
5468 				sourceEnd);
5469 			return;
5470 		case ProblemReasons.NoError : // 0
5471 		default :
5472 			needImplementation(statement); // want to fail to see why we were here...
5473 			break;
5474 	}
5475 	int severity = computeSeverity(id);
5476 	if (severity == ProblemSeverities.Ignore) return;
5477 	this.handle(
5478 		id,
5479 		new String[] {new String(targetConstructor.declaringClass.readableName()), typesAsString(targetConstructor, false)},
5480 		new String[] {new String(targetConstructor.declaringClass.shortReadableName()), typesAsString(targetConstructor, true)},
5481 		severity,
5482 		statement.sourceStart,
5483 		statement.sourceEnd);
5484 }
5485 /*
5486  * Similar implementation than invalidField(FieldReference...)
5487  * Note that following problem id cannot occur for Javadoc:
5488  * 	- NonStaticReferenceInStaticContext :
5489  * 	- NonStaticReferenceInConstructorInvocation :
5490  * 	- ReceiverTypeNotVisible :
5491  */
javadocInvalidField(FieldReference fieldRef, Binding fieldBinding, TypeBinding searchedType, int modifiers)5492 public void javadocInvalidField(FieldReference fieldRef, Binding fieldBinding, TypeBinding searchedType, int modifiers) {
5493 	int id = IProblem.JavadocUndefinedField;
5494 	switch (fieldBinding.problemId()) {
5495 		case ProblemReasons.NotFound :
5496 			id = IProblem.JavadocUndefinedField;
5497 			break;
5498 		case ProblemReasons.NotVisible :
5499 			id = IProblem.JavadocNotVisibleField;
5500 			break;
5501 		case ProblemReasons.Ambiguous :
5502 			id = IProblem.JavadocAmbiguousField;
5503 			break;
5504 		case ProblemReasons.NoError : // 0
5505 		default :
5506 			needImplementation(fieldRef); // want to fail to see why we were here...
5507 			break;
5508 	}
5509 	int severity = computeSeverity(id);
5510 	if (severity == ProblemSeverities.Ignore) return;
5511 	// report issue
5512 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5513 		String[] arguments = new String[] {new String(fieldBinding.readableName())};
5514 		handle(
5515 			id,
5516 			arguments,
5517 			arguments,
5518 			severity,
5519 			fieldRef.sourceStart,
5520 			fieldRef.sourceEnd);
5521 	}
5522 }
javadocInvalidMemberTypeQualification(int sourceStart, int sourceEnd, int modifiers)5523 public void javadocInvalidMemberTypeQualification(int sourceStart, int sourceEnd, int modifiers){
5524 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5525 		this.handle(IProblem.JavadocInvalidMemberTypeQualification, NoArgument, NoArgument, sourceStart, sourceEnd);
5526 	}
5527 }
5528 /*
5529  * Similar implementation than invalidMethod(MessageSend...)
5530  * Note that following problem id cannot occur for Javadoc:
5531  * 	- NonStaticReferenceInStaticContext :
5532  * 	- NonStaticReferenceInConstructorInvocation :
5533  * 	- ReceiverTypeNotVisible :
5534  */
javadocInvalidMethod(MessageSend messageSend, MethodBinding method, int modifiers)5535 public void javadocInvalidMethod(MessageSend messageSend, MethodBinding method, int modifiers) {
5536 	if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) return;
5537 	// set problem id
5538 	ProblemMethodBinding problemMethod = null;
5539 	MethodBinding shownMethod = null;
5540 	int id = IProblem.JavadocUndefinedMethod; //default...
5541 	switch (method.problemId()) {
5542 		case ProblemReasons.NotFound :
5543 			id = IProblem.JavadocUndefinedMethod;
5544 			problemMethod = (ProblemMethodBinding) method;
5545 			if (problemMethod.closestMatch != null) {
5546 				int severity = computeSeverity(IProblem.JavadocParameterMismatch);
5547 				if (severity == ProblemSeverities.Ignore) return;
5548 				String closestParameterTypeNames = typesAsString(problemMethod.closestMatch, false);
5549 				String parameterTypeNames = typesAsString(method, false);
5550 				String closestParameterTypeShortNames = typesAsString(problemMethod.closestMatch, true);
5551 				String parameterTypeShortNames = typesAsString(method, true);
5552 				if (closestParameterTypeShortNames.equals(parameterTypeShortNames)){
5553 					closestParameterTypeShortNames = closestParameterTypeNames;
5554 					parameterTypeShortNames = parameterTypeNames;
5555 				}
5556 				this.handle(
5557 					IProblem.JavadocParameterMismatch,
5558 					new String[] {
5559 						new String(problemMethod.closestMatch.declaringClass.readableName()),
5560 						new String(problemMethod.closestMatch.selector),
5561 						closestParameterTypeNames,
5562 						parameterTypeNames
5563 					},
5564 					new String[] {
5565 						new String(problemMethod.closestMatch.declaringClass.shortReadableName()),
5566 						new String(problemMethod.closestMatch.selector),
5567 						closestParameterTypeShortNames,
5568 						parameterTypeShortNames
5569 					},
5570 					severity,
5571 					(int) (messageSend.nameSourcePosition >>> 32),
5572 					(int) messageSend.nameSourcePosition);
5573 				return;
5574 			}
5575 			break;
5576 		case ProblemReasons.NotVisible :
5577 			id = IProblem.JavadocNotVisibleMethod;
5578 			break;
5579 		case ProblemReasons.Ambiguous :
5580 			id = IProblem.JavadocAmbiguousMethod;
5581 			break;
5582 		case ProblemReasons.ParameterBoundMismatch :
5583 			int severity = computeSeverity(IProblem.JavadocGenericMethodTypeArgumentMismatch);
5584 			if (severity == ProblemSeverities.Ignore) return;
5585 			problemMethod = (ProblemMethodBinding) method;
5586 			ParameterizedGenericMethodBinding substitutedMethod = (ParameterizedGenericMethodBinding) problemMethod.closestMatch;
5587 			shownMethod = substitutedMethod.original();
5588 			int augmentedLength = problemMethod.parameters.length;
5589 			TypeBinding inferredTypeArgument = problemMethod.parameters[augmentedLength-2];
5590 			TypeVariableBinding typeParameter = (TypeVariableBinding) problemMethod.parameters[augmentedLength-1];
5591 			TypeBinding[] invocationArguments = new TypeBinding[augmentedLength-2]; // remove extra info from the end
5592 			System.arraycopy(problemMethod.parameters, 0, invocationArguments, 0, augmentedLength-2);
5593 			this.handle(
5594 				IProblem.JavadocGenericMethodTypeArgumentMismatch,
5595 				new String[] {
5596 				        new String(shownMethod.selector),
5597 				        typesAsString(shownMethod, false),
5598 				        new String(shownMethod.declaringClass.readableName()),
5599 				        typesAsString(invocationArguments, false),
5600 				        new String(inferredTypeArgument.readableName()),
5601 				        new String(typeParameter.sourceName()),
5602 				        parameterBoundAsString(typeParameter, false) },
5603 				new String[] {
5604 				        new String(shownMethod.selector),
5605 				        typesAsString(shownMethod, true),
5606 				        new String(shownMethod.declaringClass.shortReadableName()),
5607 				        typesAsString(invocationArguments, true),
5608 				        new String(inferredTypeArgument.shortReadableName()),
5609 				        new String(typeParameter.sourceName()),
5610 				        parameterBoundAsString(typeParameter, true) },
5611 				severity,
5612 				(int) (messageSend.nameSourcePosition >>> 32),
5613 				(int) messageSend.nameSourcePosition);
5614 			return;
5615 		case ProblemReasons.TypeParameterArityMismatch :
5616 			problemMethod = (ProblemMethodBinding) method;
5617 			shownMethod = problemMethod.closestMatch;
5618 			boolean noTypeVariables = shownMethod.typeVariables == Binding.NO_TYPE_VARIABLES;
5619 			severity = computeSeverity(noTypeVariables ? IProblem.JavadocNonGenericMethod : IProblem.JavadocIncorrectArityForParameterizedMethod);
5620 			if (severity == ProblemSeverities.Ignore) return;
5621 			if (noTypeVariables) {
5622 				this.handle(
5623 					IProblem.JavadocNonGenericMethod,
5624 					new String[] {
5625 					        new String(shownMethod.selector),
5626 					        typesAsString(shownMethod, false),
5627 					        new String(shownMethod.declaringClass.readableName()),
5628 					        typesAsString(method, false) },
5629 					new String[] {
5630 					        new String(shownMethod.selector),
5631 					        typesAsString(shownMethod, true),
5632 					        new String(shownMethod.declaringClass.shortReadableName()),
5633 					        typesAsString(method, true) },
5634 					severity,
5635 					(int) (messageSend.nameSourcePosition >>> 32),
5636 					(int) messageSend.nameSourcePosition);
5637 			} else {
5638 				this.handle(
5639 					IProblem.JavadocIncorrectArityForParameterizedMethod,
5640 					new String[] {
5641 					        new String(shownMethod.selector),
5642 					        typesAsString(shownMethod, false),
5643 					        new String(shownMethod.declaringClass.readableName()),
5644 							typesAsString(shownMethod.typeVariables, false),
5645 					        typesAsString(method, false) },
5646 					new String[] {
5647 					        new String(shownMethod.selector),
5648 					        typesAsString(shownMethod, true),
5649 					        new String(shownMethod.declaringClass.shortReadableName()),
5650 							typesAsString(shownMethod.typeVariables, true),
5651 					        typesAsString(method, true) },
5652 					severity,
5653 					(int) (messageSend.nameSourcePosition >>> 32),
5654 					(int) messageSend.nameSourcePosition);
5655 			}
5656 			return;
5657 		case ProblemReasons.ParameterizedMethodTypeMismatch :
5658 			severity = computeSeverity(IProblem.JavadocParameterizedMethodArgumentTypeMismatch);
5659 			if (severity == ProblemSeverities.Ignore) return;
5660 			problemMethod = (ProblemMethodBinding) method;
5661 			shownMethod = problemMethod.closestMatch;
5662 			this.handle(
5663 				IProblem.JavadocParameterizedMethodArgumentTypeMismatch,
5664 				new String[] {
5665 				        new String(shownMethod.selector),
5666 				        typesAsString(shownMethod, false),
5667 				        new String(shownMethod.declaringClass.readableName()),
5668 						typesAsString(((ParameterizedGenericMethodBinding)shownMethod).typeArguments, false),
5669 				        typesAsString(method, false) },
5670 				new String[] {
5671 				        new String(shownMethod.selector),
5672 				        typesAsString(shownMethod, true),
5673 				        new String(shownMethod.declaringClass.shortReadableName()),
5674 						typesAsString(((ParameterizedGenericMethodBinding)shownMethod).typeArguments, true),
5675 				        typesAsString(method, true) },
5676 				severity,
5677 				(int) (messageSend.nameSourcePosition >>> 32),
5678 				(int) messageSend.nameSourcePosition);
5679 			return;
5680 		case ProblemReasons.TypeArgumentsForRawGenericMethod :
5681 			severity = computeSeverity(IProblem.JavadocTypeArgumentsForRawGenericMethod);
5682 			if (severity == ProblemSeverities.Ignore) return;
5683 			problemMethod = (ProblemMethodBinding) method;
5684 			shownMethod = problemMethod.closestMatch;
5685 			this.handle(
5686 				IProblem.JavadocTypeArgumentsForRawGenericMethod,
5687 				new String[] {
5688 				        new String(shownMethod.selector),
5689 				        typesAsString(shownMethod, false),
5690 				        new String(shownMethod.declaringClass.readableName()),
5691 				        typesAsString(method, false) },
5692 				new String[] {
5693 				        new String(shownMethod.selector),
5694 				        typesAsString(shownMethod, true),
5695 				        new String(shownMethod.declaringClass.shortReadableName()),
5696 				        typesAsString(method, true) },
5697 				severity,
5698 				(int) (messageSend.nameSourcePosition >>> 32),
5699 				(int) messageSend.nameSourcePosition);
5700 			return;
5701 		case ProblemReasons.NoError : // 0
5702 		default :
5703 			needImplementation(messageSend); // want to fail to see why we were here...
5704 			break;
5705 	}
5706 	int severity = computeSeverity(id);
5707 	if (severity == ProblemSeverities.Ignore) return;
5708 	// report issue
5709 	this.handle(
5710 		id,
5711 		new String[] {
5712 			new String(method.declaringClass.readableName()),
5713 			new String(method.selector), typesAsString(method, false)},
5714 		new String[] {
5715 			new String(method.declaringClass.shortReadableName()),
5716 			new String(method.selector), typesAsString(method, true)},
5717 		severity,
5718 		(int) (messageSend.nameSourcePosition >>> 32),
5719 		(int) messageSend.nameSourcePosition);
5720 }
javadocInvalidParamTagName(int sourceStart, int sourceEnd)5721 public void javadocInvalidParamTagName(int sourceStart, int sourceEnd) {
5722 	this.handle(IProblem.JavadocInvalidParamTagName, NoArgument, NoArgument, sourceStart, sourceEnd);
5723 }
javadocInvalidParamTypeParameter(int sourceStart, int sourceEnd)5724 public void javadocInvalidParamTypeParameter(int sourceStart, int sourceEnd) {
5725 	this.handle(IProblem.JavadocInvalidParamTagTypeParameter, NoArgument, NoArgument, sourceStart, sourceEnd);
5726 }
javadocInvalidProvidesClass(int sourceStart, int sourceEnd)5727 public void javadocInvalidProvidesClass(int sourceStart, int sourceEnd) {
5728 	this.handle(IProblem.JavadocInvalidProvidesClass, NoArgument, NoArgument, sourceStart, sourceEnd);
5729 }
5730 
javadocInvalidProvidesClassName(TypeReference typeReference, int modifiers)5731 public void javadocInvalidProvidesClassName(TypeReference typeReference, int modifiers) {
5732 	int severity = computeSeverity(IProblem.JavadocInvalidProvidesClassName);
5733 	if (severity == ProblemSeverities.Ignore) return;
5734 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5735 		String[] arguments = new String[] {String.valueOf(typeReference.resolvedType.sourceName())};
5736 		this.handle(
5737 			IProblem.JavadocInvalidProvidesClassName,
5738 			arguments,
5739 			arguments,
5740 			severity,
5741 			typeReference.sourceStart,
5742 			typeReference.sourceEnd);
5743 	}
5744 }
javadocInvalidReference(int sourceStart, int sourceEnd)5745 public void javadocInvalidReference(int sourceStart, int sourceEnd) {
5746 	this.handle(IProblem.JavadocInvalidSeeReference, NoArgument, NoArgument, sourceStart, sourceEnd);
5747 }
5748 /**
5749  * Report an invalid reference that does not conform to the href syntax.
5750  * Valid syntax example: @see IProblem.JavadocInvalidSeeHref
5751  */
javadocInvalidSeeHref(int sourceStart, int sourceEnd)5752 public void javadocInvalidSeeHref(int sourceStart, int sourceEnd) {
5753 this.handle(IProblem.JavadocInvalidSeeHref, NoArgument, NoArgument, sourceStart, sourceEnd);
5754 }
javadocInvalidSeeReferenceArgs(int sourceStart, int sourceEnd)5755 public void javadocInvalidSeeReferenceArgs(int sourceStart, int sourceEnd) {
5756 	this.handle(IProblem.JavadocInvalidSeeArgs, NoArgument, NoArgument, sourceStart, sourceEnd);
5757 }
5758 /**
5759  * Report a problem on an invalid URL reference.
5760  * Valid syntax example: @see IProblem.JavadocInvalidSeeUrlReference
5761  */
javadocInvalidSeeUrlReference(int sourceStart, int sourceEnd)5762 public void javadocInvalidSeeUrlReference(int sourceStart, int sourceEnd) {
5763 	this.handle(IProblem.JavadocInvalidSeeUrlReference, NoArgument, NoArgument, sourceStart, sourceEnd);
5764 }
javadocInvalidTag(int sourceStart, int sourceEnd)5765 public void javadocInvalidTag(int sourceStart, int sourceEnd) {
5766 	this.handle(IProblem.JavadocInvalidTag, NoArgument, NoArgument, sourceStart, sourceEnd);
5767 }
javadocInvalidThrowsClass(int sourceStart, int sourceEnd)5768 public void javadocInvalidThrowsClass(int sourceStart, int sourceEnd) {
5769 	this.handle(IProblem.JavadocInvalidThrowsClass, NoArgument, NoArgument, sourceStart, sourceEnd);
5770 }
javadocInvalidThrowsClassName(TypeReference typeReference, int modifiers)5771 public void javadocInvalidThrowsClassName(TypeReference typeReference, int modifiers) {
5772 	int severity = computeSeverity(IProblem.JavadocInvalidThrowsClassName);
5773 	if (severity == ProblemSeverities.Ignore) return;
5774 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5775 		String[] arguments = new String[] {String.valueOf(typeReference.resolvedType.sourceName())};
5776 		this.handle(
5777 			IProblem.JavadocInvalidThrowsClassName,
5778 			arguments,
5779 			arguments,
5780 			severity,
5781 			typeReference.sourceStart,
5782 			typeReference.sourceEnd);
5783 	}
5784 }
javadocInvalidType(ASTNode location, TypeBinding type, int modifiers)5785 public void javadocInvalidType(ASTNode location, TypeBinding type, int modifiers) {
5786 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5787 		int id = IProblem.JavadocUndefinedType; // default
5788 		switch (type.problemId()) {
5789 			case ProblemReasons.NotFound :
5790 				id = IProblem.JavadocUndefinedType;
5791 				break;
5792 			case ProblemReasons.NotVisible :
5793 				id = IProblem.JavadocNotVisibleType;
5794 				break;
5795 			case ProblemReasons.NotAccessible:
5796 				id = IProblem.JavadocNotAccessibleType;
5797 				break;
5798 			case ProblemReasons.Ambiguous :
5799 				id = IProblem.JavadocAmbiguousType;
5800 				break;
5801 			case ProblemReasons.InternalNameProvided :
5802 				id = IProblem.JavadocInternalTypeNameProvided;
5803 				break;
5804 			case ProblemReasons.InheritedNameHidesEnclosingName :
5805 				id = IProblem.JavadocInheritedNameHidesEnclosingTypeName;
5806 				break;
5807 			case ProblemReasons.NonStaticReferenceInStaticContext :
5808 				id = IProblem.JavadocNonStaticTypeFromStaticInvocation;
5809 			    break;
5810 			case ProblemReasons.NoError : // 0
5811 			default :
5812 				needImplementation(location); // want to fail to see why we were here...
5813 				break;
5814 		}
5815 		int severity = computeSeverity(id);
5816 		if (severity == ProblemSeverities.Ignore) return;
5817 		this.handle(
5818 			id,
5819 			new String[] {new String(type.readableName())},
5820 			new String[] {new String(type.shortReadableName())},
5821 			severity,
5822 			location.sourceStart,
5823 			location.sourceEnd);
5824 	}
5825 }
javadocInvalidUsesClass(int sourceStart, int sourceEnd)5826 public void javadocInvalidUsesClass(int sourceStart, int sourceEnd) {
5827 	this.handle(IProblem.JavadocInvalidUsesClass, NoArgument, NoArgument, sourceStart, sourceEnd);
5828 }
5829 
javadocInvalidUsesClassName(TypeReference typeReference, int modifiers)5830 public void javadocInvalidUsesClassName(TypeReference typeReference, int modifiers) {
5831 	int severity = computeSeverity(IProblem.JavadocInvalidUsesClassName);
5832 	if (severity == ProblemSeverities.Ignore) return;
5833 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5834 		String[] arguments = new String[] {String.valueOf(typeReference.resolvedType.sourceName())};
5835 		this.handle(
5836 			IProblem.JavadocInvalidUsesClassName,
5837 			arguments,
5838 			arguments,
5839 			severity,
5840 			typeReference.sourceStart,
5841 			typeReference.sourceEnd);
5842 	}
5843 }
javadocInvalidValueReference(int sourceStart, int sourceEnd, int modifiers)5844 public void javadocInvalidValueReference(int sourceStart, int sourceEnd, int modifiers) {
5845 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
5846 		this.handle(IProblem.JavadocInvalidValueReference, NoArgument, NoArgument, sourceStart, sourceEnd);
5847 }
javadocMalformedSeeReference(int sourceStart, int sourceEnd)5848 public void javadocMalformedSeeReference(int sourceStart, int sourceEnd) {
5849 	this.handle(IProblem.JavadocMalformedSeeReference, NoArgument, NoArgument, sourceStart, sourceEnd);
5850 }
javadocMissing(int sourceStart, int sourceEnd, int modifiers)5851 public void javadocMissing(int sourceStart, int sourceEnd, int modifiers){
5852 	int severity = computeSeverity(IProblem.JavadocMissing);
5853 	this.javadocMissing(sourceStart, sourceEnd, severity, modifiers);
5854 }
javadocMissing(int sourceStart, int sourceEnd, int severity, int modifiers)5855 public void javadocMissing(int sourceStart, int sourceEnd, int severity, int modifiers){
5856 	if (severity == ProblemSeverities.Ignore) return;
5857 	boolean overriding = (modifiers & (ExtraCompilerModifiers.AccImplementing|ExtraCompilerModifiers.AccOverriding)) != 0;
5858 	boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocComments) != ProblemSeverities.Ignore)
5859 					&& (!overriding || this.options.reportMissingJavadocCommentsOverriding);
5860 	if (report) {
5861 		String arg = javadocVisibilityArgument(this.options.reportMissingJavadocCommentsVisibility, modifiers);
5862 		if (arg != null) {
5863 			String[] arguments = new String[] { arg };
5864 			this.handle(
5865 				IProblem.JavadocMissing,
5866 				arguments,
5867 				arguments,
5868 				severity,
5869 				sourceStart,
5870 				sourceEnd);
5871 		}
5872 	}
5873 }
javadocModuleMissing(int sourceStart, int sourceEnd, int severity)5874 public void javadocModuleMissing(int sourceStart, int sourceEnd, int severity){
5875 	if (severity == ProblemSeverities.Ignore) return;
5876 	boolean report = this.options.getSeverity(CompilerOptions.MissingJavadocComments) != ProblemSeverities.Ignore;
5877 	if (report) {
5878 			String[] arguments = new String[] { "module" }; //$NON-NLS-1$
5879 			this.handle(
5880 				IProblem.JavadocMissing,
5881 				arguments,
5882 				arguments,
5883 				severity,
5884 				sourceStart,
5885 				sourceEnd);
5886 	}
5887 }
javadocMissingHashCharacter(int sourceStart, int sourceEnd, String ref)5888 public void javadocMissingHashCharacter(int sourceStart, int sourceEnd, String ref){
5889 	int severity = computeSeverity(IProblem.JavadocMissingHashCharacter);
5890 	if (severity == ProblemSeverities.Ignore) return;
5891 	String[] arguments = new String[] { ref };
5892 	this.handle(
5893 		IProblem.JavadocMissingHashCharacter,
5894 		arguments,
5895 		arguments,
5896 		severity,
5897 		sourceStart,
5898 		sourceEnd);
5899 }
javadocMissingIdentifier(int sourceStart, int sourceEnd, int modifiers)5900 public void javadocMissingIdentifier(int sourceStart, int sourceEnd, int modifiers){
5901 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
5902 		this.handle(IProblem.JavadocMissingIdentifier, NoArgument, NoArgument, sourceStart, sourceEnd);
5903 }
javadocMissingParamName(int sourceStart, int sourceEnd, int modifiers)5904 public void javadocMissingParamName(int sourceStart, int sourceEnd, int modifiers){
5905 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
5906 		this.handle(IProblem.JavadocMissingParamName, NoArgument, NoArgument, sourceStart, sourceEnd);
5907 }
javadocMissingParamTag(char[] name, int sourceStart, int sourceEnd, int modifiers)5908 public void javadocMissingParamTag(char[] name, int sourceStart, int sourceEnd, int modifiers) {
5909 	int severity = computeSeverity(IProblem.JavadocMissingParamTag);
5910 	if (severity == ProblemSeverities.Ignore) return;
5911 	boolean overriding = (modifiers & (ExtraCompilerModifiers.AccImplementing|ExtraCompilerModifiers.AccOverriding)) != 0;
5912 	boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore)
5913 					&& (!overriding || this.options.reportMissingJavadocTagsOverriding);
5914 	if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) {
5915 		String[] arguments = new String[] { String.valueOf(name) };
5916 		this.handle(
5917 			IProblem.JavadocMissingParamTag,
5918 			arguments,
5919 			arguments,
5920 			severity,
5921 			sourceStart,
5922 			sourceEnd);
5923 	}
5924 }
javadocMissingProvidesClassName(int sourceStart, int sourceEnd, int modifiers)5925 public void javadocMissingProvidesClassName(int sourceStart, int sourceEnd, int modifiers){
5926 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5927 		this.handle(IProblem.JavadocMissingProvidesClassName, NoArgument, NoArgument, sourceStart, sourceEnd);
5928 	}
5929 }
javadocMissingProvidesTag(TypeReference typeRef, int sourceStart, int sourceEnd, int modifiers)5930 public void javadocMissingProvidesTag(TypeReference typeRef, int sourceStart, int sourceEnd, int modifiers){
5931 	int severity = computeSeverity(IProblem.JavadocMissingProvidesTag);
5932 	if (severity == ProblemSeverities.Ignore) return;
5933 	boolean report = this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore;
5934 	if (report) {
5935 		String[] arguments = new String[] { String.valueOf(typeRef.resolvedType.sourceName()) };
5936 		this.handle(
5937 			IProblem.JavadocMissingProvidesTag,
5938 			arguments,
5939 			arguments,
5940 			severity,
5941 			sourceStart,
5942 			sourceEnd);
5943 	}
5944 }
javadocMissingReference(int sourceStart, int sourceEnd, int modifiers)5945 public void javadocMissingReference(int sourceStart, int sourceEnd, int modifiers){
5946 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers))
5947 		this.handle(IProblem.JavadocMissingSeeReference, NoArgument, NoArgument, sourceStart, sourceEnd);
5948 }
javadocMissingReturnTag(int sourceStart, int sourceEnd, int modifiers)5949 public void javadocMissingReturnTag(int sourceStart, int sourceEnd, int modifiers){
5950 	boolean overriding = (modifiers & (ExtraCompilerModifiers.AccImplementing|ExtraCompilerModifiers.AccOverriding)) != 0;
5951 	boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore)
5952 					&& (!overriding || this.options.reportMissingJavadocTagsOverriding);
5953 	if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) {
5954 		this.handle(IProblem.JavadocMissingReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd);
5955 	}
5956 }
javadocMissingTagDescription(char[] tokenName, int sourceStart, int sourceEnd, int modifiers)5957 public void javadocMissingTagDescription(char[] tokenName, int sourceStart, int sourceEnd, int modifiers) {
5958 	int severity = computeSeverity(IProblem.JavadocMissingTagDescription);
5959 	if (severity == ProblemSeverities.Ignore) return;
5960 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5961 		String[] arguments = new String[] { new String(tokenName) };
5962 		// use IProblem.JavadocEmptyReturnTag for all identified tags
5963 		this.handle(IProblem.JavadocEmptyReturnTag, arguments, arguments, sourceStart, sourceEnd);
5964 	}
5965 }
javadocMissingTagDescriptionAfterReference(int sourceStart, int sourceEnd, int modifiers)5966 public void javadocMissingTagDescriptionAfterReference(int sourceStart, int sourceEnd, int modifiers){
5967 	int severity = computeSeverity(IProblem.JavadocMissingTagDescription);
5968 	if (severity == ProblemSeverities.Ignore) return;
5969 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5970 		this.handle(IProblem.JavadocMissingTagDescription, NoArgument, NoArgument, severity, sourceStart, sourceEnd);
5971 	}
5972 }
javadocMissingThrowsClassName(int sourceStart, int sourceEnd, int modifiers)5973 public void javadocMissingThrowsClassName(int sourceStart, int sourceEnd, int modifiers){
5974 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5975 		this.handle(IProblem.JavadocMissingThrowsClassName, NoArgument, NoArgument, sourceStart, sourceEnd);
5976 	}
5977 }
javadocMissingThrowsTag(TypeReference typeRef, int modifiers)5978 public void javadocMissingThrowsTag(TypeReference typeRef, int modifiers){
5979 	int severity = computeSeverity(IProblem.JavadocMissingThrowsTag);
5980 	if (severity == ProblemSeverities.Ignore) return;
5981 	boolean overriding = (modifiers & (ExtraCompilerModifiers.AccImplementing|ExtraCompilerModifiers.AccOverriding)) != 0;
5982 	boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore)
5983 					&& (!overriding || this.options.reportMissingJavadocTagsOverriding);
5984 	if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) {
5985 		String[] arguments = new String[] { String.valueOf(typeRef.resolvedType.sourceName()) };
5986 		this.handle(
5987 			IProblem.JavadocMissingThrowsTag,
5988 			arguments,
5989 			arguments,
5990 			severity,
5991 			typeRef.sourceStart,
5992 			typeRef.sourceEnd);
5993 	}
5994 }
javadocMissingUsesClassName(int sourceStart, int sourceEnd, int modifiers)5995 public void javadocMissingUsesClassName(int sourceStart, int sourceEnd, int modifiers){
5996 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
5997 		this.handle(IProblem.JavadocMissingUsesClassName, NoArgument, NoArgument, sourceStart, sourceEnd);
5998 	}
5999 }
6000 
javadocMissingUsesTag(TypeReference typeRef, int sourceStart, int sourceEnd, int modifiers)6001 public void javadocMissingUsesTag(TypeReference typeRef, int sourceStart, int sourceEnd, int modifiers){
6002 	int severity = computeSeverity(IProblem.JavadocMissingUsesTag);
6003 	if (severity == ProblemSeverities.Ignore) return;
6004 	boolean report = this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore;
6005 	if (report) {
6006 		String[] arguments = new String[] { String.valueOf(typeRef.resolvedType.sourceName()) };
6007 		this.handle(
6008 			IProblem.JavadocMissingUsesTag,
6009 			arguments,
6010 			arguments,
6011 			severity,
6012 			sourceStart,
6013 			sourceEnd);
6014 	}
6015 }
javadocUndeclaredParamTagName(char[] token, int sourceStart, int sourceEnd, int modifiers)6016 public void javadocUndeclaredParamTagName(char[] token, int sourceStart, int sourceEnd, int modifiers) {
6017 	int severity = computeSeverity(IProblem.JavadocInvalidParamName);
6018 	if (severity == ProblemSeverities.Ignore) return;
6019 	if (javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) {
6020 		String[] arguments = new String[] {String.valueOf(token)};
6021 		this.handle(
6022 			IProblem.JavadocInvalidParamName,
6023 			arguments,
6024 			arguments,
6025 			severity,
6026 			sourceStart,
6027 			sourceEnd);
6028 	}
6029 }
6030 
javadocUnexpectedTag(int sourceStart, int sourceEnd)6031 public void javadocUnexpectedTag(int sourceStart, int sourceEnd) {
6032 	this.handle(IProblem.JavadocUnexpectedTag, NoArgument, NoArgument, sourceStart, sourceEnd);
6033 }
6034 
javadocUnexpectedText(int sourceStart, int sourceEnd)6035 public void javadocUnexpectedText(int sourceStart, int sourceEnd) {
6036 	this.handle(IProblem.JavadocUnexpectedText, NoArgument, NoArgument, sourceStart, sourceEnd);
6037 }
6038 
javadocUnterminatedInlineTag(int sourceStart, int sourceEnd)6039 public void javadocUnterminatedInlineTag(int sourceStart, int sourceEnd) {
6040 	this.handle(IProblem.JavadocUnterminatedInlineTag, NoArgument, NoArgument, sourceStart, sourceEnd);
6041 }
6042 
javadocVisibility(int visibility, int modifiers)6043 private boolean javadocVisibility(int visibility, int modifiers) {
6044 	if (modifiers < 0) return true;
6045 	switch (modifiers & ExtraCompilerModifiers.AccVisibilityMASK) {
6046 		case ClassFileConstants.AccPublic :
6047 			return true;
6048 		case ClassFileConstants.AccProtected:
6049 			return (visibility != ClassFileConstants.AccPublic);
6050 		case ClassFileConstants.AccDefault:
6051 			return (visibility == ClassFileConstants.AccDefault || visibility == ClassFileConstants.AccPrivate);
6052 		case ClassFileConstants.AccPrivate:
6053 			return (visibility == ClassFileConstants.AccPrivate);
6054 	}
6055 	return true;
6056 }
6057 
javadocVisibilityArgument(int visibility, int modifiers)6058 private String javadocVisibilityArgument(int visibility, int modifiers) {
6059 	String argument = null;
6060 	switch (modifiers & ExtraCompilerModifiers.AccVisibilityMASK) {
6061 		case ClassFileConstants.AccPublic :
6062 			argument = CompilerOptions.PUBLIC;
6063 			break;
6064 		case ClassFileConstants.AccProtected:
6065 			if (visibility != ClassFileConstants.AccPublic) {
6066 				argument = CompilerOptions.PROTECTED;
6067 			}
6068 			break;
6069 		case ClassFileConstants.AccDefault:
6070 			if (visibility == ClassFileConstants.AccDefault || visibility == ClassFileConstants.AccPrivate) {
6071 				argument = CompilerOptions.DEFAULT;
6072 			}
6073 			break;
6074 		case ClassFileConstants.AccPrivate:
6075 			if (visibility == ClassFileConstants.AccPrivate) {
6076 				argument = CompilerOptions.PRIVATE;
6077 			}
6078 			break;
6079 	}
6080 	return argument;
6081 }
6082 
localVariableHiding(LocalDeclaration local, Binding hiddenVariable, boolean isSpecialArgHidingField)6083 public void localVariableHiding(LocalDeclaration local, Binding hiddenVariable, boolean  isSpecialArgHidingField) {
6084 	if (hiddenVariable instanceof LocalVariableBinding) {
6085 		int id = (local instanceof Argument)
6086 				? IProblem.ArgumentHidingLocalVariable
6087 				: IProblem.LocalVariableHidingLocalVariable;
6088 		int severity = computeSeverity(id);
6089 		if (severity == ProblemSeverities.Ignore) return;
6090 		String[] arguments = new String[] {new String(local.name)  };
6091 		this.handle(
6092 			id,
6093 			arguments,
6094 			arguments,
6095 			severity,
6096 			nodeSourceStart(hiddenVariable, local),
6097 			nodeSourceEnd(hiddenVariable, local));
6098 	} else if (hiddenVariable instanceof FieldBinding) {
6099 		if (isSpecialArgHidingField && !this.options.reportSpecialParameterHidingField){
6100 			return;
6101 		}
6102 		int id = (local instanceof Argument)
6103 				? IProblem.ArgumentHidingField
6104 				: IProblem.LocalVariableHidingField;
6105 		int severity = computeSeverity(id);
6106 		if (severity == ProblemSeverities.Ignore) return;
6107 		FieldBinding field = (FieldBinding) hiddenVariable;
6108 		this.handle(
6109 			id,
6110 			new String[] {new String(local.name) , new String(field.declaringClass.readableName()) },
6111 			new String[] {new String(local.name), new String(field.declaringClass.shortReadableName()) },
6112 			severity,
6113 			local.sourceStart,
6114 			local.sourceEnd);
6115 	}
6116 }
6117 
localVariableNonNullComparedToNull(LocalVariableBinding local, ASTNode location)6118 public void localVariableNonNullComparedToNull(LocalVariableBinding local, ASTNode location) {
6119 	int severity = computeSeverity(IProblem.NonNullLocalVariableComparisonYieldsFalse);
6120 	if (severity == ProblemSeverities.Ignore) return;
6121 	String[] arguments;
6122 	int problemId;
6123 	if (local.isNonNull()) {
6124 		char[][] annotationName = this.options.nonNullAnnotationName; // cannot be null if local is declared @NonNull
6125 		arguments = new String[] {new String(local.name), new String(annotationName[annotationName.length-1])  };
6126 		problemId = IProblem.SpecdNonNullLocalVariableComparisonYieldsFalse;
6127 	} else {
6128 		arguments = new String[] {new String(local.name)  };
6129 		problemId = IProblem.NonNullLocalVariableComparisonYieldsFalse;
6130 	}
6131 	this.handle(
6132 		problemId,
6133 		arguments,
6134 		arguments,
6135 		severity,
6136 		nodeSourceStart(local, location),
6137 		nodeSourceEnd(local, location));
6138 }
6139 
localVariableNullComparedToNonNull(LocalVariableBinding local, ASTNode location)6140 public void localVariableNullComparedToNonNull(LocalVariableBinding local, ASTNode location) {
6141 	int severity = computeSeverity(IProblem.NullLocalVariableComparisonYieldsFalse);
6142 	if (severity == ProblemSeverities.Ignore) return;
6143 	String[] arguments = new String[] {new String(local.name)  };
6144 	this.handle(
6145 		IProblem.NullLocalVariableComparisonYieldsFalse,
6146 		arguments,
6147 		arguments,
6148 		severity,
6149 		nodeSourceStart(local, location),
6150 		nodeSourceEnd(local, location));
6151 }
6152 
6153 /**
6154  * @param expr expression being compared for null or nonnull
6155  * @param checkForNull true if checking for null, false if checking for nonnull
6156  */
expressionNonNullComparison(Expression expr, boolean checkForNull)6157 public boolean expressionNonNullComparison(Expression expr, boolean checkForNull) {
6158 	int problemId = 0;
6159 	Binding binding = null;
6160 	String[] arguments = null;
6161 	int start = 0, end = 0;
6162 	Expression location = expr;
6163 
6164 	if (expr.resolvedType != null) {
6165 		long tagBits = expr.resolvedType.tagBits & TagBits.AnnotationNullMASK;
6166 		if (tagBits == TagBits.AnnotationNonNull) {
6167 			problemId = IProblem.RedundantNullCheckAgainstNonNullType;
6168 			arguments = new String[] { String.valueOf(expr.resolvedType.nullAnnotatedReadableName(this.options, true)) };
6169 			start = nodeSourceStart(location);
6170 			end = nodeSourceEnd(location);
6171 			handle(problemId, arguments, arguments, start, end);
6172 			return true;
6173 		}
6174 	}
6175 	// unwrap uninteresting nodes:
6176 	while (true) {
6177 		if (expr instanceof Assignment)
6178 			return false; // don't report against the assignment, but the variable
6179 		else if (expr instanceof CastExpression)
6180 			expr = ((CastExpression) expr).expression;
6181 		else
6182 			break;
6183 	}
6184 	// check all those kinds of expressions that can possible answer NON_NULL from nullStatus():
6185 	if (expr instanceof MessageSend) {
6186 		problemId = checkForNull
6187 				? IProblem.NonNullMessageSendComparisonYieldsFalse
6188 				: IProblem.RedundantNullCheckOnNonNullMessageSend;
6189 		MethodBinding method = ((MessageSend)expr).binding;
6190 		binding = method;
6191 		arguments = new String[] { new String(method.shortReadableName()) };
6192 		start = location.sourceStart;
6193 		end = location.sourceEnd;
6194 	} else if (expr instanceof Reference && !(expr instanceof ThisReference) && !(expr instanceof ArrayReference)) {
6195 		FieldBinding field = ((Reference)expr).lastFieldBinding();
6196 		if (field == null) {
6197 			return false;
6198 		}
6199 		if (field.isNonNull()) {
6200 			problemId = checkForNull
6201 					? IProblem.NonNullSpecdFieldComparisonYieldsFalse
6202 					: IProblem.RedundantNullCheckOnNonNullSpecdField;
6203 			char[][] nonNullName = this.options.nonNullAnnotationName;
6204 			arguments = new String[] { new String(field.name),
6205 									   new String(nonNullName[nonNullName.length-1]) };
6206 		} else if (field.constant() != Constant.NotAConstant) {
6207 			problemId = checkForNull ? IProblem.ConstNonNullFieldComparisonYieldsFalse : IProblem.RedundantNullCheckOnConstNonNullField;
6208 			char[][] nonNullName = this.options.nonNullAnnotationName;
6209 			arguments = new String[] { new String(field.name),
6210 									   new String(nonNullName[nonNullName.length-1]) };
6211 		} else {
6212 			// signaling redundancy based on syntactic analysis:
6213 			problemId = checkForNull
6214 					? IProblem.FieldComparisonYieldsFalse
6215 					: IProblem.RedundantNullCheckOnField;
6216 			arguments = new String[] { String.valueOf(field.name)};
6217 		}
6218 		binding = field;
6219 		start = nodeSourceStart(binding, location);
6220 		end = nodeSourceEnd(binding, location);
6221 	} else if (expr instanceof AllocationExpression
6222 			|| expr instanceof ArrayAllocationExpression
6223 			|| expr instanceof ArrayInitializer
6224 			|| expr instanceof ClassLiteralAccess
6225 			|| expr instanceof ThisReference) {
6226 		// fall through to bottom
6227 	} else if (expr instanceof Literal
6228 				|| expr instanceof ConditionalExpression
6229 				|| expr instanceof SwitchExpression) {
6230 		if (expr instanceof NullLiteral) {
6231 			needImplementation(location); // reported as nonnull??
6232 			return false;
6233 		}
6234 		if (expr.resolvedType != null && expr.resolvedType.isBaseType()) {
6235 			// false alarm, auto(un)boxing is involved
6236 			return false;
6237 		}
6238 		// fall through to bottom
6239 	} else if (expr instanceof BinaryExpression) {
6240 		if ((expr.bits & ASTNode.ReturnTypeIDMASK) != TypeIds.T_JavaLangString) {
6241 			// false alarm, primitive types involved, must be auto(un)boxing?
6242 			return false;
6243 		}
6244 		// fall through to bottom
6245 	} else {
6246 		needImplementation(expr); // want to see if we get here
6247 		return false;
6248 	}
6249 	if (problemId == 0) {
6250 		// standard case, fill in details now
6251 		problemId = checkForNull
6252 				? IProblem.NonNullExpressionComparisonYieldsFalse
6253 				: IProblem.RedundantNullCheckOnNonNullExpression;
6254 		start = location.sourceStart;
6255 		end = location.sourceEnd;
6256 		arguments = NoArgument;
6257 	}
6258 	this.handle(problemId, arguments, arguments, start, end);
6259 	return true;
6260 }
nullAnnotationUnsupportedLocation(Annotation annotation)6261 public void nullAnnotationUnsupportedLocation(Annotation annotation) {
6262 	String[] arguments = new String[] {
6263 		String.valueOf(annotation.resolvedType.readableName())
6264 	};
6265 	String[] shortArguments = new String[] {
6266 		String.valueOf(annotation.resolvedType.shortReadableName())
6267 	};
6268 	int severity = ProblemSeverities.Error | ProblemSeverities.Fatal;
6269 	if (annotation.recipient instanceof ReferenceBinding) {
6270 		if (((ReferenceBinding) annotation.recipient).isAnnotationType())
6271 			severity = ProblemSeverities.Warning; // special case for https://bugs.eclipse.org/461878
6272 	}
6273 	handle(IProblem.NullAnnotationUnsupportedLocation,
6274 			arguments, shortArguments,
6275 			severity,
6276 			annotation.sourceStart, annotation.sourceEnd);
6277 }
nullAnnotationAtQualifyingType(Annotation annotation)6278 public void nullAnnotationAtQualifyingType(Annotation annotation) {
6279 	String[] arguments = new String[] {
6280 		String.valueOf(annotation.resolvedType.readableName())
6281 	};
6282 	String[] shortArguments = new String[] {
6283 		String.valueOf(annotation.resolvedType.shortReadableName())
6284 	};
6285 	int severity = ProblemSeverities.Error | ProblemSeverities.Fatal;
6286 	handle(IProblem.NullAnnotationAtQualifyingType,
6287 			arguments, shortArguments,
6288 			severity,
6289 			annotation.sourceStart, annotation.sourceEnd);
6290 }
nullAnnotationUnsupportedLocation(TypeReference type)6291 public void nullAnnotationUnsupportedLocation(TypeReference type) {
6292 	int sourceEnd = type.sourceEnd;
6293 	if (type instanceof ParameterizedSingleTypeReference) {
6294 		ParameterizedSingleTypeReference typeReference = (ParameterizedSingleTypeReference) type;
6295 		TypeReference[] typeArguments = typeReference.typeArguments;
6296 		if (typeArguments[typeArguments.length - 1].sourceEnd > typeReference.sourceEnd) {
6297 			sourceEnd = retrieveClosingAngleBracketPosition(typeReference.sourceEnd);
6298 		} else {
6299 			sourceEnd = type.sourceEnd;
6300 		}
6301 	} else if (type instanceof ParameterizedQualifiedTypeReference) {
6302 		ParameterizedQualifiedTypeReference typeReference = (ParameterizedQualifiedTypeReference) type;
6303 		sourceEnd = retrieveClosingAngleBracketPosition(typeReference.sourceEnd);
6304 	} else {
6305 		sourceEnd = type.sourceEnd;
6306 	}
6307 
6308 	handle(IProblem.NullAnnotationUnsupportedLocationAtType,
6309 		NoArgument, NoArgument, type.sourceStart, sourceEnd);
6310 }
localVariableNullInstanceof(LocalVariableBinding local, ASTNode location)6311 public void localVariableNullInstanceof(LocalVariableBinding local, ASTNode location) {
6312 	int severity = computeSeverity(IProblem.NullLocalVariableInstanceofYieldsFalse);
6313 	if (severity == ProblemSeverities.Ignore) return;
6314 	String[] arguments = new String[] {new String(local.name)  };
6315 	this.handle(
6316 		IProblem.NullLocalVariableInstanceofYieldsFalse,
6317 		arguments,
6318 		arguments,
6319 		severity,
6320 		nodeSourceStart(local, location),
6321 		nodeSourceEnd(local, location));
6322 }
6323 
localVariableNullReference(LocalVariableBinding local, ASTNode location)6324 public void localVariableNullReference(LocalVariableBinding local, ASTNode location) {
6325 	if (location instanceof Expression &&  ((Expression) location).isTrulyExpression() &&
6326 			(((Expression)location).implicitConversion & TypeIds.UNBOXING) != 0) {
6327 		nullUnboxing(location, local.type);
6328 		return;
6329 	}
6330 	int severity = computeSeverity(IProblem.NullLocalVariableReference);
6331 	if (severity == ProblemSeverities.Ignore) return;
6332 	String[] arguments = new String[] {new String(local.name)  };
6333 	this.handle(
6334 		IProblem.NullLocalVariableReference,
6335 		arguments,
6336 		arguments,
6337 		severity,
6338 		nodeSourceStart(local, location),
6339 		nodeSourceEnd(local, location));
6340 }
6341 
fieldFreeTypeVariableReference(FieldBinding variable, long position)6342 public void fieldFreeTypeVariableReference(FieldBinding variable, long position) {
6343 	char[][] nullableName = this.options.nullableAnnotationName;
6344 	String[] arguments = new String[] {new String(variable.type.readableName()),
6345 			new String(nullableName[nullableName.length-1])};
6346 	this.handle(
6347 		IProblem.UncheckedAccessOfValueOfFreeTypeVariable,
6348 		arguments,
6349 		arguments,
6350 		(int)(position >>> 32),
6351 		(int)position);
6352 }
6353 
6354 
localVariableFreeTypeVariableReference(LocalVariableBinding local, ASTNode location)6355 public void localVariableFreeTypeVariableReference(LocalVariableBinding local, ASTNode location) {
6356 	int severity = computeSeverity(IProblem.UncheckedAccessOfValueOfFreeTypeVariable);
6357 	if (severity == ProblemSeverities.Ignore) return;
6358 	char[][] nullableName = this.options.nullableAnnotationName;
6359 	String[] arguments = new String[] {new String(local.type.readableName()),
6360 			new String(nullableName[nullableName.length-1])};
6361 	this.handle(
6362 		IProblem.UncheckedAccessOfValueOfFreeTypeVariable,
6363 		arguments,
6364 		arguments,
6365 		severity,
6366 		nodeSourceStart(local, location),
6367 		nodeSourceEnd(local, location));
6368 }
6369 
methodReturnTypeFreeTypeVariableReference(MethodBinding method, ASTNode location)6370 public void methodReturnTypeFreeTypeVariableReference(MethodBinding method, ASTNode location) {
6371 	int severity = computeSeverity(IProblem.UncheckedAccessOfValueOfFreeTypeVariable);
6372 	if (severity == ProblemSeverities.Ignore) return;
6373 	char[][] nullableName = this.options.nullableAnnotationName;
6374 	String[] arguments = new String[] {new String(method.returnType.readableName()),
6375 			new String(nullableName[nullableName.length-1])};
6376 	this.handle(
6377 		IProblem.UncheckedAccessOfValueOfFreeTypeVariable,
6378 		arguments,
6379 		arguments,
6380 		location.sourceStart,
6381 		location.sourceEnd);
6382 }
6383 
6384 
localVariablePotentialNullReference(LocalVariableBinding local, ASTNode location)6385 public void localVariablePotentialNullReference(LocalVariableBinding local, ASTNode location) {
6386 	if(local.type.isFreeTypeVariable()) {
6387 		localVariableFreeTypeVariableReference(local, location);
6388 		return;
6389 	}
6390 	if (location instanceof Expression &&  ((Expression) location).isTrulyExpression()
6391 			&& (((Expression)location).implicitConversion & TypeIds.UNBOXING) != 0) {
6392 		potentialNullUnboxing(location, local.type);
6393 		return;
6394 	}
6395 	if ((local.type.tagBits & TagBits.AnnotationNullable) != 0 && location instanceof Expression
6396 			&&  ((Expression) location).isTrulyExpression()) {
6397 		dereferencingNullableExpression((Expression) location);
6398 		return;
6399 	}
6400 	int severity = computeSeverity(IProblem.PotentialNullLocalVariableReference);
6401 	if (severity == ProblemSeverities.Ignore) return;
6402 	String[] arguments = new String[] {new String(local.name)};
6403 	this.handle(
6404 		IProblem.PotentialNullLocalVariableReference,
6405 		arguments,
6406 		arguments,
6407 		severity,
6408 		nodeSourceStart(local, location),
6409 		nodeSourceEnd(local, location));
6410 }
potentialNullUnboxing(ASTNode expression, TypeBinding boxType)6411 public void potentialNullUnboxing(ASTNode expression, TypeBinding boxType) {
6412 	String[] arguments = new String[] { String.valueOf(boxType.readableName()) };
6413 	String[] argumentsShort = new String[] { String.valueOf(boxType.shortReadableName()) };
6414 	this.handle(IProblem.PotentialNullUnboxing, arguments, argumentsShort, expression.sourceStart, expression.sourceEnd);
6415 }
nullUnboxing(ASTNode expression, TypeBinding boxType)6416 public void nullUnboxing(ASTNode expression, TypeBinding boxType) {
6417 	String[] arguments = new String[] { String.valueOf(boxType.readableName()) };
6418 	String[] argumentsShort = new String[] { String.valueOf(boxType.shortReadableName()) };
6419 	this.handle(IProblem.NullUnboxing, arguments, argumentsShort, expression.sourceStart, expression.sourceEnd);
6420 }
nullableFieldDereference(FieldBinding variable, long position)6421 public void nullableFieldDereference(FieldBinding variable, long position) {
6422 	char[][] nullableName = this.options.nullableAnnotationName;
6423 	String[] arguments = new String[] {new String(variable.name), new String(nullableName[nullableName.length-1])};
6424 	this.handle(
6425 		IProblem.NullableFieldReference,
6426 		arguments,
6427 		arguments,
6428 		(int)(position >>> 32),
6429 		(int)position);
6430 }
6431 
localVariableRedundantCheckOnNonNull(LocalVariableBinding local, ASTNode location)6432 public void localVariableRedundantCheckOnNonNull(LocalVariableBinding local, ASTNode location) {
6433 	int severity = computeSeverity(IProblem.RedundantNullCheckOnNonNullLocalVariable);
6434 	if (severity == ProblemSeverities.Ignore) return;
6435 	String[] arguments;
6436 	int problemId;
6437 	if (local.isNonNull()) {
6438 		char[][] annotationName = this.options.nonNullAnnotationName; // cannot be null if local is declared @NonNull
6439 		arguments = new String[] {new String(local.name), new String(annotationName[annotationName.length-1])  };
6440 		problemId = IProblem.RedundantNullCheckOnSpecdNonNullLocalVariable;
6441 	} else {
6442 		arguments = new String[] {new String(local.name)  };
6443 		problemId = IProblem.RedundantNullCheckOnNonNullLocalVariable;
6444 	}
6445 	this.handle(
6446 		problemId,
6447 		arguments,
6448 		arguments,
6449 		severity,
6450 		nodeSourceStart(local, location),
6451 		nodeSourceEnd(local, location));
6452 }
6453 
localVariableRedundantCheckOnNull(LocalVariableBinding local, ASTNode location)6454 public void localVariableRedundantCheckOnNull(LocalVariableBinding local, ASTNode location) {
6455 	int severity = computeSeverity(IProblem.RedundantNullCheckOnNullLocalVariable);
6456 	if (severity == ProblemSeverities.Ignore) return;
6457 	String[] arguments = new String[] {new String(local.name)  };
6458 	this.handle(
6459 		IProblem.RedundantNullCheckOnNullLocalVariable,
6460 		arguments,
6461 		arguments,
6462 		severity,
6463 		nodeSourceStart(local, location),
6464 		nodeSourceEnd(local, location));
6465 }
6466 
localVariableRedundantNullAssignment(LocalVariableBinding local, ASTNode location)6467 public void localVariableRedundantNullAssignment(LocalVariableBinding local, ASTNode location) {
6468 	if ((location.bits & ASTNode.FirstAssignmentToLocal) != 0) // https://bugs.eclipse.org/338303 - Warning about Redundant assignment conflicts with definite assignment
6469 		return;
6470 	int severity = computeSeverity(IProblem.RedundantLocalVariableNullAssignment);
6471 	if (severity == ProblemSeverities.Ignore) return;
6472 	String[] arguments = new String[] {new String(local.name)  };
6473 	this.handle(
6474 		IProblem.RedundantLocalVariableNullAssignment,
6475 		arguments,
6476 		arguments,
6477 		severity,
6478 		nodeSourceStart(local, location),
6479 		nodeSourceEnd(local, location));
6480 }
6481 
methodMustOverride(AbstractMethodDeclaration method, long complianceLevel)6482 public void methodMustOverride(AbstractMethodDeclaration method, long complianceLevel) {
6483 	MethodBinding binding = method.binding;
6484 	this.handle(
6485 		complianceLevel == ClassFileConstants.JDK1_5 ? IProblem.MethodMustOverride : IProblem.MethodMustOverrideOrImplement,
6486 		new String[] {new String(binding.selector), typesAsString(binding, false), new String(binding.declaringClass.readableName()), },
6487 		new String[] {new String(binding.selector), typesAsString(binding, true), new String(binding.declaringClass.shortReadableName()),},
6488 		method.sourceStart,
6489 		method.sourceEnd);
6490 }
6491 
methodNameClash(MethodBinding currentMethod, MethodBinding inheritedMethod, int severity)6492 public void methodNameClash(MethodBinding currentMethod, MethodBinding inheritedMethod, int severity) {
6493 	this.handle(
6494 		IProblem.MethodNameClash,
6495 		new String[] {
6496 			new String(currentMethod.selector),
6497 			typesAsString(currentMethod, false),
6498 			new String(currentMethod.declaringClass.readableName()),
6499 			typesAsString(inheritedMethod, false),
6500 			new String(inheritedMethod.declaringClass.readableName()),
6501 		 },
6502 		new String[] {
6503 			new String(currentMethod.selector),
6504 			typesAsString(currentMethod, true),
6505 			new String(currentMethod.declaringClass.shortReadableName()),
6506 			typesAsString(inheritedMethod, true),
6507 			new String(inheritedMethod.declaringClass.shortReadableName()),
6508 		 },
6509 		severity,
6510 		currentMethod.sourceStart(),
6511 		currentMethod.sourceEnd());
6512 }
6513 
methodNameClashHidden(MethodBinding currentMethod, MethodBinding inheritedMethod)6514 public void methodNameClashHidden(MethodBinding currentMethod, MethodBinding inheritedMethod) {
6515 	this.handle(
6516 		IProblem.MethodNameClashHidden,
6517 		new String[] {
6518 			new String(currentMethod.selector),
6519 			typesAsString(currentMethod, currentMethod.parameters, false),
6520 			new String(currentMethod.declaringClass.readableName()),
6521 			typesAsString(inheritedMethod, inheritedMethod.parameters, false),
6522 			new String(inheritedMethod.declaringClass.readableName()),
6523 		 },
6524 		new String[] {
6525 			new String(currentMethod.selector),
6526 			typesAsString(currentMethod, currentMethod.parameters, true),
6527 			new String(currentMethod.declaringClass.shortReadableName()),
6528 			typesAsString(inheritedMethod, inheritedMethod.parameters, true),
6529 			new String(inheritedMethod.declaringClass.shortReadableName()),
6530 		 },
6531 		currentMethod.sourceStart(),
6532 		currentMethod.sourceEnd());
6533 }
6534 
methodNeedBody(AbstractMethodDeclaration methodDecl)6535 public void methodNeedBody(AbstractMethodDeclaration methodDecl) {
6536 	this.handle(
6537 		IProblem.MethodRequiresBody,
6538 		NoArgument,
6539 		NoArgument,
6540 		methodDecl.sourceStart,
6541 		methodDecl.sourceEnd);
6542 }
6543 
methodNeedingNoBody(MethodDeclaration methodDecl)6544 public void methodNeedingNoBody(MethodDeclaration methodDecl) {
6545 	this.handle(
6546 		((methodDecl.modifiers & ClassFileConstants.AccNative) != 0) ? IProblem.BodyForNativeMethod : IProblem.BodyForAbstractMethod,
6547 		NoArgument,
6548 		NoArgument,
6549 		methodDecl.sourceStart,
6550 		methodDecl.sourceEnd);
6551 }
6552 
methodWithConstructorName(MethodDeclaration methodDecl)6553 public void methodWithConstructorName(MethodDeclaration methodDecl) {
6554 	this.handle(
6555 		IProblem.MethodButWithConstructorName,
6556 		NoArgument,
6557 		NoArgument,
6558 		methodDecl.sourceStart,
6559 		methodDecl.sourceEnd);
6560 }
6561 
methodCanBeDeclaredStatic(MethodDeclaration methodDecl)6562 public void methodCanBeDeclaredStatic(MethodDeclaration methodDecl) {
6563 	int severity = computeSeverity(IProblem.MethodCanBeStatic);
6564 	if (severity == ProblemSeverities.Ignore) return;
6565 	MethodBinding method = methodDecl.binding;
6566 	this.handle(
6567 			IProblem.MethodCanBeStatic,
6568 		new String[] {
6569 			new String(method.declaringClass.readableName()),
6570 			new String(method.selector),
6571 			typesAsString(method, false)
6572 		 },
6573 		new String[] {
6574 			new String(method.declaringClass.shortReadableName()),
6575 			new String(method.selector),
6576 			typesAsString(method, true)
6577 		 },
6578 		severity,
6579 		methodDecl.sourceStart,
6580 		methodDecl.sourceEnd);
6581 }
6582 
methodCanBePotentiallyDeclaredStatic(MethodDeclaration methodDecl)6583 public void methodCanBePotentiallyDeclaredStatic(MethodDeclaration methodDecl) {
6584 	int severity = computeSeverity(IProblem.MethodCanBePotentiallyStatic);
6585 	if (severity == ProblemSeverities.Ignore) return;
6586 	MethodBinding method = methodDecl.binding;
6587 	this.handle(
6588 			IProblem.MethodCanBePotentiallyStatic,
6589 		new String[] {
6590 			new String(method.declaringClass.readableName()),
6591 			new String(method.selector),
6592 			typesAsString(method, false)
6593 		 },
6594 		new String[] {
6595 			new String(method.declaringClass.shortReadableName()),
6596 			new String(method.selector),
6597 			typesAsString(method, true)
6598 		 },
6599 		severity,
6600 		methodDecl.sourceStart,
6601 		methodDecl.sourceEnd);
6602 }
6603 
missingDeprecatedAnnotationForField(FieldDeclaration field)6604 public void missingDeprecatedAnnotationForField(FieldDeclaration field) {
6605 	int severity = computeSeverity(IProblem.FieldMissingDeprecatedAnnotation);
6606 	if (severity == ProblemSeverities.Ignore) return;
6607 	FieldBinding binding = field.binding;
6608 	this.handle(
6609 		IProblem.FieldMissingDeprecatedAnnotation,
6610 		new String[] {new String(binding.declaringClass.readableName()), new String(binding.name), },
6611 		new String[] {new String(binding.declaringClass.shortReadableName()), new String(binding.name), },
6612 		severity,
6613 		nodeSourceStart(binding, field),
6614 		nodeSourceEnd(binding, field));
6615 }
6616 
missingDeprecatedAnnotationForMethod(AbstractMethodDeclaration method)6617 public void missingDeprecatedAnnotationForMethod(AbstractMethodDeclaration method) {
6618 	int severity = computeSeverity(IProblem.MethodMissingDeprecatedAnnotation);
6619 	if (severity == ProblemSeverities.Ignore) return;
6620 	MethodBinding binding = method.binding;
6621 	this.handle(
6622 		IProblem.MethodMissingDeprecatedAnnotation,
6623 		new String[] {new String(binding.selector), typesAsString(binding, false), new String(binding.declaringClass.readableName()), },
6624 		new String[] {new String(binding.selector), typesAsString(binding, true), new String(binding.declaringClass.shortReadableName()),},
6625 		severity,
6626 		method.sourceStart,
6627 		method.sourceEnd);
6628 }
6629 
missingDeprecatedAnnotationForType(TypeDeclaration type)6630 public void missingDeprecatedAnnotationForType(TypeDeclaration type) {
6631 	int severity = computeSeverity(IProblem.TypeMissingDeprecatedAnnotation);
6632 	if (severity == ProblemSeverities.Ignore) return;
6633 	TypeBinding binding = type.binding;
6634 	this.handle(
6635 		IProblem.TypeMissingDeprecatedAnnotation,
6636 		new String[] {new String(binding.readableName()), },
6637 		new String[] {new String(binding.shortReadableName()),},
6638 		severity,
6639 		type.sourceStart,
6640 		type.sourceEnd);
6641 }
notAFunctionalInterface(TypeDeclaration type)6642 public void notAFunctionalInterface(TypeDeclaration type) {
6643 	TypeBinding binding = type.binding;
6644 	this.handle(
6645 		IProblem.InterfaceNotFunctionalInterface,
6646 		new String[] {new String(binding.readableName()), },
6647 		new String[] {new String(binding.shortReadableName()),},
6648 		type.sourceStart,
6649 		type.sourceEnd);
6650 }
6651 
missingEnumConstantCase(SwitchStatement switchStatement, FieldBinding enumConstant)6652 public void missingEnumConstantCase(SwitchStatement switchStatement, FieldBinding enumConstant) {
6653 	missingEnumConstantCase(switchStatement.defaultCase, enumConstant, switchStatement.expression);
6654 }
missingEnumConstantCase(SwitchExpression switchExpression, FieldBinding enumConstant)6655 public void missingEnumConstantCase(SwitchExpression switchExpression, FieldBinding enumConstant) {
6656 	missingSwitchExpressionEnumConstantCase(switchExpression.defaultCase, enumConstant, switchExpression.expression);
6657 }
missingSwitchExpressionEnumConstantCase(CaseStatement defaultCase, FieldBinding enumConstant, ASTNode expression)6658 private void missingSwitchExpressionEnumConstantCase(CaseStatement defaultCase, FieldBinding enumConstant, ASTNode expression) {
6659 	this.handle(
6660 			IProblem.SwitchExpressionsYieldMissingEnumConstantCase,
6661 			new String[] {new String(enumConstant.declaringClass.readableName()), new String(enumConstant.name) },
6662 			new String[] {new String(enumConstant.declaringClass.shortReadableName()), new String(enumConstant.name) },
6663 			expression.sourceStart,
6664 			expression.sourceEnd);
6665 }
missingEnumConstantCase(CaseStatement defaultCase, FieldBinding enumConstant, ASTNode expression)6666 private void missingEnumConstantCase(CaseStatement defaultCase, FieldBinding enumConstant, ASTNode expression) {
6667 	this.handle(
6668 			defaultCase == null ? IProblem.MissingEnumConstantCase : IProblem.MissingEnumConstantCaseDespiteDefault,
6669 			new String[] {new String(enumConstant.declaringClass.readableName()), new String(enumConstant.name) },
6670 			new String[] {new String(enumConstant.declaringClass.shortReadableName()), new String(enumConstant.name) },
6671 			expression.sourceStart,
6672 			expression.sourceEnd);
6673 }
missingDefaultCase(SwitchStatement switchStatement, boolean isEnumSwitch, TypeBinding expressionType)6674 public void missingDefaultCase(SwitchStatement switchStatement, boolean isEnumSwitch, TypeBinding expressionType) {
6675 	if (isEnumSwitch) {
6676 		this.handle(
6677 				IProblem.MissingEnumDefaultCase,
6678 				new String[] {new String(expressionType.readableName())},
6679 				new String[] {new String(expressionType.shortReadableName())},
6680 				switchStatement.expression.sourceStart,
6681 				switchStatement.expression.sourceEnd);
6682 	} else {
6683 		this.handle(
6684 				switchStatement instanceof SwitchExpression ?
6685 						IProblem.SwitchExpressionsYieldMissingDefaultCase : IProblem.MissingDefaultCase,
6686 				NoArgument,
6687 				NoArgument,
6688 				switchStatement.expression.sourceStart,
6689 				switchStatement.expression.sourceEnd);
6690 	}
6691 }
missingOverrideAnnotation(AbstractMethodDeclaration method)6692 public void missingOverrideAnnotation(AbstractMethodDeclaration method) {
6693 	int severity = computeSeverity(IProblem.MissingOverrideAnnotation);
6694 	if (severity == ProblemSeverities.Ignore) return;
6695 	MethodBinding binding = method.binding;
6696 	this.handle(
6697 		IProblem.MissingOverrideAnnotation,
6698 		new String[] {new String(binding.selector), typesAsString(binding, false), new String(binding.declaringClass.readableName()), },
6699 		new String[] {new String(binding.selector), typesAsString(binding, true), new String(binding.declaringClass.shortReadableName()),},
6700 		severity,
6701 		method.sourceStart,
6702 		method.sourceEnd);
6703 }
missingOverrideAnnotationForInterfaceMethodImplementation(AbstractMethodDeclaration method)6704 public void missingOverrideAnnotationForInterfaceMethodImplementation(AbstractMethodDeclaration method) {
6705 	int severity = computeSeverity(IProblem.MissingOverrideAnnotationForInterfaceMethodImplementation);
6706 	if (severity == ProblemSeverities.Ignore) return;
6707 	MethodBinding binding = method.binding;
6708 	this.handle(
6709 		IProblem.MissingOverrideAnnotationForInterfaceMethodImplementation,
6710 		new String[] {new String(binding.selector), typesAsString(binding, false), new String(binding.declaringClass.readableName()), },
6711 		new String[] {new String(binding.selector), typesAsString(binding, true), new String(binding.declaringClass.shortReadableName()),},
6712 		severity,
6713 		method.sourceStart,
6714 		method.sourceEnd);
6715 }
missingReturnType(AbstractMethodDeclaration methodDecl)6716 public void missingReturnType(AbstractMethodDeclaration methodDecl) {
6717 	this.handle(
6718 		IProblem.MissingReturnType,
6719 		NoArgument,
6720 		NoArgument,
6721 		methodDecl.sourceStart,
6722 		methodDecl.sourceEnd);
6723 }
missingSemiColon(Expression expression)6724 public void missingSemiColon(Expression expression){
6725 	this.handle(
6726 		IProblem.MissingSemiColon,
6727 		NoArgument,
6728 		NoArgument,
6729 		expression.sourceStart,
6730 		expression.sourceEnd);
6731 }
missingSerialVersion(TypeDeclaration typeDecl)6732 public void missingSerialVersion(TypeDeclaration typeDecl) {
6733 	String[] arguments = new String[] {new String(typeDecl.name)};
6734 	this.handle(
6735 		IProblem.MissingSerialVersion,
6736 		arguments,
6737 		arguments,
6738 		typeDecl.sourceStart,
6739 		typeDecl.sourceEnd);
6740 }
missingSynchronizedOnInheritedMethod(MethodBinding currentMethod, MethodBinding inheritedMethod)6741 public void missingSynchronizedOnInheritedMethod(MethodBinding currentMethod, MethodBinding inheritedMethod) {
6742 	this.handle(
6743 			IProblem.MissingSynchronizedModifierInInheritedMethod,
6744 			new String[] {
6745 					new String(currentMethod.declaringClass.readableName()),
6746 					new String(currentMethod.selector),
6747 					typesAsString(currentMethod, false),
6748 			},
6749 			new String[] {
6750 					new String(currentMethod.declaringClass.shortReadableName()),
6751 					new String(currentMethod.selector),
6752 					typesAsString(currentMethod, true),
6753 			},
6754 			currentMethod.sourceStart(),
6755 			currentMethod.sourceEnd());
6756 }
missingTypeInConstructor(ASTNode location, MethodBinding constructor)6757 public void missingTypeInConstructor(ASTNode location, MethodBinding constructor) {
6758 	List missingTypes = constructor.collectMissingTypes(null);
6759 	if (missingTypes == null) {
6760 		System.err.println("The constructor " + constructor + " is wrongly tagged as containing missing types"); //$NON-NLS-1$ //$NON-NLS-2$
6761 		return;
6762 	}
6763 	TypeBinding missingType = (TypeBinding) missingTypes.get(0);
6764 	int start = location.sourceStart;
6765 	int end = location.sourceEnd;
6766 	if (location instanceof QualifiedAllocationExpression) {
6767 		QualifiedAllocationExpression qualifiedAllocation = (QualifiedAllocationExpression) location;
6768 		if (qualifiedAllocation.anonymousType != null) {
6769 			start = qualifiedAllocation.anonymousType.sourceStart;
6770 			end = qualifiedAllocation.anonymousType.sourceEnd;
6771 		}
6772 	}
6773 	this.handle(
6774 			IProblem.MissingTypeInConstructor,
6775 			new String[] {
6776 			        new String(constructor.declaringClass.readableName()),
6777 			        typesAsString(constructor, false),
6778 			       	new String(missingType.readableName()),
6779 			},
6780 			new String[] {
6781 			        new String(constructor.declaringClass.shortReadableName()),
6782 			        typesAsString(constructor, true),
6783 			       	new String(missingType.shortReadableName()),
6784 			},
6785 			start,
6786 			end);
6787 }
missingTypeInLambda(LambdaExpression lambda, MethodBinding method)6788 public void missingTypeInLambda(LambdaExpression lambda, MethodBinding method) {
6789 	int nameSourceStart = lambda.sourceStart();
6790 	int nameSourceEnd = lambda.diagnosticsSourceEnd();
6791 	List missingTypes = method.collectMissingTypes(null);
6792 	if (missingTypes == null) {
6793 		System.err.println("The lambda expression " + method + " is wrongly tagged as containing missing types"); //$NON-NLS-1$ //$NON-NLS-2$
6794 		return;
6795 	}
6796 	TypeBinding missingType = (TypeBinding) missingTypes.get(0);
6797 	this.handle(
6798 			IProblem.MissingTypeInLambda,
6799 			new String[] {
6800 			        new String(missingType.readableName()),
6801 			},
6802 			new String[] {
6803 			        new String(missingType.shortReadableName()),
6804 			},
6805 			nameSourceStart,
6806 			nameSourceEnd);
6807 }
missingTypeInMethod(ASTNode astNode, MethodBinding method)6808 public void missingTypeInMethod(ASTNode astNode, MethodBinding method) {
6809 	int nameSourceStart, nameSourceEnd;
6810 	if (astNode instanceof MessageSend) {
6811 		MessageSend messageSend = astNode instanceof MessageSend ? (MessageSend) (astNode) : null;
6812 		nameSourceStart = (int) (messageSend.nameSourcePosition >>> 32);
6813 		nameSourceEnd = (int) messageSend.nameSourcePosition;
6814 	} else {
6815 		nameSourceStart = astNode.sourceStart;
6816 		nameSourceEnd = astNode.sourceEnd;
6817 	}
6818 	List missingTypes = method.collectMissingTypes(null);
6819 	if (missingTypes == null) {
6820 		System.err.println("The method " + method + " is wrongly tagged as containing missing types"); //$NON-NLS-1$ //$NON-NLS-2$
6821 		return;
6822 	}
6823 	TypeBinding missingType = (TypeBinding) missingTypes.get(0);
6824 	this.handle(
6825 			IProblem.MissingTypeInMethod,
6826 			new String[] {
6827 			        new String(method.declaringClass.readableName()),
6828 			        new String(method.selector),
6829 			        typesAsString(method, false),
6830 			       	new String(missingType.readableName()),
6831 			},
6832 			new String[] {
6833 			        new String(method.declaringClass.shortReadableName()),
6834 			        new String(method.selector),
6835 			        typesAsString(method, true),
6836 			       	new String(missingType.shortReadableName()),
6837 			},
6838 			nameSourceStart,
6839 			nameSourceEnd);
6840 }
missingValueForAnnotationMember(Annotation annotation, char[] memberName)6841 public void missingValueForAnnotationMember(Annotation annotation, char[] memberName) {
6842 	String memberString = new String(memberName);
6843 	this.handle(
6844 		IProblem.MissingValueForAnnotationMember,
6845 		new String[] {new String(annotation.resolvedType.readableName()), memberString },
6846 		new String[] {new String(annotation.resolvedType.shortReadableName()), memberString},
6847 		annotation.sourceStart,
6848 		annotation.sourceEnd);
6849 }
mustDefineDimensionsOrInitializer(ArrayAllocationExpression expression)6850 public void mustDefineDimensionsOrInitializer(ArrayAllocationExpression expression) {
6851 	this.handle(
6852 		IProblem.MustDefineEitherDimensionExpressionsOrInitializer,
6853 		NoArgument,
6854 		NoArgument,
6855 		expression.sourceStart,
6856 		expression.sourceEnd);
6857 }
mustUseAStaticMethod(MessageSend messageSend, MethodBinding method)6858 public void mustUseAStaticMethod(MessageSend messageSend, MethodBinding method) {
6859 	this.handle(
6860 		IProblem.StaticMethodRequested,
6861 		new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method, false)},
6862 		new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method, true)},
6863 		messageSend.sourceStart,
6864 		messageSend.sourceEnd);
6865 }
nativeMethodsCannotBeStrictfp(ReferenceBinding type, AbstractMethodDeclaration methodDecl)6866 public void nativeMethodsCannotBeStrictfp(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
6867 	String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
6868 	this.handle(
6869 		IProblem.NativeMethodsCannotBeStrictfp,
6870 		arguments,
6871 		arguments,
6872 		methodDecl.sourceStart,
6873 		methodDecl.sourceEnd);
6874 }
needImplementation(ASTNode location)6875 public void needImplementation(ASTNode location) {
6876 	this.abortDueToInternalError(Messages.abort_missingCode, location);
6877 }
6878 
needToEmulateFieldAccess(FieldBinding field, ASTNode location, boolean isReadAccess)6879 public void needToEmulateFieldAccess(FieldBinding field, ASTNode location, boolean isReadAccess) {
6880 	int id = isReadAccess
6881 			? IProblem.NeedToEmulateFieldReadAccess
6882 			: IProblem.NeedToEmulateFieldWriteAccess;
6883 	int severity = computeSeverity(id);
6884 	if (severity == ProblemSeverities.Ignore) return;
6885 	this.handle(
6886 		id,
6887 		new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
6888 		new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
6889 		severity,
6890 		nodeSourceStart(field, location),
6891 		nodeSourceEnd(field, location));
6892 }
needToEmulateMethodAccess( MethodBinding method, ASTNode location)6893 public void needToEmulateMethodAccess(
6894 	MethodBinding method,
6895 	ASTNode location) {
6896 
6897 	if (method.isConstructor()) {
6898 		int severity = computeSeverity(IProblem.NeedToEmulateConstructorAccess);
6899 		if (severity == ProblemSeverities.Ignore) return;
6900 		if (method.declaringClass.isEnum())
6901 			return; // tolerate emulation for enum constructors, which can only be made private
6902 		this.handle(
6903 			IProblem.NeedToEmulateConstructorAccess,
6904 			new String[] {
6905 				new String(method.declaringClass.readableName()),
6906 				typesAsString(method, false)
6907 			 },
6908 			new String[] {
6909 				new String(method.declaringClass.shortReadableName()),
6910 				typesAsString(method, true)
6911 			 },
6912 			severity,
6913 			location.sourceStart,
6914 			location.sourceEnd);
6915 		return;
6916 	}
6917 	int severity = computeSeverity(IProblem.NeedToEmulateMethodAccess);
6918 	if (severity == ProblemSeverities.Ignore) return;
6919 	this.handle(
6920 		IProblem.NeedToEmulateMethodAccess,
6921 		new String[] {
6922 			new String(method.declaringClass.readableName()),
6923 			new String(method.selector),
6924 			typesAsString(method, false)
6925 		 },
6926 		new String[] {
6927 			new String(method.declaringClass.shortReadableName()),
6928 			new String(method.selector),
6929 			typesAsString(method, true)
6930 		 },
6931 		 severity,
6932 		location.sourceStart,
6933 		location.sourceEnd);
6934 }
noAdditionalBoundAfterTypeVariable(TypeReference boundReference)6935 public void noAdditionalBoundAfterTypeVariable(TypeReference boundReference) {
6936 	this.handle(
6937 		IProblem.NoAdditionalBoundAfterTypeVariable,
6938 		new String[] { new String(boundReference.resolvedType.readableName()) },
6939 		new String[] { new String(boundReference.resolvedType.shortReadableName()) },
6940 		boundReference.sourceStart,
6941 		boundReference.sourceEnd);
6942 }
nodeSourceEnd(ASTNode node)6943 private int nodeSourceEnd(ASTNode node) {
6944 	if (node instanceof Reference) {
6945 		Binding field = ((Reference) node).lastFieldBinding();
6946 		if (field != null)
6947 			return nodeSourceEnd(field, node);
6948 	}
6949 	return node.sourceEnd;
6950 }
nodeSourceEnd(Binding field, ASTNode node)6951 private int nodeSourceEnd(Binding field, ASTNode node) {
6952 	return nodeSourceEnd(field, node, 0);
6953 }
nodeSourceEnd(Binding field, ASTNode node, int index)6954 private int nodeSourceEnd(Binding field, ASTNode node, int index) {
6955 	if (node instanceof ArrayTypeReference) {
6956 		return ((ArrayTypeReference) node).originalSourceEnd;
6957 	} else if (node instanceof QualifiedNameReference) {
6958 		QualifiedNameReference ref = (QualifiedNameReference) node;
6959 		if (ref.binding == field) {
6960 			if (index == 0) {
6961 				return (int) (ref.sourcePositions[ref.indexOfFirstFieldBinding-1]);
6962 			} else {
6963 				int length = ref.sourcePositions.length;
6964 				if (index < length) {
6965 					return (int) (ref.sourcePositions[index]);
6966 				}
6967 				return (int) (ref.sourcePositions[0]);
6968 			}
6969 		}
6970 		FieldBinding[] otherFields = ref.otherBindings;
6971 		if (otherFields != null) {
6972 			int offset = ref.indexOfFirstFieldBinding;
6973 			if (index != 0) {
6974 				for (int i = 0, length = otherFields.length; i < length; i++) {
6975 					if ((otherFields[i] == field) && (i + offset == index)) {
6976 						return (int) (ref.sourcePositions[i + offset]);
6977 					}
6978 				}
6979 			} else {
6980 				for (int i = 0, length = otherFields.length; i < length; i++) {
6981 					if (otherFields[i] == field)
6982 						return (int) (ref.sourcePositions[i + offset]);
6983 				}
6984 			}
6985 		}
6986 	} else if (node instanceof ParameterizedQualifiedTypeReference) {
6987 		ParameterizedQualifiedTypeReference reference = (ParameterizedQualifiedTypeReference) node;
6988 		if (index < reference.sourcePositions.length) {
6989 			return (int) reference.sourcePositions[index];
6990 		}
6991 	} else if (node instanceof ArrayQualifiedTypeReference) {
6992 		ArrayQualifiedTypeReference reference = (ArrayQualifiedTypeReference) node;
6993 		int length = reference.sourcePositions.length;
6994 		if (index < length) {
6995 			return (int) reference.sourcePositions[index];
6996 		}
6997 		return (int) reference.sourcePositions[length - 1];
6998 	} else if (node instanceof QualifiedTypeReference) {
6999 		QualifiedTypeReference reference = (QualifiedTypeReference) node;
7000 		int length = reference.sourcePositions.length;
7001 		if (index < length) {
7002 			return (int) reference.sourcePositions[index];
7003 		}
7004 	}
7005 	return node.sourceEnd;
7006 }
nodeSourceStart(ASTNode node)7007 private int nodeSourceStart(ASTNode node) {
7008 	if (node instanceof Reference) {
7009 		Binding field = ((Reference) node).lastFieldBinding();
7010 		if (field != null)
7011 			return nodeSourceStart(field, node);
7012 	}
7013 	return node.sourceStart;
7014 }
nodeSourceStart(Binding field, ASTNode node)7015 private int nodeSourceStart(Binding field, ASTNode node) {
7016 	return nodeSourceStart(field, node, 0);
7017 }
nodeSourceStart(Binding field, ASTNode node, int index)7018 private int nodeSourceStart(Binding field, ASTNode node, int index) {
7019 	if (node instanceof FieldReference) {
7020 		FieldReference fieldReference = (FieldReference) node;
7021 		return (int) (fieldReference.nameSourcePosition >> 32);
7022 	} else 	if (node instanceof QualifiedNameReference) {
7023 		QualifiedNameReference ref = (QualifiedNameReference) node;
7024 		if (ref.binding == field) {
7025 			if (index == 0) {
7026 				return (int) (ref.sourcePositions[ref.indexOfFirstFieldBinding-1] >> 32);
7027 			} else {
7028 				return (int) (ref.sourcePositions[index] >> 32);
7029 			}
7030 		}
7031 		FieldBinding[] otherFields = ref.otherBindings;
7032 		if (otherFields != null) {
7033 			int offset = ref.indexOfFirstFieldBinding;
7034 			if (index != 0) {
7035 				for (int i = 0, length = otherFields.length; i < length; i++) {
7036 					if ((otherFields[i] == field) && (i + offset == index)) {
7037 						return (int) (ref.sourcePositions[i + offset] >> 32);
7038 					}
7039 				}
7040 			} else {
7041 				for (int i = 0, length = otherFields.length; i < length; i++) {
7042 					if (otherFields[i] == field) {
7043 						return (int) (ref.sourcePositions[i + offset] >> 32);
7044 					}
7045 				}
7046 			}
7047 		}
7048 	} else if (node instanceof ParameterizedQualifiedTypeReference) {
7049 		ParameterizedQualifiedTypeReference reference = (ParameterizedQualifiedTypeReference) node;
7050 		return (int) (reference.sourcePositions[0]>>>32);
7051 	}
7052 	return node.sourceStart;
7053 }
noMoreAvailableSpaceForArgument(LocalVariableBinding local, ASTNode location)7054 public void noMoreAvailableSpaceForArgument(LocalVariableBinding local, ASTNode location) {
7055 	String[] arguments = new String[]{ new String(local.name) };
7056 	this.handle(
7057 		local instanceof SyntheticArgumentBinding
7058 			? IProblem.TooManySyntheticArgumentSlots
7059 			: IProblem.TooManyArgumentSlots,
7060 		arguments,
7061 		arguments,
7062 		ProblemSeverities.Abort | ProblemSeverities.Error | ProblemSeverities.Fatal,
7063 		nodeSourceStart(local, location),
7064 		nodeSourceEnd(local, location));
7065 }
noMoreAvailableSpaceForConstant(TypeDeclaration typeDeclaration)7066 public void noMoreAvailableSpaceForConstant(TypeDeclaration typeDeclaration) {
7067 	this.handle(
7068 		IProblem.TooManyBytesForStringConstant,
7069 		new String[]{ new String(typeDeclaration.binding.readableName())},
7070 		new String[]{ new String(typeDeclaration.binding.shortReadableName())},
7071 		ProblemSeverities.Abort | ProblemSeverities.Error | ProblemSeverities.Fatal,
7072 		typeDeclaration.sourceStart,
7073 		typeDeclaration.sourceEnd);
7074 }
7075 
noMoreAvailableSpaceForLocal(LocalVariableBinding local, ASTNode location)7076 public void noMoreAvailableSpaceForLocal(LocalVariableBinding local, ASTNode location) {
7077 	String[] arguments = new String[]{ new String(local.name) };
7078 	this.handle(
7079 		IProblem.TooManyLocalVariableSlots,
7080 		arguments,
7081 		arguments,
7082 		ProblemSeverities.Abort | ProblemSeverities.Error | ProblemSeverities.Fatal,
7083 		nodeSourceStart(local, location),
7084 		nodeSourceEnd(local, location));
7085 }
noMoreAvailableSpaceInConstantPool(TypeDeclaration typeDeclaration)7086 public void noMoreAvailableSpaceInConstantPool(TypeDeclaration typeDeclaration) {
7087 	this.handle(
7088 		IProblem.TooManyConstantsInConstantPool,
7089 		new String[]{ new String(typeDeclaration.binding.readableName())},
7090 		new String[]{ new String(typeDeclaration.binding.shortReadableName())},
7091 		ProblemSeverities.Abort | ProblemSeverities.Error | ProblemSeverities.Fatal,
7092 		typeDeclaration.sourceStart,
7093 		typeDeclaration.sourceEnd);
7094 }
7095 
nonExternalizedStringLiteral(ASTNode location)7096 public void nonExternalizedStringLiteral(ASTNode location) {
7097 	this.handle(
7098 		IProblem.NonExternalizedStringLiteral,
7099 		NoArgument,
7100 		NoArgument,
7101 		location.sourceStart,
7102 		location.sourceEnd);
7103 }
7104 
nonGenericTypeCannotBeParameterized(int index, ASTNode location, TypeBinding type, TypeBinding[] argumentTypes)7105 public void nonGenericTypeCannotBeParameterized(int index, ASTNode location, TypeBinding type, TypeBinding[] argumentTypes) {
7106 	if (location == null) { // binary case
7107 	    this.handle(
7108 			IProblem.NonGenericType,
7109 			new String[] {new String(type.readableName()), typesAsString(argumentTypes, false)},
7110 			new String[] {new String(type.shortReadableName()), typesAsString(argumentTypes, true)},
7111 			ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
7112 			0,
7113 			0);
7114 	    return;
7115 	}
7116     this.handle(
7117 		IProblem.NonGenericType,
7118 		new String[] {new String(type.readableName()), typesAsString(argumentTypes, false)},
7119 		new String[] {new String(type.shortReadableName()), typesAsString(argumentTypes, true)},
7120 		nodeSourceStart(null, location),
7121 		nodeSourceEnd(null, location, index));
7122 }
nonStaticAccessToStaticField(ASTNode location, FieldBinding field)7123 public void nonStaticAccessToStaticField(ASTNode location, FieldBinding field) {
7124 	nonStaticAccessToStaticField(location, field, -1);
7125 }
nonStaticAccessToStaticField(ASTNode location, FieldBinding field, int index)7126 public void nonStaticAccessToStaticField(ASTNode location, FieldBinding field, int index) {
7127 	int severity = computeSeverity(IProblem.NonStaticAccessToStaticField);
7128 	if (severity == ProblemSeverities.Ignore) return;
7129 	this.handle(
7130 		IProblem.NonStaticAccessToStaticField,
7131 		new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
7132 		new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
7133 		severity,
7134 		nodeSourceStart(field, location, index),
7135 		nodeSourceEnd(field, location, index));
7136 }
nonStaticAccessToStaticMethod(ASTNode location, MethodBinding method)7137 public void nonStaticAccessToStaticMethod(ASTNode location, MethodBinding method) {
7138 	this.handle(
7139 		IProblem.NonStaticAccessToStaticMethod,
7140 		new String[] {new String(method.declaringClass.readableName()), new String(method.selector), typesAsString(method, false)},
7141 		new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), typesAsString(method, true)},
7142 		location.sourceStart,
7143 		location.sourceEnd);
7144 }
nonStaticContextForEnumMemberType(SourceTypeBinding type)7145 public void nonStaticContextForEnumMemberType(SourceTypeBinding type) {
7146 	String[] arguments = new String[] {new String(type.sourceName())};
7147 	this.handle(
7148 		IProblem.NonStaticContextForEnumMemberType,
7149 		arguments,
7150 		arguments,
7151 		type.sourceStart(),
7152 		type.sourceEnd());
7153 }
noSuchEnclosingInstance(TypeBinding targetType, ASTNode location, boolean isConstructorCall)7154 public void noSuchEnclosingInstance(TypeBinding targetType, ASTNode location, boolean isConstructorCall) {
7155 
7156 	int id;
7157 
7158 	if (isConstructorCall) {
7159 		//28 = No enclosing instance of type {0} is available due to some intermediate constructor invocation
7160 		id = IProblem.EnclosingInstanceInConstructorCall;
7161 	} else if ((location instanceof ExplicitConstructorCall)
7162 				&& ((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper) {
7163 		//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}).
7164 		id = IProblem.MissingEnclosingInstanceForConstructorCall;
7165 	} else if (location instanceof AllocationExpression
7166 				&& (((AllocationExpression) location).binding.declaringClass.isMemberType()
7167 					|| (((AllocationExpression) location).binding.declaringClass.isAnonymousType()
7168 						&& ((AllocationExpression) location).binding.declaringClass.superclass().isMemberType()))) {
7169 		//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}).
7170 		id = IProblem.MissingEnclosingInstance;
7171 	} else { // default
7172 		//22 = No enclosing instance of the type {0} is accessible in scope
7173 		id = IProblem.IncorrectEnclosingInstanceReference;
7174 	}
7175 
7176 	this.handle(
7177 		id,
7178 		new String[] { new String(targetType.readableName())},
7179 		new String[] { new String(targetType.shortReadableName())},
7180 		location.sourceStart,
7181 		location instanceof LambdaExpression ? ((LambdaExpression)location).diagnosticsSourceEnd() : location.sourceEnd);
7182 }
notCompatibleTypesError(EqualExpression expression, TypeBinding leftType, TypeBinding rightType)7183 public void notCompatibleTypesError(EqualExpression expression, TypeBinding leftType, TypeBinding rightType) {
7184 	String leftName = new String(leftType.readableName());
7185 	String rightName = new String(rightType.readableName());
7186 	String leftShortName = new String(leftType.shortReadableName());
7187 	String rightShortName = new String(rightType.shortReadableName());
7188 	if (leftShortName.equals(rightShortName)){
7189 		leftShortName = leftName;
7190 		rightShortName = rightName;
7191 	}
7192 	this.handle(
7193 		IProblem.IncompatibleTypesInEqualityOperator,
7194 		new String[] {leftName, rightName },
7195 		new String[] {leftShortName, rightShortName },
7196 		expression.sourceStart,
7197 		expression.sourceEnd);
7198 }
notCompatibleTypesError(InstanceOfExpression expression, TypeBinding leftType, TypeBinding rightType)7199 public void notCompatibleTypesError(InstanceOfExpression expression, TypeBinding leftType, TypeBinding rightType) {
7200 	String leftName = new String(leftType.readableName());
7201 	String rightName = new String(rightType.readableName());
7202 	String leftShortName = new String(leftType.shortReadableName());
7203 	String rightShortName = new String(rightType.shortReadableName());
7204 	if (leftShortName.equals(rightShortName)){
7205 		leftShortName = leftName;
7206 		rightShortName = rightName;
7207 	}
7208 	this.handle(
7209 		IProblem.IncompatibleTypesInConditionalOperator,
7210 		new String[] {leftName, rightName },
7211 		new String[] {leftShortName, rightShortName },
7212 		expression.sourceStart,
7213 		expression.sourceEnd);
7214 }
notCompatibleTypesErrorInForeach(Expression expression, TypeBinding leftType, TypeBinding rightType)7215 public void notCompatibleTypesErrorInForeach(Expression expression, TypeBinding leftType, TypeBinding rightType) {
7216 	String leftName = new String(leftType.readableName());
7217 	String rightName = new String(rightType.readableName());
7218 	String leftShortName = new String(leftType.shortReadableName());
7219 	String rightShortName = new String(rightType.shortReadableName());
7220 	if (leftShortName.equals(rightShortName)){
7221 		leftShortName = leftName;
7222 		rightShortName = rightName;
7223 	}
7224 	this.handle(
7225 		IProblem.IncompatibleTypesInForeach,
7226 		new String[] {leftName, rightName },
7227 		new String[] {leftShortName, rightShortName },
7228 		expression.sourceStart,
7229 		expression.sourceEnd);
7230 }
objectCannotBeGeneric(TypeDeclaration typeDecl)7231 public void objectCannotBeGeneric(TypeDeclaration typeDecl) {
7232 	this.handle(
7233 		IProblem.ObjectCannotBeGeneric,
7234 		NoArgument,
7235 		NoArgument,
7236 		typeDecl.typeParameters[0].sourceStart,
7237 		typeDecl.typeParameters[typeDecl.typeParameters.length-1].sourceEnd);
7238 }
objectCannotHaveSuperTypes(SourceTypeBinding type)7239 public void objectCannotHaveSuperTypes(SourceTypeBinding type) {
7240 	this.handle(
7241 		IProblem.ObjectCannotHaveSuperTypes,
7242 		NoArgument,
7243 		NoArgument,
7244 		type.sourceStart(),
7245 		type.sourceEnd());
7246 }
objectMustBeClass(SourceTypeBinding type)7247 public void objectMustBeClass(SourceTypeBinding type) {
7248 	this.handle(
7249 		IProblem.ObjectMustBeClass,
7250 		NoArgument,
7251 		NoArgument,
7252 		type.sourceStart(),
7253 		type.sourceEnd());
7254 }
operatorOnlyValidOnNumericType(CompoundAssignment assignment, TypeBinding leftType, TypeBinding rightType)7255 public void operatorOnlyValidOnNumericType(CompoundAssignment  assignment, TypeBinding leftType, TypeBinding rightType) {
7256 	String leftName = new String(leftType.readableName());
7257 	String rightName = new String(rightType.readableName());
7258 	String leftShortName = new String(leftType.shortReadableName());
7259 	String rightShortName = new String(rightType.shortReadableName());
7260 	if (leftShortName.equals(rightShortName)){
7261 		leftShortName = leftName;
7262 		rightShortName = rightName;
7263 	}
7264 	this.handle(
7265 		IProblem.TypeMismatch,
7266 		new String[] {leftName, rightName },
7267 		new String[] {leftShortName, rightShortName },
7268 		assignment.sourceStart,
7269 		assignment.sourceEnd);
7270 }
overridesDeprecatedMethod(MethodBinding localMethod, MethodBinding inheritedMethod)7271 public void overridesDeprecatedMethod(MethodBinding localMethod, MethodBinding inheritedMethod) {
7272 	String localMethodName = new String(
7273 								CharOperation.concat(
7274 									localMethod.declaringClass.readableName(),
7275 									localMethod.readableName(),
7276 									'.'));
7277 	String localMethodShortName = new String(
7278 									CharOperation.concat(
7279 										localMethod.declaringClass.shortReadableName(),
7280 										localMethod.shortReadableName(),
7281 										'.'));
7282 	String sinceValue = deprecatedSinceValue(() -> inheritedMethod.getAnnotations());
7283 	if (sinceValue != null) {
7284 		this.handle(
7285 			(inheritedMethod.tagBits & TagBits.AnnotationTerminallyDeprecated) != 0
7286 				? IProblem.OverridingTerminallyDeprecatedSinceVersionMethod : IProblem.OverridingDeprecatedSinceVersionMethod,
7287 			new String[] {
7288 				localMethodName,
7289 				new String(inheritedMethod.declaringClass.readableName()),
7290 				sinceValue},
7291 			new String[] {
7292 				localMethodShortName,
7293 				new String(inheritedMethod.declaringClass.shortReadableName()),
7294 				sinceValue},
7295 			localMethod.sourceStart(),
7296 			localMethod.sourceEnd());
7297 
7298 	} else {
7299 		this.handle(
7300 			(inheritedMethod.tagBits & TagBits.AnnotationTerminallyDeprecated) != 0
7301 				? IProblem.OverridingTerminallyDeprecatedMethod : IProblem.OverridingDeprecatedMethod,
7302 			new String[] {
7303 				localMethodName,
7304 				new String(inheritedMethod.declaringClass.readableName())},
7305 			new String[] {
7306 				localMethodShortName,
7307 				new String(inheritedMethod.declaringClass.shortReadableName())},
7308 			localMethod.sourceStart(),
7309 			localMethod.sourceEnd());
7310 	}
7311 }
overridesMethodWithoutSuperInvocation(MethodBinding localMethod)7312 public void overridesMethodWithoutSuperInvocation(MethodBinding localMethod) {
7313 	this.handle(
7314 		IProblem.OverridingMethodWithoutSuperInvocation,
7315 		new String[] {
7316 			new String(
7317 					CharOperation.concat(
7318 						localMethod.declaringClass.readableName(),
7319 						localMethod.readableName(),
7320 						'.'))
7321 			},
7322 		new String[] {
7323 			new String(
7324 					CharOperation.concat(
7325 						localMethod.declaringClass.shortReadableName(),
7326 						localMethod.shortReadableName(),
7327 						'.'))
7328 			},
7329 		localMethod.sourceStart(),
7330 		localMethod.sourceEnd());
7331 }
overridesPackageDefaultMethod(MethodBinding localMethod, MethodBinding inheritedMethod)7332 public void overridesPackageDefaultMethod(MethodBinding localMethod, MethodBinding inheritedMethod) {
7333 	this.handle(
7334 		IProblem.OverridingNonVisibleMethod,
7335 		new String[] {
7336 			new String(
7337 					CharOperation.concat(
7338 						localMethod.declaringClass.readableName(),
7339 						localMethod.readableName(),
7340 						'.')),
7341 			new String(inheritedMethod.declaringClass.readableName())},
7342 		new String[] {
7343 			new String(
7344 					CharOperation.concat(
7345 						localMethod.declaringClass.shortReadableName(),
7346 						localMethod.shortReadableName(),
7347 						'.')),
7348 			new String(inheritedMethod.declaringClass.shortReadableName())},
7349 		localMethod.sourceStart(),
7350 		localMethod.sourceEnd());
7351 }
packageCollidesWithType(CompilationUnitDeclaration compUnitDecl)7352 public void packageCollidesWithType(CompilationUnitDeclaration compUnitDecl) {
7353 	String[] arguments = new String[] {CharOperation.toString(compUnitDecl.currentPackage.tokens)};
7354 	this.handle(
7355 		IProblem.PackageCollidesWithType,
7356 		arguments,
7357 		arguments,
7358 		compUnitDecl.currentPackage.sourceStart,
7359 		compUnitDecl.currentPackage.sourceEnd);
7360 }
packageIsNotExpectedPackage(CompilationUnitDeclaration compUnitDecl)7361 public void packageIsNotExpectedPackage(CompilationUnitDeclaration compUnitDecl) {
7362 	boolean hasPackageDeclaration = compUnitDecl.currentPackage == null;
7363 	String[] arguments = new String[] {
7364 		CharOperation.toString(compUnitDecl.compilationResult.compilationUnit.getPackageName()),
7365 		hasPackageDeclaration ? "" : CharOperation.toString(compUnitDecl.currentPackage.tokens), //$NON-NLS-1$
7366 	};
7367 	int end;
7368 	if (compUnitDecl.sourceEnd <= 0) {
7369 		end = -1;
7370 	} else {
7371 		end = hasPackageDeclaration ? 0 : compUnitDecl.currentPackage.sourceEnd;
7372 	}
7373 	this.handle(
7374 		IProblem.PackageIsNotExpectedPackage,
7375 		arguments,
7376 		arguments,
7377 		hasPackageDeclaration ? 0 : compUnitDecl.currentPackage.sourceStart,
7378 		end);
7379 }
parameterAssignment(LocalVariableBinding local, ASTNode location)7380 public void parameterAssignment(LocalVariableBinding local, ASTNode location) {
7381 	int severity = computeSeverity(IProblem.ParameterAssignment);
7382 	if (severity == ProblemSeverities.Ignore) return;
7383 	String[] arguments = new String[] { new String(local.readableName())};
7384 	this.handle(
7385 		IProblem.ParameterAssignment,
7386 		arguments,
7387 		arguments,
7388 		severity,
7389 		nodeSourceStart(local, location),
7390 		nodeSourceEnd(local, location)); // should never be a qualified name reference
7391 }
parameterBoundAsString(TypeVariableBinding typeVariable, boolean makeShort)7392 private String parameterBoundAsString(TypeVariableBinding typeVariable, boolean makeShort) {
7393     StringBuffer nameBuffer = new StringBuffer(10);
7394     if (TypeBinding.equalsEquals(typeVariable.firstBound, typeVariable.superclass)) {
7395         nameBuffer.append(makeShort ? typeVariable.superclass.shortReadableName() : typeVariable.superclass.readableName());
7396     }
7397     int length;
7398     if ((length = typeVariable.superInterfaces.length) > 0) {
7399 	    for (int i = 0; i < length; i++) {
7400 	        if (i > 0 || TypeBinding.equalsEquals(typeVariable.firstBound, typeVariable.superclass)) nameBuffer.append(" & "); //$NON-NLS-1$
7401 	        nameBuffer.append(makeShort ? typeVariable.superInterfaces[i].shortReadableName() : typeVariable.superInterfaces[i].readableName());
7402 	    }
7403 	}
7404 	return nameBuffer.toString();
7405 }
parameterizedMemberTypeMissingArguments(ASTNode location, TypeBinding type, int index)7406 public void parameterizedMemberTypeMissingArguments(ASTNode location, TypeBinding type, int index) {
7407 	if (location == null) { // binary case
7408 	    this.handle(
7409 			IProblem.MissingArgumentsForParameterizedMemberType,
7410 			new String[] {new String(type.readableName())},
7411 			new String[] {new String(type.shortReadableName())},
7412 			ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
7413 			0,
7414 			0);
7415 	    return;
7416 	}
7417     this.handle(
7418 		IProblem.MissingArgumentsForParameterizedMemberType,
7419 		new String[] {new String(type.readableName())},
7420 		new String[] {new String(type.shortReadableName())},
7421 		location.sourceStart,
7422 		nodeSourceEnd(null, location, index));
7423 }
parseError( int startPosition, int endPosition, int currentToken, char[] currentTokenSource, String errorTokenName, String[] possibleTokens)7424 public void parseError(
7425 	int startPosition,
7426 	int endPosition,
7427 	int currentToken,
7428 	char[] currentTokenSource,
7429 	String errorTokenName,
7430 	String[] possibleTokens) {
7431 
7432 	if (possibleTokens.length == 0) { //no suggestion available
7433 		if (isKeyword(currentToken)) {
7434 			String[] arguments = new String[] {new String(currentTokenSource)};
7435 			this.handle(
7436 				IProblem.ParsingErrorOnKeywordNoSuggestion,
7437 				arguments,
7438 				arguments,
7439 				// this is the current -invalid- token position
7440 				startPosition,
7441 				endPosition);
7442 			return;
7443 		} else {
7444 			String[] arguments = new String[] {errorTokenName};
7445 			this.handle(
7446 				IProblem.ParsingErrorNoSuggestion,
7447 				arguments,
7448 				arguments,
7449 				// this is the current -invalid- token position
7450 				startPosition,
7451 				endPosition);
7452 			return;
7453 		}
7454 	}
7455 
7456 	//build a list of probable right tokens
7457 	StringBuffer list = new StringBuffer(20);
7458 	for (int i = 0, max = possibleTokens.length; i < max; i++) {
7459 		if (i > 0)
7460 			list.append(", "); //$NON-NLS-1$
7461 		list.append('"');
7462 		list.append(possibleTokens[i]);
7463 		list.append('"');
7464 	}
7465 
7466 	if (isKeyword(currentToken)) {
7467 		String[] arguments = new String[] {new String(currentTokenSource), list.toString()};
7468 		this.handle(
7469 			IProblem.ParsingErrorOnKeyword,
7470 			arguments,
7471 			arguments,
7472 			// this is the current -invalid- token position
7473 			startPosition,
7474 			endPosition);
7475 		return;
7476 	}
7477 	//extract the literal when it's a literal
7478 	if (isLiteral(currentToken) ||
7479 		isIdentifier(currentToken)) {
7480 			errorTokenName = new String(currentTokenSource);
7481 	}
7482 
7483 	String[] arguments = new String[] {errorTokenName, list.toString()};
7484 	this.handle(
7485 		IProblem.ParsingError,
7486 		arguments,
7487 		arguments,
7488 		// this is the current -invalid- token position
7489 		startPosition,
7490 		endPosition);
7491 }
parseErrorDeleteToken( int start, int end, int currentKind, char[] errorTokenSource, String errorTokenName)7492 public void parseErrorDeleteToken(
7493 	int start,
7494 	int end,
7495 	int currentKind,
7496 	char[] errorTokenSource,
7497 	String errorTokenName){
7498 	syntaxError(
7499 		IProblem.ParsingErrorDeleteToken,
7500 		start,
7501 		end,
7502 		currentKind,
7503 		errorTokenSource,
7504 		errorTokenName,
7505 		null);
7506 }
7507 
parseErrorDeleteTokens( int start, int end)7508 public void parseErrorDeleteTokens(
7509 	int start,
7510 	int end){
7511 	this.handle(
7512 		IProblem.ParsingErrorDeleteTokens,
7513 		NoArgument,
7514 		NoArgument,
7515 		start,
7516 		end);
7517 }
parseErrorInsertAfterToken( int start, int end, int currentKind, char[] errorTokenSource, String errorTokenName, String expectedToken)7518 public void parseErrorInsertAfterToken(
7519 	int start,
7520 	int end,
7521 	int currentKind,
7522 	char[] errorTokenSource,
7523 	String errorTokenName,
7524 	String expectedToken){
7525 	syntaxError(
7526 		IProblem.ParsingErrorInsertTokenAfter,
7527 		start,
7528 		end,
7529 		currentKind,
7530 		errorTokenSource,
7531 		errorTokenName,
7532 		expectedToken);
7533 }
parseErrorInsertBeforeToken( int start, int end, int currentKind, char[] errorTokenSource, String errorTokenName, String expectedToken)7534 public void parseErrorInsertBeforeToken(
7535 	int start,
7536 	int end,
7537 	int currentKind,
7538 	char[] errorTokenSource,
7539 	String errorTokenName,
7540 	String expectedToken){
7541 	syntaxError(
7542 		IProblem.ParsingErrorInsertTokenBefore,
7543 		start,
7544 		end,
7545 		currentKind,
7546 		errorTokenSource,
7547 		errorTokenName,
7548 		expectedToken);
7549 }
parseErrorInsertToComplete( int start, int end, String inserted, String completed)7550 public void parseErrorInsertToComplete(
7551 	int start,
7552 	int end,
7553 	String inserted,
7554 	String completed){
7555 	String[] arguments = new String[] {inserted, completed};
7556 	this.handle(
7557 		IProblem.ParsingErrorInsertToComplete,
7558 		arguments,
7559 		arguments,
7560 		start,
7561 		end);
7562 }
7563 
parseErrorInsertToCompletePhrase( int start, int end, String inserted)7564 public void parseErrorInsertToCompletePhrase(
7565 	int start,
7566 	int end,
7567 	String inserted){
7568 	String[] arguments = new String[] {inserted};
7569 	this.handle(
7570 		IProblem.ParsingErrorInsertToCompletePhrase,
7571 		arguments,
7572 		arguments,
7573 		start,
7574 		end);
7575 }
parseErrorInsertToCompleteScope( int start, int end, String inserted)7576 public void parseErrorInsertToCompleteScope(
7577 	int start,
7578 	int end,
7579 	String inserted){
7580 	String[] arguments = new String[] {inserted};
7581 	this.handle(
7582 		IProblem.ParsingErrorInsertToCompleteScope,
7583 		arguments,
7584 		arguments,
7585 		start,
7586 		end);
7587 }
parseErrorInvalidToken( int start, int end, int currentKind, char[] errorTokenSource, String errorTokenName, String expectedToken)7588 public void parseErrorInvalidToken(
7589 	int start,
7590 	int end,
7591 	int currentKind,
7592 	char[] errorTokenSource,
7593 	String errorTokenName,
7594 	String expectedToken){
7595 	syntaxError(
7596 		IProblem.ParsingErrorInvalidToken,
7597 		start,
7598 		end,
7599 		currentKind,
7600 		errorTokenSource,
7601 		errorTokenName,
7602 		expectedToken);
7603 }
parseErrorMergeTokens( int start, int end, String expectedToken)7604 public void parseErrorMergeTokens(
7605 	int start,
7606 	int end,
7607 	String expectedToken){
7608 	String[] arguments = new String[] {expectedToken};
7609 	this.handle(
7610 		IProblem.ParsingErrorMergeTokens,
7611 		arguments,
7612 		arguments,
7613 		start,
7614 		end);
7615 }
parseErrorMisplacedConstruct( int start, int end)7616 public void parseErrorMisplacedConstruct(
7617 	int start,
7618 	int end){
7619 	this.handle(
7620 		IProblem.ParsingErrorMisplacedConstruct,
7621 		NoArgument,
7622 		NoArgument,
7623 		start,
7624 		end);
7625 }
parseErrorNoSuggestion( int start, int end, int currentKind, char[] errorTokenSource, String errorTokenName)7626 public void parseErrorNoSuggestion(
7627 	int start,
7628 	int end,
7629 	int currentKind,
7630 	char[] errorTokenSource,
7631 	String errorTokenName){
7632 	syntaxError(
7633 		IProblem.ParsingErrorNoSuggestion,
7634 		start,
7635 		end,
7636 		currentKind,
7637 		errorTokenSource,
7638 		errorTokenName,
7639 		null);
7640 }
parseErrorNoSuggestionForTokens( int start, int end)7641 public void parseErrorNoSuggestionForTokens(
7642 	int start,
7643 	int end){
7644 	this.handle(
7645 		IProblem.ParsingErrorNoSuggestionForTokens,
7646 		NoArgument,
7647 		NoArgument,
7648 		start,
7649 		end);
7650 }
parseErrorReplaceToken( int start, int end, int currentKind, char[] errorTokenSource, String errorTokenName, String expectedToken)7651 public void parseErrorReplaceToken(
7652 	int start,
7653 	int end,
7654 	int currentKind,
7655 	char[] errorTokenSource,
7656 	String errorTokenName,
7657 	String expectedToken){
7658 	handleSyntaxError(
7659 		IProblem.ParsingError,
7660 		start,
7661 		end,
7662 		currentKind,
7663 		errorTokenSource,
7664 		errorTokenName,
7665 		expectedToken);
7666 }
parseErrorReplaceTokens( int start, int end, String expectedToken)7667 public void parseErrorReplaceTokens(
7668 	int start,
7669 	int end,
7670 	String expectedToken){
7671 	String[] arguments = new String[] {expectedToken};
7672 	this.handle(
7673 		IProblem.ParsingErrorReplaceTokens,
7674 		arguments,
7675 		arguments,
7676 		start,
7677 		end);
7678 }
parseErrorUnexpectedEnd( int start, int end)7679 public void parseErrorUnexpectedEnd(
7680 	int start,
7681 	int end){
7682 
7683 	String[] arguments;
7684 	if(this.referenceContext instanceof ConstructorDeclaration) {
7685 		arguments = new String[] {Messages.parser_endOfConstructor};
7686 	} else if(this.referenceContext instanceof MethodDeclaration) {
7687 		arguments = new String[] {Messages.parser_endOfMethod};
7688 	} else if(this.referenceContext instanceof TypeDeclaration) {
7689 		arguments = new String[] {Messages.parser_endOfInitializer};
7690 	} else {
7691 		arguments = new String[] {Messages.parser_endOfFile};
7692 	}
7693 	this.handle(
7694 		IProblem.ParsingErrorUnexpectedEOF,
7695 		arguments,
7696 		arguments,
7697 		start,
7698 		end);
7699 }
possibleAccidentalBooleanAssignment(Assignment assignment)7700 public void possibleAccidentalBooleanAssignment(Assignment assignment) {
7701 	this.handle(
7702 		IProblem.PossibleAccidentalBooleanAssignment,
7703 		NoArgument,
7704 		NoArgument,
7705 		assignment.sourceStart,
7706 		assignment.sourceEnd);
7707 }
possibleFallThroughCase(CaseStatement caseStatement)7708 public void possibleFallThroughCase(CaseStatement caseStatement) {
7709 	// as long as we consider fake reachable as reachable, better keep 'possible' in the name
7710 	this.handle(
7711 		IProblem.FallthroughCase,
7712 		NoArgument,
7713 		NoArgument,
7714 		caseStatement.sourceStart,
7715 		caseStatement.sourceEnd);
7716 }
publicClassMustMatchFileName(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl)7717 public void publicClassMustMatchFileName(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
7718 	this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
7719 	String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
7720 	this.handle(
7721 		IProblem.PublicClassMustMatchFileName,
7722 		arguments,
7723 		arguments,
7724 		typeDecl.sourceStart,
7725 		typeDecl.sourceEnd,
7726 		compUnitDecl.compilationResult);
7727 }
rawMemberTypeCannotBeParameterized(ASTNode location, ReferenceBinding type, TypeBinding[] argumentTypes)7728 public void rawMemberTypeCannotBeParameterized(ASTNode location, ReferenceBinding type, TypeBinding[] argumentTypes) {
7729 	if (location == null) { // binary case
7730 	    this.handle(
7731 			IProblem.RawMemberTypeCannotBeParameterized,
7732 			new String[] {new String(type.readableName()), typesAsString(argumentTypes, false), new String(type.enclosingType().readableName())},
7733 			new String[] {new String(type.shortReadableName()), typesAsString(argumentTypes, true), new String(type.enclosingType().shortReadableName())},
7734 			ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
7735 			0,
7736 			0);
7737 	    return;
7738 	}
7739     this.handle(
7740 		IProblem.RawMemberTypeCannotBeParameterized,
7741 		new String[] {new String(type.readableName()), typesAsString(argumentTypes, false), new String(type.enclosingType().readableName())},
7742 		new String[] {new String(type.shortReadableName()), typesAsString(argumentTypes, true), new String(type.enclosingType().shortReadableName())},
7743 		location.sourceStart,
7744 		location.sourceEnd);
7745 }
rawTypeReference(ASTNode location, TypeBinding type)7746 public void rawTypeReference(ASTNode location, TypeBinding type) {
7747 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
7748 	type = type.leafComponentType();
7749     this.handle(
7750 		IProblem.RawTypeReference,
7751 		new String[] {new String(type.readableName()), new String(type.erasure().readableName()), },
7752 		new String[] {new String(type.shortReadableName()),new String(type.erasure().shortReadableName()),},
7753 		location.sourceStart,
7754 		nodeSourceEnd(null, location, Integer.MAX_VALUE));
7755 }
recursiveConstructorInvocation(ExplicitConstructorCall constructorCall)7756 public void recursiveConstructorInvocation(ExplicitConstructorCall constructorCall) {
7757 	this.handle(
7758 		IProblem.RecursiveConstructorInvocation,
7759 		new String[] {
7760 			new String(constructorCall.binding.declaringClass.readableName()),
7761 			typesAsString(constructorCall.binding, false)
7762 		},
7763 		new String[] {
7764 			new String(constructorCall.binding.declaringClass.shortReadableName()),
7765 			typesAsString(constructorCall.binding, true)
7766 		},
7767 		constructorCall.sourceStart,
7768 		constructorCall.sourceEnd);
7769 }
redefineArgument(Argument arg)7770 public void redefineArgument(Argument arg) {
7771 	String[] arguments = new String[] {new String(arg.name)};
7772 	this.handle(
7773 		IProblem.RedefinedArgument,
7774 		arguments,
7775 		arguments,
7776 		arg.sourceStart,
7777 		arg.sourceEnd);
7778 }
redefineLocal(LocalDeclaration localDecl)7779 public void redefineLocal(LocalDeclaration localDecl) {
7780 	String[] arguments = new String[] {new String(localDecl.name)};
7781 	this.handle(
7782 		IProblem.RedefinedLocal,
7783 		arguments,
7784 		arguments,
7785 		localDecl.sourceStart,
7786 		localDecl.sourceEnd);
7787 }
redundantSuperInterface(SourceTypeBinding type, TypeReference reference, ReferenceBinding superinterface, ReferenceBinding declaringType)7788 public void redundantSuperInterface(SourceTypeBinding type, TypeReference reference, ReferenceBinding superinterface, ReferenceBinding declaringType) {
7789 	int severity = computeSeverity(IProblem.RedundantSuperinterface);
7790 	if (severity != ProblemSeverities.Ignore) {
7791 		this.handle(
7792 			IProblem.RedundantSuperinterface,
7793 			new String[] {
7794 				new String(superinterface.readableName()),
7795 				new String(type.readableName()),
7796 				new String(declaringType.readableName())},
7797 			new String[] {
7798 				new String(superinterface.shortReadableName()),
7799 				new String(type.shortReadableName()),
7800 				new String(declaringType.shortReadableName())},
7801 			severity,
7802 			reference.sourceStart,
7803 			reference.sourceEnd);
7804 	}
7805 }
referenceMustBeArrayTypeAt(TypeBinding arrayType, ArrayReference arrayRef)7806 public void referenceMustBeArrayTypeAt(TypeBinding arrayType, ArrayReference arrayRef) {
7807 	this.handle(
7808 		IProblem.ArrayReferenceRequired,
7809 		new String[] {new String(arrayType.readableName())},
7810 		new String[] {new String(arrayType.shortReadableName())},
7811 		arrayRef.sourceStart,
7812 		arrayRef.sourceEnd);
7813 }
repeatedAnnotationWithContainer(Annotation annotation, Annotation container)7814 public void repeatedAnnotationWithContainer(Annotation annotation, Annotation container) {
7815 	this.handle(
7816 		IProblem.RepeatedAnnotationWithContainerAnnotation,
7817 		new String[] {new String(annotation.resolvedType.readableName()), new String(container.resolvedType.readableName())},
7818 		new String[] {new String(annotation.resolvedType.shortReadableName()), new String(container.resolvedType.shortReadableName())},
7819 		annotation.sourceStart,
7820 		annotation.sourceEnd);
7821 }
containerAnnotationTypeMustHaveValue(ASTNode markerNode, ReferenceBinding containerAnnotationType)7822 public void containerAnnotationTypeMustHaveValue(ASTNode markerNode, ReferenceBinding containerAnnotationType) {
7823 	this.handle(
7824 		IProblem.ContainerAnnotationTypeMustHaveValue,
7825 		new String[] {new String(containerAnnotationType.readableName())},
7826 		new String[] {new String(containerAnnotationType.shortReadableName())},
7827 		markerNode.sourceStart,
7828 		markerNode.sourceEnd);
7829 }
containerAnnotationTypeHasWrongValueType(ASTNode markerNode, ReferenceBinding containerAnnotationType, ReferenceBinding annotationType, TypeBinding returnType)7830 public void containerAnnotationTypeHasWrongValueType(ASTNode markerNode, ReferenceBinding containerAnnotationType, ReferenceBinding annotationType, TypeBinding returnType) {
7831 	this.handle(
7832 		IProblem.ContainerAnnotationTypeHasWrongValueType,
7833 		new String[] {new String(containerAnnotationType.readableName()), new String(annotationType.readableName()), new String(returnType.readableName())},
7834 		new String[] {new String(containerAnnotationType.shortReadableName()), new String(annotationType.shortReadableName()), new String(returnType.shortReadableName())},
7835 		markerNode.sourceStart,
7836 		markerNode.sourceEnd);
7837 }
containerAnnotationTypeHasNonDefaultMembers(ASTNode markerNode, ReferenceBinding containerAnnotationType, char[] selector)7838 public void containerAnnotationTypeHasNonDefaultMembers(ASTNode markerNode, ReferenceBinding containerAnnotationType, char[] selector) {
7839 	this.handle(
7840 		IProblem.ContainerAnnotationTypeHasNonDefaultMembers,
7841 		new String[] {new String(containerAnnotationType.readableName()), new String(selector)},
7842 		new String[] {new String(containerAnnotationType.shortReadableName()), new String(selector)},
7843 		markerNode.sourceStart,
7844 		markerNode.sourceEnd);
7845 }
containerAnnotationTypeHasShorterRetention(ASTNode markerNode, ReferenceBinding annotationType, String annotationRetention, ReferenceBinding containerAnnotationType, String containerRetention)7846 public void containerAnnotationTypeHasShorterRetention(ASTNode markerNode, ReferenceBinding annotationType, String annotationRetention, ReferenceBinding containerAnnotationType, String containerRetention) {
7847 	this.handle(
7848 		IProblem.ContainerAnnotationTypeHasShorterRetention,
7849 		new String[] {new String(annotationType.readableName()), annotationRetention, new String(containerAnnotationType.readableName()), containerRetention},
7850 		new String[] {new String(annotationType.shortReadableName()), annotationRetention, new String(containerAnnotationType.shortReadableName()), containerRetention},
7851 		markerNode.sourceStart,
7852 		markerNode.sourceEnd);
7853 }
repeatableAnnotationTypeTargetMismatch(ASTNode markerNode, ReferenceBinding annotationType, ReferenceBinding containerAnnotationType, String unmetTargets)7854 public void repeatableAnnotationTypeTargetMismatch(ASTNode markerNode, ReferenceBinding annotationType, ReferenceBinding containerAnnotationType, String unmetTargets) {
7855 	this.handle(
7856 		IProblem.RepeatableAnnotationTypeTargetMismatch,
7857 		new String[] {new String(annotationType.readableName()), new String(containerAnnotationType.readableName()), unmetTargets},
7858 		new String[] {new String(annotationType.shortReadableName()), new String(containerAnnotationType.shortReadableName()), unmetTargets},
7859 		markerNode.sourceStart,
7860 		markerNode.sourceEnd);
7861 }
7862 
repeatableAnnotationTypeIsDocumented(ASTNode markerNode, ReferenceBinding annotationType, ReferenceBinding containerAnnotationType)7863 public void repeatableAnnotationTypeIsDocumented(ASTNode markerNode, ReferenceBinding annotationType, ReferenceBinding containerAnnotationType) {
7864 	this.handle(
7865 		IProblem.RepeatableAnnotationTypeIsDocumented,
7866 		new String[] {new String(annotationType.readableName()), new String(containerAnnotationType.readableName())},
7867 		new String[] {new String(annotationType.shortReadableName()), new String(containerAnnotationType.shortReadableName())},
7868 		markerNode.sourceStart,
7869 		markerNode.sourceEnd);
7870 }
7871 
repeatableAnnotationTypeIsInherited(ASTNode markerNode, ReferenceBinding annotationType, ReferenceBinding containerAnnotationType)7872 public void repeatableAnnotationTypeIsInherited(ASTNode markerNode, ReferenceBinding annotationType, ReferenceBinding containerAnnotationType) {
7873 	this.handle(
7874 		IProblem.RepeatableAnnotationTypeIsInherited,
7875 		new String[] {new String(annotationType.readableName()), new String(containerAnnotationType.readableName())},
7876 		new String[] {new String(annotationType.shortReadableName()), new String(containerAnnotationType.shortReadableName())},
7877 		markerNode.sourceStart,
7878 		markerNode.sourceEnd);
7879 }
7880 
repeatableAnnotationWithRepeatingContainer(Annotation annotation, ReferenceBinding containerType)7881 public void repeatableAnnotationWithRepeatingContainer(Annotation annotation, ReferenceBinding containerType) {
7882 	this.handle(
7883 		IProblem.RepeatableAnnotationWithRepeatingContainerAnnotation,
7884 		new String[] {new String(annotation.resolvedType.readableName()), new String(containerType.readableName())},
7885 		new String[] {new String(annotation.resolvedType.shortReadableName()), new String(containerType.shortReadableName())},
7886 		annotation.sourceStart,
7887 		annotation.sourceEnd);
7888 }
7889 
reset()7890 public void reset() {
7891 	this.positionScanner = null;
7892 }
resourceHasToImplementAutoCloseable(TypeBinding binding, ASTNode reference)7893 public void resourceHasToImplementAutoCloseable(TypeBinding binding, ASTNode reference) {
7894 	if (this.options.sourceLevel < ClassFileConstants.JDK1_7) {
7895 		return; // Not supported in 1.7 would have been reported. Hence another not required
7896 	}
7897 	this.handle(
7898 			IProblem.ResourceHasToImplementAutoCloseable,
7899 			new String[] {new String(binding.readableName())},
7900 			new String[] {new String(binding.shortReadableName())},
7901 			reference.sourceStart,
7902 			reference.sourceEnd);
7903 }
retrieveClosingAngleBracketPosition(int start)7904 private int retrieveClosingAngleBracketPosition(int start) {
7905 	if (this.referenceContext == null) return start;
7906 	CompilationResult compilationResult = this.referenceContext.compilationResult();
7907 	if (compilationResult == null) return start;
7908 	ICompilationUnit compilationUnit = compilationResult.getCompilationUnit();
7909 	if (compilationUnit == null) return start;
7910 	char[] contents = compilationUnit.getContents();
7911 	if (contents.length == 0) return start;
7912 	if (this.positionScanner == null) {
7913 		this.positionScanner = new Scanner(false, false, false, this.options.sourceLevel, this.options.complianceLevel, null, null, false,
7914 				this.options.enablePreviewFeatures);
7915 		this.positionScanner.returnOnlyGreater = true;
7916 	}
7917 	this.positionScanner.setSource(contents);
7918 	this.positionScanner.resetTo(start, contents.length);
7919 	int end = start;
7920 	int count = 0;
7921 	try {
7922 		int token;
7923 		loop: while ((token = this.positionScanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
7924 			switch(token) {
7925 				case TerminalTokens.TokenNameLESS:
7926 					count++;
7927 					break;
7928 				case TerminalTokens.TokenNameGREATER:
7929 					count--;
7930 					if (count == 0) {
7931 						end = this.positionScanner.currentPosition - 1;
7932 						break loop;
7933 					}
7934 					break;
7935 				case TerminalTokens.TokenNameLBRACE :
7936 					break loop;
7937 			}
7938 		}
7939 	} catch(InvalidInputException e) {
7940 		// ignore
7941 	}
7942 	return end;
7943 }
retrieveEndingPositionAfterOpeningParenthesis(int sourceStart, int sourceEnd, int numberOfParen)7944 private int retrieveEndingPositionAfterOpeningParenthesis(int sourceStart, int sourceEnd, int numberOfParen) {
7945 	if (this.referenceContext == null) return sourceEnd;
7946 	CompilationResult compilationResult = this.referenceContext.compilationResult();
7947 	if (compilationResult == null) return sourceEnd;
7948 	ICompilationUnit compilationUnit = compilationResult.getCompilationUnit();
7949 	if (compilationUnit == null) return sourceEnd;
7950 	char[] contents = compilationUnit.getContents();
7951 	if (contents.length == 0) return sourceEnd;
7952 	if (this.positionScanner == null) {
7953 		this.positionScanner = new Scanner(false, false, false, this.options.sourceLevel, this.options.complianceLevel, null, null, false,
7954 				this.options.enablePreviewFeatures);
7955 	}
7956 	this.positionScanner.setSource(contents);
7957 	this.positionScanner.resetTo(sourceStart, sourceEnd);
7958 	try {
7959 		int token;
7960 		int previousSourceEnd = sourceEnd;
7961 		while ((token = this.positionScanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
7962 			switch(token) {
7963 				case TerminalTokens.TokenNameRPAREN:
7964 					return previousSourceEnd;
7965 				default :
7966 					previousSourceEnd = this.positionScanner.currentPosition - 1;
7967 			}
7968 		}
7969 	} catch(InvalidInputException e) {
7970 		// ignore
7971 	}
7972 	return sourceEnd;
7973 }
retrieveStartingPositionAfterOpeningParenthesis(int sourceStart, int sourceEnd, int numberOfParen)7974 private int retrieveStartingPositionAfterOpeningParenthesis(int sourceStart, int sourceEnd, int numberOfParen) {
7975 	if (this.referenceContext == null) return sourceStart;
7976 	CompilationResult compilationResult = this.referenceContext.compilationResult();
7977 	if (compilationResult == null) return sourceStart;
7978 	ICompilationUnit compilationUnit = compilationResult.getCompilationUnit();
7979 	if (compilationUnit == null) return sourceStart;
7980 	char[] contents = compilationUnit.getContents();
7981 	if (contents.length == 0) return sourceStart;
7982 	if (this.positionScanner == null) {
7983 		this.positionScanner = new Scanner(false, false, false, this.options.sourceLevel, this.options.complianceLevel, null, null, false,
7984 				this.options.enablePreviewFeatures);
7985 	}
7986 	this.positionScanner.setSource(contents);
7987 	this.positionScanner.resetTo(sourceStart, sourceEnd);
7988 	int count = 0;
7989 	try {
7990 		int token;
7991 		while ((token = this.positionScanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
7992 			switch(token) {
7993 				case TerminalTokens.TokenNameLPAREN:
7994 					count++;
7995 					if (count == numberOfParen) {
7996 						this.positionScanner.getNextToken();
7997 						return this.positionScanner.startPosition;
7998 					}
7999 			}
8000 		}
8001 	} catch(InvalidInputException e) {
8002 		// ignore
8003 	}
8004 	return sourceStart;
8005 }
scannerError(Parser parser, String errorTokenName)8006 public void scannerError(Parser parser, String errorTokenName) {
8007 	Scanner scanner = parser.scanner;
8008 
8009 	int flag = IProblem.ParsingErrorNoSuggestion;
8010 	int startPos = scanner.startPosition;
8011 	int endPos = scanner.currentPosition - 1;
8012 
8013 	//special treatment for recognized errors....
8014 	if (errorTokenName.equals(Scanner.END_OF_SOURCE))
8015 		flag = IProblem.EndOfSource;
8016 	else if (errorTokenName.equals(Scanner.INVALID_HEXA))
8017 		flag = IProblem.InvalidHexa;
8018 	else if (errorTokenName.equals(Scanner.ILLEGAL_HEXA_LITERAL))
8019 		flag = IProblem.IllegalHexaLiteral;
8020 	else if (errorTokenName.equals(Scanner.INVALID_OCTAL))
8021 		flag = IProblem.InvalidOctal;
8022 	else if (errorTokenName.equals(Scanner.INVALID_CHARACTER_CONSTANT))
8023 		flag = IProblem.InvalidCharacterConstant;
8024 	else if (errorTokenName.equals(Scanner.INVALID_ESCAPE))
8025 		flag = IProblem.InvalidEscape;
8026 	else if (errorTokenName.equals(Scanner.INVALID_UNICODE_ESCAPE)){
8027 		flag = IProblem.InvalidUnicodeEscape;
8028 		// better locate the error message
8029 		char[] source = scanner.source;
8030 		int checkPos = scanner.currentPosition - 1;
8031 		if (checkPos >= source.length) checkPos = source.length - 1;
8032 		while (checkPos >= startPos){
8033 			if (source[checkPos] == '\\') break;
8034 			checkPos --;
8035 		}
8036 		startPos = checkPos;
8037 	} else if (errorTokenName.equals(Scanner.INVALID_LOW_SURROGATE)) {
8038 		flag = IProblem.InvalidLowSurrogate;
8039 	} else if (errorTokenName.equals(Scanner.INVALID_HIGH_SURROGATE)) {
8040 		flag = IProblem.InvalidHighSurrogate;
8041 		// better locate the error message
8042 		char[] source = scanner.source;
8043 		int checkPos = scanner.startPosition + 1;
8044 		while (checkPos <= endPos){
8045 			if (source[checkPos] == '\\') break;
8046 			checkPos ++;
8047 		}
8048 		endPos = checkPos - 1;
8049 	} else if (errorTokenName.equals(Scanner.INVALID_FLOAT))
8050 		flag = IProblem.InvalidFloat;
8051 	else if (errorTokenName.equals(Scanner.UNTERMINATED_STRING))
8052 		flag = IProblem.UnterminatedString;
8053 	else if (errorTokenName.equals(Scanner.UNTERMINATED_TEXT_BLOCK))
8054 		flag = IProblem.UnterminatedTextBlock;
8055 	else if (errorTokenName.equals(Scanner.UNTERMINATED_COMMENT))
8056 		flag = IProblem.UnterminatedComment;
8057 	else if (errorTokenName.equals(Scanner.INVALID_CHAR_IN_STRING))
8058 		flag = IProblem.UnterminatedString;
8059 	else if (errorTokenName.equals(Scanner.INVALID_DIGIT))
8060 		flag = IProblem.InvalidDigit;
8061 	else if (errorTokenName.equals(Scanner.INVALID_BINARY))
8062 		flag = IProblem.InvalidBinary;
8063 	else if (errorTokenName.equals(Scanner.BINARY_LITERAL_NOT_BELOW_17))
8064 		flag = IProblem.BinaryLiteralNotBelow17;
8065 	else if (errorTokenName.equals(Scanner.INVALID_UNDERSCORE))
8066 		flag = IProblem.IllegalUnderscorePosition;
8067 	else if (errorTokenName.equals(Scanner.UNDERSCORES_IN_LITERALS_NOT_BELOW_17))
8068 		flag = IProblem.UnderscoresInLiteralsNotBelow17;
8069 
8070 	String[] arguments = flag == IProblem.ParsingErrorNoSuggestion
8071 			? new String[] {errorTokenName}
8072 			: NoArgument;
8073 	this.handle(
8074 		flag,
8075 		arguments,
8076 		arguments,
8077 		// this is the current -invalid- token position
8078 		startPos,
8079 		endPos,
8080 		parser.compilationUnit.compilationResult);
8081 }
shouldImplementHashcode(SourceTypeBinding type)8082 public void shouldImplementHashcode(SourceTypeBinding type) {
8083 	this.handle(
8084 		IProblem.ShouldImplementHashcode,
8085 		new String[] {new String(type.readableName())},
8086 		new String[] {new String(type.shortReadableName())},
8087 		type.sourceStart(),
8088 		type.sourceEnd());
8089 }
shouldReturn(TypeBinding returnType, ASTNode location)8090 public void shouldReturn(TypeBinding returnType, ASTNode location) {
8091 	int sourceStart = location.sourceStart;
8092 	int sourceEnd = location.sourceEnd;
8093 	if (location instanceof LambdaExpression) {
8094 		LambdaExpression exp = (LambdaExpression) location;
8095 		sourceStart = exp.sourceStart;
8096 		sourceEnd = exp.diagnosticsSourceEnd();
8097 	}
8098 	this.handle(
8099 		methodHasMissingSwitchDefault() ? IProblem.ShouldReturnValueHintMissingDefault : IProblem.ShouldReturnValue,
8100 		new String[] { new String (returnType.readableName())},
8101 		new String[] { new String (returnType.shortReadableName())},
8102 		sourceStart,
8103 		sourceEnd);
8104 }
8105 
signalNoImplicitStringConversionForCharArrayExpression(Expression expression)8106 public void signalNoImplicitStringConversionForCharArrayExpression(Expression expression) {
8107 	this.handle(
8108 		IProblem.NoImplicitStringConversionForCharArrayExpression,
8109 		NoArgument,
8110 		NoArgument,
8111 		expression.sourceStart,
8112 		expression.sourceEnd);
8113 }
staticAndInstanceConflict(MethodBinding currentMethod, MethodBinding inheritedMethod)8114 public void staticAndInstanceConflict(MethodBinding currentMethod, MethodBinding inheritedMethod) {
8115 	if (currentMethod.isStatic())
8116 		this.handle(
8117 			// This static method cannot hide the instance method from %1
8118 			// 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.
8119 			IProblem.CannotHideAnInstanceMethodWithAStaticMethod,
8120 			new String[] {new String(inheritedMethod.declaringClass.readableName())},
8121 			new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
8122 			currentMethod.sourceStart(),
8123 			currentMethod.sourceEnd());
8124 	else
8125 		this.handle(
8126 			// This instance method cannot override the static method from %1
8127 			// 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.
8128 			IProblem.CannotOverrideAStaticMethodWithAnInstanceMethod,
8129 			new String[] {new String(inheritedMethod.declaringClass.readableName())},
8130 			new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
8131 			currentMethod.sourceStart(),
8132 			currentMethod.sourceEnd());
8133 }
staticFieldAccessToNonStaticVariable(ASTNode location, FieldBinding field)8134 public void staticFieldAccessToNonStaticVariable(ASTNode location, FieldBinding field) {
8135 	String[] arguments = new String[] {new String(field.readableName())};
8136 	this.handle(
8137 		IProblem.NonStaticFieldFromStaticInvocation,
8138 		arguments,
8139 		arguments,
8140 		nodeSourceStart(field,location),
8141 		nodeSourceEnd(field, location));
8142 }
staticInheritedMethodConflicts(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods)8143 public void staticInheritedMethodConflicts(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
8144 	this.handle(
8145 		// The static method %1 conflicts with the abstract method in %2
8146 		// 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.
8147 		IProblem.StaticInheritedMethodConflicts,
8148 		new String[] {
8149 			new String(concreteMethod.readableName()),
8150 			new String(abstractMethods[0].declaringClass.readableName())},
8151 		new String[] {
8152 			new String(concreteMethod.readableName()),
8153 			new String(abstractMethods[0].declaringClass.shortReadableName())},
8154 		type.sourceStart(),
8155 		type.sourceEnd());
8156 }
staticMemberOfParameterizedType(ASTNode location, ReferenceBinding type, ReferenceBinding qualifyingType, int index)8157 public void staticMemberOfParameterizedType(ASTNode location, ReferenceBinding type, ReferenceBinding qualifyingType, int index) {
8158 	if (location == null) { // binary case
8159 	    this.handle(
8160 			IProblem.StaticMemberOfParameterizedType,
8161 			new String[] {new String(type.readableName()), new String(type.enclosingType().readableName()), },
8162 			new String[] {new String(type.shortReadableName()), new String(type.enclosingType().shortReadableName()), },
8163 			ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
8164 			0,
8165 			0);
8166 	    return;
8167 	}
8168 	/*if (location instanceof ArrayTypeReference) {
8169 		ArrayTypeReference arrayTypeReference = (ArrayTypeReference) location;
8170 		if (arrayTypeReference.token != null && arrayTypeReference.token.length == 0) return;
8171 		end = arrayTypeReference.originalSourceEnd;
8172 	}*/
8173     this.handle(
8174 		IProblem.StaticMemberOfParameterizedType,
8175 		new String[] {new String(type.readableName()), new String(qualifyingType.readableName()), },
8176 		new String[] {new String(type.shortReadableName()), new String(qualifyingType.shortReadableName()), },
8177 		location.sourceStart,
8178 		nodeSourceEnd(null, location, index));
8179 }
stringConstantIsExceedingUtf8Limit(ASTNode location)8180 public void stringConstantIsExceedingUtf8Limit(ASTNode location) {
8181 	this.handle(
8182 		IProblem.StringConstantIsExceedingUtf8Limit,
8183 		NoArgument,
8184 		NoArgument,
8185 		location.sourceStart,
8186 		location.sourceEnd);
8187 }
superclassMustBeAClass(SourceTypeBinding type, TypeReference superclassRef, ReferenceBinding superType)8188 public void superclassMustBeAClass(SourceTypeBinding type, TypeReference superclassRef, ReferenceBinding superType) {
8189 	this.handle(
8190 		IProblem.SuperclassMustBeAClass,
8191 		new String[] {new String(superType.readableName()), new String(type.sourceName())},
8192 		new String[] {new String(superType.shortReadableName()), new String(type.sourceName())},
8193 		superclassRef.sourceStart,
8194 		superclassRef.sourceEnd);
8195 }
superfluousSemicolon(int sourceStart, int sourceEnd)8196 public void superfluousSemicolon(int sourceStart, int sourceEnd) {
8197 	this.handle(
8198 		IProblem.SuperfluousSemicolon,
8199 		NoArgument,
8200 		NoArgument,
8201 		sourceStart,
8202 		sourceEnd);
8203 }
superinterfaceMustBeAnInterface(SourceTypeBinding type, TypeReference superInterfaceRef, ReferenceBinding superType)8204 public void superinterfaceMustBeAnInterface(SourceTypeBinding type, TypeReference superInterfaceRef, ReferenceBinding superType) {
8205 	this.handle(
8206 		IProblem.SuperInterfaceMustBeAnInterface,
8207 		new String[] {new String(superType.readableName()), new String(type.sourceName())},
8208 		new String[] {new String(superType.shortReadableName()), new String(type.sourceName())},
8209 		superInterfaceRef.sourceStart,
8210 		superInterfaceRef.sourceEnd);
8211 }
superinterfacesCollide(TypeBinding type, ASTNode decl, TypeBinding superType, TypeBinding inheritedSuperType)8212 public void superinterfacesCollide(TypeBinding type, ASTNode decl, TypeBinding superType, TypeBinding inheritedSuperType) {
8213 	this.handle(
8214 		IProblem.SuperInterfacesCollide,
8215 		new String[] {new String(superType.readableName()), new String(inheritedSuperType.readableName()), new String(type.sourceName())},
8216 		new String[] {new String(superType.shortReadableName()), new String(inheritedSuperType.shortReadableName()), new String(type.sourceName())},
8217 		decl.sourceStart,
8218 		decl.sourceEnd);
8219 }
superTypeCannotUseWildcard(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding)8220 public void superTypeCannotUseWildcard(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) {
8221 	String name = new String(type.sourceName());
8222 	String superTypeFullName = new String(superTypeBinding.readableName());
8223 	String superTypeShortName = new String(superTypeBinding.shortReadableName());
8224 	if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName;
8225 	this.handle(
8226 		IProblem.SuperTypeUsingWildcard,
8227 		new String[] {superTypeFullName, name},
8228 		new String[] {superTypeShortName, name},
8229 		superclass.sourceStart,
8230 		superclass.sourceEnd);
8231 }
handleSyntaxErrorOnNewTokens( int id, int start, int end, int currentKind, char[] errorTokenSource, String errorTokenName, String expectedToken)8232 private boolean handleSyntaxErrorOnNewTokens(
8233 	int id,
8234 	int start,
8235 	int end,
8236 	int currentKind,
8237 	char[] errorTokenSource,
8238 	String errorTokenName,
8239 	String expectedToken) {
8240 	boolean val = false;
8241 	if (isIdentifier(currentKind)) {
8242 		String eTokenName = new String(errorTokenSource);
8243 		String origExpectedToken = expectedToken;
8244 		expectedToken = replaceIfSynthetic(expectedToken);
8245 		if (isIdentifier(currentKind)) {
8246 			if (RESTRICTED_IDENTIFIER_RECORD.equals(origExpectedToken) && RECORD.equals(eTokenName)) {
8247 				if (this.options.sourceLevel < ClassFileConstants.JDK14) {
8248 					previewFeatureNotSupported(start, end, RECORD, CompilerOptions.VERSION_14);
8249 					val = true;
8250 				} else if (!this.options.enablePreviewFeatures) {
8251 					previewFeatureNotEnabled(start, end, RECORD);
8252 					val = true;
8253 				}
8254 			}
8255 		}
8256 	}
8257 	return val;
8258 }
handleSyntaxError( int id, int start, int end, int currentKind, char[] errorTokenSource, String errorTokenName, String expectedToken)8259 private void handleSyntaxError(
8260 	int id,
8261 	int start,
8262 	int end,
8263 	int currentKind,
8264 	char[] errorTokenSource,
8265 	String errorTokenName,
8266 	String expectedToken) {
8267 	if (!handleSyntaxErrorOnNewTokens(
8268 			IProblem.ParsingError,
8269 			start,
8270 			end,
8271 			currentKind,
8272 			errorTokenSource,
8273 			errorTokenName,
8274 			expectedToken
8275 			)) {
8276 		syntaxError(
8277 			IProblem.ParsingError,
8278 			start,
8279 			end,
8280 			currentKind,
8281 			errorTokenSource,
8282 			errorTokenName,
8283 			expectedToken);
8284 	}
8285 }
syntaxError( int id, int startPosition, int endPosition, int currentKind, char[] currentTokenSource, String errorTokenName, String expectedToken)8286 private void syntaxError(
8287 	int id,
8288 	int startPosition,
8289 	int endPosition,
8290 	int currentKind,
8291 	char[] currentTokenSource,
8292 	String errorTokenName,
8293 	String expectedToken) {
8294 
8295 	if (currentKind == TerminalTokens.TokenNameAT && expectedToken != null && expectedToken.equals("@")) { //$NON-NLS-1$
8296 		// In the diagnose parser case, we don't have the wherewithal to discriminate when we should hand out @308 vs @. So we always answer @.
8297 		// We should silently recover so swallow the message.
8298 		return;
8299 	}
8300 	String eTokenName;
8301 	if (isKeyword(currentKind) ||
8302 		isLiteral(currentKind) ||
8303 		isIdentifier(currentKind)) {
8304 			eTokenName = new String(currentTokenSource);
8305 	} else {
8306 		eTokenName = errorTokenName;
8307 	}
8308 
8309 	String[] arguments;
8310 	if(expectedToken != null) {
8311 		expectedToken = replaceIfSynthetic(expectedToken);
8312 		arguments = new String[] {eTokenName, expectedToken};
8313 	} else {
8314 		arguments = new String[] {eTokenName};
8315 	}
8316 	this.handle(
8317 		id,
8318 		arguments,
8319 		arguments,
8320 		startPosition,
8321 		endPosition);
8322 }
replaceIfSynthetic(String token)8323 private String replaceIfSynthetic(String token) {
8324 	/* Java 8 grammar changes use some synthetic tokens to make the grammar LALR(1). These tokens should not be exposed in messages
8325 	   as it would make no sense to the programmer whatsoever. Replace such artificial tokens with some "suitable"  alternative. At
8326 	   the moment, there are two synthetic tokens that need such massaging viz : "BeginLambda" and "BeginTypeArguments". There is a
8327 	   third synthetic token "ElidedSemicolonAndRightBrace" that we don't expect to show up in messages since it is manufactured by
8328 	   the parser automatically.
8329 	*/
8330 	if (token.equals("BeginTypeArguments")) //$NON-NLS-1$
8331 		return "."; //$NON-NLS-1$
8332 	if (token.equals("BeginLambda")) //$NON-NLS-1$
8333 		return "("; //$NON-NLS-1$
8334 	if (token.equals("RestrictedIdentifierYield")) //$NON-NLS-1$
8335 		return "yield"; //$NON-NLS-1$
8336 	if (token.equals(RESTRICTED_IDENTIFIER_RECORD))
8337 		return RECORD;
8338 	return token;
8339 }
task(String tag, String message, String priority, int start, int end)8340 public void task(String tag, String message, String priority, int start, int end){
8341 	this.handle(
8342 		IProblem.Task,
8343 		new String[] { tag, message, priority/*secret argument that is not surfaced in getMessage()*/},
8344 		new String[] { tag, message, priority/*secret argument that is not surfaced in getMessage()*/},
8345 		start,
8346 		end);
8347 }
8348 
tooManyDimensions(ASTNode expression)8349 public void tooManyDimensions(ASTNode expression) {
8350 	this.handle(
8351 		IProblem.TooManyArrayDimensions,
8352 		NoArgument,
8353 		NoArgument,
8354 		expression.sourceStart,
8355 		expression.sourceEnd);
8356 }
8357 
tooManyFields(TypeDeclaration typeDeclaration)8358 public void tooManyFields(TypeDeclaration typeDeclaration) {
8359 	this.handle(
8360 		IProblem.TooManyFields,
8361 		new String[]{ new String(typeDeclaration.binding.readableName())},
8362 		new String[]{ new String(typeDeclaration.binding.shortReadableName())},
8363 		ProblemSeverities.Abort | ProblemSeverities.Error | ProblemSeverities.Fatal,
8364 		typeDeclaration.sourceStart,
8365 		typeDeclaration.sourceEnd);
8366 }
tooManyMethods(TypeDeclaration typeDeclaration)8367 public void tooManyMethods(TypeDeclaration typeDeclaration) {
8368 	this.handle(
8369 		IProblem.TooManyMethods,
8370 		new String[]{ new String(typeDeclaration.binding.readableName())},
8371 		new String[]{ new String(typeDeclaration.binding.shortReadableName())},
8372 		ProblemSeverities.Abort | ProblemSeverities.Error | ProblemSeverities.Fatal,
8373 		typeDeclaration.sourceStart,
8374 		typeDeclaration.sourceEnd);
8375 }
tooManyParametersForSyntheticMethod(AbstractMethodDeclaration method)8376 public void tooManyParametersForSyntheticMethod(AbstractMethodDeclaration method) {
8377 	MethodBinding binding = method.binding;
8378 	String selector = null;
8379 	if (binding.isConstructor()) {
8380 		selector = new String(binding.declaringClass.sourceName());
8381 	} else {
8382 		selector = new String(method.selector);
8383 	}
8384 	this.handle(
8385 		IProblem.TooManyParametersForSyntheticMethod,
8386 		new String[] {selector, typesAsString(binding, false), new String(binding.declaringClass.readableName()), },
8387 		new String[] {selector, typesAsString(binding, true), new String(binding.declaringClass.shortReadableName()),},
8388 		ProblemSeverities.AbortMethod | ProblemSeverities.Error | ProblemSeverities.Fatal,
8389 		method.sourceStart,
8390 		method.sourceEnd);
8391 }
typeCastError(CastExpression expression, TypeBinding leftType, TypeBinding rightType)8392 public void typeCastError(CastExpression expression, TypeBinding leftType, TypeBinding rightType) {
8393 	String leftName = new String(leftType.readableName());
8394 	String rightName = new String(rightType.readableName());
8395 	String leftShortName = new String(leftType.shortReadableName());
8396 	String rightShortName = new String(rightType.shortReadableName());
8397 	if (leftShortName.equals(rightShortName)){
8398 		leftShortName = leftName;
8399 		rightShortName = rightName;
8400 	}
8401 	this.handle(
8402 		IProblem.IllegalCast,
8403 		new String[] { rightName, leftName },
8404 		new String[] { rightShortName, leftShortName },
8405 		expression.sourceStart,
8406 		expression.sourceEnd);
8407 }
unsafeCastInInstanceof(Expression expression, TypeBinding leftType, TypeBinding rightType)8408 public void unsafeCastInInstanceof(Expression expression, TypeBinding leftType, TypeBinding rightType) {
8409 	String leftName = new String(leftType.readableName());
8410 	String rightName = new String(rightType.readableName());
8411 	String leftShortName = new String(leftType.shortReadableName());
8412 	String rightShortName = new String(rightType.shortReadableName());
8413 	if (leftShortName.equals(rightShortName)){
8414 		leftShortName = leftName;
8415 		rightShortName = rightName;
8416 	}
8417 	this.handle(
8418 		IProblem.UnsafeCast,
8419 		new String[] { rightName, leftName },
8420 		new String[] { rightShortName, leftShortName },
8421 		expression.sourceStart,
8422 		expression.sourceEnd);
8423 }
typeCollidesWithEnclosingType(TypeDeclaration typeDecl)8424 public void typeCollidesWithEnclosingType(TypeDeclaration typeDecl) {
8425 	String[] arguments = new String[] {new String(typeDecl.name)};
8426 	this.handle(
8427 		IProblem.HidingEnclosingType,
8428 		arguments,
8429 		arguments,
8430 		typeDecl.sourceStart,
8431 		typeDecl.sourceEnd);
8432 }
typeCollidesWithPackage(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl)8433 public void typeCollidesWithPackage(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
8434 	this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
8435 	String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
8436 	this.handle(
8437 		IProblem.TypeCollidesWithPackage,
8438 		arguments,
8439 		arguments,
8440 		typeDecl.sourceStart,
8441 		typeDecl.sourceEnd,
8442 		compUnitDecl.compilationResult);
8443 }
typeHiding(TypeDeclaration typeDecl, TypeBinding hiddenType)8444 public void typeHiding(TypeDeclaration typeDecl, TypeBinding hiddenType) {
8445 	int severity = computeSeverity(IProblem.TypeHidingType);
8446 	if (severity == ProblemSeverities.Ignore) return;
8447 	this.handle(
8448 		IProblem.TypeHidingType,
8449 		new String[] { new String(typeDecl.name) , new String(hiddenType.shortReadableName()) },
8450 		new String[] { new String(typeDecl.name) , new String(hiddenType.readableName()) },
8451 		severity,
8452 		typeDecl.sourceStart,
8453 		typeDecl.sourceEnd);
8454 }
typeHiding(TypeDeclaration typeDecl, TypeVariableBinding hiddenTypeParameter)8455 public void typeHiding(TypeDeclaration typeDecl, TypeVariableBinding hiddenTypeParameter) {
8456 	int severity = computeSeverity(IProblem.TypeHidingTypeParameterFromType);
8457 	if (severity == ProblemSeverities.Ignore) return;
8458 	if (hiddenTypeParameter.declaringElement instanceof TypeBinding) {
8459 		TypeBinding declaringType = (TypeBinding) hiddenTypeParameter.declaringElement;
8460 		this.handle(
8461 			IProblem.TypeHidingTypeParameterFromType,
8462 			new String[] { new String(typeDecl.name) , new String(hiddenTypeParameter.readableName()), new String(declaringType.readableName())  },
8463 			new String[] { new String(typeDecl.name) , new String(hiddenTypeParameter.shortReadableName()), new String(declaringType.shortReadableName()) },
8464 			severity,
8465 			typeDecl.sourceStart,
8466 			typeDecl.sourceEnd);
8467 	} else {
8468 		// type parameter of generic method
8469 		MethodBinding declaringMethod = (MethodBinding) hiddenTypeParameter.declaringElement;
8470 		this.handle(
8471 				IProblem.TypeHidingTypeParameterFromMethod,
8472 				new String[] {
8473 						new String(typeDecl.name),
8474 						new String(hiddenTypeParameter.readableName()),
8475 						new String(declaringMethod.selector),
8476 						typesAsString(declaringMethod, false),
8477 						new String(declaringMethod.declaringClass.readableName()),
8478 				},
8479 				new String[] {
8480 						new String(typeDecl.name),
8481 						new String(hiddenTypeParameter.shortReadableName()),
8482 						new String(declaringMethod.selector),
8483 						typesAsString(declaringMethod, true),
8484 						new String(declaringMethod.declaringClass.shortReadableName()),
8485 				},
8486 				severity,
8487 				typeDecl.sourceStart,
8488 				typeDecl.sourceEnd);
8489 	}
8490 }
typeHiding(TypeParameter typeParam, Binding hidden)8491 public void typeHiding(TypeParameter typeParam, Binding hidden) {
8492 	int severity = computeSeverity(IProblem.TypeParameterHidingType);
8493 	if (severity == ProblemSeverities.Ignore) return;
8494 	TypeBinding hiddenType = (TypeBinding) hidden;
8495 	this.handle(
8496 		IProblem.TypeParameterHidingType,
8497 		new String[] { new String(typeParam.name) , new String(hiddenType.readableName())  },
8498 		new String[] { new String(typeParam.name) , new String(hiddenType.shortReadableName()) },
8499 		severity,
8500 		typeParam.sourceStart,
8501 		typeParam.sourceEnd);
8502 }
notAnnotationType(TypeBinding actualType, ASTNode location)8503 public void notAnnotationType(TypeBinding actualType, ASTNode location) {
8504 	this.handle(
8505 			IProblem.NotAnnotationType,
8506 			new String[] {new String(actualType.leafComponentType().readableName())},
8507 			new String[] {new String(actualType.leafComponentType().shortReadableName())},
8508 			location.sourceStart,
8509 			location.sourceEnd);
8510 }
typeMismatchError(TypeBinding actualType, TypeBinding expectedType, ASTNode location, ASTNode expectingLocation)8511 public void typeMismatchError(TypeBinding actualType, TypeBinding expectedType, ASTNode location, ASTNode expectingLocation) {
8512 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) { // don't expose type variable names, complain on erased types
8513 		if (actualType instanceof TypeVariableBinding)
8514 			actualType = actualType.erasure();
8515 		if (expectedType instanceof TypeVariableBinding)
8516 			expectedType = expectedType.erasure();
8517 	}
8518 	if (actualType != null && (actualType.tagBits & TagBits.HasMissingType) != 0) { // improve secondary error
8519 		if (location instanceof Annotation) {
8520 			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=376977
8521 			return; // Already reported, don't report a secondary error
8522 		}
8523 		this.handle(
8524 				IProblem.UndefinedType,
8525 				new String[] {new String(actualType.leafComponentType().readableName())},
8526 				new String[] {new String(actualType.leafComponentType().shortReadableName())},
8527 				location.sourceStart,
8528 				location.sourceEnd);
8529 			return;
8530 	}
8531 	if (expectingLocation != null && (expectedType.tagBits & TagBits.HasMissingType) != 0) { // improve secondary error
8532 		this.handle(
8533 				IProblem.UndefinedType,
8534 				new String[] {new String(expectedType.leafComponentType().readableName())},
8535 				new String[] {new String(expectedType.leafComponentType().shortReadableName())},
8536 				expectingLocation.sourceStart,
8537 				expectingLocation.sourceEnd);
8538 			return;
8539 	}
8540 
8541 	char[] actualShortReadableName = actualType.shortReadableName();
8542 	char[] expectedShortReadableName = expectedType.shortReadableName();
8543 	char[] actualReadableName = actualType.readableName();
8544 	char[] expectedReadableName = expectedType.readableName();
8545 	if (CharOperation.equals(actualShortReadableName, expectedShortReadableName)) {
8546 		if (CharOperation.equals(actualReadableName, expectedReadableName)) {
8547 			// if full type names are equal, assume the incompatibility is due to mismatching null annotations:
8548 			actualReadableName = actualType.nullAnnotatedReadableName(this.options, false);
8549 			expectedReadableName = expectedType.nullAnnotatedReadableName(this.options, false);
8550 			actualShortReadableName = actualType.nullAnnotatedReadableName(this.options, true);
8551 			expectedShortReadableName = expectedType.nullAnnotatedReadableName(this.options, true);
8552 		} else {
8553 			actualShortReadableName = actualReadableName;
8554 			expectedShortReadableName = expectedReadableName;
8555 		}
8556 	}
8557 	this.handle(
8558 		expectingLocation instanceof ReturnStatement ? IProblem.ReturnTypeMismatch : IProblem.TypeMismatch,
8559 		new String[] {new String(actualReadableName), new String(expectedReadableName)},
8560 		new String[] {new String(actualShortReadableName), new String(expectedShortReadableName)},
8561 		location.sourceStart,
8562 		location.sourceEnd);
8563 }
typeMismatchError(TypeBinding typeArgument, TypeVariableBinding typeParameter, ReferenceBinding genericType, ASTNode location)8564 public void typeMismatchError(TypeBinding typeArgument, TypeVariableBinding typeParameter, ReferenceBinding genericType, ASTNode location) {
8565 	if (location == null) { // binary case
8566 		this.handle(
8567 			IProblem.TypeArgumentMismatch,
8568 			new String[] { new String(typeArgument.readableName()), new String(genericType.readableName()), new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, false) },
8569 			new String[] { new String(typeArgument.shortReadableName()), new String(genericType.shortReadableName()), new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, true) },
8570 			ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
8571 			0,
8572 			0);
8573         return;
8574     }
8575 	this.handle(
8576 		IProblem.TypeArgumentMismatch,
8577 		new String[] { new String(typeArgument.readableName()), new String(genericType.readableName()), new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, false) },
8578 		new String[] { new String(typeArgument.shortReadableName()), new String(genericType.shortReadableName()), new String(typeParameter.sourceName()), parameterBoundAsString(typeParameter, true) },
8579 		location.sourceStart,
8580 		location.sourceEnd);
8581 }
typesAsString(MethodBinding methodBinding, boolean makeShort)8582 private String typesAsString(MethodBinding methodBinding, boolean makeShort) {
8583 	return typesAsString(methodBinding, methodBinding.parameters, makeShort);
8584 }
typesAsString(MethodBinding methodBinding, TypeBinding[] parameters, boolean makeShort)8585 private String typesAsString(MethodBinding methodBinding, TypeBinding[] parameters, boolean makeShort) {
8586 	return typesAsString(methodBinding, parameters, makeShort, false);
8587 }
typesAsString(MethodBinding methodBinding, boolean makeShort, boolean showNullAnnotations)8588 private String typesAsString(MethodBinding methodBinding, boolean makeShort, boolean showNullAnnotations) {
8589 	return typesAsString(methodBinding, methodBinding.parameters, makeShort, showNullAnnotations);
8590 }
typesAsString(MethodBinding methodBinding, TypeBinding[] parameters, boolean makeShort, boolean showNullAnnotations)8591 private String typesAsString(MethodBinding methodBinding, TypeBinding[] parameters, boolean makeShort, boolean showNullAnnotations) {
8592 	if (methodBinding.isPolymorphic()) {
8593 		// get the original polymorphicMethod method
8594 		TypeBinding[] types = methodBinding.original().parameters;
8595 		StringBuffer buffer = new StringBuffer(10);
8596 		for (int i = 0, length = types.length; i < length; i++) {
8597 			if (i != 0) {
8598 				buffer.append(", "); //$NON-NLS-1$
8599 			}
8600 			TypeBinding type = types[i];
8601 			boolean isVarargType = i == length-1;
8602 			if (isVarargType) {
8603 				type = ((ArrayBinding)type).elementsType();
8604 			}
8605 			if (showNullAnnotations)
8606 				buffer.append(new String(type.nullAnnotatedReadableName(this.options, makeShort)));
8607 			else
8608 				buffer.append(new String(makeShort ? type.shortReadableName() : type.readableName()));
8609 			if (isVarargType) {
8610 				buffer.append("..."); //$NON-NLS-1$
8611 			}
8612 		}
8613 		return buffer.toString();
8614 	}
8615 	StringBuffer buffer = new StringBuffer(10);
8616 	for (int i = 0, length = parameters.length; i < length; i++) {
8617 		if (i != 0) {
8618 			buffer.append(", "); //$NON-NLS-1$
8619 		}
8620 		TypeBinding type = parameters[i];
8621 		boolean isVarargType = methodBinding.isVarargs() && i == length-1;
8622 		if (isVarargType) {
8623 			type = ((ArrayBinding)type).elementsType();
8624 		}
8625 		if (showNullAnnotations)
8626 			buffer.append(new String(type.nullAnnotatedReadableName(this.options, makeShort)));
8627 		else
8628 			buffer.append(new String(makeShort ? type.shortReadableName() : type.readableName()));
8629 		if (isVarargType) {
8630 			buffer.append("..."); //$NON-NLS-1$
8631 		}
8632 	}
8633 	return buffer.toString();
8634 }
typesAsString(TypeBinding[] types, boolean makeShort)8635 private String typesAsString(TypeBinding[] types, boolean makeShort) {
8636 	return typesAsString(types, makeShort, false);
8637 }
typesAsString(TypeBinding[] types, boolean makeShort, boolean showNullAnnotations)8638 private String typesAsString(TypeBinding[] types, boolean makeShort, boolean showNullAnnotations) {
8639 	StringBuffer buffer = new StringBuffer(10);
8640 	for (int i = 0, length = types.length; i < length; i++) {
8641 		if (i != 0) {
8642 			buffer.append(", "); //$NON-NLS-1$
8643 		}
8644 		TypeBinding type = types[i];
8645 		if (showNullAnnotations)
8646 			buffer.append(new String(type.nullAnnotatedReadableName(this.options, makeShort)));
8647 		else
8648 			buffer.append(new String(makeShort ? type.shortReadableName() : type.readableName()));
8649 	}
8650 	return buffer.toString();
8651 }
8652 
undefinedAnnotationValue(TypeBinding annotationType, MemberValuePair memberValuePair)8653 public void undefinedAnnotationValue(TypeBinding annotationType, MemberValuePair memberValuePair) {
8654 	if (isRecoveredName(memberValuePair.name)) return;
8655 	String name = 	new String(memberValuePair.name);
8656 	this.handle(
8657 		IProblem.UndefinedAnnotationMember,
8658 		new String[] { name, new String(annotationType.readableName())},
8659 		new String[] {	name, new String(annotationType.shortReadableName())},
8660 		memberValuePair.sourceStart,
8661 		memberValuePair.sourceEnd);
8662 }
undefinedLabel(BranchStatement statement)8663 public void undefinedLabel(BranchStatement statement) {
8664 	if (isRecoveredName(statement.label)) return;
8665 	String[] arguments = new String[] {new String(statement.label)};
8666 	this.handle(
8667 		IProblem.UndefinedLabel,
8668 		arguments,
8669 		arguments,
8670 		statement.sourceStart,
8671 		statement.sourceEnd);
8672 }
8673 // can only occur inside binaries
undefinedTypeVariableSignature(char[] variableName, ReferenceBinding binaryType)8674 public void undefinedTypeVariableSignature(char[] variableName, ReferenceBinding binaryType) {
8675 	this.handle(
8676 		IProblem.UndefinedTypeVariable,
8677 		new String[] {new String(variableName), new String(binaryType.readableName()) },
8678 		new String[] {new String(variableName), new String(binaryType.shortReadableName())},
8679 		ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
8680 		0,
8681 		0);
8682 }
undocumentedEmptyBlock(int blockStart, int blockEnd)8683 public void undocumentedEmptyBlock(int blockStart, int blockEnd) {
8684 	this.handle(
8685 		IProblem.UndocumentedEmptyBlock,
8686 		NoArgument,
8687 		NoArgument,
8688 		blockStart,
8689 		blockEnd);
8690 }
unexpectedStaticModifierForField(SourceTypeBinding type, FieldDeclaration fieldDecl)8691 public void unexpectedStaticModifierForField(SourceTypeBinding type, FieldDeclaration fieldDecl) {
8692 	String[] arguments = new String[] {new String(fieldDecl.name)};
8693 	this.handle(
8694 		IProblem.UnexpectedStaticModifierForField,
8695 		arguments,
8696 		arguments,
8697 		fieldDecl.sourceStart,
8698 		fieldDecl.sourceEnd);
8699 }
unexpectedStaticModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl)8700 public void unexpectedStaticModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
8701 	String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
8702 	this.handle(
8703 		IProblem.UnexpectedStaticModifierForMethod,
8704 		arguments,
8705 		arguments,
8706 		methodDecl.sourceStart,
8707 		methodDecl.sourceEnd);
8708 }
unhandledException(TypeBinding exceptionType, ASTNode location)8709 public void unhandledException(TypeBinding exceptionType, ASTNode location) {
8710 
8711 	boolean insideDefaultConstructor =
8712 		(this.referenceContext instanceof ConstructorDeclaration)
8713 			&& ((ConstructorDeclaration)this.referenceContext).isDefaultConstructor();
8714 	boolean insideImplicitConstructorCall =
8715 		(location instanceof ExplicitConstructorCall)
8716 			&& (((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper);
8717 
8718 	int sourceEnd = location.sourceEnd;
8719 	if (location instanceof LocalDeclaration) {
8720 		sourceEnd = ((LocalDeclaration) location).declarationEnd;
8721 	}
8722 	this.handle(
8723 		insideDefaultConstructor
8724 			? IProblem.UnhandledExceptionInDefaultConstructor
8725 			: (insideImplicitConstructorCall
8726 					? IProblem.UndefinedConstructorInImplicitConstructorCall
8727 					: IProblem.UnhandledException),
8728 		new String[] {new String(exceptionType.readableName())},
8729 		new String[] {new String(exceptionType.shortReadableName())},
8730 		location.sourceStart,
8731 		sourceEnd);
8732 }
unhandledExceptionFromAutoClose(TypeBinding exceptionType, ASTNode location)8733 public void unhandledExceptionFromAutoClose (TypeBinding exceptionType, ASTNode location) {
8734 	Binding binding = null;
8735 	if (location instanceof LocalDeclaration) {
8736 		binding = ((LocalDeclaration)location).binding;
8737 	} else if (location instanceof  NameReference) {
8738 		binding = ((NameReference) location).binding;
8739 	} else if (location instanceof FieldReference) {
8740 		binding = ((FieldReference) location).binding;
8741 	}
8742 	if (binding != null) {
8743 		this.handle(
8744 			IProblem.UnhandledExceptionOnAutoClose,
8745 			new String[] {
8746 					new String(exceptionType.readableName()),
8747 					new String(binding.readableName())},
8748 			new String[] {
8749 					new String(exceptionType.shortReadableName()),
8750 					new String(binding.shortReadableName())},
8751 			location.sourceStart,
8752 			location.sourceEnd);
8753 	}
8754 }
unhandledWarningToken(Expression token)8755 public void unhandledWarningToken(Expression token) {
8756 	String[] arguments = new String[] { token.constant.stringValue() };
8757 	this.handle(
8758 		IProblem.UnhandledWarningToken,
8759 		arguments,
8760 		arguments,
8761 		token.sourceStart,
8762 		token.sourceEnd);
8763 }
uninitializedBlankFinalField(FieldBinding field, ASTNode location)8764 public void uninitializedBlankFinalField(FieldBinding field, ASTNode location) {
8765 	String[] arguments = new String[] {new String(field.readableName())};
8766 	this.handle(
8767 		methodHasMissingSwitchDefault() ? IProblem.UninitializedBlankFinalFieldHintMissingDefault : IProblem.UninitializedBlankFinalField,
8768 		arguments,
8769 		arguments,
8770 		nodeSourceStart(field, location),
8771 		nodeSourceEnd(field, location));
8772 }
uninitializedNonNullField(FieldBinding field, ASTNode location)8773 public void uninitializedNonNullField(FieldBinding field, ASTNode location) {
8774 	char[][] nonNullAnnotationName = this.options.nonNullAnnotationName;
8775 	if(!field.isNonNull()) {
8776 		String[] arguments = new String[] {
8777 				new String(field.readableName()),
8778 				new String(field.type.readableName()),
8779 				new String(nonNullAnnotationName[nonNullAnnotationName.length-1])
8780 		};
8781 		this.handle(
8782 				methodHasMissingSwitchDefault() ? IProblem.UninitializedFreeTypeVariableFieldHintMissingDefault : IProblem.UninitializedFreeTypeVariableField,
8783 				arguments,
8784 				arguments,
8785 				nodeSourceStart(field, location),
8786 				nodeSourceEnd(field, location));
8787 		return;
8788 	}
8789 	String[] arguments = new String[] {
8790 			new String(nonNullAnnotationName[nonNullAnnotationName.length-1]),
8791 			new String(field.readableName())
8792 	};
8793 	this.handle(
8794 		methodHasMissingSwitchDefault() ? IProblem.UninitializedNonNullFieldHintMissingDefault : IProblem.UninitializedNonNullField,
8795 		arguments,
8796 		arguments,
8797 		nodeSourceStart(field, location),
8798 		nodeSourceEnd(field, location));
8799 }
uninitializedLocalVariable(LocalVariableBinding binding, ASTNode location, Scope scope)8800 public void uninitializedLocalVariable(LocalVariableBinding binding, ASTNode location, Scope scope) {
8801 	if ((binding.modifiers & ExtraCompilerModifiers.AccPatternVariable) == 0) {
8802 		binding.markAsUninitializedIn(scope);
8803 		String[] arguments = new String[] {new String(binding.readableName())};
8804 		this.handle(
8805 				methodHasMissingSwitchDefault() ? IProblem.UninitializedLocalVariableHintMissingDefault : IProblem.UninitializedLocalVariable,
8806 						arguments,
8807 						arguments,
8808 						nodeSourceStart(binding, location),
8809 						nodeSourceEnd(binding, location));
8810 	} else {
8811 		String[] arguments = new String[] {new String(binding.readableName())};
8812 		this.handle(
8813 				IProblem.PatternVariableNotInScope,
8814 						arguments,
8815 						arguments,
8816 						nodeSourceStart(binding, location),
8817 						nodeSourceEnd(binding, location));
8818 
8819 	}
8820 }
methodHasMissingSwitchDefault()8821 private boolean methodHasMissingSwitchDefault() {
8822 	MethodScope methodScope = null;
8823 	if (this.referenceContext instanceof Block) {
8824 		methodScope = ((Block)this.referenceContext).scope.methodScope();
8825 	} else if (this.referenceContext instanceof AbstractMethodDeclaration) {
8826 		methodScope = ((AbstractMethodDeclaration)this.referenceContext).scope;
8827 	}
8828 	return methodScope != null && methodScope.hasMissingSwitchDefault;
8829 }
unmatchedBracket(int position, ReferenceContext context, CompilationResult compilationResult)8830 public void unmatchedBracket(int position, ReferenceContext context, CompilationResult compilationResult) {
8831 	this.handle(
8832 		IProblem.UnmatchedBracket,
8833 		NoArgument,
8834 		NoArgument,
8835 		position,
8836 		position,
8837 		context,
8838 		compilationResult);
8839 }
unnecessaryCast(CastExpression castExpression)8840 public void unnecessaryCast(CastExpression castExpression) {
8841 	if (castExpression.expression instanceof FunctionalExpression)
8842 		return;
8843 	int severity = computeSeverity(IProblem.UnnecessaryCast);
8844 	if (severity == ProblemSeverities.Ignore) return;
8845 	TypeBinding castedExpressionType = castExpression.expression.resolvedType;
8846 	this.handle(
8847 		IProblem.UnnecessaryCast,
8848 		new String[]{ new String(castedExpressionType.readableName()), new String(castExpression.type.resolvedType.readableName())},
8849 		new String[]{ new String(castedExpressionType.shortReadableName()), new String(castExpression.type.resolvedType.shortReadableName())},
8850 		severity,
8851 		castExpression.sourceStart,
8852 		castExpression.sourceEnd);
8853 }
unnecessaryElse(ASTNode location)8854 public void unnecessaryElse(ASTNode location) {
8855 	this.handle(
8856 		IProblem.UnnecessaryElse,
8857 		NoArgument,
8858 		NoArgument,
8859 		location.sourceStart,
8860 		location.sourceEnd);
8861 }
unnecessaryEnclosingInstanceSpecification(Expression expression, ReferenceBinding targetType)8862 public void unnecessaryEnclosingInstanceSpecification(Expression expression, ReferenceBinding targetType) {
8863 	this.handle(
8864 		IProblem.IllegalEnclosingInstanceSpecification,
8865 		new String[]{ new String(targetType.readableName())},
8866 		new String[]{ new String(targetType.shortReadableName())},
8867 		expression.sourceStart,
8868 		expression.sourceEnd);
8869 }
unnecessaryInstanceof(InstanceOfExpression instanceofExpression, TypeBinding checkType)8870 public void unnecessaryInstanceof(InstanceOfExpression instanceofExpression, TypeBinding checkType) {
8871 	int severity = computeSeverity(IProblem.UnnecessaryInstanceof);
8872 	if (severity == ProblemSeverities.Ignore) return;
8873 	TypeBinding expressionType = instanceofExpression.expression.resolvedType;
8874 	this.handle(
8875 		IProblem.UnnecessaryInstanceof,
8876 		new String[]{ new String(expressionType.readableName()), new String(checkType.readableName())},
8877 		new String[]{ new String(expressionType.shortReadableName()), new String(checkType.shortReadableName())},
8878 		severity,
8879 		instanceofExpression.sourceStart,
8880 		instanceofExpression.sourceEnd);
8881 }
unnecessaryNLSTags(int sourceStart, int sourceEnd)8882 public void unnecessaryNLSTags(int sourceStart, int sourceEnd) {
8883 	this.handle(
8884 		IProblem.UnnecessaryNLSTag,
8885 		NoArgument,
8886 		NoArgument,
8887 		sourceStart,
8888 		sourceEnd);
8889 }
unnecessaryTypeArgumentsForMethodInvocation(MethodBinding method, TypeBinding[] genericTypeArguments, TypeReference[] typeArguments)8890 public void unnecessaryTypeArgumentsForMethodInvocation(MethodBinding method, TypeBinding[] genericTypeArguments, TypeReference[] typeArguments) {
8891 	String methodName = method.isConstructor()
8892 		? new String(method.declaringClass.shortReadableName())
8893 		: new String(method.selector);
8894 	this.handle(
8895 			method.isConstructor()
8896 				? IProblem.UnusedTypeArgumentsForConstructorInvocation
8897 				: IProblem.UnusedTypeArgumentsForMethodInvocation,
8898 		new String[] {
8899 				methodName,
8900 		        typesAsString(method, false),
8901 		        new String(method.declaringClass.readableName()),
8902 		        typesAsString(genericTypeArguments, false) },
8903 		new String[] {
8904 				methodName,
8905 		        typesAsString(method, true),
8906 		        new String(method.declaringClass.shortReadableName()),
8907 		        typesAsString(genericTypeArguments, true) },
8908 		typeArguments[0].sourceStart,
8909 		typeArguments[typeArguments.length-1].sourceEnd);
8910 }
unqualifiedFieldAccess(NameReference reference, FieldBinding field)8911 public void unqualifiedFieldAccess(NameReference reference, FieldBinding field) {
8912 	int sourceStart = reference.sourceStart;
8913 	int sourceEnd = reference.sourceEnd;
8914 	if (reference instanceof SingleNameReference) {
8915 		int numberOfParens = (reference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
8916 		if (numberOfParens != 0) {
8917 			sourceStart = retrieveStartingPositionAfterOpeningParenthesis(sourceStart, sourceEnd, numberOfParens);
8918 			sourceEnd = retrieveEndingPositionAfterOpeningParenthesis(sourceStart, sourceEnd, numberOfParens);
8919 		} else {
8920 			sourceStart = nodeSourceStart(field, reference);
8921 			sourceEnd = nodeSourceEnd(field, reference);
8922 		}
8923 	} else {
8924 		sourceStart = nodeSourceStart(field, reference);
8925 		sourceEnd = nodeSourceEnd(field, reference);
8926 	}
8927 	this.handle(
8928 		IProblem.UnqualifiedFieldAccess,
8929 		new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
8930 		new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
8931 		sourceStart,
8932 		sourceEnd);
8933 }
unreachableCatchBlock(ReferenceBinding exceptionType, ASTNode location)8934 public void unreachableCatchBlock(ReferenceBinding exceptionType, ASTNode location) {
8935 	this.handle(
8936 		IProblem.UnreachableCatch,
8937 		new String[] {
8938 			new String(exceptionType.readableName()),
8939 		 },
8940 		new String[] {
8941 			new String(exceptionType.shortReadableName()),
8942 		 },
8943 		location.sourceStart,
8944 		location.sourceEnd);
8945 }
unreachableCode(Statement statement)8946 public void unreachableCode(Statement statement) {
8947 	int sourceStart = statement.sourceStart;
8948 	int sourceEnd = statement.sourceEnd;
8949 	if (statement instanceof LocalDeclaration) {
8950 		LocalDeclaration declaration = (LocalDeclaration) statement;
8951 		sourceStart = declaration.declarationSourceStart;
8952 		sourceEnd = declaration.declarationSourceEnd;
8953 	} else if (statement instanceof Expression &&  ((Expression) statement).isTrulyExpression()) {
8954 		int statemendEnd = ((Expression) statement).statementEnd;
8955 		if (statemendEnd != -1) sourceEnd = statemendEnd;
8956 	}
8957 	this.handle(
8958 		IProblem.CodeCannotBeReached,
8959 		NoArgument,
8960 		NoArgument,
8961 		sourceStart,
8962 		sourceEnd);
8963 }
unresolvableReference(NameReference nameRef, Binding binding)8964 public void unresolvableReference(NameReference nameRef, Binding binding) {
8965 /* also need to check that the searchedType is the receiver type
8966 	if (binding instanceof ProblemBinding) {
8967 		ProblemBinding problem = (ProblemBinding) binding;
8968 		if (problem.searchType != null && problem.searchType.isHierarchyInconsistent())
8969 			severity = SecondaryError;
8970 	}
8971 */
8972 	String[] arguments = new String[] {new String(binding.readableName())};
8973 	int end = nameRef.sourceEnd;
8974 	int sourceStart = nameRef.sourceStart;
8975 	if (nameRef instanceof QualifiedNameReference) {
8976 		QualifiedNameReference ref = (QualifiedNameReference) nameRef;
8977 		if (isRecoveredName(ref.tokens)) return;
8978 		if (ref.indexOfFirstFieldBinding >= 1)
8979 			end = (int) ref.sourcePositions[ref.indexOfFirstFieldBinding - 1];
8980 	} else {
8981 		SingleNameReference ref = (SingleNameReference) nameRef;
8982 		if (isRecoveredName(ref.token)) return;
8983 		int numberOfParens = (ref.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
8984 		if (numberOfParens != 0) {
8985 			sourceStart = retrieveStartingPositionAfterOpeningParenthesis(sourceStart, end, numberOfParens);
8986 			end = retrieveEndingPositionAfterOpeningParenthesis(sourceStart, end, numberOfParens);
8987 		}
8988 	}
8989 	int problemId = (nameRef.bits & Binding.VARIABLE) != 0 && (nameRef.bits & Binding.TYPE) == 0
8990 		? IProblem.UnresolvedVariable
8991 		: IProblem.UndefinedName;
8992 	this.handle(
8993 		problemId,
8994 		arguments,
8995 		arguments,
8996 		sourceStart,
8997 		end);
8998 }
unsafeCast(CastExpression castExpression, Scope scope)8999 public void unsafeCast(CastExpression castExpression, Scope scope) {
9000 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
9001 	int severity = computeSeverity(IProblem.UnsafeGenericCast);
9002 	if (severity == ProblemSeverities.Ignore) return;
9003 	TypeBinding castedExpressionType = castExpression.expression.resolvedType;
9004 	TypeBinding castExpressionResolvedType = castExpression.resolvedType;
9005 	this.handle(
9006 		IProblem.UnsafeGenericCast,
9007 		new String[]{
9008 			new String(castedExpressionType.readableName()),
9009 			new String(castExpressionResolvedType.readableName())
9010 		},
9011 		new String[]{
9012 			new String(castedExpressionType.shortReadableName()),
9013 			new String(castExpressionResolvedType.shortReadableName())
9014 		},
9015 		severity,
9016 		castExpression.sourceStart,
9017 		castExpression.sourceEnd);
9018 }
unsafeNullnessCast(CastExpression castExpression, Scope scope)9019 public void unsafeNullnessCast(CastExpression castExpression, Scope scope) {
9020 	TypeBinding castedExpressionType = castExpression.expression.resolvedType;
9021 	TypeBinding castExpressionResolvedType = castExpression.resolvedType;
9022 	this.handle(
9023 		IProblem.UnsafeNullnessCast,
9024 		new String[]{
9025 			new String(castedExpressionType.nullAnnotatedReadableName(this.options, false)),
9026 			new String(castExpressionResolvedType.nullAnnotatedReadableName(this.options, false))
9027 		},
9028 		new String[]{
9029 			new String(castedExpressionType.nullAnnotatedReadableName(this.options, true)),
9030 			new String(castExpressionResolvedType.nullAnnotatedReadableName(this.options, true))
9031 		},
9032 		castExpression.sourceStart,
9033 		castExpression.sourceEnd);
9034 }
unsafeGenericArrayForVarargs(TypeBinding leafComponentType, ASTNode location)9035 public void unsafeGenericArrayForVarargs(TypeBinding leafComponentType, ASTNode location) {
9036 	int severity = computeSeverity(IProblem.UnsafeGenericArrayForVarargs);
9037 	if (severity == ProblemSeverities.Ignore) return;
9038 	this.handle(
9039 		IProblem.UnsafeGenericArrayForVarargs,
9040 		new String[]{ new String(leafComponentType.readableName())},
9041 		new String[]{ new String(leafComponentType.shortReadableName())},
9042 		severity,
9043 		location.sourceStart,
9044 		location.sourceEnd);
9045 }
unsafeRawFieldAssignment(FieldBinding field, TypeBinding expressionType, ASTNode location)9046 public void unsafeRawFieldAssignment(FieldBinding field, TypeBinding expressionType, ASTNode location) {
9047 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
9048 	int severity = computeSeverity(IProblem.UnsafeRawFieldAssignment);
9049 	if (severity == ProblemSeverities.Ignore) return;
9050 	this.handle(
9051 		IProblem.UnsafeRawFieldAssignment,
9052 		new String[] {
9053 		        new String(expressionType.readableName()), new String(field.name), new String(field.declaringClass.readableName()), new String(field.declaringClass.erasure().readableName()) },
9054 		new String[] {
9055 		        new String(expressionType.shortReadableName()), new String(field.name), new String(field.declaringClass.shortReadableName()), new String(field.declaringClass.erasure().shortReadableName()) },
9056 		severity,
9057 		nodeSourceStart(field,location),
9058 		nodeSourceEnd(field, location));
9059 }
unsafeRawGenericMethodInvocation(ASTNode location, MethodBinding rawMethod, TypeBinding[] argumentTypes)9060 public void unsafeRawGenericMethodInvocation(ASTNode location, MethodBinding rawMethod, TypeBinding[] argumentTypes) {
9061 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
9062 	boolean isConstructor = rawMethod.isConstructor();
9063 	int severity = computeSeverity(isConstructor ? IProblem.UnsafeRawGenericConstructorInvocation : IProblem.UnsafeRawGenericMethodInvocation);
9064 	if (severity == ProblemSeverities.Ignore) return;
9065     if (isConstructor) {
9066 		this.handle(
9067 			IProblem.UnsafeRawGenericConstructorInvocation, // The generic constructor {0}({1}) of type {2} is applied to non-parameterized type arguments ({3})
9068 			new String[] {
9069 				new String(rawMethod.declaringClass.sourceName()),
9070 				typesAsString(rawMethod.original(), false),
9071 				new String(rawMethod.declaringClass.readableName()),
9072 				typesAsString(argumentTypes, false),
9073 			 },
9074 			new String[] {
9075 				new String(rawMethod.declaringClass.sourceName()),
9076 				typesAsString(rawMethod.original(), true),
9077 				new String(rawMethod.declaringClass.shortReadableName()),
9078 				typesAsString(argumentTypes, true),
9079 			 },
9080 			severity,
9081 			location.sourceStart,
9082 			location.sourceEnd);
9083     } else {
9084 		this.handle(
9085 			IProblem.UnsafeRawGenericMethodInvocation,
9086 			new String[] {
9087 				new String(rawMethod.selector),
9088 				typesAsString(rawMethod.original(), false),
9089 				new String(rawMethod.declaringClass.readableName()),
9090 				typesAsString(argumentTypes, false),
9091 			 },
9092 			new String[] {
9093 				new String(rawMethod.selector),
9094 				typesAsString(rawMethod.original(), true),
9095 				new String(rawMethod.declaringClass.shortReadableName()),
9096 				typesAsString(argumentTypes, true),
9097 			 },
9098 			severity,
9099 			location.sourceStart,
9100 			location.sourceEnd);
9101     }
9102 }
unsafeRawInvocation(ASTNode location, MethodBinding rawMethod)9103 public void unsafeRawInvocation(ASTNode location, MethodBinding rawMethod) {
9104 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
9105 	boolean isConstructor = rawMethod.isConstructor();
9106 	int severity = computeSeverity(isConstructor ? IProblem.UnsafeRawConstructorInvocation : IProblem.UnsafeRawMethodInvocation);
9107 	if (severity == ProblemSeverities.Ignore) return;
9108     if (isConstructor) {
9109 		this.handle(
9110 			IProblem.UnsafeRawConstructorInvocation,
9111 			new String[] {
9112 				new String(rawMethod.declaringClass.readableName()),
9113 				typesAsString(rawMethod.original(), rawMethod.parameters, false),
9114 				new String(rawMethod.declaringClass.erasure().readableName()),
9115 			 },
9116 			new String[] {
9117 				new String(rawMethod.declaringClass.shortReadableName()),
9118 				typesAsString(rawMethod.original(), rawMethod.parameters, true),
9119 				new String(rawMethod.declaringClass.erasure().shortReadableName()),
9120 			 },
9121 			severity,
9122 			location.sourceStart,
9123 			location.sourceEnd);
9124     } else {
9125 		this.handle(
9126 			IProblem.UnsafeRawMethodInvocation,
9127 			new String[] {
9128 				new String(rawMethod.selector),
9129 				typesAsString(rawMethod.original(), rawMethod.parameters, false),
9130 				new String(rawMethod.declaringClass.readableName()),
9131 				new String(rawMethod.declaringClass.erasure().readableName()),
9132 			 },
9133 			new String[] {
9134 				new String(rawMethod.selector),
9135 				typesAsString(rawMethod.original(), rawMethod.parameters, true),
9136 				new String(rawMethod.declaringClass.shortReadableName()),
9137 				new String(rawMethod.declaringClass.erasure().shortReadableName()),
9138 			 },
9139 			severity,
9140 			location.sourceStart,
9141 			location.sourceEnd);
9142     }
9143 }
unsafeReturnTypeOverride(MethodBinding currentMethod, MethodBinding inheritedMethod, SourceTypeBinding type)9144 public void unsafeReturnTypeOverride(MethodBinding currentMethod, MethodBinding inheritedMethod, SourceTypeBinding type) {
9145 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) {
9146 		return;
9147 	}
9148 	int severity = computeSeverity(IProblem.UnsafeReturnTypeOverride);
9149 	if (severity == ProblemSeverities.Ignore) return;
9150 	int start = type.sourceStart();
9151 	int end = type.sourceEnd();
9152 	if (TypeBinding.equalsEquals(currentMethod.declaringClass, type)) {
9153 		ASTNode location = ((MethodDeclaration) currentMethod.sourceMethod()).returnType;
9154 		start = location.sourceStart();
9155 		end = location.sourceEnd();
9156 	}
9157 	this.handle(
9158 			IProblem.UnsafeReturnTypeOverride,
9159 			new String[] {
9160 				new String(currentMethod.returnType.readableName()),
9161 				new String(currentMethod.selector),
9162 				typesAsString(currentMethod.original(), false),
9163 				new String(currentMethod.declaringClass.readableName()),
9164 				new String(inheritedMethod.returnType.readableName()),
9165 				new String(inheritedMethod.declaringClass.readableName()),
9166 				//new String(inheritedMethod.returnType.erasure().readableName()),
9167 			 },
9168 			new String[] {
9169 				new String(currentMethod.returnType.shortReadableName()),
9170 				new String(currentMethod.selector),
9171 				typesAsString(currentMethod.original(), true),
9172 				new String(currentMethod.declaringClass.shortReadableName()),
9173 				new String(inheritedMethod.returnType.shortReadableName()),
9174 				new String(inheritedMethod.declaringClass.shortReadableName()),
9175 				//new String(inheritedMethod.returnType.erasure().shortReadableName()),
9176 			 },
9177 			severity,
9178 			start,
9179 			end);
9180 }
unsafeTypeConversion(Expression expression, TypeBinding expressionType, TypeBinding expectedType)9181 public void unsafeTypeConversion(Expression expression, TypeBinding expressionType, TypeBinding expectedType) {
9182 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
9183 	int severity = computeSeverity(IProblem.UnsafeTypeConversion);
9184 	if (severity == ProblemSeverities.Ignore) return;
9185 	if (!this.options.reportUnavoidableGenericTypeProblems && expression.forcedToBeRaw(this.referenceContext)) {
9186 		return;
9187 	}
9188 	this.handle(
9189 		IProblem.UnsafeTypeConversion,
9190 		new String[] { new String(expressionType.readableName()), new String(expectedType.readableName()), new String(expectedType.erasure().readableName()) },
9191 		new String[] { new String(expressionType.shortReadableName()), new String(expectedType.shortReadableName()), new String(expectedType.erasure().shortReadableName()) },
9192 		severity,
9193 		expression.sourceStart,
9194 		expression.sourceEnd);
9195 }
unsafeElementTypeConversion(Expression expression, TypeBinding expressionType, TypeBinding expectedType)9196 public void unsafeElementTypeConversion(Expression expression, TypeBinding expressionType, TypeBinding expectedType) {
9197 	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
9198 	int severity = computeSeverity(IProblem.UnsafeElementTypeConversion);
9199 	if (severity == ProblemSeverities.Ignore) return;
9200 	if (!this.options.reportUnavoidableGenericTypeProblems && expression.forcedToBeRaw(this.referenceContext)) {
9201 		return;
9202 	}
9203 	this.handle(
9204 		IProblem.UnsafeElementTypeConversion,
9205 		new String[] { new String(expressionType.readableName()), new String(expectedType.readableName()), new String(expectedType.erasure().readableName()) },
9206 		new String[] { new String(expressionType.shortReadableName()), new String(expectedType.shortReadableName()), new String(expectedType.erasure().shortReadableName()) },
9207 		severity,
9208 		expression.sourceStart,
9209 		expression.sourceEnd);
9210 }
unusedArgument(LocalDeclaration localDecl)9211 public void unusedArgument(LocalDeclaration localDecl) {
9212 	int severity = computeSeverity(IProblem.ArgumentIsNeverUsed);
9213 	if (severity == ProblemSeverities.Ignore) return;
9214 	String[] arguments = new String[] {new String(localDecl.name)};
9215 	this.handle(
9216 		IProblem.ArgumentIsNeverUsed,
9217 		arguments,
9218 		arguments,
9219 		severity,
9220 		localDecl.sourceStart,
9221 		localDecl.sourceEnd);
9222 }
unusedExceptionParameter(LocalDeclaration exceptionParameter)9223 public void unusedExceptionParameter(LocalDeclaration exceptionParameter) {
9224 	int severity = computeSeverity(IProblem.ExceptionParameterIsNeverUsed);
9225 	if (severity == ProblemSeverities.Ignore) return;
9226 	String[] arguments = new String[] {new String(exceptionParameter.name)};
9227 	this.handle(
9228 		IProblem.ExceptionParameterIsNeverUsed,
9229 		arguments,
9230 		arguments,
9231 		severity,
9232 		exceptionParameter.sourceStart,
9233 		exceptionParameter.sourceEnd);
9234 }
unusedDeclaredThrownException(ReferenceBinding exceptionType, AbstractMethodDeclaration method, ASTNode location)9235 public void unusedDeclaredThrownException(ReferenceBinding exceptionType, AbstractMethodDeclaration method, ASTNode location) {
9236 	boolean isConstructor = method.isConstructor();
9237 	int severity = computeSeverity(isConstructor ? IProblem.UnusedConstructorDeclaredThrownException : IProblem.UnusedMethodDeclaredThrownException);
9238 	if (severity == ProblemSeverities.Ignore) return;
9239 	if (isConstructor) {
9240 		this.handle(
9241 			IProblem.UnusedConstructorDeclaredThrownException,
9242 			new String[] {
9243 				new String(method.binding.declaringClass.readableName()),
9244 				typesAsString(method.binding, false),
9245 				new String(exceptionType.readableName()),
9246 			 },
9247 			new String[] {
9248 				new String(method.binding.declaringClass.shortReadableName()),
9249 				typesAsString(method.binding, true),
9250 				new String(exceptionType.shortReadableName()),
9251 			 },
9252 			severity,
9253 			location.sourceStart,
9254 			location.sourceEnd);
9255 	} else {
9256 		this.handle(
9257 			IProblem.UnusedMethodDeclaredThrownException,
9258 			new String[] {
9259 				new String(method.binding.declaringClass.readableName()),
9260 				new String(method.selector),
9261 				typesAsString(method.binding, false),
9262 				new String(exceptionType.readableName()),
9263 			 },
9264 			new String[] {
9265 				new String(method.binding.declaringClass.shortReadableName()),
9266 				new String(method.selector),
9267 				typesAsString(method.binding, true),
9268 				new String(exceptionType.shortReadableName()),
9269 			 },
9270 			severity,
9271 			location.sourceStart,
9272 			location.sourceEnd);
9273 	}
9274 }
unusedImport(ImportReference importRef)9275 public void unusedImport(ImportReference importRef) {
9276 	int severity = computeSeverity(IProblem.UnusedImport);
9277 	if (severity == ProblemSeverities.Ignore) return;
9278 	String[] arguments = new String[] { CharOperation.toString(importRef.tokens) };
9279 	this.handle(
9280 		IProblem.UnusedImport,
9281 		arguments,
9282 		arguments,
9283 		severity,
9284 		importRef.sourceStart,
9285 		importRef.sourceEnd);
9286 }
unusedLabel(LabeledStatement statement)9287 public void unusedLabel(LabeledStatement statement) {
9288 	int severity = computeSeverity(IProblem.UnusedLabel);
9289 	if (severity == ProblemSeverities.Ignore) return;
9290 	String[] arguments = new String[] {new String(statement.label)};
9291 	this.handle(
9292 		IProblem.UnusedLabel,
9293 		arguments,
9294 		arguments,
9295 		severity,
9296 		statement.sourceStart,
9297 		statement.labelEnd);
9298 }
unusedLocalVariable(LocalDeclaration localDecl)9299 public void unusedLocalVariable(LocalDeclaration localDecl) {
9300 	int severity = computeSeverity(IProblem.LocalVariableIsNeverUsed);
9301 	if (severity == ProblemSeverities.Ignore) return;
9302 	String[] arguments = new String[] {new String(localDecl.name)};
9303 	this.handle(
9304 		IProblem.LocalVariableIsNeverUsed,
9305 		arguments,
9306 		arguments,
9307 		severity,
9308 		localDecl.sourceStart,
9309 		localDecl.sourceEnd);
9310 }
unusedObjectAllocation(AllocationExpression allocationExpression)9311 public void unusedObjectAllocation(AllocationExpression allocationExpression) {
9312 	this.handle(
9313 		IProblem.UnusedObjectAllocation,
9314 		NoArgument,
9315 		NoArgument,
9316 		allocationExpression.sourceStart,
9317 		allocationExpression.sourceEnd);
9318 }
unusedPrivateConstructor(ConstructorDeclaration constructorDecl)9319 public void unusedPrivateConstructor(ConstructorDeclaration constructorDecl) {
9320 
9321 	int severity = computeSeverity(IProblem.UnusedPrivateConstructor);
9322 	if (severity == ProblemSeverities.Ignore) return;
9323 
9324 	if (excludeDueToAnnotation(constructorDecl.annotations, IProblem.UnusedPrivateConstructor)) return;
9325 
9326 	MethodBinding constructor = constructorDecl.binding;
9327 	this.handle(
9328 			IProblem.UnusedPrivateConstructor,
9329 		new String[] {
9330 			new String(constructor.declaringClass.readableName()),
9331 			typesAsString(constructor, false)
9332 		 },
9333 		new String[] {
9334 			new String(constructor.declaringClass.shortReadableName()),
9335 			typesAsString(constructor, true)
9336 		 },
9337 		severity,
9338 		constructorDecl.sourceStart,
9339 		constructorDecl.sourceEnd);
9340 }
unusedPrivateField(FieldDeclaration fieldDecl)9341 public void unusedPrivateField(FieldDeclaration fieldDecl) {
9342 
9343 	int severity = computeSeverity(IProblem.UnusedPrivateField);
9344 	if (severity == ProblemSeverities.Ignore) return;
9345 
9346 	FieldBinding field = fieldDecl.binding;
9347 
9348 	if (CharOperation.equals(TypeConstants.SERIALVERSIONUID, field.name)
9349 			&& field.isStatic()
9350 			&& field.isFinal()
9351 			&& TypeBinding.equalsEquals(TypeBinding.LONG, field.type)) {
9352 		ReferenceBinding referenceBinding = field.declaringClass;
9353 		if (referenceBinding != null) {
9354 			if (referenceBinding.findSuperTypeOriginatingFrom(TypeIds.T_JavaIoSerializable, false /*Serializable is not a class*/) != null) {
9355 				return; // do not report unused serialVersionUID field for class that implements Serializable
9356 			}
9357 		}
9358 	}
9359 	if (CharOperation.equals(TypeConstants.SERIALPERSISTENTFIELDS, field.name)
9360 			&& field.isStatic()
9361 			&& field.isFinal()
9362 			&& field.type.dimensions() == 1
9363 			&& CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTSTREAMFIELD, field.type.leafComponentType().readableName())) {
9364 		ReferenceBinding referenceBinding = field.declaringClass;
9365 		if (referenceBinding != null) {
9366 			if (referenceBinding.findSuperTypeOriginatingFrom(TypeIds.T_JavaIoSerializable, false /*Serializable is not a class*/) != null) {
9367 				return; // do not report unused serialVersionUID field for class that implements Serializable
9368 			}
9369 		}
9370 	}
9371 	if (excludeDueToAnnotation(fieldDecl.annotations, IProblem.UnusedPrivateField)) return;
9372 	this.handle(
9373 			IProblem.UnusedPrivateField,
9374 		new String[] {
9375 			new String(field.declaringClass.readableName()),
9376 			new String(field.name),
9377 		 },
9378 		new String[] {
9379 			new String(field.declaringClass.shortReadableName()),
9380 			new String(field.name),
9381 		 },
9382 		severity,
9383 		nodeSourceStart(field, fieldDecl),
9384 		nodeSourceEnd(field, fieldDecl));
9385 }
unusedPrivateMethod(AbstractMethodDeclaration methodDecl)9386 public void unusedPrivateMethod(AbstractMethodDeclaration methodDecl) {
9387 
9388 	int severity = computeSeverity(IProblem.UnusedPrivateMethod);
9389 	if (severity == ProblemSeverities.Ignore) return;
9390 
9391 	MethodBinding method = methodDecl.binding;
9392 
9393 	// no report for serialization support 'void readObject(ObjectInputStream)'
9394 	if (!method.isStatic()
9395 			&& TypeBinding.VOID == method.returnType
9396 			&& method.parameters.length == 1
9397 			&& method.parameters[0].dimensions() == 0
9398 			&& CharOperation.equals(method.selector, TypeConstants.READOBJECT)
9399 			&& CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTINPUTSTREAM, method.parameters[0].readableName())) {
9400 		return;
9401 	}
9402 	// no report for serialization support 'void writeObject(ObjectOutputStream)'
9403 	if (!method.isStatic()
9404 			&& TypeBinding.VOID == method.returnType
9405 			&& method.parameters.length == 1
9406 			&& method.parameters[0].dimensions() == 0
9407 			&& CharOperation.equals(method.selector, TypeConstants.WRITEOBJECT)
9408 			&& CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTOUTPUTSTREAM, method.parameters[0].readableName())) {
9409 		return;
9410 	}
9411 	// no report for serialization support 'Object readResolve()'
9412 	if (!method.isStatic()
9413 			&& TypeIds.T_JavaLangObject == method.returnType.id
9414 			&& method.parameters.length == 0
9415 			&& CharOperation.equals(method.selector, TypeConstants.READRESOLVE)) {
9416 		return;
9417 	}
9418 	// no report for serialization support 'Object writeReplace()'
9419 	if (!method.isStatic()
9420 			&& TypeIds.T_JavaLangObject == method.returnType.id
9421 			&& method.parameters.length == 0
9422 			&& CharOperation.equals(method.selector, TypeConstants.WRITEREPLACE)) {
9423 		return;
9424 	}
9425 	if (excludeDueToAnnotation(methodDecl.annotations, IProblem.UnusedPrivateMethod)) return;
9426 
9427 	this.handle(
9428 			IProblem.UnusedPrivateMethod,
9429 		new String[] {
9430 			new String(method.declaringClass.readableName()),
9431 			new String(method.selector),
9432 			typesAsString(method, false)
9433 		 },
9434 		new String[] {
9435 			new String(method.declaringClass.shortReadableName()),
9436 			new String(method.selector),
9437 			typesAsString(method, true)
9438 		 },
9439 		severity,
9440 		methodDecl.sourceStart,
9441 		methodDecl.sourceEnd);
9442 }
9443 
9444 /**
9445  * Returns true if a private member should not be warned as unused if
9446  * annotated with a non-standard annotation.
9447  * https://bugs.eclipse.org/365437
9448  * https://bugs.eclipse.org/376590
9449  */
excludeDueToAnnotation(Annotation[] annotations, int problemId)9450 private boolean excludeDueToAnnotation(Annotation[] annotations, int problemId) {
9451 	int annotationsLen = 0;
9452 	if (annotations != null) {
9453 		annotationsLen = annotations.length;
9454 	} else {
9455 		return false;
9456 	}
9457 	if (annotationsLen == 0) return false;
9458 	for (int i = 0; i < annotationsLen; i++) {
9459 		TypeBinding resolvedType = annotations[i].resolvedType;
9460 		if (resolvedType != null) {
9461 			switch (resolvedType.id) {
9462 				case TypeIds.T_JavaLangSuppressWarnings:
9463 				case TypeIds.T_JavaLangDeprecated:
9464 				case TypeIds.T_JavaLangSafeVarargs:
9465 					break;
9466 				case TypeIds.T_JavaxInjectInject:
9467 				case TypeIds.T_ComGoogleInjectInject:
9468 				case TypeIds.T_OrgSpringframeworkBeansFactoryAnnotationAutowired:
9469 					if (problemId != IProblem.UnusedPrivateField)
9470 						return true; // @Inject on method/ctor does constitute a relevant use, just on fields it doesn't
9471 					break;
9472 				default:
9473 					if (resolvedType instanceof ReferenceBinding)
9474 						if (((ReferenceBinding) resolvedType).hasNullBit(TypeIds.BitNullableAnnotation|TypeIds.BitNonNullAnnotation|TypeIds.BitNonNullByDefaultAnnotation))
9475 							break;
9476 					return true; // non-standard annotation found, don't warn
9477 			}
9478 		}
9479 	}
9480 	return false;
9481 }
unusedPrivateType(TypeDeclaration typeDecl)9482 public void unusedPrivateType(TypeDeclaration typeDecl) {
9483 	int severity = computeSeverity(IProblem.UnusedPrivateType);
9484 	if (severity == ProblemSeverities.Ignore) return;
9485 	if (excludeDueToAnnotation(typeDecl.annotations, IProblem.UnusedPrivateType)) return;
9486 	ReferenceBinding type = typeDecl.binding;
9487 	this.handle(
9488 			IProblem.UnusedPrivateType,
9489 		new String[] {
9490 			new String(type.readableName()),
9491 		 },
9492 		new String[] {
9493 			new String(type.shortReadableName()),
9494 		 },
9495 		severity,
9496 		typeDecl.sourceStart,
9497 		typeDecl.sourceEnd);
9498 }
unusedTypeParameter(TypeParameter typeParameter)9499 public void unusedTypeParameter(TypeParameter typeParameter) {
9500 	int severity = computeSeverity(IProblem.UnusedTypeParameter);
9501 	if (severity == ProblemSeverities.Ignore) return;
9502 	String [] arguments = new String[] {new String(typeParameter.name)};
9503 	this.handle(
9504 			IProblem.UnusedTypeParameter,
9505 			arguments,
9506 			arguments,
9507 			typeParameter.sourceStart,
9508 			typeParameter.sourceEnd);
9509 }
unusedWarningToken(Expression token)9510 public void unusedWarningToken(Expression token) {
9511 	String[] arguments = new String[] { token.constant.stringValue() };
9512 	this.handle(
9513 		IProblem.UnusedWarningToken,
9514 		arguments,
9515 		arguments,
9516 		token.sourceStart,
9517 		token.sourceEnd);
9518 }
problemNotAnalysed(Expression token, String optionKey)9519 public void problemNotAnalysed(Expression token, String optionKey) {
9520 	this.handle(
9521 		IProblem.ProblemNotAnalysed,
9522 		optionKey != null ? new String[]{optionKey} : new String[]{},
9523 		new String[] { token.constant.stringValue() },
9524 		token.sourceStart,
9525 		token.sourceEnd);
9526 }
previewFeatureNotEnabled(int sourceStart, int sourceEnd, String featureName)9527 public void previewFeatureNotEnabled(int sourceStart, int sourceEnd, String featureName) {
9528 	String[] args = new String[] {featureName};
9529 	this.handle(
9530 			IProblem.PreviewFeatureDisabled,
9531 			args,
9532 			args,
9533 			sourceStart,
9534 			sourceEnd);
9535 }
previewFeatureUsed(int sourceStart, int sourceEnd)9536 public void previewFeatureUsed(int sourceStart, int sourceEnd) {
9537 	this.handle(
9538 			IProblem.PreviewFeatureUsed,
9539 			NoArgument,
9540 			NoArgument,
9541 			sourceStart,
9542 			sourceEnd);
9543 }
previewFeatureNotSupported(int sourceStart, int sourceEnd, String featureName, String sourceLevel)9544 public void previewFeatureNotSupported(int sourceStart, int sourceEnd, String featureName, String sourceLevel) {
9545 	String[] args = new String[] {featureName, sourceLevel};
9546 	this.handle(
9547 			IProblem.PreviewFeatureNotSupported,
9548 			args,
9549 			args,
9550 			sourceStart,
9551 			sourceEnd);
9552 }
useAssertAsAnIdentifier(int sourceStart, int sourceEnd)9553 public void useAssertAsAnIdentifier(int sourceStart, int sourceEnd) {
9554 	this.handle(
9555 		IProblem.UseAssertAsAnIdentifier,
9556 		NoArgument,
9557 		NoArgument,
9558 		sourceStart,
9559 		sourceEnd);
9560 }
useEnumAsAnIdentifier(int sourceStart, int sourceEnd)9561 public void useEnumAsAnIdentifier(int sourceStart, int sourceEnd) {
9562 	this.handle(
9563 		IProblem.UseEnumAsAnIdentifier,
9564 		NoArgument,
9565 		NoArgument,
9566 		sourceStart,
9567 		sourceEnd);
9568 }
illegalUseOfUnderscoreAsAnIdentifier(int sourceStart, int sourceEnd, boolean reportError)9569 public void illegalUseOfUnderscoreAsAnIdentifier(int sourceStart, int sourceEnd, boolean reportError) {
9570 	this.underScoreIsError = reportError;
9571 	try {
9572 		this.handle(
9573 			IProblem.IllegalUseOfUnderscoreAsAnIdentifier,
9574 			NoArgument,
9575 			NoArgument,
9576 			sourceStart,
9577 			sourceEnd);
9578 	} finally {
9579 		this.underScoreIsError = false;
9580 	}
9581 }
varargsArgumentNeedCast(MethodBinding method, TypeBinding argumentType, InvocationSite location)9582 public void varargsArgumentNeedCast(MethodBinding method, TypeBinding argumentType, InvocationSite location) {
9583 	int severity = this.options.getSeverity(CompilerOptions.VarargsArgumentNeedCast);
9584 	if (severity == ProblemSeverities.Ignore) return;
9585 	ArrayBinding varargsType = (ArrayBinding)method.parameters[method.parameters.length-1];
9586 	if (method.isConstructor()) {
9587 		this.handle(
9588 			IProblem.ConstructorVarargsArgumentNeedCast,
9589 			new String[] {
9590 					new String(argumentType.readableName()),
9591 					new String(varargsType.readableName()),
9592 					new String(method.declaringClass.readableName()),
9593 					typesAsString(method, false),
9594 					new String(varargsType.elementsType().readableName()),
9595 			},
9596 			new String[] {
9597 					new String(argumentType.shortReadableName()),
9598 					new String(varargsType.shortReadableName()),
9599 					new String(method.declaringClass.shortReadableName()),
9600 					typesAsString(method, true),
9601 					new String(varargsType.elementsType().shortReadableName()),
9602 			},
9603 			severity,
9604 			location.sourceStart(),
9605 			location.sourceEnd());
9606 	} else {
9607 		this.handle(
9608 			IProblem.MethodVarargsArgumentNeedCast,
9609 			new String[] {
9610 					new String(argumentType.readableName()),
9611 					new String(varargsType.readableName()),
9612 					new String(method.selector),
9613 					typesAsString(method, false),
9614 					new String(method.declaringClass.readableName()),
9615 					new String(varargsType.elementsType().readableName()),
9616 			},
9617 			new String[] {
9618 					new String(argumentType.shortReadableName()),
9619 					new String(varargsType.shortReadableName()),
9620 					new String(method.selector), typesAsString(method, true),
9621 					new String(method.declaringClass.shortReadableName()),
9622 					new String(varargsType.elementsType().shortReadableName()),
9623 			},
9624 			severity,
9625 			location.sourceStart(),
9626 			location.sourceEnd());
9627 	}
9628 }
varargsConflict(MethodBinding method1, MethodBinding method2, SourceTypeBinding type)9629 public void varargsConflict(MethodBinding method1, MethodBinding method2, SourceTypeBinding type) {
9630 	this.handle(
9631 		IProblem.VarargsConflict,
9632 		new String[] {
9633 		        new String(method1.selector),
9634 		        typesAsString(method1, false),
9635 		        new String(method1.declaringClass.readableName()),
9636 		        typesAsString(method2, false),
9637 		        new String(method2.declaringClass.readableName())
9638 		},
9639 		new String[] {
9640 		        new String(method1.selector),
9641 		        typesAsString(method1, true),
9642 		        new String(method1.declaringClass.shortReadableName()),
9643 		        typesAsString(method2, true),
9644 		        new String(method2.declaringClass.shortReadableName())
9645 		},
9646 		TypeBinding.equalsEquals(method1.declaringClass, type) ? method1.sourceStart() : type.sourceStart(),
9647 		TypeBinding.equalsEquals(method1.declaringClass, type) ? method1.sourceEnd() : type.sourceEnd());
9648 }
safeVarargsOnFixedArityMethod(MethodBinding method)9649 public void safeVarargsOnFixedArityMethod(MethodBinding method) {
9650 	String [] arguments = new String[] { new String(method.isConstructor() ? method.declaringClass.shortReadableName() : method.selector)};
9651 	this.handle(
9652 		IProblem.SafeVarargsOnFixedArityMethod,
9653 		arguments,
9654 		arguments,
9655 		method.sourceStart(),
9656 		method.sourceEnd());
9657 }
safeVarargsOnNonFinalInstanceMethod(MethodBinding method)9658 public void safeVarargsOnNonFinalInstanceMethod(MethodBinding method) {
9659 	String [] arguments = new String[] { new String(method.isConstructor() ? method.declaringClass.shortReadableName() : method.selector)};
9660 	this.handle(
9661 		IProblem.SafeVarargsOnNonFinalInstanceMethod,
9662 		arguments,
9663 		arguments,
9664 		method.sourceStart(),
9665 		method.sourceEnd());
9666 }
possibleHeapPollutionFromVararg(AbstractVariableDeclaration vararg)9667 public void possibleHeapPollutionFromVararg(AbstractVariableDeclaration vararg) {
9668 	String[] arguments = new String[] {new String(vararg.name)};
9669 	this.handle(
9670 		IProblem.PotentialHeapPollutionFromVararg,
9671 		arguments,
9672 		arguments,
9673 		vararg.sourceStart,
9674 		vararg.sourceEnd);
9675 }
variableTypeCannotBeVoid(AbstractVariableDeclaration varDecl)9676 public void variableTypeCannotBeVoid(AbstractVariableDeclaration varDecl) {
9677 	String[] arguments = new String[] {new String(varDecl.name)};
9678 	this.handle(
9679 		IProblem.VariableTypeCannotBeVoid,
9680 		arguments,
9681 		arguments,
9682 		varDecl.sourceStart,
9683 		varDecl.sourceEnd);
9684 }
varLocalMultipleDeclarators(AbstractVariableDeclaration varDecl)9685 public void varLocalMultipleDeclarators(AbstractVariableDeclaration varDecl) {
9686 	this.handle(
9687 		IProblem.VarLocalMultipleDeclarators,
9688 		NoArgument,
9689 		NoArgument,
9690 		varDecl.sourceStart,
9691 		varDecl.sourceEnd);
9692 }
varLocalCannotBeArray(AbstractVariableDeclaration varDecl)9693 public void varLocalCannotBeArray(AbstractVariableDeclaration varDecl) {
9694 	this.handle(
9695 		IProblem.VarLocalCannotBeArray,
9696 		NoArgument,
9697 		NoArgument,
9698 		varDecl.sourceStart,
9699 		varDecl.sourceEnd);
9700 }
varLocalReferencesItself(AbstractVariableDeclaration varDecl)9701 public void varLocalReferencesItself(AbstractVariableDeclaration varDecl) {
9702 	this.handle(
9703 		IProblem.VarLocalReferencesItself,
9704 		NoArgument,
9705 		NoArgument,
9706 		varDecl.sourceStart,
9707 		varDecl.sourceEnd);
9708 }
varLocalWithoutInitizalier(AbstractVariableDeclaration varDecl)9709 public void varLocalWithoutInitizalier(AbstractVariableDeclaration varDecl) {
9710 	this.handle(
9711 		IProblem.VarLocalWithoutInitizalier,
9712 		NoArgument,
9713 		NoArgument,
9714 		varDecl.sourceStart,
9715 		varDecl.sourceEnd);
9716 }
varLocalInitializedToNull(AbstractVariableDeclaration varDecl)9717 public void varLocalInitializedToNull(AbstractVariableDeclaration varDecl) {
9718 	this.handle(
9719 		IProblem.VarLocalInitializedToNull,
9720 		NoArgument,
9721 		NoArgument,
9722 		varDecl.sourceStart,
9723 		varDecl.sourceEnd);
9724 }
varLocalInitializedToVoid(AbstractVariableDeclaration varDecl)9725 public void varLocalInitializedToVoid(AbstractVariableDeclaration varDecl) {
9726 	this.handle(
9727 		IProblem.VarLocalInitializedToVoid,
9728 		NoArgument,
9729 		NoArgument,
9730 		varDecl.sourceStart,
9731 		varDecl.sourceEnd);
9732 }
varLocalCannotBeArrayInitalizers(AbstractVariableDeclaration varDecl)9733 public void varLocalCannotBeArrayInitalizers(AbstractVariableDeclaration varDecl) {
9734 	this.handle(
9735 		IProblem.VarLocalCannotBeArrayInitalizers,
9736 		NoArgument,
9737 		NoArgument,
9738 		varDecl.sourceStart,
9739 		varDecl.sourceEnd);
9740 }
varLocalCannotBeLambda(AbstractVariableDeclaration varDecl)9741 public void varLocalCannotBeLambda(AbstractVariableDeclaration varDecl) {
9742 	this.handle(
9743 		IProblem.VarLocalCannotBeLambda,
9744 		NoArgument,
9745 		NoArgument,
9746 		varDecl.sourceStart,
9747 		varDecl.sourceEnd);
9748 }
varLocalCannotBeMethodReference(AbstractVariableDeclaration varDecl)9749 public void varLocalCannotBeMethodReference(AbstractVariableDeclaration varDecl) {
9750 	this.handle(
9751 		IProblem.VarLocalCannotBeMethodReference,
9752 		NoArgument,
9753 		NoArgument,
9754 		varDecl.sourceStart,
9755 		varDecl.sourceEnd);
9756 }
varIsReservedTypeName(TypeDeclaration decl)9757 public void varIsReservedTypeName(TypeDeclaration decl) {
9758 	this.handle(
9759 		IProblem.VarIsReserved,
9760 		NoArgument,
9761 		NoArgument,
9762 		decl.sourceStart,
9763 		decl.sourceEnd);
9764 }
varIsReservedTypeNameInFuture(ASTNode decl)9765 public void varIsReservedTypeNameInFuture(ASTNode decl) {
9766 	this.handle(
9767 		IProblem.VarIsReservedInFuture,
9768 		NoArgument,
9769 		NoArgument,
9770 		ProblemSeverities.Warning,
9771 		decl.sourceStart,
9772 		decl.sourceEnd);
9773 }
varIsNotAllowedHere(ASTNode astNode)9774 public void varIsNotAllowedHere(ASTNode astNode) {
9775 	this.handle(
9776 		IProblem.VarIsNotAllowedHere,
9777 		NoArgument,
9778 		NoArgument,
9779 		astNode.sourceStart,
9780 		astNode.sourceEnd);
9781 }
varCannotBeMixedWithNonVarParams(ASTNode astNode)9782 public void varCannotBeMixedWithNonVarParams(ASTNode astNode) {
9783 	this.handle(
9784 		IProblem.VarCannotBeMixedWithNonVarParams,
9785 		NoArgument,
9786 		NoArgument,
9787 		astNode.sourceStart,
9788 		astNode.sourceEnd);
9789 }
variableTypeCannotBeVoidArray(AbstractVariableDeclaration varDecl)9790 public void variableTypeCannotBeVoidArray(AbstractVariableDeclaration varDecl) {
9791 	this.handle(
9792 		IProblem.CannotAllocateVoidArray,
9793 		NoArgument,
9794 		NoArgument,
9795 		varDecl.type.sourceStart,
9796 		varDecl.type.sourceEnd);
9797 }
visibilityConflict(MethodBinding currentMethod, MethodBinding inheritedMethod)9798 public void visibilityConflict(MethodBinding currentMethod, MethodBinding inheritedMethod) {
9799 	this.handle(
9800 		//	Cannot reduce the visibility of the inherited method from %1
9801 		// 8.4.6.3 - The access modifier of an hiding method must provide at least as much access as the hidden method.
9802 		// 8.4.6.3 - The access modifier of an overiding method must provide at least as much access as the overriden method.
9803 		IProblem.MethodReducesVisibility,
9804 		new String[] {new String(inheritedMethod.declaringClass.readableName())},
9805 		new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
9806 		currentMethod.sourceStart(),
9807 		currentMethod.sourceEnd());
9808 }
wildcardAssignment(TypeBinding variableType, TypeBinding expressionType, ASTNode location)9809 public void wildcardAssignment(TypeBinding variableType, TypeBinding expressionType, ASTNode location) {
9810 	this.handle(
9811 		IProblem.WildcardFieldAssignment,
9812 		new String[] {
9813 		        new String(expressionType.readableName()), new String(variableType.readableName()) },
9814 		new String[] {
9815 		        new String(expressionType.shortReadableName()), new String(variableType.shortReadableName()) },
9816 		location.sourceStart,
9817 		location.sourceEnd);
9818 }
wildcardInvocation(ASTNode location, TypeBinding receiverType, MethodBinding method, TypeBinding[] arguments)9819 public void wildcardInvocation(ASTNode location, TypeBinding receiverType, MethodBinding method, TypeBinding[] arguments) {
9820 	TypeBinding offendingArgument = null;
9821 	TypeBinding offendingParameter = null;
9822 	for (int i = 0, length = method.parameters.length; i < length; i++) {
9823 		TypeBinding parameter = method.parameters[i];
9824 		if (parameter.isWildcard() && (((WildcardBinding) parameter).boundKind != Wildcard.SUPER)) {
9825 			offendingParameter = parameter;
9826 			offendingArgument = arguments[i];
9827 			break;
9828 		}
9829 	}
9830 
9831 	if (method.isConstructor()) {
9832 		this.handle(
9833 			IProblem.WildcardConstructorInvocation,
9834 			new String[] {
9835 				new String(receiverType.sourceName()),
9836 				typesAsString(method, false),
9837 				new String(receiverType.readableName()),
9838 				typesAsString(arguments, false),
9839 				new String(offendingArgument.readableName()),
9840 				new String(offendingParameter.readableName()),
9841 			 },
9842 			new String[] {
9843 				new String(receiverType.sourceName()),
9844 				typesAsString(method, true),
9845 				new String(receiverType.shortReadableName()),
9846 				typesAsString(arguments, true),
9847 				new String(offendingArgument.shortReadableName()),
9848 				new String(offendingParameter.shortReadableName()),
9849 			 },
9850 			location.sourceStart,
9851 			location.sourceEnd);
9852     } else {
9853 		this.handle(
9854 			IProblem.WildcardMethodInvocation,
9855 			new String[] {
9856 				new String(method.selector),
9857 				typesAsString(method, false),
9858 				new String(receiverType.readableName()),
9859 				typesAsString(arguments, false),
9860 				new String(offendingArgument.readableName()),
9861 				new String(offendingParameter.readableName()),
9862 			 },
9863 			new String[] {
9864 				new String(method.selector),
9865 				typesAsString(method, true),
9866 				new String(receiverType.shortReadableName()),
9867 				typesAsString(arguments, true),
9868 				new String(offendingArgument.shortReadableName()),
9869 				new String(offendingParameter.shortReadableName()),
9870 			 },
9871 			location.sourceStart,
9872 			location.sourceEnd);
9873     }
9874 }
wrongSequenceOfExceptionTypesError(TypeReference typeRef, TypeBinding exceptionType, TypeBinding hidingExceptionType)9875 public void wrongSequenceOfExceptionTypesError(TypeReference typeRef, TypeBinding exceptionType, TypeBinding hidingExceptionType) {
9876 	//the two catch block under and upper are in an incorrect order.
9877 	//under should be define BEFORE upper in the source
9878 
9879 	this.handle(
9880 		IProblem.InvalidCatchBlockSequence,
9881 		new String[] {
9882 			new String(exceptionType.readableName()),
9883 			new String(hidingExceptionType.readableName()),
9884 		 },
9885 		new String[] {
9886 			new String(exceptionType.shortReadableName()),
9887 			new String(hidingExceptionType.shortReadableName()),
9888 		 },
9889 		typeRef.sourceStart,
9890 		typeRef.sourceEnd);
9891 }
wrongSequenceOfExceptionTypes(TypeReference typeRef, TypeBinding exceptionType, TypeBinding hidingExceptionType)9892 public void wrongSequenceOfExceptionTypes(TypeReference typeRef, TypeBinding exceptionType, TypeBinding hidingExceptionType) {
9893 	// type references inside a multi-catch block are not of union type
9894 	this.handle(
9895 		IProblem.InvalidUnionTypeReferenceSequence,
9896 		new String[] {
9897 			new String(exceptionType.readableName()),
9898 			new String(hidingExceptionType.readableName()),
9899 		 },
9900 		new String[] {
9901 			new String(exceptionType.shortReadableName()),
9902 			new String(hidingExceptionType.shortReadableName()),
9903 		 },
9904 		typeRef.sourceStart,
9905 		typeRef.sourceEnd);
9906 }
9907 
autoManagedResourcesNotBelow17(Statement[] resources)9908 public void autoManagedResourcesNotBelow17(Statement[] resources) {
9909 	Statement stmt0 = resources[0];
9910 	Statement stmtn = resources[resources.length - 1];
9911 	int sourceStart = stmt0 instanceof LocalDeclaration ? ((LocalDeclaration) stmt0).declarationSourceStart : stmt0.sourceStart;
9912 	int sourceEnd = stmtn instanceof LocalDeclaration ? ((LocalDeclaration) stmtn).declarationSourceEnd : stmtn.sourceEnd;
9913 	this.handle(
9914 			IProblem.AutoManagedResourceNotBelow17,
9915 			NoArgument,
9916 			NoArgument,
9917 			sourceStart,
9918 			sourceEnd);
9919 }
autoManagedVariableResourcesNotBelow9(Expression resource)9920 public void autoManagedVariableResourcesNotBelow9(Expression resource) {
9921 	this.handle(
9922 			IProblem.AutoManagedVariableResourceNotBelow9,
9923 			NoArgument,
9924 			NoArgument,
9925 			resource.sourceStart,
9926 			resource.sourceEnd);
9927 }
cannotInferElidedTypes(AllocationExpression allocationExpression)9928 public void cannotInferElidedTypes(AllocationExpression allocationExpression) {
9929 	String arguments [] = new String [] { allocationExpression.type.toString() };
9930 	this.handle(
9931 			IProblem.CannotInferElidedTypes,
9932 			arguments,
9933 			arguments,
9934 			allocationExpression.sourceStart,
9935 			allocationExpression.sourceEnd);
9936 }
diamondNotWithExplicitTypeArguments(TypeReference[] typeArguments)9937 public void diamondNotWithExplicitTypeArguments(TypeReference[] typeArguments) {
9938 	this.handle(
9939 			IProblem.CannotUseDiamondWithExplicitTypeArguments,
9940 			NoArgument,
9941 			NoArgument,
9942 			typeArguments[0].sourceStart,
9943 			typeArguments[typeArguments.length - 1].sourceEnd);
9944 }
rawConstructorReferenceNotWithExplicitTypeArguments(TypeReference[] typeArguments)9945 public void rawConstructorReferenceNotWithExplicitTypeArguments(TypeReference[] typeArguments) {
9946 	this.handle(
9947 			IProblem.IllegalTypeArgumentsInRawConstructorReference,
9948 			NoArgument,
9949 			NoArgument,
9950 			typeArguments[0].sourceStart,
9951 			typeArguments[typeArguments.length - 1].sourceEnd);
9952 }
diamondNotWithAnoymousClasses(TypeReference type)9953 public void diamondNotWithAnoymousClasses(TypeReference type) {
9954 	this.handle(
9955 			IProblem.CannotUseDiamondWithAnonymousClasses,
9956 			NoArgument,
9957 			NoArgument,
9958 			type.sourceStart,
9959 			type.sourceEnd);
9960 }
anonymousDiamondWithNonDenotableTypeArguments(TypeReference type, TypeBinding tb)9961 public void anonymousDiamondWithNonDenotableTypeArguments(TypeReference type, TypeBinding tb) {
9962 	this.handle(
9963 			IProblem.NonDenotableTypeArgumentForAnonymousDiamond,
9964 			new String[]{new String(tb.leafComponentType().shortReadableName()), type.toString()},
9965 			new String[]{new String(tb.leafComponentType().shortReadableName()), type.toString()},
9966 			type.sourceStart,
9967 			type.sourceEnd);
9968 }
redundantSpecificationOfTypeArguments(ASTNode location, TypeBinding[] argumentTypes)9969 public void redundantSpecificationOfTypeArguments(ASTNode location, TypeBinding[] argumentTypes) {
9970 	int severity = computeSeverity(IProblem.RedundantSpecificationOfTypeArguments);
9971 	if (severity != ProblemSeverities.Ignore) {
9972 		int sourceStart = -1;
9973 		if (location instanceof QualifiedTypeReference) {
9974 			QualifiedTypeReference ref = (QualifiedTypeReference)location;
9975 			sourceStart = (int) (ref.sourcePositions[ref.sourcePositions.length - 1] >> 32);
9976 		} else {
9977 			sourceStart = location.sourceStart;
9978 		}
9979 		this.handle(
9980 			IProblem.RedundantSpecificationOfTypeArguments,
9981 			new String[] {typesAsString(argumentTypes, false)},
9982 			new String[] {typesAsString(argumentTypes, true)},
9983 			severity,
9984 			sourceStart,
9985 			location.sourceEnd);
9986     }
9987 }
potentiallyUnclosedCloseable(FakedTrackingVariable trackVar, ASTNode location)9988 public void potentiallyUnclosedCloseable(FakedTrackingVariable trackVar, ASTNode location) {
9989 	String[] args = { trackVar.nameForReporting(location, this.referenceContext) };
9990 	if (location == null || trackVar.acquisition != null) {
9991 		// if acquisition is set, the problem is not location specific
9992 		this.handle(
9993 			IProblem.PotentiallyUnclosedCloseable,
9994 			args,
9995 			args,
9996 			trackVar.sourceStart,
9997 			trackVar.sourceEnd);
9998 	} else {
9999 		this.handle(
10000 			IProblem.PotentiallyUnclosedCloseableAtExit,
10001 			args,
10002 			args,
10003 			location.sourceStart,
10004 			location.sourceEnd);
10005 	}
10006 }
unclosedCloseable(FakedTrackingVariable trackVar, ASTNode location)10007 public void unclosedCloseable(FakedTrackingVariable trackVar, ASTNode location) {
10008 	String[] args = { String.valueOf(trackVar.name) };
10009 	if (location == null) {
10010 		this.handle(
10011 			IProblem.UnclosedCloseable,
10012 			args,
10013 			args,
10014 			trackVar.sourceStart,
10015 			trackVar.sourceEnd);
10016 	} else {
10017 		this.handle(
10018 			IProblem.UnclosedCloseableAtExit,
10019 			args,
10020 			args,
10021 			location.sourceStart,
10022 			location.sourceEnd);
10023 	}
10024 }
explicitlyClosedAutoCloseable(FakedTrackingVariable trackVar)10025 public void explicitlyClosedAutoCloseable(FakedTrackingVariable trackVar) {
10026 	String[] args = { String.valueOf(trackVar.name) };
10027 	this.handle(
10028 		IProblem.ExplicitlyClosedAutoCloseable,
10029 		args,
10030 		args,
10031 		trackVar.sourceStart,
10032 		trackVar.sourceEnd);
10033 }
10034 
nullityMismatch(Expression expression, TypeBinding providedType, TypeBinding requiredType, int nullStatus, char[][] annotationName)10035 public void nullityMismatch(Expression expression, TypeBinding providedType, TypeBinding requiredType, int nullStatus, char[][] annotationName) {
10036 	if ((nullStatus & FlowInfo.NULL) != 0) {
10037 		nullityMismatchIsNull(expression, requiredType);
10038 		return;
10039 	}
10040 	if (expression instanceof MessageSend) {
10041 		if ((((MessageSend) expression).binding.tagBits & TagBits.AnnotationNullable) != 0) {
10042 			nullityMismatchSpecdNullable(expression, requiredType, this.options.nonNullAnnotationName);
10043 			return;
10044 		}
10045 	}
10046 	if ((nullStatus & FlowInfo.POTENTIALLY_NULL) != 0) {
10047 		VariableBinding var = expression.localVariableBinding();
10048 		if (var == null && expression instanceof Reference) {
10049 			var = ((Reference)expression).lastFieldBinding();
10050 		}
10051 		if(var != null && var.type.isFreeTypeVariable()) {
10052 			nullityMismatchVariableIsFreeTypeVariable(var, expression);
10053 			return;
10054 		}
10055 		if (var != null && var.isNullable()) {
10056 			nullityMismatchSpecdNullable(expression, requiredType, annotationName);
10057 			return;
10058 		}
10059 			if (expression instanceof ArrayReference && expression.resolvedType.isFreeTypeVariable()) {
10060 				nullityMismatchingTypeAnnotation(expression, providedType, requiredType, NullAnnotationMatching.NULL_ANNOTATIONS_MISMATCH);
10061 				return;
10062 			}
10063 			nullityMismatchPotentiallyNull(expression, requiredType, annotationName);
10064 		return;
10065 	}
10066 	if (this.options.usesNullTypeAnnotations())
10067 		nullityMismatchingTypeAnnotation(expression, providedType, requiredType, NullAnnotationMatching.NULL_ANNOTATIONS_UNCHECKED);
10068 	else
10069 		nullityMismatchIsUnknown(expression, providedType, requiredType, annotationName);
10070 }
nullityMismatchIsNull(Expression expression, TypeBinding requiredType)10071 public void nullityMismatchIsNull(Expression expression, TypeBinding requiredType) {
10072 	int problemId = IProblem.RequiredNonNullButProvidedNull;
10073 	boolean useNullTypeAnnotations = this.options.usesNullTypeAnnotations();
10074 	if (useNullTypeAnnotations && requiredType.isTypeVariable() && !requiredType.hasNullTypeAnnotations())
10075 		problemId = IProblem.NullNotCompatibleToFreeTypeVariable;
10076 	if (requiredType instanceof CaptureBinding) {
10077 		CaptureBinding capture = (CaptureBinding) requiredType;
10078 		if (capture.wildcard != null)
10079 			requiredType = capture.wildcard;
10080 	}
10081 	String[] arguments;
10082 	String[] argumentsShort;
10083 	if (!useNullTypeAnnotations) {
10084 		arguments      = new String[] { annotatedTypeName(requiredType, this.options.nonNullAnnotationName) };
10085 		argumentsShort = new String[] { shortAnnotatedTypeName(requiredType, this.options.nonNullAnnotationName) };
10086 	} else {
10087 		if (problemId == IProblem.NullNotCompatibleToFreeTypeVariable) {
10088 			arguments      = new String[] { new String(requiredType.sourceName()) }; // don't show any bounds
10089 			argumentsShort = new String[] { new String(requiredType.sourceName()) };
10090 		} else {
10091 			arguments      = new String[] { new String(requiredType.nullAnnotatedReadableName(this.options, false)) };
10092 			argumentsShort = new String[] { new String(requiredType.nullAnnotatedReadableName(this.options, true))  };
10093 		}
10094 	}
10095 	this.handle(problemId, arguments, argumentsShort, expression.sourceStart, expression.sourceEnd);
10096 }
nullityMismatchSpecdNullable(Expression expression, TypeBinding requiredType, char[][] annotationName)10097 public void nullityMismatchSpecdNullable(Expression expression, TypeBinding requiredType, char[][] annotationName) {
10098 	int problemId = IProblem.RequiredNonNullButProvidedSpecdNullable;
10099 	char[][] nullableName = this.options.nullableAnnotationName;
10100 	String[] arguments = new String[] {
10101 			annotatedTypeName(requiredType, annotationName),
10102 			String.valueOf(CharOperation.concatWith(nullableName, '.'))
10103 	};
10104 	String[] argumentsShort = new String[] {
10105 			shortAnnotatedTypeName(requiredType, annotationName),
10106 			String.valueOf(nullableName[nullableName.length-1])
10107 	};
10108 	if (expression.resolvedType != null && expression.resolvedType.hasNullTypeAnnotations()) {
10109 		problemId = IProblem.NullityMismatchingTypeAnnotation;
10110 		arguments[1] = String.valueOf(expression.resolvedType.nullAnnotatedReadableName(this.options, false));
10111 		argumentsShort[1] = String.valueOf(expression.resolvedType.nullAnnotatedReadableName(this.options, true));
10112 	}
10113 	this.handle(problemId, arguments, argumentsShort, expression.sourceStart, expression.sourceEnd);
10114 }
nullityMismatchPotentiallyNull(Expression expression, TypeBinding requiredType, char[][] annotationName)10115 public void nullityMismatchPotentiallyNull(Expression expression, TypeBinding requiredType, char[][] annotationName) {
10116 	int problemId = IProblem.RequiredNonNullButProvidedPotentialNull;
10117 	char[][] nullableName = this.options.nullableAnnotationName;
10118 	String[] arguments = new String[] {
10119 			annotatedTypeName(requiredType, annotationName),
10120 			String.valueOf(CharOperation.concatWith(nullableName, '.'))
10121 	};
10122 	String[] argumentsShort = new String[] {
10123 			shortAnnotatedTypeName(requiredType, annotationName),
10124 			String.valueOf(nullableName[nullableName.length-1])
10125 	};
10126 	this.handle(problemId, arguments, argumentsShort, expression.sourceStart, expression.sourceEnd);
10127 }
nullityMismatchIsUnknown(Expression expression, TypeBinding providedType, TypeBinding requiredType, char[][] annotationName)10128 public void nullityMismatchIsUnknown(Expression expression, TypeBinding providedType, TypeBinding requiredType, char[][] annotationName) {
10129 	int problemId = IProblem.RequiredNonNullButProvidedUnknown;
10130 	String[] arguments = new String[] {
10131 			String.valueOf(providedType.readableName()),
10132 			annotatedTypeName(requiredType, annotationName)
10133 	};
10134 	String[] argumentsShort = new String[] {
10135 			String.valueOf(providedType.shortReadableName()),
10136 			shortAnnotatedTypeName(requiredType, annotationName)
10137 	};
10138 	this.handle(problemId, arguments, argumentsShort, expression.sourceStart, expression.sourceEnd);
10139 }
nullityMismatchIsFreeTypeVariable(TypeBinding providedType, int sourceStart, int sourceEnd)10140 private void nullityMismatchIsFreeTypeVariable(TypeBinding providedType, int sourceStart, int sourceEnd) {
10141 	char[][] nullableName = this.options.nullableAnnotationName;
10142 	char[][] nonNullName = this.options.nonNullAnnotationName;
10143 	String[] arguments = new String[] {
10144 			new String(nonNullName[nonNullName.length-1]),
10145 			new String(providedType.readableName()),
10146 			new String(nullableName[nullableName.length-1])};
10147 	this.handle(IProblem.RequiredNonNullButProvidedFreeTypeVariable, arguments, arguments, sourceStart, sourceEnd);
10148 }
nullityMismatchVariableIsFreeTypeVariable(VariableBinding variable, ASTNode location)10149 public void nullityMismatchVariableIsFreeTypeVariable(VariableBinding variable, ASTNode location) {
10150 	int severity = computeSeverity(IProblem.RequiredNonNullButProvidedFreeTypeVariable);
10151 	if (severity == ProblemSeverities.Ignore) return;
10152 	nullityMismatchIsFreeTypeVariable(variable.type, nodeSourceStart(variable, location),
10153 			nodeSourceEnd(variable, location));
10154 }
illegalRedefinitionToNonNullParameter(Argument argument, ReferenceBinding declaringClass, char[][] inheritedAnnotationName)10155 public void illegalRedefinitionToNonNullParameter(Argument argument, ReferenceBinding declaringClass, char[][] inheritedAnnotationName) {
10156 	int sourceStart = argument.type.sourceStart;
10157 	if (argument.annotations != null) {
10158 		for (int i=0; i<argument.annotations.length; i++) {
10159 			Annotation annotation = argument.annotations[i];
10160 			if (annotation.hasNullBit(TypeIds.BitNonNullAnnotation|TypeIds.BitNullableAnnotation)) {
10161 				sourceStart = annotation.sourceStart;
10162 				break;
10163 			}
10164 		}
10165 	}
10166 	if (inheritedAnnotationName == null) {
10167 		this.handle(
10168 			IProblem.IllegalDefinitionToNonNullParameter,
10169 			new String[] { new String(argument.name), new String(declaringClass.readableName()) },
10170 			new String[] { new String(argument.name), new String(declaringClass.shortReadableName()) },
10171 			sourceStart,
10172 			argument.type.sourceEnd);
10173 	} else {
10174 		this.handle(
10175 			IProblem.IllegalRedefinitionToNonNullParameter,
10176 			new String[] { new String(argument.name), new String(declaringClass.readableName()), CharOperation.toString(inheritedAnnotationName)},
10177 			new String[] { new String(argument.name), new String(declaringClass.shortReadableName()), new String(inheritedAnnotationName[inheritedAnnotationName.length-1])},
10178 			sourceStart,
10179 			argument.type.sourceEnd);
10180 	}
10181 }
parameterLackingNullableAnnotation(Argument argument, ReferenceBinding declaringClass, char[][] inheritedAnnotationName)10182 public void parameterLackingNullableAnnotation(Argument argument, ReferenceBinding declaringClass, char[][] inheritedAnnotationName) {
10183 	this.handle(
10184 		IProblem.ParameterLackingNullableAnnotation,
10185 		new String[] { new String(declaringClass.readableName()), CharOperation.toString(inheritedAnnotationName)},
10186 		new String[] { new String(declaringClass.shortReadableName()), new String(inheritedAnnotationName[inheritedAnnotationName.length-1])},
10187 		argument.type.sourceStart,
10188 		argument.type.sourceEnd);
10189 }
parameterLackingNonnullAnnotation(Argument argument, ReferenceBinding declaringClass, char[][] inheritedAnnotationName)10190 public void parameterLackingNonnullAnnotation(Argument argument, ReferenceBinding declaringClass, char[][] inheritedAnnotationName) {
10191 	this.handle(
10192 		IProblem.ParameterLackingNonNullAnnotation,
10193 		new String[] { new String(declaringClass.readableName()), CharOperation.toString(inheritedAnnotationName)},
10194 		new String[] { new String(declaringClass.shortReadableName()), new String(inheritedAnnotationName[inheritedAnnotationName.length-1])},
10195 		argument.type.sourceStart,
10196 		argument.type.sourceEnd);
10197 }
inheritedParameterLackingNonnullAnnotation(MethodBinding currentMethod, int paramRank, ReferenceBinding specificationType, ASTNode location, char[][] annotationName)10198 public void inheritedParameterLackingNonnullAnnotation(MethodBinding currentMethod, int paramRank, ReferenceBinding specificationType,
10199 		ASTNode location, char[][] annotationName) {
10200 	this.handle(IProblem.InheritedParameterLackingNonNullAnnotation,
10201 		new String[] {
10202 			String.valueOf(paramRank), new String(currentMethod.readableName()),
10203 			new String(specificationType.readableName()), CharOperation.toString(annotationName)
10204 		},
10205 		new String[] {
10206 			String.valueOf(paramRank), new String(currentMethod.shortReadableName()),
10207 			new String(specificationType.shortReadableName()), new String(annotationName[annotationName.length-1])
10208 		},
10209 		location.sourceStart, location.sourceEnd
10210 		);
10211 }
illegalParameterRedefinition(Argument argument, ReferenceBinding declaringClass, TypeBinding inheritedParameter)10212 public void illegalParameterRedefinition(Argument argument, ReferenceBinding declaringClass, TypeBinding inheritedParameter) {
10213 	int sourceStart = argument.type.sourceStart;
10214 	if (argument.annotations != null) {
10215 		for (int i=0; i<argument.annotations.length; i++) {
10216 			Annotation annotation = argument.annotations[i];
10217 			if (annotation.hasNullBit(TypeIds.BitNonNullAnnotation|TypeIds.BitNullableAnnotation)) {
10218 				sourceStart = annotation.sourceStart;
10219 				break;
10220 			}
10221 		}
10222 	}
10223 	this.handle(
10224 		IProblem.IllegalParameterNullityRedefinition,
10225 		new String[] { new String(argument.name), new String(declaringClass.readableName()), new String(inheritedParameter.nullAnnotatedReadableName(this.options, false)) },
10226 		new String[] { new String(argument.name), new String(declaringClass.shortReadableName()), new String(inheritedParameter.nullAnnotatedReadableName(this.options, true))  },
10227 		sourceStart,
10228 		argument.type.sourceEnd);
10229 }
illegalReturnRedefinition(AbstractMethodDeclaration abstractMethodDecl, MethodBinding inheritedMethod, char[][] nonNullAnnotationName)10230 public void illegalReturnRedefinition(AbstractMethodDeclaration abstractMethodDecl, MethodBinding inheritedMethod, char[][] nonNullAnnotationName) {
10231 	// nonNullAnnotationName is not used in 1.8-mode
10232 	MethodDeclaration methodDecl = (MethodDeclaration) abstractMethodDecl;
10233 	StringBuffer methodSignature = new StringBuffer();
10234 	methodSignature
10235 		.append(inheritedMethod.declaringClass.readableName())
10236 		.append('.')
10237 		.append(inheritedMethod.readableName());
10238 
10239 	StringBuffer shortSignature = new StringBuffer();
10240 	shortSignature
10241 		.append(inheritedMethod.declaringClass.shortReadableName())
10242 		.append('.')
10243 		.append(inheritedMethod.shortReadableName());
10244 	int sourceStart = methodDecl.returnType.sourceStart;
10245 	Annotation[] annotations = methodDecl.annotations;
10246 	Annotation annotation = findAnnotation(annotations, TypeIds.BitNullableAnnotation);
10247 	if (annotation != null) {
10248 		sourceStart = annotation.sourceStart;
10249 	}
10250 	TypeBinding inheritedReturnType = inheritedMethod.returnType;
10251 	int problemId = IProblem.IllegalReturnNullityRedefinition;
10252 	StringBuilder returnType = new StringBuilder();
10253 	StringBuilder returnTypeShort = new StringBuilder();
10254 	if (this.options.usesNullTypeAnnotations()) {
10255 		// 1.8+
10256 		if (inheritedReturnType.isTypeVariable() && (inheritedReturnType.tagBits & TagBits.AnnotationNullMASK) == 0) {
10257 			problemId = IProblem.IllegalReturnNullityRedefinitionFreeTypeVariable;
10258 
10259 			returnType.append(inheritedReturnType.readableName());
10260 			returnTypeShort.append(inheritedReturnType.shortReadableName());
10261 		} else {
10262 			returnType.append(inheritedReturnType.nullAnnotatedReadableName(this.options, false));
10263 			returnTypeShort.append(inheritedReturnType.nullAnnotatedReadableName(this.options, true));
10264 		}
10265 	} else {
10266 		// 1.7-
10267 		returnType.append('@').append(CharOperation.concatWith(nonNullAnnotationName, '.'));
10268 		returnType.append(' ').append(inheritedReturnType.readableName());
10269 
10270 		returnTypeShort.append('@').append(nonNullAnnotationName[nonNullAnnotationName.length-1]);
10271 		returnTypeShort.append(' ').append(inheritedReturnType.shortReadableName());
10272 	}
10273 	String[] arguments = new String[] { methodSignature.toString(), returnType.toString() };
10274 	String[] argumentsShort = new String[] { shortSignature.toString(), returnTypeShort.toString() };
10275 	this.handle(
10276 			problemId,
10277 			arguments,
10278 			argumentsShort,
10279 			sourceStart,
10280 			methodDecl.returnType.sourceEnd);
10281 }
referenceExpressionArgumentNullityMismatch(ReferenceExpression location, TypeBinding requiredType, TypeBinding providedType, MethodBinding descriptorMethod, int idx, NullAnnotationMatching status)10282 public void referenceExpressionArgumentNullityMismatch(ReferenceExpression location, TypeBinding requiredType, TypeBinding providedType,
10283 		MethodBinding descriptorMethod, int idx, NullAnnotationMatching status) {
10284 	StringBuffer methodSignature = new StringBuffer();
10285 	methodSignature
10286 		.append(descriptorMethod.declaringClass.readableName())
10287 		.append('.')
10288 		.append(descriptorMethod.readableName());
10289 	StringBuffer shortSignature = new StringBuffer();
10290 	shortSignature
10291 		.append(descriptorMethod.declaringClass.shortReadableName())
10292 		.append('.')
10293 		.append(descriptorMethod.shortReadableName());
10294 	this.handle(
10295 			status.isUnchecked() ? IProblem.ReferenceExpressionParameterNullityUnchecked : IProblem.ReferenceExpressionParameterNullityMismatch,
10296 			new String[] { idx == -1 ? "'this'" : String.valueOf(idx + 1), //$NON-NLS-1$
10297 							String.valueOf(requiredType.nullAnnotatedReadableName(this.options, false)),
10298 							String.valueOf(providedType.nullAnnotatedReadableName(this.options, false)),
10299 							methodSignature.toString() },
10300 			new String[] { idx == -1 ? "'this'" : String.valueOf(idx + 1), //$NON-NLS-1$
10301 							String.valueOf(requiredType.nullAnnotatedReadableName(this.options, true)),
10302 							String.valueOf(providedType.nullAnnotatedReadableName(this.options, true)),
10303 							shortSignature.toString() },
10304 			location.sourceStart,
10305 			location.sourceEnd);
10306 }
illegalReturnRedefinition(ASTNode location, MethodBinding descriptorMethod, boolean isUnchecked, TypeBinding providedType)10307 public void illegalReturnRedefinition(ASTNode location, MethodBinding descriptorMethod,
10308 			boolean isUnchecked, TypeBinding providedType) {
10309 	StringBuffer methodSignature = new StringBuffer()
10310 		.append(descriptorMethod.declaringClass.readableName())
10311 		.append('.')
10312 		.append(descriptorMethod.readableName());
10313 	StringBuffer shortSignature = new StringBuffer()
10314 		.append(descriptorMethod.declaringClass.shortReadableName())
10315 		.append('.')
10316 		.append(descriptorMethod.shortReadableName());
10317 	this.handle(
10318 		isUnchecked
10319 			? IProblem.ReferenceExpressionReturnNullRedefUnchecked
10320 			: IProblem.ReferenceExpressionReturnNullRedef,
10321 		new String[] { methodSignature.toString(),
10322 						String.valueOf(descriptorMethod.returnType.nullAnnotatedReadableName(this.options, false)),
10323 						String.valueOf(providedType.nullAnnotatedReadableName(this.options, false))},
10324 		new String[] { shortSignature.toString(),
10325 						String.valueOf(descriptorMethod.returnType.nullAnnotatedReadableName(this.options, true)),
10326 						String.valueOf(providedType.nullAnnotatedReadableName(this.options, true))},
10327 		location.sourceStart,
10328 		location.sourceEnd);
10329 }
messageSendPotentialNullReference(MethodBinding method, ASTNode location)10330 public void messageSendPotentialNullReference(MethodBinding method, ASTNode location) {
10331 	String[] arguments = new String[] {new String(method.readableName())};
10332 	this.handle(
10333 		IProblem.PotentialNullMessageSendReference,
10334 		arguments,
10335 		arguments,
10336 		location.sourceStart,
10337 		location.sourceEnd);
10338 }
messageSendRedundantCheckOnNonNull(MethodBinding method, ASTNode location)10339 public void messageSendRedundantCheckOnNonNull(MethodBinding method, ASTNode location) {
10340 	String[] arguments = new String[] {new String(method.readableName())  };
10341 	this.handle(
10342 		IProblem.RedundantNullCheckOnNonNullMessageSend,
10343 		arguments,
10344 		arguments,
10345 		location.sourceStart,
10346 		location.sourceEnd);
10347 }
expressionNullReference(ASTNode location)10348 public void expressionNullReference(ASTNode location) {
10349 	this.handle(
10350 		IProblem.NullExpressionReference,
10351 		NoArgument,
10352 		NoArgument,
10353 		location.sourceStart,
10354 		location.sourceEnd);
10355 }
expressionPotentialNullReference(ASTNode location)10356 public void expressionPotentialNullReference(ASTNode location) {
10357 	this.handle(
10358 		IProblem.PotentialNullExpressionReference,
10359 		NoArgument,
10360 		NoArgument,
10361 		location.sourceStart,
10362 		location.sourceEnd);
10363 }
10364 
cannotImplementIncompatibleNullness(ReferenceContext context, MethodBinding currentMethod, MethodBinding inheritedMethod, boolean showReturn)10365 public void cannotImplementIncompatibleNullness(ReferenceContext context, MethodBinding currentMethod, MethodBinding inheritedMethod, boolean showReturn) {
10366 	int sourceStart = 0, sourceEnd = 0;
10367 	if (context instanceof TypeDeclaration) {
10368 		TypeDeclaration type = (TypeDeclaration) context;
10369 		if (type.superclass != null) {
10370 			sourceStart = type.superclass.sourceStart;
10371 			sourceEnd =   type.superclass.sourceEnd;
10372 		} else {
10373 			sourceStart = type.sourceStart;
10374 			sourceEnd =   type.sourceEnd;
10375 		}
10376 	}
10377 	String[] problemArguments = {
10378 			showReturn
10379 				? new String(currentMethod.returnType.nullAnnotatedReadableName(this.options, false))+' '
10380 				: "", //$NON-NLS-1$
10381 			new String(currentMethod.selector),
10382 			typesAsString(currentMethod, false, true),
10383 			new String(currentMethod.declaringClass.readableName()),
10384 			new String(inheritedMethod.declaringClass.readableName())
10385 		};
10386 	String[] messageArguments = {
10387 			showReturn
10388 				? new String(currentMethod.returnType.nullAnnotatedReadableName(this.options, true))+' '
10389 				: "", //$NON-NLS-1$
10390 			new String(currentMethod.selector),
10391 			typesAsString(currentMethod, true, true),
10392 			new String(currentMethod.declaringClass.shortReadableName()),
10393 			new String(inheritedMethod.declaringClass.shortReadableName())
10394 		};
10395 	this.handle(
10396 			IProblem.CannotImplementIncompatibleNullness,
10397 			problemArguments,
10398 			messageArguments,
10399 			sourceStart,
10400 			sourceEnd);
10401 }
10402 
nullAnnotationIsRedundant(AbstractMethodDeclaration sourceMethod, int i)10403 public void nullAnnotationIsRedundant(AbstractMethodDeclaration sourceMethod, int i) {
10404 	int sourceStart, sourceEnd;
10405 	if (i == -1) {
10406 		MethodDeclaration methodDecl = (MethodDeclaration) sourceMethod;
10407 		Annotation annotation = findAnnotation(methodDecl.annotations, TypeIds.BitNonNullAnnotation);
10408 		sourceStart = annotation != null ? annotation.sourceStart : methodDecl.returnType.sourceStart;
10409 		sourceEnd = methodDecl.returnType.sourceEnd;
10410 	} else {
10411 		Argument arg = sourceMethod.arguments[i];
10412 		sourceStart = arg.declarationSourceStart;
10413 		sourceEnd = arg.sourceEnd;
10414 	}
10415 	this.handle(IProblem.RedundantNullAnnotation, ProblemHandler.NoArgument, ProblemHandler.NoArgument, sourceStart, sourceEnd);
10416 }
10417 
nullAnnotationIsRedundant(FieldDeclaration sourceField)10418 public void nullAnnotationIsRedundant(FieldDeclaration sourceField) {
10419 	Annotation annotation = findAnnotation(sourceField.annotations, TypeIds.BitNonNullAnnotation);
10420 	int sourceStart = annotation != null ? annotation.sourceStart : sourceField.type.sourceStart;
10421 	int sourceEnd = sourceField.type.sourceEnd;
10422 	this.handle(IProblem.RedundantNullAnnotation, ProblemHandler.NoArgument, ProblemHandler.NoArgument, sourceStart, sourceEnd);
10423 }
10424 
nullDefaultAnnotationIsRedundant(ASTNode location, Annotation[] annotations, Binding outer)10425 public void nullDefaultAnnotationIsRedundant(ASTNode location, Annotation[] annotations, Binding outer) {
10426 	if (outer == Scope.NOT_REDUNDANT)
10427 		return;
10428 	Annotation annotation = findAnnotation(annotations, TypeIds.BitNonNullByDefaultAnnotation);
10429 	int start = annotation != null ? annotation.sourceStart : location.sourceStart;
10430 	int end = annotation != null ? annotation.sourceEnd : location.sourceStart;
10431 	String[] args = NoArgument;
10432 	String[] shortArgs = NoArgument;
10433 	if (outer != null) {
10434 		args = new String[] { new String(outer.readableName()) };
10435 		shortArgs = new String[] { new String(outer.shortReadableName()) };
10436 	}
10437 	int problemId = IProblem.RedundantNullDefaultAnnotation;
10438 	if (outer instanceof ModuleBinding) {
10439 		problemId = IProblem.RedundantNullDefaultAnnotationModule;
10440 	} else if (outer instanceof PackageBinding) {
10441 		problemId = IProblem.RedundantNullDefaultAnnotationPackage;
10442 	} else if (outer instanceof ReferenceBinding) {
10443 		problemId = IProblem.RedundantNullDefaultAnnotationType;
10444 	} else if (outer instanceof MethodBinding) {
10445 		problemId = IProblem.RedundantNullDefaultAnnotationMethod;
10446 	} else if (outer instanceof LocalVariableBinding) {
10447 		problemId = IProblem.RedundantNullDefaultAnnotationLocal;
10448 	} else if (outer instanceof FieldBinding) {
10449 		problemId = IProblem.RedundantNullDefaultAnnotationField;
10450 	}
10451 	this.handle(problemId, args, shortArgs, start, end);
10452 }
10453 
contradictoryNullAnnotations(Annotation annotation)10454 public void contradictoryNullAnnotations(Annotation annotation) {
10455 	contradictoryNullAnnotations(annotation.sourceStart, annotation.sourceEnd);
10456 }
10457 
contradictoryNullAnnotations(Annotation[] annotations)10458 public void contradictoryNullAnnotations(Annotation[] annotations) {
10459 	contradictoryNullAnnotations(annotations[0].sourceStart, annotations[annotations.length-1].sourceEnd);
10460 }
10461 
contradictoryNullAnnotations(int sourceStart, int sourceEnd)10462 public void contradictoryNullAnnotations(int sourceStart, int sourceEnd) {
10463 	// when this error is triggered we can safely assume that both annotations have been configured
10464 	char[][] nonNullAnnotationName = this.options.nonNullAnnotationName;
10465 	char[][] nullableAnnotationName = this.options.nullableAnnotationName;
10466 	String[] arguments = {
10467 		new String(CharOperation.concatWith(nonNullAnnotationName, '.')),
10468 		new String(CharOperation.concatWith(nullableAnnotationName, '.'))
10469 	};
10470 	String[] shortArguments = {
10471 			new String(nonNullAnnotationName[nonNullAnnotationName.length-1]),
10472 			new String(nullableAnnotationName[nullableAnnotationName.length-1])
10473 		};
10474 	this.handle(IProblem.ContradictoryNullAnnotations, arguments, shortArguments, sourceStart, sourceEnd);
10475 }
10476 
contradictoryNullAnnotationsInferred(MethodBinding inferredMethod, ASTNode location)10477 public void contradictoryNullAnnotationsInferred(MethodBinding inferredMethod, ASTNode location) {
10478 	contradictoryNullAnnotationsInferred(inferredMethod, location.sourceStart, location.sourceEnd, false);
10479 }
contradictoryNullAnnotationsInferred(MethodBinding inferredMethod, int sourceStart, int sourceEnd, boolean isFunctionalExpression)10480 public void contradictoryNullAnnotationsInferred(MethodBinding inferredMethod, int sourceStart, int sourceEnd, boolean isFunctionalExpression) {
10481 	// when this error is triggered we can safely assume that both annotations have been configured
10482 	char[][] nonNullAnnotationName = this.options.nonNullAnnotationName;
10483 	char[][] nullableAnnotationName = this.options.nullableAnnotationName;
10484 	String[] arguments = {
10485 		new String(CharOperation.concatWith(nonNullAnnotationName, '.')),
10486 		new String(CharOperation.concatWith(nullableAnnotationName, '.')),
10487 		new String(inferredMethod.returnType.nullAnnotatedReadableName(this.options, false)),
10488 		new String(inferredMethod.selector),
10489 		typesAsString(inferredMethod, false, true)
10490 	};
10491 	String[] shortArguments = {
10492 			new String(nonNullAnnotationName[nonNullAnnotationName.length-1]),
10493 			new String(nullableAnnotationName[nullableAnnotationName.length-1]),
10494 			new String(inferredMethod.returnType.nullAnnotatedReadableName(this.options, true)),
10495 			new String(inferredMethod.selector),
10496 			typesAsString(inferredMethod, true, true)
10497 		};
10498 	this.handle(
10499 			isFunctionalExpression ? IProblem.ContradictoryNullAnnotationsInferredFunctionType : IProblem.ContradictoryNullAnnotationsInferred,
10500 			arguments, shortArguments, sourceStart, sourceEnd);
10501 }
10502 
contradictoryNullAnnotationsOnBounds(Annotation annotation, long previousTagBit)10503 public void contradictoryNullAnnotationsOnBounds(Annotation annotation, long previousTagBit) {
10504 	char[][] annotationName = previousTagBit == TagBits.AnnotationNonNull ? this.options.nonNullAnnotationName : this.options.nullableAnnotationName;
10505 	String[] arguments = {
10506 		new String(CharOperation.concatWith(annotationName, '.')),
10507 	};
10508 	String[] shortArguments = {
10509 		new String(annotationName[annotationName.length-1]),
10510 	};
10511 	this.handle(IProblem.ContradictoryNullAnnotationsOnBound, arguments, shortArguments, annotation.sourceStart, annotation.sourceEnd);
10512 }
10513 
10514 // conflict default <-> inherited
conflictingNullAnnotations(MethodBinding currentMethod, ASTNode location, MethodBinding inheritedMethod)10515 public void conflictingNullAnnotations(MethodBinding currentMethod, ASTNode location, MethodBinding inheritedMethod)
10516 {
10517 	char[][] nonNullAnnotationName = this.options.nonNullAnnotationName;
10518 	char[][] nullableAnnotationName = this.options.nullableAnnotationName;
10519 	String[] arguments = {
10520 		new String(CharOperation.concatWith(nonNullAnnotationName, '.')),
10521 		new String(CharOperation.concatWith(nullableAnnotationName, '.')),
10522 		new String(inheritedMethod.declaringClass.readableName())
10523 	};
10524 	String[] shortArguments = {
10525 			new String(nonNullAnnotationName[nonNullAnnotationName.length-1]),
10526 			new String(nullableAnnotationName[nullableAnnotationName.length-1]),
10527 			new String(inheritedMethod.declaringClass.shortReadableName())
10528 		};
10529 	this.handle(IProblem.ConflictingNullAnnotations, arguments, shortArguments, location.sourceStart, location.sourceEnd);
10530 }
10531 
10532 // conflict between different inheriteds
conflictingInheritedNullAnnotations(ASTNode location, boolean previousIsNonNull, MethodBinding previousInherited, boolean isNonNull, MethodBinding inheritedMethod)10533 public void conflictingInheritedNullAnnotations(ASTNode location, boolean previousIsNonNull, MethodBinding previousInherited, boolean isNonNull, MethodBinding inheritedMethod)
10534 {
10535 	char[][] previousAnnotationName = previousIsNonNull ? this.options.nonNullAnnotationName : this.options.nullableAnnotationName;
10536 	char[][] annotationName = isNonNull ? this.options.nonNullAnnotationName : this.options.nullableAnnotationName;
10537 	String[] arguments = {
10538 		new String(CharOperation.concatWith(previousAnnotationName, '.')),
10539 		new String(previousInherited.declaringClass.readableName()),
10540 		new String(CharOperation.concatWith(annotationName, '.')),
10541 		new String(inheritedMethod.declaringClass.readableName())
10542 	};
10543 	String[] shortArguments = {
10544 			new String(previousAnnotationName[previousAnnotationName.length-1]),
10545 			new String(previousInherited.declaringClass.shortReadableName()),
10546 			new String(annotationName[annotationName.length-1]),
10547 			new String(inheritedMethod.declaringClass.shortReadableName())
10548 		};
10549 	this.handle(IProblem.ConflictingInheritedNullAnnotations, arguments, shortArguments, location.sourceStart, location.sourceEnd);
10550 }
10551 
illegalAnnotationForBaseType(TypeReference type, Annotation[] annotations, long nullAnnotationTagBit)10552 public void illegalAnnotationForBaseType(TypeReference type, Annotation[] annotations, long nullAnnotationTagBit)
10553 {
10554 	int typeBit = (nullAnnotationTagBit == TagBits.AnnotationNullable)
10555 			? TypeIds.BitNullableAnnotation : TypeIds.BitNonNullAnnotation;
10556 	char[][] annotationNames = (nullAnnotationTagBit == TagBits.AnnotationNonNull)
10557 			? this.options.nonNullAnnotationName
10558 			: this.options.nullableAnnotationName;
10559 	String typeName = new String(type.resolvedType.leafComponentType().readableName()); // use the actual name (accounting for 'var')
10560 	String[] args = new String[] { new String(annotationNames[annotationNames.length-1]), typeName };
10561 	Annotation annotation = findAnnotation(annotations, typeBit);
10562 	int start = annotation != null ? annotation.sourceStart : type.sourceStart;
10563 	int end = annotation != null ? annotation.sourceEnd : type.sourceEnd;
10564 	this.handle(IProblem.IllegalAnnotationForBaseType,
10565 			args,
10566 			args,
10567 			start,
10568 			end);
10569 }
10570 
illegalAnnotationForBaseType(Annotation annotation, TypeBinding type)10571 public void illegalAnnotationForBaseType(Annotation annotation, TypeBinding type)
10572 {
10573 	String[] args = new String[] {
10574 		new String(annotation.resolvedType.shortReadableName()),
10575 		new String(type.readableName())
10576 	};
10577 	this.handle(IProblem.IllegalAnnotationForBaseType,
10578 			args,
10579 			args,
10580 			annotation.sourceStart,
10581 			annotation.sourceEnd);
10582 }
10583 
annotatedTypeName(TypeBinding type, char[][] annotationName)10584 private String annotatedTypeName(TypeBinding type, char[][] annotationName) {
10585 	if ((type.tagBits & TagBits.AnnotationNullMASK) != 0)
10586 		return String.valueOf(type.nullAnnotatedReadableName(this.options, false));
10587 	int dims = 0;
10588 	char[] typeName = type.readableName();
10589 	char[] annotationDisplayName = CharOperation.concatWith(annotationName, '.');
10590 	return internalAnnotatedTypeName(annotationDisplayName, typeName, dims);
10591 }
shortAnnotatedTypeName(TypeBinding type, char[][] annotationName)10592 private String shortAnnotatedTypeName(TypeBinding type, char[][] annotationName) {
10593 	if ((type.tagBits & TagBits.AnnotationNullMASK) != 0)
10594 		return String.valueOf(type.nullAnnotatedReadableName(this.options, true));
10595 	int dims = 0;
10596 	char[] typeName = type.shortReadableName();
10597 	char[] annotationDisplayName = annotationName[annotationName.length-1];
10598 	return internalAnnotatedTypeName(annotationDisplayName, typeName, dims);
10599 }
10600 
internalAnnotatedTypeName(char[] annotationName, char[] typeName, int dims)10601 String internalAnnotatedTypeName(char[] annotationName, char[] typeName, int dims) {
10602 	char[] fullName;
10603 	if (dims > 0) {
10604 		int plainLen = annotationName.length+typeName.length+2; // adding '@' and ' ' ...
10605 		fullName = new char[plainLen+(2*dims)]; // ... and []*
10606 		System.arraycopy(typeName, 0, fullName, 0, typeName.length);
10607 		fullName[typeName.length] = ' ';
10608 		fullName[typeName.length+1] = '@';
10609 		System.arraycopy(annotationName, 0, fullName, typeName.length+2, annotationName.length);
10610 		for (int i=0; i<dims; i++) {
10611 			fullName[plainLen+i] = '[';
10612 			fullName[plainLen+i+1] = ']';
10613 		}
10614 	} else {
10615 		fullName = new char[annotationName.length+typeName.length+2]; // adding '@' and ' '
10616 		fullName[0] = '@';
10617 		System.arraycopy(annotationName, 0, fullName, 1, annotationName.length);
10618 		fullName[annotationName.length+1] = ' ';
10619 		System.arraycopy(typeName, 0, fullName, annotationName.length+2, typeName.length);
10620 	}
10621 	return String.valueOf(fullName);
10622 }
findAnnotation(Annotation[] annotations, int typeBit)10623 private Annotation findAnnotation(Annotation[] annotations, int typeBit) {
10624 	if (annotations != null) {
10625 		// should have a @NonNull/@Nullable annotation, search for it:
10626 		int length = annotations.length;
10627 		for (int j = length - 1; j >= 0; j--) {
10628 			if (annotations[j].hasNullBit(typeBit)) {
10629 				return annotations[j];
10630 			}
10631 		}
10632 	}
10633 	return null;
10634 }
10635 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=372012
missingNonNullByDefaultAnnotation(TypeDeclaration type)10636 public void missingNonNullByDefaultAnnotation(TypeDeclaration type) {
10637 	int severity;
10638 	CompilationUnitDeclaration compUnitDecl = type.getCompilationUnitDeclaration();
10639 	String[] arguments;
10640 	if (compUnitDecl.currentPackage == null) {
10641 		severity = computeSeverity(IProblem.MissingNonNullByDefaultAnnotationOnType);
10642 		if (severity == ProblemSeverities.Ignore) return;
10643 		// Default package
10644 		TypeBinding binding = type.binding;
10645 		this.handle(
10646 				IProblem.MissingNonNullByDefaultAnnotationOnType,
10647 				new String[] {new String(binding.readableName()), },
10648 				new String[] {new String(binding.shortReadableName()),},
10649 				severity,
10650 				type.sourceStart,
10651 				type.sourceEnd);
10652 	} else {
10653 		severity = computeSeverity(IProblem.MissingNonNullByDefaultAnnotationOnPackage);
10654 		if (severity == ProblemSeverities.Ignore) return;
10655 		arguments = new String[] {CharOperation.toString(compUnitDecl.currentPackage.tokens)};
10656 		this.handle(
10657 			IProblem.MissingNonNullByDefaultAnnotationOnPackage,
10658 			arguments,
10659 			arguments,
10660 			severity,
10661 			compUnitDecl.currentPackage.sourceStart,
10662 			compUnitDecl.currentPackage.sourceEnd);
10663 	}
10664 }
10665 
illegalModifiersForElidedType(Argument argument)10666 public void illegalModifiersForElidedType(Argument argument) {
10667 	String[] arg = new String[] {new String(argument.name)};
10668 	this.handle(
10669 			IProblem.IllegalModifiersForElidedType,
10670 			arg,
10671 			arg,
10672 			argument.declarationSourceStart,
10673 			argument.declarationSourceEnd);
10674 }
10675 
illegalModifiers(int modifierSourceStart, int modifiersSourceEnd)10676 public void illegalModifiers(int modifierSourceStart, int modifiersSourceEnd) {
10677 	this.handle(
10678 			IProblem.IllegalModifiers,
10679 			NoArgument,
10680 			NoArgument,
10681 			modifierSourceStart,
10682 			modifiersSourceEnd);
10683 }
10684 
arrayReferencePotentialNullReference(ArrayReference arrayReference)10685 public void arrayReferencePotentialNullReference(ArrayReference arrayReference) {
10686 	// TODO(stephan): merge with other expressions
10687 	this.handle(IProblem.ArrayReferencePotentialNullReference, NoArgument, NoArgument, arrayReference.sourceStart, arrayReference.sourceEnd);
10688 
10689 }
nullityMismatchingTypeAnnotation(Expression expression, TypeBinding providedType, TypeBinding requiredType, NullAnnotationMatching status)10690 public void nullityMismatchingTypeAnnotation(Expression expression, TypeBinding providedType, TypeBinding requiredType, NullAnnotationMatching status)
10691 {
10692 	if (providedType == requiredType) return; //$IDENTITY-COMPARISON$
10693 
10694 	// try to improve nonnull vs. null:
10695 	if (providedType.id == TypeIds.T_null || status.nullStatus == FlowInfo.NULL) {
10696 		nullityMismatchIsNull(expression, requiredType);
10697 		return;
10698 	}
10699 	if ((requiredType.tagBits & TagBits.AnnotationNonNull) != 0) { // some problems need a closer look to report the best possible message:
10700 		// try to improve nonnull vs. nullable:
10701 		if (status.isPotentiallyNullMismatch()
10702 				&& (providedType.tagBits & TagBits.AnnotationNullable) == 0)
10703 		{
10704 			if(this.options.pessimisticNullAnalysisForFreeTypeVariablesEnabled && providedType.isTypeVariable() && !providedType.hasNullTypeAnnotations()) {
10705 				nullityMismatchIsFreeTypeVariable(providedType, expression.sourceStart, expression.sourceEnd);
10706 				return;
10707 			}
10708 
10709 			nullityMismatchPotentiallyNull(expression, requiredType, this.options.nonNullAnnotationName);
10710 			return;
10711 		}
10712 		VariableBinding var = expression.localVariableBinding();
10713 		if (var == null && expression instanceof Reference) {
10714 			var = ((Reference)expression).lastFieldBinding();
10715 		}
10716 		if(var != null && var.type.isFreeTypeVariable()) {
10717 			nullityMismatchVariableIsFreeTypeVariable(var, expression);
10718 			return;
10719 		}
10720 	}
10721 
10722 	String[] arguments;
10723 	String[] shortArguments;
10724 
10725 	int problemId = 0;
10726 	String superHint = null;
10727 	String superHintShort = null;
10728 	if (status.superTypeHint != null && requiredType.isParameterizedType()) {
10729 		problemId = (status.isAnnotatedToUnannotated()
10730 					? IProblem.AnnotatedTypeArgumentToUnannotatedSuperHint
10731 					: (status.isUnchecked()
10732 						? IProblem.NullityUncheckedTypeAnnotationDetailSuperHint
10733 						: IProblem.NullityMismatchingTypeAnnotationSuperHint));
10734 		superHint = status.superTypeHintName(this.options, false);
10735 		superHintShort = status.superTypeHintName(this.options, true);
10736 	} else {
10737 		problemId = (status.isAnnotatedToUnannotated()
10738 					? IProblem.AnnotatedTypeArgumentToUnannotated
10739 					: (status.isUnchecked()
10740 						? IProblem.NullityUncheckedTypeAnnotationDetail
10741 						: (requiredType.isTypeVariable() && !requiredType.hasNullTypeAnnotations())
10742 							? IProblem.NullityMismatchAgainstFreeTypeVariable
10743 							: IProblem.NullityMismatchingTypeAnnotation));
10744 		if (problemId == IProblem.NullityMismatchAgainstFreeTypeVariable) {
10745 			arguments      = new String[] { null, null, new String(requiredType.sourceName()) }; // don't show bounds here
10746 			shortArguments = new String[] { null, null, new String(requiredType.sourceName()) };
10747 		} else {
10748 			arguments      = new String[2];
10749 			shortArguments = new String[2];
10750 		}
10751 	}
10752 	String requiredName;
10753 	String requiredNameShort;
10754 	if (problemId == IProblem.NullityMismatchAgainstFreeTypeVariable) {
10755 		requiredName		= new String(requiredType.sourceName()); // don't show bounds here
10756 		requiredNameShort 	= new String(requiredType.sourceName()); // don't show bounds here
10757 	} else {
10758 		requiredName 		= new String(requiredType.nullAnnotatedReadableName(this.options, false));
10759 		requiredNameShort 	= new String(requiredType.nullAnnotatedReadableName(this.options, true));
10760 	}
10761 	String providedName		 = String.valueOf(providedType.nullAnnotatedReadableName(this.options, false));
10762 	String providedNameShort = String.valueOf(providedType.nullAnnotatedReadableName(this.options, true));
10763 	// assemble arguments:
10764 	if (superHint != null) {
10765 		arguments 		= new String[] { requiredName, providedName, superHint };
10766 		shortArguments 	= new String[] { requiredNameShort, providedNameShort, superHintShort };
10767 	} else {
10768 		arguments 		= new String[] { requiredName, providedName };
10769 		shortArguments 	= new String[] { requiredNameShort, providedNameShort };
10770 	}
10771 	this.handle(problemId, arguments, shortArguments, expression.sourceStart, expression.sourceEnd);
10772 }
10773 
nullityMismatchTypeArgument(TypeBinding typeVariable, TypeBinding typeArgument, ASTNode location)10774 public void nullityMismatchTypeArgument(TypeBinding typeVariable, TypeBinding typeArgument, ASTNode location) {
10775 	String[] arguments = {
10776 		String.valueOf(typeVariable.nullAnnotatedReadableName(this.options, false)),
10777 		String.valueOf(typeArgument.nullAnnotatedReadableName(this.options, false))
10778 	};
10779 	String[] shortArguments = {
10780 		String.valueOf(typeVariable.nullAnnotatedReadableName(this.options, true)),
10781 		String.valueOf(typeArgument.nullAnnotatedReadableName(this.options, true))
10782 	};
10783 	this.handle(
10784 			IProblem.NullityMismatchTypeArgument,
10785 			arguments,
10786 			shortArguments,
10787 			location.sourceStart,
10788 			location.sourceEnd);
10789 }
10790 
cannotRedefineTypeArgumentNullity(TypeBinding typeVariable, Binding superElement, ASTNode location)10791 public void cannotRedefineTypeArgumentNullity(TypeBinding typeVariable, Binding superElement, ASTNode location) {
10792 	String[] arguments = new String[2];
10793 	String[] shortArguments = new String[2];
10794 	arguments[0]		= String.valueOf(typeVariable.nullAnnotatedReadableName(this.options, false));
10795 	shortArguments[0] 	= String.valueOf(typeVariable.nullAnnotatedReadableName(this.options, true));
10796 	if (superElement instanceof MethodBinding) {
10797 		ReferenceBinding declaringClass = ((MethodBinding) superElement).declaringClass;
10798 		arguments[1] 		= String.valueOf(CharOperation.concat(declaringClass.readableName(), superElement.shortReadableName(), '.'));
10799 		shortArguments[1] 	= String.valueOf(CharOperation.concat(declaringClass.shortReadableName(), superElement.shortReadableName(), '.'));
10800 	} else {
10801 		arguments[1] 		= String.valueOf(superElement.readableName());
10802 		shortArguments[1] 	= String.valueOf(superElement.shortReadableName());
10803 	}
10804 	this.handle(
10805 			IProblem.IllegalRedefinitionOfTypeVariable,
10806 			arguments,
10807 			shortArguments,
10808 			location.sourceStart,
10809 			location.sourceEnd);
10810 }
10811 
implicitObjectBoundNoNullDefault(TypeReference reference)10812 public void implicitObjectBoundNoNullDefault(TypeReference reference) {
10813 	this.handle(IProblem.ImplicitObjectBoundNoNullDefault,
10814 			NoArgument, NoArgument,
10815 			ProblemSeverities.Warning,
10816 			reference.sourceStart, reference.sourceEnd);
10817 }
nonNullTypeVariableInUnannotatedBinary(LookupEnvironment environment, MethodBinding method, Expression expression, int providedSeverity)10818 public void nonNullTypeVariableInUnannotatedBinary(LookupEnvironment environment, MethodBinding method, Expression expression, int providedSeverity) {
10819 	TypeBinding declaredReturnType = method.original().returnType;
10820 	int severity = computeSeverity(IProblem.NonNullTypeVariableFromLegacyMethod);
10821 	if ((severity & ProblemSeverities.CoreSeverityMASK) == ProblemSeverities.Warning)
10822 		severity = providedSeverity; // leverage the greater precision from our caller
10823 	if (declaredReturnType instanceof TypeVariableBinding) { // paranoia check
10824 		TypeVariableBinding typeVariable = (TypeVariableBinding) declaredReturnType;
10825 		TypeBinding declaringClass = method.declaringClass;
10826 
10827 		char[][] nonNullName = this.options.nonNullAnnotationName;
10828 		String shortNonNullName = String.valueOf(nonNullName[nonNullName.length-1]);
10829 
10830 		if (typeVariable.declaringElement instanceof ReferenceBinding) {
10831 			String[] arguments = new String[] {
10832 					shortNonNullName,
10833 					String.valueOf(declaringClass.nullAnnotatedReadableName(this.options, false)),
10834 					String.valueOf(declaringClass.original().readableName())};
10835 			String[] shortArguments = {
10836 					shortNonNullName,
10837 					String.valueOf(declaringClass.nullAnnotatedReadableName(this.options, true)),
10838 					String.valueOf(declaringClass.original().shortReadableName()) };
10839 			this.handle(IProblem.NonNullTypeVariableFromLegacyMethod,
10840 					arguments,
10841 					shortArguments,
10842 					severity,
10843 					expression.sourceStart,
10844 					expression.sourceEnd);
10845 		} else if (typeVariable.declaringElement instanceof MethodBinding && method instanceof ParameterizedGenericMethodBinding) {
10846 			TypeBinding substitution = ((ParameterizedGenericMethodBinding) method).typeArguments[typeVariable.rank];
10847 			String[] arguments = new String[] {
10848 					shortNonNullName,
10849 					String.valueOf(typeVariable.readableName()),
10850 					String.valueOf(substitution.nullAnnotatedReadableName(this.options, false)),
10851 					String.valueOf(declaringClass.original().readableName())};
10852 			String[] shortArguments = {
10853 					shortNonNullName,
10854 					String.valueOf(typeVariable.shortReadableName()),
10855 					String.valueOf(substitution.nullAnnotatedReadableName(this.options, true)),
10856 					String.valueOf(declaringClass.original().shortReadableName()) };
10857 			this.handle(IProblem.NonNullMethodTypeVariableFromLegacyMethod,
10858 					arguments,
10859 					shortArguments,
10860 					severity,
10861 					expression.sourceStart,
10862 					expression.sourceEnd);
10863 		}
10864 	}
10865 }
dereferencingNullableExpression(Expression expression)10866 public void dereferencingNullableExpression(Expression expression) {
10867 	if (expression instanceof MessageSend) {
10868 		MessageSend send = (MessageSend) expression;
10869 		messageSendPotentialNullReference(send.binding, send);
10870 		return;
10871 	}
10872 	char[][] nullableName = this.options.nullableAnnotationName;
10873 	char[] nullableShort = nullableName[nullableName.length-1];
10874 	String[] arguments = { String.valueOf(nullableShort) };
10875 	// TODO(stephan): more sophisticated handling for various kinds of expressions
10876 	int start = nodeSourceStart(expression);
10877 	int end = nodeSourceEnd(expression);
10878 	this.handle(IProblem.DereferencingNullableExpression, arguments, arguments, start, end);
10879 }
dereferencingNullableExpression(long positions, LookupEnvironment env)10880 public void dereferencingNullableExpression(long positions, LookupEnvironment env) {
10881 	char[][] nullableName = env.getNullableAnnotationName();
10882 	char[] nullableShort = nullableName[nullableName.length-1];
10883 	String[] arguments = { String.valueOf(nullableShort) };
10884 	this.handle(IProblem.DereferencingNullableExpression, arguments, arguments, (int)(positions>>>32), (int)(positions&0xFFFF));
10885 }
onlyReferenceTypesInIntersectionCast(TypeReference typeReference)10886 public void onlyReferenceTypesInIntersectionCast(TypeReference typeReference) {
10887 	this.handle(
10888 			IProblem.IllegalBasetypeInIntersectionCast,
10889 			NoArgument,
10890 			NoArgument,
10891 			typeReference.sourceStart,
10892 			typeReference.sourceEnd);
10893 }
illegalArrayTypeInIntersectionCast(TypeReference typeReference)10894 public void illegalArrayTypeInIntersectionCast(TypeReference typeReference) {
10895 	this.handle(
10896 			IProblem.IllegalArrayTypeInIntersectionCast,
10897 			NoArgument,
10898 			NoArgument,
10899 			typeReference.sourceStart,
10900 			typeReference.sourceEnd);
10901 }
intersectionCastNotBelow18(TypeReference[] typeReferences)10902 public void intersectionCastNotBelow18(TypeReference[] typeReferences) {
10903 	int length = typeReferences.length;
10904 	this.handle(
10905 			IProblem.IntersectionCastNotBelow18,
10906 			NoArgument,
10907 			NoArgument,
10908 			typeReferences[0].sourceStart,
10909 			typeReferences[length -1].sourceEnd);
10910 }
10911 
duplicateBoundInIntersectionCast(TypeReference typeReference)10912 public void duplicateBoundInIntersectionCast(TypeReference typeReference) {
10913 	this.handle(
10914 			IProblem.DuplicateBoundInIntersectionCast,
10915 			NoArgument,
10916 			NoArgument,
10917 			typeReference.sourceStart,
10918 			typeReference.sourceEnd);
10919 }
10920 
lambdaRedeclaresArgument(Argument argument)10921 public void lambdaRedeclaresArgument(Argument argument) {
10922 	String[] arguments = new String[] {new String(argument.name)};
10923 	this.handle(
10924 		IProblem.LambdaRedeclaresArgument,
10925 		arguments,
10926 		arguments,
10927 		argument.sourceStart,
10928 		argument.sourceEnd);
10929 }
lambdaRedeclaresLocal(LocalDeclaration local)10930 public void lambdaRedeclaresLocal(LocalDeclaration local) {
10931 	String[] arguments = new String[] {new String(local.name)};
10932 	this.handle(
10933 		IProblem.LambdaRedeclaresLocal,
10934 		arguments,
10935 		arguments,
10936 		local.sourceStart,
10937 		local.sourceEnd);
10938 }
10939 
descriptorHasInvisibleType(FunctionalExpression expression, ReferenceBinding referenceBinding)10940 public void descriptorHasInvisibleType(FunctionalExpression expression, ReferenceBinding referenceBinding) {
10941 	this.handle(
10942 		IProblem.LambdaDescriptorMentionsUnmentionable,
10943 		new String[] { new String(referenceBinding.readableName()) },
10944 		new String[] { new String(referenceBinding.shortReadableName()) },
10945 		expression.sourceStart,
10946 		expression.diagnosticsSourceEnd());
10947 }
10948 
methodReferenceSwingsBothWays(ReferenceExpression expression, MethodBinding instanceMethod, MethodBinding nonInstanceMethod)10949 public void methodReferenceSwingsBothWays(ReferenceExpression expression, MethodBinding instanceMethod, MethodBinding nonInstanceMethod) {
10950 	char [] selector = instanceMethod.selector;
10951 	TypeBinding receiverType = instanceMethod.declaringClass;
10952 	StringBuffer buffer1 = new StringBuffer();
10953 	StringBuffer shortBuffer1 = new StringBuffer();
10954 	TypeBinding [] parameters = instanceMethod.parameters;
10955 	for (int i = 0, length = parameters.length; i < length; i++) {
10956 		if (i != 0){
10957 			buffer1.append(", "); //$NON-NLS-1$
10958 			shortBuffer1.append(", "); //$NON-NLS-1$
10959 		}
10960 		buffer1.append(new String(parameters[i].readableName()));
10961 		shortBuffer1.append(new String(parameters[i].shortReadableName()));
10962 	}
10963 	StringBuffer buffer2 = new StringBuffer();
10964 	StringBuffer shortBuffer2 = new StringBuffer();
10965 	parameters = nonInstanceMethod.parameters;
10966 	for (int i = 0, length = parameters.length; i < length; i++) {
10967 		if (i != 0){
10968 			buffer2.append(", "); //$NON-NLS-1$
10969 			shortBuffer2.append(", "); //$NON-NLS-1$
10970 		}
10971 		buffer2.append(new String(parameters[i].readableName()));
10972 		shortBuffer2.append(new String(parameters[i].shortReadableName()));
10973 	}
10974 
10975 	int id = IProblem.MethodReferenceSwingsBothWays;
10976 	this.handle(
10977 		id,
10978 		new String[] { new String(receiverType.readableName()), new String(selector), buffer1.toString(), new String(selector), buffer2.toString() },
10979 		new String[] { new String(receiverType.shortReadableName()), new String(selector), shortBuffer1.toString(), new String(selector), shortBuffer2.toString() },
10980 		expression.sourceStart,
10981 		expression.sourceEnd);
10982 }
10983 
methodMustBeAccessedStatically(ReferenceExpression expression, MethodBinding nonInstanceMethod)10984 public void methodMustBeAccessedStatically(ReferenceExpression expression, MethodBinding nonInstanceMethod) {
10985 	TypeBinding receiverType = nonInstanceMethod.declaringClass;
10986 	char [] selector = nonInstanceMethod.selector;
10987 	StringBuffer buffer = new StringBuffer();
10988 	StringBuffer shortBuffer = new StringBuffer();
10989 	TypeBinding [] parameters = nonInstanceMethod.parameters;
10990 	for (int i = 0, length = parameters.length; i < length; i++) {
10991 		if (i != 0){
10992 			buffer.append(", "); //$NON-NLS-1$
10993 			shortBuffer.append(", "); //$NON-NLS-1$
10994 		}
10995 		buffer.append(new String(parameters[i].readableName()));
10996 		shortBuffer.append(new String(parameters[i].shortReadableName()));
10997 	}
10998 	int id = IProblem.StaticMethodShouldBeAccessedStatically;
10999 	this.handle(
11000 		id,
11001 		new String[] { new String(receiverType.readableName()), new String(selector), buffer.toString() },
11002 		new String[] { new String(receiverType.shortReadableName()), new String(selector), shortBuffer.toString() },
11003 		expression.sourceStart,
11004 		expression.sourceEnd);
11005 }
11006 
methodMustBeAccessedWithInstance(ReferenceExpression expression, MethodBinding instanceMethod)11007 public void methodMustBeAccessedWithInstance(ReferenceExpression expression, MethodBinding instanceMethod) {
11008 	TypeBinding receiverType = instanceMethod.declaringClass;
11009 	char [] selector = instanceMethod.selector;
11010 	StringBuffer buffer = new StringBuffer();
11011 	StringBuffer shortBuffer = new StringBuffer();
11012 	TypeBinding [] parameters = instanceMethod.parameters;
11013 	for (int i = 0, length = parameters.length; i < length; i++) {
11014 		if (i != 0) {
11015 			buffer.append(", "); //$NON-NLS-1$
11016 			shortBuffer.append(", "); //$NON-NLS-1$
11017 		}
11018 		buffer.append(new String(parameters[i].readableName()));
11019 		shortBuffer.append(new String(parameters[i].shortReadableName()));
11020 	}
11021 	int id = IProblem.StaticMethodRequested;
11022 	this.handle(
11023 		id,
11024 		new String[] { new String(receiverType.readableName()), new String(selector), buffer.toString() },
11025 		new String[] { new String(receiverType.shortReadableName()), new String(selector), shortBuffer.toString() },
11026 		expression.sourceStart,
11027 		expression.sourceEnd);
11028 }
11029 
invalidArrayConstructorReference(ReferenceExpression expression, TypeBinding lhsType, TypeBinding[] parameters)11030 public void invalidArrayConstructorReference(ReferenceExpression expression, TypeBinding lhsType, TypeBinding[] parameters) {
11031 	StringBuffer buffer = new StringBuffer();
11032 	StringBuffer shortBuffer = new StringBuffer();
11033 	for (int i = 0, length = parameters.length; i < length; i++) {
11034 		if (i != 0) {
11035 			buffer.append(", "); //$NON-NLS-1$
11036 			shortBuffer.append(", "); //$NON-NLS-1$
11037 		}
11038 		buffer.append(new String(parameters[i].readableName()));
11039 		shortBuffer.append(new String(parameters[i].shortReadableName()));
11040 	}
11041 	int id = IProblem.InvalidArrayConstructorReference;
11042 	this.handle(
11043 		id,
11044 		new String[] { new String(lhsType.readableName()), buffer.toString() },
11045 		new String[] { new String(lhsType.shortReadableName()), shortBuffer.toString() },
11046 		expression.sourceStart,
11047 		expression.sourceEnd);
11048 }
11049 
constructedArrayIncompatible(ReferenceExpression expression, TypeBinding receiverType, TypeBinding returnType)11050 public void constructedArrayIncompatible(ReferenceExpression expression, TypeBinding receiverType, TypeBinding returnType) {
11051 	this.handle(
11052 			IProblem.ConstructedArrayIncompatible,
11053 			new String[] { new String(receiverType.readableName()), new String(returnType.readableName()) },
11054 			new String[] { new String(receiverType.shortReadableName()), new String(returnType.shortReadableName()) },
11055 			expression.sourceStart,
11056 			expression.sourceEnd);
11057 }
11058 
danglingReference(ReferenceExpression expression, TypeBinding receiverType, char[] selector, TypeBinding[] descriptorParameters)11059 public void danglingReference(ReferenceExpression expression, TypeBinding receiverType, char[] selector, TypeBinding[] descriptorParameters) {
11060 	StringBuffer buffer = new StringBuffer();
11061 	StringBuffer shortBuffer = new StringBuffer();
11062 	TypeBinding [] parameters = descriptorParameters;
11063 	for (int i = 0, length = parameters.length; i < length; i++) {
11064 		if (i != 0) {
11065 			buffer.append(", "); //$NON-NLS-1$
11066 			shortBuffer.append(", "); //$NON-NLS-1$
11067 		}
11068 		buffer.append(new String(parameters[i].readableName()));
11069 		shortBuffer.append(new String(parameters[i].shortReadableName()));
11070 	}
11071 
11072 	int id = IProblem.DanglingReference;
11073 	this.handle(
11074 		id,
11075 		new String[] { new String(receiverType.readableName()), new String(selector), buffer.toString() },
11076 		new String[] { new String(receiverType.shortReadableName()), new String(selector), shortBuffer.toString() },
11077 		expression.sourceStart,
11078 		expression.sourceEnd);
11079 }
unhandledException(TypeBinding exceptionType, ReferenceExpression location)11080 public void unhandledException(TypeBinding exceptionType, ReferenceExpression location) {
11081 	this.handle(IProblem.UnhandledException,
11082 		new String[] {new String(exceptionType.readableName())},
11083 		new String[] {new String(exceptionType.shortReadableName())},
11084 		location.sourceStart,
11085 		location.sourceEnd);
11086 }
11087 
incompatibleReturnType(ReferenceExpression expression, MethodBinding method, TypeBinding returnType)11088 public void incompatibleReturnType(ReferenceExpression expression, MethodBinding method, TypeBinding returnType) {
11089 	if (method.isConstructor()) {
11090 		this.handle(IProblem.ConstructionTypeMismatch,
11091 				new String[] { new String(method.declaringClass.readableName()), new String(returnType.readableName())},
11092 				new String[] { new String(method.declaringClass.shortReadableName()), new String(returnType.shortReadableName())},
11093 				expression.sourceStart,
11094 				expression.sourceEnd);
11095 
11096 	} else {
11097 		StringBuffer buffer = new StringBuffer();
11098 		StringBuffer shortBuffer = new StringBuffer();
11099 		TypeBinding [] parameters = method.parameters;
11100 		for (int i = 0, length = parameters.length; i < length; i++) {
11101 			if (i != 0) {
11102 				buffer.append(", "); //$NON-NLS-1$
11103 				shortBuffer.append(", "); //$NON-NLS-1$
11104 			}
11105 			buffer.append(new String(parameters[i].readableName()));
11106 			shortBuffer.append(new String(parameters[i].shortReadableName()));
11107 		}
11108 		String selector = new String(method.selector);
11109 		this.handle(IProblem.IncompatibleMethodReference,
11110 				new String[] { selector, buffer.toString(), new String(method.declaringClass.readableName()), new String(method.returnType.readableName()), new String(returnType.readableName())},
11111 				new String[] { selector, shortBuffer.toString(), new String(method.declaringClass.shortReadableName()), new String(method.returnType.shortReadableName()), new String(returnType.shortReadableName())},
11112 				expression.sourceStart,
11113 				expression.sourceEnd);
11114 	}
11115 }
11116 
illegalSuperAccess(TypeBinding superType, TypeBinding directSuperType, ASTNode location)11117 public void illegalSuperAccess(TypeBinding superType, TypeBinding directSuperType, ASTNode location) {
11118 	if (directSuperType.problemId() == ProblemReasons.InterfaceMethodInvocationNotBelow18) {
11119 		interfaceSuperInvocationNotBelow18((QualifiedSuperReference) location);
11120 		return;
11121 	}
11122 	if (directSuperType.problemId() != ProblemReasons.AttemptToBypassDirectSuper)
11123 		needImplementation(location);
11124 	handle(IProblem.SuperAccessCannotBypassDirectSuper,
11125 			new String[] { String.valueOf(superType.readableName()), String.valueOf(directSuperType.readableName()) },
11126 			new String[] { String.valueOf(superType.shortReadableName()), String.valueOf(directSuperType.shortReadableName()) },
11127 			location.sourceStart,
11128 			location.sourceEnd);
11129 }
illegalSuperCallBypassingOverride(InvocationSite location, MethodBinding targetMethod, ReferenceBinding overrider)11130 public void illegalSuperCallBypassingOverride(InvocationSite location, MethodBinding targetMethod, ReferenceBinding overrider) {
11131 	this.handle(IProblem.SuperCallCannotBypassOverride,
11132 			new String[] { 	String.valueOf(targetMethod.readableName()),
11133 							String.valueOf(targetMethod.declaringClass.readableName()),
11134 							String.valueOf(overrider.readableName()) },
11135 			new String[] { 	String.valueOf(targetMethod.shortReadableName()),
11136 							String.valueOf(targetMethod.declaringClass.shortReadableName()),
11137 							String.valueOf(overrider.shortReadableName()) },
11138 			location.sourceStart(),
11139 			location.sourceEnd());
11140 }
disallowedTargetForContainerAnnotation(Annotation annotation, TypeBinding containerAnnotationType)11141 public void disallowedTargetForContainerAnnotation(Annotation annotation, TypeBinding containerAnnotationType) {
11142 	this.handle(
11143 		IProblem.DisallowedTargetForContainerAnnotationType,
11144 		new String[] {new String(annotation.resolvedType.readableName()), new String(containerAnnotationType.readableName())},
11145 		new String[] {new String(annotation.resolvedType.shortReadableName()), new String(containerAnnotationType.shortReadableName())},
11146 		annotation.sourceStart,
11147 		annotation.sourceEnd);
11148 }
typeAnnotationAtQualifiedName(Annotation annotation)11149 public void typeAnnotationAtQualifiedName(Annotation annotation) {
11150 		this.handle(IProblem.TypeAnnotationAtQualifiedName, NoArgument, NoArgument, annotation.sourceStart,
11151 				annotation.sourceEnd);
11152 	}
genericInferenceError(String message, InvocationSite invocationSite)11153 public void genericInferenceError(String message, InvocationSite invocationSite) {
11154 	genericInferenceProblem(message, invocationSite, ProblemSeverities.Error);
11155 }
genericInferenceProblem(String message, InvocationSite invocationSite, int severity)11156 public void genericInferenceProblem(String message, InvocationSite invocationSite, int severity) {
11157 	String[] args = new String[]{message};
11158 	int start = 0, end = 0;
11159 	if (invocationSite != null) {
11160 		start = invocationSite.sourceStart();
11161 		end = invocationSite.sourceEnd();
11162 	}
11163 	this.handle(IProblem.GenericInferenceError, args, args, severity|ProblemSeverities.InternalError, start, end);
11164 }
uninternedIdentityComparison(EqualExpression expr, TypeBinding lhs, TypeBinding rhs, CompilationUnitDeclaration unit)11165 public void uninternedIdentityComparison(EqualExpression expr, TypeBinding lhs, TypeBinding rhs, CompilationUnitDeclaration unit) {
11166 
11167 	char [] lhsName = lhs.sourceName();
11168 	char [] rhsName = rhs.sourceName();
11169 
11170 	if (CharOperation.equals(lhsName, "VoidTypeBinding".toCharArray())  //$NON-NLS-1$
11171 			|| CharOperation.equals(lhsName, "NullTypeBinding".toCharArray())  //$NON-NLS-1$
11172 			|| CharOperation.equals(lhsName, "ProblemReferenceBinding".toCharArray())) //$NON-NLS-1$
11173 		return;
11174 
11175 	if (CharOperation.equals(rhsName, "VoidTypeBinding".toCharArray())  //$NON-NLS-1$
11176 			|| CharOperation.equals(rhsName, "NullTypeBinding".toCharArray())  //$NON-NLS-1$
11177 			|| CharOperation.equals(rhsName, "ProblemReferenceBinding".toCharArray())) //$NON-NLS-1$
11178 		return;
11179 
11180 	boolean[] validIdentityComparisonLines = unit.validIdentityComparisonLines;
11181 	if (validIdentityComparisonLines != null) {
11182 		int problemStartPosition = expr.left.sourceStart;
11183 		int[] lineEnds;
11184 		int lineNumber = problemStartPosition >= 0
11185 				? Util.getLineNumber(problemStartPosition, lineEnds = unit.compilationResult().getLineSeparatorPositions(), 0, lineEnds.length-1)
11186 						: 0;
11187 		if (lineNumber <= validIdentityComparisonLines.length && validIdentityComparisonLines[lineNumber - 1])
11188 			return;
11189 	}
11190 
11191 	this.handle(
11192 			IProblem.UninternedIdentityComparison,
11193 			new String[] {
11194 					new String(lhs.readableName()),
11195 					new String(rhs.readableName())
11196 			},
11197 			new String[] {
11198 					new String(lhs.shortReadableName()),
11199 					new String(rhs.shortReadableName())
11200 			},
11201 			expr.sourceStart,
11202 			expr.sourceEnd);
11203 }
invalidTypeArguments(TypeReference[] typeReference)11204 public void invalidTypeArguments(TypeReference[] typeReference) {
11205 	this.handle(IProblem.InvalidTypeArguments,
11206 			NoArgument, NoArgument,
11207 			typeReference[0].sourceStart,
11208 			typeReference[typeReference.length - 1].sourceEnd);
11209 }
invalidModule(ModuleReference ref)11210 public void invalidModule(ModuleReference ref) {
11211 	this.handle(IProblem.UndefinedModule,
11212 		NoArgument, new String[] { CharOperation.charToString(ref.moduleName) },
11213 		ref.sourceStart, ref.sourceEnd);
11214 }
missingModuleAddReads(char[] requiredModuleName)11215 public void missingModuleAddReads(char[] requiredModuleName) {
11216 	String[] args = new String[] { new String(requiredModuleName) };
11217 	this.handle(IProblem.UndefinedModuleAddReads, args, args, 0, 0);
11218 }
invalidOpensStatement(OpensStatement statement, ModuleDeclaration module)11219 public void invalidOpensStatement(OpensStatement statement, ModuleDeclaration module) {
11220 	this.handle(IProblem.InvalidOpensStatement,
11221 		NoArgument, new String[] { CharOperation.charToString(module.moduleName) },
11222 		statement.declarationSourceStart, statement.declarationSourceEnd);
11223 }
invalidPackageReference(int problem, PackageVisibilityStatement ref)11224 public void invalidPackageReference(int problem, PackageVisibilityStatement ref) {
11225 	this.handle(problem,
11226 			NoArgument,
11227 			new String[] { CharOperation.charToString(ref.pkgName) },
11228 			ref.computeSeverity(problem),
11229 			ref.pkgRef.sourceStart,
11230 			ref.pkgRef.sourceEnd);
11231 }
exportingForeignPackage(PackageVisibilityStatement ref, ModuleBinding enclosingModule)11232 public void exportingForeignPackage(PackageVisibilityStatement ref, ModuleBinding enclosingModule) {
11233 	String[] arguments = new String[] { CharOperation.charToString(ref.pkgName), CharOperation.charToString(enclosingModule.moduleName) };
11234 	this.handle(IProblem.ExportingForeignPackage,
11235 			arguments,
11236 			arguments,
11237 			ref.pkgRef.sourceStart,
11238 			ref.pkgRef.sourceEnd);
11239 }
duplicateModuleReference(int problem, ModuleReference ref)11240 public void duplicateModuleReference(int problem, ModuleReference ref) {
11241 	this.handle(problem,
11242 		NoArgument, new String[] { CharOperation.charToString(ref.moduleName) },
11243 		ref.sourceStart, ref.sourceEnd);
11244 }
duplicateTypeReference(int problem, TypeReference ref)11245 public void duplicateTypeReference(int problem, TypeReference ref) {
11246 	this.handle(problem,
11247 		NoArgument, new String[] { ref.toString() },
11248 		ref.sourceStart, ref.sourceEnd);
11249 }
duplicateTypeReference(int problem, TypeReference ref1, TypeReference ref2)11250 public void duplicateTypeReference(int problem, TypeReference ref1, TypeReference ref2) {
11251 	this.handle(problem,
11252 		NoArgument, new String[] { ref1.toString(), ref2.toString() },
11253 		ref1.sourceStart, ref2.sourceEnd);
11254 }
duplicateResourceReference(Reference ref)11255 public void duplicateResourceReference(Reference ref) {
11256 	this.handle(IProblem.DuplicateResource,
11257 		NoArgument, new String[] {ref.toString() },
11258 		ProblemSeverities.Warning,
11259 		ref.sourceStart, ref.sourceEnd);
11260 }
cyclicModuleDependency(ModuleBinding binding, ModuleReference ref)11261 public void cyclicModuleDependency(ModuleBinding binding, ModuleReference ref) {
11262 	this.handle(IProblem.CyclicModuleDependency,
11263 		NoArgument, new String[] { CharOperation.charToString(binding.moduleName), CharOperation.charToString(ref.moduleName) },
11264 		ref.sourceStart, ref.sourceEnd);
11265 }
invalidServiceRef(int problem, TypeReference type)11266 public void invalidServiceRef(int problem, TypeReference type) {
11267 	this.handle(problem,
11268 		NoArgument, new String[] { CharOperation.charToString(type.resolvedType.readableName()) },
11269 		type.sourceStart, type.sourceEnd);
11270 }
11271 
unlikelyArgumentType(Expression argument, MethodBinding method, TypeBinding argumentType, TypeBinding receiverType, DangerousMethod dangerousMethod)11272 public void unlikelyArgumentType(Expression argument, MethodBinding method, TypeBinding argumentType,
11273 							TypeBinding receiverType, DangerousMethod dangerousMethod)
11274 {
11275 	this.handle(
11276 			dangerousMethod == DangerousMethod.Equals ? IProblem.UnlikelyEqualsArgumentType : IProblem.UnlikelyCollectionMethodArgumentType,
11277 			new String[] {
11278 				new String(argumentType.readableName()),
11279 				new String(method.readableName()),
11280 				new String(receiverType.readableName())
11281 			},
11282 			new String[] {
11283 				new String(argumentType.shortReadableName()),
11284 				new String(method.shortReadableName()),
11285 				new String(receiverType.shortReadableName())
11286 			},
11287 			argument.sourceStart,
11288 			argument.sourceEnd);
11289 }
11290 
nonPublicTypeInAPI(TypeBinding type, int sourceStart, int sourceEnd)11291 public void nonPublicTypeInAPI(TypeBinding type, int sourceStart, int sourceEnd) {
11292 	handle(IProblem.NonPublicTypeInAPI,
11293 			new String[] { new String(type.readableName()) },
11294 			new String[] { new String(type.shortReadableName()) },
11295 			sourceStart,
11296 			sourceEnd);
11297 }
11298 
notExportedTypeInAPI(TypeBinding type, int sourceStart, int sourceEnd)11299 public void notExportedTypeInAPI(TypeBinding type, int sourceStart, int sourceEnd) {
11300 	handle(IProblem.NotExportedTypeInAPI,
11301 			new String[] { new String(type.readableName()) },
11302 			new String[] { new String(type.shortReadableName()) },
11303 			sourceStart,
11304 			sourceEnd);
11305 }
11306 
missingRequiresTransitiveForTypeInAPI(ReferenceBinding referenceBinding, int sourceStart, int sourceEnd)11307 public void missingRequiresTransitiveForTypeInAPI(ReferenceBinding referenceBinding, int sourceStart, int sourceEnd) {
11308 	String moduleName = new String(referenceBinding.fPackage.enclosingModule.readableName());
11309 	handle(IProblem.MissingRequiresTransitiveForTypeInAPI,
11310 			new String[] { new String(referenceBinding.readableName()), moduleName },
11311 			new String[] { new String(referenceBinding.shortReadableName()), moduleName },
11312 			sourceStart,
11313 			sourceEnd);
11314 }
11315 
unnamedPackageInNamedModule(ModuleBinding module)11316 public void unnamedPackageInNamedModule(ModuleBinding module) {
11317 	String[] args = { new String(module.readableName()) };
11318 	handle(IProblem.UnnamedPackageInNamedModule,
11319 			args,
11320 			args,
11321 			0,
11322 			0);
11323 }
11324 
autoModuleWithUnstableName(ModuleReference moduleReference)11325 public void autoModuleWithUnstableName(ModuleReference moduleReference) {
11326 	String[] args = { new String(moduleReference.moduleName) };
11327 	handle(IProblem.UnstableAutoModuleName,
11328 			args,
11329 			args,
11330 			moduleReference.sourceStart,
11331 			moduleReference.sourceEnd);
11332 }
switchExpressionIncompatibleResultExpressions(SwitchExpression expression)11333 public void switchExpressionIncompatibleResultExpressions(SwitchExpression expression) {
11334 	TypeBinding type = expression.resultExpressions.get(0).resolvedType;
11335 	this.handle(
11336 		IProblem.SwitchExpressionsYieldIncompatibleResultExpressionTypes,
11337 		new String[] {new String(type.readableName())},
11338 		new String[] {new String(type.shortReadableName())},
11339 		expression.sourceStart,
11340 		expression.sourceEnd);
11341 }
switchExpressionEmptySwitchBlock(SwitchExpression expression)11342 public void switchExpressionEmptySwitchBlock(SwitchExpression expression) {
11343 	this.handle(
11344 		IProblem.SwitchExpressionsYieldEmptySwitchBlock,
11345 		NoArgument,
11346 		NoArgument,
11347 		expression.sourceStart,
11348 		expression.sourceEnd);
11349 }
switchExpressionNoResultExpressions(SwitchExpression expression)11350 public void switchExpressionNoResultExpressions(SwitchExpression expression) {
11351 	this.handle(
11352 		IProblem.SwitchExpressionsYieldNoResultExpression,
11353 		NoArgument,
11354 		NoArgument,
11355 		expression.sourceStart,
11356 		expression.sourceEnd);
11357 }
switchExpressionSwitchLabeledBlockCompletesNormally(Block block)11358 public void switchExpressionSwitchLabeledBlockCompletesNormally(Block block) {
11359 	this.handle(
11360 		IProblem.SwitchExpressionaYieldSwitchLabeledBlockCompletesNormally,
11361 		NoArgument,
11362 		NoArgument,
11363 		block.sourceEnd - 1,
11364 		block.sourceEnd);
11365 }
switchExpressionLastStatementCompletesNormally(Statement stmt)11366 public void switchExpressionLastStatementCompletesNormally(Statement stmt) {
11367 	this.handle(
11368 		IProblem.SwitchExpressionaYieldSwitchLabeledBlockCompletesNormally,
11369 		NoArgument,
11370 		NoArgument,
11371 		stmt.sourceEnd - 1,
11372 		stmt.sourceEnd);
11373 }
switchExpressionIllegalLastStatement(Statement stmt)11374 public void switchExpressionIllegalLastStatement(Statement stmt) {
11375 	this.handle(
11376 		IProblem.SwitchExpressionsYieldIllegalLastStatement,
11377 		NoArgument,
11378 		NoArgument,
11379 		stmt.sourceStart,
11380 		stmt.sourceEnd);
11381 }
switchExpressionTrailingSwitchLabels(Statement stmt)11382 public void switchExpressionTrailingSwitchLabels(Statement stmt) {
11383 	this.handle(
11384 		IProblem.SwitchExpressionsYieldTrailingSwitchLabels,
11385 		NoArgument,
11386 		NoArgument,
11387 		stmt.sourceStart,
11388 		stmt.sourceEnd);
11389 }
switchExpressionMixedCase(ASTNode statement)11390 public void switchExpressionMixedCase(ASTNode statement) {
11391 	this.handle(
11392 		IProblem.SwitchPreviewMixedCase,
11393 		NoArgument,
11394 		NoArgument,
11395 		statement.sourceStart,
11396 		statement.sourceEnd);
11397 }
switchExpressionBreakNotAllowed(ASTNode statement)11398 public void switchExpressionBreakNotAllowed(ASTNode statement) {
11399 	this.handle(
11400 		IProblem.SwitchExpressionsYieldBreakNotAllowed,
11401 		NoArgument,
11402 		NoArgument,
11403 		statement.sourceStart,
11404 		statement.sourceEnd);
11405 }
switchExpressionsYieldUnqualifiedMethodWarning(ASTNode statement)11406 public void switchExpressionsYieldUnqualifiedMethodWarning(ASTNode statement) {
11407 	this.handle(
11408 		IProblem.SwitchExpressionsYieldUnqualifiedMethodWarning,
11409 		NoArgument,
11410 		NoArgument,
11411 		statement.sourceStart,
11412 		statement.sourceEnd);
11413 }
switchExpressionsYieldUnqualifiedMethodError(ASTNode statement)11414 public void switchExpressionsYieldUnqualifiedMethodError(ASTNode statement) {
11415 	this.handle(
11416 		IProblem.SwitchExpressionsYieldUnqualifiedMethodError,
11417 		NoArgument,
11418 		NoArgument,
11419 		statement.sourceStart,
11420 		statement.sourceEnd);
11421 }
switchExpressionsYieldOutsideSwitchExpression(ASTNode statement)11422 public void switchExpressionsYieldOutsideSwitchExpression(ASTNode statement) {
11423 	this.handle(
11424 		IProblem.SwitchExpressionsYieldOutsideSwitchExpression,
11425 		NoArgument,
11426 		NoArgument,
11427 		statement.sourceStart,
11428 		statement.sourceEnd);
11429 }
switchExpressionsYieldRestrictedGeneralWarning(ASTNode statement)11430 public void switchExpressionsYieldRestrictedGeneralWarning(ASTNode statement) {
11431 	this.handle(
11432 		IProblem.SwitchExpressionsYieldRestrictedGeneralWarning,
11433 		NoArgument,
11434 		NoArgument,
11435 		statement.sourceStart,
11436 		statement.sourceEnd);
11437 }
switchExpressionsYieldIllegalStatement(ASTNode statement)11438 public void switchExpressionsYieldIllegalStatement(ASTNode statement) {
11439 	this.handle(
11440 		IProblem.SwitchExpressionsYieldIllegalStatement,
11441 		NoArgument,
11442 		NoArgument,
11443 		statement.sourceStart,
11444 		statement.sourceEnd);
11445 }
switchExpressionsYieldTypeDeclarationWarning(ASTNode statement)11446 public void switchExpressionsYieldTypeDeclarationWarning(ASTNode statement) {
11447 	this.handle(
11448 		IProblem.SwitchExpressionsYieldTypeDeclarationWarning,
11449 		NoArgument,
11450 		NoArgument,
11451 		statement.sourceStart,
11452 		statement.sourceEnd);
11453 }
switchExpressionsYieldTypeDeclarationError(ASTNode statement)11454 public void switchExpressionsYieldTypeDeclarationError(ASTNode statement) {
11455 	this.handle(
11456 		IProblem.SwitchExpressionsYieldTypeDeclarationError,
11457 		NoArgument,
11458 		NoArgument,
11459 		statement.sourceStart,
11460 		statement.sourceEnd);
11461 }
multiConstantCaseLabelsNotSupported(ASTNode statement)11462 public void multiConstantCaseLabelsNotSupported(ASTNode statement) {
11463 	this.handle(
11464 		IProblem.MultiConstantCaseLabelsNotSupported,
11465 		NoArgument,
11466 		NoArgument,
11467 		statement.sourceStart,
11468 		statement.sourceEnd);
11469 }
arrowInCaseStatementsNotSupported(ASTNode statement)11470 public void arrowInCaseStatementsNotSupported(ASTNode statement) {
11471 	this.handle(
11472 		IProblem.ArrowInCaseStatementsNotSupported,
11473 		NoArgument,
11474 		NoArgument,
11475 		statement.sourceStart,
11476 		statement.sourceEnd);
11477 }
switchExpressionsNotSupported(ASTNode statement)11478 public void switchExpressionsNotSupported(ASTNode statement) {
11479 	this.handle(
11480 		IProblem.SwitchExpressionsNotSupported,
11481 		NoArgument,
11482 		NoArgument,
11483 		statement.sourceStart,
11484 		statement.sourceEnd);
11485 }
switchExpressionsBreakOutOfSwitchExpression(ASTNode statement)11486 public void switchExpressionsBreakOutOfSwitchExpression(ASTNode statement) {
11487 	this.handle(
11488 		IProblem.SwitchExpressionsBreakOutOfSwitchExpression,
11489 		NoArgument,
11490 		NoArgument,
11491 		statement.sourceStart,
11492 		statement.sourceEnd);
11493 }
switchExpressionsContinueOutOfSwitchExpression(ASTNode statement)11494 public void switchExpressionsContinueOutOfSwitchExpression(ASTNode statement) {
11495 	this.handle(
11496 		IProblem.SwitchExpressionsContinueOutOfSwitchExpression,
11497 		NoArgument,
11498 		NoArgument,
11499 		statement.sourceStart,
11500 		statement.sourceEnd);
11501 }
switchExpressionsReturnWithinSwitchExpression(ASTNode statement)11502 public void switchExpressionsReturnWithinSwitchExpression(ASTNode statement) {
11503 	this.handle(
11504 		IProblem.SwitchExpressionsReturnWithinSwitchExpression,
11505 		NoArgument,
11506 		NoArgument,
11507 		statement.sourceStart,
11508 		statement.sourceEnd);
11509 }
illegalModifierForInnerRecord(SourceTypeBinding type)11510 public void illegalModifierForInnerRecord(SourceTypeBinding type) {
11511 	if (!this.options.enablePreviewFeatures)
11512 		return;
11513 	String[] arguments = new String[] {new String(type.sourceName())};
11514 	this.handle(
11515 		IProblem.RecordIllegalModifierForInnerRecord,
11516 		arguments,
11517 		arguments,
11518 		type.sourceStart(),
11519 		type.sourceEnd());
11520 }
illegalModifierForRecord(SourceTypeBinding type)11521 public void illegalModifierForRecord(SourceTypeBinding type) {
11522 	if (!this.options.enablePreviewFeatures)
11523 		return;
11524 	String[] arguments = new String[] {new String(type.sourceName())};
11525 	this.handle(
11526 		IProblem.RecordIllegalModifierForRecord,
11527 		arguments,
11528 		arguments,
11529 		type.sourceStart(),
11530 		type.sourceEnd());
11531 }
recordNonStaticFieldDeclarationInRecord(FieldDeclaration field)11532 public void recordNonStaticFieldDeclarationInRecord(FieldDeclaration field) {
11533 	if (!this.options.enablePreviewFeatures)
11534 		return;
11535 	this.handle(
11536 		IProblem.RecordNonStaticFieldDeclarationInRecord,
11537 		new String[] { new String(field.name) },
11538 		new String[] { new String(field.name) },
11539 		field.sourceStart,
11540 		field.sourceEnd);
11541 }
recordAccessorMethodHasThrowsClause(ASTNode methodDeclaration)11542 public void recordAccessorMethodHasThrowsClause(ASTNode methodDeclaration) {
11543 	if (!this.options.enablePreviewFeatures)
11544 		return;
11545 	this.handle(
11546 		IProblem.RecordAccessorMethodHasThrowsClause,
11547 		NoArgument,
11548 		NoArgument,
11549 		methodDeclaration.sourceStart,
11550 		methodDeclaration.sourceEnd);
11551 }
recordCanonicalConstructorNotPublic(AbstractMethodDeclaration methodDecl)11552 public void recordCanonicalConstructorNotPublic(AbstractMethodDeclaration methodDecl) {
11553 	if (!this.options.enablePreviewFeatures)
11554 		return;
11555 	this.handle(
11556 		IProblem.RecordCanonicalConstructorShouldBePublic,
11557 		new String[] {
11558 				new String(methodDecl.selector)
11559 			},
11560 			new String[] {
11561 				new String(methodDecl.selector)
11562 			},
11563 		methodDecl.sourceStart,
11564 		methodDecl.sourceEnd);
11565 }
recordCompactConstructorHasReturnStatement(ReturnStatement stmt)11566 public void recordCompactConstructorHasReturnStatement(ReturnStatement stmt) {
11567 	if (!this.options.enablePreviewFeatures)
11568 		return;
11569 	this.handle(
11570 		IProblem.RecordCompactConstructorHasReturnStatement,
11571 		NoArgument,
11572 		NoArgument,
11573 		stmt.sourceStart,
11574 		stmt.sourceEnd);
11575 }
recordIllegalComponentNameInRecord(RecordComponent recComp, TypeDeclaration typeDecl)11576 public void recordIllegalComponentNameInRecord(RecordComponent recComp, TypeDeclaration typeDecl) {
11577 	if (!this.options.enablePreviewFeatures)
11578 		return;
11579 	this.handle(
11580 		IProblem.RecordIllegalComponentNameInRecord,
11581 		new String[] {
11582 				new String(recComp.name), new String(typeDecl.name)
11583 			},
11584 			new String[] {
11585 					new String(recComp.name), new String(typeDecl.name)
11586 			},
11587 		recComp.sourceStart,
11588 		recComp.sourceEnd);
11589 }
recordDuplicateComponent(RecordComponent recordComponent)11590 public void recordDuplicateComponent(RecordComponent recordComponent) {
11591 	if (!this.options.enablePreviewFeatures)
11592 		return;
11593 	this.handle(
11594 		IProblem.RecordDuplicateComponent,
11595 		new String[] { new String(recordComponent.name)},
11596 		new String[] { new String(recordComponent.name)},
11597 		recordComponent.sourceStart,
11598 		recordComponent.sourceEnd);
11599 }
recordIllegalNativeModifierInRecord(AbstractMethodDeclaration method)11600 public void recordIllegalNativeModifierInRecord(AbstractMethodDeclaration method) {
11601 	if (!this.options.enablePreviewFeatures)
11602 		return;
11603 	this.handle(
11604 		IProblem.RecordIllegalNativeModifierInRecord,
11605 		new String[] { new String(method.selector)},
11606 		new String[] { new String(method.selector)},
11607 		method.sourceStart,
11608 		method.sourceEnd);
11609 }
recordInstanceInitializerBlockInRecord(Initializer initializer)11610 public void recordInstanceInitializerBlockInRecord(Initializer initializer) {
11611 	if (!this.options.enablePreviewFeatures)
11612 		return;
11613 	this.handle(
11614 		IProblem.RecordInstanceInitializerBlockInRecord,
11615 		NoArgument,
11616 		NoArgument,
11617 		initializer.sourceStart,
11618 		initializer.sourceEnd);
11619 }
recordIsAReservedTypeName(ASTNode decl)11620 public void recordIsAReservedTypeName(ASTNode decl) {
11621 	if (!this.options.enablePreviewFeatures)
11622 		return;
11623 	this.handle(
11624 		IProblem.RecordIsAReservedTypeName,
11625 		NoArgument,
11626 		NoArgument,
11627 		decl.sourceStart,
11628 		decl.sourceEnd);
11629 }
recordIllegalAccessorReturnType(ASTNode returnType, TypeBinding type)11630 public void recordIllegalAccessorReturnType(ASTNode returnType, TypeBinding type) {
11631 	if (!this.options.enablePreviewFeatures)
11632 		return;
11633 	this.handle(
11634 		IProblem.RecordIllegalAccessorReturnType,
11635 		new String[] {new String(type.readableName())},
11636 		new String[] {new String(type.shortReadableName())},
11637 		returnType.sourceStart,
11638 		returnType.sourceEnd);
11639 }
recordAccessorMethodShouldNotBeGeneric(ASTNode methodDecl)11640 public void recordAccessorMethodShouldNotBeGeneric(ASTNode methodDecl) {
11641 	if (!this.options.enablePreviewFeatures)
11642 		return;
11643 	this.handle(
11644 		IProblem.RecordAccessorMethodShouldNotBeGeneric,
11645 		NoArgument,
11646 		NoArgument,
11647 		methodDecl.sourceStart,
11648 		methodDecl.sourceEnd);
11649 }
recordAccessorMethodShouldBePublic(ASTNode methodDecl)11650 public void recordAccessorMethodShouldBePublic(ASTNode methodDecl) {
11651 	if (!this.options.enablePreviewFeatures)
11652 		return;
11653 	this.handle(
11654 		IProblem.RecordAccessorMethodShouldBePublic,
11655 		NoArgument,
11656 		NoArgument,
11657 		methodDecl.sourceStart,
11658 		methodDecl.sourceEnd);
11659 }
recordCanonicalConstructorShouldNotBeGeneric(AbstractMethodDeclaration methodDecl)11660 public void recordCanonicalConstructorShouldNotBeGeneric(AbstractMethodDeclaration methodDecl) {
11661 	if (!this.options.enablePreviewFeatures)
11662 		return;
11663 	this.handle(
11664 		IProblem.RecordCanonicalConstructorShouldNotBeGeneric,
11665 		new String[] { new String(methodDecl.selector)},
11666 		new String[] { new String(methodDecl.selector)},
11667 		methodDecl.sourceStart,
11668 		methodDecl.sourceEnd);
11669 }
recordCanonicalConstructorShouldBePublic(MethodDeclaration methodDecl)11670 public void recordCanonicalConstructorShouldBePublic(MethodDeclaration methodDecl) {
11671 	if (!this.options.enablePreviewFeatures)
11672 		return;
11673 	this.handle(
11674 		IProblem.RecordCanonicalConstructorShouldBePublic,
11675 		new String[] { new String(methodDecl.selector)},
11676 		new String[] { new String(methodDecl.selector)},
11677 		methodDecl.sourceStart,
11678 		methodDecl.sourceEnd);
11679 }
recordCanonicalConstructorHasThrowsClause(AbstractMethodDeclaration methodDecl)11680 public void recordCanonicalConstructorHasThrowsClause(AbstractMethodDeclaration methodDecl) {
11681 	if (!this.options.enablePreviewFeatures)
11682 		return;
11683 	this.handle(
11684 		IProblem.RecordCanonicalConstructorHasThrowsClause,
11685 		new String[] { new String(methodDecl.selector)},
11686 		new String[] { new String(methodDecl.selector)},
11687 		methodDecl.sourceStart,
11688 		methodDecl.sourceEnd);
11689 }
recordCanonicalConstructorHasReturnStatement(ASTNode methodDecl)11690 public void recordCanonicalConstructorHasReturnStatement(ASTNode methodDecl) {
11691 	if (!this.options.enablePreviewFeatures)
11692 		return;
11693 	this.handle(
11694 		IProblem.RecordCanonicalConstructorHasReturnStatement,
11695 		NoArgument,
11696 		NoArgument,
11697 		methodDecl.sourceStart,
11698 		methodDecl.sourceEnd);
11699 }
recordCanonicalConstructorHasExplicitConstructorCall(ASTNode methodDecl)11700 public void recordCanonicalConstructorHasExplicitConstructorCall(ASTNode methodDecl) {
11701 	if (!this.options.enablePreviewFeatures)
11702 		return;
11703 	this.handle(
11704 		IProblem.RecordCanonicalConstructorHasExplicitConstructorCall,
11705 		NoArgument,
11706 		NoArgument,
11707 		methodDecl.sourceStart,
11708 		methodDecl.sourceEnd);
11709 }
recordCompactConstructorHasExplicitConstructorCall(ASTNode methodDecl)11710 public void recordCompactConstructorHasExplicitConstructorCall(ASTNode methodDecl) {
11711 	if (!this.options.enablePreviewFeatures)
11712 		return;
11713 	this.handle(
11714 		IProblem.RecordCompactConstructorHasExplicitConstructorCall,
11715 		NoArgument,
11716 		NoArgument,
11717 		methodDecl.sourceStart,
11718 		methodDecl.sourceEnd);
11719 }
recordNestedRecordInherentlyStatic(SourceTypeBinding type)11720 public void recordNestedRecordInherentlyStatic(SourceTypeBinding type) {
11721 	if (!this.options.enablePreviewFeatures)
11722 		return;
11723 	this.handle(
11724 		IProblem.RecordNestedRecordInherentlyStatic,
11725 		NoArgument,
11726 		NoArgument,
11727 		type.sourceStart(),
11728 		type.sourceEnd());
11729 }
recordAccessorMethodShouldNotBeStatic(ASTNode methodDecl)11730 public void recordAccessorMethodShouldNotBeStatic(ASTNode methodDecl) {
11731 	if (!this.options.enablePreviewFeatures)
11732 		return;
11733 	this.handle(
11734 		IProblem.RecordAccessorMethodShouldNotBeStatic,
11735 		NoArgument,
11736 		NoArgument,
11737 		methodDecl.sourceStart,
11738 		methodDecl.sourceEnd);
11739 }
recordCannotExtendRecord(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding)11740 public void recordCannotExtendRecord(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) {
11741 	if (!this.options.enablePreviewFeatures)
11742 		return;
11743 	String name = new String(type.sourceName());
11744 	String superTypeFullName = new String(superTypeBinding.readableName());
11745 	String superTypeShortName = new String(superTypeBinding.shortReadableName());
11746 	if (superTypeShortName.equals(name)) superTypeShortName = superTypeFullName;
11747 	this.handle(
11748 		IProblem.RecordCannotExtendRecord,
11749 		new String[] {superTypeFullName, name},
11750 		new String[] {superTypeShortName, name},
11751 		superclass.sourceStart,
11752 		superclass.sourceEnd);
11753 }
recordComponentCannotBeVoid(RecordComponent arg)11754 public void recordComponentCannotBeVoid(RecordComponent arg) {
11755 	if (!this.options.enablePreviewFeatures)
11756 		return;
11757 	String[] arguments = new String[] { new String(arg.name) };
11758 	this.handle(
11759 		IProblem.RecordComponentCannotBeVoid,
11760 		arguments,
11761 		arguments,
11762 		arg.sourceStart,
11763 		arg.sourceEnd);
11764 }
recordIllegalVararg(RecordComponent argType, TypeDeclaration typeDecl)11765 public void recordIllegalVararg(RecordComponent argType, TypeDeclaration typeDecl) {
11766 	String[] arguments = new String[] {CharOperation.toString(argType.type.getTypeName()), new String(typeDecl.name)};
11767 	this.handle(
11768 		IProblem.RecordIllegalVararg,
11769 		arguments,
11770 		arguments,
11771 		argType.sourceStart,
11772 		argType.sourceEnd);
11773 }
recordStaticReferenceToOuterLocalVariable(LocalVariableBinding local, ASTNode node)11774 public void recordStaticReferenceToOuterLocalVariable(LocalVariableBinding local, ASTNode node) {
11775 	String[] arguments = new String[] {new String(local.readableName())};
11776 	this.handle(
11777 		IProblem.RecordStaticReferenceToOuterLocalVariable,
11778 		arguments,
11779 		arguments,
11780 		node.sourceStart,
11781 		node.sourceEnd);
11782 }
11783 }