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 * IBM Corporation - added the following constants: 14 * COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE 15 * COMPILER_PB_STATIC_ACCESS_RECEIVER 16 * COMPILER_TASK_TAGS 17 * CORE_CIRCULAR_CLASSPATH 18 * CORE_INCOMPLETE_CLASSPATH 19 * IBM Corporation - added run(IWorkspaceRunnable, IProgressMonitor) 20 * IBM Corporation - added exclusion patterns to source classpath entries 21 * IBM Corporation - added specific output location to source classpath entries 22 * IBM Corporation - added the following constants: 23 * CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER 24 * CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER 25 * CLEAN 26 * IBM Corporation - added getClasspathContainerInitializer(String) 27 * IBM Corporation - added the following constants: 28 * CODEASSIST_ARGUMENT_PREFIXES 29 * CODEASSIST_ARGUMENT_SUFFIXES 30 * CODEASSIST_FIELD_PREFIXES 31 * CODEASSIST_FIELD_SUFFIXES 32 * CODEASSIST_LOCAL_PREFIXES 33 * CODEASSIST_LOCAL_SUFFIXES 34 * CODEASSIST_STATIC_FIELD_PREFIXES 35 * CODEASSIST_STATIC_FIELD_SUFFIXES 36 * COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION 37 * IBM Corporation - added the following constants: 38 * COMPILER_PB_LOCAL_VARIABLE_HIDING 39 * COMPILER_PB_SPECIAL_PARAMETER_HIDING_FIELD 40 * COMPILER_PB_FIELD_HIDING 41 * COMPILER_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT 42 * CORE_INCOMPATIBLE_JDK_LEVEL 43 * VERSION_1_5 44 * COMPILER_PB_EMPTY_STATEMENT 45 * IBM Corporation - added the following constants: 46 * COMPILER_PB_INDIRECT_STATIC_ACCESS 47 * COMPILER_PB_BOOLEAN_METHOD_THROWING_EXCEPTION 48 * COMPILER_PB_UNNECESSARY_CAST 49 * IBM Corporation - added the following constants: 50 * COMPILER_PB_INVALID_JAVADOC 51 * COMPILER_PB_INVALID_JAVADOC_TAGS 52 * COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY 53 * COMPILER_PB_MISSING_JAVADOC_TAGS 54 * COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY 55 * COMPILER_PB_MISSING_JAVADOC_TAGS_OVERRIDING 56 * COMPILER_PB_MISSING_JAVADOC_COMMENTS 57 * COMPILER_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY 58 * COMPILER_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING 59 * COMPILER_PB_DEPRECATION_WHEN_OVERRIDING_DEPRECATED_METHOD 60 * COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING 61 * IBM Corporation - added the following constants: 62 * TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC 63 * IBM Corporation - added the following constants: 64 * COMPILER_PB_FALLTHROUGH_CASE 65 * COMPILER_PB_PARAMETER_ASSIGNMENT 66 * COMPILER_PB_NULL_REFERENCE 67 * IBM Corporation - added the following constants: 68 * CODEASSIST_DEPRECATION_CHECK 69 * IBM Corporation - added the following constants: 70 * COMPILER_PB_POTENTIAL_NULL_REFERENCE 71 * COMPILER_PB_REDUNDANT_NULL_CHECK 72 * IBM Corporation - added the following constants: 73 * COMPILER_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE 74 * IBM Corporation - added the following constants: 75 * COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_INCLUDE_DOC_COMMENT_REFERENCE 76 * IBM Corporation - added the following constants: 77 * COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION 78 * COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_NO_TAG 79 * COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_RETURN_TAG 80 * COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_ALL_TAGS 81 * IBM Corporation - added the following constants: 82 * COMPILER_PB_REDUNDANT_SUPERINTERFACE 83 * IBM Corporation - added the following constant: 84 * COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_EXEMPT_EXCEPTION_AND_THROWABLE 85 * IBM Corporation - added getOptionForConfigurableSeverity(int) 86 * Benjamin Muskalla - added COMPILER_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD 87 * Stephan Herrmann - added COMPILER_PB_UNUSED_OBJECT_ALLOCATION 88 * Stephan Herrmann - added COMPILER_PB_SUPPRESS_OPTIONAL_ERRORS 89 * Stephan Herrmann - added the following constants: 90 * COMPILER_PB_UNCLOSED_CLOSEABLE, 91 * COMPILER_PB_POTENTIALLY_UNCLOSED_CLOSEABLE 92 * COMPILER_PB_EXPLICITLY_CLOSED_AUTOCLOSEABLE 93 * COMPILER_ANNOTATION_NULL_ANALYSIS 94 * COMPILER_NULLABLE_ANNOTATION_NAME 95 * COMPILER_NONNULL_ANNOTATION_NAME 96 * COMPILER_PB_NULL_SPECIFICATION_VIOLATION 97 * COMPILER_PB_POTENTIAL_NULL_SPECIFICATION_VIOLATION 98 * COMPILER_PB_NULL_SPECIFICATION_INSUFFICIENT_INFO 99 * COMPILER_PB_MISSING_ENUM_CASE_DESPITE_DEFAULT 100 * COMPILER_PB_SWITCH_MISSING_DEFAULT_CASE 101 * COMPILER_INHERIT_NULL_ANNOTATIONS 102 * COMPILER_PB_NONNULL_PARAMETER_ANNOTATION_DROPPED 103 * COMPILER_PB_SYNTACTIC_NULL_ANALYSIS_FOR_FIELDS 104 * COMPILER_PB_UNLIKELY_COLLECTION_METHOD_ARGUMENT_TYPE 105 * COMPILER_PB_UNLIKELY_EQUALS_ARGUMENT_TYPE 106 * Jesper S Moller - Contributions for bug 381345 : [1.8] Take care of the Java 8 major version 107 * - added the following constants: 108 * COMPILER_CODEGEN_METHOD_PARAMETERS_ATTR 109 * Harry Terkelsen (het@google.com) - Bug 449262 - Allow the use of third-party Java formatters 110 * Gábor Kövesdán - Contribution for Bug 350000 - [content assist] Include non-prefix matches in auto-complete suggestions 111 * Karsten Thoms - Bug 532505 - Reduce memory footprint of ClasspathAccessRule 112 * 113 *******************************************************************************/ 114 115 package org.eclipse.jdt.core; 116 117 import java.io.File; 118 import java.io.IOException; 119 import java.util.ArrayList; 120 import java.util.Arrays; 121 import java.util.Collections; 122 import java.util.HashMap; 123 import java.util.HashSet; 124 import java.util.Hashtable; 125 import java.util.LinkedHashSet; 126 import java.util.List; 127 import java.util.Map; 128 import java.util.Set; 129 import java.util.stream.Collectors; 130 import java.util.stream.Stream; 131 import java.util.zip.ZipFile; 132 133 import org.eclipse.core.resources.IContainer; 134 import org.eclipse.core.resources.IFile; 135 import org.eclipse.core.resources.IFolder; 136 import org.eclipse.core.resources.IMarker; 137 import org.eclipse.core.resources.IMarkerDelta; 138 import org.eclipse.core.resources.IProject; 139 import org.eclipse.core.resources.IResource; 140 import org.eclipse.core.resources.IResourceChangeEvent; 141 import org.eclipse.core.resources.IResourceChangeListener; 142 import org.eclipse.core.resources.IWorkspace; 143 import org.eclipse.core.resources.IWorkspaceRoot; 144 import org.eclipse.core.resources.IWorkspaceRunnable; 145 import org.eclipse.core.resources.ResourcesPlugin; 146 import org.eclipse.core.runtime.CoreException; 147 import org.eclipse.core.runtime.IConfigurationElement; 148 import org.eclipse.core.runtime.IExtension; 149 import org.eclipse.core.runtime.IExtensionPoint; 150 import org.eclipse.core.runtime.IPath; 151 import org.eclipse.core.runtime.IProgressMonitor; 152 import org.eclipse.core.runtime.OperationCanceledException; 153 import org.eclipse.core.runtime.Path; 154 import org.eclipse.core.runtime.Platform; 155 import org.eclipse.core.runtime.Plugin; 156 import org.eclipse.core.runtime.QualifiedName; 157 import org.eclipse.core.runtime.SubMonitor; 158 import org.eclipse.core.runtime.jobs.ISchedulingRule; 159 import org.eclipse.jdt.core.compiler.CharOperation; 160 import org.eclipse.jdt.core.compiler.IProblem; 161 import org.eclipse.jdt.core.search.IJavaSearchConstants; 162 import org.eclipse.jdt.core.search.IJavaSearchScope; 163 import org.eclipse.jdt.core.search.SearchEngine; 164 import org.eclipse.jdt.core.search.SearchPattern; 165 import org.eclipse.jdt.core.search.TypeNameRequestor; 166 import org.eclipse.jdt.core.util.IAttributeNamesConstants; 167 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; 168 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; 169 import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException; 170 import org.eclipse.jdt.internal.compiler.env.AutomaticModuleNaming; 171 import org.eclipse.jdt.internal.compiler.env.IModule; 172 import org.eclipse.jdt.internal.compiler.env.IModule.IModuleReference; 173 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; 174 import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; 175 import org.eclipse.jdt.internal.core.BatchOperation; 176 import org.eclipse.jdt.internal.core.BufferManager; 177 import org.eclipse.jdt.internal.core.ClasspathAttribute; 178 import org.eclipse.jdt.internal.core.ClasspathEntry; 179 import org.eclipse.jdt.internal.core.ClasspathValidation; 180 import org.eclipse.jdt.internal.core.CreateTypeHierarchyOperation; 181 import org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner; 182 import org.eclipse.jdt.internal.core.ExternalFoldersManager; 183 import org.eclipse.jdt.internal.core.JavaCorePreferenceInitializer; 184 import org.eclipse.jdt.internal.core.JavaModel; 185 import org.eclipse.jdt.internal.core.JavaModelManager; 186 import org.eclipse.jdt.internal.core.JavaProject; 187 import org.eclipse.jdt.internal.core.PackageFragmentRoot; 188 import org.eclipse.jdt.internal.core.Region; 189 import org.eclipse.jdt.internal.core.SetContainerOperation; 190 import org.eclipse.jdt.internal.core.SetVariablesOperation; 191 import org.eclipse.jdt.internal.core.builder.JavaBuilder; 192 import org.eclipse.jdt.internal.core.builder.ModuleInfoBuilder; 193 import org.eclipse.jdt.internal.core.builder.State; 194 import org.eclipse.jdt.internal.core.nd.indexer.Indexer; 195 import org.eclipse.jdt.internal.core.search.indexing.IndexManager; 196 import org.eclipse.jdt.internal.core.util.MementoTokenizer; 197 import org.eclipse.jdt.internal.core.util.Messages; 198 import org.eclipse.jdt.internal.core.util.ModuleUtil; 199 import org.eclipse.jdt.internal.core.util.Util; 200 import org.osgi.framework.BundleContext; 201 202 /** 203 * The plug-in runtime class for the Java model plug-in containing the core 204 * (UI-free) support for Java projects. 205 * <p> 206 * Like all plug-in runtime classes (subclasses of <code>Plugin</code>), this 207 * class is automatically instantiated by the platform when the plug-in gets 208 * activated. Clients must not attempt to instantiate plug-in runtime classes 209 * directly. 210 * </p> 211 * <p> 212 * The single instance of this class can be accessed from any plug-in declaring 213 * the Java model plug-in as a prerequisite via 214 * <code>JavaCore.getJavaCore()</code>. The Java model plug-in will be activated 215 * automatically if not already active. 216 * </p> 217 * @noinstantiate This class is not intended to be instantiated by clients. 218 */ 219 @SuppressWarnings({ "unchecked", "rawtypes" }) 220 public final class JavaCore extends Plugin { 221 222 private static final IResource[] NO_GENERATED_RESOURCES = new IResource[0]; 223 224 private static Plugin JAVA_CORE_PLUGIN = null; 225 /** 226 * The plug-in identifier of the Java core support 227 * (value <code>"org.eclipse.jdt.core"</code>). 228 */ 229 public static final String PLUGIN_ID = "org.eclipse.jdt.core" ; //$NON-NLS-1$ 230 231 /** 232 * The identifier for the Java builder 233 * (value <code>"org.eclipse.jdt.core.javabuilder"</code>). 234 */ 235 public static final String BUILDER_ID = PLUGIN_ID + ".javabuilder" ; //$NON-NLS-1$ 236 237 /** 238 * The identifier for the Java model 239 * (value <code>"org.eclipse.jdt.core.javamodel"</code>). 240 */ 241 public static final String MODEL_ID = PLUGIN_ID + ".javamodel" ; //$NON-NLS-1$ 242 243 /** 244 * The identifier for the Java nature 245 * (value <code>"org.eclipse.jdt.core.javanature"</code>). 246 * The presence of this nature on a project indicates that it is 247 * Java-capable. 248 * 249 * @see org.eclipse.core.resources.IProject#hasNature(java.lang.String) 250 */ 251 public static final String NATURE_ID = PLUGIN_ID + ".javanature" ; //$NON-NLS-1$ 252 253 /** 254 * Name of the handle id attribute in a Java marker. 255 */ 256 protected static final String ATT_HANDLE_ID = 257 "org.eclipse.jdt.internal.core.JavaModelManager.handleId" ; //$NON-NLS-1$ 258 259 /** 260 * Name of the User Library Container id. 261 * @since 3.0 262 */ 263 public static final String USER_LIBRARY_CONTAINER_ID= "org.eclipse.jdt.USER_LIBRARY"; //$NON-NLS-1$ 264 265 /** 266 * @since 3.14 267 */ 268 public static final String MODULE_PATH_CONTAINER_ID = "org.eclipse.jdt.MODULE_PATH"; //$NON-NLS-1$ 269 270 // Begin configurable option IDs { 271 272 /** 273 * Compiler option ID: Generating Local Variable Debug Attribute. 274 * <p>When generated, this attribute will enable local variable names 275 * to be displayed in debugger, only in place where variables are 276 * definitely assigned (.class file is then bigger).</p> 277 * <dl> 278 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.debug.localVariable"</code></dd> 279 * <dt>Possible values:</dt><dd><code>{ "generate", "do not generate" }</code></dd> 280 * <dt>Default:</dt><dd><code>"generate"</code></dd> 281 * </dl> 282 * @category CompilerOptionID 283 */ 284 public static final String COMPILER_LOCAL_VARIABLE_ATTR = PLUGIN_ID + ".compiler.debug.localVariable"; //$NON-NLS-1$ 285 /** 286 * Compiler option ID: Generating Line Number Debug Attribute. 287 * <p>When generated, this attribute will enable source code highlighting in debugger 288 * (.class file is then bigger).</p> 289 * <dl> 290 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.debug.lineNumber"</code></dd> 291 * <dt>Possible values:</dt><dd><code>{ "generate", "do not generate" }</code></dd> 292 * <dt>Default:</dt><dd><code>"generate"</code></dd> 293 * </dl> 294 * @category CompilerOptionID 295 */ 296 public static final String COMPILER_LINE_NUMBER_ATTR = PLUGIN_ID + ".compiler.debug.lineNumber"; //$NON-NLS-1$ 297 /** 298 * Compiler option ID: Generating Source Debug Attribute. 299 * <p>When generated, this attribute will enable the debugger to present the 300 * corresponding source code.</p> 301 * <dl> 302 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.debug.sourceFile"</code></dd> 303 * <dt>Possible values:</dt><dd><code>{ "generate", "do not generate" }</code></dd> 304 * <dt>Default:</dt><dd><code>"generate"</code></dd> 305 * </dl> 306 * @category CompilerOptionID 307 */ 308 public static final String COMPILER_SOURCE_FILE_ATTR = PLUGIN_ID + ".compiler.debug.sourceFile"; //$NON-NLS-1$ 309 /** 310 * Compiler option ID: Preserving Unused Local Variables. 311 * <p>Unless requested to preserve unused local variables (that is, never read), the 312 * compiler will optimize them out, potentially altering debugging.</p> 313 * <dl> 314 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.codegen.unusedLocal"</code></dd> 315 * <dt>Possible values:</dt><dd><code>{ "preserve", "optimize out" }</code></dd> 316 * <dt>Default:</dt><dd><code>"preserve"</code></dd> 317 * </dl> 318 * @category CompilerOptionID 319 */ 320 public static final String COMPILER_CODEGEN_UNUSED_LOCAL = PLUGIN_ID + ".compiler.codegen.unusedLocal"; //$NON-NLS-1$ 321 /** 322 * Compiler option ID: Generating Method Parameters Attribute. 323 * <p>When generated, this attribute will enable information about the formal parameters of a method 324 * (such as their names) to be accessed from reflection libraries, annotation processing, 325 * code weaving, and in the debugger, from platform target level 1.8 and later.</p> 326 * <dl> 327 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.codegen.methodParameters"</code></dd> 328 * <dt>Possible values:</dt><dd><code>{ "generate", "do not generate" }</code></dd> 329 * <dt>Default:</dt><dd><code>"do not generate"</code></dd> 330 * </dl> 331 * @since 3.10 332 * @category CompilerOptionID 333 */ 334 public static final String COMPILER_CODEGEN_METHOD_PARAMETERS_ATTR = PLUGIN_ID + ".compiler.codegen.methodParameters"; //$NON-NLS-1$ 335 /** 336 * Compiler option ID: Defining Target Java Platform. 337 * <p>For binary compatibility reasons, .class files are tagged with a minimal required VM version.</p> 338 * <p>Note that <code>"1.4"</code> and higher target versions require the compliance mode to be at least as high 339 * as the target version. Usually, compliance, target, and source versions are set to the same values.</p> 340 * <p><code>"cldc1.1"</code> requires the source version to be <code>"1.3"</code> and the compliance version to be <code>"1.4"</code> or lower.</p> 341 * <dl> 342 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.codegen.targetPlatform"</code></dd> 343 * <dt>Possible values:</dt><dd><code>{ "1.1", "cldc1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "9", "10", "11" }</code></dd> 344 * <dt>Default:</dt><dd><code>"1.2"</code></dd> 345 * </dl> 346 * @category CompilerOptionID 347 * @see #COMPILER_COMPLIANCE 348 * @see #COMPILER_SOURCE 349 * @see #setComplianceOptions(String, Map) 350 */ 351 public static final String COMPILER_CODEGEN_TARGET_PLATFORM = PLUGIN_ID + ".compiler.codegen.targetPlatform"; //$NON-NLS-1$ 352 /** 353 * Compiler option ID: Inline JSR Bytecode Instruction. 354 * <p>When enabled, the compiler will no longer generate JSR instructions, but rather inline corresponding 355 * subroutine code sequences (mostly corresponding to try finally blocks). The generated code will thus 356 * get bigger, but will load faster on virtual machines since the verification process is then much simpler.</p> 357 * <p>This mode is anticipating support for the Java Specification Request 202.</p> 358 * <p>Note that JSR inlining is optional only for target platform lesser than 1.5. From 1.5 on, the JSR 359 * inlining is mandatory (also see related setting {@link #COMPILER_CODEGEN_TARGET_PLATFORM}).</p> 360 * <dl> 361 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode"</code></dd> 362 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 363 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 364 * </dl> 365 * @since 3.0 366 * @category CompilerOptionID 367 */ 368 public static final String COMPILER_CODEGEN_INLINE_JSR_BYTECODE = PLUGIN_ID + ".compiler.codegen.inlineJsrBytecode"; //$NON-NLS-1$ 369 /** 370 * Compiler option ID: Javadoc Comment Support. 371 * <p>When this support is disabled, the compiler will ignore all javadoc problems options settings 372 * and will not report any javadoc problem. It will also not find any reference in javadoc comment and 373 * DOM AST Javadoc node will be only a flat text instead of having structured tag elements.</p> 374 * <dl> 375 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.doc.comment.support"</code></dd> 376 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 377 * <dt>Default:</dt><dd><code>"enabled"</code></dd> 378 * </dl> 379 * @since 3.0 380 * @category CompilerOptionID 381 */ 382 public static final String COMPILER_DOC_COMMENT_SUPPORT = PLUGIN_ID + ".compiler.doc.comment.support"; //$NON-NLS-1$ 383 /** 384 * @deprecated Discontinued since turning off would violate language specs. 385 * @category DeprecatedOptionID 386 */ 387 public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID + ".compiler.problem.unreachableCode"; //$NON-NLS-1$ 388 /** 389 * @deprecated Discontinued since turning off would violate language specs. 390 * @category DeprecatedOptionID 391 */ 392 public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID + ".compiler.problem.invalidImport"; //$NON-NLS-1$ 393 /** 394 * Compiler option ID: Reporting Attempt to Override Package Visible Method. 395 * <p>A package visible method, which is any method that is not explicitly 396 * declared as public, protected or private, is not visible from other 397 * packages, and thus cannot be overridden from another package. 398 * Attempting to override a package visible method from another package 399 * introduces a new method that is unrelated to the original one. When 400 * enabling this option, the compiler will signal such situations as an 401 * error or a warning.</p> 402 * <dl> 403 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"</code></dd> 404 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 405 * <dt>Default:</dt><dd><code>"warning"</code></dd> 406 * </dl> 407 * @category CompilerOptionID 408 */ 409 public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID + ".compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$ 410 /** 411 * Compiler option ID: Reporting Method With Constructor Name. 412 * <p>Naming a method with a constructor name is generally considered poor 413 * style programming. When enabling this option, the compiler will signal such 414 * scenario either as an error or a warning.</p> 415 * <dl> 416 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"</code></dd> 417 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 418 * <dt>Default:</dt><dd><code>"warning"</code></dd> 419 * </dl> 420 * @category CompilerOptionID 421 */ 422 public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID + ".compiler.problem.methodWithConstructorName"; //$NON-NLS-1$ 423 /** 424 * Compiler option ID: Reporting Deprecation. 425 * <p>When enabled, the compiler will signal use of deprecated API either as an 426 * error or a warning.</p> 427 * <dl> 428 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.deprecation"</code></dd> 429 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 430 * <dt>Default:</dt><dd><code>"warning"</code></dd> 431 * </dl> 432 * @category CompilerOptionID 433 */ 434 public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID + ".compiler.problem.deprecation"; //$NON-NLS-1$ 435 /** 436 * Compiler option ID: Reporting Terminal Deprecation. 437 * <p>When enabled, the compiler will signal use of terminally deprecated API either as an 438 * error or a warning.</p> 439 * <dl> 440 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.terminalDeprecation"</code></dd> 441 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 442 * <dt>Default:</dt><dd><code>"warning"</code></dd> 443 * </dl> 444 * @since 3.14 445 * @category CompilerOptionID 446 */ 447 public static final String COMPILER_PB_TERMINAL_DEPRECATION = PLUGIN_ID + ".compiler.problem.terminalDeprecation"; //$NON-NLS-1$ 448 /** 449 * Compiler option ID: Reporting Deprecation Inside Deprecated Code. 450 * <p>When enabled, the compiler will signal use of deprecated API inside deprecated code.</p> 451 * <p>The severity of the problem is controlled with option {@link #COMPILER_PB_DEPRECATION}.</p> 452 * <dl> 453 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode"</code></dd> 454 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 455 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 456 * </dl> 457 * @since 2.1 458 * @category CompilerOptionID 459 */ 460 public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID + ".compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$ 461 /** 462 * Compiler option ID: Reporting Deprecation When Overriding Deprecated Method. 463 * <p>When enabled, the compiler will signal the declaration of a method overriding a deprecated one.</p> 464 * <p>The severity of the problem is controlled with option {@link #COMPILER_PB_DEPRECATION}.</p> 465 * <dl> 466 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod"</code></dd> 467 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 468 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 469 * </dl> 470 * @since 3.0 471 * @category CompilerOptionID 472 */ 473 public static final String COMPILER_PB_DEPRECATION_WHEN_OVERRIDING_DEPRECATED_METHOD = "org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod"; //$NON-NLS-1$ 474 /** 475 * Compiler option ID: Reporting Hidden Catch Block. 476 * <p>Locally to a try statement, some catch blocks may hide others. For example,</p> 477 * <pre> 478 * try { throw new java.io.CharConversionException(); 479 * } catch (java.io.CharConversionException e) { 480 * } catch (java.io.IOException e) {}. 481 * </pre> 482 * <p>When enabling this option, the compiler will issue an error or a warning for hidden 483 * catch blocks corresponding to checked exceptions.</p> 484 * <dl> 485 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"</code></dd> 486 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 487 * <dt>Default:</dt><dd><code>"warning"</code></dd> 488 * </dl> 489 * @category CompilerOptionID 490 */ 491 public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID + ".compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$ 492 /** 493 * Compiler option ID: Reporting Unused Local. 494 * <p>When enabled, the compiler will issue an error or a warning for unused local 495 * variables (that is, variables never read from).</p> 496 * <dl> 497 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unusedLocal"</code></dd> 498 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 499 * <dt>Default:</dt><dd><code>"warning"</code></dd> 500 * </dl> 501 * @category CompilerOptionID 502 */ 503 public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID + ".compiler.problem.unusedLocal"; //$NON-NLS-1$ 504 /** 505 * Compiler option ID: Reporting Unused Parameter. 506 * <p>When enabled, the compiler will issue an error or a warning for unused method 507 * parameters (that is, parameters never read from).</p> 508 * <dl> 509 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unusedParameter"</code></dd> 510 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 511 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 512 * </dl> 513 * @category CompilerOptionID 514 */ 515 public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID + ".compiler.problem.unusedParameter"; //$NON-NLS-1$ 516 /** 517 * Compiler option ID: Reporting Unused Exception Parameter. 518 * <p>When enabled, the compiler will issue an error or a warning for unused exception 519 * parameters (that is, the thrown exception is never read from).</p> 520 * <dl> 521 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter"</code></dd> 522 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 523 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 524 * </dl> 525 * @category CompilerOptionID 526 * @since 3.11 527 */ 528 public static final String COMPILER_PB_UNUSED_EXCEPTION_PARAMETER = PLUGIN_ID + ".compiler.problem.unusedExceptionParameter"; //$NON-NLS-1$ 529 /** 530 * Compiler option ID: Reporting Unused Parameter if Implementing Abstract Method. 531 * <p>When enabled, the compiler will signal unused parameters in abstract method implementations.</p> 532 * <p>The severity of the problem is controlled with option {@link #COMPILER_PB_UNUSED_PARAMETER}.</p> 533 * <dl> 534 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"</code></dd> 535 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 536 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 537 * </dl> 538 * @since 2.1 539 * @category CompilerOptionID 540 */ 541 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID + ".compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$ 542 /** 543 * Compiler option ID: Reporting Unused Parameter if Overriding Concrete Method. 544 * <p>When enabled, the compiler will signal unused parameters in methods overriding concrete ones.</p> 545 * <p>The severity of the problem is controlled with option {@link #COMPILER_PB_UNUSED_PARAMETER}.</p> 546 * <dl> 547 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"</code></dd> 548 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 549 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 550 * </dl> 551 * @since 2.1 552 * @category CompilerOptionID 553 */ 554 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID + ".compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$ 555 /** 556 * Compiler option ID: Consider Reference in Doc Comment for Unused Parameter Check. 557 * <p>When enabled, the compiler will consider doc comment references to parameters (i.e. <code>@param</code> clauses) for the unused 558 * parameter check. Thus, documented parameters will be considered as mandated as per doc contract.</p> 559 * <p>The severity of the unused parameter problem is controlled with option {@link #COMPILER_PB_UNUSED_PARAMETER}.</p> 560 * <p>Note: this option has no effect until the doc comment support is enabled according to the 561 * option {@link #COMPILER_DOC_COMMENT_SUPPORT}.</p> 562 * <dl> 563 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference"</code></dd> 564 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 565 * <dt>Default:</dt><dd><code>"enabled"</code></dd> 566 * </dl> 567 * @since 3.3 568 * @category CompilerOptionID 569 */ 570 public static final String COMPILER_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE = PLUGIN_ID + ".compiler.problem.unusedParameterIncludeDocCommentReference"; //$NON-NLS-1$ 571 /** 572 * Compiler option ID: Reporting Unused Import. 573 * <p>When enabled, the compiler will issue an error or a warning for unused import 574 * reference.</p> 575 * <dl> 576 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unusedImport"</code></dd> 577 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 578 * <dt>Default:</dt><dd><code>"warning"</code></dd> 579 * </dl> 580 * @since 2.0 581 * @category CompilerOptionID 582 */ 583 public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID + ".compiler.problem.unusedImport"; //$NON-NLS-1$ 584 /** 585 * Compiler option ID: Reporting Presence of Type Arguments for a Non-Generic Method Invocation. 586 * <p>When enabled, the compiler will issue an error or a warning whenever type arguments are encountered for a 587 * non-generic method invocation. Note that prior to compliance level is <code>"1.7"</code>, this situation would automatically result 588 * in an error. From Java7 on, unused type arguments are being tolerated, and optionally warned against.</p> 589 * <dl> 590 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unusedTypeArgumentsForMethodInvocation"</code></dd> 591 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 592 * <dt>Default:</dt><dd><code>"warning"</code></dd> 593 * </dl> 594 * @since 3.4 595 * @category CompilerOptionID 596 */ 597 public static final String COMPILER_PB_UNUSED_TYPE_ARGUMENTS_FOR_METHOD_INVOCATION = PLUGIN_ID + ".compiler.problem.unusedTypeArgumentsForMethodInvocation"; //$NON-NLS-1$ 598 /** 599 * Compiler option ID: Reporting Synthetic Access Emulation. 600 * <p>When enabled, the compiler will issue an error or a warning whenever it emulates 601 * access to a non-accessible member of an enclosing type. Such access can have 602 * performance implications.</p> 603 * <dl> 604 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"</code></dd> 605 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 606 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 607 * </dl> 608 * @category CompilerOptionID 609 */ 610 public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID + ".compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$ 611 612 /** 613 * Compiler option ID: Reporting Unused Type Parameter. 614 * <p>When enabled, the compiler will issue an error or a warning whenever it encounters an 615 * unused type parameter. </p> 616 * <dl> 617 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unusedTypeParameter"</code></dd> 618 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 619 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 620 * </dl> 621 * @since 3.9 622 * @category CompilerOptionID 623 */ 624 public static final String COMPILER_PB_UNUSED_TYPE_PARAMETER = PLUGIN_ID + ".compiler.problem.unusedTypeParameter"; //$NON-NLS-1$ 625 626 /** 627 * Compiler option ID: Reporting Non-Externalized String Literal. 628 * <p>When enabled, the compiler will issue an error or a warning for non externalized 629 * String literal (that is, not tagged with <code>//$NON-NLS-<n>$</code>).</p> 630 * <dl> 631 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"</code></dd> 632 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 633 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 634 * </dl> 635 * @since 2.0 636 * @category CompilerOptionID 637 */ 638 public static final String COMPILER_PB_NON_NLS_STRING_LITERAL = PLUGIN_ID + ".compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$ 639 /** 640 * Compiler option ID: Reporting Usage of <code>'assert'</code> Identifier. 641 * <p>When enabled, the compiler will issue an error or a warning whenever <code>'assert'</code> is 642 * used as an identifier (reserved keyword in 1.4).</p> 643 * <dl> 644 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.assertIdentifier"</code></dd> 645 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 646 * <dt>Default:</dt><dd><code>"warning"</code></dd> 647 * </dl> 648 * @since 2.0 649 * @category CompilerOptionID 650 */ 651 public static final String COMPILER_PB_ASSERT_IDENTIFIER = PLUGIN_ID + ".compiler.problem.assertIdentifier"; //$NON-NLS-1$ 652 /** 653 * Compiler option ID: Reporting Usage of <code>'enum'</code> Identifier. 654 * <p>When enabled, the compiler will issue an error or a warning whenever <code>'enum'</code> is 655 * used as an identifier (reserved keyword in 1.5).</p> 656 * <dl> 657 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.enumIdentifier"</code></dd> 658 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 659 * <dt>Default:</dt><dd><code>"warning"</code></dd> 660 * </dl> 661 * @since 3.1 662 * @category CompilerOptionID 663 */ 664 public static final String COMPILER_PB_ENUM_IDENTIFIER = PLUGIN_ID + ".compiler.problem.enumIdentifier"; //$NON-NLS-1$ 665 /** 666 * Compiler option ID: Reporting Non-Static Reference to a Static Member. 667 * <p>When enabled, the compiler will issue an error or a warning whenever a static field 668 * or method is accessed with an expression receiver. A reference to a static member should 669 * be qualified with a type name.</p> 670 * <dl> 671 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.staticAccessReceiver"</code></dd> 672 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 673 * <dt>Default:</dt><dd><code>"warning"</code></dd> 674 * </dl> 675 * @since 2.1 676 * @category CompilerOptionID 677 */ 678 public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID + ".compiler.problem.staticAccessReceiver"; //$NON-NLS-1$ 679 /** 680 * Compiler option ID: Reporting Indirect Reference to a Static Member. 681 * <p>When enabled, the compiler will issue an error or a warning whenever a static field 682 * or method is accessed in an indirect way. A reference to a static member should 683 * preferably be qualified with its declaring type name.</p> 684 * <dl> 685 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.indirectStaticAccess"</code></dd> 686 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 687 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 688 * </dl> 689 * @since 3.0 690 * @category CompilerOptionID 691 */ 692 public static final String COMPILER_PB_INDIRECT_STATIC_ACCESS = PLUGIN_ID + ".compiler.problem.indirectStaticAccess"; //$NON-NLS-1$ 693 /** 694 * Compiler option ID: Reporting Assignment with no Effect. 695 * <p>When enabled, the compiler will issue an error or a warning whenever an assignment 696 * has no effect (e.g <code>'x = x'</code>).</p> 697 * <dl> 698 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.noEffectAssignment"</code></dd> 699 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 700 * <dt>Default:</dt><dd><code>"warning"</code></dd> 701 * </dl> 702 * @since 2.1 703 * @category CompilerOptionID 704 */ 705 public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID + ".compiler.problem.noEffectAssignment"; //$NON-NLS-1$ 706 /** 707 * Compiler option ID: Reporting Interface Method not Compatible with non-Inherited Methods. 708 * <p>When enabled, the compiler will issue an error or a warning whenever an interface 709 * defines a method incompatible with a non-inherited <code>Object</code> method. Until this conflict 710 * is resolved, such an interface cannot be implemented. For example,</p> 711 * <pre> 712 * interface I { 713 * int clone(); 714 * } 715 * </pre> 716 * <dl> 717 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"</code></dd> 718 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 719 * <dt>Default:</dt><dd><code>"warning"</code></dd> 720 * </dl> 721 * @since 2.1 722 * @category CompilerOptionID 723 */ 724 public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$ 725 /** 726 * Compiler option ID: Reporting Unused Private Members. 727 * <p>When enabled, the compiler will issue an error or a warning whenever a private 728 * method or field is declared but never used within the same unit.</p> 729 * <dl> 730 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"</code></dd> 731 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 732 * <dt>Default:</dt><dd><code>"warning"</code></dd> 733 * </dl> 734 * @since 2.1 735 * @category CompilerOptionID 736 */ 737 public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$ 738 /** 739 * Compiler option ID: Reporting Local Variable Declaration Hiding another Variable. 740 * <p>When enabled, the compiler will issue an error or a warning whenever a local variable 741 * declaration is hiding some field or local variable (either locally, inherited or defined in enclosing type).</p> 742 * <dl> 743 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.localVariableHiding"</code></dd> 744 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 745 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 746 * </dl> 747 * @since 3.0 748 * @category CompilerOptionID 749 */ 750 public static final String COMPILER_PB_LOCAL_VARIABLE_HIDING = PLUGIN_ID + ".compiler.problem.localVariableHiding"; //$NON-NLS-1$ 751 /** 752 * Compiler option ID: Reporting Special Parameter Hiding another Field. 753 * <p>When enabled, the compiler will signal cases where a constructor or setter method parameter declaration 754 * is hiding some field (either locally, inherited or defined in enclosing type).</p> 755 * <p>The severity of the problem is controlled with option {@link #COMPILER_PB_LOCAL_VARIABLE_HIDING}.</p> 756 * <dl> 757 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.specialParameterHidingField"</code></dd> 758 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 759 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 760 * </dl> 761 * @since 3.0 762 * @category CompilerOptionID 763 */ 764 public static final String COMPILER_PB_SPECIAL_PARAMETER_HIDING_FIELD = PLUGIN_ID + ".compiler.problem.specialParameterHidingField"; //$NON-NLS-1$ 765 /** 766 * Compiler option ID: Reporting Field Declaration Hiding another Variable. 767 * <p>When enabled, the compiler will issue an error or a warning whenever a field 768 * declaration is hiding some field or local variable (either locally, inherited or defined in enclosing type).</p> 769 * <dl> 770 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.fieldHiding"</code></dd> 771 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 772 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 773 * </dl> 774 * @since 3.0 775 * @category CompilerOptionID 776 */ 777 public static final String COMPILER_PB_FIELD_HIDING = PLUGIN_ID + ".compiler.problem.fieldHiding"; //$NON-NLS-1$ 778 /** 779 * Compiler option ID: Reporting Type Declaration Hiding another Type. 780 * <p>When enabled, the compiler will issue an error or a warning in situations where a type parameter 781 * declaration is hiding some type, when a nested type is hiding some type parameter, or when 782 * a nested type is hiding another nested type defined in same unit.</p> 783 * <dl> 784 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.typeParameterHiding"</code></dd> 785 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 786 * <dt>Default:</dt><dd><code>"warning"</code></dd> 787 * </dl> 788 * @since 3.1 789 * @category CompilerOptionID 790 */ 791 public static final String COMPILER_PB_TYPE_PARAMETER_HIDING = PLUGIN_ID + ".compiler.problem.typeParameterHiding"; //$NON-NLS-1$ 792 /** 793 * Compiler option ID: Reporting Possible Accidental Boolean Assignment. 794 * <p>When enabled, the compiler will issue an error or a warning if a boolean assignment is acting as the condition 795 * of a control statement (where it probably was meant to be a boolean comparison).</p> 796 * <dl> 797 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment"</code></dd> 798 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 799 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 800 * </dl> 801 * @since 3.0 802 * @category CompilerOptionID 803 */ 804 public static final String COMPILER_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT = PLUGIN_ID + ".compiler.problem.possibleAccidentalBooleanAssignment"; //$NON-NLS-1$ 805 /** 806 * Compiler option ID: Reporting Switch Fall-Through Case. 807 * <p>When enabled, the compiler will issue an error or a warning if a case may be 808 * entered by falling through previous case. Empty cases are allowed.</p> 809 * <dl> 810 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.fallthroughCase"</code></dd> 811 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 812 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 813 * </dl> 814 * @since 3.2 815 * @category CompilerOptionID 816 */ 817 public static final String COMPILER_PB_FALLTHROUGH_CASE = PLUGIN_ID + ".compiler.problem.fallthroughCase"; //$NON-NLS-1$ 818 /** 819 * Compiler option ID: Reporting Empty Statements and Unnecessary Semicolons. 820 * <p>When enabled, the compiler will issue an error or a warning if an empty statement or a 821 * unnecessary semicolon is encountered.</p> 822 * <dl> 823 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.emptyStatement"</code></dd> 824 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 825 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 826 * </dl> 827 * @since 3.0 828 * @category CompilerOptionID 829 */ 830 public static final String COMPILER_PB_EMPTY_STATEMENT = PLUGIN_ID + ".compiler.problem.emptyStatement"; //$NON-NLS-1$ 831 /** 832 * Compiler option ID. 833 * <dl> 834 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.booleanMethodThrowingException"</code></dd> 835 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 836 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 837 * </dl> 838 * @since 3.0 839 * @category CompilerOptionID 840 * @deprecated - this option has no effect 841 */ 842 public static final String COMPILER_PB_BOOLEAN_METHOD_THROWING_EXCEPTION = PLUGIN_ID + ".compiler.problem.booleanMethodThrowingException"; //$NON-NLS-1$ 843 /** 844 * Compiler option ID: Reporting Unnecessary Type Check. 845 * <p>When enabled, the compiler will issue an error or a warning when a cast or an <code>instanceof</code> operation 846 * is unnecessary.</p> 847 * <dl> 848 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck"</code></dd> 849 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 850 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 851 * </dl> 852 * @since 3.0 853 * @category CompilerOptionID 854 */ 855 public static final String COMPILER_PB_UNNECESSARY_TYPE_CHECK = PLUGIN_ID + ".compiler.problem.unnecessaryTypeCheck"; //$NON-NLS-1$ 856 /** 857 * Compiler option ID: Reporting Unnecessary Else. 858 * <p>When enabled, the compiler will issue an error or a warning when a statement is unnecessarily 859 * nested within an <code>else</code> clause (in situation where then clause is not completing normally).</p> 860 * <dl> 861 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unnecessaryElse"</code></dd> 862 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 863 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 864 * </dl> 865 * @since 3.0 866 * @category CompilerOptionID 867 */ 868 public static final String COMPILER_PB_UNNECESSARY_ELSE = PLUGIN_ID + ".compiler.problem.unnecessaryElse"; //$NON-NLS-1$ 869 /** 870 * Compiler option ID: Reporting Undocumented Empty Block. 871 * <p>When enabled, the compiler will issue an error or a warning when an empty block is detected and it is not 872 * documented with any comment.</p> 873 * <dl> 874 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock"</code></dd> 875 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 876 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 877 * </dl> 878 * @since 3.0 879 * @category CompilerOptionID 880 */ 881 public static final String COMPILER_PB_UNDOCUMENTED_EMPTY_BLOCK = PLUGIN_ID + ".compiler.problem.undocumentedEmptyBlock"; //$NON-NLS-1$ 882 /** 883 * Compiler option ID: Reporting Finally Blocks Not Completing Normally. 884 * <p>When enabled, the compiler will issue an error or a warning when a finally block does not complete normally.</p> 885 * <dl> 886 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally"</code></dd> 887 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 888 * <dt>Default:</dt><dd><code>"warning"</code></dd> 889 * </dl> 890 * @since 3.0 891 * @category CompilerOptionID 892 */ 893 public static final String COMPILER_PB_FINALLY_BLOCK_NOT_COMPLETING = PLUGIN_ID + ".compiler.problem.finallyBlockNotCompletingNormally"; //$NON-NLS-1$ 894 /** 895 * Compiler option ID: Reporting Unused Declared Thrown Exception. 896 * <p>When enabled, the compiler will issue an error or a warning when a 897 * method or a constructor is declaring a checked exception as thrown, 898 * but its body actually raises neither that exception, nor any other 899 * exception extending it.</p> 900 * <p>This diagnostic is further tuned by options 901 * {@link #COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_INCLUDE_DOC_COMMENT_REFERENCE}, 902 * {@link #COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_EXEMPT_EXCEPTION_AND_THROWABLE}, 903 * and {@link #COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING}.</p> 904 * <dl> 905 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException"</code></dd> 906 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 907 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 908 * </dl> 909 * @since 3.0 910 * @category CompilerOptionID 911 */ 912 public static final String COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION = PLUGIN_ID + ".compiler.problem.unusedDeclaredThrownException"; //$NON-NLS-1$ 913 /** 914 * Compiler option ID: Reporting Unused Declared Thrown Exception in Overriding Method. 915 * <p>When disabled, the compiler will report unused declared thrown 916 * exceptions neither on overriding methods nor on implementing methods.</p> 917 * <p>The severity of the unused declared thrown exception problem is 918 * controlled with option {@link #COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION}.</p> 919 * <p>This diagnostic is further tuned by options 920 * {@link #COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_INCLUDE_DOC_COMMENT_REFERENCE} and 921 * {@link #COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_EXEMPT_EXCEPTION_AND_THROWABLE}.</p> 922 * <dl> 923 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding"</code></dd> 924 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 925 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 926 * </dl> 927 * @since 3.0 928 * @category CompilerOptionID 929 */ 930 public static final String COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING = PLUGIN_ID + ".compiler.problem.unusedDeclaredThrownExceptionWhenOverriding"; //$NON-NLS-1$ 931 /** 932 * Compiler option ID: Consider Reference in Doc Comment for Unused Declared Thrown Exception Check. 933 * <p>When enabled, the compiler will consider doc comment references to 934 * exceptions (i.e. <code>@throws</code> clauses) for the unused 935 * declared thrown exception check. Thus, documented exceptions will be 936 * considered as mandated as per doc contract.</p> 937 * <p>The severity of the unused declared thrown exception problem is controlled with option {@link #COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION}.</p> 938 * <p>Note: this option has no effect until the doc comment support is enabled according to the 939 * option {@link #COMPILER_DOC_COMMENT_SUPPORT}.</p> 940 * <p>This diagnostic is further tuned by options 941 * {@link #COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_EXEMPT_EXCEPTION_AND_THROWABLE} 942 * and {@link #COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING}.</p> 943 * <dl> 944 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference"</code></dd> 945 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 946 * <dt>Default:</dt><dd><code>"enabled"</code></dd> 947 * </dl> 948 * @since 3.4 949 * @category CompilerOptionID 950 */ 951 public static final String COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_INCLUDE_DOC_COMMENT_REFERENCE = PLUGIN_ID + ".compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference"; //$NON-NLS-1$ 952 /** 953 * Compiler option ID: Reporting Unused Declared Thrown Exception Exempts Exception And Throwable. 954 * <p>When enabled, the compiler will issue an error or a warning when a 955 * method or a constructor is declaring a checked exception else than 956 * {@link java.lang.Throwable} or {@link java.lang.Exception} as thrown, 957 * but its body actually raises neither that exception, nor any other 958 * exception extending it. When disabled, the compiler will issue an 959 * error or a warning when a method or a constructor is declaring a 960 * checked exception (including {@link java.lang.Throwable} and 961 * {@link java.lang.Exception}) as thrown, but its body actually raises 962 * neither that exception, nor any other exception extending it.</p> 963 * <p>The severity of the unused declared thrown exception problem is 964 * controlled with option 965 * {@link #COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION}.</p> 966 * <p>This diagnostic is further tuned by options 967 * {@link #COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_INCLUDE_DOC_COMMENT_REFERENCE} 968 * and {@link #COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING}.</p> 969 * <dl> 970 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable"</code></dd> 971 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 972 * <dt>Default:</dt><dd><code>"enabled"</code></dd> 973 * </dl> 974 * @since 3.4 975 * @category CompilerOptionID 976 */ 977 public static final String COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_EXEMPT_EXCEPTION_AND_THROWABLE = PLUGIN_ID + ".compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable"; //$NON-NLS-1$ 978 /** 979 * Compiler option ID: Reporting Unqualified Access to Field. 980 * <p>When enabled, the compiler will issue an error or a warning when a field is access without any qualification. 981 * In order to improve code readability, it should be qualified, e.g. <code>'x'</code> should rather be written <code>'this.x'</code>.</p> 982 * <dl> 983 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess"</code></dd> 984 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 985 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 986 * </dl> 987 * @since 3.0 988 * @category CompilerOptionID 989 */ 990 public static final String COMPILER_PB_UNQUALIFIED_FIELD_ACCESS = PLUGIN_ID + ".compiler.problem.unqualifiedFieldAccess"; //$NON-NLS-1$ 991 /** 992 * @deprecated Use {@link #COMPILER_PB_UNCHECKED_TYPE_OPERATION} instead. 993 * @since 3.1 994 * @category DeprecatedOptionID 995 */ 996 public static final String COMPILER_PB_UNSAFE_TYPE_OPERATION = PLUGIN_ID + ".compiler.problem.uncheckedTypeOperation"; //$NON-NLS-1$ 997 /** 998 * Compiler option ID: Reporting Unchecked Type Operation. 999 * <p>When enabled, the compiler will issue an error or a warning whenever an operation involves generic types, and potentially 1000 * invalidates type safety since involving raw types (e.g. invoking <code>#foo(X<String>)</code> with arguments <code>(X)</code>).</p> 1001 * <dl> 1002 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation"</code></dd> 1003 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1004 * <dt>Default:</dt><dd><code>"warning"</code></dd> 1005 * </dl> 1006 * @since 3.1 1007 * @category CompilerOptionID 1008 */ 1009 public static final String COMPILER_PB_UNCHECKED_TYPE_OPERATION = PLUGIN_ID + ".compiler.problem.uncheckedTypeOperation"; //$NON-NLS-1$ 1010 /** 1011 * Compiler option ID: Reporting Raw Type Reference. 1012 * <p>When enabled, the compiler will issue an error or a warning when detecting references to raw types. Raw types are 1013 * discouraged, and are intended to help interfacing with legacy code. In the future, the language specification may 1014 * reject raw references to generic types.</p> 1015 * <dl> 1016 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.rawTypeReference"</code></dd> 1017 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1018 * <dt>Default:</dt><dd><code>"warning"</code></dd> 1019 * </dl> 1020 * @since 3.2 1021 * @category CompilerOptionID 1022 */ 1023 public static final String COMPILER_PB_RAW_TYPE_REFERENCE = PLUGIN_ID + ".compiler.problem.rawTypeReference"; //$NON-NLS-1$ 1024 /** 1025 * Compiler option ID: Reporting of Unavoidable Generic Type Problems due to raw APIs. 1026 * <p> When enabled, the compiler will issue an error or warning even when it detects a generics-related type problem 1027 * that could not have been avoided by the programmer, because a referenced API already contains raw types. 1028 * As an example, a type may be forced to use raw types 1029 * in its method signatures and return types because the methods it overrides from a super type are declared to 1030 * use raw types in the first place.</p> 1031 * <dl> 1032 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems"</code></dd> 1033 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 1034 * <dt>Default:</dt><dd><code>"enabled"</code></dd> 1035 * </dl> 1036 * @since 3.7 1037 * @category CompilerOptionID 1038 */ 1039 public static final String COMPILER_PB_UNAVOIDABLE_GENERIC_TYPE_PROBLEMS = PLUGIN_ID + ".compiler.problem.unavoidableGenericTypeProblems"; //$NON-NLS-1$ 1040 1041 /** 1042 * Compiler option ID: Reporting final Bound for Type Parameter. 1043 * <p>When enabled, the compiler will issue an error or a warning whenever a generic type parameter is associated with a 1044 * bound corresponding to a final type; since final types cannot be further extended, the parameter is pretty useless.</p> 1045 * <dl> 1046 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.finalParameterBound"</code></dd> 1047 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1048 * <dt>Default:</dt><dd><code>"warning"</code></dd> 1049 * </dl> 1050 * @since 3.1 1051 * @category CompilerOptionID 1052 */ 1053 public static final String COMPILER_PB_FINAL_PARAMETER_BOUND = PLUGIN_ID + ".compiler.problem.finalParameterBound"; //$NON-NLS-1$ 1054 /** 1055 * Compiler option ID: Reporting Missing Declaration of serialVersionUID Field on Serializable Class. 1056 * <p>When enabled, the compiler will issue an error or a warning whenever a serializable class is missing a local declaration 1057 * of a <code>serialVersionUID</code> field. This field must be declared as static final and be of type <code>long</code>.</p> 1058 * <dl> 1059 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingSerialVersion"</code></dd> 1060 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1061 * <dt>Default:</dt><dd><code>"warning"</code></dd> 1062 * </dl> 1063 * @since 3.1 1064 * @category CompilerOptionID 1065 */ 1066 public static final String COMPILER_PB_MISSING_SERIAL_VERSION = PLUGIN_ID + ".compiler.problem.missingSerialVersion"; //$NON-NLS-1$ 1067 /** 1068 * Compiler option ID: Reporting Varargs Argument Needing a Cast in Method/Constructor Invocation. 1069 * <p>When enabled, the compiler will issue an error or a warning whenever a varargs arguments should be cast 1070 * when passed to a method/constructor invocation. (e.g. <code>Class.getMethod(String name, Class ... args )</code> 1071 * invoked with arguments <code>("foo", null)</code>).</p> 1072 * <dl> 1073 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast"</code></dd> 1074 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1075 * <dt>Default:</dt><dd><code>"warning"</code></dd> 1076 * </dl> 1077 * @since 3.1 1078 * @category CompilerOptionID 1079 */ 1080 public static final String COMPILER_PB_VARARGS_ARGUMENT_NEED_CAST = PLUGIN_ID + ".compiler.problem.varargsArgumentNeedCast"; //$NON-NLS-1$ 1081 /** 1082 * Compiler option ID: Reporting Boxing/Unboxing Conversion. 1083 * <p>When enabled, the compiler will issue an error or a warning whenever a boxing or an unboxing 1084 * conversion is performed.</p> 1085 * <dl> 1086 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.autoboxing"</code></dd> 1087 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1088 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 1089 * </dl> 1090 * @since 3.1 1091 * @category CompilerOptionID 1092 */ 1093 public static final String COMPILER_PB_AUTOBOXING = PLUGIN_ID + ".compiler.problem.autoboxing"; //$NON-NLS-1$ 1094 /** 1095 * Compiler option ID: Reporting Use of Annotation Type as Super Interface. 1096 * <p>When enabled, the compiler will issue an error or a warning whenever an annotation type is used 1097 * as a super-interface. Though legal, this is discouraged.</p> 1098 * <dl> 1099 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.annotationSuperInterface"</code></dd> 1100 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1101 * <dt>Default:</dt><dd><code>"warning"</code></dd> 1102 * </dl> 1103 * @since 3.1 1104 * @category CompilerOptionID 1105 */ 1106 public static final String COMPILER_PB_ANNOTATION_SUPER_INTERFACE = PLUGIN_ID + ".compiler.problem.annotationSuperInterface"; //$NON-NLS-1$ 1107 /** 1108 * Compiler option ID: Reporting Missing <code>@Override</code> Annotation. 1109 * <p>When enabled, the compiler will issue an error or a warning whenever encountering a method 1110 * declaration which overrides a superclass method but has no <code>@Override</code> annotation.</p> 1111 * <dl> 1112 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation"</code></dd> 1113 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1114 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 1115 * </dl> 1116 * @since 3.1 1117 * @category CompilerOptionID 1118 */ 1119 public static final String COMPILER_PB_MISSING_OVERRIDE_ANNOTATION = PLUGIN_ID + ".compiler.problem.missingOverrideAnnotation"; //$NON-NLS-1$ 1120 /** 1121 * Compiler option ID: Reporting Missing <code>@Override</code> Annotation for interface method implementation. 1122 * <p>When enabled, the compiler will issue an error or a warning whenever encountering a method 1123 * declaration which overrides or implements a superinterface method but has no <code>@Override</code> annotation.</p> 1124 * <p>This option only has an effect if the compiler compliance is 1.6 or greater.</p> 1125 * <p>The severity of the problem is controlled with option {@link #COMPILER_PB_MISSING_OVERRIDE_ANNOTATION}.</p> 1126 * <dl> 1127 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation"</code></dd> 1128 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 1129 * <dt>Default:</dt><dd><code>"enabled"</code></dd> 1130 * </dl> 1131 * @since 3.6 1132 * @category CompilerOptionID 1133 */ 1134 public static final String COMPILER_PB_MISSING_OVERRIDE_ANNOTATION_FOR_INTERFACE_METHOD_IMPLEMENTATION = PLUGIN_ID + ".compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation"; //$NON-NLS-1$ 1135 /** 1136 * Compiler option ID: Reporting Missing <code>@Deprecated</code> Annotation. 1137 * <p>When enabled, the compiler will issue an error or a warning whenever encountering a declaration 1138 * carrying a <code>@deprecated</code> doc tag but having no corresponding <code>@Deprecated</code> annotation.</p> 1139 * <dl> 1140 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation"</code></dd> 1141 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1142 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 1143 * </dl> 1144 * @since 3.1 1145 * @category CompilerOptionID 1146 */ 1147 public static final String COMPILER_PB_MISSING_DEPRECATED_ANNOTATION = PLUGIN_ID + ".compiler.problem.missingDeprecatedAnnotation"; //$NON-NLS-1$ 1148 /** 1149 * Compiler option ID: Reporting Missing HashCode Method. 1150 * <p>When enabled, the compiler will issue an error or a warning if a type 1151 * overrides Object.equals(Object) but does not override hashCode().</p> 1152 * <dl> 1153 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod"</code></dd> 1154 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1155 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 1156 * </dl> 1157 * @since 3.5 1158 * @category CompilerOptionID 1159 */ 1160 public static final String COMPILER_PB_MISSING_HASHCODE_METHOD = PLUGIN_ID + ".compiler.problem.missingHashCodeMethod"; //$NON-NLS-1$ 1161 /** 1162 * Compiler option ID: Reporting Dead Code. 1163 * <p>When enabled, the compiler will issue an error or a warning if some non fatal dead code is detected. For instance, <code>if (false) foo();</code> 1164 * is not reported as truly unreachable code by the Java Language Specification. If this diagnostic is enabled, then the invocation of <code>foo()</code> is 1165 * going to be signaled as being dead code.</p> 1166 * <dl> 1167 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.deadCode"</code></dd> 1168 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1169 * <dt>Default:</dt><dd><code>"warning"</code></dd> 1170 * </dl> 1171 * @since 3.5 1172 * @category CompilerOptionID 1173 */ 1174 public static final String COMPILER_PB_DEAD_CODE = PLUGIN_ID + ".compiler.problem.deadCode"; //$NON-NLS-1$ 1175 /** 1176 * Compiler option ID: Reporting Dead Code Inside Trivial If Statement. 1177 * <p>When enabled, the compiler will signal presence of dead code inside trivial IF statement, e.g. <code>if (DEBUG)...</code>.</p> 1178 * <p>The severity of the problem is controlled with option {@link #COMPILER_PB_DEAD_CODE}.</p> 1179 * <dl> 1180 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.deadCodeInTrivialIfStatement"</code></dd> 1181 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 1182 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 1183 * </dl> 1184 * @since 3.5 1185 * @category CompilerOptionID 1186 */ 1187 public static final String COMPILER_PB_DEAD_CODE_IN_TRIVIAL_IF_STATEMENT = PLUGIN_ID + ".compiler.problem.deadCodeInTrivialIfStatement"; //$NON-NLS-1$ 1188 /** 1189 * Compiler option ID: Reporting Incomplete Enum Switch. 1190 * <p>When enabled, the compiler will issue an error or a warning 1191 * regarding each enum constant for which a corresponding case label is lacking. 1192 * Reporting is further controlled by the option {@link #COMPILER_PB_MISSING_ENUM_CASE_DESPITE_DEFAULT}.</p> 1193 * <dl> 1194 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch"</code></dd> 1195 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1196 * <dt>Default:</dt><dd><code>"warning"</code></dd> 1197 * </dl> 1198 * @since 3.1 1199 * @category CompilerOptionID 1200 */ 1201 public static final String COMPILER_PB_INCOMPLETE_ENUM_SWITCH = PLUGIN_ID + ".compiler.problem.incompleteEnumSwitch"; //$NON-NLS-1$ 1202 /** 1203 * Compiler option ID: Reporting Missing Enum Case In Switch Despite An Existing Default Case. 1204 * <p>This option further controls the option {@link #COMPILER_PB_INCOMPLETE_ENUM_SWITCH}:</p> 1205 * <ul> 1206 * <li>If enabled the compiler will report problems about missing enum constants even if a default case exists 1207 * in the same switch statement.</li> 1208 * <li>If disabled existence of a default case is considered as sufficient to make a switch statement complete.</li> 1209 * </ul> 1210 * This option has no effect if {@link #COMPILER_PB_INCOMPLETE_ENUM_SWITCH} is set to <code>"ignore"</code>. 1211 * <dl> 1212 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault"</code></dd> 1213 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 1214 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 1215 * </dl> 1216 * @since 3.8 1217 * @category CompilerOptionID 1218 */ 1219 public static final String COMPILER_PB_MISSING_ENUM_CASE_DESPITE_DEFAULT = PLUGIN_ID + ".compiler.problem.missingEnumCaseDespiteDefault"; //$NON-NLS-1$ 1220 /** 1221 * Compiler option ID: Reporting Missing Default Case In Switch. 1222 * <p>When enabled, the compiler will issue an error or a warning 1223 * against each switch statement that lacks a default case.</p> 1224 * <dl> 1225 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingDefaultCase"</code></dd> 1226 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1227 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 1228 * </dl> 1229 * @since 3.8 1230 * @category CompilerOptionID 1231 */ 1232 public static final String COMPILER_PB_SWITCH_MISSING_DEFAULT_CASE = PLUGIN_ID + ".compiler.problem.missingDefaultCase"; //$NON-NLS-1$ 1233 /** 1234 * @since 3.1 1235 * @deprecated Use {@link #COMPILER_PB_NULL_REFERENCE} instead. 1236 * @category DeprecatedOptionID 1237 */ 1238 public static final String COMPILER_PB_INCONSISTENT_NULL_CHECK = PLUGIN_ID + ".compiler.problem.inconsistentNullCheck"; //$NON-NLS-1$ 1239 /** 1240 * Compiler option ID: Reporting Unreferenced Label. 1241 * <p>When enabled, the compiler will issue an error or a warning when encountering a labeled statement which label 1242 * is never explicitly referenced. A label is considered to be referenced if its name explicitly appears behind a break 1243 * or continue statement; for instance the following label would be considered unreferenced:</p> 1244 * <code>LABEL: { break; }</code> 1245 * <dl> 1246 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unusedLabel"</code></dd> 1247 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1248 * <dt>Default:</dt><dd><code>"warning"</code></dd> 1249 * </dl> 1250 * @since 3.2 1251 * @category CompilerOptionID 1252 */ 1253 public static final String COMPILER_PB_UNUSED_LABEL = PLUGIN_ID + ".compiler.problem.unusedLabel"; //$NON-NLS-1$ 1254 /** 1255 * Compiler option ID: Reporting Invalid Javadoc Comment. 1256 * <p>This is the generic control for the severity of Javadoc problems. 1257 * When enabled, the compiler will issue an error or a warning for a problem in Javadoc.</p> 1258 * <dl> 1259 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.invalidJavadoc"</code></dd> 1260 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1261 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 1262 * </dl> 1263 * @since 3.0 1264 * @category CompilerOptionID 1265 */ 1266 public static final String COMPILER_PB_INVALID_JAVADOC = PLUGIN_ID + ".compiler.problem.invalidJavadoc"; //$NON-NLS-1$ 1267 /** 1268 * Compiler option ID: Reporting Invalid Javadoc Tags. 1269 * <p>When enabled, the compiler will signal unbound or unexpected reference tags in Javadoc. 1270 * A <code>@throws</code> tag referencing an undeclared exception would be considered as unexpected.</p> 1271 * <p>Note that this diagnosis can be enabled based on the visibility of the construct associated with the Javadoc; 1272 * also see the setting {@link #COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY}.</p> 1273 * <dl> 1274 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.invalidJavadocTags"</code></dd> 1275 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 1276 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 1277 * </dl> 1278 * @since 3.0 1279 * @category CompilerOptionID 1280 */ 1281 public static final String COMPILER_PB_INVALID_JAVADOC_TAGS = PLUGIN_ID + ".compiler.problem.invalidJavadocTags"; //$NON-NLS-1$ 1282 /** 1283 * Compiler option ID: Reporting Invalid Javadoc Tags with Deprecated References. 1284 * <p>Specify whether the compiler will report deprecated references used in Javadoc tags.</p> 1285 * <p>Note that this diagnosis can be enabled based on the visibility of the construct associated with the Javadoc; 1286 * also see the setting {@link #COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY}.</p> 1287 * <dl> 1288 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef"</code></dd> 1289 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 1290 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 1291 * </dl> 1292 * @since 3.1 1293 * @category CompilerOptionID 1294 */ 1295 public static final String COMPILER_PB_INVALID_JAVADOC_TAGS__DEPRECATED_REF = PLUGIN_ID + ".compiler.problem.invalidJavadocTagsDeprecatedRef"; //$NON-NLS-1$ 1296 /** 1297 * Compiler option ID: Reporting Invalid Javadoc Tags with Not Visible References. 1298 * <p>Specify whether the compiler will report non-visible references used in Javadoc tags.</p> 1299 * <p>Note that this diagnosis can be enabled based on the visibility of the construct associated with the Javadoc; 1300 * also see the setting {@link #COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY}.</p> 1301 * <dl> 1302 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef"</code></dd> 1303 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 1304 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 1305 * </dl> 1306 * @since 3.1 1307 * @category CompilerOptionID 1308 */ 1309 public static final String COMPILER_PB_INVALID_JAVADOC_TAGS__NOT_VISIBLE_REF = PLUGIN_ID + ".compiler.problem.invalidJavadocTagsNotVisibleRef"; //$NON-NLS-1$ 1310 /** 1311 * Compiler option ID: Visibility Level For Invalid Javadoc Tags. 1312 * <p>Set the minimum visibility level for Javadoc tag problems. Below this level problems will be ignored.</p> 1313 * <dl> 1314 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility"</code></dd> 1315 * <dt>Possible values:</dt><dd><code>{ "public", "protected", "default", "private" }</code></dd> 1316 * <dt>Default:</dt><dd><code>"public"</code></dd> 1317 * </dl> 1318 * @since 3.0 1319 * @category CompilerOptionID 1320 */ 1321 public static final String COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY = PLUGIN_ID + ".compiler.problem.invalidJavadocTagsVisibility"; //$NON-NLS-1$ 1322 /** 1323 * Compiler option ID: Reporting missing tag description. 1324 * <p>When enabled, the compiler will report a warning or an error for any Javadoc tag missing a required description.</p> 1325 * <p>The severity of the problem is controlled with option {@link #COMPILER_PB_INVALID_JAVADOC}.</p> 1326 * <p>It does not depend on option {@link #COMPILER_PB_INVALID_JAVADOC_TAGS}.</p> 1327 * <p>When this option is valued to {@link #COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_ALL_STANDARD_TAGS}, 1328 * a subset of the standard <a href="http://download.oracle.com/javase/6/docs/technotes/tools/windows/javadoc.html#javadoctags">Javadoc tags</a> 1329 * that have a description, text or label are checked. While this set may grow in the future, note that user-defined tags are not and will not be checked.</p> 1330 * <dl> 1331 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription"</code></dd> 1332 * <dt>Possible values:</dt><dd><code>{ "return_tag", "all_standard_tags", "no_tag" }</code></dd> 1333 * <dt>Default:</dt><dd><code>"return_tag"</code></dd> 1334 * </dl> 1335 * @since 3.4 1336 * @category CompilerOptionID 1337 */ 1338 public static final String COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION = PLUGIN_ID + ".compiler.problem.missingJavadocTagDescription"; //$NON-NLS-1$ 1339 /** 1340 * Compiler option ID: Reporting Missing Javadoc Tags. 1341 * <p>This is the generic control for the severity of Javadoc missing tag problems. 1342 * When enabled, the compiler will issue an error or a warning when tags are missing in Javadoc comments.</p> 1343 * <p>Note that this diagnosis can be enabled based on the visibility of the construct associated with the Javadoc; 1344 * also see the setting {@link #COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY}.</p> 1345 * <dl> 1346 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingJavadocTags"</code></dd> 1347 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1348 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 1349 * </dl> 1350 * @since 3.0 1351 * @category CompilerOptionID 1352 */ 1353 public static final String COMPILER_PB_MISSING_JAVADOC_TAGS = PLUGIN_ID + ".compiler.problem.missingJavadocTags"; //$NON-NLS-1$ 1354 /** 1355 * Compiler option ID: Visibility Level For Missing Javadoc Tags. 1356 * <p>Set the minimum visibility level for Javadoc missing tag problems. Below this level problems will be ignored.</p> 1357 * <dl> 1358 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility"</code></dd> 1359 * <dt>Possible values:</dt><dd><code>{ "public", "protected", "default", "private" }</code></dd> 1360 * <dt>Default:</dt><dd><code>"public"</code></dd> 1361 * </dl> 1362 * @since 3.0 1363 * @category CompilerOptionID 1364 */ 1365 public static final String COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY = PLUGIN_ID + ".compiler.problem.missingJavadocTagsVisibility"; //$NON-NLS-1$ 1366 /** 1367 * Compiler option ID: Reporting Missing Javadoc Tags on Overriding Methods. 1368 * <p>Specify whether the compiler will verify overriding methods in order to report Javadoc missing tag problems.</p> 1369 * <dl> 1370 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding"</code></dd> 1371 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 1372 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 1373 * </dl> 1374 * @since 3.0 1375 * @category CompilerOptionID 1376 */ 1377 public static final String COMPILER_PB_MISSING_JAVADOC_TAGS_OVERRIDING = PLUGIN_ID + ".compiler.problem.missingJavadocTagsOverriding"; //$NON-NLS-1$ 1378 /** 1379 * Compiler option ID: Reporting Missing Javadoc Tags for Method Type Parameters. 1380 * <p>Specify whether a missing <code>@param</code> for a type parameter in a method declaration should be reported. 1381 * When enabled, the compiler will issue a missing Javadoc tag error or warning for a type parameter without a 1382 * corresponding <code>@param</code> tag.</p> 1383 * <p>This option only has an effect if the compiler compliance is 1.5 or greater.</p> 1384 * <dl> 1385 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters"</code></dd> 1386 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 1387 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 1388 * </dl> 1389 * @since 3.7 1390 * @category CompilerOptionID 1391 */ 1392 public static final String COMPILER_PB_MISSING_JAVADOC_TAGS_METHOD_TYPE_PARAMETERS = PLUGIN_ID + ".compiler.problem.missingJavadocTagsMethodTypeParameters"; //$NON-NLS-1$ 1393 /** 1394 * Compiler option ID: Reporting Missing Javadoc Comments. 1395 * <p>This is the generic control for the severity of missing Javadoc comment problems. 1396 * When enabled, the compiler will issue an error or a warning when Javadoc comments are missing.</p> 1397 * <p>Note that this diagnosis can be enabled based on the visibility of the construct associated with the expected Javadoc; 1398 * also see the setting {@link #COMPILER_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY}.</p> 1399 * <dl> 1400 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingJavadocComments"</code></dd> 1401 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1402 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 1403 * </dl> 1404 * @since 3.0 1405 * @category CompilerOptionID 1406 */ 1407 public static final String COMPILER_PB_MISSING_JAVADOC_COMMENTS = PLUGIN_ID + ".compiler.problem.missingJavadocComments"; //$NON-NLS-1$ 1408 /** 1409 * Compiler option ID: Visibility Level For Missing Javadoc Comments. 1410 * <p>Set the minimum visibility level for missing Javadoc problems. Below this level problems will be ignored.</p> 1411 * <dl> 1412 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility"</code></dd> 1413 * <dt>Possible values:</dt><dd><code>{ "public", "protected", "default", "private" }</code></dd> 1414 * <dt>Default:</dt><dd><code>"public"</code></dd> 1415 * </dl> 1416 * @since 3.0 1417 * @category CompilerOptionID 1418 */ 1419 public static final String COMPILER_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY = PLUGIN_ID + ".compiler.problem.missingJavadocCommentsVisibility"; //$NON-NLS-1$ 1420 /** 1421 * Compiler option ID: Reporting Missing Javadoc Comments on Overriding Methods. 1422 * <p>Specify whether the compiler will verify overriding methods in order to report missing Javadoc comment problems.</p> 1423 * <dl> 1424 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding"</code></dd> 1425 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 1426 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 1427 * </dl> 1428 * @since 3.0 1429 * @category CompilerOptionID 1430 */ 1431 public static final String COMPILER_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING = PLUGIN_ID + ".compiler.problem.missingJavadocCommentsOverriding"; //$NON-NLS-1$ 1432 /** 1433 * Compiler option ID: Reporting Usage of <code>char[]</code> Expressions in String Concatenations. 1434 * <p>When enabled, the compiler will issue an error or a warning whenever a <code>char[]</code> expression 1435 * is used in String concatenations (for example, <code>"hello" + new char[]{'w','o','r','l','d'}</code>).</p> 1436 * <dl> 1437 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion"</code></dd> 1438 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1439 * <dt>Default:</dt><dd><code>"warning"</code></dd> 1440 * </dl> 1441 * @since 2.1 1442 * @category CompilerOptionID 1443 */ 1444 public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$ 1445 /** 1446 * Compiler option ID: Maximum Number of Problems Reported per Compilation Unit. 1447 * <p>Specify the maximum number of problems reported on each compilation unit.</p> 1448 * <dl> 1449 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.maxProblemPerUnit"</code></dd> 1450 * <dt>Possible values:</dt><dd><code>"<n>"</code> where <code><n></code> is zero or a positive integer (if zero then all problems are reported).</dd> 1451 * <dt>Default:</dt><dd><code>"100"</code></dd> 1452 * </dl> 1453 * @since 2.0 1454 * @category CompilerOptionID 1455 */ 1456 public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID + ".compiler.maxProblemPerUnit"; //$NON-NLS-1$ 1457 /** 1458 * Compiler option ID: Treating Optional Error as Fatal. 1459 * <p>When enabled, optional errors (i.e. optional problems which severity is set to <code>"error"</code>) will be treated as standard 1460 * compiler errors, yielding problem methods/types preventing from running offending code until the issue got resolved.</p> 1461 * <p>When disabled, optional errors are only considered as warnings, still carrying an error indication to make them more 1462 * severe. Note that by default, optional errors are not fatal. Non-optional errors are 1463 * always fatal.</p> 1464 * <dl> 1465 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.fatalOptionalError"</code></dd> 1466 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 1467 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 1468 * </dl> 1469 * @since 3.2 1470 * @category CompilerOptionID 1471 */ 1472 public static final String COMPILER_PB_FATAL_OPTIONAL_ERROR = PLUGIN_ID + ".compiler.problem.fatalOptionalError"; //$NON-NLS-1$ 1473 /** 1474 * Compiler option ID: Reporting Parameter Assignment. 1475 * <p>When enabled, the compiler will issue an error or a warning if a parameter is 1476 * assigned to.</p> 1477 * <dl> 1478 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.parameterAssignment"</code></dd> 1479 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1480 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 1481 * </dl> 1482 * @since 3.2 1483 * @category CompilerOptionID 1484 */ 1485 public static final String COMPILER_PB_PARAMETER_ASSIGNMENT = PLUGIN_ID + ".compiler.problem.parameterAssignment"; //$NON-NLS-1$ 1486 /** 1487 * Compiler option ID: Reporting a method that qualifies as static, but not declared static. 1488 * <p>When enabled, the compiler will issue an error or a warning if a method has 1489 * not been declared as <code>static</code>, even though it qualifies as one.</p> 1490 * <dl> 1491 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic"</code></dd> 1492 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1493 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 1494 * </dl> 1495 * @since 3.7 1496 * @category CompilerOptionID 1497 */ 1498 public static final String COMPILER_PB_MISSING_STATIC_ON_METHOD = PLUGIN_ID + ".compiler.problem.reportMethodCanBeStatic"; //$NON-NLS-1$ 1499 /** 1500 * Compiler option ID: Reporting a method that may qualify as static, but not declared static. 1501 * <p>When enabled, the compiler will issue an error or a warning if a method has 1502 * not been declared as <code>static</code>, even though it may qualify as one, 1503 * when another method doesn't override it.</p> 1504 * <dl> 1505 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic"</code></dd> 1506 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1507 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 1508 * </dl> 1509 * @since 3.7 1510 * @category CompilerOptionID 1511 */ 1512 public static final String COMPILER_PB_POTENTIALLY_MISSING_STATIC_ON_METHOD = PLUGIN_ID + ".compiler.problem.reportMethodCanBePotentiallyStatic"; //$NON-NLS-1$ 1513 /** 1514 * Compiler option ID: Reporting a resource that is not closed properly. 1515 * <p>When enabled, the compiler will issue an error or a warning if 1516 * a local variable holds a value of type <code>java.lang.AutoCloseable</code> (compliance>=1.7) 1517 * or a value of type <code>java.io.Closeable</code> (compliance<=1.6) and if 1518 * flow analysis shows that the method <code>close()</code> is not invoked locally on that value.</p> 1519 * <dl> 1520 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unclosedCloseable"</code></dd> 1521 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1522 * <dt>Default:</dt><dd><code>"warning"</code></dd> 1523 * </dl> 1524 * @since 3.8 1525 * @category CompilerOptionID 1526 */ 1527 public static final String COMPILER_PB_UNCLOSED_CLOSEABLE = PLUGIN_ID + ".compiler.problem.unclosedCloseable"; //$NON-NLS-1$ 1528 /** 1529 * Compiler option ID: Reporting a resource that may not be closed properly. 1530 * <p>When enabled, the compiler will issue an error or a warning if 1531 * a local variable holds a value of type <code>java.lang.AutoCloseable</code> (compliance>=1.7) 1532 * or a value of type <code>java.io.Closeable</code> (compliance<=1.6) and if 1533 * flow analysis shows that the method <code>close()</code> is 1534 * not invoked locally on that value for all execution paths.</p> 1535 * <dl> 1536 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable"</code></dd> 1537 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1538 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 1539 * </dl> 1540 * @since 3.8 1541 * @category CompilerOptionID 1542 */ 1543 public static final String COMPILER_PB_POTENTIALLY_UNCLOSED_CLOSEABLE = PLUGIN_ID + ".compiler.problem.potentiallyUnclosedCloseable"; //$NON-NLS-1$ 1544 /** 1545 * Compiler option ID: Reporting a resource that is not managed by try-with-resources. 1546 * <p>When enabled, the compiler will issue an error or a warning if a local variable 1547 * holds a value of type <code>java.lang.AutoCloseable</code>, and if the method 1548 * <code>close()</code> is explicitly invoked on that resource, but the resource is 1549 * not managed by a try-with-resources block.</p> 1550 * <dl> 1551 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable"</code></dd> 1552 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1553 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 1554 * </dl> 1555 * @since 3.8 1556 * @category CompilerOptionID 1557 */ 1558 public static final String COMPILER_PB_EXPLICITLY_CLOSED_AUTOCLOSEABLE = PLUGIN_ID + ".compiler.problem.explicitlyClosedAutoCloseable"; //$NON-NLS-1$ 1559 1560 /** 1561 * Compiler option ID: Reporting a method invocation providing an argument of an unlikely type. 1562 * <p>When enabled, the compiler will issue an error or warning when certain well-known Collection methods 1563 * that take an 'Object', like e.g. {@link Map#get(Object)}, are used with an argument type 1564 * that seems to be not related to the corresponding type argument of the Collection.</p> 1565 * <p>By default, this analysis will apply some heuristics to determine whether or not two 1566 * types may or may not be related, which can be changed via option 1567 * {@link #COMPILER_PB_UNLIKELY_COLLECTION_METHOD_ARGUMENT_TYPE_STRICT}.</p> 1568 * <dl> 1569 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType"</code></dd> 1570 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1571 * <dt>Default:</dt><dd><code>"warning"</code></dd> 1572 * </dl> 1573 * @since 3.13 1574 * @category CompilerOptionID 1575 */ 1576 public static final String COMPILER_PB_UNLIKELY_COLLECTION_METHOD_ARGUMENT_TYPE = PLUGIN_ID + ".compiler.problem.unlikelyCollectionMethodArgumentType"; //$NON-NLS-1$ 1577 1578 /** 1579 * Compiler option ID: Perform strict analysis against the expected type of collection methods. 1580 * <p>This is a sub-option of {@link #COMPILER_PB_UNLIKELY_COLLECTION_METHOD_ARGUMENT_TYPE}, 1581 * which will replace the heuristics with strict compatibility checks, 1582 * i.e., each argument that is not strictly compatible with the expected type will trigger an error or warning.</p> 1583 * <p>This option has no effect if {@link #COMPILER_PB_UNLIKELY_COLLECTION_METHOD_ARGUMENT_TYPE} is set to <code>"ignore"</code>.</p> 1584 * <dl> 1585 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict"</code></dd> 1586 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 1587 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 1588 * </dl> 1589 * @since 3.13 1590 * @category CompilerOptionID 1591 */ 1592 public static final String COMPILER_PB_UNLIKELY_COLLECTION_METHOD_ARGUMENT_TYPE_STRICT = PLUGIN_ID + ".compiler.problem.unlikelyCollectionMethodArgumentTypeStrict"; //$NON-NLS-1$ 1593 1594 /** 1595 * Compiler option ID: Reporting a method invocation providing an argument of an unlikely type to method 'equals'. 1596 * <p> 1597 * When enabled, the compiler will issue an error or warning when {@link java.lang.Object#equals(Object)} is used with an argument type 1598 * that seems to be not related to the receiver's type, or correspondingly when the arguments of {@link java.util.Objects#equals(Object, Object)} 1599 * have types that seem to be not related to each other. 1600 * </p> 1601 * <dl> 1602 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType"</code></dd> 1603 * <dt>Possible values:</dt> 1604 * <dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1605 * <dt>Default:</dt><dd><code>"info"</code></dd> 1606 * </dl> 1607 * 1608 * @since 3.13 1609 * @category CompilerOptionID 1610 */ 1611 public static final String COMPILER_PB_UNLIKELY_EQUALS_ARGUMENT_TYPE = PLUGIN_ID + ".compiler.problem.unlikelyEqualsArgumentType"; //$NON-NLS-1$ 1612 1613 /** 1614 * Compiler option ID: Reporting when public API uses a non-API type. 1615 * <p> 1616 * This option is relevant only when compiling code in a named module (at compliance 9 or greater). 1617 * <p> 1618 * When enabled, the compiler will issue an error or warning when public API mentions a type that is not 1619 * accessible to clients. Here, public API refers to signatures of public fields and methods declared 1620 * by a public type in an exported package. 1621 * In these positions types are complained against that are either not public or not in an exported package. 1622 * Export qualification is not taken into account. 1623 * If a type in one of these positions is declared in another module that is required by the current module, 1624 * but without the {@code transitive} modifier, this is reported as a problem, too. 1625 * <dl> 1626 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.APILeak"</code></dd> 1627 * <dt>Possible values:</dt> 1628 * <dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1629 * <dt>Default:</dt><dd><code>"warning"</code></dd> 1630 * </dl> 1631 * 1632 * @since 3.14 1633 * @category CompilerOptionID 1634 */ 1635 public static final String COMPILER_PB_API_LEAKS = PLUGIN_ID + ".compiler.problem.APILeak"; //$NON-NLS-1$ 1636 1637 /** 1638 * Compiler option ID: Reporting when a module requires an auto module with an unstable name. 1639 * <p> 1640 * The name of an auto module name is considered unstable when it is derived from a file name rather than 1641 * being declared in the module's MANIFEST.MF. 1642 * <p> 1643 * When enabled, the compiler will issue an error or warning when a module references an auto module 1644 * with an unstable name in its 'requires' clause. 1645 * <dl> 1646 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName"</code></dd> 1647 * <dt>Possible values:</dt> 1648 * <dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1649 * <dt>Default:</dt><dd><code>"warning"</code></dd> 1650 * </dl> 1651 * 1652 * @since 3.14 1653 * @category CompilerOptionID 1654 */ 1655 public static final String COMPILER_PB_UNSTABLE_AUTO_MODULE_NAME = PLUGIN_ID + ".compiler.problem.unstableAutoModuleName"; //$NON-NLS-1$ 1656 1657 /** 1658 * Compiler option ID: Reporting when a {@code @SuppressWarnings} annotation might be unused, but exact information is not available. 1659 * <p> 1660 * This issue occurs when a suppress warnings token (like, e.g., {@code "unused"}) represents a group of problems, 1661 * and some of the problems in that group are currently disabled (configured as "ignore"). 1662 * In this situation the compiler may not know if none of the problems in that group could be found within the 1663 * annotated code section. 1664 * <p> 1665 * When enabled, the compiler will issue an error, warning or info when a {@code @SuppressWarnings} annotation 1666 * was not observed to be necessary, but analysis of the suppressed group of problems was incomplete. 1667 * 1668 * <dl> 1669 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed"</code></dd> 1670 * <dt>Possible values:</dt> 1671 * <dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1672 * <dt>Default:</dt><dd><code>"info"</code></dd> 1673 * </dl> 1674 * 1675 * @since 3.20 1676 * @category CompilerOptionID 1677 */ 1678 public static final String COMPILER_PB_SUPPRESS_WARNINGS_NOT_FULLY_ANALYSED = PLUGIN_ID + ".compiler.problem.suppressWarningsNotFullyAnalysed"; //$NON-NLS-1$ 1679 1680 /** 1681 * Compiler option ID: Annotation-based Null Analysis. 1682 * <p>This option controls whether the compiler will use null annotations for 1683 * improved analysis of (potential) null references.</p> 1684 * <p>When enabled, the compiler will interpret the annotation types defined using 1685 * {@link #COMPILER_NONNULL_ANNOTATION_NAME} and {@link #COMPILER_NULLABLE_ANNOTATION_NAME} 1686 * as specifying whether or not a given type includes the value <code>null</code>.</p> 1687 * <p>The effect of these analyses is further controlled by the options 1688 * {@link #COMPILER_PB_NULL_SPECIFICATION_VIOLATION}, 1689 * {@link #COMPILER_PB_NULL_ANNOTATION_INFERENCE_CONFLICT} and 1690 * {@link #COMPILER_PB_NULL_UNCHECKED_CONVERSION}. 1691 * </p> 1692 * <dl> 1693 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.annotation.nullanalysis"</code></dd> 1694 * <dt>Possible values:</dt><dd><code>{ "disabled", "enabled" }</code></dd> 1695 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 1696 * </dl> 1697 * @since 3.8 1698 * @category CompilerOptionID 1699 */ 1700 public static final String COMPILER_ANNOTATION_NULL_ANALYSIS = PLUGIN_ID + ".compiler.annotation.nullanalysis"; //$NON-NLS-1$ 1701 /** 1702 * Compiler option ID: Name of Annotation Type for Nullable Types. 1703 * <p>This option defines a fully qualified Java type name that the compiler may use 1704 * to perform special null analysis.</p> 1705 * <p>If the annotation specified by this option is applied to a type in a method 1706 * signature or variable declaration, this will be interpreted as a specification 1707 * that <code>null</code> is a legal value in that position. Currently supported 1708 * positions are: method parameters, method return type, fields and local variables.</p> 1709 * <p>If a value whose type 1710 * is annotated with this annotation is dereferenced without checking for null, 1711 * the compiler will trigger a diagnostic as further controlled by 1712 * {@link #COMPILER_PB_POTENTIAL_NULL_REFERENCE}.</p> 1713 * <p>The compiler may furthermore check adherence to the null specification as 1714 * further controlled by {@link #COMPILER_PB_NULL_SPECIFICATION_VIOLATION}, 1715 * {@link #COMPILER_PB_NULL_ANNOTATION_INFERENCE_CONFLICT} and 1716 * {@link #COMPILER_PB_NULL_UNCHECKED_CONVERSION}.</p> 1717 * <p>This option only has an effect if the option {@link #COMPILER_ANNOTATION_NULL_ANALYSIS} is enabled.</p> 1718 * <dl> 1719 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.annotation.nullable"</code></dd> 1720 * <dt>Possible values:</dt><dd>any legal, fully qualified Java type name; must resolve to an annotation type.</dd> 1721 * <dt>Default:</dt><dd><code>"org.eclipse.jdt.annotation.Nullable"</code></dd> 1722 * </dl> 1723 * @since 3.8 1724 * @category CompilerOptionID 1725 */ 1726 public static final String COMPILER_NULLABLE_ANNOTATION_NAME = PLUGIN_ID + ".compiler.annotation.nullable"; //$NON-NLS-1$ 1727 /** 1728 * Compiler option ID: Names of Secondary Annotation Types for Nullable Types. 1729 * <p>This option defines a comma-separated list of fully qualified Java type names 1730 * that the compiler may use to perform special null analysis.</p> 1731 * <p>The annotation types identified by the names in this list are interpreted in the same way 1732 * as the annotation identified by {@link #COMPILER_NULLABLE_ANNOTATION_NAME}. 1733 * The intention is to support libraries using different sets of null annotations, 1734 * in addition to those used by the current project. Secondary null annotations should not be 1735 * used in the project's own source code.</p> 1736 * <p>JDT will never actively use any secondary annotation names from this list, 1737 * i.e., inferred null annotations and content assist proposals mentioning null annotations 1738 * are always rendered using the primary name from {@link #COMPILER_NULLABLE_ANNOTATION_NAME}.</p> 1739 * <p>This option only has an effect if the option {@link #COMPILER_ANNOTATION_NULL_ANALYSIS} is enabled.</p> 1740 * <dl> 1741 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.annotation.nullable.secondary"</code></dd> 1742 * <dt>Possible values:</dt><dd>a comma-separated list of legal, fully qualified Java type names; 1743 * each name in the list must resolve to an annotation type.</dd> 1744 * <dt>Default:</dt><dd><code>""</code></dd> 1745 * </dl> 1746 * @since 3.12 1747 * @category CompilerOptionID 1748 */ 1749 public static final String COMPILER_NULLABLE_ANNOTATION_SECONDARY_NAMES = PLUGIN_ID + ".compiler.annotation.nullable.secondary"; //$NON-NLS-1$ 1750 /** 1751 * Compiler option ID: Name of Annotation Type for Non-Null Types. 1752 * <p>This option defines a fully qualified Java type name that the compiler may use 1753 * to perform special null analysis.</p> 1754 * <p>If the annotation specified by this option is applied to a type in a method 1755 * signature or variable declaration, this will be interpreted as a specification 1756 * that <code>null</code> is <b>not</b> a legal value in that position. Currently 1757 * supported positions are: method parameters, method return type, fields and local variables.</p> 1758 * <p>For values declared with this annotation, the compiler will never trigger a null 1759 * reference diagnostic (as controlled by {@link #COMPILER_PB_POTENTIAL_NULL_REFERENCE} 1760 * and {@link #COMPILER_PB_NULL_REFERENCE}), because the assumption is made that null 1761 * will never occur at runtime in these positions.</p> 1762 * <p>The compiler may furthermore check adherence to the null specification as further 1763 * controlled by {@link #COMPILER_PB_NULL_SPECIFICATION_VIOLATION}, 1764 * {@link #COMPILER_PB_NULL_ANNOTATION_INFERENCE_CONFLICT} and 1765 * {@link #COMPILER_PB_NULL_UNCHECKED_CONVERSION}.</p> 1766 * <p>This option only has an effect if the option {@link #COMPILER_ANNOTATION_NULL_ANALYSIS} is enabled.</p> 1767 * <dl> 1768 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.annotation.nonnull"</code></dd> 1769 * <dt>Possible values:</dt><dd>any legal, fully qualified Java type name; must resolve to an annotation type.</dd> 1770 * <dt>Default:</dt><dd><code>"org.eclipse.jdt.annotation.NonNull"</code></dd> 1771 * </dl> 1772 * @since 3.8 1773 * @category CompilerOptionID 1774 */ 1775 public static final String COMPILER_NONNULL_ANNOTATION_NAME = PLUGIN_ID + ".compiler.annotation.nonnull"; //$NON-NLS-1$ 1776 /** 1777 * Compiler option ID: Names of Secondary Annotation Types for Non-Null Types. 1778 * <p>This option defines a comma-separated list of fully qualified Java type names 1779 * that the compiler may use to perform special null analysis.</p> 1780 * <p>The annotation types identified by the names in this list are interpreted in the same way 1781 * as the annotation identified by {@link #COMPILER_NONNULL_ANNOTATION_NAME}. 1782 * The intention is to support libraries using different sets of null annotations, 1783 * in addition to those used by the current project. Secondary null annotations should not be 1784 * used in the project's own source code.</p> 1785 * <p>JDT will never actively use any secondary annotation names from this list, 1786 * i.e., inferred null annotations and content assist proposals mentioning null annotations 1787 * are always rendered using the primary name from {@link #COMPILER_NONNULL_ANNOTATION_NAME}.</p> 1788 * <p>This option only has an effect if the option {@link #COMPILER_ANNOTATION_NULL_ANALYSIS} is enabled.</p> 1789 * <dl> 1790 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.annotation.nonnull.secondary"</code></dd> 1791 * <dt>Possible values:</dt><dd>a comma-separated list of legal, fully qualified Java type names; 1792 * each name in the list must resolve to an annotation type.</dd> 1793 * <dt>Default:</dt><dd><code>""</code></dd> 1794 * </dl> 1795 * @since 3.12 1796 * @category CompilerOptionID 1797 */ 1798 public static final String COMPILER_NONNULL_ANNOTATION_SECONDARY_NAMES = PLUGIN_ID + ".compiler.annotation.nonnull.secondary"; //$NON-NLS-1$ 1799 /** 1800 * Compiler option ID: Name of Annotation Type to specify a nullness default for unannotated types. 1801 * <p>This option defines a fully qualified Java type name that the compiler may use 1802 * to perform special null analysis.</p> 1803 * <p>If the annotation is applied without an argument, all unannotated types in method signatures 1804 * and field declarations within the annotated element will be treated as if they were specified 1805 * with the non-null annotation (see {@link #COMPILER_NONNULL_ANNOTATION_NAME}).</p> 1806 * <p>If the annotation is applied with the constant <code>false</code> as its argument 1807 * all corresponding defaults at outer scopes will be canceled for the annotated element.</p> 1808 * <p>This option only has an effect if the option {@link #COMPILER_ANNOTATION_NULL_ANALYSIS} is enabled.</p> 1809 * <dl> 1810 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.annotation.nonnullbydefault"</code></dd> 1811 * <dt>Possible values:</dt><dd>any legal, fully qualified Java type name; must resolve to an annotation type. 1812 * That annotation type should have exactly one boolean parameter.</dd> 1813 * <dt>Default:</dt><dd><code>"org.eclipse.jdt.annotation.NonNullByDefault"</code></dd> 1814 * </dl> 1815 * @since 3.8 1816 * @category CompilerOptionID 1817 */ 1818 public static final String COMPILER_NONNULL_BY_DEFAULT_ANNOTATION_NAME = PLUGIN_ID + ".compiler.annotation.nonnullbydefault"; //$NON-NLS-1$ 1819 /** 1820 * Compiler option ID: Names of Secondary Annotation Types to specify a nullness default for unannotated types. 1821 * <p>This option defines a comma-separated list of fully qualified Java type names 1822 * that the compiler may use to perform special null analysis.</p> 1823 * <p>The annotation types identified by the names in this list are interpreted in the same way 1824 * as the annotation identified by {@link #COMPILER_NONNULL_BY_DEFAULT_ANNOTATION_NAME}. 1825 * The intention is to support libraries using different sets of null annotations, 1826 * in addition to those used by the current project. Secondary null annotations should not be 1827 * used in the project's own source code.</p> 1828 * <p>This option only has an effect if the option {@link #COMPILER_ANNOTATION_NULL_ANALYSIS} is enabled.</p> 1829 * <dl> 1830 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary"</code></dd> 1831 * <dt>Possible values:</dt><dd>a comma-separated list of legal, fully qualified Java type names; 1832 * each name in the list must resolve to an annotation type.</dd> 1833 * <dt>Default:</dt><dd><code>""</code></dd> 1834 * </dl> 1835 * @since 3.12 1836 * @category CompilerOptionID 1837 */ 1838 public static final String COMPILER_NONNULL_BY_DEFAULT_ANNOTATION_SECONDARY_NAMES = PLUGIN_ID + ".compiler.annotation.nonnullbydefault.secondary"; //$NON-NLS-1$ 1839 /** 1840 * Compiler option ID: Reporting missing default nullness annotation. 1841 * <p>When enabled, the compiler will issue an error or a warning in the following cases:</p> 1842 * <ul> 1843 * <li> When a package does not contain a default nullness annotation, as a result of missing package-info.java 1844 * or missing default nullness annotation in package-info.java.</li> 1845 * <li> When a type inside a default package does not contain a default nullness annotation.</li> 1846 * </ul> 1847 * <p>This option only has an effect if the option {@link #COMPILER_ANNOTATION_NULL_ANALYSIS} is enabled.</p> 1848 * <dl> 1849 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation"</code></dd> 1850 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code>.</dd> 1851 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 1852 * </dl> 1853 * @since 3.8 1854 * @category CompilerOptionID 1855 */ 1856 public static final String COMPILER_PB_MISSING_NONNULL_BY_DEFAULT_ANNOTATION = PLUGIN_ID + ".compiler.annotation.missingNonNullByDefaultAnnotation"; //$NON-NLS-1$ 1857 /** 1858 * Compiler option ID: Reporting Violations of Null Specifications. 1859 * <p>Depending on this option, the compiler will issue either an error or a warning 1860 * whenever one of the following situations is detected:</p> 1861 * <ol> 1862 * <li>A method declared with a nonnull annotation returns a 1863 * <em>nullable</em> expression.</li> 1864 * <li>A <em>nullable</em> expression is passed 1865 * as an argument in a method call where the corresponding parameter of the called 1866 * method is declared with a nonnull annotation.</li> 1867 * <li>A <em>nullable</em> expression is assigned 1868 * to a local variable that is declared with a nonnull annotation.</li> 1869 * <li>A method that overrides an inherited method declared with a nonnull annotation 1870 * tries to relax that contract by specifying a nullable annotation 1871 * (prohibition of contravariant return).</li> 1872 * <li>A method that overrides an inherited method which has a nullable declaration 1873 * for at least one of its parameters, tries to tighten that null contract by 1874 * specifying a nonnull annotation for its corresponding parameter 1875 * (prohibition of covariant parameters).</li> 1876 * <li>A non-static field with a nonnull annotation is not definitely assigned at 1877 * the end of each constructor.</li> 1878 * <li>A static field with a nonnull annotation is not definitely assigned in static initializers.</li> 1879 * </ol> 1880 * In the above an expression is considered as <em>nullable</em> if 1881 * either it is statically known to evaluate to the value <code>null</code>, or if it is 1882 * declared with a nullable annotation. 1883 * <p>The compiler options {@link #COMPILER_NONNULL_ANNOTATION_NAME} and 1884 * {@link #COMPILER_NULLABLE_ANNOTATION_NAME} control which annotations the compiler 1885 * shall interpret as nonnull or nullable annotations, respectively. 1886 * </p> 1887 * <p>This option only has an effect if the option {@link #COMPILER_ANNOTATION_NULL_ANALYSIS} is enabled.</p> 1888 * <dl> 1889 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.nullSpecViolation"</code></dd> 1890 * <dt>Possible values:</dt><dd><code>{ "error", "warning" }</code></dd> 1891 * <dt>Default:</dt><dd><code>"error"</code></dd> 1892 * </dl> 1893 * @since 3.8 1894 * @category CompilerOptionID 1895 */ 1896 public static final String COMPILER_PB_NULL_SPECIFICATION_VIOLATION = PLUGIN_ID + ".compiler.problem.nullSpecViolation"; //$NON-NLS-1$ 1897 /** 1898 * Compiler option ID: Reporting conflicts between declared null annotation and inferred null value 1899 * <p>When enabled, the compiler will issue an error or a warning whenever one of the 1900 * following situations is detected:</p> 1901 * <ol> 1902 * <li>A method declared with a nonnull annotation returns an expression that is 1903 * statically known to evaluate to a null value on some flow.</li> 1904 * <li>An expression that is statically known to evaluate to a null value on some flow 1905 * is passed as an argument in a method call where the corresponding parameter of 1906 * the called method is declared with a nonnull annotation.</li> 1907 * <li>An expression that is statically known to evaluate to a null value on some flow 1908 * is assigned to a local variable that is declared with a nonnull annotation.</li> 1909 * </ol> 1910 * <p>The compiler options {@link #COMPILER_NONNULL_ANNOTATION_NAME} and 1911 * {@link #COMPILER_NULLABLE_ANNOTATION_NAME} control which annotations the compiler 1912 * shall interpret as nonnull or nullable annotations, respectively. 1913 * </p> 1914 * <p>This option only has an effect if the option {@link #COMPILER_ANNOTATION_NULL_ANALYSIS} is enabled.</p> 1915 * <dl> 1916 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict"</code></dd> 1917 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1918 * <dt>Default:</dt><dd><code>"error"</code></dd> 1919 * </dl> 1920 * @since 3.8 1921 * @category CompilerOptionID 1922 */ 1923 public static final String COMPILER_PB_NULL_ANNOTATION_INFERENCE_CONFLICT = PLUGIN_ID + ".compiler.problem.nullAnnotationInferenceConflict"; //$NON-NLS-1$ 1924 /** 1925 * Compiler option ID: Reporting unchecked conversion from a type with unknown nullness to a null annotated type 1926 * <p>When enabled, the compiler will issue an error or a warning whenever one of the 1927 * following situations is detected:</p> 1928 * <ol> 1929 * <li>A method declared with a nonnull annotation returns an expression for which 1930 * insufficient nullness information is available for statically proving that no 1931 * flow will pass a null value at runtime.</li> 1932 * <li>An expression for which insufficient nullness information is available for 1933 * statically proving that it will never evaluate to a null value at runtime 1934 * is passed as an argument in a method call where the corresponding parameter of 1935 * the called method is declared with a nonnull annotation.</li> 1936 * <li>An expression for which insufficient nullness information is available for 1937 * statically proving that it will never evaluate to a null value at runtime 1938 * is assigned to a local variable that is declared with a nonnull annotation.</li> 1939 * </ol> 1940 * <p>Unchecked null conversion is usually a consequence of using other unannotated 1941 * variables or methods.</p> 1942 * <p>The compiler options {@link #COMPILER_NONNULL_ANNOTATION_NAME} and 1943 * {@link #COMPILER_NULLABLE_ANNOTATION_NAME} control which annotations the compiler 1944 * shall interpret as nonnull or nullable annotations, respectively. 1945 * </p> 1946 * <p>This option only has an effect if the option {@link #COMPILER_ANNOTATION_NULL_ANALYSIS} is enabled.</p> 1947 * <dl> 1948 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion"</code></dd> 1949 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1950 * <dt>Default:</dt><dd><code>"warning"</code></dd> 1951 * </dl> 1952 * @since 3.8 1953 * @category CompilerOptionID 1954 */ 1955 public static final String COMPILER_PB_NULL_UNCHECKED_CONVERSION = PLUGIN_ID + ".compiler.problem.nullUncheckedConversion"; //$NON-NLS-1$ 1956 /** 1957 * Compiler option ID: Reporting problems detected by pessimistic null analysis for free type variables. 1958 * <p>Unless set to <code>"ignore"</code>, type variables not affected by any explicit null annotation are pessimistically analyzed 1959 * in two directions: When reading a value of this type, it is assumed to be nullable. When this type appears as the required type 1960 * (i.e., at the left hand side of an assignment or variable initialization, or as the method return type against which a return statement 1961 * is being checked) the type is considered to require the nonnull property.</p> 1962 * <p>Problems reported due to this pessimistic analysis are reported with the level given in this option.</p> 1963 * @since 3.12 1964 * @category CompilerOptionID 1965 * <dl> 1966 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables"</code></dd> 1967 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1968 * <dt>Default:</dt><dd><code>"warning"</code></dd> 1969 * </dl> 1970 */ 1971 public static final String COMPILER_PB_PESSIMISTIC_NULL_ANALYSIS_FOR_FREE_TYPE_VARIABLES = PLUGIN_ID + ".compiler.problem.pessimisticNullAnalysisForFreeTypeVariables"; //$NON-NLS-1$ 1972 /** 1973 * Compiler option ID: Reporting Redundant Null Annotations. 1974 * <p>When enabled, the compiler will issue an error or a warning when a non-null annotation 1975 * (see {@link #COMPILER_NONNULL_ANNOTATION_NAME}) 1976 * is applied although the same effect is already achieved by a default applicable at the 1977 * current location. Such a default may be set by using the annotation specified by the option 1978 * {@link #COMPILER_NONNULL_BY_DEFAULT_ANNOTATION_NAME}. 1979 * </p> 1980 * <p>This option only has an effect if the option {@link #COMPILER_ANNOTATION_NULL_ANALYSIS} is enabled.</p> 1981 * <dl> 1982 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation"</code></dd> 1983 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 1984 * <dt>Default:</dt><dd><code>"warning"</code></dd> 1985 * </dl> 1986 * @since 3.8 1987 * @category CompilerOptionID 1988 */ 1989 public static final String COMPILER_PB_REDUNDANT_NULL_ANNOTATION = PLUGIN_ID + ".compiler.problem.redundantNullAnnotation"; //$NON-NLS-1$ 1990 /** 1991 * Compiler option ID: Perform syntactic null analysis for fields. 1992 * <p>When enabled, the compiler will detect certain syntactic constellations where a null 1993 * related warning against a field reference would normally be raised but can be suppressed 1994 * at low risk given that the same field reference was known to be non-null immediately before.</p> 1995 * <dl> 1996 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields"</code></dd> 1997 * <dt>Possible values:</dt><dd><code>{ "disabled", "enabled" }</code></dd> 1998 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 1999 * </dl> 2000 * @since 3.9 2001 * @category CompilerOptionID 2002 */ 2003 public static final String COMPILER_PB_SYNTACTIC_NULL_ANALYSIS_FOR_FIELDS = JavaCore.PLUGIN_ID+".compiler.problem.syntacticNullAnalysisForFields"; //$NON-NLS-1$ 2004 /** 2005 * Compiler option ID: Inheritance of null annotations. 2006 * <p>When enabled, the compiler will check for each method without any explicit null annotations: 2007 * If it overrides a method which has null annotations, it will treat the 2008 * current method as if it had the same annotations as the overridden method.</p> 2009 * <p>Annotation inheritance will use the <em>effective</em> nullness of the overridden method 2010 * after transitively applying inheritance and after applying any default nullness 2011 * (see {@link #COMPILER_NONNULL_BY_DEFAULT_ANNOTATION_NAME}) at the site of the overridden method.</p> 2012 * <p>If different implicit null annotations (from a nonnull default and/or overridden methods) are applicable 2013 * to the same type in a method signature, this is flagged as an error 2014 * and an explicit null annotation must be used to disambiguate.</p> 2015 * <dl> 2016 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations"</code></dd> 2017 * <dt>Possible values:</dt><dd><code>{ "disabled", "enabled" }</code></dd> 2018 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 2019 * </dl> 2020 * @since 3.9 2021 * @category CompilerOptionID 2022 */ 2023 public static final String COMPILER_INHERIT_NULL_ANNOTATIONS = JavaCore.PLUGIN_ID+".compiler.annotation.inheritNullAnnotations"; //$NON-NLS-1$ 2024 /** 2025 * Compiler option ID: Reporting Dropped Nonnull Parameter Annotations. 2026 * <p>When enabled, the compiler will issue an error or a warning against a parameter of 2027 * a method that overrides an inherited method 2028 * if all of the following hold:</p> 2029 * <ul> 2030 * <li>The overridden method declares the corresponding parameter as non-null (see {@link #COMPILER_NONNULL_ANNOTATION_NAME}).</li> 2031 * <li>The parameter in the overriding method has no null annotation.</li> 2032 * <li>The overriding method is not affected by a nullness default (see {@link #COMPILER_NONNULL_BY_DEFAULT_ANNOTATION_NAME}).</li> 2033 * <li>Inheritance of null annotations is disabled (see {@link #COMPILER_INHERIT_NULL_ANNOTATIONS}).</li> 2034 * </ul> 2035 * <p>This particular situation bears the same inherent risk as any unannotated method parameter, 2036 * because the compiler's null ananysis cannot decide wither <code>null</code> is or is not a legal value for this parameter. 2037 * However, the annotation in the overridden method <em>suggests</em> that the parameter should also be annotated as non-null. 2038 * If that is not intended or possible, it is recommended to annotate the parameter as nullable, 2039 * in order to make this (legal) change of contract explicit.</p> 2040 * <dl> 2041 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped"</code></dd> 2042 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 2043 * <dt>Default:</dt><dd><code>"warning"</code></dd> 2044 * </dl> 2045 * @since 3.9 2046 * @category CompilerOptionID 2047 */ 2048 public static final String COMPILER_PB_NONNULL_PARAMETER_ANNOTATION_DROPPED = JavaCore.PLUGIN_ID+".compiler.problem.nonnullParameterAnnotationDropped"; //$NON-NLS-1$ 2049 /** 2050 * Compiler option ID: Reporting Unsafe NonNull Interpretation Of Type Variables. 2051 * <p>When enabled, the compiler will issue an error or a warning against a method call 2052 * if all of the following hold:</p> 2053 * <ul> 2054 * <li>The method's declared return type is a type variable without any null annotation.</li> 2055 * <li>For the given invocation this type variable is substituted with a nonnull type.</li> 2056 * <li>The type declaring the method is provided by a third-party library.</li> 2057 * <li>No null annotations exist for this library type, neither in its class file nor using external annotations.</li> 2058 * </ul> 2059 * <p>This particular situation leverages the option to consistently substitute all occurrences of a type variable 2060 * with a nonnull type, but it bears the risk that the library type may not be aware of null annotations thus lacking 2061 * a necessary <code>@Nullable</code> annotation for a particular occurrence of a type variable.</p> 2062 * <p>This option only has an effect if the option {@link #COMPILER_ANNOTATION_NULL_ANALYSIS} is enabled and when 2063 * the configured set of null annotations declares the target <code>TYPE_USE</code></p> 2064 * <dl> 2065 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation"</code></dd> 2066 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 2067 * <dt>Default:</dt><dd><code>"warning"</code></dd> 2068 * </dl> 2069 * @since 3.12 2070 * @category CompilerOptionID 2071 */ 2072 public static final String COMPILER_PB_NONNULL_TYPEVAR_FROM_LEGACY_INVOCATION = JavaCore.PLUGIN_ID+".compiler.problem.nonnullTypeVariableFromLegacyInvocation"; //$NON-NLS-1$ 2073 /** 2074 * Compiler option ID: Reporting Unsafe Conversion To Unannotated Type Argument. 2075 * <p>When enabled, the compiler will issue an error, warning or info when a value of a parameterized type 2076 * with annotated type arguments is assigned to a variable / bound to a method argument, where the corresponding 2077 * type argument is unannotated.</p> 2078 * <p>This situation is problematic because it will enable using the less-annotated type to manipulate the given 2079 * objects in ways that may violate contracts of the more-annotated type.</p> 2080 * <dl> 2081 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated"</code></dd> 2082 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 2083 * <dt>Default:</dt><dd><code>"info"</code></dd> 2084 * </dl> 2085 * @since 3.21 2086 * @category CompilerOptionID 2087 */ 2088 public static final String COMPILER_PB_ANNOTATED_TYPE_ARGUMENT_TO_UNANNOTATED = JavaCore.PLUGIN_ID+".compiler.problem.annotatedTypeArgumentToUnannotated"; //$NON-NLS-1$ 2089 /** 2090 * Compiler option ID: Setting Source Compatibility Mode. 2091 * <p>Specify whether which source level compatibility is used. From 1.4 on, <code>'assert'</code> is a keyword 2092 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM 2093 * level should be set to <code>"1.4"</code> and the compliance mode should be <code>"1.4"</code>.</p> 2094 * <p>Source level 1.5 is necessary to enable generics, autoboxing, covariance, annotations, enumerations 2095 * enhanced for loop, static imports and varargs.</p> 2096 * <p>In source levels <code>"1.5"</code> and higher, the compliance and target settings should be 2097 * set to the same version as the source level.</p> 2098 * <dl> 2099 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.source"</code></dd> 2100 * <dt>Possible values:</dt><dd><code>{ "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "9", "10", "11" }</code></dd> 2101 * <dt>Default:</dt><dd><code>"1.3"</code></dd> 2102 * </dl> 2103 * @since 2.0 2104 * @category CompilerOptionID 2105 * @see #COMPILER_COMPLIANCE 2106 * @see #COMPILER_CODEGEN_TARGET_PLATFORM 2107 * @see #setComplianceOptions(String, Map) 2108 */ 2109 public static final String COMPILER_SOURCE = PLUGIN_ID + ".compiler.source"; //$NON-NLS-1$ 2110 /** 2111 * Compiler option ID: Setting Compliance Level. 2112 * <p>Select the compliance level for the compiler. 2113 * {@link #COMPILER_SOURCE} and {@link #COMPILER_CODEGEN_TARGET_PLATFORM} settings cannot be 2114 * higher than the compiler compliance level. In <code>"1.5"</code> and higher compliance, source and target settings 2115 * should match the compliance setting.</p> 2116 * <dl> 2117 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.compliance"</code></dd> 2118 * <dt>Possible values:</dt><dd><code>{ "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "9", "10", "11" }</code></dd> 2119 * <dt>Default:</dt><dd><code>"1.4"</code></dd> 2120 * </dl> 2121 * @since 2.0 2122 * @category CompilerOptionID 2123 * @see #COMPILER_SOURCE 2124 * @see #COMPILER_CODEGEN_TARGET_PLATFORM 2125 * @see #setComplianceOptions(String, Map) 2126 */ 2127 public static final String COMPILER_COMPLIANCE = PLUGIN_ID + ".compiler.compliance"; //$NON-NLS-1$ 2128 /** 2129 * Compiler option ID: Use system libraries from release. 2130 * <p>When enabled, the compiler will compile against the system libraries from release 2131 * of the specified compliance level</p> 2132 * <p>Setting this option sets the {@link #COMPILER_CODEGEN_TARGET_PLATFORM}) and {@link #COMPILER_SOURCE} to 2133 * the same level as the compiler compliance. This option is available to a project only when a supporting 2134 * JDK is found in the project's build path</p> 2135 * <dl> 2136 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.release"</code></dd> 2137 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 2138 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 2139 * </dl> 2140 * @since 3.14 2141 * @category CompilerOptionID 2142 */ 2143 public static final String COMPILER_RELEASE = PLUGIN_ID + ".compiler.release"; //$NON-NLS-1$ 2144 /** 2145 * Compiler option ID: Defining the Automatic Task Priorities. 2146 * <p>In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low) 2147 * of the task markers issued by the compiler. 2148 * If the default is specified, the priority of each task marker is <code>"NORMAL"</code>.</p> 2149 * <p>Task Priorities and task tags must have the same length. If task priorities are set, then task tags should also 2150 * be set.</p> 2151 * <dl> 2152 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.taskPriorities"</code></dd> 2153 * <dt>Possible values:</dt><dd><code>{ "<priority>[,<priority>]*" }</code> where <code><priority></code> is one of <code>"HIGH"</code>, <code>"NORMAL"</code> or <code>"LOW"</code></dd> 2154 * <dt>Default:</dt><dd><code>"NORMAL,HIGH,NORMAL"</code></dd> 2155 * </dl> 2156 * @since 2.1 2157 * @category CompilerOptionID 2158 * @see #COMPILER_TASK_TAGS 2159 */ 2160 public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID + ".compiler.taskPriorities"; //$NON-NLS-1$ 2161 /** 2162 * Compiler option ID: Defining the Automatic Task Tags. 2163 * <p>When the tag list is not empty, the compiler will issue a task marker whenever it encounters 2164 * one of the corresponding tags inside any comment in Java source code.</p> 2165 * <p>Generated task messages will start with the tag, and range until the next line separator, 2166 * comment ending, or tag.</p> 2167 * <p>When a given line of code bears multiple tags, each tag will be reported separately. 2168 * Moreover, a tag immediately followed by another tag will be reported using the contents of the 2169 * next non-empty tag of the line, if any.</p> 2170 * <p>Note that tasks messages are trimmed. If a tag is starting with a letter or digit, then it cannot be leaded by 2171 * another letter or digit to be recognized (<code>"fooToDo"</code> will not be recognized as a task for tag <code>"ToDo"</code>, but <code>"foo#ToDo"</code> 2172 * will be detected for either tag <code>"ToDo"</code> or <code>"#ToDo"</code>). Respectively, a tag ending with a letter or digit cannot be followed 2173 * by a letter or digit to be recognized (<code>"ToDofoo"</code> will not be recognized as a task for tag <code>"ToDo"</code>, but <code>"ToDo:foo"</code> will 2174 * be detected either for tag <code>"ToDo"</code> or <code>"ToDo:"</code>).</p> 2175 * <p>Task Priorities and task tags must have the same length. If task tags are set, then task priorities should also 2176 * be set.</p> 2177 * <dl> 2178 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.taskTags"</code></dd> 2179 * <dt>Possible values:</dt><dd><code>{ "<tag>[,<tag>]*" }</code> where <code><tag></code> is a String without any wild-card or leading/trailing spaces</dd> 2180 * <dt>Default:</dt><dd><code>"TODO,FIXME,XXX"</code></dd> 2181 * </dl> 2182 * @since 2.1 2183 * @category CompilerOptionID 2184 * @see #COMPILER_TASK_PRIORITIES 2185 */ 2186 public static final String COMPILER_TASK_TAGS = PLUGIN_ID + ".compiler.taskTags"; //$NON-NLS-1$ 2187 /** 2188 * Compiler option ID: Determining whether task tags are case-sensitive. 2189 * <p>When enabled, task tags are considered in a case-sensitive way.</p> 2190 * <dl> 2191 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.taskCaseSensitive"</code></dd> 2192 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 2193 * <dt>Default:</dt><dd><code>"enabled"</code></dd> 2194 * </dl> 2195 * @since 3.0 2196 * @category CompilerOptionID 2197 */ 2198 public static final String COMPILER_TASK_CASE_SENSITIVE = PLUGIN_ID + ".compiler.taskCaseSensitive"; //$NON-NLS-1$ 2199 /** 2200 * Compiler option ID: Reporting Forbidden Reference to Type with Restricted Access. 2201 * <p>When enabled, the compiler will issue an error or a warning when referring to a type that is non accessible, as defined according 2202 * to the access rule specifications.</p> 2203 * <dl> 2204 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.forbiddenReference"</code></dd> 2205 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 2206 * <dt>Default:</dt><dd><code>"error"</code></dd> 2207 * </dl> 2208 * @since 3.1 2209 * @category CompilerOptionID 2210 */ 2211 public static final String COMPILER_PB_FORBIDDEN_REFERENCE = PLUGIN_ID + ".compiler.problem.forbiddenReference"; //$NON-NLS-1$ 2212 /** 2213 * Compiler option ID: Reporting Discouraged Reference to Type with Restricted Access. 2214 * <p>When enabled, the compiler will issue an error or a warning when referring to a type with discouraged access, as defined according 2215 * to the access rule specifications.</p> 2216 * <dl> 2217 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.discouragedReference"</code></dd> 2218 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 2219 * <dt>Default:</dt><dd><code>"warning"</code></dd> 2220 * </dl> 2221 * @since 3.1 2222 * @category CompilerOptionID 2223 */ 2224 public static final String COMPILER_PB_DISCOURAGED_REFERENCE = PLUGIN_ID + ".compiler.problem.discouragedReference"; //$NON-NLS-1$ 2225 /** 2226 * Compiler option ID: Determining Effect of <code>@SuppressWarnings</code>. 2227 * <p>When enabled, the <code>@SuppressWarnings</code> annotation can be used to suppress some compiler warnings.</p> 2228 * <p>When disabled, all <code>@SupressWarnings</code> annotations are ignored; i.e., warnings are reported.</p> 2229 * <dl> 2230 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.suppressWarnings"</code></dd> 2231 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 2232 * <dt>Default:</dt><dd><code>"enabled"</code></dd> 2233 * </dl> 2234 * @since 3.1 2235 * @category CompilerOptionID 2236 */ 2237 public static final String COMPILER_PB_SUPPRESS_WARNINGS = PLUGIN_ID + ".compiler.problem.suppressWarnings"; //$NON-NLS-1$ 2238 /** 2239 * Compiler option ID: Raise null related errors or warnings arising because of assert statements. 2240 * <p>When enabled, the compiler will flag all null related errors or warnings that have been enabled by the user, 2241 * irrespective of whether a variable occurred in an assert statement.</p> 2242 * <p>When disabled, the compiler will not flag null related errors or warnings on variables that got marked as maybe or definitely 2243 * <code>null</code> in an assert statement upstream.</p> 2244 * <dl> 2245 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts"</code></dd> 2246 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 2247 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 2248 * </dl> 2249 * @since 3.7 2250 * @category CompilerOptionID 2251 */ 2252 public static final String COMPILER_PB_INCLUDE_ASSERTS_IN_NULL_ANALYSIS = PLUGIN_ID + ".compiler.problem.includeNullInfoFromAsserts"; //$NON-NLS-1$ 2253 /** 2254 * Compiler option ID: Further Determining the Effect of <code>@SuppressWarnings</code> if also 2255 * {@link #COMPILER_PB_SUPPRESS_WARNINGS} is enabled. 2256 * <p>When enabled, the <code>@SuppressWarnings</code> annotation can additionally be used to suppress 2257 * optional compiler diagnostics that have been configured as {@link #ERROR}.</p> 2258 * <p>When disabled, all <code>@SuppressWarnings</code> annotations only affects warnings.</p> 2259 * <dl> 2260 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors"</code></dd> 2261 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 2262 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 2263 * </dl> 2264 * @since 3.6 2265 * @category CompilerOptionID 2266 */ 2267 public static final String COMPILER_PB_SUPPRESS_OPTIONAL_ERRORS = PLUGIN_ID + ".compiler.problem.suppressOptionalErrors"; //$NON-NLS-1$ 2268 /** 2269 * Compiler option ID: Reporting Unhandled Warning Token for <code>@SuppressWarnings</code>. 2270 * <p>When enabled, the compiler will issue an error or a warning when encountering a token 2271 * it cannot handle inside a <code>@SuppressWarnings</code> annotation.</p> 2272 * <dl> 2273 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unhandledWarningToken"</code></dd> 2274 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 2275 * <dt>Default:</dt><dd><code>"warning"</code></dd> 2276 * </dl> 2277 * @since 3.1 2278 * @category CompilerOptionID 2279 */ 2280 public static final String COMPILER_PB_UNHANDLED_WARNING_TOKEN = PLUGIN_ID + ".compiler.problem.unhandledWarningToken"; //$NON-NLS-1$ 2281 /** 2282 * Compiler option ID: Reporting Unnecessary <code>@SuppressWarnings</code>. 2283 * <p>When enabled, the compiler will issue an error or a warning when encountering <code>@SuppressWarnings</code> annotation 2284 * for which no corresponding warning got detected in the code. This diagnostic is provided to help developers to get 2285 * rid of transient <code>@SuppressWarnings</code> no longer needed. Note that <code>@SuppressWarnings("all")</code> is still 2286 * silencing the warning for unnecessary <code>@SuppressWarnings</code>, as it is the master switch to silence ALL warnings.</p> 2287 * <dl> 2288 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unusedWarningToken"</code></dd> 2289 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 2290 * <dt>Default:</dt><dd><code>"warning"</code></dd> 2291 * </dl> 2292 * @since 3.4 2293 * @category CompilerOptionID 2294 */ 2295 public static final String COMPILER_PB_UNUSED_WARNING_TOKEN = PLUGIN_ID + ".compiler.problem.unusedWarningToken"; //$NON-NLS-1$ 2296 /** 2297 * Compiler option ID: Reporting Null Dereference. 2298 * <p>When enabled, the compiler will issue an error or a warning whenever a 2299 * variable that is statically known to hold a null value is used to 2300 * access a field or method.</p> 2301 * <p>Assert statements are ignored unless {@link #COMPILER_PB_INCLUDE_ASSERTS_IN_NULL_ANALYSIS} 2302 * is enabled.</p> 2303 * <dl> 2304 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.nullReference"</code></dd> 2305 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 2306 * <dt>Default:</dt><dd><code>"warning"</code></dd> 2307 * </dl> 2308 * @since 3.2 2309 * @category CompilerOptionID 2310 */ 2311 public static final String COMPILER_PB_NULL_REFERENCE = PLUGIN_ID + ".compiler.problem.nullReference"; //$NON-NLS-1$ 2312 /** 2313 * Compiler option ID: Reporting Potential Null Dereference. 2314 * <p>When enabled, the compiler will issue an error or a warning whenever a 2315 * variable that has formerly been tested against null but is not (no more) 2316 * statically known to hold a non-null value is used to access a field or 2317 * method.</p> 2318 * <p>Assert statements are ignored unless {@link #COMPILER_PB_INCLUDE_ASSERTS_IN_NULL_ANALYSIS} 2319 * is enabled.</p> 2320 * <dl> 2321 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.potentialNullReference"</code></dd> 2322 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 2323 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 2324 * </dl> 2325 * @since 3.3 2326 * @category CompilerOptionID 2327 */ 2328 public static final String COMPILER_PB_POTENTIAL_NULL_REFERENCE = PLUGIN_ID + ".compiler.problem.potentialNullReference"; //$NON-NLS-1$ 2329 /** 2330 * Compiler option ID: Reporting Redundant Null Check. 2331 * <p>When enabled, the compiler will issue an error or a warning whenever a 2332 * variable that is statically known to hold a null or a non-null value 2333 * is tested against null.</p> 2334 * <p>Assert statements are ignored unless {@link #COMPILER_PB_INCLUDE_ASSERTS_IN_NULL_ANALYSIS} 2335 * is enabled.</p> 2336 * <dl> 2337 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.redundantNullCheck"</code></dd> 2338 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 2339 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 2340 * </dl> 2341 * @since 3.3 2342 * @category CompilerOptionID 2343 */ 2344 public static final String COMPILER_PB_REDUNDANT_NULL_CHECK = PLUGIN_ID + ".compiler.problem.redundantNullCheck"; //$NON-NLS-1$ 2345 /** 2346 * Compiler option ID: Reporting Overriding method that doesn't call the super method invocation. 2347 * <p>When enabled, the compiler will issue an error or a warning if a method is overriding a method without calling 2348 * the super invocation.</p> 2349 * <dl> 2350 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation"</code></dd> 2351 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 2352 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 2353 * </dl> 2354 * @since 3.3 2355 * @category CompilerOptionID 2356 */ 2357 public static final String COMPILER_PB_OVERRIDING_METHOD_WITHOUT_SUPER_INVOCATION = PLUGIN_ID + ".compiler.problem.overridingMethodWithoutSuperInvocation"; //$NON-NLS-1$ 2358 /** 2359 * Compiler option ID: Reporting Redundant Superinterface. 2360 * <p>When enabled, the compiler will issue an error or a warning if a type 2361 * explicitly implements an interface that is already implemented by any 2362 * of its supertypes.</p> 2363 * <dl> 2364 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.redundantSuperinterface"</code></dd> 2365 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 2366 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 2367 * </dl> 2368 * @since 3.4 2369 * @category CompilerOptionID 2370 */ 2371 public static final String COMPILER_PB_REDUNDANT_SUPERINTERFACE = PLUGIN_ID + ".compiler.problem.redundantSuperinterface"; //$NON-NLS-1$ 2372 /** 2373 * Compiler option ID: Reporting Comparison of Identical Expressions. 2374 * <p>When enabled, the compiler will issue an error or a warning if a comparison 2375 * is involving identical operands (e.g <code>'x == x'</code>).</p> 2376 * <dl> 2377 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.comparingIdentical"</code></dd> 2378 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 2379 * <dt>Default:</dt><dd><code>"warning"</code></dd> 2380 * </dl> 2381 * @since 3.5 2382 * @category CompilerOptionID 2383 */ 2384 public static final String COMPILER_PB_COMPARING_IDENTICAL = PLUGIN_ID + ".compiler.problem.comparingIdentical"; //$NON-NLS-1$ 2385 /** 2386 * Compiler option ID: Reporting Missing Synchronized Modifier On Inherited Method. 2387 * <p>When enabled, the compiler will issue an error or a warning if a method 2388 * overrides a synchronized method without having a synchronized modifier.</p> 2389 * <dl> 2390 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod"</code></dd> 2391 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 2392 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 2393 * </dl> 2394 * @since 3.5 2395 * @category CompilerOptionID 2396 */ 2397 public static final String COMPILER_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD = PLUGIN_ID + ".compiler.problem.missingSynchronizedOnInheritedMethod"; //$NON-NLS-1$ 2398 /** 2399 * Compiler option ID: Reporting Allocation of an Unused Object. 2400 * <p>When enabled, the compiler will issue an error or a warning if an object is allocated but never used, 2401 * neither by holding a reference nor by invoking one of the object's methods.</p> 2402 * <dl> 2403 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation"</code></dd> 2404 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 2405 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 2406 * </dl> 2407 * @since 3.6 2408 * @category CompilerOptionID 2409 */ 2410 public static final String COMPILER_PB_UNUSED_OBJECT_ALLOCATION = PLUGIN_ID + ".compiler.problem.unusedObjectAllocation"; //$NON-NLS-1$ 2411 /** 2412 * Compiler option ID: Reporting redundant specification of type arguments in class instance creation expressions. 2413 * <p>When enabled, the compiler will issue an error or a warning if type arguments are used in a class instance creation, 2414 * when the '<>' operator can be used instead.</p> 2415 * <p>This option only has an effect if the compiler compliance is 1.7 or greater.</p> 2416 * <dl> 2417 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments"</code></dd> 2418 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd> 2419 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 2420 * </dl> 2421 * @since 3.7.1 2422 * @category CompilerOptionID 2423 */ 2424 public static final String COMPILER_PB_REDUNDANT_TYPE_ARGUMENTS = PLUGIN_ID + ".compiler.problem.redundantSpecificationOfTypeArguments"; //$NON-NLS-1$ 2425 /** 2426 * Core option ID: Computing Project Build Order. 2427 * <p>Indicate whether JavaCore should enforce the project build order to be based on 2428 * the classpath prerequisite chain. When requesting to compute, this takes over 2429 * the platform default order (based on project references).</p> 2430 * <dl> 2431 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.computeJavaBuildOrder"</code></dd> 2432 * <dt>Possible values:</dt><dd><code>{ "compute", "ignore" }</code></dd> 2433 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 2434 * </dl> 2435 * @category CoreOptionID 2436 */ 2437 public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder"; //$NON-NLS-1$ 2438 /** 2439 * Core option ID: Specifying Filters for Resource Copying Control. 2440 * <p>Allow to specify some filters to control the resource copy process.</p> 2441 * <dl> 2442 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"</code></dd> 2443 * <dt>Possible values:</dt><dd><code>{ "<name>[,<name>]* }</code> where <code><name></code> is a file name pattern (* and ? wild-cards allowed) 2444 * or the name of a folder which ends with <code>'/'</code></dd> 2445 * <dt>Default:</dt><dd><code>""</code></dd> 2446 * </dl> 2447 * @since 2.0 2448 * @category CoreOptionID 2449 */ 2450 public static final String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER = PLUGIN_ID + ".builder.resourceCopyExclusionFilter"; //$NON-NLS-1$ 2451 /** 2452 * Core option ID: Reporting Duplicate Resources. 2453 * <p>Indicate the severity of the problem reported when more than one occurrence 2454 * of a resource is to be copied into the output location.</p> 2455 * <dl> 2456 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.builder.duplicateResourceTask"</code></dd> 2457 * <dt>Possible values:</dt><dd><code>{ "error", "warning" }</code></dd> 2458 * <dt>Default:</dt><dd><code>"warning"</code></dd> 2459 * </dl> 2460 * @since 2.1 2461 * @category CoreOptionID 2462 */ 2463 public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID + ".builder.duplicateResourceTask"; //$NON-NLS-1$ 2464 /** 2465 * Core option ID: Cleaning Output Folder(s). 2466 * <p>Indicate whether the JavaBuilder is allowed to clean the output folders 2467 * when performing full build operations.</p> 2468 * <dl> 2469 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.builder.cleanOutputFolder"</code></dd> 2470 * <dt>Possible values:</dt><dd><code>{ "clean", "ignore" }</code></dd> 2471 * <dt>Default:</dt><dd><code>"clean"</code></dd> 2472 * </dl> 2473 * @since 2.1 2474 * @category CoreOptionID 2475 */ 2476 public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID + ".builder.cleanOutputFolder"; //$NON-NLS-1$ 2477 /** 2478 * Core option ID: Recreate Modified class files in Output Folder. 2479 * <p>Indicate whether the JavaBuilder should check for any changes to .class files 2480 * in the output folders while performing incremental build operations. If changes 2481 * are detected to managed .class files, then a full build is performed, otherwise 2482 * the changes are left as is. Tools further altering generated .class files, like optimizers, 2483 * should ensure this option remains set in its default state of ignore.</p> 2484 * <dl> 2485 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder"</code></dd> 2486 * <dt>Possible values:</dt><dd><code>{ "enabled", "ignore" }</code></dd> 2487 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 2488 * </dl> 2489 * @since 3.2 2490 * @category CoreOptionID 2491 */ 2492 public static final String CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER = PLUGIN_ID + ".builder.recreateModifiedClassFileInOutputFolder"; //$NON-NLS-1$ 2493 /** 2494 * Core option ID: Reporting Incomplete Classpath. 2495 * <p>Indicate the severity of the problem reported when an entry on the classpath does not exist, 2496 * is not legitimate or is not visible (for example, a referenced project is closed).</p> 2497 * <dl> 2498 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.incompleteClasspath"</code></dd> 2499 * <dt>Possible values:</dt><dd><code>{ "error", "warning"}</code></dd> 2500 * <dt>Default:</dt><dd><code>"error"</code></dd> 2501 * </dl> 2502 * @since 2.1 2503 * @category CoreOptionID 2504 */ 2505 public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID + ".incompleteClasspath"; //$NON-NLS-1$ 2506 /** 2507 * Core option ID: Reporting Classpath Cycle. 2508 * <p>Indicate the severity of the problem reported when a project is involved in a cycle.</p> 2509 * <dl> 2510 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.circularClasspath"</code></dd> 2511 * <dt>Possible values:</dt><dd><code>{ "error", "warning" }</code></dd> 2512 * <dt>Default:</dt><dd><code>"error"</code></dd> 2513 * </dl> 2514 * @since 2.1 2515 * @category CoreOptionID 2516 */ 2517 public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID + ".circularClasspath"; //$NON-NLS-1$ 2518 /** 2519 * Core option ID: Reporting Incompatible JDK Level for Required Binaries. 2520 * <p>Indicate the severity of the problem reported when a project prerequisites another project 2521 * or library with an incompatible target JDK level (e.g. project targeting 1.1 vm, but compiled against 1.4 libraries).</p> 2522 * <dl> 2523 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.incompatibleJDKLevel"</code></dd> 2524 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd> 2525 * <dt>Default:</dt><dd><code>"ignore"</code></dd> 2526 * </dl> 2527 * @since 3.0 2528 * @category CoreOptionID 2529 */ 2530 public static final String CORE_INCOMPATIBLE_JDK_LEVEL = PLUGIN_ID + ".incompatibleJDKLevel"; //$NON-NLS-1$ 2531 /** 2532 * Core option ID: Abort if Invalid Classpath. 2533 * <p>Allow to toggle the builder to abort if the classpath is invalid.</p> 2534 * <dl> 2535 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.builder.invalidClasspath"</code></dd> 2536 * <dt>Possible values:</dt><dd><code>{ "abort", "ignore" }</code></dd> 2537 * <dt>Default:</dt><dd><code>"abort"</code></dd> 2538 * </dl> 2539 * @since 2.0 2540 * @category CoreOptionID 2541 */ 2542 public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID + ".builder.invalidClasspath"; //$NON-NLS-1$ 2543 /** 2544 * Core option ID: Default Source Encoding Format. 2545 * <p>Get the default encoding format of source files. This value is 2546 * immutable and preset to the result of <code>ResourcesPlugin.getEncoding()</code>.</p> 2547 * <p>It is offered as a convenience shortcut only.</p> 2548 * <dl> 2549 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.encoding"</code></dd> 2550 * <dt>value:</dt><dd><code><immutable, platform default value></code></dd> 2551 * </dl> 2552 * @since 2.0 2553 * @category CoreOptionID 2554 */ 2555 public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; //$NON-NLS-1$ 2556 /** 2557 * Core option ID: Enabling Usage of Classpath Exclusion Patterns. 2558 * <p>When disabled, no entry on a project classpath can be associated with 2559 * an exclusion pattern.</p> 2560 * <dl> 2561 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.classpath.exclusionPatterns"</code></dd> 2562 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 2563 * <dt>Default:</dt><dd><code>"enabled"</code></dd> 2564 * </dl> 2565 * @since 2.1 2566 * @category CoreOptionID 2567 */ 2568 public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID + ".classpath.exclusionPatterns"; //$NON-NLS-1$ 2569 /** 2570 * Core option ID: Enabling Usage of Classpath Multiple Output Locations. 2571 * <p>When disabled, no entry on a project classpath can be associated with 2572 * a specific output location, preventing thus usage of multiple output locations.</p> 2573 * <dl> 2574 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.classpath.multipleOutputLocations"</code></dd> 2575 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 2576 * <dt>Default:</dt><dd><code>"enabled"</code></dd> 2577 * </dl> 2578 * @since 2.1 2579 * @category CoreOptionID 2580 */ 2581 public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID + ".classpath.multipleOutputLocations"; //$NON-NLS-1$ 2582 /** 2583 * Core option ID: Reporting an output location overlapping another source location. 2584 * <p> Indicate the severity of the problem reported when a source entry's output location overlaps another 2585 * source entry.</p> 2586 * 2587 * <dl> 2588 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource"</code></dd> 2589 * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd> 2590 * <dt>Default:</dt><dd><code>"error"</code></dd> 2591 * </dl> 2592 * @since 3.6.4 2593 */ 2594 public static final String CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE = PLUGIN_ID + ".classpath.outputOverlappingAnotherSource"; //$NON-NLS-1$ 2595 2596 /** 2597 * Core option ID: Reporting if a project which has only main sources depends on a project with only test sources. 2598 * <p> Indicate the severity of the problem reported when a project that has one or more main source folders but 2599 * no test source folders has a project on its build path that only has one or more test source folders, but no main source folders.</p> 2600 * 2601 * <dl> 2602 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.classpath.mainOnlyProjectHasTestOnlyDependency"</code></dd> 2603 * <dt>Possible values:</dt><dd><code>{ "error", "ignore" }</code></dd> 2604 * <dt>Default:</dt><dd><code>"error"</code></dd> 2605 * </dl> 2606 * @since 3.16 2607 */ 2608 public static final String CORE_MAIN_ONLY_PROJECT_HAS_TEST_ONLY_DEPENDENCY = PLUGIN_ID + ".classpath.mainOnlyProjectHasTestOnlyDependency"; //$NON-NLS-1$ 2609 2610 /** 2611 * Compiler option ID: Enabling support for preview language features. 2612 * <p>When enabled, the compiler will activate the preview language features of this Java version.</p> 2613 * 2614 * <dl> 2615 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures"</code></dd> 2616 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 2617 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 2618 * </dl> 2619 * @category CompilerOptionID 2620 * @since 3.18 2621 */ 2622 public static final String COMPILER_PB_ENABLE_PREVIEW_FEATURES = PLUGIN_ID + ".compiler.problem.enablePreviewFeatures"; //$NON-NLS-1$ 2623 /** 2624 * Compiler option ID: Reporting Preview features. 2625 * <p>When enabled, the compiler will issue a warning when a preview feature is used.</p> 2626 * <dl> 2627 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures"</code></dd> 2628 * <dt>Possible values:</dt><dd><code>{ "warning", "info", "ignore" }</code></dd> 2629 * <dt>Default:</dt><dd><code>"warning"</code></dd> 2630 * </dl> 2631 * @category CompilerOptionID 2632 * @since 3.18 2633 */ 2634 public static final String COMPILER_PB_REPORT_PREVIEW_FEATURES = PLUGIN_ID + ".compiler.problem.reportPreviewFeatures"; //$NON-NLS-1$ 2635 /** 2636 * Core option ID: Set the timeout value for retrieving the method's parameter names from javadoc. 2637 * <p>Timeout in milliseconds to retrieve the method's parameter names from javadoc.</p> 2638 * <p>If the value is <code>0</code>, the parameter names are not fetched and the raw names are returned.</p> 2639 * <dl> 2640 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.timeoutForParameterNameFromAttachedJavadoc"</code></dd> 2641 * <dt>Possible values:</dt><dd><code>"<n>"</code>, where <code>n</code> is an integer greater than or equal to <code>0</code></dd> 2642 * <dt>Default:</dt><dd><code>"50"</code></dd> 2643 * </dl> 2644 * @since 3.2 2645 * @category CoreOptionID 2646 */ 2647 public static final String TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC = PLUGIN_ID + ".timeoutForParameterNameFromAttachedJavadoc"; //$NON-NLS-1$ 2648 2649 /** 2650 * Core option ID: The ID of the formatter to use in formatting operations. 2651 * <dl> 2652 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.javaFormatter"</code></dd> 2653 * <dt>Default:</dt><dd><code>"org.eclipse.jdt.core.defaultJavaFormatter"</code></dd> 2654 * </dl> 2655 * @see #DEFAULT_JAVA_FORMATTER 2656 * @see #JAVA_FORMATTER_EXTENSION_POINT_ID 2657 * @since 3.11 2658 * @category CoreOptionID 2659 */ 2660 public static final String JAVA_FORMATTER = PLUGIN_ID + ".javaFormatter"; //$NON-NLS-1$ 2661 2662 /** 2663 * @since 2.0 2664 * @deprecated Use {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION}, 2665 * {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_BRACE_POSITION_FOR_BLOCK} , 2666 * {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION}, 2667 * {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION}, 2668 * {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_BRACE_POSITION_FOR_SWITCH}, 2669 * {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION} instead. 2670 * @category DeprecatedOptionID 2671 */ 2672 public static final String FORMATTER_NEWLINE_OPENING_BRACE = PLUGIN_ID + ".formatter.newline.openingBrace"; //$NON-NLS-1$ 2673 /** 2674 * @since 2.0 2675 * @deprecated Use {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT}, 2676 * {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT}, 2677 * {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT}, 2678 * {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT} instead. 2679 * @category DeprecatedOptionID 2680 */ 2681 public static final String FORMATTER_NEWLINE_CONTROL = PLUGIN_ID + ".formatter.newline.controlStatement"; //$NON-NLS-1$ 2682 /** 2683 * @since 2.0 2684 * @deprecated Use {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_COMPACT_ELSE_IF} instead. 2685 * @category DeprecatedOptionID 2686 */ 2687 public static final String FORMATTER_NEWLINE_ELSE_IF = PLUGIN_ID + ".formatter.newline.elseIf"; //$NON-NLS-1$ 2688 /** 2689 * @since 2.0 2690 * @deprecated Use {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK} instead. 2691 * @category DeprecatedOptionID 2692 */ 2693 public static final String FORMATTER_NEWLINE_EMPTY_BLOCK = PLUGIN_ID + ".formatter.newline.emptyBlock"; //$NON-NLS-1$ 2694 /** 2695 * @since 2.0 2696 * @deprecated Use {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE} instead. 2697 * @category DeprecatedOptionID 2698 */ 2699 public static final String FORMATTER_CLEAR_BLANK_LINES = PLUGIN_ID + ".formatter.newline.clearAll"; //$NON-NLS-1$ 2700 /** 2701 * @since 2.0 2702 * @deprecated Use {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_LINE_SPLIT} instead 2703 * @category DeprecatedOptionID 2704 */ 2705 public static final String FORMATTER_LINE_SPLIT = PLUGIN_ID + ".formatter.lineSplit"; //$NON-NLS-1$ 2706 /** 2707 * @since 2.0 2708 * @deprecated Use {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR} instead. 2709 * @category DeprecatedOptionID 2710 */ 2711 public static final String FORMATTER_COMPACT_ASSIGNMENT = PLUGIN_ID + ".formatter.style.assignment"; //$NON-NLS-1$ 2712 /** 2713 * @since 2.0 2714 * @deprecated Use {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_TAB_CHAR} instead. 2715 * @category DeprecatedOptionID 2716 */ 2717 public static final String FORMATTER_TAB_CHAR = PLUGIN_ID + ".formatter.tabulation.char"; //$NON-NLS-1$ 2718 /** 2719 * @since 2.0 2720 * @deprecated Use {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_TAB_SIZE} instead. 2721 * @category DeprecatedOptionID 2722 */ 2723 public static final String FORMATTER_TAB_SIZE = PLUGIN_ID + ".formatter.tabulation.size"; //$NON-NLS-1$ 2724 /** 2725 * @since 2.1 2726 * @deprecated Use {@link org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST} instead. 2727 * @category DeprecatedOptionID 2728 */ 2729 public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID + ".formatter.space.castexpression"; //$NON-NLS-1$ 2730 /** 2731 * Code assist option ID: Activate Visibility Sensitive Completion. 2732 * <p>When active, completion doesn't show that you can not see 2733 * (for example, you can not see private methods of a super class).</p> 2734 * <dl> 2735 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.visibilityCheck"</code></dd> 2736 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 2737 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 2738 * </dl> 2739 * @since 2.0 2740 * @category CodeAssistOptionID 2741 */ 2742 public static final String CODEASSIST_VISIBILITY_CHECK = PLUGIN_ID + ".codeComplete.visibilityCheck"; //$NON-NLS-1$ 2743 /** 2744 * Code assist option ID: Activate Deprecation Sensitive Completion. 2745 * <p>When enabled, completion doesn't propose deprecated members and types.</p> 2746 * <dl> 2747 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.deprecationCheck"</code></dd> 2748 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 2749 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 2750 * </dl> 2751 * @since 3.2 2752 * @category CodeAssistOptionID 2753 */ 2754 public static final String CODEASSIST_DEPRECATION_CHECK = PLUGIN_ID + ".codeComplete.deprecationCheck"; //$NON-NLS-1$ 2755 /** 2756 * Code assist option ID: Activate Camel Case Sensitive Completion. 2757 * <p>When enabled, completion shows proposals whose name match the CamelCase 2758 * pattern.</p> 2759 * <dl> 2760 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.camelCaseMatch"</code></dd> 2761 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 2762 * <dt>Default:</dt><dd><code>"enabled"</code></dd> 2763 * </dl> 2764 * @since 3.2 2765 * @category CodeAssistOptionID 2766 */ 2767 public static final String CODEASSIST_CAMEL_CASE_MATCH = PLUGIN_ID + ".codeComplete.camelCaseMatch"; //$NON-NLS-1$ 2768 /** 2769 * Code assist option ID: Activate Substring Code Completion. 2770 * <p>When enabled, completion shows proposals in which the pattern can 2771 * be found as a substring in a case-insensitive way.</p> 2772 * <dl> 2773 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.substringMatch"</code></dd> 2774 * </dl> 2775 * @since 3.12 2776 * @deprecated - this option has no effect 2777 * @category DeprecatedOptionID 2778 */ 2779 public static final String CODEASSIST_SUBSTRING_MATCH = PLUGIN_ID + ".codeComplete.substringMatch"; //$NON-NLS-1$ 2780 /** 2781 * Code assist option ID: Activate Subword Code Completion. 2782 * <p>When enabled, completion shows proposals in which the pattern can 2783 * be found as a subword in a case-insensitive way.</p> 2784 * <dl> 2785 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.subwordMatch"</code></dd> 2786 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 2787 * <dt>Default:</dt><dd><code>"enabled"</code></dd> 2788 * </dl> 2789 * @since 3.21 2790 * @category CodeAssistOptionID 2791 */ 2792 public static final String CODEASSIST_SUBWORD_MATCH = PLUGIN_ID + ".codeComplete.subwordMatch"; //$NON-NLS-1$ 2793 /** 2794 * Code assist option ID: Automatic Qualification of Implicit Members. 2795 * <p>When active, completion automatically qualifies completion on implicit 2796 * field references and message expressions.</p> 2797 * <dl> 2798 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.forceImplicitQualification"</code></dd> 2799 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 2800 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 2801 * </dl> 2802 * @since 2.0 2803 * @category CodeAssistOptionID 2804 */ 2805 public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID + ".codeComplete.forceImplicitQualification"; //$NON-NLS-1$ 2806 /** 2807 * Code assist option ID: Define the Prefixes for Field Name. 2808 * <p>When the prefixes is non empty, completion for field name will begin with 2809 * one of the proposed prefixes.</p> 2810 * <dl> 2811 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.fieldPrefixes"</code></dd> 2812 * <dt>Possible values:</dt><dd><code>{ "<prefix>[,<prefix>]*" }</code> where <code><prefix></code> is a String without any wild-card</dd> 2813 * <dt>Default:</dt><dd><code>""</code></dd> 2814 * </dl> 2815 * @since 2.1 2816 * @category CodeAssistOptionID 2817 */ 2818 public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.fieldPrefixes"; //$NON-NLS-1$ 2819 /** 2820 * Code assist option ID: Define the Prefixes for Static Field Name. 2821 * <p>When the prefixes is non empty, completion for static field name will begin with 2822 * one of the proposed prefixes.</p> 2823 * <dl> 2824 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.staticFieldPrefixes"</code></dd> 2825 * <dt>Possible values:</dt><dd><code>{ "<prefix>[,<prefix>]*" }</code> where <code><prefix></code> is a String without any wild-card</dd> 2826 * <dt>Default:</dt><dd><code>""</code></dd> 2827 * </dl> 2828 * @since 2.1 2829 * @category CodeAssistOptionID 2830 */ 2831 public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$ 2832 /** 2833 * Code assist option ID: Define the Prefixes for Static Final Field Name. 2834 * <p>When the prefixes is non empty, completion for static final field name will begin with 2835 * one of the proposed prefixes.</p> 2836 * <dl> 2837 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes"</code></dd> 2838 * <dt>Possible values:</dt><dd><code>{ "<prefix>[,<prefix>]*" }</code> where <code><prefix></code> is a String without any wild-card</dd> 2839 * <dt>Default:</dt><dd><code>""</code></dd> 2840 * </dl> 2841 * @since 3.5 2842 * @category CodeAssistOptionID 2843 */ 2844 public static final String CODEASSIST_STATIC_FINAL_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.staticFinalFieldPrefixes"; //$NON-NLS-1$ 2845 /** 2846 * Code assist option ID: Define the Prefixes for Local Variable Name. 2847 * <p>When the prefixes is non empty, completion for local variable name will begin with 2848 * one of the proposed prefixes.</p> 2849 * <dl> 2850 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.localPrefixes"</code></dd> 2851 * <dt>Possible values:</dt><dd><code>{ "<prefix>[,<prefix>]*" }</code> where <code><prefix></code> is a String without any wild-card</dd> 2852 * <dt>Default:</dt><dd><code>""</code></dd> 2853 * </dl> 2854 * @since 2.1 2855 * @category CodeAssistOptionID 2856 */ 2857 public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID + ".codeComplete.localPrefixes"; //$NON-NLS-1$ 2858 /** 2859 * Code assist option ID: Define the Prefixes for Argument Name. 2860 * <p>When the prefixes is non empty, completion for argument name will begin with 2861 * one of the proposed prefixes.</p> 2862 * <dl> 2863 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.argumentPrefixes"</code></dd> 2864 * <dt>Possible values:</dt><dd><code>{ "<prefix>[,<prefix>]*" }</code> where <code><prefix></code> is a String without any wild-card</dd> 2865 * <dt>Default:</dt><dd><code>""</code></dd> 2866 * </dl> 2867 * @since 2.1 2868 * @category CodeAssistOptionID 2869 */ 2870 public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID + ".codeComplete.argumentPrefixes"; //$NON-NLS-1$ 2871 /** 2872 * Code assist option ID: Define the Suffixes for Field Name. 2873 * <p>When the suffixes is non empty, completion for field name will end with 2874 * one of the proposed suffixes.</p> 2875 * <dl> 2876 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.fieldSuffixes"</code></dd> 2877 * <dt>Possible values:</dt><dd><code>{ "<suffix>[,<suffix>]*" }</code> where <code><suffix></code> is a String without any wild-card</dd> 2878 * <dt>Default:</dt><dd><code>""</code></dd> 2879 * </dl> 2880 * @since 2.1 2881 * @category CodeAssistOptionID 2882 */ 2883 public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.fieldSuffixes"; //$NON-NLS-1$ 2884 /** 2885 * Code assist option ID: Define the Suffixes for Static Field Name. 2886 * <p>When the suffixes is non empty, completion for static field name will end with 2887 * one of the proposed suffixes.</p> 2888 * <dl> 2889 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.staticFieldSuffixes"</code></dd> 2890 * <dt>Possible values:</dt><dd><code>{ "<suffix>[,<suffix>]*" }</code>< where <code><suffix></code> is a String without any wild-card</dd> 2891 * <dt>Default:</dt><dd><code>""</code></dd> 2892 * </dl> 2893 * @since 2.1 2894 * @category CodeAssistOptionID 2895 */ 2896 public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$ 2897 /** 2898 * Code assist option ID: Define the Suffixes for Static Final Field Name. 2899 * <p>When the suffixes is non empty, completion for static final field name will end with 2900 * one of the proposed suffixes.</p> 2901 * <dl> 2902 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes"</code></dd> 2903 * <dt>Possible values:</dt><dd><code>{ "<suffix>[,<suffix>]*" }</code>< where <code><suffix></code> is a String without any wild-card</dd> 2904 * <dt>Default:</dt><dd><code>""</code></dd> 2905 * </dl> 2906 * @since 3.5 2907 * @category CodeAssistOptionID 2908 */ 2909 public static final String CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.staticFinalFieldSuffixes"; //$NON-NLS-1$ 2910 /** 2911 * Code assist option ID: Define the Suffixes for Local Variable Name. 2912 * <p>When the suffixes is non empty, completion for local variable name will end with 2913 * one of the proposed suffixes.</p> 2914 * <dl> 2915 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.localSuffixes"</code></dd> 2916 * <dt>Possible values:</dt><dd><code>{ "<suffix>[,<suffix>]*" }</code> where <code><suffix></code> is a String without any wild-card</dd> 2917 * <dt>Default:</dt><dd><code>""</code></dd> 2918 * </dl> 2919 * @since 2.1 2920 * @category CodeAssistOptionID 2921 */ 2922 public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID + ".codeComplete.localSuffixes"; //$NON-NLS-1$ 2923 /** 2924 * Code assist option ID: Define the Suffixes for Argument Name. 2925 * <p>When the suffixes is non empty, completion for argument name will end with 2926 * one of the proposed suffixes.</p> 2927 * <dl> 2928 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.argumentSuffixes"</code></dd> 2929 * <dt>Possible values:</dt><dd><code>{ "<suffix>[,<suffix>]*" }</code> where <code><suffix></code> is a String without any wild-card</dd> 2930 * <dt>Default:</dt><dd><code>""</code></dd> 2931 * </dl> 2932 * @since 2.1 2933 * @category CodeAssistOptionID 2934 */ 2935 public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID + ".codeComplete.argumentSuffixes"; //$NON-NLS-1$ 2936 /** 2937 * Code assist option ID: Activate Forbidden Reference Sensitive Completion. 2938 * <p>When enabled, completion doesn't propose elements which match a 2939 * forbidden reference rule.</p> 2940 * <dl> 2941 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.forbiddenReferenceCheck"</code></dd> 2942 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 2943 * <dt>Default:</dt><dd><code>"enabled"</code></dd> 2944 * </dl> 2945 * @since 3.1 2946 * @category CodeAssistOptionID 2947 */ 2948 public static final String CODEASSIST_FORBIDDEN_REFERENCE_CHECK= PLUGIN_ID + ".codeComplete.forbiddenReferenceCheck"; //$NON-NLS-1$ 2949 /** 2950 * Code assist option ID: Activate Discouraged Reference Sensitive Completion. 2951 * <p>When enabled, completion doesn't propose elements which match a 2952 * discouraged reference rule.</p> 2953 * <dl> 2954 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.discouragedReferenceCheck"</code></dd> 2955 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 2956 * <dt>Default:</dt><dd><code>"disabled"</code></dd> 2957 * </dl> 2958 * @since 3.1 2959 * @category CodeAssistOptionID 2960 */ 2961 public static final String CODEASSIST_DISCOURAGED_REFERENCE_CHECK= PLUGIN_ID + ".codeComplete.discouragedReferenceCheck"; //$NON-NLS-1$ 2962 /** 2963 * Code assist option ID: Activate Suggestion of Static Import. 2964 * <p>When enabled, completion proposals can contain static import 2965 * pattern.</p> 2966 * <dl> 2967 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.suggestStaticImports"</code></dd> 2968 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> 2969 * <dt>Default:</dt><dd><code>"enabled"</code></dd> 2970 * </dl> 2971 * @since 3.3 2972 * @category CodeAssistOptionID 2973 */ 2974 public static final String CODEASSIST_SUGGEST_STATIC_IMPORTS= PLUGIN_ID + ".codeComplete.suggestStaticImports"; //$NON-NLS-1$ 2975 // end configurable option IDs } 2976 // Begin configurable option values { 2977 /** 2978 * @deprecated Use {@link #DEFAULT_TASK_TAGS} instead. 2979 * @since 2.1 2980 * @category DeprecatedOptionValue 2981 */ 2982 public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$ 2983 /** 2984 * @deprecated Use {@link #DEFAULT_TASK_PRIORITIES} instead. 2985 * @since 2.1 2986 * @category DeprecatedOptionValue 2987 */ 2988 public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; //$NON-NLS-1$ 2989 /** 2990 * Configurable option value: {@value}. 2991 * @since 3.0 2992 * @category OptionValue 2993 */ 2994 public static final String DEFAULT_TASK_TAGS = "TODO,FIXME,XXX"; //$NON-NLS-1$ 2995 /** 2996 * Configurable option value: {@value}. 2997 * @since 3.0 2998 * @category OptionValue 2999 */ 3000 public static final String DEFAULT_TASK_PRIORITIES = "NORMAL,HIGH,NORMAL"; //$NON-NLS-1$ 3001 /** 3002 * Configurable option value: {@value}. 3003 * @category OptionValue 3004 */ 3005 public static final String GENERATE = "generate"; //$NON-NLS-1$ 3006 /** 3007 * Configurable option value: {@value}. 3008 * @category OptionValue 3009 */ 3010 public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$ 3011 /** 3012 * Configurable option value: {@value}. 3013 * @category OptionValue 3014 */ 3015 public static final String PRESERVE = "preserve"; //$NON-NLS-1$ 3016 /** 3017 * Configurable option value: {@value}. 3018 * @category OptionValue 3019 */ 3020 public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$ 3021 /** 3022 * Configurable option value for {@link #COMPILER_TASK_PRIORITIES}: {@value}. 3023 * @since 2.1 3024 * @category OptionValue 3025 */ 3026 public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$ 3027 /** 3028 * Configurable option value for {@link #COMPILER_TASK_PRIORITIES}: {@value}. 3029 * @since 2.1 3030 * @category OptionValue 3031 */ 3032 public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$ 3033 /** 3034 * Configurable option value for {@link #COMPILER_TASK_PRIORITIES}: {@value}. 3035 * @since 2.1 3036 * @category OptionValue 3037 */ 3038 public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$ 3039 /** 3040 * Configurable option value: {@value}. 3041 * @category OptionValue 3042 */ 3043 public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$ 3044 /** 3045 * Configurable option value: {@value}. 3046 * @category OptionValue 3047 */ 3048 public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$ 3049 /** 3050 * Configurable option value: {@value}. 3051 * @since 2.0 3052 * @category OptionValue 3053 */ 3054 public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$ 3055 /** 3056 * Configurable option value: {@value}. 3057 * @since 2.0 3058 * @category OptionValue 3059 */ 3060 public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$ 3061 /** 3062 * Configurable option value: {@value}. 3063 * @since 3.0 3064 * @category OptionValue 3065 */ 3066 public static final String VERSION_1_5 = "1.5"; //$NON-NLS-1$ 3067 /** 3068 * Configurable option value: {@value}. 3069 * @since 3.2 3070 * @category OptionValue 3071 */ 3072 public static final String VERSION_1_6 = "1.6"; //$NON-NLS-1$ 3073 /** 3074 * Configurable option value: {@value}. 3075 * @since 3.3 3076 * @category OptionValue 3077 */ 3078 public static final String VERSION_1_7 = "1.7"; //$NON-NLS-1$ 3079 /** 3080 * Configurable option value: {@value}. 3081 * @since 3.10 3082 * @category OptionValue 3083 */ 3084 public static final String VERSION_1_8 = "1.8"; //$NON-NLS-1$ 3085 /** 3086 * Configurable option value: {@value}. 3087 * @since 3.14 3088 * @category OptionValue 3089 */ 3090 public static final String VERSION_9 = "9"; //$NON-NLS-1$ 3091 /** 3092 * Configurable option value: {@value}. 3093 * @since 3.14 3094 * @category OptionValue 3095 */ 3096 public static final String VERSION_10 = "10"; //$NON-NLS-1$ 3097 /** 3098 * Configurable option value: {@value}. 3099 * @since 3.16 3100 * @category OptionValue 3101 */ 3102 public static final String VERSION_11 = "11"; //$NON-NLS-1$ 3103 /** 3104 * Configurable option value: {@value}. 3105 * @since 3.18 3106 * @category OptionValue 3107 */ 3108 public static final String VERSION_12 = "12"; //$NON-NLS-1$ 3109 /** 3110 * Configurable option value: {@value}. 3111 * @since 3.20 3112 * @category OptionValue 3113 */ 3114 public static final String VERSION_13 = "13"; //$NON-NLS-1$ 3115 /** 3116 * Configurable option value: {@value}. 3117 * @since 3.22 3118 * @category OptionValue 3119 */ 3120 public static final String VERSION_14 = "14"; //$NON-NLS-1$ 3121 /** 3122 * Configurable option value: {@value}. 3123 * @since 3.4 3124 * @category OptionValue 3125 */ 3126 public static final String VERSION_CLDC_1_1 = "cldc1.1"; //$NON-NLS-1$ 3127 private static List<String> allVersions = Collections.unmodifiableList(Arrays.asList(VERSION_CLDC_1_1, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5, 3128 VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14)); 3129 3130 /** 3131 * Returns all {@link JavaCore}{@code #VERSION_*} levels in the order of their 3132 * introduction. For e.g., {@link JavaCore#VERSION_1_8} appears before {@link JavaCore#VERSION_10} 3133 * 3134 * @return all available versions 3135 * @since 3.14 3136 */ getAllVersions()3137 public static List<String> getAllVersions() { 3138 return allVersions; 3139 } 3140 3141 /** 3142 * Returns whether the given version of Java or Java Runtime is supported 3143 * by the Java Development Toolkit. 3144 * 3145 * A true indicates that the given version is supported. For e.g., if the argument 3146 * is <code>11.0.1</code> and {@link #getAllVersions()} contains <code>11</code>, 3147 * the method returns <code>true</code>. 3148 * 3149 * @return a boolean indicating support for the given version of Java or Java Runtime. 3150 * @since 3.16 3151 */ isSupportedJavaVersion(String version)3152 public static boolean isSupportedJavaVersion(String version) { 3153 return CompilerOptions.versionToJdkLevel(version, false) > 0; 3154 } 3155 3156 /** 3157 * Configurable option value: {@value}. 3158 * @since 2.0 3159 * @category OptionValue 3160 */ 3161 public static final String ABORT = "abort"; //$NON-NLS-1$ 3162 /** 3163 * Configurable option value: {@value}. 3164 * @category OptionValue 3165 */ 3166 public static final String ERROR = "error"; //$NON-NLS-1$ 3167 /** 3168 * Configurable option value: {@value}. 3169 * @category OptionValue 3170 */ 3171 public static final String WARNING = "warning"; //$NON-NLS-1$ 3172 /** 3173 * Configurable option value: {@value}. 3174 * @category OptionValue 3175 */ 3176 public static final String IGNORE = "ignore"; //$NON-NLS-1$ 3177 /** 3178 * Configurable option value: {@value}. 3179 * @category OptionValue 3180 * @since 3.12 3181 */ 3182 public static final String INFO = "info"; //$NON-NLS-1$ 3183 /** 3184 * Configurable option value: {@value}. 3185 * @category OptionValue 3186 */ 3187 public static final String COMPUTE = "compute"; //$NON-NLS-1$ 3188 /** 3189 * Configurable option value: {@value}. 3190 * @since 2.0 3191 * @category OptionValue 3192 */ 3193 public static final String INSERT = "insert"; //$NON-NLS-1$ 3194 /** 3195 * Configurable option value: {@value}. 3196 * @since 2.0 3197 * @category OptionValue 3198 */ 3199 public static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$ 3200 /** 3201 * Configurable option value: {@value}. 3202 * @since 2.0 3203 * @category OptionValue 3204 */ 3205 public static final String PRESERVE_ONE = "preserve one"; //$NON-NLS-1$ 3206 /** 3207 * Configurable option value: {@value}. 3208 * @since 2.0 3209 * @category OptionValue 3210 */ 3211 public static final String CLEAR_ALL = "clear all"; //$NON-NLS-1$ 3212 /** 3213 * Configurable option value: {@value}. 3214 * @since 2.0 3215 * @category OptionValue 3216 */ 3217 public static final String NORMAL = "normal"; //$NON-NLS-1$ 3218 /** 3219 * Configurable option value: {@value}. 3220 * @since 2.0 3221 * @category OptionValue 3222 */ 3223 public static final String COMPACT = "compact"; //$NON-NLS-1$ 3224 /** 3225 * Configurable option value: {@value}. 3226 * @since 2.0 3227 * @category OptionValue 3228 */ 3229 public static final String TAB = "tab"; //$NON-NLS-1$ 3230 /** 3231 * Configurable option value: {@value}. 3232 * @since 2.0 3233 * @category OptionValue 3234 */ 3235 public static final String SPACE = "space"; //$NON-NLS-1$ 3236 /** 3237 * Configurable option value: {@value}. 3238 * @since 2.0 3239 * @category OptionValue 3240 */ 3241 public static final String ENABLED = "enabled"; //$NON-NLS-1$ 3242 /** 3243 * Configurable option value: {@value}. 3244 * @since 2.0 3245 * @category OptionValue 3246 */ 3247 public static final String DISABLED = "disabled"; //$NON-NLS-1$ 3248 /** 3249 * Configurable option value: {@value}. 3250 * @since 2.1 3251 * @category OptionValue 3252 */ 3253 public static final String CLEAN = "clean"; //$NON-NLS-1$ 3254 /** 3255 * Configurable option value: {@value}. 3256 * @since 3.0 3257 * @category OptionValue 3258 */ 3259 public static final String PUBLIC = "public"; //$NON-NLS-1$ 3260 /** 3261 * Configurable option value: {@value}. 3262 * @since 3.0 3263 * @category OptionValue 3264 */ 3265 public static final String PROTECTED = "protected"; //$NON-NLS-1$ 3266 /** 3267 * Configurable option value: {@value}. 3268 * @since 3.0 3269 * @category OptionValue 3270 */ 3271 public static final String DEFAULT = "default"; //$NON-NLS-1$ 3272 /** 3273 * Configurable option value: {@value}. 3274 * @since 3.0 3275 * @category OptionValue 3276 */ 3277 public static final String PRIVATE = "private"; //$NON-NLS-1$ 3278 /** 3279 * Configurable option value: {@value}. 3280 * @since 3.1 3281 * @category OptionValue 3282 */ 3283 public static final String NEVER = "never"; //$NON-NLS-1$ 3284 /** 3285 * Configurable option value: {@value}. 3286 * @since 3.4 3287 * @category OptionValue 3288 */ 3289 public static final String COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_NO_TAG = CompilerOptions.NO_TAG; 3290 /** 3291 * Configurable option value: {@value}. 3292 * @since 3.4 3293 * @category OptionValue 3294 */ 3295 public static final String COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_RETURN_TAG = CompilerOptions.RETURN_TAG; 3296 /** 3297 * Configurable option value: {@value}. 3298 * @since 3.4 3299 * @category OptionValue 3300 */ 3301 public static final String COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_ALL_STANDARD_TAGS = CompilerOptions.ALL_STANDARD_TAGS; 3302 // end configurable option values } 3303 3304 /** 3305 * Value of the content-type for Java source files. Use this value to retrieve the Java content type 3306 * from the content type manager, and to add new Java-like extensions to this content type. 3307 * 3308 * @see org.eclipse.core.runtime.content.IContentTypeManager#getContentType(String) 3309 * @see #getJavaLikeExtensions() 3310 * @since 3.2 3311 */ 3312 public static final String JAVA_SOURCE_CONTENT_TYPE = JavaCore.PLUGIN_ID+".javaSource" ; //$NON-NLS-1$ 3313 3314 /** 3315 * The ID of the Eclipse built-in formatter. 3316 * 3317 * @see #JAVA_FORMATTER 3318 * @see #JAVA_FORMATTER_EXTENSION_POINT_ID 3319 * @since 3.11 3320 */ 3321 public static final String DEFAULT_JAVA_FORMATTER = PLUGIN_ID + ".defaultJavaFormatter"; //$NON-NLS-1$ 3322 3323 /** 3324 * Name of the extension point for contributing a source code formatter 3325 * @see #JAVA_FORMATTER 3326 * @see #DEFAULT_JAVA_FORMATTER 3327 * @since 3.11 3328 */ 3329 public static final String JAVA_FORMATTER_EXTENSION_POINT_ID = "javaFormatter" ; //$NON-NLS-1$ 3330 3331 /** 3332 * Creates the Java core plug-in. 3333 * <p> 3334 * The plug-in instance is created automatically by the 3335 * Eclipse platform. Clients must not call. 3336 * </p> 3337 * 3338 * @since 3.0 3339 */ JavaCore()3340 public JavaCore() { 3341 super(); 3342 JAVA_CORE_PLUGIN = this; 3343 } 3344 3345 /** 3346 * Adds the given listener for changes to Java elements. 3347 * Has no effect if an identical listener is already registered. 3348 * <p> 3349 * This listener will only be notified during the POST_CHANGE resource change notification 3350 * and any reconcile operation (POST_RECONCILE). 3351 * </p> 3352 * <p> 3353 * For finer control of the notification, use <code>addElementChangedListener(IElementChangedListener,int)</code>, 3354 * which allows to specify a different eventMask. 3355 * </p> 3356 * 3357 * @param listener the listener 3358 * @see ElementChangedEvent 3359 */ addElementChangedListener(IElementChangedListener listener)3360 public static void addElementChangedListener(IElementChangedListener listener) { 3361 addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE | ElementChangedEvent.POST_RECONCILE); 3362 } 3363 3364 /** 3365 * Adds the given listener for changes to Java elements. 3366 * Has no effect if an identical listener is already registered. 3367 * After completion of this method, the given listener will be registered for exactly 3368 * the specified events. If they were previously registered for other events, they 3369 * will be deregistered. 3370 * <p> 3371 * Once registered, a listener starts receiving notification of changes to 3372 * java elements in the model. The listener continues to receive 3373 * notifications until it is replaced or removed. 3374 * </p> 3375 * <p> 3376 * Listeners can listen for several types of event as defined in <code>ElementChangeEvent</code>. 3377 * Clients are free to register for any number of event types however if they register 3378 * for more than one, it is their responsibility to ensure they correctly handle the 3379 * case where the same java element change shows up in multiple notifications. 3380 * Clients are guaranteed to receive only the events for which they are registered. 3381 * </p> 3382 * 3383 * @param listener the listener 3384 * @param eventMask the bit-wise OR of all event types of interest to the listener 3385 * @see IElementChangedListener 3386 * @see ElementChangedEvent 3387 * @see #removeElementChangedListener(IElementChangedListener) 3388 * @since 2.0 3389 */ addElementChangedListener(IElementChangedListener listener, int eventMask)3390 public static void addElementChangedListener(IElementChangedListener listener, int eventMask) { 3391 JavaModelManager.getDeltaState().addElementChangedListener(listener, eventMask); 3392 } 3393 3394 /** 3395 * Configures the given marker attribute map for the given Java element. 3396 * Used for markers, which denote a Java element rather than a resource. 3397 * 3398 * @param attributes the mutable marker attribute map (key type: <code>String</code>, 3399 * value type: <code>String</code>) 3400 * @param element the Java element for which the marker needs to be configured 3401 */ addJavaElementMarkerAttributes( Map attributes, IJavaElement element)3402 public static void addJavaElementMarkerAttributes( 3403 Map attributes, 3404 IJavaElement element) { 3405 if (element instanceof IMember) 3406 element = ((IMember) element).getClassFile(); 3407 if (attributes != null && element != null) 3408 attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier()); 3409 } 3410 addNonJavaResources(Object[] nonJavaResources, IContainer container, int rootPathSegmentCounts, ArrayList collector)3411 private static void addNonJavaResources(Object[] nonJavaResources, 3412 IContainer container, 3413 int rootPathSegmentCounts, 3414 ArrayList collector) { 3415 for (int i = 0, max = nonJavaResources.length; i < max; i++) { 3416 Object nonJavaResource = nonJavaResources[i]; 3417 if (nonJavaResource instanceof IFile) { 3418 IFile file = (IFile) nonJavaResource; 3419 IPath path = file.getFullPath().removeFirstSegments(rootPathSegmentCounts); 3420 IResource member = container.findMember(path); 3421 if (member != null && member.exists()) { 3422 collector.add(member); 3423 } 3424 } else if (nonJavaResource instanceof IFolder) { 3425 IFolder folder = (IFolder) nonJavaResource; 3426 IResource[] members = null; 3427 try { 3428 members = folder.members(); 3429 } catch (CoreException e) { 3430 // ignore 3431 } 3432 if (members != null) { 3433 addNonJavaResources(members, container, rootPathSegmentCounts, collector); 3434 } 3435 } 3436 } 3437 } 3438 3439 /** 3440 * Adds the given listener for POST_CHANGE resource change events to the Java core. 3441 * The listener is guaranteed to be notified of the POST_CHANGE resource change event before 3442 * the Java core starts processing the resource change event itself. 3443 * <p> 3444 * Has no effect if an identical listener is already registered. 3445 * </p> 3446 * 3447 * @param listener the listener 3448 * @see #removePreProcessingResourceChangedListener(IResourceChangeListener) 3449 * @since 3.0 3450 * @deprecated use addPreProcessingResourceChangedListener(listener, IResourceChangeEvent.POST_CHANGE) instead 3451 */ addPreProcessingResourceChangedListener(IResourceChangeListener listener)3452 public static void addPreProcessingResourceChangedListener(IResourceChangeListener listener) { 3453 addPreProcessingResourceChangedListener(listener, IResourceChangeEvent.POST_CHANGE); 3454 } 3455 3456 /** 3457 * Adds the given listener for resource change events of the given types to the Java core. 3458 * The listener is guaranteed to be notified of the resource change event before 3459 * the Java core starts processing the resource change event itself. 3460 * <p> 3461 * If an identical listener is already registered, the given event types are added to the event types 3462 * of interest to the listener. 3463 * </p> 3464 * <p> 3465 * Supported event types are: 3466 * </p> 3467 * <ul> 3468 * <li>{@link IResourceChangeEvent#PRE_BUILD}</li> 3469 * <li>{@link IResourceChangeEvent#POST_BUILD}</li> 3470 * <li>{@link IResourceChangeEvent#POST_CHANGE}</li> 3471 * <li>{@link IResourceChangeEvent#PRE_DELETE}</li> 3472 * <li>{@link IResourceChangeEvent#PRE_CLOSE}</li> 3473 * </ul> 3474 * This list may increase in the future. 3475 * 3476 * @param listener the listener 3477 * @param eventMask the bit-wise OR of all event types of interest to the 3478 * listener 3479 * @see #removePreProcessingResourceChangedListener(IResourceChangeListener) 3480 * @see IResourceChangeEvent 3481 * @since 3.2 3482 */ addPreProcessingResourceChangedListener(IResourceChangeListener listener, int eventMask)3483 public static void addPreProcessingResourceChangedListener(IResourceChangeListener listener, int eventMask) { 3484 JavaModelManager.getDeltaState().addPreResourceChangedListener(listener, eventMask); 3485 } 3486 3487 /** 3488 * Configures the given marker for the given Java element. 3489 * Used for markers, which denote a Java element rather than a resource. 3490 * 3491 * @param marker the marker to be configured 3492 * @param element the Java element for which the marker needs to be configured 3493 * @exception CoreException if the <code>IMarker.setAttribute</code> on the marker fails 3494 */ configureJavaElementMarker(IMarker marker, IJavaElement element)3495 public void configureJavaElementMarker(IMarker marker, IJavaElement element) 3496 throws CoreException { 3497 if (element instanceof IMember) 3498 element = ((IMember) element).getClassFile(); 3499 if (marker != null && element != null) 3500 marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier()); 3501 } 3502 3503 /** 3504 * Returns the Java model element corresponding to the given handle identifier 3505 * generated by <code>IJavaElement.getHandleIdentifier()</code>, or 3506 * <code>null</code> if unable to create the associated element. 3507 * 3508 * @param handleIdentifier the given handle identifier 3509 * @return the Java element corresponding to the handle identifier 3510 */ create(String handleIdentifier)3511 public static IJavaElement create(String handleIdentifier) { 3512 return create(handleIdentifier, DefaultWorkingCopyOwner.PRIMARY); 3513 } 3514 3515 /** 3516 * Returns the Java model element corresponding to the given handle identifier 3517 * generated by <code>IJavaElement.getHandleIdentifier()</code>, or 3518 * <code>null</code> if unable to create the associated element. 3519 * If the returned Java element is an <code>ICompilationUnit</code> or an element 3520 * inside a compilation unit, the compilation unit's owner is the given owner if such a 3521 * working copy exists, otherwise the compilation unit is a primary compilation unit. 3522 * 3523 * @param handleIdentifier the given handle identifier 3524 * @param owner the owner of the returned compilation unit, ignored if the returned 3525 * element is not a compilation unit, or an element inside a compilation unit 3526 * @return the Java element corresponding to the handle identifier 3527 * @since 3.0 3528 */ create(String handleIdentifier, WorkingCopyOwner owner)3529 public static IJavaElement create(String handleIdentifier, WorkingCopyOwner owner) { 3530 if (handleIdentifier == null) { 3531 return null; 3532 } 3533 if (owner == null) 3534 owner = DefaultWorkingCopyOwner.PRIMARY; 3535 MementoTokenizer memento = new MementoTokenizer(handleIdentifier); 3536 JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel(); 3537 return model.getHandleFromMemento(memento, owner); 3538 } 3539 3540 /** 3541 * Returns the Java element corresponding to the given file, or 3542 * <code>null</code> if unable to associate the given file 3543 * with a Java element. 3544 * 3545 * <p>The file must be one of:</p> 3546 * <ul> 3547 * <li>a file with one of the {@link JavaCore#getJavaLikeExtensions() 3548 * Java-like extensions} - the element returned is the corresponding <code>ICompilationUnit</code></li> 3549 * <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li> 3550 * <li>a ZIP archive (e.g. a <code>.jar</code>, a <code>.zip</code> file, etc.) - the element returned is the corresponding <code>IPackageFragmentRoot</code></li> 3551 * </ul> 3552 * <p> 3553 * Creating a Java element has the side effect of creating and opening all of the 3554 * element's parents if they are not yet open. 3555 * </p> 3556 * 3557 * @param file the given file 3558 * @return the Java element corresponding to the given file, or 3559 * <code>null</code> if unable to associate the given file 3560 * with a Java element 3561 */ create(IFile file)3562 public static IJavaElement create(IFile file) { 3563 return JavaModelManager.create(file, null/*unknown java project*/); 3564 } 3565 /** 3566 * Returns the package fragment or package fragment root corresponding to the given folder, or 3567 * <code>null</code> if unable to associate the given folder with a Java element. 3568 * <p> 3569 * Note that a package fragment root is returned rather than a default package. 3570 * </p> 3571 * <p> 3572 * Creating a Java element has the side effect of creating and opening all of the 3573 * element's parents if they are not yet open. 3574 * </p> 3575 * 3576 * @param folder the given folder 3577 * @return the package fragment or package fragment root corresponding to the given folder, or 3578 * <code>null</code> if unable to associate the given folder with a Java element 3579 */ create(IFolder folder)3580 public static IJavaElement create(IFolder folder) { 3581 return JavaModelManager.create(folder, null/*unknown java project*/); 3582 } 3583 /** 3584 * Returns the Java project corresponding to the given project. 3585 * <p> 3586 * Creating a Java Project has the side effect of creating and opening all of the 3587 * project's parents if they are not yet open. 3588 * </p> 3589 * <p> 3590 * Note that no check is done at this time on the existence or the java nature of this project. 3591 * </p> 3592 * 3593 * @param project the given project 3594 * @return the Java project corresponding to the given project, null if the given project is null 3595 */ create(IProject project)3596 public static IJavaProject create(IProject project) { 3597 if (project == null) { 3598 return null; 3599 } 3600 JavaModel javaModel = JavaModelManager.getJavaModelManager().getJavaModel(); 3601 return javaModel.getJavaProject(project); 3602 } 3603 /** 3604 * Returns the Java element corresponding to the given resource, or 3605 * <code>null</code> if unable to associate the given resource 3606 * with a Java element. 3607 * <p> 3608 * The resource must be one of: 3609 * </p> 3610 * <ul> 3611 * <li>a project - the element returned is the corresponding <code>IJavaProject</code></li> 3612 * <li>a file with one of the {@link JavaCore#getJavaLikeExtensions() 3613 * Java-like extensions} - the element returned is the corresponding <code>ICompilationUnit</code></li> 3614 * <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li> 3615 * <li>a ZIP archive (e.g. a <code>.jar</code>, a <code>.zip</code> file, etc.) - the element returned is the corresponding <code>IPackageFragmentRoot</code></li> 3616 * <li>a folder - the element returned is the corresponding <code>IPackageFragmentRoot</code> 3617 * or <code>IPackageFragment</code></li> 3618 * <li>the workspace root resource - the element returned is the <code>IJavaModel</code></li> 3619 * </ul> 3620 * <p> 3621 * Creating a Java element has the side effect of creating and opening all of the 3622 * element's parents if they are not yet open. 3623 * </p> 3624 * 3625 * @param resource the given resource 3626 * @return the Java element corresponding to the given resource, or 3627 * <code>null</code> if unable to associate the given resource 3628 * with a Java element 3629 */ create(IResource resource)3630 public static IJavaElement create(IResource resource) { 3631 return JavaModelManager.create(resource, null/*unknown java project*/); 3632 } 3633 /** 3634 * Returns the Java element corresponding to the given file, its project being the given 3635 * project. Returns <code>null</code> if unable to associate the given resource 3636 * with a Java element. 3637 * <p> 3638 * The resource must be one of: 3639 * </p> 3640 * <ul> 3641 * <li>a project - the element returned is the corresponding <code>IJavaProject</code></li> 3642 * <li>a file with one of the {@link JavaCore#getJavaLikeExtensions() 3643 * Java-like extensions} - the element returned is the corresponding <code>ICompilationUnit</code></li> 3644 * <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li> 3645 * <li>a ZIP archive (e.g. a <code>.jar</code>, a <code>.zip</code> file, etc.) - the element returned is the corresponding <code>IPackageFragmentRoot</code></li> 3646 * <li>a folder - the element returned is the corresponding <code>IPackageFragmentRoot</code> 3647 * or <code>IPackageFragment</code></li> 3648 * <li>the workspace root resource - the element returned is the <code>IJavaModel</code></li> 3649 * </ul> 3650 * <p> 3651 * Creating a Java element has the side effect of creating and opening all of the 3652 * element's parents if they are not yet open. 3653 * </p> 3654 * 3655 * @param resource the given resource 3656 * @return the Java element corresponding to the given file, or 3657 * <code>null</code> if unable to associate the given file 3658 * with a Java element 3659 * @since 3.3 3660 */ create(IResource resource, IJavaProject project)3661 public static IJavaElement create(IResource resource, IJavaProject project) { 3662 return JavaModelManager.create(resource, project); 3663 } 3664 /** 3665 * Returns the Java model. 3666 * 3667 * @param root the given root 3668 * @return the Java model, or <code>null</code> if the root is null 3669 */ create(IWorkspaceRoot root)3670 public static IJavaModel create(IWorkspaceRoot root) { 3671 if (root == null) { 3672 return null; 3673 } 3674 return JavaModelManager.getJavaModelManager().getJavaModel(); 3675 } 3676 /** 3677 * Creates and returns a class file element for 3678 * the given <code>.class</code> file. Returns <code>null</code> if unable 3679 * to recognize the class file. 3680 * 3681 * @param file the given <code>.class</code> file 3682 * @return a class file element for the given <code>.class</code> file, or <code>null</code> if unable 3683 * to recognize the class file 3684 */ createClassFileFrom(IFile file)3685 public static IClassFile createClassFileFrom(IFile file) { 3686 return JavaModelManager.createClassFileFrom(file, null); 3687 } 3688 /** 3689 * Creates and returns a compilation unit element for 3690 * the given source file (i.e. a file with one of the {@link JavaCore#getJavaLikeExtensions() 3691 * Java-like extensions}). Returns <code>null</code> if unable 3692 * to recognize the compilation unit. 3693 * 3694 * @param file the given source file 3695 * @return a compilation unit element for the given source file, or <code>null</code> if unable 3696 * to recognize the compilation unit 3697 */ createCompilationUnitFrom(IFile file)3698 public static ICompilationUnit createCompilationUnitFrom(IFile file) { 3699 return JavaModelManager.createCompilationUnitFrom(file, null/*unknown java project*/); 3700 } 3701 /** 3702 * Creates and returns a handle for the given JAR file. 3703 * The Java model associated with the JAR's project may be 3704 * created as a side effect. 3705 * 3706 * @param file the given JAR file 3707 * @return a handle for the given JAR file, or <code>null</code> if unable to create a JAR package fragment root. 3708 * (for example, if the JAR file represents a non-Java resource) 3709 */ createJarPackageFragmentRootFrom(IFile file)3710 public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile file) { 3711 return JavaModelManager.createJarPackageFragmentRootFrom(file, null/*unknown java project*/); 3712 } 3713 3714 /** 3715 * Answers the project specific value for a given classpath container. 3716 * In case this container path could not be resolved, then will answer <code>null</code>. 3717 * Both the container path and the project context are supposed to be non-null. 3718 * <p> 3719 * The containerPath is a formed by a first ID segment followed with extra segments, which can be 3720 * used as additional hints for resolution. If no container was ever recorded for this container path 3721 * onto this project (using <code>setClasspathContainer</code>, then a 3722 * <code>ClasspathContainerInitializer</code> will be activated if any was registered for this container 3723 * ID onto the extension point "org.eclipse.jdt.core.classpathContainerInitializer". 3724 * </p> 3725 * <p> 3726 * There is no assumption that the returned container must answer the exact same containerPath 3727 * when requested <code>IClasspathContainer#getPath</code>. 3728 * Indeed, the containerPath is just an indication for resolving it to an actual container object. 3729 * </p> 3730 * <p> 3731 * Classpath container values are persisted locally to the workspace, but 3732 * are not preserved from a session to another. It is thus highly recommended to register a 3733 * <code>ClasspathContainerInitializer</code> for each referenced container 3734 * (through the extension point "org.eclipse.jdt.core.ClasspathContainerInitializer"). 3735 * </p> 3736 * 3737 * @param containerPath the name of the container, which needs to be resolved 3738 * @param project a specific project in which the container is being resolved 3739 * @return the corresponding classpath container or <code>null</code> if unable to find one. 3740 * 3741 * @exception JavaModelException if an exception occurred while resolving the container, or if the resolved container 3742 * contains illegal entries (contains CPE_CONTAINER entries or null entries). 3743 * 3744 * @see ClasspathContainerInitializer 3745 * @see IClasspathContainer 3746 * @see #setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor) 3747 * @since 2.0 3748 */ getClasspathContainer(IPath containerPath, IJavaProject project)3749 public static IClasspathContainer getClasspathContainer(IPath containerPath, IJavaProject project) throws JavaModelException { 3750 3751 JavaModelManager manager = JavaModelManager.getJavaModelManager(); 3752 IClasspathContainer container = manager.getClasspathContainer(containerPath, project); 3753 if (container == JavaModelManager.CONTAINER_INITIALIZATION_IN_PROGRESS) { 3754 return manager.getPreviousSessionContainer(containerPath, project); 3755 } 3756 return container; 3757 } 3758 3759 /** 3760 * Helper method finding the classpath container initializer registered for a given classpath container ID 3761 * or <code>null</code> if none was found while iterating over the contributions to extension point to 3762 * the extension point "org.eclipse.jdt.core.classpathContainerInitializer". 3763 * <p> 3764 * A containerID is the first segment of any container path, used to identify the registered container initializer. 3765 * </p> 3766 * @param containerID - a containerID identifying a registered initializer 3767 * @return ClasspathContainerInitializer - the registered classpath container initializer or <code>null</code> if 3768 * none was found. 3769 * @since 2.1 3770 */ getClasspathContainerInitializer(String containerID)3771 public static ClasspathContainerInitializer getClasspathContainerInitializer(String containerID) { 3772 Hashtable containerInitializersCache = JavaModelManager.getJavaModelManager().containerInitializersCache; 3773 ClasspathContainerInitializer initializer = (ClasspathContainerInitializer) containerInitializersCache.get(containerID); 3774 if (initializer == null) { 3775 initializer = computeClasspathContainerInitializer(containerID); 3776 if (initializer == null) 3777 return null; 3778 containerInitializersCache.put(containerID, initializer); 3779 } 3780 return initializer; 3781 } 3782 computeClasspathContainerInitializer(String containerID)3783 private static ClasspathContainerInitializer computeClasspathContainerInitializer(String containerID) { 3784 Plugin jdtCorePlugin = JavaCore.getPlugin(); 3785 if (jdtCorePlugin == null) return null; 3786 3787 IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(JavaCore.PLUGIN_ID, JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID); 3788 if (extension != null) { 3789 IExtension[] extensions = extension.getExtensions(); 3790 for(int i = 0; i < extensions.length; i++){ 3791 IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); 3792 for(int j = 0; j < configElements.length; j++){ 3793 IConfigurationElement configurationElement = configElements[j]; 3794 String initializerID = configurationElement.getAttribute("id"); //$NON-NLS-1$ 3795 if (initializerID != null && initializerID.equals(containerID)){ 3796 if (JavaModelManager.CP_RESOLVE_VERBOSE_ADVANCED) 3797 verbose_found_container_initializer(containerID, configurationElement); 3798 try { 3799 Object execExt = configurationElement.createExecutableExtension("class"); //$NON-NLS-1$ 3800 if (execExt instanceof ClasspathContainerInitializer){ 3801 return (ClasspathContainerInitializer)execExt; 3802 } 3803 } catch(CoreException e) { 3804 // executable extension could not be created: ignore this initializer 3805 if (JavaModelManager.CP_RESOLVE_VERBOSE || JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { 3806 verbose_failed_to_instanciate_container_initializer(containerID, configurationElement); 3807 e.printStackTrace(); 3808 } 3809 } 3810 } 3811 } 3812 } 3813 } 3814 return null; 3815 } 3816 verbose_failed_to_instanciate_container_initializer(String containerID, IConfigurationElement configurationElement)3817 private static void verbose_failed_to_instanciate_container_initializer(String containerID, IConfigurationElement configurationElement) { 3818 Util.verbose( 3819 "CPContainer INIT - failed to instanciate initializer\n" + //$NON-NLS-1$ 3820 " container ID: " + containerID + '\n' + //$NON-NLS-1$ 3821 " class: " + configurationElement.getAttribute("class"), //$NON-NLS-1$ //$NON-NLS-2$ 3822 System.err); 3823 } 3824 verbose_found_container_initializer(String containerID, IConfigurationElement configurationElement)3825 private static void verbose_found_container_initializer(String containerID, IConfigurationElement configurationElement) { 3826 Util.verbose( 3827 "CPContainer INIT - found initializer\n" + //$NON-NLS-1$ 3828 " container ID: " + containerID + '\n' + //$NON-NLS-1$ 3829 " class: " + configurationElement.getAttribute("class")); //$NON-NLS-1$ //$NON-NLS-2$ 3830 } 3831 3832 /** 3833 * Returns the path held in the given classpath variable. 3834 * Returns <code>null</code> if unable to bind. 3835 * <p> 3836 * Classpath variable values are persisted locally to the workspace, and 3837 * are preserved from session to session. 3838 * </p> 3839 * <p> 3840 * Note that classpath variables can be contributed registered initializers for, 3841 * using the extension point "org.eclipse.jdt.core.classpathVariableInitializer". 3842 * If an initializer is registered for a variable, its persisted value will be ignored: 3843 * its initializer will thus get the opportunity to rebind the variable differently on 3844 * each session. 3845 * </p> 3846 * 3847 * @param variableName the name of the classpath variable 3848 * @return the path, or <code>null</code> if none 3849 * @see #setClasspathVariable(String, IPath) 3850 */ getClasspathVariable(final String variableName)3851 public static IPath getClasspathVariable(final String variableName) { 3852 3853 JavaModelManager manager = JavaModelManager.getJavaModelManager(); 3854 IPath variablePath = manager.variableGet(variableName); 3855 if (variablePath == JavaModelManager.VARIABLE_INITIALIZATION_IN_PROGRESS){ 3856 return manager.getPreviousSessionVariable(variableName); 3857 } 3858 3859 if (variablePath != null) { 3860 if (variablePath == JavaModelManager.CP_ENTRY_IGNORE_PATH) 3861 return null; 3862 return variablePath; 3863 } 3864 3865 // even if persisted value exists, initializer is given priority, only if no initializer is found the persisted value is reused 3866 final ClasspathVariableInitializer initializer = JavaCore.getClasspathVariableInitializer(variableName); 3867 if (initializer != null){ 3868 if (JavaModelManager.CP_RESOLVE_VERBOSE) 3869 verbose_triggering_variable_initialization(variableName, initializer); 3870 if (JavaModelManager.CP_RESOLVE_VERBOSE_ADVANCED) 3871 verbose_triggering_variable_initialization_invocation_trace(); 3872 manager.variablePut(variableName, JavaModelManager.VARIABLE_INITIALIZATION_IN_PROGRESS); // avoid initialization cycles 3873 boolean ok = false; 3874 try { 3875 // let OperationCanceledException go through 3876 // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59363) 3877 initializer.initialize(variableName); 3878 3879 variablePath = manager.variableGet(variableName); // initializer should have performed side-effect 3880 if (variablePath == JavaModelManager.VARIABLE_INITIALIZATION_IN_PROGRESS) return null; // break cycle (initializer did not init or reentering call) 3881 if (JavaModelManager.CP_RESOLVE_VERBOSE_ADVANCED) 3882 verbose_variable_value_after_initialization(variableName, variablePath); 3883 manager.variablesWithInitializer.add(variableName); 3884 ok = true; 3885 } catch (RuntimeException | Error e) { 3886 if (JavaModelManager.CP_RESOLVE_VERBOSE || JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) 3887 e.printStackTrace(); 3888 throw e; 3889 } finally { 3890 if (!ok) JavaModelManager.getJavaModelManager().variablePut(variableName, null); // flush cache 3891 } 3892 } else { 3893 if (JavaModelManager.CP_RESOLVE_VERBOSE_ADVANCED || JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) 3894 verbose_no_variable_initializer_found(variableName); 3895 } 3896 return variablePath; 3897 } 3898 verbose_no_variable_initializer_found(String variableName)3899 private static void verbose_no_variable_initializer_found(String variableName) { 3900 Util.verbose( 3901 "CPVariable INIT - no initializer found\n" + //$NON-NLS-1$ 3902 " variable: " + variableName); //$NON-NLS-1$ 3903 } 3904 verbose_variable_value_after_initialization(String variableName, IPath variablePath)3905 private static void verbose_variable_value_after_initialization(String variableName, IPath variablePath) { 3906 Util.verbose( 3907 "CPVariable INIT - after initialization\n" + //$NON-NLS-1$ 3908 " variable: " + variableName +'\n' + //$NON-NLS-1$ 3909 " variable path: " + variablePath); //$NON-NLS-1$ 3910 } 3911 verbose_triggering_variable_initialization(String variableName, ClasspathVariableInitializer initializer)3912 private static void verbose_triggering_variable_initialization(String variableName, ClasspathVariableInitializer initializer) { 3913 Util.verbose( 3914 "CPVariable INIT - triggering initialization\n" + //$NON-NLS-1$ 3915 " variable: " + variableName + '\n' + //$NON-NLS-1$ 3916 " initializer: " + initializer); //$NON-NLS-1$ 3917 } 3918 verbose_triggering_variable_initialization_invocation_trace()3919 private static void verbose_triggering_variable_initialization_invocation_trace() { 3920 Util.verbose( 3921 "CPVariable INIT - triggering initialization\n" + //$NON-NLS-1$ 3922 " invocation trace:"); //$NON-NLS-1$ 3923 new Exception("<Fake exception>").printStackTrace(System.out); //$NON-NLS-1$ 3924 } 3925 3926 /** 3927 * Returns deprecation message of a given classpath variable. 3928 * 3929 * @param variableName 3930 * @return A string if the classpath variable is deprecated, <code>null</code> otherwise. 3931 * @since 3.3 3932 */ getClasspathVariableDeprecationMessage(String variableName)3933 public static String getClasspathVariableDeprecationMessage(String variableName) { 3934 JavaModelManager manager = JavaModelManager.getJavaModelManager(); 3935 3936 // Returns the stored deprecation message 3937 String message = manager.deprecatedVariables.get(variableName); 3938 if (message != null) { 3939 return message; 3940 } 3941 3942 // If the variable has been already initialized, then there's no deprecation message 3943 IPath variablePath = manager.variableGet(variableName); 3944 if (variablePath != null && variablePath != JavaModelManager.VARIABLE_INITIALIZATION_IN_PROGRESS) { 3945 return null; 3946 } 3947 3948 // Search for extension point to get the possible deprecation message 3949 Plugin jdtCorePlugin = JavaCore.getPlugin(); 3950 if (jdtCorePlugin == null) return null; 3951 3952 IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(JavaCore.PLUGIN_ID, JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID); 3953 if (extension != null) { 3954 IExtension[] extensions = extension.getExtensions(); 3955 for(int i = 0; i < extensions.length; i++){ 3956 IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); 3957 for(int j = 0; j < configElements.length; j++){ 3958 IConfigurationElement configElement = configElements[j]; 3959 String varAttribute = configElement.getAttribute("variable"); //$NON-NLS-1$ 3960 if (variableName.equals(varAttribute)) { 3961 String deprecatedAttribute = configElement.getAttribute("deprecated"); //$NON-NLS-1$ 3962 if (deprecatedAttribute != null) { 3963 return deprecatedAttribute; 3964 } 3965 } 3966 } 3967 } 3968 } 3969 return null; 3970 } 3971 3972 /** 3973 * Helper method finding the classpath variable initializer registered for a given classpath variable name 3974 * or <code>null</code> if none was found while iterating over the contributions to extension point to 3975 * the extension point "org.eclipse.jdt.core.classpathVariableInitializer". 3976 * 3977 * @param variable the given variable 3978 * @return ClasspathVariableInitializer - the registered classpath variable initializer or <code>null</code> if 3979 * none was found. 3980 * @since 2.1 3981 */ getClasspathVariableInitializer(String variable)3982 public static ClasspathVariableInitializer getClasspathVariableInitializer(String variable){ 3983 3984 Plugin jdtCorePlugin = JavaCore.getPlugin(); 3985 if (jdtCorePlugin == null) return null; 3986 3987 IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(JavaCore.PLUGIN_ID, JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID); 3988 if (extension != null) { 3989 IExtension[] extensions = extension.getExtensions(); 3990 for(int i = 0; i < extensions.length; i++){ 3991 IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); 3992 for(int j = 0; j < configElements.length; j++){ 3993 IConfigurationElement configElement = configElements[j]; 3994 try { 3995 String varAttribute = configElement.getAttribute("variable"); //$NON-NLS-1$ 3996 if (variable.equals(varAttribute)) { 3997 if (JavaModelManager.CP_RESOLVE_VERBOSE_ADVANCED) 3998 verbose_found_variable_initializer(variable, configElement); 3999 Object execExt = configElement.createExecutableExtension("class"); //$NON-NLS-1$ 4000 if (execExt instanceof ClasspathVariableInitializer){ 4001 ClasspathVariableInitializer initializer = (ClasspathVariableInitializer)execExt; 4002 String deprecatedAttribute = configElement.getAttribute("deprecated"); //$NON-NLS-1$ 4003 if (deprecatedAttribute != null) { 4004 JavaModelManager.getJavaModelManager().deprecatedVariables.put(variable, deprecatedAttribute); 4005 } 4006 String readOnlyAttribute = configElement.getAttribute("readOnly"); //$NON-NLS-1$ 4007 if (JavaModelManager.TRUE.equals(readOnlyAttribute)) { 4008 JavaModelManager.getJavaModelManager().readOnlyVariables.add(variable); 4009 } 4010 return initializer; 4011 } 4012 } 4013 } catch(CoreException e){ 4014 // executable extension could not be created: ignore this initializer 4015 if (JavaModelManager.CP_RESOLVE_VERBOSE || JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { 4016 verbose_failed_to_instanciate_variable_initializer(variable, configElement); 4017 e.printStackTrace(); 4018 } 4019 } 4020 } 4021 } 4022 } 4023 return null; 4024 } 4025 verbose_failed_to_instanciate_variable_initializer(String variable, IConfigurationElement configElement)4026 private static void verbose_failed_to_instanciate_variable_initializer(String variable, IConfigurationElement configElement) { 4027 Util.verbose( 4028 "CPContainer INIT - failed to instanciate initializer\n" + //$NON-NLS-1$ 4029 " variable: " + variable + '\n' + //$NON-NLS-1$ 4030 " class: " + configElement.getAttribute("class"), //$NON-NLS-1$ //$NON-NLS-2$ 4031 System.err); 4032 } 4033 verbose_found_variable_initializer(String variable, IConfigurationElement configElement)4034 private static void verbose_found_variable_initializer(String variable, IConfigurationElement configElement) { 4035 Util.verbose( 4036 "CPVariable INIT - found initializer\n" + //$NON-NLS-1$ 4037 " variable: " + variable + '\n' + //$NON-NLS-1$ 4038 " class: " + configElement.getAttribute("class")); //$NON-NLS-1$ //$NON-NLS-2$ 4039 } 4040 4041 /** 4042 * Returns the names of all known classpath variables. 4043 * <p> 4044 * Classpath variable values are persisted locally to the workspace, and 4045 * are preserved from session to session. 4046 * </p> 4047 * 4048 * @return the list of classpath variable names 4049 * @see #setClasspathVariable(String, IPath) 4050 */ getClasspathVariableNames()4051 public static String[] getClasspathVariableNames() { 4052 return JavaModelManager.getJavaModelManager().variableNames(); 4053 } 4054 4055 /** 4056 * Returns a table of all known configurable options with their default values. 4057 * These options allow to configure the behaviour of the underlying components. 4058 * The client may safely use the result as a template that they can modify and 4059 * then pass to <code>setOptions</code>. 4060 * <p> 4061 * Helper constants have been defined on JavaCore for each of the option IDs 4062 * (categorized in Code assist option ID, Compiler option ID and Core option ID) 4063 * and some of their acceptable values (categorized in Option value). Some 4064 * options accept open value sets beyond the documented constant values. 4065 * </p> 4066 * <p> 4067 * Note: each release may add new options. 4068 * </p> 4069 * 4070 * @return a table of all known configurable options with their default values 4071 */ getDefaultOptions()4072 public static Hashtable<String, String> getDefaultOptions(){ 4073 return JavaModelManager.getJavaModelManager().getDefaultOptions(); 4074 } 4075 4076 /** 4077 * Returns the workspace root default charset encoding. 4078 * 4079 * @return the name of the default charset encoding for workspace root. 4080 * @see IContainer#getDefaultCharset() 4081 * @see ResourcesPlugin#getEncoding() 4082 * @since 3.0 4083 */ getEncoding()4084 public static String getEncoding() { 4085 try { 4086 return ResourcesPlugin.getWorkspace().getRoot().getDefaultCharset(); 4087 } 4088 catch (IllegalStateException ise) { 4089 // happen when there's no workspace (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=216817) 4090 // or when it is shutting down (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=60687) 4091 return System.getProperty("file.encoding"); //$NON-NLS-1$ 4092 } 4093 catch (CoreException ce) { 4094 // fails silently and return plugin global encoding if core exception occurs 4095 } 4096 return ResourcesPlugin.getEncoding(); 4097 } 4098 4099 /** 4100 * Returns an array that contains the resources generated by the Java builder when building the 4101 * compilation units contained in the given region. 4102 * <p>The contents of the array is accurate only if the elements of the given region have been built.</p> 4103 * <p>The given region can contain instances of:</p> 4104 * <ul> 4105 * <li><code>org.eclipse.jdt.core.ICompilationUnit</code></li> 4106 * <li><code>org.eclipse.jdt.core.IPackageFragment</code></li> 4107 * <li><code>org.eclipse.jdt.core.IPackageFragmentRoot</code></li> 4108 * <li><code>org.eclipse.jdt.core.IJavaProject</code></li> 4109 * </ul> 4110 * <p>All other types of <code>org.eclipse.jdt.core.IJavaElement</code> are ignored.</p> 4111 * 4112 * @param region the given region 4113 * @param includesNonJavaResources a flag that indicates if non-java resources should be included 4114 * 4115 * @return an array that contains the resources generated by the Java builder when building the 4116 * compilation units contained in the given region, an empty array if none 4117 * @exception IllegalArgumentException if the given region is <code>null</code> 4118 * @since 3.3 4119 */ getGeneratedResources(IRegion region, boolean includesNonJavaResources)4120 public static IResource[] getGeneratedResources(IRegion region, boolean includesNonJavaResources) { 4121 if (region == null) throw new IllegalArgumentException("region cannot be null"); //$NON-NLS-1$ 4122 IJavaElement[] elements = region.getElements(); 4123 HashMap projectsStates = new HashMap(); 4124 ArrayList collector = new ArrayList(); 4125 for (int i = 0, max = elements.length; i < max; i++) { 4126 // collect all the java project 4127 IJavaElement element = elements[i]; 4128 IJavaProject javaProject = element.getJavaProject(); 4129 IProject project = javaProject.getProject(); 4130 State state = null; 4131 State currentState = (State) projectsStates.get(project); 4132 if (currentState != null) { 4133 state = currentState; 4134 } else { 4135 state = (State) JavaModelManager.getJavaModelManager().getLastBuiltState(project, null); 4136 if (state != null) { 4137 projectsStates.put(project, state); 4138 } 4139 } 4140 if (state == null) continue; 4141 if (element.getElementType() == IJavaElement.JAVA_PROJECT) { 4142 IPackageFragmentRoot[] roots = null; 4143 try { 4144 roots = javaProject.getPackageFragmentRoots(); 4145 } catch (JavaModelException e) { 4146 // ignore 4147 } 4148 if (roots == null) continue; 4149 IRegion region2 = JavaCore.newRegion(); 4150 for (int j = 0; j < roots.length; j++) { 4151 region2.add(roots[j]); 4152 } 4153 IResource[] res = getGeneratedResources(region2, includesNonJavaResources); 4154 for (int j = 0, max2 = res.length; j < max2; j++) { 4155 collector.add(res[j]); 4156 } 4157 continue; 4158 } 4159 IPath outputLocation = null; 4160 try { 4161 outputLocation = javaProject.getOutputLocation(); 4162 } catch (JavaModelException e) { 4163 // ignore 4164 } 4165 IJavaElement root = element; 4166 while (root != null && root.getElementType() != IJavaElement.PACKAGE_FRAGMENT_ROOT) { 4167 root = root.getParent(); 4168 } 4169 if (root == null) continue; 4170 IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) root; 4171 int rootPathSegmentCounts = packageFragmentRoot.getPath().segmentCount(); 4172 try { 4173 IClasspathEntry entry = packageFragmentRoot.getRawClasspathEntry(); 4174 IPath entryOutputLocation = entry.getOutputLocation(); 4175 if (entryOutputLocation != null) { 4176 outputLocation = entryOutputLocation; 4177 } 4178 } catch (JavaModelException e) { 4179 e.printStackTrace(); 4180 } 4181 if (outputLocation == null) continue; 4182 IContainer container = (IContainer) project.getWorkspace().getRoot().findMember(outputLocation); 4183 switch(element.getElementType()) { 4184 case IJavaElement.COMPILATION_UNIT : 4185 // get the .class files generated when this element was built 4186 ICompilationUnit unit = (ICompilationUnit) element; 4187 getGeneratedResource(unit, container, state, rootPathSegmentCounts, collector); 4188 break; 4189 case IJavaElement.PACKAGE_FRAGMENT : 4190 // collect all the .class files generated when all the units in this package were built 4191 IPackageFragment fragment = (IPackageFragment) element; 4192 ICompilationUnit[] compilationUnits = null; 4193 try { 4194 compilationUnits = fragment.getCompilationUnits(); 4195 } catch (JavaModelException e) { 4196 // ignore 4197 } 4198 if (compilationUnits == null) continue; 4199 for (int j = 0, max2 = compilationUnits.length; j < max2; j++) { 4200 getGeneratedResource(compilationUnits[j], container, state, rootPathSegmentCounts, collector); 4201 } 4202 if (includesNonJavaResources) { 4203 // retrieve all non-java resources from the output location using the package fragment path 4204 Object[] nonJavaResources = null; 4205 try { 4206 nonJavaResources = fragment.getNonJavaResources(); 4207 } catch (JavaModelException e) { 4208 // ignore 4209 } 4210 if (nonJavaResources != null) { 4211 addNonJavaResources(nonJavaResources, container, rootPathSegmentCounts, collector); 4212 } 4213 } 4214 break; 4215 case IJavaElement.PACKAGE_FRAGMENT_ROOT : 4216 // collect all the .class files generated when all the units in this package were built 4217 IPackageFragmentRoot fragmentRoot = (IPackageFragmentRoot) element; 4218 if (fragmentRoot.isArchive()) continue; 4219 IJavaElement[] children = null; 4220 try { 4221 children = fragmentRoot.getChildren(); 4222 } catch (JavaModelException e) { 4223 // ignore 4224 } 4225 if (children == null) continue; 4226 for (int j = 0, max2 = children.length; j < max2; j++) { 4227 fragment = (IPackageFragment) children[j]; 4228 ICompilationUnit[] units = null; 4229 try { 4230 units = fragment.getCompilationUnits(); 4231 } catch (JavaModelException e) { 4232 // ignore 4233 } 4234 if (units == null) continue; 4235 for (int n = 0, max3 = units.length; n < max3; n++) { 4236 getGeneratedResource(units[n], container, state, rootPathSegmentCounts, collector); 4237 } 4238 if (includesNonJavaResources) { 4239 // retrieve all non-java resources from the output location using the package fragment path 4240 Object[] nonJavaResources = null; 4241 try { 4242 nonJavaResources = fragment.getNonJavaResources(); 4243 } catch (JavaModelException e) { 4244 // ignore 4245 } 4246 if (nonJavaResources != null) { 4247 addNonJavaResources(nonJavaResources, container, rootPathSegmentCounts, collector); 4248 } 4249 } 4250 } 4251 break; 4252 } 4253 } 4254 int size = collector.size(); 4255 if (size != 0) { 4256 IResource[] result = new IResource[size]; 4257 collector.toArray(result); 4258 return result; 4259 } 4260 return NO_GENERATED_RESOURCES; 4261 } 4262 getGeneratedResource(ICompilationUnit unit, IContainer container, State state, int rootPathSegmentCounts, ArrayList collector)4263 private static void getGeneratedResource(ICompilationUnit unit, 4264 IContainer container, 4265 State state, 4266 int rootPathSegmentCounts, 4267 ArrayList collector) { 4268 IResource resource = unit.getResource(); 4269 char[][] typeNames = state.getDefinedTypeNamesFor(resource.getProjectRelativePath().toString()); 4270 if (typeNames != null) { 4271 IPath path = unit.getPath().removeFirstSegments(rootPathSegmentCounts).removeLastSegments(1); 4272 for (int j = 0, max2 = typeNames.length; j < max2; j++) { 4273 IPath localPath = path.append(new String(typeNames[j]) + ".class"); //$NON-NLS-1$ 4274 IResource member = container.findMember(localPath); 4275 if (member != null && member.exists()) { 4276 collector.add(member); 4277 } 4278 } 4279 } else { 4280 IPath path = unit.getPath().removeFirstSegments(rootPathSegmentCounts).removeLastSegments(1); 4281 path = path.append(Util.getNameWithoutJavaLikeExtension(unit.getElementName()) + ".class"); //$NON-NLS-1$ 4282 IResource member = container.findMember(path); 4283 if (member != null && member.exists()) { 4284 collector.add(member); 4285 } 4286 } 4287 } 4288 4289 /** 4290 * Returns the single instance of the Java core plug-in runtime class. 4291 * Equivalent to <code>(JavaCore) getPlugin()</code>. 4292 * 4293 * @return the single instance of the Java core plug-in runtime class 4294 */ getJavaCore()4295 public static JavaCore getJavaCore() { 4296 return (JavaCore) getPlugin(); 4297 } 4298 4299 /** 4300 * Returns the list of known Java-like extensions. 4301 * Java like extension are defined in the {@link org.eclipse.core.runtime.Platform#getContentTypeManager() 4302 * content type manager} for the {@link #JAVA_SOURCE_CONTENT_TYPE}. 4303 * <p> 4304 * Note that a Java-like extension doesn't include the leading dot ('.'). 4305 * Also note that the "java" extension is always defined as a Java-like extension. 4306 * </p> 4307 * 4308 * @return the list of known Java-like extensions. 4309 * @since 3.2 4310 */ getJavaLikeExtensions()4311 public static String[] getJavaLikeExtensions() { 4312 return CharOperation.toStrings(Util.getJavaLikeExtensions()); 4313 } 4314 4315 /** 4316 * Helper method for returning one option value only. Equivalent to <code>(String)JavaCore.getOptions().get(optionName)</code> 4317 * Note that it may answer <code>null</code> if this option does not exist. 4318 * <p> 4319 * Helper constants have been defined on JavaCore for each of the option IDs 4320 * (categorized in Code assist option ID, Compiler option ID and Core option ID) 4321 * and some of their acceptable values (categorized in Option value). Some 4322 * options accept open value sets beyond the documented constant values. 4323 * </p> 4324 * <p> 4325 * Note: each release may add new options. 4326 * </p> 4327 * 4328 * @param optionName the name of an option 4329 * @return the String value of a given option 4330 * @see JavaCore#getDefaultOptions() 4331 * @see JavaCorePreferenceInitializer for changing default settings 4332 * @since 2.0 4333 */ getOption(String optionName)4334 public static String getOption(String optionName) { 4335 return JavaModelManager.getJavaModelManager().getOption(optionName); 4336 } 4337 4338 /** 4339 * Returns the option that can be used to configure the severity of the 4340 * compiler problem identified by <code>problemID</code> if any, 4341 * <code>null</code> otherwise. Non-null return values are taken from the 4342 * constants defined by this class whose names start with 4343 * <code>COMPILER_PB</code> and for which the possible values of the 4344 * option are defined by <code>{ "error", "warning", "info", "ignore" }</code>. A 4345 * null return value means that the provided problem ID is unknown or that 4346 * it matches a problem whose severity cannot be configured. 4347 * @param problemID one of the problem IDs defined by {@link IProblem} 4348 * @return the option that can be used to configure the severity of the 4349 * compiler problem identified by <code>problemID</code> if any, 4350 * <code>null</code> otherwise 4351 * @since 3.4 4352 */ getOptionForConfigurableSeverity(int problemID)4353 public static String getOptionForConfigurableSeverity(int problemID) { 4354 return CompilerOptions.optionKeyFromIrritant(ProblemReporter.getIrritant(problemID)); 4355 } 4356 4357 /** 4358 * Returns the option that can be used to configure the severity of the 4359 * compiler build path problem identified by <code>id</code> if any, 4360 * <code>null</code> otherwise. Non-null return values are taken from the 4361 * constants defined by this class whose names start with 4362 * <code>CORE_</code> and for which the possible values of the 4363 * option are defined by <code>{ "error", "warning", "info", "ignore" }</code>. A 4364 * null return value means that the provided id is unknown or that 4365 * it matches a problem whose severity cannot be configured. 4366 * @param id one of the build path problems defined in IJavaModelStatusConstants 4367 * @return the option that can be used to configure the severity of the 4368 * compiler problem identified by <code>id</code> if any, 4369 * <code>null</code> otherwise 4370 * @since 3.16 4371 */ getOptionForConfigurableBuildPathProblemSeverity(int id)4372 public static String getOptionForConfigurableBuildPathProblemSeverity(int id) { 4373 switch (id) { 4374 case IJavaModelStatusConstants.CLASSPATH_CYCLE: 4375 return JavaCore.CORE_CIRCULAR_CLASSPATH; 4376 case IJavaModelStatusConstants.INCOMPATIBLE_JDK_LEVEL: 4377 return JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL; 4378 case IJavaModelStatusConstants.OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE: 4379 return JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE; 4380 case IJavaModelStatusConstants.MAIN_ONLY_PROJECT_DEPENDS_ON_TEST_ONLY_PROJECT: 4381 return JavaCore.CORE_MAIN_ONLY_PROJECT_HAS_TEST_ONLY_DEPENDENCY; 4382 case IJavaModelStatusConstants.INVALID_CLASSPATH: 4383 return JavaCore.CORE_INCOMPLETE_CLASSPATH; 4384 } 4385 return null; 4386 } 4387 4388 /** 4389 * Returns the table of the current options. Initially, all options have their default values, 4390 * and this method returns a table that includes all known options. 4391 * <p> 4392 * Helper constants have been defined on JavaCore for each of the option IDs 4393 * (categorized in Code assist option ID, Compiler option ID and Core option ID) 4394 * and some of their acceptable values (categorized in Option value). Some 4395 * options accept open value sets beyond the documented constant values. 4396 * </p> 4397 * <p> 4398 * Note: each release may add new options. 4399 * </p> 4400 * <p>Returns a default set of options even if the platform is not running.</p> 4401 * 4402 * @return table of current settings of all options 4403 * (key type: <code>String</code>; value type: <code>String</code>) 4404 * @see #getDefaultOptions() 4405 * @see JavaCorePreferenceInitializer for changing default settings 4406 */ getOptions()4407 public static Hashtable<String, String> getOptions() { 4408 return JavaModelManager.getJavaModelManager().getOptions(); 4409 } 4410 4411 /** 4412 * Returns the single instance of the Java core plug-in runtime class. 4413 * 4414 * @return the single instance of the Java core plug-in runtime class 4415 */ getPlugin()4416 public static Plugin getPlugin() { 4417 return JAVA_CORE_PLUGIN; 4418 } 4419 4420 /** 4421 * This is a helper method, which returns the resolved classpath entry denoted 4422 * by a given entry (if it is a variable entry). It is obtained by resolving the variable 4423 * reference in the first segment. Returns <code>null</code> if unable to resolve using 4424 * the following algorithm: 4425 * <ul> 4426 * <li> if variable segment cannot be resolved, returns <code>null</code></li> 4427 * <li> finds a project, JAR or binary folder in the workspace at the resolved path location</li> 4428 * <li> if none finds an external JAR file or folder outside the workspace at the resolved path location </li> 4429 * <li> if none returns <code>null</code></li> 4430 * </ul> 4431 * <p> 4432 * Variable source attachment path and root path are also resolved and recorded in the resulting classpath entry. 4433 * </p> 4434 * <p> 4435 * NOTE: This helper method does not handle classpath containers, for which should rather be used 4436 * <code>JavaCore#getClasspathContainer(IPath, IJavaProject)</code>. 4437 * </p> 4438 * 4439 * @param entry the given variable entry 4440 * @return the resolved library or project classpath entry, or <code>null</code> 4441 * if the given variable entry could not be resolved to a valid classpath entry 4442 */ getResolvedClasspathEntry(IClasspathEntry entry)4443 public static IClasspathEntry getResolvedClasspathEntry(IClasspathEntry entry) { 4444 return JavaModelManager.getJavaModelManager().resolveVariableEntry(entry, false/*don't use previous session value*/); 4445 } 4446 4447 4448 /** 4449 * Resolve a variable path (helper method). 4450 * 4451 * @param variablePath the given variable path 4452 * @return the resolved variable path or <code>null</code> if none 4453 */ getResolvedVariablePath(IPath variablePath)4454 public static IPath getResolvedVariablePath(IPath variablePath) { 4455 return JavaModelManager.getJavaModelManager().getResolvedVariablePath(variablePath, false/*don't use previous session value*/); 4456 } 4457 4458 /** 4459 * Answers the shared working copies currently registered for this buffer factory. 4460 * Working copies can be shared by several clients using the same buffer factory,see 4461 * <code>IWorkingCopy.getSharedWorkingCopy</code>. 4462 * 4463 * @param factory the given buffer factory 4464 * @return the list of shared working copies for a given buffer factory 4465 * @since 2.0 4466 * @deprecated Use {@link #getWorkingCopies(WorkingCopyOwner)} instead 4467 */ getSharedWorkingCopies(IBufferFactory factory)4468 public static IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory){ 4469 4470 // if factory is null, default factory must be used 4471 if (factory == null) factory = BufferManager.getDefaultBufferManager().getDefaultBufferFactory(); 4472 4473 return getWorkingCopies(org.eclipse.jdt.internal.core.BufferFactoryWrapper.create(factory)); 4474 } 4475 4476 /** 4477 * Returns the names of all defined user libraries. The corresponding classpath container path 4478 * is the name appended to the USER_LIBRARY_CONTAINER_ID. 4479 * @return Return an array containing the names of all known user defined. 4480 * @since 3.0 4481 */ getUserLibraryNames()4482 public static String[] getUserLibraryNames() { 4483 return JavaModelManager.getUserLibraryManager().getUserLibraryNames(); 4484 } 4485 4486 /** 4487 * Returns the working copies that have the given owner. 4488 * Only compilation units in working copy mode are returned. 4489 * If the owner is <code>null</code>, primary working copies are returned. 4490 * 4491 * @param owner the given working copy owner or <code>null</code> for primary working copy owner 4492 * @return the list of working copies for a given owner 4493 * @since 3.0 4494 */ getWorkingCopies(WorkingCopyOwner owner)4495 public static ICompilationUnit[] getWorkingCopies(WorkingCopyOwner owner){ 4496 4497 JavaModelManager manager = JavaModelManager.getJavaModelManager(); 4498 if (owner == null) owner = DefaultWorkingCopyOwner.PRIMARY; 4499 ICompilationUnit[] result = manager.getWorkingCopies(owner, false/*don't add primary WCs*/); 4500 if (result == null) return JavaModelManager.NO_WORKING_COPY; 4501 return result; 4502 } 4503 4504 /** 4505 * Initializes JavaCore internal structures to allow subsequent operations (such 4506 * as the ones that need a resolved classpath) to run full speed. A client may 4507 * choose to call this method in a background thread early after the workspace 4508 * has started so that the initialization is transparent to the user. 4509 * <p> 4510 * However calling this method is optional. Services will lazily perform 4511 * initialization when invoked. This is only a way to reduce initialization 4512 * overhead on user actions, if it can be performed before at some 4513 * appropriate moment. 4514 * </p><p> 4515 * This initialization runs across all Java projects in the workspace. Thus the 4516 * workspace root scheduling rule is used during this operation. 4517 * </p><p> 4518 * This method may return before the initialization is complete. The 4519 * initialization will then continue in a background thread. 4520 * </p><p> 4521 * This method can be called concurrently. 4522 * </p> 4523 * 4524 * @param monitor a progress monitor, or <code>null</code> if progress 4525 * reporting and cancellation are not desired 4526 * @exception CoreException if the initialization fails, 4527 * the status of the exception indicates the reason of the failure 4528 * @since 3.1 4529 */ initializeAfterLoad(IProgressMonitor monitor)4530 public static void initializeAfterLoad(IProgressMonitor monitor) throws CoreException { 4531 SubMonitor mainMonitor = SubMonitor.convert(monitor, Messages.javamodel_initialization, 100); 4532 mainMonitor.subTask(Messages.javamodel_configuring_classpath_containers); 4533 4534 // initialize all containers and variables 4535 JavaModelManager manager = JavaModelManager.getJavaModelManager(); 4536 try { 4537 SubMonitor subMonitor = mainMonitor.split(50).setWorkRemaining(100); // 50% of the time is spent in initializing containers and variables 4538 subMonitor.split(5); // give feedback to the user that something is happening 4539 manager.batchContainerInitializationsProgress.initializeAfterLoadMonitor.set(subMonitor); 4540 if (manager.forceBatchInitializations(true/*initAfterLoad*/)) { // if no other thread has started the batch container initializations 4541 manager.getClasspathContainer(Path.EMPTY, null); // force the batch initialization 4542 } else { // else wait for the batch initialization to finish 4543 while (manager.batchContainerInitializations == JavaModelManager.BATCH_INITIALIZATION_IN_PROGRESS) { 4544 subMonitor.subTask(manager.batchContainerInitializationsProgress.subTaskName); 4545 subMonitor.split(manager.batchContainerInitializationsProgress.getWorked()); 4546 synchronized(manager) { 4547 try { 4548 manager.wait(100); 4549 } catch (InterruptedException e) { 4550 // continue 4551 } 4552 } 4553 } 4554 } 4555 } finally { 4556 manager.batchContainerInitializationsProgress.initializeAfterLoadMonitor.set(null); 4557 } 4558 4559 // avoid leaking source attachment properties (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=183413 ) 4560 // and recreate links for external folders if needed 4561 mainMonitor.subTask(Messages.javamodel_resetting_source_attachment_properties); 4562 final IJavaProject[] projects = manager.getJavaModel().getJavaProjects(); 4563 HashSet visitedPaths = new HashSet(); 4564 ExternalFoldersManager externalFoldersManager = JavaModelManager.getExternalManager(); 4565 for (int i = 0, length = projects.length; i < length; i++) { 4566 JavaProject javaProject = (JavaProject) projects[i]; 4567 IClasspathEntry[] classpath; 4568 try { 4569 classpath = javaProject.getResolvedClasspath(); 4570 } catch (JavaModelException e) { 4571 // project no longer exist: ignore 4572 continue; 4573 } 4574 if (classpath != null) { 4575 for (int j = 0, length2 = classpath.length; j < length2; j++) { 4576 IClasspathEntry entry = classpath[j]; 4577 if (entry.getSourceAttachmentPath() != null) { 4578 IPath entryPath = entry.getPath(); 4579 if (visitedPaths.add(entryPath)) { 4580 Util.setSourceAttachmentProperty(entryPath, null); 4581 } 4582 } 4583 // else source might have been attached by IPackageFragmentRoot#attachSource(...), we keep it 4584 if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { 4585 IPath entryPath = entry.getPath(); 4586 if (ExternalFoldersManager.isExternalFolderPath(entryPath) && externalFoldersManager.getFolder(entryPath) == null) { 4587 externalFoldersManager.addFolder(entryPath, true); 4588 } 4589 } 4590 } 4591 } 4592 } 4593 try { 4594 externalFoldersManager.createPendingFolders(mainMonitor.split(1)); 4595 } 4596 catch(JavaModelException jme) { 4597 // Creation of external folder project failed. Log it and continue; 4598 Util.log(jme, "Error while processing external folders"); //$NON-NLS-1$ 4599 } 4600 4601 // ensure external jars are refreshed (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=93668) 4602 // before search is initialized (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=405051) 4603 final JavaModel model = manager.getJavaModel(); 4604 try { 4605 mainMonitor.subTask(Messages.javamodel_refreshing_external_jars); 4606 model.refreshExternalArchives( 4607 null/*refresh all projects*/, 4608 mainMonitor.split(1) // 1% of the time is spent in jar refresh 4609 ); 4610 } catch (JavaModelException e) { 4611 // refreshing failed: ignore 4612 } 4613 4614 // initialize delta state 4615 mainMonitor.subTask(Messages.javamodel_initializing_delta_state); 4616 manager.deltaState.rootsAreStale = true; // in case it was already initialized before we cleaned up the source attachment properties 4617 manager.deltaState.initializeRoots(true/*initAfteLoad*/); 4618 4619 // dummy query for waiting until the indexes are ready 4620 mainMonitor.subTask(Messages.javamodel_configuring_searchengine); 4621 // 47% of the time is spent in the dummy search 4622 updateLegacyIndex(mainMonitor.split(47)); 4623 4624 // check if the build state version number has changed since last session 4625 // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=98969) 4626 mainMonitor.subTask(Messages.javamodel_getting_build_state_number); 4627 QualifiedName qName = new QualifiedName(JavaCore.PLUGIN_ID, "stateVersionNumber"); //$NON-NLS-1$ 4628 IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); 4629 String versionNumber = null; 4630 try { 4631 versionNumber = root.getPersistentProperty(qName); 4632 } catch (CoreException e) { 4633 // could not read version number: consider it is new 4634 } 4635 String newVersionNumber = Byte.toString(State.VERSION); 4636 if (!newVersionNumber.equals(versionNumber)) { 4637 // build state version number has changed: touch every projects to force a rebuild 4638 if (JavaBuilder.DEBUG) 4639 System.out.println("Build state version number has changed"); //$NON-NLS-1$ 4640 IWorkspaceRunnable runnable = new IWorkspaceRunnable() { 4641 @Override 4642 public void run(IProgressMonitor progressMonitor2) throws CoreException { 4643 for (int i = 0, length = projects.length; i < length; i++) { 4644 IJavaProject project = projects[i]; 4645 try { 4646 if (JavaBuilder.DEBUG) 4647 System.out.println("Touching " + project.getElementName()); //$NON-NLS-1$ 4648 new ClasspathValidation((JavaProject) project).validate(); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=287164 4649 project.getProject().touch(progressMonitor2); 4650 } catch (CoreException e) { 4651 // could not touch this project: ignore 4652 } 4653 } 4654 } 4655 }; 4656 mainMonitor.subTask(Messages.javamodel_building_after_upgrade); 4657 try { 4658 ResourcesPlugin.getWorkspace().run(runnable, mainMonitor.split(1)); 4659 } catch (CoreException e) { 4660 // could not touch all projects 4661 } 4662 try { 4663 root.setPersistentProperty(qName, newVersionNumber); 4664 } catch (CoreException e) { 4665 Util.log(e, "Could not persist build state version number"); //$NON-NLS-1$ 4666 } 4667 } 4668 } 4669 updateLegacyIndex(IProgressMonitor monitor)4670 private static void updateLegacyIndex(IProgressMonitor monitor) { 4671 SearchEngine engine = new SearchEngine(); 4672 IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); 4673 try { 4674 engine.searchAllTypeNames( 4675 null, 4676 SearchPattern.R_EXACT_MATCH, 4677 "!@$#!@".toCharArray(), //$NON-NLS-1$ 4678 SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE, 4679 IJavaSearchConstants.CLASS, 4680 scope, 4681 new TypeNameRequestor() { 4682 @Override 4683 public void acceptType( 4684 int modifiers, 4685 char[] packageName, 4686 char[] simpleTypeName, 4687 char[][] enclosingTypeNames, 4688 String path) { 4689 // no type to accept 4690 } 4691 }, 4692 // will not activate index query caches if indexes are not ready, since it would take to long 4693 // to wait until indexes are fully rebuild 4694 IJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH, 4695 monitor 4696 ); 4697 } catch (JavaModelException e) { 4698 // /search failed: ignore 4699 } catch (OperationCanceledException e) { 4700 if (monitor.isCanceled()) 4701 throw e; 4702 // else indexes were not ready: catch the exception so that jars are still refreshed 4703 } 4704 } 4705 4706 /** 4707 * Returns whether a given classpath variable is read-only or not. 4708 * 4709 * @param variableName 4710 * @return <code>true</code> if the classpath variable is read-only, 4711 * <code>false</code> otherwise. 4712 * @since 3.3 4713 */ isClasspathVariableReadOnly(String variableName)4714 public static boolean isClasspathVariableReadOnly(String variableName) { 4715 return JavaModelManager.getJavaModelManager().readOnlyVariables.contains(variableName); 4716 } 4717 4718 /** 4719 * Returns whether the given file name's extension is a Java-like extension. 4720 * 4721 * @return whether the given file name's extension is a Java-like extension 4722 * @see #getJavaLikeExtensions() 4723 * @since 3.2 4724 */ isJavaLikeFileName(String fileName)4725 public static boolean isJavaLikeFileName(String fileName) { 4726 return Util.isJavaLikeFileName(fileName); 4727 } 4728 4729 /** 4730 * Returns whether the given marker references the given Java element. 4731 * Used for markers, which denote a Java element rather than a resource. 4732 * 4733 * @param element the element 4734 * @param marker the marker 4735 * @return <code>true</code> if the marker references the element, false otherwise 4736 * @exception CoreException if the <code>IMarker.getAttribute</code> on the marker fails 4737 */ isReferencedBy(IJavaElement element, IMarker marker)4738 public static boolean isReferencedBy(IJavaElement element, IMarker marker) throws CoreException { 4739 4740 // only match units or classfiles 4741 if (element instanceof IMember){ 4742 IMember member = (IMember) element; 4743 if (member.isBinary()){ 4744 element = member.getClassFile(); 4745 } else { 4746 element = member.getCompilationUnit(); 4747 } 4748 } 4749 if (element == null) return false; 4750 if (marker == null) return false; 4751 4752 String markerHandleId = (String)marker.getAttribute(ATT_HANDLE_ID); 4753 if (markerHandleId == null) return false; 4754 4755 IJavaElement markerElement = JavaCore.create(markerHandleId); 4756 while (true){ 4757 if (element.equals(markerElement)) return true; // external elements may still be equal with different handleIDs. 4758 4759 // cycle through enclosing types in case marker is associated with a classfile (15568) 4760 if (markerElement instanceof IOrdinaryClassFile){ 4761 IType enclosingType = ((IOrdinaryClassFile)markerElement).getType().getDeclaringType(); 4762 if (enclosingType != null){ 4763 markerElement = enclosingType.getClassFile(); // retry with immediate enclosing classfile 4764 continue; 4765 } 4766 } 4767 break; 4768 } 4769 return false; 4770 } 4771 4772 /** 4773 * Returns whether the given marker delta references the given Java element. 4774 * Used for markers deltas, which denote a Java element rather than a resource. 4775 * 4776 * @param element the element 4777 * @param markerDelta the marker delta 4778 * @return <code>true</code> if the marker delta references the element 4779 * @exception CoreException if the <code>IMarkerDelta.getAttribute</code> on the marker delta fails 4780 */ isReferencedBy(IJavaElement element, IMarkerDelta markerDelta)4781 public static boolean isReferencedBy(IJavaElement element, IMarkerDelta markerDelta) throws CoreException { 4782 4783 // only match units or classfiles 4784 if (element instanceof IMember){ 4785 IMember member = (IMember) element; 4786 if (member.isBinary()){ 4787 element = member.getClassFile(); 4788 } else { 4789 element = member.getCompilationUnit(); 4790 } 4791 } 4792 if (element == null) return false; 4793 if (markerDelta == null) return false; 4794 4795 String markerDeltarHandleId = (String)markerDelta.getAttribute(ATT_HANDLE_ID); 4796 if (markerDeltarHandleId == null) return false; 4797 4798 IJavaElement markerElement = JavaCore.create(markerDeltarHandleId); 4799 while (true){ 4800 if (element.equals(markerElement)) return true; // external elements may still be equal with different handleIDs. 4801 4802 // cycle through enclosing types in case marker is associated with a classfile (15568) 4803 if (markerElement instanceof IOrdinaryClassFile){ 4804 IType enclosingType = ((IOrdinaryClassFile)markerElement).getType().getDeclaringType(); 4805 if (enclosingType != null){ 4806 markerElement = enclosingType.getClassFile(); // retry with immediate enclosing classfile 4807 continue; 4808 } 4809 } 4810 break; 4811 } 4812 return false; 4813 } 4814 4815 /** 4816 * Creates and returns a new access rule with the given file pattern and kind. 4817 * <p> 4818 * The rule kind is one of {@link IAccessRule#K_ACCESSIBLE}, {@link IAccessRule#K_DISCOURAGED}, 4819 * or {@link IAccessRule#K_NON_ACCESSIBLE}, optionally combined with {@link IAccessRule#IGNORE_IF_BETTER}, 4820 * e.g. <code>IAccessRule.K_NON_ACCESSIBLE | IAccessRule.IGNORE_IF_BETTER</code>. 4821 * </p> 4822 * 4823 * @param filePattern the file pattern this access rule should match 4824 * @param kind one of {@link IAccessRule#K_ACCESSIBLE}, {@link IAccessRule#K_DISCOURAGED}, 4825 * or {@link IAccessRule#K_NON_ACCESSIBLE}, optionally combined with 4826 * {@link IAccessRule#IGNORE_IF_BETTER} 4827 * @return a new access rule 4828 * @since 3.1 4829 * 4830 * @see IClasspathEntry#getExclusionPatterns() 4831 */ newAccessRule(IPath filePattern, int kind)4832 public static IAccessRule newAccessRule(IPath filePattern, int kind) { 4833 return JavaModelManager.getJavaModelManager().getAccessRule(filePattern, kind); 4834 } 4835 4836 /** 4837 * Creates and returns a new classpath attribute with the given name and the given value. 4838 * 4839 * @return a new classpath attribute 4840 * @since 3.1 4841 */ newClasspathAttribute(String name, String value)4842 public static IClasspathAttribute newClasspathAttribute(String name, String value) { 4843 return new ClasspathAttribute(name, value); 4844 } 4845 4846 /** 4847 * Creates and returns a new classpath entry of kind <code>CPE_CONTAINER</code> 4848 * for the given path. This method is fully equivalent to calling 4849 * {@link #newContainerEntry(IPath, IAccessRule[], IClasspathAttribute[], boolean) 4850 * newContainerEntry(containerPath, new IAccessRule[0], new IClasspathAttribute[0], false)}. 4851 * 4852 * @param containerPath the path identifying the container, it must be formed of two 4853 * segments 4854 * @return a new container classpath entry 4855 * 4856 * @see JavaCore#getClasspathContainer(IPath, IJavaProject) 4857 * @since 2.0 4858 */ newContainerEntry(IPath containerPath)4859 public static IClasspathEntry newContainerEntry(IPath containerPath) { 4860 return newContainerEntry( 4861 containerPath, 4862 ClasspathEntry.NO_ACCESS_RULES, 4863 ClasspathEntry.NO_EXTRA_ATTRIBUTES, 4864 false/*not exported*/); 4865 } 4866 4867 /** 4868 * Creates and returns a new classpath entry of kind <code>CPE_CONTAINER</code> 4869 * for the given path. This method is fully equivalent to calling 4870 * {@link #newContainerEntry(IPath, IAccessRule[], IClasspathAttribute[], boolean) 4871 * newContainerEntry(containerPath, new IAccessRule[0], new IClasspathAttribute[0], isExported)}. 4872 * 4873 * @param containerPath the path identifying the container, it must be formed of at least 4874 * one segment (ID+hints) 4875 * @param isExported a boolean indicating whether this entry is contributed to dependent 4876 * projects in addition to the output location 4877 * @return a new container classpath entry 4878 * 4879 * @see JavaCore#getClasspathContainer(IPath, IJavaProject) 4880 * @see JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor) 4881 * @since 2.0 4882 */ newContainerEntry(IPath containerPath, boolean isExported)4883 public static IClasspathEntry newContainerEntry(IPath containerPath, boolean isExported) { 4884 return newContainerEntry( 4885 containerPath, 4886 ClasspathEntry.NO_ACCESS_RULES, 4887 ClasspathEntry.NO_EXTRA_ATTRIBUTES, 4888 isExported); 4889 } 4890 4891 /** 4892 * Creates and returns a new classpath entry of kind <code>CPE_CONTAINER</code> 4893 * for the given path. The path of the container will be used during resolution so as to map this 4894 * container entry to a set of other classpath entries the container is acting for. 4895 * <p> 4896 * A container entry allows to express indirect references to a set of libraries, projects and variable entries, 4897 * which can be interpreted differently for each Java project where it is used. 4898 * A classpath container entry can be resolved using <code>JavaCore.getResolvedClasspathContainer</code>, 4899 * and updated with <code>JavaCore.classpathContainerChanged</code> 4900 * </p> 4901 * <p> 4902 * A container is exclusively resolved by a <code>ClasspathContainerInitializer</code> registered onto the 4903 * extension point "org.eclipse.jdt.core.classpathContainerInitializer". 4904 * </p> 4905 * <p> 4906 * A container path must be formed of at least one segment, where: 4907 * </p> 4908 * <ul> 4909 * <li> the first segment is a unique ID identifying the target container, there must be a container initializer registered 4910 * onto this ID through the extension point "org.eclipse.jdt.core.classpathContainerInitializer". </li> 4911 * <li> the remaining segments will be passed onto the initializer, and can be used as additional 4912 * hints during the initialization phase. </li> 4913 * </ul> 4914 * <p> 4915 * Example of an ClasspathContainerInitializer for a classpath container denoting a default JDK container: 4916 * </p> 4917 * <pre> 4918 * containerEntry = JavaCore.newContainerEntry(new Path("MyProvidedJDK/default")); 4919 * 4920 * <extension 4921 * point="org.eclipse.jdt.core.classpathContainerInitializer"> 4922 * <containerInitializer 4923 * id="MyProvidedJDK" 4924 * class="com.example.MyInitializer"/> 4925 * </pre> 4926 * <p> 4927 * The access rules determine the set of accessible source and class files 4928 * in the container. If the list of access rules is empty, then all files 4929 * in this container are accessible. 4930 * See {@link IAccessRule} for a detailed description of access 4931 * rules. Note that if an entry defined by the container defines access rules, 4932 * then these access rules are combined with the given access rules. 4933 * The given access rules are considered first, then the entry's access rules are 4934 * considered. 4935 * </p> 4936 * <p> 4937 * The <code>extraAttributes</code> list contains name/value pairs that must be persisted with 4938 * this entry. If no extra attributes are provided, an empty array must be passed in.<br> 4939 * Note that this list should not contain any duplicate name. 4940 * </p> 4941 * <p> 4942 * The <code>isExported</code> flag indicates whether this entry is contributed to dependent 4943 * projects. If not exported, dependent projects will not see any of the classes from this entry. 4944 * If exported, dependent projects will concatenate the accessible files patterns of this entry with the 4945 * accessible files patterns of the projects, and they will concatenate the non accessible files patterns of this entry 4946 * with the non accessible files patterns of the project. 4947 * </p> 4948 * <p> 4949 * Note that this operation does not attempt to validate classpath containers 4950 * or access the resources at the given paths. 4951 * </p> 4952 * 4953 * @param containerPath the path identifying the container, it must be formed of at least 4954 * one segment (ID+hints) 4955 * @param accessRules the possibly empty list of access rules for this entry 4956 * @param extraAttributes the possibly empty list of extra attributes to persist with this entry 4957 * @param isExported a boolean indicating whether this entry is contributed to dependent 4958 * projects in addition to the output location 4959 * @return a new container classpath entry 4960 * 4961 * @see JavaCore#getClasspathContainer(IPath, IJavaProject) 4962 * @see JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor) 4963 * @see JavaCore#newContainerEntry(IPath, boolean) 4964 * @see JavaCore#newAccessRule(IPath, int) 4965 * @since 3.1 4966 */ newContainerEntry( IPath containerPath, IAccessRule[] accessRules, IClasspathAttribute[] extraAttributes, boolean isExported)4967 public static IClasspathEntry newContainerEntry( 4968 IPath containerPath, 4969 IAccessRule[] accessRules, 4970 IClasspathAttribute[] extraAttributes, 4971 boolean isExported) { 4972 4973 if (containerPath == null) { 4974 throw new ClasspathEntry.AssertionFailedException("Container path cannot be null"); //$NON-NLS-1$ 4975 } else if (containerPath.segmentCount() < 1) { 4976 throw new ClasspathEntry.AssertionFailedException("Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$ 4977 } 4978 if (accessRules == null || accessRules.length == 0) { 4979 accessRules = ClasspathEntry.NO_ACCESS_RULES; 4980 } 4981 if (extraAttributes == null || extraAttributes.length == 0) { 4982 extraAttributes = ClasspathEntry.NO_EXTRA_ATTRIBUTES; 4983 } 4984 return new ClasspathEntry( 4985 IPackageFragmentRoot.K_SOURCE, 4986 IClasspathEntry.CPE_CONTAINER, 4987 containerPath, 4988 ClasspathEntry.INCLUDE_ALL, // inclusion patterns 4989 ClasspathEntry.EXCLUDE_NONE, // exclusion patterns 4990 null, // source attachment 4991 null, // source attachment root 4992 null, // specific output folder 4993 isExported, 4994 accessRules, 4995 true, // combine access rules 4996 extraAttributes); 4997 } 4998 4999 /** 5000 * Creates and returns a type hierarchy for all types in the given 5001 * region, considering subtypes within that region and considering types in the 5002 * working copies with the given owner. 5003 * In other words, the owner's working copies will take 5004 * precedence over their original compilation units in the workspace. 5005 * <p> 5006 * Note that if a working copy is empty, it will be as if the original compilation 5007 * unit had been deleted. 5008 * </p> 5009 * 5010 * @param monitor the given progress monitor 5011 * @param region the given region 5012 * @param owner the owner of working copies that take precedence over their original compilation units, 5013 * or <code>null</code> if the primary working copy owner should be used 5014 * @exception JavaModelException if an element in the region does not exist or if an 5015 * exception occurs while accessing its corresponding resource 5016 * @exception IllegalArgumentException if region is <code>null</code> 5017 * @return a type hierarchy for all types in the given 5018 * region, considering subtypes within that region 5019 * @since 3.1 5020 */ newTypeHierarchy(IRegion region, WorkingCopyOwner owner, IProgressMonitor monitor)5021 public static ITypeHierarchy newTypeHierarchy(IRegion region, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException { 5022 if (region == null) { 5023 throw new IllegalArgumentException(Messages.hierarchy_nullRegion); 5024 } 5025 ICompilationUnit[] workingCopies = JavaModelManager.getJavaModelManager().getWorkingCopies(owner, true/*add primary working copies*/); 5026 CreateTypeHierarchyOperation op = 5027 new CreateTypeHierarchyOperation(region, workingCopies, null, true/*compute subtypes*/); 5028 op.runOperation(monitor); 5029 return op.getResult(); 5030 } 5031 5032 /** 5033 * Creates and returns a new non-exported classpath entry of kind <code>CPE_LIBRARY</code> for the 5034 * JAR or folder identified by the given absolute path. This specifies that all package fragments 5035 * within the root will have children of type <code>IClassFile</code>. 5036 * This method is fully equivalent to calling 5037 * {@link #newLibraryEntry(IPath, IPath, IPath, IAccessRule[], IClasspathAttribute[], boolean) 5038 * newLibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath, new IAccessRule[0], new IClasspathAttribute[0], false)}. 5039 * 5040 * @param path the path to the library 5041 * @param sourceAttachmentPath the absolute path of the corresponding source archive or folder, 5042 * or <code>null</code> if none. Note, since 3.0, an empty path is allowed to denote no source attachment. 5043 * Since 3.4, this path can also denote a path external to the workspace. 5044 * and will be automatically converted to <code>null</code>. 5045 * @param sourceAttachmentRootPath the location of the root of the source files within the source archive or folder 5046 * or <code>null</code> if this location should be automatically detected. 5047 * @return a new library classpath entry 5048 */ newLibraryEntry( IPath path, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath)5049 public static IClasspathEntry newLibraryEntry( 5050 IPath path, 5051 IPath sourceAttachmentPath, 5052 IPath sourceAttachmentRootPath) { 5053 5054 return newLibraryEntry( 5055 path, 5056 sourceAttachmentPath, 5057 sourceAttachmentRootPath, 5058 ClasspathEntry.NO_ACCESS_RULES, 5059 ClasspathEntry.NO_EXTRA_ATTRIBUTES, 5060 false/*not exported*/); 5061 } 5062 5063 /** 5064 * Creates and returns a new classpath entry of kind <code>CPE_LIBRARY</code> for the JAR or folder 5065 * identified by the given absolute path. This specifies that all package fragments within the root 5066 * will have children of type <code>IClassFile</code>. 5067 * <p> 5068 * This method is fully equivalent to calling 5069 * {@link #newLibraryEntry(IPath, IPath, IPath, IAccessRule[], IClasspathAttribute[], boolean) 5070 * newLibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath, new IAccessRule[0], new IClasspathAttribute[0], isExported)}. 5071 * </p> 5072 * 5073 * @param path the path to the library 5074 * @param sourceAttachmentPath the absolute path of the corresponding source archive or folder, 5075 * or <code>null</code> if none. Note, since 3.0, an empty path is allowed to denote no source attachment. 5076 * and will be automatically converted to <code>null</code>. Since 3.4, this path can also denote a path external 5077 * to the workspace. 5078 * @param sourceAttachmentRootPath the location of the root of the source files within the source archive or folder 5079 * or <code>null</code> if this location should be automatically detected. 5080 * @param isExported indicates whether this entry is contributed to dependent 5081 * projects in addition to the output location 5082 * @return a new library classpath entry 5083 * @since 2.0 5084 */ newLibraryEntry( IPath path, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, boolean isExported)5085 public static IClasspathEntry newLibraryEntry( 5086 IPath path, 5087 IPath sourceAttachmentPath, 5088 IPath sourceAttachmentRootPath, 5089 boolean isExported) { 5090 5091 return newLibraryEntry( 5092 path, 5093 sourceAttachmentPath, 5094 sourceAttachmentRootPath, 5095 ClasspathEntry.NO_ACCESS_RULES, 5096 ClasspathEntry.NO_EXTRA_ATTRIBUTES, 5097 isExported); 5098 } 5099 5100 /** 5101 * Creates and returns a new classpath entry of kind <code>CPE_LIBRARY</code> for the JAR or folder 5102 * identified by the given absolute path. This specifies that all package fragments within the root 5103 * will have children of type <code>IClassFile</code>. 5104 * <p> 5105 * A library entry is used to denote a prerequisite JAR or root folder containing binaries. 5106 * The target JAR can either be defined internally to the workspace (absolute path relative 5107 * to the workspace root), or externally to the workspace (absolute path in the file system). 5108 * The target root folder can also be defined internally to the workspace (absolute path relative 5109 * to the workspace root), or - since 3.4 - externally to the workspace (absolute path in the file system). 5110 * Since 3.5, the path to the library can also be relative to the project using ".." as the first segment. 5111 * </p> 5112 * <p> 5113 * e.g. Here are some examples of binary path usage 5114 * </p> 5115 * <ul> 5116 * <li><code> "c:\jdk1.2.2\jre\lib\rt.jar" </code> - reference to an external JAR on Windows</li> 5117 * <li><code> "/Project/someLib.jar" </code> - reference to an internal JAR on Windows or Linux</li> 5118 * <li><code> "/Project/classes/" </code> - reference to an internal binary folder on Windows or Linux</li> 5119 * <li><code> "/home/usr/classes" </code> - reference to an external binary folder on Linux</li> 5120 * <li><code> "../../lib/someLib.jar" </code> - reference to an external JAR that is a sibling of the workspace on either platform</li> 5121 * </ul> 5122 * Note that on non-Windows platform, a path <code>"/some/lib.jar"</code> is ambiguous. 5123 * It can be a path to an external JAR (its file system path being <code>"/some/lib.jar"</code>) 5124 * or it can be a path to an internal JAR (<code>"some"</code> being a project in the workspace). 5125 * Such an ambiguity is solved when the classpath entry is used (e.g. in {@link IJavaProject#getPackageFragmentRoots()}). 5126 * If the resource <code>"lib.jar"</code> exists in project <code>"some"</code>, then it is considered an 5127 * internal JAR. Otherwise it is an external JAR. 5128 * <p>Also note that this operation does not attempt to validate or access the 5129 * resources at the given paths. 5130 * </p><p> 5131 * The access rules determine the set of accessible class files 5132 * in the library. If the list of access rules is empty then all files 5133 * in this library are accessible. 5134 * See {@link IAccessRule} for a detailed description of access 5135 * rules. 5136 * </p> 5137 * <p> 5138 * The <code>extraAttributes</code> list contains name/value pairs that must be persisted with 5139 * this entry. If no extra attributes are provided, an empty array must be passed in.<br> 5140 * Note that this list should not contain any duplicate name. 5141 * </p> 5142 * <p> 5143 * The <code>isExported</code> flag indicates whether this entry is contributed to dependent 5144 * projects. If not exported, dependent projects will not see any of the classes from this entry. 5145 * If exported, dependent projects will concatenate the accessible files patterns of this entry with the 5146 * accessible files patterns of the projects, and they will concatenate the non accessible files patterns of this entry 5147 * with the non accessible files patterns of the project. 5148 * </p> 5149 * <p> 5150 * Since 3.5, if the library is a ZIP archive, the "Class-Path" clause (if any) in the "META-INF/MANIFEST.MF" is read 5151 * and referenced ZIP archives are added to the {@link IJavaProject#getResolvedClasspath(boolean) resolved classpath}. 5152 * </p> 5153 * 5154 * @param path the path to the library 5155 * @param sourceAttachmentPath the absolute path of the corresponding source archive or folder, 5156 * or <code>null</code> if none. Note, since 3.0, an empty path is allowed to denote no source attachment. 5157 * and will be automatically converted to <code>null</code>. Since 3.4, this path can also denote a path external 5158 * to the workspace. 5159 * @param sourceAttachmentRootPath the location of the root of the source files within the source archive or folder 5160 * or <code>null</code> if this location should be automatically detected. 5161 * @param accessRules the possibly empty list of access rules for this entry 5162 * @param extraAttributes the possibly empty list of extra attributes to persist with this entry 5163 * @param isExported indicates whether this entry is contributed to dependent 5164 * projects in addition to the output location 5165 * @return a new library classpath entry 5166 * @since 3.1 5167 */ newLibraryEntry( IPath path, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, IAccessRule[] accessRules, IClasspathAttribute[] extraAttributes, boolean isExported)5168 public static IClasspathEntry newLibraryEntry( 5169 IPath path, 5170 IPath sourceAttachmentPath, 5171 IPath sourceAttachmentRootPath, 5172 IAccessRule[] accessRules, 5173 IClasspathAttribute[] extraAttributes, 5174 boolean isExported) { 5175 5176 if (path == null) throw new ClasspathEntry.AssertionFailedException("Library path cannot be null"); //$NON-NLS-1$ 5177 if (accessRules == null || accessRules.length==0) { 5178 accessRules = ClasspathEntry.NO_ACCESS_RULES; 5179 } 5180 if (extraAttributes == null || extraAttributes.length==0) { 5181 extraAttributes = ClasspathEntry.NO_EXTRA_ATTRIBUTES; 5182 } 5183 boolean hasDotDot = ClasspathEntry.hasDotDot(path); 5184 if (!hasDotDot && !path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute: " + path); //$NON-NLS-1$ 5185 if (sourceAttachmentPath != null) { 5186 if (sourceAttachmentPath.isEmpty()) { 5187 sourceAttachmentPath = null; // treat empty path as none 5188 } else if (!sourceAttachmentPath.isAbsolute()) { 5189 throw new ClasspathEntry.AssertionFailedException("Source attachment path '" //$NON-NLS-1$ 5190 + sourceAttachmentPath 5191 + "' for IClasspathEntry must be absolute"); //$NON-NLS-1$ 5192 } 5193 } 5194 return new ClasspathEntry( 5195 IPackageFragmentRoot.K_BINARY, 5196 IClasspathEntry.CPE_LIBRARY, 5197 hasDotDot ? path : JavaProject.canonicalizedPath(path), 5198 ClasspathEntry.INCLUDE_ALL, // inclusion patterns 5199 ClasspathEntry.EXCLUDE_NONE, // exclusion patterns 5200 sourceAttachmentPath, 5201 sourceAttachmentRootPath, 5202 null, // specific output folder 5203 isExported, 5204 accessRules, 5205 false, // no access rules to combine 5206 extraAttributes); 5207 } 5208 5209 /** 5210 * Creates and returns a new non-exported classpath entry of kind <code>CPE_PROJECT</code> 5211 * for the project identified by the given absolute path. 5212 * <p> 5213 * This method is fully equivalent to calling 5214 * {@link #newProjectEntry(IPath, IAccessRule[], boolean, IClasspathAttribute[], boolean) 5215 * newProjectEntry(path, new IAccessRule[0], true, new IClasspathAttribute[0], false)}. 5216 * </p> 5217 * 5218 * @param path the absolute path of the binary archive 5219 * @return a new project classpath entry 5220 */ newProjectEntry(IPath path)5221 public static IClasspathEntry newProjectEntry(IPath path) { 5222 return newProjectEntry(path, false); 5223 } 5224 5225 /** 5226 * Creates and returns a new classpath entry of kind <code>CPE_PROJECT</code> 5227 * for the project identified by the given absolute path. 5228 * <p> 5229 * This method is fully equivalent to calling 5230 * {@link #newProjectEntry(IPath, IAccessRule[], boolean, IClasspathAttribute[], boolean) 5231 * newProjectEntry(path, new IAccessRule[0], true, new IClasspathAttribute[0], isExported)}. 5232 * </p> 5233 * 5234 * @param path the absolute path of the prerequisite project 5235 * @param isExported indicates whether this entry is contributed to dependent 5236 * projects in addition to the output location 5237 * @return a new project classpath entry 5238 * @since 2.0 5239 */ newProjectEntry(IPath path, boolean isExported)5240 public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) { 5241 5242 if (!path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute"); //$NON-NLS-1$ 5243 5244 return newProjectEntry( 5245 path, 5246 ClasspathEntry.NO_ACCESS_RULES, 5247 true, 5248 ClasspathEntry.NO_EXTRA_ATTRIBUTES, 5249 isExported); 5250 } 5251 5252 /** 5253 * Creates and returns a new classpath entry of kind <code>CPE_PROJECT</code> 5254 * for the project identified by the given absolute path. 5255 * <p> 5256 * A project entry is used to denote a prerequisite project on a classpath. 5257 * The referenced project will be contributed as a whole, either as sources (in the Java Model, it 5258 * contributes all its package fragment roots) or as binaries (when building, it contributes its 5259 * whole output location). 5260 * </p> 5261 * <p> 5262 * A project reference allows to indirect through another project, independently from its internal layout. 5263 * </p><p> 5264 * The prerequisite project is referred to using an absolute path relative to the workspace root. 5265 * </p> 5266 * <p> 5267 * The access rules determine the set of accessible class files 5268 * in the project. If the list of access rules is empty then all files 5269 * in this project are accessible. 5270 * See {@link IAccessRule} for a detailed description of access rules. 5271 * </p> 5272 * <p> 5273 * The <code>combineAccessRules</code> flag indicates whether access rules of one (or more) 5274 * exported entry of the project should be combined with the given access rules. If they should 5275 * be combined, the given access rules are considered first, then the entry's access rules are 5276 * considered. 5277 * </p> 5278 * <p> 5279 * The <code>extraAttributes</code> list contains name/value pairs that must be persisted with 5280 * this entry. If no extra attributes are provided, an empty array must be passed in.<br> 5281 * Note that this list should not contain any duplicate name. 5282 * </p> 5283 * <p> 5284 * The <code>isExported</code> flag indicates whether this entry is contributed to dependent 5285 * projects. If not exported, dependent projects will not see any of the classes from this entry. 5286 * If exported, dependent projects will concatenate the accessible files patterns of this entry with the 5287 * accessible files patterns of the projects, and they will concatenate the non accessible files patterns of this entry 5288 * with the non accessible files patterns of the project. 5289 * </p> 5290 * 5291 * @param path the absolute path of the prerequisite project 5292 * @param accessRules the possibly empty list of access rules for this entry 5293 * @param combineAccessRules whether the access rules of the project's exported entries should be combined with the given access rules 5294 * @param extraAttributes the possibly empty list of extra attributes to persist with this entry 5295 * @param isExported indicates whether this entry is contributed to dependent 5296 * projects in addition to the output location 5297 * @return a new project classpath entry 5298 * @since 3.1 5299 */ newProjectEntry( IPath path, IAccessRule[] accessRules, boolean combineAccessRules, IClasspathAttribute[] extraAttributes, boolean isExported)5300 public static IClasspathEntry newProjectEntry( 5301 IPath path, 5302 IAccessRule[] accessRules, 5303 boolean combineAccessRules, 5304 IClasspathAttribute[] extraAttributes, 5305 boolean isExported) { 5306 5307 if (!path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute"); //$NON-NLS-1$ 5308 if (accessRules == null || accessRules.length == 0) { 5309 accessRules = ClasspathEntry.NO_ACCESS_RULES; 5310 } 5311 if (extraAttributes == null || extraAttributes.length == 0) { 5312 extraAttributes = ClasspathEntry.NO_EXTRA_ATTRIBUTES; 5313 } 5314 return new ClasspathEntry( 5315 IPackageFragmentRoot.K_SOURCE, 5316 IClasspathEntry.CPE_PROJECT, 5317 path, 5318 ClasspathEntry.INCLUDE_ALL, // inclusion patterns 5319 ClasspathEntry.EXCLUDE_NONE, // exclusion patterns 5320 null, // source attachment 5321 null, // source attachment root 5322 null, // specific output folder 5323 isExported, 5324 accessRules, 5325 combineAccessRules, 5326 extraAttributes); 5327 } 5328 5329 /** 5330 * Returns a new empty region. 5331 * 5332 * @return a new empty region 5333 */ newRegion()5334 public static IRegion newRegion() { 5335 return new Region(); 5336 } 5337 5338 /** 5339 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code> 5340 * for all files in the project's source folder identified by the given 5341 * absolute workspace-relative path. 5342 * <p> 5343 * The convenience method is fully equivalent to: 5344 * </p> 5345 * <pre> 5346 * newSourceEntry(path, new IPath[] {}, new IPath[] {}, null); 5347 * </pre> 5348 * 5349 * @param path the absolute workspace-relative path of a source folder 5350 * @return a new source classpath entry 5351 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath) 5352 */ newSourceEntry(IPath path)5353 public static IClasspathEntry newSourceEntry(IPath path) { 5354 5355 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, null /*output location*/); 5356 } 5357 5358 /** 5359 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code> 5360 * for the project's source folder identified by the given absolute 5361 * workspace-relative path but excluding all source files with paths 5362 * matching any of the given patterns. 5363 * <p> 5364 * The convenience method is fully equivalent to: 5365 * </p> 5366 * <pre> 5367 * newSourceEntry(path, new IPath[] {}, exclusionPatterns, null); 5368 * </pre> 5369 * 5370 * @param path the absolute workspace-relative path of a source folder 5371 * @param exclusionPatterns the possibly empty list of exclusion patterns 5372 * represented as relative paths 5373 * @return a new source classpath entry 5374 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath) 5375 * @since 2.1 5376 */ newSourceEntry(IPath path, IPath[] exclusionPatterns)5377 public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns) { 5378 5379 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL, exclusionPatterns, null /*output location*/); 5380 } 5381 5382 /** 5383 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code> 5384 * for the project's source folder identified by the given absolute 5385 * workspace-relative path but excluding all source files with paths 5386 * matching any of the given patterns, and associated with a specific output location 5387 * (that is, ".class" files are not going to the project default output location). 5388 * <p> 5389 * The convenience method is fully equivalent to: 5390 * </p> 5391 * <pre> 5392 * newSourceEntry(path, new IPath[] {}, exclusionPatterns, specificOutputLocation); 5393 * </pre> 5394 * 5395 * @param path the absolute workspace-relative path of a source folder 5396 * @param exclusionPatterns the possibly empty list of exclusion patterns 5397 * represented as relative paths 5398 * @param specificOutputLocation the specific output location for this source entry (<code>null</code> if using project default output location) 5399 * @return a new source classpath entry 5400 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath) 5401 * @since 2.1 5402 */ newSourceEntry(IPath path, IPath[] exclusionPatterns, IPath specificOutputLocation)5403 public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns, IPath specificOutputLocation) { 5404 5405 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL, exclusionPatterns, specificOutputLocation); 5406 } 5407 5408 /** 5409 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code> 5410 * for the project's source folder identified by the given absolute 5411 * workspace-relative path but excluding all source files with paths 5412 * matching any of the given patterns, and associated with a specific output location 5413 * (that is, ".class" files are not going to the project default output location). 5414 * <p> 5415 * The convenience method is fully equivalent to: 5416 * </p> 5417 * <pre> 5418 * newSourceEntry(path, new IPath[] {}, exclusionPatterns, specificOutputLocation, new IClasspathAttribute[] {}); 5419 * </pre> 5420 * 5421 * @param path the absolute workspace-relative path of a source folder 5422 * @param inclusionPatterns the possibly empty list of inclusion patterns 5423 * represented as relative paths 5424 * @param exclusionPatterns the possibly empty list of exclusion patterns 5425 * represented as relative paths 5426 * @param specificOutputLocation the specific output location for this source entry (<code>null</code> if using project default output location) 5427 * @return a new source classpath entry 5428 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath, IClasspathAttribute[]) 5429 * @since 3.0 5430 */ newSourceEntry(IPath path, IPath[] inclusionPatterns, IPath[] exclusionPatterns, IPath specificOutputLocation)5431 public static IClasspathEntry newSourceEntry(IPath path, IPath[] inclusionPatterns, IPath[] exclusionPatterns, IPath specificOutputLocation) { 5432 return newSourceEntry(path, inclusionPatterns, exclusionPatterns, specificOutputLocation, ClasspathEntry.NO_EXTRA_ATTRIBUTES); 5433 } 5434 5435 /** 5436 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code> 5437 * for the project's source folder identified by the given absolute 5438 * workspace-relative path using the given inclusion and exclusion patterns 5439 * to determine which source files are included, and the given output path 5440 * to control the output location of generated files. 5441 * <p> 5442 * The source folder is referred to using an absolute path relative to the 5443 * workspace root, e.g. <code>/Project/src</code>. A project's source 5444 * folders are located with that project. That is, a source classpath 5445 * entry specifying the path <code>/P1/src</code> is only usable for 5446 * project <code>P1</code>. 5447 * </p> 5448 * <p> 5449 * The inclusion patterns determines the initial set of source files that 5450 * are to be included; the exclusion patterns are then used to reduce this 5451 * set. When no inclusion patterns are specified, the initial file set 5452 * includes all relevant files in the resource tree rooted at the source 5453 * entry's path. On the other hand, specifying one or more inclusion 5454 * patterns means that all <b>and only</b> files matching at least one of 5455 * the specified patterns are to be included. If exclusion patterns are 5456 * specified, the initial set of files is then reduced by eliminating files 5457 * matched by at least one of the exclusion patterns. Inclusion and 5458 * exclusion patterns look like relative file paths with wildcards and are 5459 * interpreted relative to the source entry's path. File patterns are 5460 * case-sensitive can contain '**', '*' or '?' wildcards (see 5461 * {@link IClasspathEntry#getExclusionPatterns()} for the full description 5462 * of their syntax and semantics). The resulting set of files are included 5463 * in the corresponding package fragment root; all package fragments within 5464 * the root will have children of type <code>ICompilationUnit</code>. 5465 * </p> 5466 * <p> 5467 * For example, if the source folder path is 5468 * <code>/Project/src</code>, there are no inclusion filters, and the 5469 * exclusion pattern is 5470 * <code>com/xyz/tests/**</code>, then source files 5471 * like <code>/Project/src/com/xyz/Foo.java</code> 5472 * and <code>/Project/src/com/xyz/utils/Bar.java</code> would be included, 5473 * whereas <code>/Project/src/com/xyz/tests/T1.java</code> 5474 * and <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be 5475 * excluded. 5476 * </p> 5477 * <p> 5478 * Additionally, a source entry can be associated with a specific output location. 5479 * By doing so, the Java builder will ensure that the generated ".class" files will 5480 * be issued inside this output location, as opposed to be generated into the 5481 * project default output location (when output location is <code>null</code>). 5482 * Note that multiple source entries may target the same output location. 5483 * The output location is referred to using an absolute path relative to the 5484 * workspace root, e.g. <code>"/Project/bin"</code>, it must be located inside 5485 * the same project as the source folder. 5486 * </p> 5487 * <p> 5488 * Also note that all sources/binaries inside a project are contributed as 5489 * a whole through a project entry 5490 * (see <code>JavaCore.newProjectEntry</code>). Particular source entries 5491 * cannot be selectively exported. 5492 * </p> 5493 * <p> 5494 * The <code>extraAttributes</code> list contains name/value pairs that must be persisted with 5495 * this entry. If no extra attributes are provided, an empty array must be passed in.<br> 5496 * Note that this list should not contain any duplicate name. 5497 * </p> 5498 * 5499 * @param path the absolute workspace-relative path of a source folder 5500 * @param inclusionPatterns the possibly empty list of inclusion patterns 5501 * represented as relative paths 5502 * @param exclusionPatterns the possibly empty list of exclusion patterns 5503 * represented as relative paths 5504 * @param specificOutputLocation the specific output location for this source entry (<code>null</code> if using project default ouput location) 5505 * @param extraAttributes the possibly empty list of extra attributes to persist with this entry 5506 * @return a new source classpath entry with the given exclusion patterns 5507 * @see IClasspathEntry#getInclusionPatterns() 5508 * @see IClasspathEntry#getExclusionPatterns() 5509 * @see IClasspathEntry#getOutputLocation() 5510 * @since 3.1 5511 */ newSourceEntry(IPath path, IPath[] inclusionPatterns, IPath[] exclusionPatterns, IPath specificOutputLocation, IClasspathAttribute[] extraAttributes)5512 public static IClasspathEntry newSourceEntry(IPath path, IPath[] inclusionPatterns, IPath[] exclusionPatterns, IPath specificOutputLocation, IClasspathAttribute[] extraAttributes) { 5513 5514 if (path == null) throw new ClasspathEntry.AssertionFailedException("Source path cannot be null"); //$NON-NLS-1$ 5515 if (!path.isAbsolute()) throw new ClasspathEntry.AssertionFailedException("Path for IClasspathEntry must be absolute"); //$NON-NLS-1$ 5516 if (exclusionPatterns == null) { 5517 exclusionPatterns = ClasspathEntry.EXCLUDE_NONE; 5518 } 5519 if (inclusionPatterns == null) { 5520 inclusionPatterns = ClasspathEntry.INCLUDE_ALL; 5521 } 5522 if (extraAttributes == null) { 5523 extraAttributes = ClasspathEntry.NO_EXTRA_ATTRIBUTES; 5524 } 5525 return new ClasspathEntry( 5526 IPackageFragmentRoot.K_SOURCE, 5527 IClasspathEntry.CPE_SOURCE, 5528 path, 5529 inclusionPatterns, 5530 exclusionPatterns, 5531 null, // source attachment 5532 null, // source attachment root 5533 specificOutputLocation, // custom output location 5534 false, 5535 null, 5536 false, // no access rules to combine 5537 extraAttributes); 5538 } 5539 5540 /** 5541 * Creates and returns a new non-exported classpath entry of kind <code>CPE_VARIABLE</code> 5542 * for the given path. This method is fully equivalent to calling 5543 * {@link #newVariableEntry(IPath, IPath, IPath, IAccessRule[], IClasspathAttribute[], boolean) 5544 * newVariableEntry(variablePath, variableSourceAttachmentPath, sourceAttachmentRootPath, new IAccessRule[0], new IClasspathAttribute[0], false)}. 5545 * 5546 * @param variablePath the path of the binary archive; first segment is the 5547 * name of a classpath variable 5548 * @param variableSourceAttachmentPath the path of the corresponding source archive, 5549 * or <code>null</code> if none; if present, the first segment is the 5550 * name of a classpath variable (not necessarily the same variable 5551 * as the one that begins <code>variablePath</code>) 5552 * @param sourceAttachmentRootPath the location of the root of the source files within the source archive 5553 * or <code>null</code> if <code>variableSourceAttachmentPath</code> is also <code>null</code> 5554 * @return a new library classpath entry 5555 */ newVariableEntry( IPath variablePath, IPath variableSourceAttachmentPath, IPath sourceAttachmentRootPath)5556 public static IClasspathEntry newVariableEntry( 5557 IPath variablePath, 5558 IPath variableSourceAttachmentPath, 5559 IPath sourceAttachmentRootPath) { 5560 5561 return newVariableEntry(variablePath, variableSourceAttachmentPath, sourceAttachmentRootPath, false); 5562 } 5563 5564 /** 5565 * Creates and returns a new classpath entry of kind <code>CPE_VARIABLE</code> 5566 * for the given path. This method is fully equivalent to calling 5567 * {@link #newVariableEntry(IPath, IPath, IPath, IAccessRule[], IClasspathAttribute[], boolean) 5568 * newVariableEntry(variablePath, variableSourceAttachmentPath, sourceAttachmentRootPath, new IAccessRule[0], new IClasspathAttribute[0], isExported)}. 5569 * 5570 * @param variablePath the path of the binary archive; first segment is the 5571 * name of a classpath variable 5572 * @param variableSourceAttachmentPath the path of the corresponding source archive, 5573 * or <code>null</code> if none; if present, the first segment is the 5574 * name of a classpath variable (not necessarily the same variable 5575 * as the one that begins <code>variablePath</code>) 5576 * @param variableSourceAttachmentRootPath the location of the root of the source files within the source archive 5577 * or <code>null</code> if <code>variableSourceAttachmentPath</code> is also <code>null</code> 5578 * @param isExported indicates whether this entry is contributed to dependent 5579 * projects in addition to the output location 5580 * @return a new variable classpath entry 5581 * @since 2.0 5582 */ newVariableEntry( IPath variablePath, IPath variableSourceAttachmentPath, IPath variableSourceAttachmentRootPath, boolean isExported)5583 public static IClasspathEntry newVariableEntry( 5584 IPath variablePath, 5585 IPath variableSourceAttachmentPath, 5586 IPath variableSourceAttachmentRootPath, 5587 boolean isExported) { 5588 5589 return newVariableEntry( 5590 variablePath, 5591 variableSourceAttachmentPath, 5592 variableSourceAttachmentRootPath, 5593 ClasspathEntry.NO_ACCESS_RULES, 5594 ClasspathEntry.NO_EXTRA_ATTRIBUTES, 5595 isExported); 5596 } 5597 5598 /** 5599 * Creates and returns a new classpath entry of kind <code>CPE_VARIABLE</code> 5600 * for the given path. The first segment of the path is the name of a classpath variable. 5601 * The trailing segments of the path will be appended to resolved variable path. 5602 * <p> 5603 * A variable entry allows to express indirect references on a classpath to other projects or libraries, 5604 * depending on what the classpath variable is referring. 5605 * </p> 5606 * <p> 5607 * It is possible to register an automatic initializer (<code>ClasspathVariableInitializer</code>), 5608 * which will be invoked through the extension point "org.eclipse.jdt.core.classpathVariableInitializer". 5609 * After resolution, a classpath variable entry may either correspond to a project or a library entry. 5610 * </p> 5611 * <p> 5612 * e.g. Here are some examples of variable path usage 5613 * </p> 5614 * <ul> 5615 * <li> "JDTCORE" where variable <code>JDTCORE</code> is 5616 * bound to "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the library "c:\jars\jdtcore.jar"</li> 5617 * <li> "JDTCORE" where variable <code>JDTCORE</code> is 5618 * bound to "/Project_JDTCORE". The resolved classpath entry is denoting the project "/Project_JDTCORE"</li> 5619 * <li> "PLUGINS/com.example/example.jar" where variable <code>PLUGINS</code> 5620 * is bound to "c:/eclipse/plugins". The resolved classpath entry is denoting the library "c:\eclipse\plugins\com.example\example.jar"</li> 5621 * </ul> 5622 * <p> 5623 * The access rules determine the set of accessible class files 5624 * in the project or library. If the list of access rules is empty then all files 5625 * in this project or library are accessible. 5626 * See {@link IAccessRule} for a detailed description of access rules. 5627 * </p> 5628 * <p> 5629 * The <code>extraAttributes</code> list contains name/value pairs that must be persisted with 5630 * this entry. If no extra attributes are provided, an empty array must be passed in.<br> 5631 * Note that this list should not contain any duplicate name. 5632 * </p> 5633 * <p> 5634 * The <code>isExported</code> flag indicates whether this entry is contributed to dependent 5635 * projects. If not exported, dependent projects will not see any of the classes from this entry. 5636 * If exported, dependent projects will concatenate the accessible files patterns of this entry with the 5637 * accessible files patterns of the projects, and they will concatenate the non accessible files patterns of this entry 5638 * with the non accessible files patterns of the project. 5639 * </p> 5640 * <p> 5641 * Note that this operation does not attempt to validate classpath variables 5642 * or access the resources at the given paths. 5643 * </p> 5644 * 5645 * @param variablePath the path of the binary archive; first segment is the 5646 * name of a classpath variable 5647 * @param variableSourceAttachmentPath the path of the corresponding source archive, 5648 * or <code>null</code> if none; if present, the first segment is the 5649 * name of a classpath variable (not necessarily the same variable 5650 * as the one that begins <code>variablePath</code>) 5651 * @param variableSourceAttachmentRootPath the location of the root of the source files within the source archive 5652 * or <code>null</code> if <code>variableSourceAttachmentPath</code> is also <code>null</code> 5653 * @param accessRules the possibly empty list of access rules for this entry 5654 * @param extraAttributes the possibly empty list of extra attributes to persist with this entry 5655 * @param isExported indicates whether this entry is contributed to dependent 5656 * projects in addition to the output location 5657 * @return a new variable classpath entry 5658 * @since 3.1 5659 */ newVariableEntry( IPath variablePath, IPath variableSourceAttachmentPath, IPath variableSourceAttachmentRootPath, IAccessRule[] accessRules, IClasspathAttribute[] extraAttributes, boolean isExported)5660 public static IClasspathEntry newVariableEntry( 5661 IPath variablePath, 5662 IPath variableSourceAttachmentPath, 5663 IPath variableSourceAttachmentRootPath, 5664 IAccessRule[] accessRules, 5665 IClasspathAttribute[] extraAttributes, 5666 boolean isExported) { 5667 5668 if (variablePath == null) throw new ClasspathEntry.AssertionFailedException("Variable path cannot be null"); //$NON-NLS-1$ 5669 if (variablePath.segmentCount() < 1) { 5670 throw new ClasspathEntry.AssertionFailedException("Illegal classpath variable path: \'" + variablePath.makeRelative().toString() + "\', must have at least one segment"); //$NON-NLS-1$//$NON-NLS-2$ 5671 } 5672 if (accessRules == null || accessRules.length == 0) { 5673 accessRules = ClasspathEntry.NO_ACCESS_RULES; 5674 } 5675 if (extraAttributes == null || extraAttributes.length == 0) { 5676 extraAttributes = ClasspathEntry.NO_EXTRA_ATTRIBUTES; 5677 } 5678 5679 return new ClasspathEntry( 5680 IPackageFragmentRoot.K_SOURCE, 5681 IClasspathEntry.CPE_VARIABLE, 5682 variablePath, 5683 ClasspathEntry.INCLUDE_ALL, // inclusion patterns 5684 ClasspathEntry.EXCLUDE_NONE, // exclusion patterns 5685 variableSourceAttachmentPath, // source attachment 5686 variableSourceAttachmentRootPath, // source attachment root 5687 null, // specific output folder 5688 isExported, 5689 accessRules, 5690 false, // no access rules to combine 5691 extraAttributes); 5692 } 5693 5694 /** 5695 * Returns an array of classpath entries that are referenced directly or indirectly 5696 * by a given classpath entry. For the entry kind {@link IClasspathEntry#CPE_LIBRARY}, 5697 * the method returns the libraries that are included in the Class-Path section of 5698 * the MANIFEST.MF file. If a referenced JAR file has further references to other library 5699 * entries, they are processed recursively and added to the list. For entry kinds other 5700 * than {@link IClasspathEntry#CPE_LIBRARY}, this method returns an empty array. 5701 * <p> 5702 * When a non-null project is passed, any additional attributes that may have been stored 5703 * previously in the project's .classpath file are retrieved and populated in the 5704 * corresponding referenced entry. If the project is <code>null</code>, the raw referenced 5705 * entries are returned without any persisted attributes. 5706 * For more details on storing referenced entries, see 5707 * {@link IJavaProject#setRawClasspath(IClasspathEntry[], IClasspathEntry[], IPath, 5708 * IProgressMonitor)}. 5709 * </p> 5710 * 5711 * @param libraryEntry the library entry whose referenced entries are sought 5712 * @param project project where the persisted referenced entries to be retrieved from. If <code>null</code> 5713 * persisted attributes are not attempted to be retrieved. 5714 * @return an array of classpath entries that are referenced directly or indirectly by the given entry. 5715 * If not applicable, returns an empty array. 5716 * @since 3.6 5717 */ getReferencedClasspathEntries(IClasspathEntry libraryEntry, IJavaProject project)5718 public static IClasspathEntry[] getReferencedClasspathEntries(IClasspathEntry libraryEntry, IJavaProject project) { 5719 JavaModelManager manager = JavaModelManager.getJavaModelManager(); 5720 return manager.getReferencedClasspathEntries(libraryEntry, project); 5721 } 5722 5723 /** 5724 * Removed the given classpath variable. Does nothing if no value was 5725 * set for this classpath variable. 5726 * <p> 5727 * This functionality cannot be used while the resource tree is locked. 5728 * </p> 5729 * <p> 5730 * Classpath variable values are persisted locally to the workspace, and 5731 * are preserved from session to session. 5732 * </p> 5733 * 5734 * @param variableName the name of the classpath variable 5735 * @see #setClasspathVariable(String, IPath) 5736 * 5737 * @deprecated Use {@link #removeClasspathVariable(String, IProgressMonitor)} instead 5738 */ removeClasspathVariable(String variableName)5739 public static void removeClasspathVariable(String variableName) { 5740 removeClasspathVariable(variableName, null); 5741 } 5742 5743 /** 5744 * Removed the given classpath variable. Does nothing if no value was 5745 * set for this classpath variable. 5746 * <p> 5747 * This functionality cannot be used while the resource tree is locked. 5748 * </p> 5749 * <p> 5750 * Classpath variable values are persisted locally to the workspace, and 5751 * are preserved from session to session. 5752 * </p> 5753 * 5754 * @param variableName the name of the classpath variable 5755 * @param monitor the progress monitor to report progress 5756 * @see #setClasspathVariable(String, IPath) 5757 */ removeClasspathVariable(String variableName, IProgressMonitor monitor)5758 public static void removeClasspathVariable(String variableName, IProgressMonitor monitor) { 5759 try { 5760 SetVariablesOperation operation = new SetVariablesOperation(new String[]{ variableName}, new IPath[]{ null }, true/*update preferences*/); 5761 operation.runOperation(monitor); 5762 } catch (JavaModelException e) { 5763 Util.log(e, "Exception while removing variable " + variableName); //$NON-NLS-1$ 5764 } 5765 } 5766 5767 /** 5768 * Removes the given element changed listener. 5769 * Has no effect if an identical listener is not registered. 5770 * 5771 * @param listener the listener 5772 */ removeElementChangedListener(IElementChangedListener listener)5773 public static void removeElementChangedListener(IElementChangedListener listener) { 5774 JavaModelManager.getDeltaState().removeElementChangedListener(listener); 5775 } 5776 5777 /** 5778 * Removes the file extension from the given file name, if it has a Java-like file 5779 * extension. Otherwise the file name itself is returned. 5780 * Note this removes the dot ('.') before the extension as well. 5781 * 5782 * @param fileName the name of a file 5783 * @return the fileName without the Java-like extension 5784 * @since 3.2 5785 */ removeJavaLikeExtension(String fileName)5786 public static String removeJavaLikeExtension(String fileName) { 5787 return Util.getNameWithoutJavaLikeExtension(fileName); 5788 } 5789 5790 /** 5791 * Removes the given pre-processing resource changed listener. 5792 * <p> 5793 * Has no effect if an identical listener is not registered. 5794 * </p> 5795 * 5796 * @param listener the listener 5797 * @since 3.0 5798 */ removePreProcessingResourceChangedListener(IResourceChangeListener listener)5799 public static void removePreProcessingResourceChangedListener(IResourceChangeListener listener) { 5800 JavaModelManager.getDeltaState().removePreResourceChangedListener(listener); 5801 } 5802 5803 /** 5804 * Deletes the index, then rebuilds any portions of the index that are 5805 * currently needed by the workspace. 5806 * 5807 * @param monitor a progress monitor, or <code>null</code> if progress 5808 * reporting and cancellation are not desired 5809 * @throws CoreException 5810 * @since 3.13 5811 */ rebuildIndex(IProgressMonitor monitor)5812 public static void rebuildIndex(IProgressMonitor monitor) throws CoreException { 5813 SubMonitor subMonitor = SubMonitor.convert(monitor, 100); 5814 IndexManager manager = JavaModelManager.getIndexManager(); 5815 manager.deleteIndexFiles(subMonitor.split(1)); 5816 manager.reset(); 5817 // New index is disabled, see bug 544898. 5818 // However we keep this call here to cleanup the possibly existing database 5819 Indexer.getInstance().rebuildIndex(subMonitor.split(95)); 5820 updateLegacyIndex(subMonitor.split(4)); 5821 } 5822 5823 /** 5824 * Runs the given action as an atomic Java model operation. 5825 * <p> 5826 * After running a method that modifies java elements, 5827 * registered listeners receive after-the-fact notification of 5828 * what just transpired, in the form of a element changed event. 5829 * This method allows clients to call a number of 5830 * methods that modify java elements and only have element 5831 * changed event notifications reported at the end of the entire 5832 * batch. 5833 * </p> 5834 * <p> 5835 * If this method is called outside the dynamic scope of another such 5836 * call, this method runs the action and then reports a single 5837 * element changed event describing the net effect of all changes 5838 * done to java elements by the action. 5839 * </p> 5840 * <p> 5841 * If this method is called in the dynamic scope of another such 5842 * call, this method simply runs the action. 5843 * </p> 5844 * 5845 * @param action the action to perform 5846 * @param monitor a progress monitor, or <code>null</code> if progress 5847 * reporting and cancellation are not desired 5848 * @exception CoreException if the operation failed. 5849 * @since 2.1 5850 */ run(IWorkspaceRunnable action, IProgressMonitor monitor)5851 public static void run(IWorkspaceRunnable action, IProgressMonitor monitor) throws CoreException { 5852 run(action, ResourcesPlugin.getWorkspace().getRoot(), monitor); 5853 } 5854 /** 5855 * Runs the given action as an atomic Java model operation. 5856 * <p> 5857 * After running a method that modifies java elements, 5858 * registered listeners receive after-the-fact notification of 5859 * what just transpired, in the form of a element changed event. 5860 * This method allows clients to call a number of 5861 * methods that modify java elements and only have element 5862 * changed event notifications reported at the end of the entire 5863 * batch. 5864 * </p> 5865 * <p> 5866 * If this method is called outside the dynamic scope of another such 5867 * call, this method runs the action and then reports a single 5868 * element changed event describing the net effect of all changes 5869 * done to java elements by the action. 5870 * </p> 5871 * <p> 5872 * If this method is called in the dynamic scope of another such 5873 * call, this method simply runs the action. 5874 * </p> 5875 * <p> 5876 * The supplied scheduling rule is used to determine whether this operation can be 5877 * run simultaneously with workspace changes in other threads. See 5878 * <code>IWorkspace.run(...)</code> for more details. 5879 * </p> 5880 * 5881 * @param action the action to perform 5882 * @param rule the scheduling rule to use when running this operation, or 5883 * <code>null</code> if there are no scheduling restrictions for this operation. 5884 * @param monitor a progress monitor, or <code>null</code> if progress 5885 * reporting and cancellation are not desired 5886 * @exception CoreException if the operation failed. 5887 * @since 3.0 5888 */ run(IWorkspaceRunnable action, ISchedulingRule rule, IProgressMonitor monitor)5889 public static void run(IWorkspaceRunnable action, ISchedulingRule rule, IProgressMonitor monitor) throws CoreException { 5890 IWorkspace workspace = ResourcesPlugin.getWorkspace(); 5891 if (workspace.isTreeLocked()) { 5892 new BatchOperation(action).run(monitor); 5893 } else { 5894 // use IWorkspace.run(...) to ensure that a build will be done in autobuild mode 5895 workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE, monitor); 5896 } 5897 } 5898 /** 5899 * Bind a container reference path to some actual containers (<code>IClasspathContainer</code>). 5900 * This API must be invoked whenever changes in container need to be reflected onto the JavaModel. 5901 * Containers can have distinct values in different projects, therefore this API considers a 5902 * set of projects with their respective containers. 5903 * <p> 5904 * <code>containerPath</code> is the path under which these values can be referenced through 5905 * container classpath entries (<code>IClasspathEntry#CPE_CONTAINER</code>). A container path 5906 * is formed by a first ID segment followed with extra segments, which can be used as additional hints 5907 * for the resolution. The container ID is used to identify a <code>ClasspathContainerInitializer</code> 5908 * registered on the extension point "org.eclipse.jdt.core.classpathContainerInitializer". 5909 * </p> 5910 * <p> 5911 * There is no assumption that each individual container value passed in argument 5912 * (<code>respectiveContainers</code>) must answer the exact same path when requested 5913 * <code>IClasspathContainer#getPath</code>. 5914 * Indeed, the containerPath is just an indication for resolving it to an actual container object. It can be 5915 * delegated to a <code>ClasspathContainerInitializer</code>, which can be activated through the extension 5916 * point "org.eclipse.jdt.core.ClasspathContainerInitializer"). 5917 * </p> 5918 * <p> 5919 * In reaction to changing container values, the JavaModel will be updated to reflect the new 5920 * state of the updated container. A combined Java element delta will be notified to describe the corresponding 5921 * classpath changes resulting from the container update. This operation is batched, and automatically eliminates 5922 * unnecessary updates (new container is same as old one). This operation acquires a lock on the workspace's root. 5923 * </p> 5924 * <p> 5925 * This functionality cannot be used while the workspace is locked, since 5926 * it may create/remove some resource markers. 5927 * </p> 5928 * <p> 5929 * Classpath container values are persisted locally to the workspace, but 5930 * are not preserved from a session to another. It is thus highly recommended to register a 5931 * <code>ClasspathContainerInitializer</code> for each referenced container 5932 * (through the extension point "org.eclipse.jdt.core.ClasspathContainerInitializer"). 5933 * </p> 5934 * <p> 5935 * Note: setting a container to <code>null</code> will cause it to be lazily resolved again whenever 5936 * its value is required. In particular, this will cause a registered initializer to be invoked 5937 * again. 5938 * </p> 5939 * @param containerPath - the name of the container reference, which is being updated 5940 * @param affectedProjects - the set of projects for which this container is being bound 5941 * @param respectiveContainers - the set of respective containers for the affected projects 5942 * @param monitor a monitor to report progress 5943 * @throws JavaModelException 5944 * @see ClasspathContainerInitializer 5945 * @see #getClasspathContainer(IPath, IJavaProject) 5946 * @see IClasspathContainer 5947 * @since 2.0 5948 */ setClasspathContainer(IPath containerPath, IJavaProject[] affectedProjects, IClasspathContainer[] respectiveContainers, IProgressMonitor monitor)5949 public static void setClasspathContainer(IPath containerPath, IJavaProject[] affectedProjects, IClasspathContainer[] respectiveContainers, IProgressMonitor monitor) throws JavaModelException { 5950 if (affectedProjects.length != respectiveContainers.length) 5951 throw new ClasspathEntry.AssertionFailedException("Projects and containers collections should have the same size"); //$NON-NLS-1$ 5952 if (affectedProjects.length == 1) { 5953 IClasspathContainer container = respectiveContainers[0]; 5954 if (container != null) { 5955 JavaModelManager manager = JavaModelManager.getJavaModelManager(); 5956 IJavaProject project = affectedProjects[0]; 5957 IClasspathContainer existingCointainer = manager.containerGet(project, containerPath); 5958 if (existingCointainer == JavaModelManager.CONTAINER_INITIALIZATION_IN_PROGRESS) { 5959 manager.containerBeingInitializedPut(project, containerPath, container); 5960 return; 5961 } 5962 } 5963 } 5964 SetContainerOperation operation = new SetContainerOperation(containerPath, affectedProjects, respectiveContainers); 5965 operation.runOperation(monitor); 5966 } 5967 5968 /** 5969 * Sets the value of the given classpath variable. 5970 * The path must have at least one segment. 5971 * <p> 5972 * This functionality cannot be used while the resource tree is locked. 5973 * </p> 5974 * <p> 5975 * Classpath variable values are persisted locally to the workspace, and 5976 * are preserved from session to session. 5977 * </p> 5978 * 5979 * @param variableName the name of the classpath variable 5980 * @param path the path 5981 * @throws JavaModelException 5982 * @see #getClasspathVariable(String) 5983 * 5984 * @deprecated Use {@link #setClasspathVariable(String, IPath, IProgressMonitor)} instead 5985 */ setClasspathVariable(String variableName, IPath path)5986 public static void setClasspathVariable(String variableName, IPath path) 5987 throws JavaModelException { 5988 5989 setClasspathVariable(variableName, path, null); 5990 } 5991 5992 /** 5993 * Sets the value of the given classpath variable. 5994 * The path must not be null. 5995 * Since 3.5, the path to a library can also be relative to the project using ".." as the first segment. 5996 * <p> 5997 * This functionality cannot be used while the resource tree is locked. 5998 * </p> 5999 * <p> 6000 * Classpath variable values are persisted locally to the workspace, and 6001 * are preserved from session to session. 6002 * </p> 6003 * <p> 6004 * Updating a variable with the same value has no effect. 6005 * </p> 6006 * 6007 * @param variableName the name of the classpath variable 6008 * @param path the path 6009 * @param monitor a monitor to report progress 6010 * @throws JavaModelException 6011 * @see #getClasspathVariable(String) 6012 */ setClasspathVariable( String variableName, IPath path, IProgressMonitor monitor)6013 public static void setClasspathVariable( 6014 String variableName, 6015 IPath path, 6016 IProgressMonitor monitor) 6017 throws JavaModelException { 6018 6019 if (path == null) throw new ClasspathEntry.AssertionFailedException("Variable path cannot be null"); //$NON-NLS-1$ 6020 setClasspathVariables(new String[]{variableName}, new IPath[]{ path }, monitor); 6021 } 6022 6023 /** 6024 * Sets the values of all the given classpath variables at once. 6025 * Null paths can be used to request corresponding variable removal. 6026 * Since 3.5, the path to a library can also be relative to the project using ".." as the first segment. 6027 * <p> 6028 * A combined Java element delta will be notified to describe the corresponding 6029 * classpath changes resulting from the variables update. This operation is batched, 6030 * and automatically eliminates unnecessary updates (new variable is same as old one). 6031 * This operation acquires a lock on the workspace's root. 6032 * </p> 6033 * <p> 6034 * This functionality cannot be used while the workspace is locked, since 6035 * it may create/remove some resource markers. 6036 * </p> 6037 * <p> 6038 * Classpath variable values are persisted locally to the workspace, and 6039 * are preserved from session to session. 6040 * </p> 6041 * <p> 6042 * Updating a variable with the same value has no effect. 6043 * </p> 6044 * 6045 * @param variableNames an array of names for the updated classpath variables 6046 * @param paths an array of path updates for the modified classpath variables (null 6047 * meaning that the corresponding value will be removed 6048 * @param monitor a monitor to report progress 6049 * @throws JavaModelException 6050 * @see #getClasspathVariable(String) 6051 * @since 2.0 6052 */ setClasspathVariables( String[] variableNames, IPath[] paths, IProgressMonitor monitor)6053 public static void setClasspathVariables( 6054 String[] variableNames, 6055 IPath[] paths, 6056 IProgressMonitor monitor) 6057 throws JavaModelException { 6058 6059 if (variableNames.length != paths.length) throw new ClasspathEntry.AssertionFailedException("Variable names and paths collections should have the same size"); //$NON-NLS-1$ 6060 SetVariablesOperation operation = new SetVariablesOperation(variableNames, paths, true/*update preferences*/); 6061 operation.runOperation(monitor); 6062 } 6063 6064 /** 6065 * Sets the default compiler options inside the given options map according 6066 * to the given compliance. 6067 * 6068 * <p>The given compliance must be one of those supported by the compiler, 6069 * that is one of the acceptable values for option {@link #COMPILER_COMPLIANCE}.</p> 6070 * 6071 * <p>The list of modified options is currently:</p> 6072 * <ul> 6073 * <li>{@link #COMPILER_COMPLIANCE}</li> 6074 * <li>{@link #COMPILER_SOURCE}</li> 6075 * <li>{@link #COMPILER_CODEGEN_TARGET_PLATFORM}</li> 6076 * <li>{@link #COMPILER_PB_ASSERT_IDENTIFIER}</li> 6077 * <li>{@link #COMPILER_PB_ENUM_IDENTIFIER}</li> 6078 * <li>{@link #COMPILER_CODEGEN_INLINE_JSR_BYTECODE} for compliance levels 1.5 and greater</li> 6079 * <li>{@link #COMPILER_PB_ENABLE_PREVIEW_FEATURES} for compliance levels 11 and greater</li> 6080 * <li>{@link #COMPILER_PB_REPORT_PREVIEW_FEATURES} for compliance levels 11 and greater</li> 6081 * </ul> 6082 * 6083 * <p>If the given compliance is unknown, the given map is unmodified.</p> 6084 * 6085 * @param compliance the given {@link #COMPILER_COMPLIANCE compliance} 6086 * @param options the given options map 6087 * @since 3.3 6088 */ setComplianceOptions(String compliance, Map options)6089 public static void setComplianceOptions(String compliance, Map options) { 6090 long jdkLevel = CompilerOptions.versionToJdkLevel(compliance); 6091 int major = (int) (jdkLevel >>> 16); 6092 switch(major) { 6093 case ClassFileConstants.MAJOR_VERSION_1_3: 6094 options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_3); 6095 options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3); 6096 options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_1); 6097 options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.IGNORE); 6098 options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.IGNORE); 6099 break; 6100 case ClassFileConstants.MAJOR_VERSION_1_4: 6101 options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4); 6102 options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3); 6103 options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2); 6104 options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.WARNING); 6105 options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.WARNING); 6106 break; 6107 case ClassFileConstants.MAJOR_VERSION_1_5: 6108 options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); 6109 options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); 6110 options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); 6111 options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); 6112 options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); 6113 options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); 6114 break; 6115 case ClassFileConstants.MAJOR_VERSION_1_6: 6116 options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_6); 6117 options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_6); 6118 options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_6); 6119 options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); 6120 options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); 6121 options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); 6122 break; 6123 case ClassFileConstants.MAJOR_VERSION_1_7: 6124 options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7); 6125 options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_7); 6126 options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_7); 6127 options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); 6128 options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); 6129 options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); 6130 break; 6131 case ClassFileConstants.MAJOR_VERSION_1_8: 6132 options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8); 6133 options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8); 6134 options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8); 6135 options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); 6136 options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); 6137 options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); 6138 break; 6139 case ClassFileConstants.MAJOR_VERSION_9: 6140 options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_9); 6141 options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_9); 6142 options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_9); 6143 options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); 6144 options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); 6145 options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); 6146 options.put(JavaCore.COMPILER_RELEASE, JavaCore.ENABLED); 6147 break; 6148 case ClassFileConstants.MAJOR_VERSION_10: 6149 options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_10); 6150 options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_10); 6151 options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_10); 6152 options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); 6153 options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); 6154 options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); 6155 options.put(JavaCore.COMPILER_RELEASE, JavaCore.ENABLED); 6156 break; 6157 default: 6158 if(major > ClassFileConstants.MAJOR_VERSION_10) { 6159 String version = CompilerOptions.versionFromJdkLevel(jdkLevel); 6160 options.put(JavaCore.COMPILER_COMPLIANCE, version); 6161 options.put(JavaCore.COMPILER_SOURCE, version); 6162 options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, version); 6163 options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); 6164 options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); 6165 options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); 6166 options.put(JavaCore.COMPILER_RELEASE, JavaCore.ENABLED); 6167 options.put(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.DISABLED); 6168 options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.WARNING); 6169 } 6170 break; 6171 } 6172 } 6173 6174 /** 6175 * Sets the current table of options. All and only the options explicitly 6176 * included in the given table are remembered; all previous option settings 6177 * are forgotten, including ones not explicitly mentioned. 6178 * <p> 6179 * Helper constants have been defined on JavaCore for each of the option IDs 6180 * (categorized in Code assist option ID, Compiler option ID and Core option ID) 6181 * and some of their acceptable values (categorized in Option value). Some 6182 * options accept open value sets beyond the documented constant values. 6183 * </p> 6184 * Note: each release may add new options. 6185 * 6186 * @param newOptions 6187 * the new options (key type: <code>String</code>; value type: 6188 * <code>String</code>), or <code>null</code> to reset all 6189 * options to their default values 6190 * @see JavaCore#getDefaultOptions() 6191 * @see JavaCorePreferenceInitializer for changing default settings 6192 */ setOptions(Hashtable<String, String> newOptions)6193 public static void setOptions(Hashtable<String, String> newOptions) { 6194 JavaModelManager.getJavaModelManager().setOptions(newOptions); 6195 } 6196 6197 /** 6198 * Returns the latest version of Java supported by the Java Model. This is usually the last entry 6199 * from {@link JavaCore#getAllVersions()}. 6200 * 6201 * @since 3.16 6202 * @return the latest Java version support by Java Model 6203 */ latestSupportedJavaVersion()6204 public static String latestSupportedJavaVersion() { 6205 return allVersions.get(allVersions.size() - 1); 6206 } 6207 /** 6208 * Compares two given versions of the Java platform. The versions being compared must both be 6209 * one of the supported values mentioned in 6210 * {@link #COMPILER_CODEGEN_TARGET_PLATFORM COMPILER_CODEGEN_TARGET_PLATFORM}, 6211 * both values from {@link #COMPILER_COMPLIANCE}, or both values from {@link #COMPILER_SOURCE}. 6212 * 6213 * @param first first version to be compared 6214 * @param second second version to be compared 6215 * @return the value {@code 0} if both versions are the same; 6216 * a value less than {@code 0} if <code>first</code> is smaller than <code>second</code>; and 6217 * a value greater than {@code 0} if <code>first</code> is higher than <code>second</code> 6218 * @since 3.12 6219 */ compareJavaVersions(String first, String second)6220 public static int compareJavaVersions(String first, String second) { 6221 return Long.compare(CompilerOptions.versionToJdkLevel(first), CompilerOptions.versionToJdkLevel(second)); 6222 } 6223 /** 6224 * Returns an array of module names referenced by this project indirectly. 6225 * This is a helper method that can be used to construct a Java module 6226 * description of an existing project. The referenced modules can either be 6227 * system modules or user modules found in project build path in the form of 6228 * libraries. 6229 * The prerequisites for this to be effective are: 6230 * <ul> 6231 * <li>the project is already in compliance level 9 or above. 6232 * <li>the system library on the build path of the project is a modularized Java Runtime. 6233 * </ul> 6234 * 6235 * @param project 6236 * the project whose referenced modules to be computed 6237 * @return an array of String containing module names 6238 * @throws CoreException 6239 * @since 3.14 6240 */ getReferencedModules(IJavaProject project)6241 public static String[] getReferencedModules(IJavaProject project) throws CoreException { 6242 return ModuleUtil.getReferencedModules(project); 6243 } 6244 6245 /** 6246 * Returns the <code>IModuleDescription</code> that the given java element contains 6247 * when regarded as an automatic module. The element must be an <code>IPackageFragmentRoot</code> 6248 * or an <code>IJavaProject</code>. 6249 * 6250 * <p>The returned module descriptor has a name (<code>getElementName()</code>) following 6251 * the specification of <code>java.lang.module.ModuleFinder.of(Path...)</code>, but it 6252 * contains no other useful information.</p> 6253 * 6254 * @return the <code>IModuleDescription</code> representing this java element as an automatic module, 6255 * never <code>null</code>. 6256 * @throws JavaModelException 6257 * @throws IllegalArgumentException if the provided element is neither <code>IPackageFragmentRoot</code> 6258 * nor <code>IJavaProject</code> 6259 * @since 3.14 6260 */ getAutomaticModuleDescription(IJavaElement element)6261 public static IModuleDescription getAutomaticModuleDescription(IJavaElement element) throws JavaModelException, IllegalArgumentException { 6262 switch (element.getElementType()) { 6263 case IJavaElement.JAVA_PROJECT: 6264 return ((JavaProject) element).getAutomaticModuleDescription(); 6265 case IJavaElement.PACKAGE_FRAGMENT_ROOT: 6266 return ((PackageFragmentRoot) element).getAutomaticModuleDescription(); 6267 default: 6268 throw new IllegalArgumentException("Illegal kind of java element: "+element.getElementType()); //$NON-NLS-1$ 6269 } 6270 } 6271 6272 /** 6273 * Filter the given set of system roots by the rules for root modules from JEP 261. 6274 * @param allSystemRoots all physically available system modules, represented by their package fragment roots 6275 * @return the list of names of default root modules 6276 * @since 3.14 6277 */ defaultRootModules(Iterable<IPackageFragmentRoot> allSystemRoots)6278 public static List<String> defaultRootModules(Iterable<IPackageFragmentRoot> allSystemRoots) { 6279 return JavaProject.defaultRootModules(allSystemRoots); 6280 } 6281 6282 /** 6283 * Compile the given module description in the context of its enclosing Java project 6284 * and add class file attributes using the given map of attribute values. 6285 * <p>In this map, the following keys are supported</p> 6286 * <dl> 6287 * <dt>{@link IAttributeNamesConstants#MODULE_MAIN_CLASS}</dt> 6288 * <dd>The associated value will be used for the <code>ModuleMainClass</code> attribute.</dd> 6289 * <dt>{@link IAttributeNamesConstants#MODULE_PACKAGES}</dt> 6290 * <dd>If the associated value is an empty string, then the compiler will generate a 6291 * <code>ModulePackages</code> attribute with a list of packages that is computed from 6292 * <ul> 6293 * <li>all <code>exports</code> directives 6294 * <li>all <code>opens</code> directives 6295 * <li>the implementation classes of all <code>provides</code> directives. 6296 * </ul> 6297 * If the associated value is not empty, it must be a comma-separated list of package names, 6298 * which will be added to the computed list. 6299 * </dl> 6300 * <p>No other keys are supported in this version, but more keys may be added in the future.</p> 6301 * 6302 * @param module handle for the <code>module-info.java</code> file to be compiled. 6303 * @param classFileAttributes map of attribute names and values to be used during class file generation 6304 * @return the compiled byte code 6305 * 6306 * @throws JavaModelException 6307 * @throws IllegalArgumentException if the map of classFileAttributes contains an unsupported key. 6308 * @since 3.14 6309 */ compileWithAttributes(IModuleDescription module, Map<String,String> classFileAttributes)6310 public static byte[] compileWithAttributes(IModuleDescription module, Map<String,String> classFileAttributes) 6311 throws JavaModelException, IllegalArgumentException 6312 { 6313 return new ModuleInfoBuilder().compileWithAttributes(module, classFileAttributes); 6314 } 6315 6316 /** 6317 * Returns the module name computed for a jar. If the file is a jar and contains a module-info.class, the name 6318 * specified in it is used, otherwise, the algorithm for automatic module naming is used, which first looks for a 6319 * module name in the Manifest.MF and as last resort computes it from the file name. 6320 * 6321 * @param file the jar to examine 6322 * @return null if file is not a file, otherwise the module name. 6323 * @since 3.14 6324 */ getModuleNameFromJar(File file)6325 public static String getModuleNameFromJar(File file) { 6326 if (!file.isFile()) { 6327 return null; 6328 } 6329 6330 char[] moduleName = null; 6331 try (ZipFile zipFile = new ZipFile(file)) { 6332 IModule module = null; 6333 ClassFileReader reader = ClassFileReader.read(zipFile, IModule.MODULE_INFO_CLASS); 6334 if (reader != null) { 6335 module = reader.getModuleDeclaration(); 6336 if (module != null) { 6337 moduleName = module.name(); 6338 } 6339 } 6340 } catch (ClassFormatException | IOException ex) { 6341 Util.log(ex); 6342 } 6343 if (moduleName == null) { 6344 moduleName = AutomaticModuleNaming.determineAutomaticModuleName(file.getAbsolutePath()); 6345 } 6346 return new String(moduleName); 6347 } 6348 6349 /** 6350 * Returns the names of the modules required by the module-info.class in the jar. If the file is not jar or a jar 6351 * that has no module-info.class is present, the empty set is returned. 6352 * 6353 * @param file the jar to examine 6354 * @return set of module names. 6355 * @since 3.14 6356 */ getRequiredModulesFromJar(File file)6357 public static Set<String> getRequiredModulesFromJar(File file) { 6358 if (!file.isFile()) { 6359 return Collections.emptySet(); 6360 } 6361 try (ZipFile zipFile = new ZipFile(file)) { 6362 IModule module = null; 6363 ClassFileReader reader = ClassFileReader.read(zipFile, IModule.MODULE_INFO_CLASS); 6364 if (reader != null) { 6365 module = reader.getModuleDeclaration(); 6366 if (module != null) { 6367 IModuleReference[] moduleRefs = module.requires(); 6368 if (moduleRefs != null) { 6369 return Stream.of(moduleRefs).map(m -> new String(m.name())) 6370 .collect(Collectors.toCollection(LinkedHashSet::new)); 6371 } 6372 } 6373 } 6374 } catch (ClassFormatException | IOException ex) { 6375 Util.log(ex); 6376 } 6377 return Collections.emptySet(); 6378 } 6379 6380 6381 /* (non-Javadoc) 6382 * Shutdown the JavaCore plug-in. 6383 * <p> 6384 * De-registers the JavaModelManager as a resource changed listener and save participant. 6385 * </p> 6386 * @see org.eclipse.core.runtime.Plugin#stop(BundleContext) 6387 */ 6388 @Override stop(BundleContext context)6389 public void stop(BundleContext context) throws Exception { 6390 try { 6391 JavaModelManager.unregisterDebugOptionsListener(); 6392 JavaModelManager.getJavaModelManager().shutdown(); 6393 } finally { 6394 // ensure we call super.stop as the last thing 6395 super.stop(context); 6396 } 6397 } 6398 6399 /* (non-Javadoc) 6400 * Startup the JavaCore plug-in. 6401 * <p> 6402 * Registers the JavaModelManager as a resource changed listener and save participant. 6403 * Starts the background indexing, and restore saved classpath variable values. 6404 * </p> 6405 * @throws Exception 6406 * @see org.eclipse.core.runtime.Plugin#start(BundleContext) 6407 */ 6408 @Override start(BundleContext context)6409 public void start(BundleContext context) throws Exception { 6410 super.start(context); 6411 JavaModelManager.registerDebugOptionsListener(context); 6412 JavaModelManager.getJavaModelManager().startup(); 6413 // New index is disabled, see bug 544898 6414 // Indexer.getInstance().rescanAll(); 6415 } 6416 } 6417