1 package net.sourceforge.phpdt.core;
4 import java.util.ArrayList;
5 import java.util.Collection;
6 import java.util.Enumeration;
7 import java.util.HashSet;
8 import java.util.Hashtable;
12 import net.sourceforge.phpdt.internal.core.BatchOperation;
13 import net.sourceforge.phpdt.internal.core.BufferManager;
14 import net.sourceforge.phpdt.internal.core.ClasspathEntry;
15 import net.sourceforge.phpdt.internal.core.JavaModel;
16 import net.sourceforge.phpdt.internal.core.JavaModelManager;
17 import net.sourceforge.phpdt.internal.core.Region;
18 import net.sourceforge.phpdt.internal.corext.Assert;
19 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
21 import org.eclipse.core.resources.IFile;
22 import org.eclipse.core.resources.IFolder;
23 import org.eclipse.core.resources.IMarker;
24 import org.eclipse.core.resources.IMarkerDelta;
25 import org.eclipse.core.resources.IProject;
26 import org.eclipse.core.resources.IProjectDescription;
27 import org.eclipse.core.resources.IResource;
28 import org.eclipse.core.resources.IResourceChangeEvent;
29 import org.eclipse.core.resources.IWorkspace;
30 import org.eclipse.core.resources.IWorkspaceRoot;
31 import org.eclipse.core.resources.IWorkspaceRunnable;
32 import org.eclipse.core.resources.ResourcesPlugin;
33 import org.eclipse.core.runtime.CoreException;
34 import org.eclipse.core.runtime.IConfigurationElement;
35 import org.eclipse.core.runtime.IPath;
36 import org.eclipse.core.runtime.IProgressMonitor;
37 import org.eclipse.core.runtime.Plugin;
38 import org.eclipse.core.runtime.Preferences;
40 public class JavaCore {
42 // public static HashSet OptionNames = new HashSet(20);
44 * The plug-in identifier of the Java core support
45 * (value <code>"net.sourceforge.phpeclipse"</code>)
47 // public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.core"; //$NON-NLS-1$
48 public static final String PLUGIN_ID = PHPeclipsePlugin.PLUGIN_ID;
50 * Possible configurable option ID.
51 * @see #getDefaultOptions
54 public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; //$NON-NLS-1$
57 * Possible configurable option ID.
58 * @see #getDefaultOptions
61 public static final String FORMATTER_NEWLINE_OPENING_BRACE = PLUGIN_ID + ".formatter.newline.openingBrace"; //$NON-NLS-1$
63 * Possible configurable option ID.
64 * @see #getDefaultOptions
67 public static final String FORMATTER_NEWLINE_CONTROL = PLUGIN_ID + ".formatter.newline.controlStatement"; //$NON-NLS-1$
69 * Possible configurable option ID.
70 * @see #getDefaultOptions
73 public static final String FORMATTER_NEWLINE_ELSE_IF = PLUGIN_ID + ".formatter.newline.elseIf"; //$NON-NLS-1$
75 * Possible configurable option ID.
76 * @see #getDefaultOptions
79 public static final String FORMATTER_NEWLINE_EMPTY_BLOCK = PLUGIN_ID + ".formatter.newline.emptyBlock"; //$NON-NLS-1$
81 * Possible configurable option ID.
82 * @see #getDefaultOptions
85 public static final String FORMATTER_CLEAR_BLANK_LINES = PLUGIN_ID + ".formatter.newline.clearAll"; //$NON-NLS-1$
87 * Possible configurable option ID.
88 * @see #getDefaultOptions
91 public static final String FORMATTER_LINE_SPLIT = PLUGIN_ID + ".formatter.lineSplit"; //$NON-NLS-1$
93 * Possible configurable option ID.
94 * @see #getDefaultOptions
97 public static final String FORMATTER_COMPACT_ASSIGNMENT = PLUGIN_ID + ".formatter.style.assignment"; //$NON-NLS-1$
99 * Possible configurable option ID.
100 * @see #getDefaultOptions
103 public static final String FORMATTER_TAB_CHAR = PLUGIN_ID + ".formatter.tabulation.char"; //$NON-NLS-1$
105 * Possible configurable option ID.
106 * @see #getDefaultOptions
109 public static final String FORMATTER_TAB_SIZE = PLUGIN_ID + ".formatter.tabulation.size"; //$NON-NLS-1$
111 * Possible configurable option value.
112 * @see #getDefaultOptions
115 public static final String INSERT = "insert"; //$NON-NLS-1$
117 * Possible configurable option value.
118 * @see #getDefaultOptions
121 public static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$
124 * Possible configurable option value.
125 * @see #getDefaultOptions
128 public static final String PRESERVE_ONE = "preserve one"; //$NON-NLS-1$
130 * Possible configurable option value.
131 * @see #getDefaultOptions
134 public static final String CLEAR_ALL = "clear all"; //$NON-NLS-1$
136 * Possible configurable option value.
137 * @see #getDefaultOptions
140 public static final String NORMAL = "normal"; //$NON-NLS-1$
142 * Possible configurable option value.
143 * @see #getDefaultOptions
146 public static final String COMPACT = "compact"; //$NON-NLS-1$
148 * Possible configurable option value.
149 * @see #getDefaultOptions
152 public static final String TAB = "tab"; //$NON-NLS-1$
154 * Possible configurable option value.
155 * @see #getDefaultOptions
158 public static final String SPACE = "space"; //$NON-NLS-1$
160 * Possible configurable option value.
161 * @see #getDefaultOptions
164 public static final String ENABLED = "enabled"; //$NON-NLS-1$
166 * Possible configurable option value.
167 * @see #getDefaultOptions
170 public static final String DISABLED = "disabled"; //$NON-NLS-1$
172 * Possible configurable option value.
173 * @see #getDefaultOptions
176 public static final String CLEAN = "clean"; //$NON-NLS-1$
179 * Possible configurable option ID.
180 * @see #getDefaultOptions
183 public static final String COMPILER_TASK_TAGS = PLUGIN_ID + ".compiler.taskTags"; //$NON-NLS-1$
186 * Name of the handle id attribute in a Java marker.
188 protected static final String ATT_HANDLE_ID =
189 "net.sourceforge.phpdt.internal.core.JavaModelManager.handleId" ; //$NON-NLS-1$
191 // *************** Possible IDs for configurable options. ********************
194 * Possible configurable option ID.
195 * @see #getDefaultOptions()
197 public static final String COMPILER_LOCAL_VARIABLE_ATTR = PLUGIN_ID + ".compiler.debug.localVariable"; //$NON-NLS-1$
199 * Possible configurable option ID.
200 * @see #getDefaultOptions()
202 public static final String COMPILER_LINE_NUMBER_ATTR = PLUGIN_ID + ".compiler.debug.lineNumber"; //$NON-NLS-1$
204 * Possible configurable option ID.
205 * @see #getDefaultOptions
207 public static final String COMPILER_SOURCE_FILE_ATTR = PLUGIN_ID + ".compiler.debug.sourceFile"; //$NON-NLS-1$
209 * Possible configurable option ID.
210 * @see #getDefaultOptions
212 public static final String COMPILER_CODEGEN_UNUSED_LOCAL = PLUGIN_ID + ".compiler.codegen.unusedLocal"; //$NON-NLS-1$
214 * Possible configurable option ID.
215 * @see #getDefaultOptions
217 public static final String COMPILER_CODEGEN_TARGET_PLATFORM = PLUGIN_ID + ".compiler.codegen.targetPlatform"; //$NON-NLS-1$
220 * Possible configurable option ID.
221 * @see #getDefaultOptions
223 public static final String COMPILER_PB_PHP_VAR_DEPRECATED = PLUGIN_ID + ".compiler.problem.phpVarDeprecatedWarning"; //$NON-NLS-1$
226 * Possible configurable option ID.
227 * @see #getDefaultOptions
229 public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID + ".compiler.problem.unreachableCode"; //$NON-NLS-1$
231 * Possible configurable option ID.
232 * @see #getDefaultOptions
234 public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID + ".compiler.problem.invalidImport"; //$NON-NLS-1$
236 * Possible configurable option ID.
237 * @see #getDefaultOptions
239 public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID + ".compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
241 * Possible configurable option ID.
242 * @see #getDefaultOptions
244 public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID + ".compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
247 * Possible configurable option ID.
248 * @see #getDefaultOptions
250 public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID + ".compiler.problem.deprecation"; //$NON-NLS-1$
252 * Possible configurable option ID.
253 * @see #getDefaultOptions
256 public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID + ".compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
258 * Possible configurable option ID.
259 * @see #getDefaultOptions
261 public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID + ".compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
263 * Possible configurable option ID.
264 * @see #getDefaultOptions
266 public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID + ".compiler.problem.unusedLocal"; //$NON-NLS-1$
268 * Possible configurable option ID.
269 * @see #getDefaultOptions
271 public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID + ".compiler.problem.unusedParameter"; //$NON-NLS-1$
273 * Possible configurable option ID.
274 * @see #getDefaultOptions
277 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID + ".compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
279 * Possible configurable option ID.
280 * @see #getDefaultOptions
283 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID + ".compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
285 * Possible configurable option ID.
286 * @see #getDefaultOptions
289 public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID + ".compiler.problem.unusedImport"; //$NON-NLS-1$
291 * Possible configurable option ID.
292 * @see #getDefaultOptions
294 public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID + ".compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
296 * Possible configurable option ID.
297 * @see #getDefaultOptions
300 public static final String COMPILER_PB_NON_NLS_STRING_LITERAL = PLUGIN_ID + ".compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
302 * Possible configurable option ID.
303 * @see #getDefaultOptions
306 public static final String COMPILER_PB_ASSERT_IDENTIFIER = PLUGIN_ID + ".compiler.problem.assertIdentifier"; //$NON-NLS-1$
308 * Possible configurable option ID.
309 * @see #getDefaultOptions
312 public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID + ".compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
314 * Possible configurable option ID.
315 * @see #getDefaultOptions
318 public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID + ".compiler.problem.noEffectAssignment"; //$NON-NLS-1$
320 * Possible configurable option ID.
321 * @see #getDefaultOptions
324 public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
326 * Possible configurable option ID.
327 * @see #getDefaultOptions
330 public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
332 * Possible configurable option ID.
333 * @see #getDefaultOptions
336 public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
338 * Possible configurable option ID.
339 * @see #getDefaultOptions
342 public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID + ".compiler.maxProblemPerUnit"; //$NON-NLS-1$
344 * Possible configurable option ID.
345 * @see #getDefaultOptions
348 public static final String COMPILER_SOURCE = PLUGIN_ID + ".compiler.source"; //$NON-NLS-1$
350 * Possible configurable option ID.
351 * @see #getDefaultOptions
354 public static final String COMPILER_COMPLIANCE = PLUGIN_ID + ".compiler.compliance"; //$NON-NLS-1$
356 * Possible configurable option ID.
357 * @see #getDefaultOptions
360 public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID + ".compiler.taskPriorities"; //$NON-NLS-1$
362 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
363 * @see #getDefaultOptions
366 public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$
368 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
369 * @see #getDefaultOptions
372 public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$
374 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
375 * @see #getDefaultOptions
378 public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$
380 * Possible configurable option ID.
381 * @see #getDefaultOptions
383 public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder"; //$NON-NLS-1$
385 * Possible configurable option ID.
386 * @see #getDefaultOptions
389 public static final String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER = PLUGIN_ID + ".builder.resourceCopyExclusionFilter"; //$NON-NLS-1$
391 * Possible configurable option ID.
392 * @see #getDefaultOptions
395 public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID + ".builder.duplicateResourceTask"; //$NON-NLS-1$
397 * Possible configurable option ID.
398 * @see #getDefaultOptions
401 public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID + ".builder.cleanOutputFolder"; //$NON-NLS-1$
403 * Possible configurable option ID.
404 * @see #getDefaultOptions
407 public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID + ".incompleteClasspath"; //$NON-NLS-1$
409 * Possible configurable option ID.
410 * @see #getDefaultOptions
413 public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID + ".circularClasspath"; //$NON-NLS-1$
415 * Possible configurable option ID.
416 * @see #getDefaultOptions
419 public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID + ".builder.invalidClasspath"; //$NON-NLS-1$
421 * Possible configurable option ID.
422 * @see #getDefaultOptions
425 public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID + ".classpath.exclusionPatterns"; //$NON-NLS-1$
427 * Possible configurable option ID.
428 * @see #getDefaultOptions
431 public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID + ".classpath.multipleOutputLocations"; //$NON-NLS-1$
436 public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$
438 * Default task priority
441 public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; //$NON-NLS-1$
443 * Possible configurable option ID
444 * @see #getDefaultOptions
447 public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID + ".formatter.space.castexpression"; //$NON-NLS-1$
449 * Possible configurable option ID.
450 * @see #getDefaultOptions
453 public static final String CODEASSIST_VISIBILITY_CHECK = PLUGIN_ID + ".codeComplete.visibilityCheck"; //$NON-NLS-1$
455 * Possible configurable option ID.
456 * @see #getDefaultOptions
459 public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID + ".codeComplete.forceImplicitQualification"; //$NON-NLS-1$
461 * Possible configurable option ID.
462 * @see #getDefaultOptions
465 public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.fieldPrefixes"; //$NON-NLS-1$
467 * Possible configurable option ID.
468 * @see #getDefaultOptions
471 public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
473 * Possible configurable option ID.
474 * @see #getDefaultOptions
477 public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID + ".codeComplete.localPrefixes"; //$NON-NLS-1$
479 * Possible configurable option ID.
480 * @see #getDefaultOptions
483 public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID + ".codeComplete.argumentPrefixes"; //$NON-NLS-1$
485 * Possible configurable option ID.
486 * @see #getDefaultOptions
489 public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.fieldSuffixes"; //$NON-NLS-1$
491 * Possible configurable option ID.
492 * @see #getDefaultOptions
495 public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
497 * Possible configurable option ID.
498 * @see #getDefaultOptions
501 public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID + ".codeComplete.localSuffixes"; //$NON-NLS-1$
503 * Possible configurable option ID.
504 * @see #getDefaultOptions
507 public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID + ".codeComplete.argumentSuffixes"; //$NON-NLS-1$
509 // *************** Possible values for configurable options. ********************
512 * Possible configurable option value.
513 * @see #getDefaultOptions
515 public static final String GENERATE = "generate"; //$NON-NLS-1$
517 * Possible configurable option value.
518 * @see #getDefaultOptions
520 public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
522 * Possible configurable option value.
523 * @see #getDefaultOptions
525 public static final String PRESERVE = "preserve"; //$NON-NLS-1$
527 * Possible configurable option value.
528 * @see #getDefaultOptions
530 public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
532 * Possible configurable option value.
533 * @see #getDefaultOptions
535 public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$
537 * Possible configurable option value.
538 * @see #getDefaultOptions
540 public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$
542 * Possible configurable option value.
543 * @see #getDefaultOptions
546 public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
548 * Possible configurable option value.
549 * @see #getDefaultOptions
552 public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
554 * Possible configurable option value.
555 * @see #getDefaultOptions
558 public static final String ABORT = "abort"; //$NON-NLS-1$
560 * Possible configurable option value.
561 * @see #getDefaultOptions
563 public static final String ERROR = "error"; //$NON-NLS-1$
565 * Possible configurable option value.
566 * @see #getDefaultOptions
568 public static final String WARNING = "warning"; //$NON-NLS-1$
570 * Possible configurable option value.
571 * @see #getDefaultOptions
573 public static final String IGNORE = "ignore"; //$NON-NLS-1$
575 * Possible configurable option value.
576 * @see #getDefaultOptions
578 public static final String COMPUTE = "compute"; //$NON-NLS-1$
580 * Possible configurable option value.
581 * @see #getDefaultOptions
587 * Returns a table of all known configurable options with their default values.
588 * These options allow to configure the behaviour of the underlying components.
589 * The client may safely use the result as a template that they can modify and
590 * then pass to <code>setOptions</code>.
592 * Helper constants have been defined on JavaCore for each of the option ID and
593 * their possible constant values.
595 * Note: more options might be added in further releases.
597 * RECOGNIZED OPTIONS:
598 * COMPILER / Generating Local Variable Debug Attribute
599 * When generated, this attribute will enable local variable names
600 * to be displayed in debugger, only in place where variables are
601 * definitely assigned (.class file is then bigger)
602 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.localVariable"
603 * - possible values: { "generate", "do not generate" }
604 * - default: "generate"
606 * COMPILER / Generating Line Number Debug Attribute
607 * When generated, this attribute will enable source code highlighting in debugger
608 * (.class file is then bigger).
609 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.lineNumber"
610 * - possible values: { "generate", "do not generate" }
611 * - default: "generate"
613 * COMPILER / Generating Source Debug Attribute
614 * When generated, this attribute will enable the debugger to present the
615 * corresponding source code.
616 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.sourceFile"
617 * - possible values: { "generate", "do not generate" }
618 * - default: "generate"
620 * COMPILER / Preserving Unused Local Variables
621 * Unless requested to preserve unused local variables (i.e. never read), the
622 * compiler will optimize them out, potentially altering debugging
623 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.unusedLocal"
624 * - possible values: { "preserve", "optimize out" }
625 * - default: "preserve"
627 * COMPILER / Defining Target Java Platform
628 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
629 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
630 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.targetPlatform"
631 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
634 * COMPILER / Reporting Unreachable Code
635 * Unreachable code can optionally be reported as an error, warning or simply
636 * ignored. The bytecode generation will always optimized it out.
637 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unreachableCode"
638 * - possible values: { "error", "warning", "ignore" }
641 * COMPILER / Reporting Invalid Import
642 * An import statement that cannot be resolved might optionally be reported
643 * as an error, as a warning or ignored.
644 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.invalidImport"
645 * - possible values: { "error", "warning", "ignore" }
648 * COMPILER / Reporting Attempt to Override Package-Default Method
649 * A package default method is not visible in a different package, and thus
650 * cannot be overridden. When enabling this option, the compiler will signal
651 * such scenarii either as an error or a warning.
652 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
653 * - possible values: { "error", "warning", "ignore" }
654 * - default: "warning"
656 * COMPILER / Reporting Method With Constructor Name
657 * Naming a method with a constructor name is generally considered poor
658 * style programming. When enabling this option, the compiler will signal such
659 * scenarii either as an error or a warning.
660 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.methodWithConstructorName"
661 * - possible values: { "error", "warning", "ignore" }
662 * - default: "warning"
664 * COMPILER / Reporting Deprecation
665 * When enabled, the compiler will signal use of deprecated API either as an
666 * error or a warning.
667 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecation"
668 * - possible values: { "error", "warning", "ignore" }
669 * - default: "warning"
671 * COMPILER / Reporting Deprecation Inside Deprecated Code
672 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
673 * The severity of the problem is controlled with option "org.phpeclipse.phpdt.core.compiler.problem.deprecation".
674 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
675 * - possible values: { "enabled", "disabled" }
676 * - default: "disabled"
678 * COMPILER / Reporting Hidden Catch Block
679 * Locally to a try statement, some catch blocks may hide others , e.g.
680 * try { throw new java.io.CharConversionException();
681 * } catch (java.io.CharConversionException e) {
682 * } catch (java.io.IOException e) {}.
683 * When enabling this option, the compiler will issue an error or a warning for hidden
684 * catch blocks corresponding to checked exceptions
685 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.hiddenCatchBlock"
686 * - possible values: { "error", "warning", "ignore" }
687 * - default: "warning"
689 * COMPILER / Reporting Unused Local
690 * When enabled, the compiler will issue an error or a warning for unused local
691 * variables (i.e. variables never read from)
692 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedLocal"
693 * - possible values: { "error", "warning", "ignore" }
694 * - default: "ignore"
696 * COMPILER / Reporting Unused Parameter
697 * When enabled, the compiler will issue an error or a warning for unused method
698 * parameters (i.e. parameters never read from)
699 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedParameter"
700 * - possible values: { "error", "warning", "ignore" }
701 * - default: "ignore"
703 * COMPILER / Reporting Unused Import
704 * When enabled, the compiler will issue an error or a warning for unused import
706 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedImport"
707 * - possible values: { "error", "warning", "ignore" }
708 * - default: "warning"
710 * COMPILER / Reporting Synthetic Access Emulation
711 * When enabled, the compiler will issue an error or a warning whenever it emulates
712 * access to a non-accessible member of an enclosing type. Such access can have
713 * performance implications.
714 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.syntheticAccessEmulation"
715 * - possible values: { "error", "warning", "ignore" }
716 * - default: "ignore"
718 * COMPILER / Reporting Non-Externalized String Literal
719 * When enabled, the compiler will issue an error or a warning for non externalized
720 * String literal (i.e. non tagged with //$NON-NLS-<n>$).
721 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
722 * - possible values: { "error", "warning", "ignore" }
723 * - default: "ignore"
725 * COMPILER / Reporting Usage of 'assert' Identifier
726 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
727 * used as an identifier (reserved keyword in 1.4)
728 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.assertIdentifier"
729 * - possible values: { "error", "warning", "ignore" }
730 * - default: "ignore"
732 * COMPILER / Reporting Usage of expression receiver on static invocation/field access
733 * When enabled, the compiler will issue an error or a warning whenever a static field
734 * or method is accessed with an expression receiver.
735 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.staticAccessReceiver"
736 * - possible values: { "error", "warning", "ignore" }
737 * - default: "warning"
739 * COMPILER / Reporting Assignment with no effect
740 * When enabled, the compiler will issue an error or a warning whenever an assignment
741 * has no effect (e.g 'x = x').
742 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.noEffectAssignment"
743 * - possible values: { "error", "warning", "ignore" }
744 * - default: "warning"
746 * COMPILER / Setting Source Compatibility Mode
747 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
748 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
749 * level should be set to "1.4" and the compliance mode should be "1.4".
750 * - option id: "org.phpeclipse.phpdt.core.compiler.source"
751 * - possible values: { "1.3", "1.4" }
754 * COMPILER / Setting Compliance Level
755 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
756 * should not go beyond "1.3" level.
757 * - option id: "org.phpeclipse.phpdt.core.compiler.compliance"
758 * - possible values: { "1.3", "1.4" }
761 * COMPILER / Maximum number of problems reported per compilation unit
762 * Specify the maximum number of problems reported on each compilation unit.
763 * - option id: "org.phpeclipse.phpdt.core.compiler.maxProblemPerUnit"
764 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
767 * COMPILER / Define the Automatic Task Tags
768 * When the tag is non empty, the compiler will issue a task marker whenever it encounters
769 * one of the corresponding tag inside any comment in Java source code.
770 * Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed.
771 * - option id: "org.phpeclipse.phpdt.core.compiler.taskTags"
772 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card
774 * COMPILER / Define the Automatic Task Priorities
775 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
776 * of the task markers issued by the compiler.
777 * If the default is specified, the priority of each task marker is "NORMAL".
778 * - option id: "org.phpeclipse.phpdt.core.compiler.taskPriorities"
779 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
782 * BUILDER / Specifying Filters for Resource Copying Control
783 * Allow to specify some filters to control the resource copy process.
784 * - option id: "org.phpeclipse.phpdt.core.builder.resourceCopyExclusionFilter"
785 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
786 * or the name of a folder which ends with '/'
789 * BUILDER / Abort if Invalid Classpath
790 * Allow to toggle the builder to abort if the classpath is invalid
791 * - option id: "org.phpeclipse.phpdt.core.builder.invalidClasspath"
792 * - possible values: { "abort", "ignore" }
793 * - default: "ignore"
795 * BUILDER / Cleaning Output Folder(s)
796 * Indicate whether the JavaBuilder is allowed to clean the output folders
797 * when performing full build operations.
798 * - option id: "org.phpeclipse.phpdt.core.builder.cleanOutputFolder"
799 * - possible values: { "clean", "ignore" }
802 * JAVACORE / Computing Project Build Order
803 * Indicate whether JavaCore should enforce the project build order to be based on
804 * the classpath prerequisite chain. When requesting to compute, this takes over
805 * the platform default order (based on project references).
806 * - option id: "org.phpeclipse.phpdt.core.computeJavaBuildOrder"
807 * - possible values: { "compute", "ignore" }
808 * - default: "ignore"
810 * JAVACORE / Specify Default Source Encoding Format
811 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
812 * to 'ResourcesPlugin.getEncoding()'.
813 * - option id: "org.phpeclipse.phpdt.core.encoding"
814 * - possible values: { any of the supported encoding name}.
815 * - default: <platform default>
817 * JAVACORE / Reporting Incomplete Classpath
818 * An entry on the classpath doesn't exist or is not visible (e.g. a referenced project is closed).
819 * - option id: "org.phpeclipse.phpdt.core.incompleteClasspath"
820 * - possible values: { "error", "warning"}
823 * JAVACORE / Reporting Classpath Cycle
824 * A project is involved in a cycle.
825 * - option id: "org.phpeclipse.phpdt.core.circularClasspath"
826 * - possible values: { "error", "warning" }
829 * FORMATTER / Inserting New Line Before Opening Brace
830 * When Insert, a new line is inserted before an opening brace, otherwise nothing
832 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.openingBrace"
833 * - possible values: { "insert", "do not insert" }
834 * - default: "do not insert"
836 * FORMATTER / Inserting New Line Inside Control Statement
837 * When Insert, a new line is inserted between } and following else, catch, finally
838 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.controlStatement"
839 * - possible values: { "insert", "do not insert" }
840 * - default: "do not insert"
842 * FORMATTER / Clearing Blank Lines
843 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
844 * and all others removed.
845 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.clearAll"
846 * - possible values: { "clear all", "preserve one" }
847 * - default: "preserve one"
849 * FORMATTER / Inserting New Line Between Else/If
850 * When Insert, a blank line is inserted between an else and an if when they are
851 * contiguous. When choosing to not insert, else-if will be kept on the same
852 * line when possible.
853 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.elseIf"
854 * - possible values: { "insert", "do not insert" }
855 * - default: "do not insert"
857 * FORMATTER / Inserting New Line In Empty Block
858 * When insert, a line break is inserted between contiguous { and }, if } is not followed
860 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.emptyBlock"
861 * - possible values: { "insert", "do not insert" }
862 * - default: "insert"
864 * FORMATTER / Splitting Lines Exceeding Length
865 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
866 * disable line splitting
867 * - option id: "org.phpeclipse.phpdt.core.formatter.lineSplit"
868 * - possible values: "<n>", where n is zero or a positive integer
871 * FORMATTER / Compacting Assignment
872 * Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space
873 * is inserted before the assignment operator
874 * - option id: "org.phpeclipse.phpdt.core.formatter.style.assignment"
875 * - possible values: { "compact", "normal" }
876 * - default: "normal"
878 * FORMATTER / Defining Indentation Character
879 * Either choose to indent with tab characters or spaces
880 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.char"
881 * - possible values: { "tab", "space" }
884 * FORMATTER / Defining Space Indentation Length
885 * When using spaces, set the amount of space characters to use for each
887 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.size"
888 * - possible values: "<n>", where n is a positive integer
891 * CODEASSIST / Activate Visibility Sensitive Completion
892 * When active, completion doesn't show that you can not see
893 * (e.g. you can not see private methods of a super class).
894 * - option id: "org.phpeclipse.phpdt.core.codeComplete.visibilityCheck"
895 * - possible values: { "enabled", "disabled" }
896 * - default: "disabled"
898 * CODEASSIST / Automatic Qualification of Implicit Members
899 * When active, completion automatically qualifies completion on implicit
900 * field references and message expressions.
901 * - option id: "org.phpeclipse.phpdt.core.codeComplete.forceImplicitQualification"
902 * - possible values: { "enabled", "disabled" }
903 * - default: "disabled"
905 * CODEASSIST / Define the Prefixes for Field Name
906 * When the prefixes is non empty, completion for field name will begin with
907 * one of the proposed prefixes.
908 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldPrefixes"
909 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
912 * CODEASSIST / Define the Prefixes for Static Field Name
913 * When the prefixes is non empty, completion for static field name will begin with
914 * one of the proposed prefixes.
915 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldPrefixes"
916 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
919 * CODEASSIST / Define the Prefixes for Local Variable Name
920 * When the prefixes is non empty, completion for local variable name will begin with
921 * one of the proposed prefixes.
922 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localPrefixes"
923 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
926 * CODEASSIST / Define the Prefixes for Argument Name
927 * When the prefixes is non empty, completion for argument name will begin with
928 * one of the proposed prefixes.
929 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentPrefixes"
930 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
933 * CODEASSIST / Define the Suffixes for Field Name
934 * When the suffixes is non empty, completion for field name will end with
935 * one of the proposed suffixes.
936 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldSuffixes"
937 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
940 * CODEASSIST / Define the Suffixes for Static Field Name
941 * When the suffixes is non empty, completion for static field name will end with
942 * one of the proposed suffixes.
943 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldSuffixes"
944 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
947 * CODEASSIST / Define the Suffixes for Local Variable Name
948 * When the suffixes is non empty, completion for local variable name will end with
949 * one of the proposed suffixes.
950 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localSuffixes"
951 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
954 * CODEASSIST / Define the Suffixes for Argument Name
955 * When the suffixes is non empty, completion for argument name will end with
956 * one of the proposed suffixes.
957 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentSuffixes"
958 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
962 * @return a mutable table containing the default settings of all known options
963 * (key type: <code>String</code>; value type: <code>String</code>)
966 // public static Hashtable getDefaultOptions() {
968 // Hashtable defaultOptions = new Hashtable(10);
970 // // see #initializeDefaultPluginPreferences() for changing default settings
971 // Preferences preferences = getPlugin().getPluginPreferences();
972 // HashSet optionNames = OptionNames;
974 // // get preferences set to their default
975 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
976 // for (int i = 0; i < defaultPropertyNames.length; i++) {
977 // String propertyName = defaultPropertyNames[i];
978 // if (optionNames.contains(propertyName)) {
979 // defaultOptions.put(propertyName, preferences.getDefaultString(propertyName));
982 // // get preferences not set to their default
983 // String[] propertyNames = preferences.propertyNames();
984 // for (int i = 0; i < propertyNames.length; i++) {
985 // String propertyName = propertyNames[i];
986 // if (optionNames.contains(propertyName)) {
987 // defaultOptions.put(propertyName, preferences.getDefaultString(propertyName));
990 // // get encoding through resource plugin
991 // defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
993 // return defaultOptions;
996 * Helper method for returning one option value only. Equivalent to <code>(String)JavaCore.getOptions().get(optionName)</code>
997 * Note that it may answer <code>null</code> if this option does not exist.
999 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
1002 * @param optionName the name of an option
1003 * @return the String value of a given option
1004 * @see JavaCore#getDefaultOptions
1007 // public static String getOption(String optionName) {
1009 // if (CORE_ENCODING.equals(optionName)) {
1010 // return ResourcesPlugin.getEncoding();
1012 // if (OptionNames.contains(optionName)) {
1013 // Preferences preferences = getPlugin().getPluginPreferences();
1014 // return preferences.getString(optionName).trim();
1020 * Returns the table of the current options. Initially, all options have their default values,
1021 * and this method returns a table that includes all known options.
1023 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
1026 * @return table of current settings of all options
1027 * (key type: <code>String</code>; value type: <code>String</code>)
1028 * @see JavaCore#getDefaultOptions
1030 // public static Hashtable getOptions() {
1032 // Hashtable options = new Hashtable(10);
1034 // // see #initializeDefaultPluginPreferences() for changing default settings
1035 // Plugin plugin = getPlugin();
1036 // if (plugin != null) {
1037 // Preferences preferences = getPlugin().getPluginPreferences();
1038 // HashSet optionNames = OptionNames;
1040 // // get preferences set to their default
1041 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1042 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1043 // String propertyName = defaultPropertyNames[i];
1044 // if (optionNames.contains(propertyName)) {
1045 // options.put(propertyName, preferences.getDefaultString(propertyName));
1048 // // get preferences not set to their default
1049 // String[] propertyNames = preferences.propertyNames();
1050 // for (int i = 0; i < propertyNames.length; i++) {
1051 // String propertyName = propertyNames[i];
1052 // if (optionNames.contains(propertyName)) {
1053 // options.put(propertyName, preferences.getString(propertyName).trim());
1056 // // get encoding through resource plugin
1057 // options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1062 * Sets the current table of options. All and only the options explicitly included in the given table
1063 * are remembered; all previous option settings are forgotten, including ones not explicitly
1066 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
1069 * @param newOptions the new options (key type: <code>String</code>; value type: <code>String</code>),
1070 * or <code>null</code> to reset all options to their default values
1071 * @see JavaCore#getDefaultOptions
1073 // public static void setOptions(Hashtable newOptions) {
1075 // // see #initializeDefaultPluginPreferences() for changing default settings
1076 // Preferences preferences = getPlugin().getPluginPreferences();
1078 // if (newOptions == null) {
1079 // newOptions = getDefaultOptions();
1081 // Enumeration keys = newOptions.keys();
1082 // while (keys.hasMoreElements()) {
1083 // String key = (String) keys.nextElement();
1084 // if (!OptionNames.contains(key))
1085 // continue; // unrecognized option
1086 // if (key.equals(CORE_ENCODING))
1087 // continue; // skipped, contributed by resource prefs
1088 // String value = (String) newOptions.get(key);
1089 // preferences.setValue(key, value);
1092 // // persist options
1093 // getPlugin().savePluginPreferences();
1095 public static IProject[] getPHPProjects() {
1096 List phpProjectsList = new ArrayList();
1097 IProject[] workspaceProjects = PHPeclipsePlugin.getWorkspace().getRoot().getProjects();
1099 for (int i = 0; i < workspaceProjects.length; i++) {
1100 IProject iProject = workspaceProjects[i];
1101 if (isPHPProject(iProject))
1102 phpProjectsList.add(iProject);
1105 IProject[] phpProjects = new IProject[phpProjectsList.size()];
1106 return (IProject[]) phpProjectsList.toArray(phpProjects);
1109 // public static PHPProject getPHPProject(String name) {
1110 // IProject aProject = PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
1111 // if (isPHPProject(aProject)) {
1112 // PHPProject thePHPProject = new PHPProject();
1113 // thePHPProject.setProject(aProject);
1114 // return thePHPProject;
1119 public static boolean isPHPProject(IProject aProject) {
1121 return aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID);
1122 } catch (CoreException e) {
1128 // public static PHPFile create(IFile aFile) {
1129 // if (PHPFile.EXTENSION.equalsIgnoreCase(aFile.getFileExtension()))
1130 // return new PHPFile(aFile);
1131 // if (PHPFile.EXTENSION1.equalsIgnoreCase(aFile.getFileExtension()))
1132 // return new PHPFile(aFile);
1133 // if (PHPFile.EXTENSION2.equalsIgnoreCase(aFile.getFileExtension()))
1134 // return new PHPFile(aFile);
1135 // if (PHPFile.EXTENSION3.equalsIgnoreCase(aFile.getFileExtension()))
1136 // return new PHPFile(aFile);
1137 // if (PHPFile.EXTENSION4.equalsIgnoreCase(aFile.getFileExtension()))
1138 // return new PHPFile(aFile);
1139 // if (PHPFile.EXTENSION5.equalsIgnoreCase(aFile.getFileExtension()))
1140 // return new PHPFile(aFile);
1145 // public static PHPProject create(IProject aProject) {
1148 // if (aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1149 // PHPProject project = new PHPProject();
1150 // project.setProject(aProject);
1153 // } catch (CoreException e) {
1154 // System.err.println("Exception occurred in PHPCore#create(IProject): " + e.toString());
1160 public static void addPHPNature(IProject project, IProgressMonitor monitor) throws CoreException {
1161 if (!project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1162 IProjectDescription description = project.getDescription();
1163 String[] prevNatures = description.getNatureIds();
1164 String[] newNatures = new String[prevNatures.length + 1];
1165 System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
1166 newNatures[prevNatures.length] = PHPeclipsePlugin.PHP_NATURE_ID;
1167 description.setNatureIds(newNatures);
1168 project.setDescription(description, monitor);
1173 * Returns the single instance of the PHP core plug-in runtime class.
1175 * @return the single instance of the PHP core plug-in runtime class
1177 public static Plugin getPlugin() {
1178 return PHPeclipsePlugin.getDefault();
1182 * Initializes the default preferences settings for this plug-in.
1186 * Runs the given action as an atomic Java model operation.
1188 * After running a method that modifies Java elements,
1189 * registered listeners receive after-the-fact notification of
1190 * what just transpired, in the form of a element changed event.
1191 * This method allows clients to call a number of
1192 * methods that modify java elements and only have element
1193 * changed event notifications reported at the end of the entire
1197 * If this method is called outside the dynamic scope of another such
1198 * call, this method runs the action and then reports a single
1199 * element changed event describing the net effect of all changes
1200 * done to java elements by the action.
1203 * If this method is called in the dynamic scope of another such
1204 * call, this method simply runs the action.
1207 * @param action the action to perform
1208 * @param monitor a progress monitor, or <code>null</code> if progress
1209 * reporting and cancellation are not desired
1210 * @exception CoreException if the operation failed.
1213 public static void run(IWorkspaceRunnable action, IProgressMonitor monitor) throws CoreException {
1214 IWorkspace workspace = ResourcesPlugin.getWorkspace();
1215 if (workspace.isTreeLocked()) {
1216 new BatchOperation(action).run(monitor);
1218 // use IWorkspace.run(...) to ensure that a build will be done in autobuild mode
1219 workspace.run(new BatchOperation(action), monitor);
1224 * Adds the given listener for changes to Java elements.
1225 * Has no effect if an identical listener is already registered.
1227 * This listener will only be notified during the POST_CHANGE resource change notification
1228 * and any reconcile operation (POST_RECONCILE).
1229 * For finer control of the notification, use <code>addElementChangedListener(IElementChangedListener,int)</code>,
1230 * which allows to specify a different eventMask.
1232 * @see ElementChangedEvent
1233 * @param listener the listener
1235 public static void addElementChangedListener(IElementChangedListener listener) {
1236 addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE | ElementChangedEvent.POST_RECONCILE);
1240 * Adds the given listener for changes to Java elements.
1241 * Has no effect if an identical listener is already registered.
1242 * After completion of this method, the given listener will be registered for exactly
1243 * the specified events. If they were previously registered for other events, they
1244 * will be deregistered.
1246 * Once registered, a listener starts receiving notification of changes to
1247 * java elements in the model. The listener continues to receive
1248 * notifications until it is replaced or removed.
1251 * Listeners can listen for several types of event as defined in <code>ElementChangeEvent</code>.
1252 * Clients are free to register for any number of event types however if they register
1253 * for more than one, it is their responsibility to ensure they correctly handle the
1254 * case where the same java element change shows up in multiple notifications.
1255 * Clients are guaranteed to receive only the events for which they are registered.
1258 * @param listener the listener
1259 * @param eventMask the bit-wise OR of all event types of interest to the listener
1260 * @see IElementChangedListener
1261 * @see ElementChangedEvent
1262 * @see #removeElementChangedListener(IElementChangedListener)
1265 public static void addElementChangedListener(IElementChangedListener listener, int eventMask) {
1266 JavaModelManager.getJavaModelManager().addElementChangedListener(listener, eventMask);
1270 * Configures the given marker attribute map for the given Java element.
1271 * Used for markers, which denote a Java element rather than a resource.
1273 * @param attributes the mutable marker attribute map (key type: <code>String</code>,
1274 * value type: <code>String</code>)
1275 * @param element the Java element for which the marker needs to be configured
1277 public static void addJavaElementMarkerAttributes(
1279 IJavaElement element) {
1280 // if (element instanceof IMember)
1281 // element = ((IMember) element).getClassFile();
1282 if (attributes != null && element != null)
1283 attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier());
1287 * Configures the given marker for the given Java element.
1288 * Used for markers, which denote a Java element rather than a resource.
1290 * @param marker the marker to be configured
1291 * @param element the Java element for which the marker needs to be configured
1292 * @exception CoreException if the <code>IMarker.setAttribute</code> on the marker fails
1294 public void configureJavaElementMarker(IMarker marker, IJavaElement element)
1295 throws CoreException {
1296 // if (element instanceof IMember)
1297 // element = ((IMember) element).getClassFile();
1298 if (marker != null && element != null)
1299 marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier());
1303 * Returns the Java model element corresponding to the given handle identifier
1304 * generated by <code>IJavaElement.getHandleIdentifier()</code>, or
1305 * <code>null</code> if unable to create the associated element.
1307 public static IJavaElement create(String handleIdentifier) {
1308 if (handleIdentifier == null) {
1312 return JavaModelManager.getJavaModelManager().getHandleFromMemento(handleIdentifier);
1313 } catch (JavaModelException e) {
1318 * Returns the Java element corresponding to the given file, or
1319 * <code>null</code> if unable to associate the given file
1320 * with a Java element.
1322 * <p>The file must be one of:<ul>
1323 * <li>a <code>.java</code> file - the element returned is the corresponding <code>ICompilationUnit</code></li>
1324 * <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li>
1325 * <li>a <code>.jar</code> file - the element returned is the corresponding <code>IPackageFragmentRoot</code></li>
1328 * Creating a Java element has the side effect of creating and opening all of the
1329 * element's parents if they are not yet open.
1331 * @param the given file
1332 * @return the Java element corresponding to the given file, or
1333 * <code>null</code> if unable to associate the given file
1334 * with a Java element
1336 public static IJavaElement create(IFile file) {
1337 return JavaModelManager.create(file, null);
1340 * Returns the package fragment or package fragment root corresponding to the given folder, or
1341 * <code>null</code> if unable to associate the given folder with a Java element.
1343 * Note that a package fragment root is returned rather than a default package.
1345 * Creating a Java element has the side effect of creating and opening all of the
1346 * element's parents if they are not yet open.
1348 * @param the given folder
1349 * @return the package fragment or package fragment root corresponding to the given folder, or
1350 * <code>null</code> if unable to associate the given folder with a Java element
1352 public static IJavaElement create(IFolder folder) {
1353 return JavaModelManager.create(folder, null);
1356 * Returns the Java project corresponding to the given project.
1358 * Creating a Java Project has the side effect of creating and opening all of the
1359 * project's parents if they are not yet open.
1361 * Note that no check is done at this time on the existence or the java nature of this project.
1363 * @param project the given project
1364 * @return the Java project corresponding to the given project, null if the given project is null
1366 public static IJavaProject create(IProject project) {
1367 if (project == null) {
1370 JavaModel javaModel = JavaModelManager.getJavaModelManager().getJavaModel();
1371 return javaModel.getJavaProject(project);
1374 * Returns the Java element corresponding to the given resource, or
1375 * <code>null</code> if unable to associate the given resource
1376 * with a Java element.
1378 * The resource must be one of:<ul>
1379 * <li>a project - the element returned is the corresponding <code>IJavaProject</code></li>
1380 * <li>a <code>.java</code> file - the element returned is the corresponding <code>ICompilationUnit</code></li>
1381 * <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li>
1382 * <li>a <code>.jar</code> file - the element returned is the corresponding <code>IPackageFragmentRoot</code></li>
1383 * <li>a folder - the element returned is the corresponding <code>IPackageFragmentRoot</code>
1384 * or <code>IPackageFragment</code></li>
1385 * <li>the workspace root resource - the element returned is the <code>IJavaModel</code></li>
1388 * Creating a Java element has the side effect of creating and opening all of the
1389 * element's parents if they are not yet open.
1391 * @param resource the given resource
1392 * @return the Java element corresponding to the given resource, or
1393 * <code>null</code> if unable to associate the given resource
1394 * with a Java element
1396 public static IJavaElement create(IResource resource) {
1397 return JavaModelManager.create(resource, null);
1400 * Returns the Java model.
1402 * @param root the given root
1403 * @return the Java model, or <code>null</code> if the root is null
1405 public static IJavaModel create(IWorkspaceRoot root) {
1409 return JavaModelManager.getJavaModelManager().getJavaModel();
1412 * Creates and returns a class file element for
1413 * the given <code>.class</code> file. Returns <code>null</code> if unable
1414 * to recognize the class file.
1416 * @param file the given <code>.class</code> file
1417 * @return a class file element for the given <code>.class</code> file, or <code>null</code> if unable
1418 * to recognize the class file
1420 //public static IClassFile createClassFileFrom(IFile file) {
1421 // return JavaModelManager.createClassFileFrom(file, null);
1424 * Creates and returns a compilation unit element for
1425 * the given <code>.java</code> file. Returns <code>null</code> if unable
1426 * to recognize the compilation unit.
1428 * @param file the given <code>.java</code> file
1429 * @return a compilation unit element for the given <code>.java</code> file, or <code>null</code> if unable
1430 * to recognize the compilation unit
1432 public static ICompilationUnit createCompilationUnitFrom(IFile file) {
1433 return JavaModelManager.createCompilationUnitFrom(file, null);
1436 * Creates and returns a handle for the given JAR file.
1437 * The Java model associated with the JAR's project may be
1438 * created as a side effect.
1440 * @param file the given JAR file
1441 * @return a handle for the given JAR file, or <code>null</code> if unable to create a JAR package fragment root.
1442 * (for example, if the JAR file represents a non-Java resource)
1444 //public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile file) {
1445 // return JavaModelManager.createJarPackageFragmentRootFrom(file, null);
1449 * Answers the project specific value for a given classpath container.
1450 * In case this container path could not be resolved, then will answer <code>null</code>.
1451 * Both the container path and the project context are supposed to be non-null.
1453 * The containerPath is a formed by a first ID segment followed with extra segments, which can be
1454 * used as additional hints for resolution. If no container was ever recorded for this container path
1455 * onto this project (using <code>setClasspathContainer</code>, then a
1456 * <code>ClasspathContainerInitializer</code> will be activated if any was registered for this container
1457 * ID onto the extension point "org.eclipse.jdt.core.classpathContainerInitializer".
1459 * There is no assumption that the returned container must answer the exact same containerPath
1460 * when requested <code>IClasspathContainer#getPath</code>.
1461 * Indeed, the containerPath is just an indication for resolving it to an actual container object.
1463 * Classpath container values are persisted locally to the workspace, but
1464 * are not preserved from a session to another. It is thus highly recommended to register a
1465 * <code>ClasspathContainerInitializer</code> for each referenced container
1466 * (through the extension point "org.eclipse.jdt.core.ClasspathContainerInitializer").
1468 * @param containerPath the name of the container, which needs to be resolved
1469 * @param project a specific project in which the container is being resolved
1470 * @return the corresponding classpath container or <code>null</code> if unable to find one.
1472 * @exception JavaModelException if an exception occurred while resolving the container, or if the resolved container
1473 * contains illegal entries (contains CPE_CONTAINER entries or null entries).
1475 * @see ClasspathContainerInitializer
1476 * @see IClasspathContainer
1477 * @see #setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor)
1480 //public static IClasspathContainer getClasspathContainer(final IPath containerPath, final IJavaProject project) throws JavaModelException {
1482 // IClasspathContainer container = JavaModelManager.containerGet(project, containerPath);
1483 // if (container == JavaModelManager.ContainerInitializationInProgress) return null; // break cycle
1485 // if (container == null){
1486 // final ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
1487 // if (initializer != null){
1488 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1489 // System.out.println("CPContainer INIT - triggering initialization of: ["+project.getElementName()+"] " + containerPath + " using initializer: "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
1490 // new Exception("FAKE exception for dumping current CPContainer (["+project.getElementName()+"] "+ containerPath+ ")INIT invocation stack trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
1492 // JavaModelManager.containerPut(project, containerPath, JavaModelManager.ContainerInitializationInProgress); // avoid initialization cycles
1493 // boolean ok = false;
1495 // // wrap initializer call with Safe runnable in case initializer would be causing some grief
1496 // Platform.run(new ISafeRunnable() {
1497 // public void handleException(Throwable exception) {
1498 // Util.log(exception, "Exception occurred in classpath container initializer: "+initializer); //$NON-NLS-1$
1500 // public void run() throws Exception {
1501 // initializer.initialize(containerPath, project);
1505 // // retrieve value (if initialization was successful)
1506 // container = JavaModelManager.containerGet(project, containerPath);
1507 // if (container == JavaModelManager.ContainerInitializationInProgress) return null; // break cycle
1510 // if (!ok) JavaModelManager.containerPut(project, containerPath, null); // flush cache
1512 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1513 // System.out.print("CPContainer INIT - after resolution: ["+project.getElementName()+"] " + containerPath + " --> "); //$NON-NLS-2$//$NON-NLS-1$//$NON-NLS-3$
1514 // if (container != null){
1515 // System.out.print("container: "+container.getDescription()+" {"); //$NON-NLS-2$//$NON-NLS-1$
1516 // IClasspathEntry[] entries = container.getClasspathEntries();
1517 // if (entries != null){
1518 // for (int i = 0; i < entries.length; i++){
1519 // if (i > 0) System.out.println(", ");//$NON-NLS-1$
1520 // System.out.println(entries[i]);
1523 // System.out.println("}");//$NON-NLS-1$
1525 // System.out.println("{unbound}");//$NON-NLS-1$
1529 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1530 // System.out.println("CPContainer INIT - no initializer found for: "+project.getElementName()+"] " + containerPath); //$NON-NLS-1$ //$NON-NLS-2$
1534 // return container;
1538 * Helper method finding the classpath container initializer registered for a given classpath container ID
1539 * or <code>null</code> if none was found while iterating over the contributions to extension point to
1540 * the extension point "org.eclipse.jdt.core.classpathContainerInitializer".
1542 * A containerID is the first segment of any container path, used to identify the registered container initializer.
1544 * @param String - a containerID identifying a registered initializer
1545 * @return ClasspathContainerInitializer - the registered classpath container initializer or <code>null</code> if
1549 //public static ClasspathContainerInitializer getClasspathContainerInitializer(String containerID){
1551 // Plugin jdtCorePlugin = JavaCore.getPlugin();
1552 // if (jdtCorePlugin == null) return null;
1554 // IExtensionPoint extension = jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID);
1555 // if (extension != null) {
1556 // IExtension[] extensions = extension.getExtensions();
1557 // for(int i = 0; i < extensions.length; i++){
1558 // IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
1559 // for(int j = 0; j < configElements.length; j++){
1560 // String initializerID = configElements[j].getAttribute("id"); //$NON-NLS-1$
1561 // if (initializerID != null && initializerID.equals(containerID)){
1562 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
1563 // System.out.println("CPContainer INIT - found initializer: "+containerID +" --> " + configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
1566 // Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
1567 // if (execExt instanceof ClasspathContainerInitializer){
1568 // return (ClasspathContainerInitializer)execExt;
1570 // } catch(CoreException e) {
1580 * Returns the path held in the given classpath variable.
1581 * Returns <node>null</code> if unable to bind.
1583 * Classpath variable values are persisted locally to the workspace, and
1584 * are preserved from session to session.
1586 * Note that classpath variables can be contributed registered initializers for,
1587 * using the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
1588 * If an initializer is registered for a variable, its persisted value will be ignored:
1589 * its initializer will thus get the opportunity to rebind the variable differently on
1592 * @param variableName the name of the classpath variable
1593 * @return the path, or <code>null</code> if none
1594 * @see #setClasspathVariable
1596 public static IPath getClasspathVariable(final String variableName) {
1598 IPath variablePath = JavaModelManager.variableGet(variableName);
1599 if (variablePath == JavaModelManager.VariableInitializationInProgress) return null; // break cycle
1601 if (variablePath != null) {
1602 return variablePath;
1605 // even if persisted value exists, initializer is given priority, only if no initializer is found the persisted value is reused
1606 // final ClasspathVariableInitializer initializer = PHPCore.getClasspathVariableInitializer(variableName);
1607 // if (initializer != null){
1608 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1609 // System.out.println("CPVariable INIT - triggering initialization of: " + variableName+ " using initializer: "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$
1610 // new Exception("FAKE exception for dumping current CPVariable ("+variableName+ ")INIT invocation stack trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$
1612 // JavaModelManager.variablePut(variableName, JavaModelManager.VariableInitializationInProgress); // avoid initialization cycles
1613 // boolean ok = false;
1615 // // wrap initializer call with Safe runnable in case initializer would be causing some grief
1616 // Platform.run(new ISafeRunnable() {
1617 // public void handleException(Throwable exception) {
1618 // Util.log(exception, "Exception occurred in classpath variable initializer: "+initializer+" while initializing variable: "+variableName); //$NON-NLS-1$ //$NON-NLS-2$
1620 // public void run() throws Exception {
1621 // initializer.initialize(variableName);
1624 // variablePath = (IPath) JavaModelManager.variableGet(variableName); // initializer should have performed side-effect
1625 // if (variablePath == JavaModelManager.VariableInitializationInProgress) return null; // break cycle (initializer did not init or reentering call)
1626 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1627 // System.out.println("CPVariable INIT - after initialization: " + variableName + " --> " + variablePath); //$NON-NLS-2$//$NON-NLS-1$
1631 // if (!ok) JavaModelManager.variablePut(variableName, null); // flush cache
1634 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1635 // System.out.println("CPVariable INIT - no initializer found for: " + variableName); //$NON-NLS-1$
1638 return variablePath;
1642 * Helper method finding the classpath variable initializer registered for a given classpath variable name
1643 * or <code>null</code> if none was found while iterating over the contributions to extension point to
1644 * the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
1646 * @param the given variable
1647 * @return ClasspathVariableInitializer - the registered classpath variable initializer or <code>null</code> if
1651 public static ClasspathVariableInitializer getClasspathVariableInitializer(String variable){
1653 Plugin jdtCorePlugin = JavaCore.getPlugin();
1654 if (jdtCorePlugin == null) return null;
1656 // IExtensionPoint extension = jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID);
1657 // if (extension != null) {
1658 // IExtension[] extensions = extension.getExtensions();
1659 // for(int i = 0; i < extensions.length; i++){
1660 // IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
1661 // for(int j = 0; j < configElements.length; j++){
1663 // String varAttribute = configElements[j].getAttribute("variable"); //$NON-NLS-1$
1664 // if (variable.equals(varAttribute)) {
1665 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
1666 // System.out.println("CPVariable INIT - found initializer: "+variable+" --> " + configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
1668 // Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
1669 // if (execExt instanceof ClasspathVariableInitializer){
1670 // return (ClasspathVariableInitializer)execExt;
1673 // } catch(CoreException e){
1682 * Returns the names of all known classpath variables.
1684 * Classpath variable values are persisted locally to the workspace, and
1685 * are preserved from session to session.
1688 * @return the list of classpath variable names
1689 * @see #setClasspathVariable
1691 //public static String[] getClasspathVariableNames() {
1692 // return JavaModelManager.variableNames();
1696 * Returns a table of all known configurable options with their default values.
1697 * These options allow to configure the behaviour of the underlying components.
1698 * The client may safely use the result as a template that they can modify and
1699 * then pass to <code>setOptions</code>.
1701 * Helper constants have been defined on JavaCore for each of the option ID and
1702 * their possible constant values.
1704 * Note: more options might be added in further releases.
1706 * RECOGNIZED OPTIONS:
1707 * COMPILER / Generating Local Variable Debug Attribute
1708 * When generated, this attribute will enable local variable names
1709 * to be displayed in debugger, only in place where variables are
1710 * definitely assigned (.class file is then bigger)
1711 * - option id: "org.eclipse.jdt.core.compiler.debug.localVariable"
1712 * - possible values: { "generate", "do not generate" }
1713 * - default: "generate"
1715 * COMPILER / Generating Line Number Debug Attribute
1716 * When generated, this attribute will enable source code highlighting in debugger
1717 * (.class file is then bigger).
1718 * - option id: "org.eclipse.jdt.core.compiler.debug.lineNumber"
1719 * - possible values: { "generate", "do not generate" }
1720 * - default: "generate"
1722 * COMPILER / Generating Source Debug Attribute
1723 * When generated, this attribute will enable the debugger to present the
1724 * corresponding source code.
1725 * - option id: "org.eclipse.jdt.core.compiler.debug.sourceFile"
1726 * - possible values: { "generate", "do not generate" }
1727 * - default: "generate"
1729 * COMPILER / Preserving Unused Local Variables
1730 * Unless requested to preserve unused local variables (that is, never read), the
1731 * compiler will optimize them out, potentially altering debugging
1732 * - option id: "org.eclipse.jdt.core.compiler.codegen.unusedLocal"
1733 * - possible values: { "preserve", "optimize out" }
1734 * - default: "preserve"
1736 * COMPILER / Defining Target Java Platform
1737 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
1738 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
1739 * - option id: "org.eclipse.jdt.core.compiler.codegen.targetPlatform"
1740 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
1743 * COMPILER / Reporting Unreachable Code
1744 * Unreachable code can optionally be reported as an error, warning or simply
1745 * ignored. The bytecode generation will always optimized it out.
1746 * - option id: "org.eclipse.jdt.core.compiler.problem.unreachableCode"
1747 * - possible values: { "error", "warning", "ignore" }
1748 * - default: "error"
1750 * COMPILER / Reporting Invalid Import
1751 * An import statement that cannot be resolved might optionally be reported
1752 * as an error, as a warning or ignored.
1753 * - option id: "org.eclipse.jdt.core.compiler.problem.invalidImport"
1754 * - possible values: { "error", "warning", "ignore" }
1755 * - default: "error"
1757 * COMPILER / Reporting Attempt to Override Package-Default Method
1758 * A package default method is not visible in a different package, and thus
1759 * cannot be overridden. When enabling this option, the compiler will signal
1760 * such scenarii either as an error or a warning.
1761 * - option id: "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"
1762 * - possible values: { "error", "warning", "ignore" }
1763 * - default: "warning"
1765 * COMPILER / Reporting Method With Constructor Name
1766 * Naming a method with a constructor name is generally considered poor
1767 * style programming. When enabling this option, the compiler will signal such
1768 * scenarii either as an error or a warning.
1769 * - option id: "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"
1770 * - possible values: { "error", "warning", "ignore" }
1771 * - default: "warning"
1773 * COMPILER / Reporting Deprecation
1774 * When enabled, the compiler will signal use of deprecated API either as an
1775 * error or a warning.
1776 * - option id: "org.eclipse.jdt.core.compiler.problem.deprecation"
1777 * - possible values: { "error", "warning", "ignore" }
1778 * - default: "warning"
1780 * COMPILER / Reporting Deprecation Inside Deprecated Code
1781 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
1782 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.deprecation".
1783 * - option id: "org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode"
1784 * - possible values: { "enabled", "disabled" }
1785 * - default: "disabled"
1787 * COMPILER / Reporting Hidden Catch Block
1788 * Locally to a try statement, some catch blocks may hide others . For example,
1789 * try { throw new java.io.CharConversionException();
1790 * } catch (java.io.CharConversionException e) {
1791 * } catch (java.io.IOException e) {}.
1792 * When enabling this option, the compiler will issue an error or a warning for hidden
1793 * catch blocks corresponding to checked exceptions
1794 * - option id: "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"
1795 * - possible values: { "error", "warning", "ignore" }
1796 * - default: "warning"
1798 * COMPILER / Reporting Unused Local
1799 * When enabled, the compiler will issue an error or a warning for unused local
1800 * variables (that is, variables never read from)
1801 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedLocal"
1802 * - possible values: { "error", "warning", "ignore" }
1803 * - default: "ignore"
1805 * COMPILER / Reporting Unused Parameter
1806 * When enabled, the compiler will issue an error or a warning for unused method
1807 * parameters (that is, parameters never read from)
1808 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameter"
1809 * - possible values: { "error", "warning", "ignore" }
1810 * - default: "ignore"
1812 * COMPILER / Reporting Unused Parameter if Implementing Abstract Method
1813 * When enabled, the compiler will signal unused parameters in abstract method implementations.
1814 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
1815 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"
1816 * - possible values: { "enabled", "disabled" }
1817 * - default: "disabled"
1819 * COMPILER / Reporting Unused Parameter if Overriding Concrete Method
1820 * When enabled, the compiler will signal unused parameters in methods overriding concrete ones.
1821 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
1822 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"
1823 * - possible values: { "enabled", "disabled" }
1824 * - default: "disabled"
1826 * COMPILER / Reporting Unused Import
1827 * When enabled, the compiler will issue an error or a warning for unused import
1829 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedImport"
1830 * - possible values: { "error", "warning", "ignore" }
1831 * - default: "warning"
1833 * COMPILER / Reporting Unused Private Members
1834 * When enabled, the compiler will issue an error or a warning whenever a private
1835 * method or field is declared but never used within the same unit.
1836 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"
1837 * - possible values: { "error", "warning", "ignore" }
1838 * - default: "ignore"
1840 * COMPILER / Reporting Synthetic Access Emulation
1841 * When enabled, the compiler will issue an error or a warning whenever it emulates
1842 * access to a non-accessible member of an enclosing type. Such access can have
1843 * performance implications.
1844 * - option id: "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"
1845 * - possible values: { "error", "warning", "ignore" }
1846 * - default: "ignore"
1848 * COMPILER / Reporting Non-Externalized String Literal
1849 * When enabled, the compiler will issue an error or a warning for non externalized
1850 * String literal (that is, not tagged with //$NON-NLS-<n>$).
1851 * - option id: "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"
1852 * - possible values: { "error", "warning", "ignore" }
1853 * - default: "ignore"
1855 * COMPILER / Reporting Usage of 'assert' Identifier
1856 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
1857 * used as an identifier (reserved keyword in 1.4)
1858 * - option id: "org.eclipse.jdt.core.compiler.problem.assertIdentifier"
1859 * - possible values: { "error", "warning", "ignore" }
1860 * - default: "ignore"
1862 * COMPILER / Reporting Non-Static Reference to a Static Member
1863 * When enabled, the compiler will issue an error or a warning whenever a static field
1864 * or method is accessed with an expression receiver. A reference to a static member should
1865 * be qualified with a type name.
1866 * - option id: "org.eclipse.jdt.core.compiler.problem.staticAccessReceiver"
1867 * - possible values: { "error", "warning", "ignore" }
1868 * - default: "warning"
1870 * COMPILER / Reporting Assignment with no Effect
1871 * When enabled, the compiler will issue an error or a warning whenever an assignment
1872 * has no effect (e.g 'x = x').
1873 * - option id: "org.eclipse.jdt.core.compiler.problem.noEffectAssignment"
1874 * - possible values: { "error", "warning", "ignore" }
1875 * - default: "warning"
1877 * COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods
1878 * When enabled, the compiler will issue an error or a warning whenever an interface
1879 * defines a method incompatible with a non-inherited Object method. Until this conflict
1880 * is resolved, such an interface cannot be implemented, For example,
1884 * - option id: "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"
1885 * - possible values: { "error", "warning", "ignore" }
1886 * - default: "warning"
1888 * COMPILER / Reporting Usage of char[] Expressions in String Concatenations
1889 * When enabled, the compiler will issue an error or a warning whenever a char[] expression
1890 * is used in String concatenations (for example, "hello" + new char[]{'w','o','r','l','d'}).
1891 * - option id: "org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion"
1892 * - possible values: { "error", "warning", "ignore" }
1893 * - default: "warning"
1895 * COMPILER / Setting Source Compatibility Mode
1896 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
1897 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
1898 * level should be set to "1.4" and the compliance mode should be "1.4".
1899 * - option id: "org.eclipse.jdt.core.compiler.source"
1900 * - possible values: { "1.3", "1.4" }
1903 * COMPILER / Setting Compliance Level
1904 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
1905 * should not go beyond "1.3" level.
1906 * - option id: "org.eclipse.jdt.core.compiler.compliance"
1907 * - possible values: { "1.3", "1.4" }
1910 * COMPILER / Maximum number of problems reported per compilation unit
1911 * Specify the maximum number of problems reported on each compilation unit.
1912 * - option id: "org.eclipse.jdt.core.compiler.maxProblemPerUnit"
1913 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
1916 * COMPILER / Define the Automatic Task Tags
1917 * When the tag list is not empty, the compiler will issue a task marker whenever it encounters
1918 * one of the corresponding tag inside any comment in Java source code.
1919 * Generated task messages will include the tag, and range until the next line separator or comment ending.
1920 * Note that tasks messages are trimmed.
1921 * - option id: "org.eclipse.jdt.core.compiler.taskTags"
1922 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card or leading/trailing spaces
1925 * COMPILER / Define the Automatic Task Priorities
1926 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
1927 * of the task markers issued by the compiler.
1928 * If the default is specified, the priority of each task marker is "NORMAL".
1929 * - option id: "org.eclipse.jdt.core.compiler.taskPriorities"
1930 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
1933 * BUILDER / Specifying Filters for Resource Copying Control
1934 * Allow to specify some filters to control the resource copy process.
1935 * - option id: "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
1936 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
1937 * or the name of a folder which ends with '/'
1940 * BUILDER / Abort if Invalid Classpath
1941 * Allow to toggle the builder to abort if the classpath is invalid
1942 * - option id: "org.eclipse.jdt.core.builder.invalidClasspath"
1943 * - possible values: { "abort", "ignore" }
1944 * - default: "abort"
1946 * BUILDER / Cleaning Output Folder(s)
1947 * Indicate whether the JavaBuilder is allowed to clean the output folders
1948 * when performing full build operations.
1949 * - option id: "org.eclipse.jdt.core.builder.cleanOutputFolder"
1950 * - possible values: { "clean", "ignore" }
1951 * - default: "clean"
1953 * BUILDER / Reporting Duplicate Resources
1954 * Indicate the severity of the problem reported when more than one occurrence
1955 * of a resource is to be copied into the output location.
1956 * - option id: "org.eclipse.jdt.core.builder.duplicateResourceTask"
1957 * - possible values: { "error", "warning" }
1958 * - default: "warning"
1960 * JAVACORE / Computing Project Build Order
1961 * Indicate whether JavaCore should enforce the project build order to be based on
1962 * the classpath prerequisite chain. When requesting to compute, this takes over
1963 * the platform default order (based on project references).
1964 * - option id: "org.eclipse.jdt.core.computeJavaBuildOrder"
1965 * - possible values: { "compute", "ignore" }
1966 * - default: "ignore"
1968 * JAVACORE / Specify Default Source Encoding Format
1969 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
1970 * to 'ResourcesPlugin.getEncoding()'.
1971 * - option id: "org.eclipse.jdt.core.encoding"
1972 * - possible values: { any of the supported encoding name}.
1973 * - default: <platform default>
1975 * JAVACORE / Reporting Incomplete Classpath
1976 * Indicate the severity of the problem reported when an entry on the classpath does not exist,
1977 * is not legite or is not visible (for example, a referenced project is closed).
1978 * - option id: "org.eclipse.jdt.core.incompleteClasspath"
1979 * - possible values: { "error", "warning"}
1980 * - default: "error"
1982 * JAVACORE / Reporting Classpath Cycle
1983 * Indicate the severity of the problem reported when a project is involved in a cycle.
1984 * - option id: "org.eclipse.jdt.core.circularClasspath"
1985 * - possible values: { "error", "warning" }
1986 * - default: "error"
1988 * JAVACORE / Enabling Usage of Classpath Exclusion Patterns
1989 * When disabled, no entry on a project classpath can be associated with
1990 * an exclusion pattern.
1991 * - option id: "org.eclipse.jdt.core.classpath.exclusionPatterns"
1992 * - possible values: { "enabled", "disabled" }
1993 * - default: "enabled"
1995 * JAVACORE / Enabling Usage of Classpath Multiple Output Locations
1996 * When disabled, no entry on a project classpath can be associated with
1997 * a specific output location, preventing thus usage of multiple output locations.
1998 * - option id: "org.eclipse.jdt.core.classpath.multipleOutputLocations"
1999 * - possible values: { "enabled", "disabled" }
2000 * - default: "enabled"
2002 * FORMATTER / Inserting New Line Before Opening Brace
2003 * When Insert, a new line is inserted before an opening brace, otherwise nothing
2005 * - option id: "org.eclipse.jdt.core.formatter.newline.openingBrace"
2006 * - possible values: { "insert", "do not insert" }
2007 * - default: "do not insert"
2009 * FORMATTER / Inserting New Line Inside Control Statement
2010 * When Insert, a new line is inserted between } and following else, catch, finally
2011 * - option id: "org.eclipse.jdt.core.formatter.newline.controlStatement"
2012 * - possible values: { "insert", "do not insert" }
2013 * - default: "do not insert"
2015 * FORMATTER / Clearing Blank Lines
2016 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
2017 * and all others removed.
2018 * - option id: "org.eclipse.jdt.core.formatter.newline.clearAll"
2019 * - possible values: { "clear all", "preserve one" }
2020 * - default: "preserve one"
2022 * FORMATTER / Inserting New Line Between Else/If
2023 * When Insert, a blank line is inserted between an else and an if when they are
2024 * contiguous. When choosing to not insert, else-if will be kept on the same
2025 * line when possible.
2026 * - option id: "org.eclipse.jdt.core.formatter.newline.elseIf"
2027 * - possible values: { "insert", "do not insert" }
2028 * - default: "do not insert"
2030 * FORMATTER / Inserting New Line In Empty Block
2031 * When insert, a line break is inserted between contiguous { and }, if } is not followed
2033 * - option id: "org.eclipse.jdt.core.formatter.newline.emptyBlock"
2034 * - possible values: { "insert", "do not insert" }
2035 * - default: "insert"
2037 * FORMATTER / Splitting Lines Exceeding Length
2038 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
2039 * disable line splitting
2040 * - option id: "org.eclipse.jdt.core.formatter.lineSplit"
2041 * - possible values: "<n>", where n is zero or a positive integer
2044 * FORMATTER / Compacting Assignment
2045 * Assignments can be formatted asymmetrically, for example 'int x= 2;', when Normal, a space
2046 * is inserted before the assignment operator
2047 * - option id: "org.eclipse.jdt.core.formatter.style.assignment"
2048 * - possible values: { "compact", "normal" }
2049 * - default: "normal"
2051 * FORMATTER / Defining Indentation Character
2052 * Either choose to indent with tab characters or spaces
2053 * - option id: "org.eclipse.jdt.core.formatter.tabulation.char"
2054 * - possible values: { "tab", "space" }
2057 * FORMATTER / Defining Space Indentation Length
2058 * When using spaces, set the amount of space characters to use for each
2060 * - option id: "org.eclipse.jdt.core.formatter.tabulation.size"
2061 * - possible values: "<n>", where n is a positive integer
2064 * FORMATTER / Inserting space in cast expression
2065 * When Insert, a space is added between the type and the expression in a cast expression.
2066 * - option id: "org.eclipse.jdt.core.formatter.space.castexpression"
2067 * - possible values: { "insert", "do not insert" }
2068 * - default: "insert"
2070 * CODEASSIST / Activate Visibility Sensitive Completion
2071 * When active, completion doesn't show that you can not see
2072 * (for example, you can not see private methods of a super class).
2073 * - option id: "org.eclipse.jdt.core.codeComplete.visibilityCheck"
2074 * - possible values: { "enabled", "disabled" }
2075 * - default: "disabled"
2077 * CODEASSIST / Automatic Qualification of Implicit Members
2078 * When active, completion automatically qualifies completion on implicit
2079 * field references and message expressions.
2080 * - option id: "org.eclipse.jdt.core.codeComplete.forceImplicitQualification"
2081 * - possible values: { "enabled", "disabled" }
2082 * - default: "disabled"
2084 * CODEASSIST / Define the Prefixes for Field Name
2085 * When the prefixes is non empty, completion for field name will begin with
2086 * one of the proposed prefixes.
2087 * - option id: "org.eclipse.jdt.core.codeComplete.fieldPrefixes"
2088 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2091 * CODEASSIST / Define the Prefixes for Static Field Name
2092 * When the prefixes is non empty, completion for static field name will begin with
2093 * one of the proposed prefixes.
2094 * - option id: "org.eclipse.jdt.core.codeComplete.staticFieldPrefixes"
2095 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2098 * CODEASSIST / Define the Prefixes for Local Variable Name
2099 * When the prefixes is non empty, completion for local variable name will begin with
2100 * one of the proposed prefixes.
2101 * - option id: "org.eclipse.jdt.core.codeComplete.localPrefixes"
2102 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2105 * CODEASSIST / Define the Prefixes for Argument Name
2106 * When the prefixes is non empty, completion for argument name will begin with
2107 * one of the proposed prefixes.
2108 * - option id: "org.eclipse.jdt.core.codeComplete.argumentPrefixes"
2109 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2112 * CODEASSIST / Define the Suffixes for Field Name
2113 * When the suffixes is non empty, completion for field name will end with
2114 * one of the proposed suffixes.
2115 * - option id: "org.eclipse.jdt.core.codeComplete.fieldSuffixes"
2116 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2119 * CODEASSIST / Define the Suffixes for Static Field Name
2120 * When the suffixes is non empty, completion for static field name will end with
2121 * one of the proposed suffixes.
2122 * - option id: "org.eclipse.jdt.core.codeComplete.staticFieldSuffixes"
2123 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2126 * CODEASSIST / Define the Suffixes for Local Variable Name
2127 * When the suffixes is non empty, completion for local variable name will end with
2128 * one of the proposed suffixes.
2129 * - option id: "org.eclipse.jdt.core.codeComplete.localSuffixes"
2130 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2133 * CODEASSIST / Define the Suffixes for Argument Name
2134 * When the suffixes is non empty, completion for argument name will end with
2135 * one of the proposed suffixes.
2136 * - option id: "org.eclipse.jdt.core.codeComplete.argumentSuffixes"
2137 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
2141 * @return a mutable table containing the default settings of all known options
2142 * (key type: <code>String</code>; value type: <code>String</code>)
2145 public static Hashtable getDefaultOptions(){
2147 Hashtable defaultOptions = new Hashtable(10);
2149 // see #initializeDefaultPluginPreferences() for changing default settings
2150 Preferences preferences = getPlugin().getPluginPreferences();
2151 HashSet optionNames = JavaModelManager.OptionNames;
2153 // get preferences set to their default
2154 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2155 for (int i = 0; i < defaultPropertyNames.length; i++){
2156 String propertyName = defaultPropertyNames[i];
2157 if (optionNames.contains(propertyName)) {
2158 defaultOptions.put(propertyName, preferences.getDefaultString(propertyName));
2161 // get preferences not set to their default
2162 String[] propertyNames = preferences.propertyNames();
2163 for (int i = 0; i < propertyNames.length; i++){
2164 String propertyName = propertyNames[i];
2165 if (optionNames.contains(propertyName)) {
2166 defaultOptions.put(propertyName, preferences.getDefaultString(propertyName));
2169 // get encoding through resource plugin
2170 defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2172 return defaultOptions;
2176 * Returns the single instance of the Java core plug-in runtime class.
2177 * Equivalent to <code>(JavaCore) getPlugin()</code>.
2179 * @return the single instance of the Java core plug-in runtime class
2181 public static PHPeclipsePlugin getJavaCore() {
2182 return (PHPeclipsePlugin) getPlugin();
2186 * Helper method for returning one option value only. Equivalent to <code>(String)JavaCore.getOptions().get(optionName)</code>
2187 * Note that it may answer <code>null</code> if this option does not exist.
2189 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
2192 * @param optionName the name of an option
2193 * @return the String value of a given option
2194 * @see JavaCore#getDefaultOptions
2197 public static String getOption(String optionName) {
2199 if (CORE_ENCODING.equals(optionName)){
2200 return ResourcesPlugin.getEncoding();
2202 if (JavaModelManager.OptionNames.contains(optionName)){
2203 Preferences preferences = getPlugin().getPluginPreferences();
2204 return preferences.getString(optionName).trim();
2210 * Returns the table of the current options. Initially, all options have their default values,
2211 * and this method returns a table that includes all known options.
2213 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
2216 * @return table of current settings of all options
2217 * (key type: <code>String</code>; value type: <code>String</code>)
2218 * @see JavaCore#getDefaultOptions
2220 public static Hashtable getOptions() {
2222 Hashtable options = new Hashtable(10);
2224 // see #initializeDefaultPluginPreferences() for changing default settings
2225 Plugin plugin = getPlugin();
2226 if (plugin != null) {
2227 Preferences preferences = getPlugin().getPluginPreferences();
2228 HashSet optionNames = JavaModelManager.OptionNames;
2230 // get preferences set to their default
2231 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2232 for (int i = 0; i < defaultPropertyNames.length; i++){
2233 String propertyName = defaultPropertyNames[i];
2234 if (optionNames.contains(propertyName)){
2235 options.put(propertyName, preferences.getDefaultString(propertyName));
2238 // get preferences not set to their default
2239 String[] propertyNames = preferences.propertyNames();
2240 for (int i = 0; i < propertyNames.length; i++){
2241 String propertyName = propertyNames[i];
2242 if (optionNames.contains(propertyName)){
2243 options.put(propertyName, preferences.getString(propertyName).trim());
2246 // get encoding through resource plugin
2247 options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2253 * This is a helper method, which returns the resolved classpath entry denoted
2254 * by a given entry (if it is a variable entry). It is obtained by resolving the variable
2255 * reference in the first segment. Returns <node>null</code> if unable to resolve using
2256 * the following algorithm:
2258 * <li> if variable segment cannot be resolved, returns <code>null</code></li>
2259 * <li> finds a project, JAR or binary folder in the workspace at the resolved path location</li>
2260 * <li> if none finds an external JAR file or folder outside the workspace at the resolved path location </li>
2261 * <li> if none returns <code>null</code></li>
2264 * Variable source attachment path and root path are also resolved and recorded in the resulting classpath entry.
2266 * NOTE: This helper method does not handle classpath containers, for which should rather be used
2267 * <code>JavaCore#getClasspathContainer(IPath, IJavaProject)</code>.
2270 * @param entry the given variable entry
2271 * @return the resolved library or project classpath entry, or <code>null</code>
2272 * if the given variable entry could not be resolved to a valid classpath entry
2274 public static IClasspathEntry getResolvedClasspathEntry(IClasspathEntry entry) {
2276 if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
2279 IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
2280 IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath());
2281 if (resolvedPath == null)
2284 Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false);
2288 // inside the workspace
2289 if (target instanceof IResource) {
2290 IResource resolvedResource = (IResource) target;
2291 if (resolvedResource != null) {
2292 switch (resolvedResource.getType()) {
2294 case IResource.PROJECT :
2296 return JavaCore.newProjectEntry(resolvedPath, entry.isExported());
2298 case IResource.FILE :
2299 // if (Util.isArchiveFileName(resolvedResource.getName())) {
2300 // // internal binary archive
2301 // return JavaCore.newLibraryEntry(
2303 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2304 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2305 // entry.isExported());
2309 case IResource.FOLDER :
2310 // internal binary folder
2311 // return JavaCore.newLibraryEntry(
2313 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2314 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2315 // entry.isExported());
2320 // outside the workspace
2321 if (target instanceof File) {
2322 File externalFile = (File) target;
2323 if (externalFile.isFile()) {
2324 String fileName = externalFile.getName().toLowerCase();
2325 // if (fileName.endsWith(".jar" //$NON-NLS-1$
2326 // ) || fileName.endsWith(".zip" //$NON-NLS-1$
2327 // )) { // external binary archive
2328 // return JavaCore.newLibraryEntry(
2330 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2331 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2332 // entry.isExported());
2334 } else { // external binary folder
2335 if (resolvedPath.isAbsolute()){
2336 // return JavaCore.newLibraryEntry(
2338 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2339 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2340 // entry.isExported());
2349 * Resolve a variable path (helper method).
2351 * @param variablePath the given variable path
2352 * @return the resolved variable path or <code>null</code> if none
2354 public static IPath getResolvedVariablePath(IPath variablePath) {
2356 if (variablePath == null)
2358 int count = variablePath.segmentCount();
2363 String variableName = variablePath.segment(0);
2364 IPath resolvedPath = JavaCore.getClasspathVariable(variableName);
2365 if (resolvedPath == null)
2368 // append path suffix
2370 resolvedPath = resolvedPath.append(variablePath.removeFirstSegments(1));
2372 return resolvedPath;
2376 * Answers the shared working copies currently registered for this buffer factory.
2377 * Working copies can be shared by several clients using the same buffer factory,see
2378 * <code>IWorkingCopy.getSharedWorkingCopy</code>.
2380 * @param factory the given buffer factory
2381 * @return the list of shared working copies for a given buffer factory
2385 public static IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory){
2387 // if factory is null, default factory must be used
2388 if (factory == null) factory = BufferManager.getDefaultBufferManager().getDefaultBufferFactory();
2389 Map sharedWorkingCopies = JavaModelManager.getJavaModelManager().sharedWorkingCopies;
2391 Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
2392 if (perFactoryWorkingCopies == null) return JavaModelManager.NoWorkingCopy;
2393 Collection copies = perFactoryWorkingCopies.values();
2394 IWorkingCopy[] result = new IWorkingCopy[copies.size()];
2395 copies.toArray(result);
2400 * Initializes the default preferences settings for this plug-in.
2402 public static void initializeDefaultPluginPreferences() {
2404 Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
2405 HashSet optionNames = JavaModelManager.OptionNames;
2407 // Compiler settings
2408 preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
2409 optionNames.add(COMPILER_LOCAL_VARIABLE_ATTR);
2411 preferences.setDefault(COMPILER_LINE_NUMBER_ATTR, GENERATE);
2412 optionNames.add(COMPILER_LINE_NUMBER_ATTR);
2414 preferences.setDefault(COMPILER_SOURCE_FILE_ATTR, GENERATE);
2415 optionNames.add(COMPILER_SOURCE_FILE_ATTR);
2417 preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE);
2418 optionNames.add(COMPILER_CODEGEN_UNUSED_LOCAL);
2420 preferences.setDefault(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1);
2421 optionNames.add(COMPILER_CODEGEN_TARGET_PLATFORM);
2423 preferences.setDefault(COMPILER_PB_PHP_VAR_DEPRECATED, WARNING);
2424 optionNames.add(COMPILER_PB_PHP_VAR_DEPRECATED);
2426 preferences.setDefault(COMPILER_PB_UNREACHABLE_CODE, ERROR);
2427 optionNames.add(COMPILER_PB_UNREACHABLE_CODE);
2429 preferences.setDefault(COMPILER_PB_INVALID_IMPORT, ERROR);
2430 optionNames.add(COMPILER_PB_INVALID_IMPORT);
2432 preferences.setDefault(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, WARNING);
2433 optionNames.add(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD);
2435 preferences.setDefault(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME, WARNING);
2436 optionNames.add(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME);
2438 preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING);
2439 optionNames.add(COMPILER_PB_DEPRECATION);
2441 preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE, DISABLED);
2442 optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE);
2444 preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING);
2445 optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK);
2447 preferences.setDefault(COMPILER_PB_UNUSED_LOCAL, IGNORE);
2448 optionNames.add(COMPILER_PB_UNUSED_LOCAL);
2450 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE);
2451 optionNames.add(COMPILER_PB_UNUSED_PARAMETER);
2453 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT, DISABLED);
2454 optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT);
2456 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE, DISABLED);
2457 optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE);
2459 preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING);
2460 optionNames.add(COMPILER_PB_UNUSED_IMPORT);
2462 preferences.setDefault(COMPILER_PB_UNUSED_PRIVATE_MEMBER, IGNORE);
2463 optionNames.add(COMPILER_PB_UNUSED_PRIVATE_MEMBER);
2465 preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE);
2466 optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION);
2468 preferences.setDefault(COMPILER_PB_NON_NLS_STRING_LITERAL, IGNORE);
2469 optionNames.add(COMPILER_PB_NON_NLS_STRING_LITERAL);
2471 preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE);
2472 optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER);
2474 preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING);
2475 optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER);
2477 preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING);
2478 optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT);
2480 preferences.setDefault(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD, WARNING);
2481 optionNames.add(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD);
2483 preferences.setDefault(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION, WARNING);
2484 optionNames.add(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION);
2486 preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAG); //$NON-NLS-1$
2487 optionNames.add(COMPILER_TASK_TAGS);
2489 preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITY); //$NON-NLS-1$
2490 optionNames.add(COMPILER_TASK_PRIORITIES);
2492 preferences.setDefault(COMPILER_SOURCE, VERSION_1_3);
2493 optionNames.add(COMPILER_SOURCE);
2495 preferences.setDefault(COMPILER_COMPLIANCE, VERSION_1_3);
2496 optionNames.add(COMPILER_COMPLIANCE);
2498 preferences.setDefault(COMPILER_PB_MAX_PER_UNIT, "100"); //$NON-NLS-1$
2499 optionNames.add(COMPILER_PB_MAX_PER_UNIT);
2502 preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
2503 optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
2505 preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT);
2506 optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH);
2508 preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING);
2509 optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE);
2511 preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN);
2512 optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER);
2514 // JavaCore settings
2515 preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE);
2516 optionNames.add(CORE_JAVA_BUILD_ORDER);
2518 preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR);
2519 optionNames.add(CORE_CIRCULAR_CLASSPATH);
2521 preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR);
2522 optionNames.add(CORE_INCOMPLETE_CLASSPATH);
2524 preferences.setDefault(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, ENABLED);
2525 optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS);
2527 preferences.setDefault(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, ENABLED);
2528 optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS);
2530 // encoding setting comes from resource plug-in
2531 optionNames.add(CORE_ENCODING);
2533 // Formatter settings
2534 preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT);
2535 optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE);
2537 preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT);
2538 optionNames.add(FORMATTER_NEWLINE_CONTROL);
2540 preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE);
2541 optionNames.add(FORMATTER_CLEAR_BLANK_LINES);
2543 preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT);
2544 optionNames.add(FORMATTER_NEWLINE_ELSE_IF);
2546 preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT);
2547 optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK);
2549 preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$
2550 optionNames.add(FORMATTER_LINE_SPLIT);
2552 preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL);
2553 optionNames.add(FORMATTER_COMPACT_ASSIGNMENT);
2555 preferences.setDefault(FORMATTER_TAB_CHAR, TAB);
2556 optionNames.add(FORMATTER_TAB_CHAR);
2558 preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$
2559 optionNames.add(FORMATTER_TAB_SIZE);
2561 preferences.setDefault(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$
2562 optionNames.add(FORMATTER_SPACE_CASTEXPRESSION);
2564 // CodeAssist settings
2565 preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$
2566 optionNames.add(CODEASSIST_VISIBILITY_CHECK);
2568 preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$
2569 optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION);
2571 preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
2572 optionNames.add(CODEASSIST_FIELD_PREFIXES);
2574 preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
2575 optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES);
2577 preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
2578 optionNames.add(CODEASSIST_LOCAL_PREFIXES);
2580 preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
2581 optionNames.add(CODEASSIST_ARGUMENT_PREFIXES);
2583 preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
2584 optionNames.add(CODEASSIST_FIELD_SUFFIXES);
2586 preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
2587 optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES);
2589 preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
2590 optionNames.add(CODEASSIST_LOCAL_SUFFIXES);
2592 preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
2593 optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES);
2597 * Returns whether the given marker references the given Java element.
2598 * Used for markers, which denote a Java element rather than a resource.
2600 * @param element the element
2601 * @param marker the marker
2602 * @return <code>true</code> if the marker references the element, false otherwise
2603 * @exception CoreException if the <code>IMarker.getAttribute</code> on the marker fails
2605 public static boolean isReferencedBy(IJavaElement element, IMarker marker) throws CoreException {
2607 // only match units or classfiles
2608 if (element instanceof IMember){
2609 IMember member = (IMember) element;
2610 if (member.isBinary()){
2611 element = null; //member.getClassFile();
2613 element = member.getCompilationUnit();
2616 if (element == null) return false;
2617 if (marker == null) return false;
2619 String markerHandleId = (String)marker.getAttribute(ATT_HANDLE_ID);
2620 if (markerHandleId == null) return false;
2622 IJavaElement markerElement = JavaCore.create(markerHandleId);
2624 if (element.equals(markerElement)) return true; // external elements may still be equal with different handleIDs.
2626 // cycle through enclosing types in case marker is associated with a classfile (15568)
2627 // if (markerElement instanceof IClassFile){
2628 // IType enclosingType = ((IClassFile)markerElement).getType().getDeclaringType();
2629 // if (enclosingType != null){
2630 // markerElement = enclosingType.getClassFile(); // retry with immediate enclosing classfile
2640 * Returns whether the given marker delta references the given Java element.
2641 * Used for markers deltas, which denote a Java element rather than a resource.
2643 * @param element the element
2644 * @param markerDelta the marker delta
2645 * @return <code>true</code> if the marker delta references the element
2646 * @exception CoreException if the <code>IMarkerDelta.getAttribute</code> on the marker delta fails
2648 public static boolean isReferencedBy(IJavaElement element, IMarkerDelta markerDelta) throws CoreException {
2650 // only match units or classfiles
2651 if (element instanceof IMember){
2652 IMember member = (IMember) element;
2653 if (member.isBinary()){
2654 element = null; //member.getClassFile();
2656 element = member.getCompilationUnit();
2659 if (element == null) return false;
2660 if (markerDelta == null) return false;
2662 String markerDeltarHandleId = (String)markerDelta.getAttribute(ATT_HANDLE_ID);
2663 if (markerDeltarHandleId == null) return false;
2665 IJavaElement markerElement = JavaCore.create(markerDeltarHandleId);
2667 if (element.equals(markerElement)) return true; // external elements may still be equal with different handleIDs.
2669 // cycle through enclosing types in case marker is associated with a classfile (15568)
2670 // if (markerElement instanceof IClassFile){
2671 // IType enclosingType = ((IClassFile)markerElement).getType().getDeclaringType();
2672 // if (enclosingType != null){
2673 // markerElement = enclosingType.getClassFile(); // retry with immediate enclosing classfile
2683 * Creates and returns a new classpath entry of kind <code>CPE_CONTAINER</code>
2684 * for the given path. The path of the container will be used during resolution so as to map this
2685 * container entry to a set of other classpath entries the container is acting for.
2687 * A container entry allows to express indirect references to a set of libraries, projects and variable entries,
2688 * which can be interpreted differently for each Java project where it is used.
2689 * A classpath container entry can be resolved using <code>JavaCore.getResolvedClasspathContainer</code>,
2690 * and updated with <code>JavaCore.classpathContainerChanged</code>
2692 * A container is exclusively resolved by a <code>ClasspathContainerInitializer</code> registered onto the
2693 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
2695 * A container path must be formed of at least one segment, where: <ul>
2696 * <li> the first segment is a unique ID identifying the target container, there must be a container initializer registered
2697 * onto this ID through the extension point "org.eclipse.jdt.core.classpathContainerInitializer". </li>
2698 * <li> the remaining segments will be passed onto the initializer, and can be used as additional
2699 * hints during the initialization phase. </li>
2702 * Example of an ClasspathContainerInitializer for a classpath container denoting a default JDK container:
2704 * containerEntry = JavaCore.newContainerEntry(new Path("MyProvidedJDK/default"));
2707 * point="org.eclipse.jdt.core.classpathContainerInitializer">
2708 * <containerInitializer
2709 * id="MyProvidedJDK"
2710 * class="com.example.MyInitializer"/>
2712 * Note that this operation does not attempt to validate classpath containers
2713 * or access the resources at the given paths.
2715 * The resulting entry is not exported to dependent projects. This method is equivalent to
2716 * <code>newContainerEntry(-,false)</code>.
2718 * @param containerPath the path identifying the container, it must be formed of two
2720 * @return a new container classpath entry
2722 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
2723 * @see JavaCore#newContainerEntry(IPath, boolean)
2726 public static IClasspathEntry newContainerEntry(IPath containerPath) {
2728 return newContainerEntry(containerPath, false);
2732 * Creates and returns a new classpath entry of kind <code>CPE_CONTAINER</code>
2733 * for the given path. The path of the container will be used during resolution so as to map this
2734 * container entry to a set of other classpath entries the container is acting for.
2736 * A container entry allows to express indirect references to a set of libraries, projects and variable entries,
2737 * which can be interpreted differently for each Java project where it is used.
2738 * A classpath container entry can be resolved using <code>JavaCore.getResolvedClasspathContainer</code>,
2739 * and updated with <code>JavaCore.classpathContainerChanged</code>
2741 * A container is exclusively resolved by a <code>ClasspathContainerInitializer</code> registered onto the
2742 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
2744 * A container path must be formed of at least one segment, where: <ul>
2745 * <li> the first segment is a unique ID identifying the target container, there must be a container initializer registered
2746 * onto this ID through the extension point "org.eclipse.jdt.core.classpathContainerInitializer". </li>
2747 * <li> the remaining segments will be passed onto the initializer, and can be used as additional
2748 * hints during the initialization phase. </li>
2751 * Example of an ClasspathContainerInitializer for a classpath container denoting a default JDK container:
2753 * containerEntry = JavaCore.newContainerEntry(new Path("MyProvidedJDK/default"));
2756 * point="org.eclipse.jdt.core.classpathContainerInitializer">
2757 * <containerInitializer
2758 * id="MyProvidedJDK"
2759 * class="com.example.MyInitializer"/>
2761 * Note that this operation does not attempt to validate classpath containers
2762 * or access the resources at the given paths.
2764 * @param containerPath the path identifying the container, it must be formed of at least
2765 * one segment (ID+hints)
2766 * @param isExported a boolean indicating whether this entry is contributed to dependent
2767 * projects in addition to the output location
2768 * @return a new container classpath entry
2770 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
2771 * @see JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor)
2772 * @see JavaCore#newContainerEntry(IPath, boolean)
2775 public static IClasspathEntry newContainerEntry(IPath containerPath, boolean isExported) {
2777 if (containerPath == null || containerPath.segmentCount() < 1) {
2780 "Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$
2782 return new ClasspathEntry(
2783 IPackageFragmentRoot.K_SOURCE,
2784 IClasspathEntry.CPE_CONTAINER,
2786 ClasspathEntry.NO_EXCLUSION_PATTERNS,
2787 null, // source attachment
2788 null, // source attachment root
2789 null, // specific output folder
2794 * Creates and returns a new non-exported classpath entry of kind <code>CPE_LIBRARY</code> for the
2795 * JAR or folder identified by the given absolute path. This specifies that all package fragments
2796 * within the root will have children of type <code>IClassFile</code>.
2798 * A library entry is used to denote a prerequisite JAR or root folder containing binaries.
2799 * The target JAR or folder can either be defined internally to the workspace (absolute path relative
2800 * to the workspace root) or externally to the workspace (absolute path in the file system).
2802 * e.g. Here are some examples of binary path usage<ul>
2803 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code> - reference to an external JAR</li>
2804 * <li><code> "/Project/someLib.jar" </code> - reference to an internal JAR </li>
2805 * <li><code> "c:/classes/" </code> - reference to an external binary folder</li>
2807 * Note that this operation does not attempt to validate or access the
2808 * resources at the given paths.
2810 * The resulting entry is not exported to dependent projects. This method is equivalent to
2811 * <code>newLibraryEntry(-,-,-,false)</code>.
2814 * @param path the absolute path of the binary archive
2815 * @param sourceAttachmentPath the absolute path of the corresponding source archive or folder,
2816 * or <code>null</code> if none
2817 * @param sourceAttachmentRootPath the location of the root within the source archive or folder
2818 * or <code>null</code> if this location should be automatically detected.
2819 * @return a new library classpath entry
2821 * @see #newLibraryEntry(IPath, IPath, IPath, boolean)
2823 //public static IClasspathEntry newLibraryEntry(
2825 // IPath sourceAttachmentPath,
2826 // IPath sourceAttachmentRootPath) {
2828 // return newLibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath, false);
2832 * Creates and returns a new classpath entry of kind <code>CPE_LIBRARY</code> for the JAR or folder
2833 * identified by the given absolute path. This specifies that all package fragments within the root
2834 * will have children of type <code>IClassFile</code>.
2836 * A library entry is used to denote a prerequisite JAR or root folder containing binaries.
2837 * The target JAR or folder can either be defined internally to the workspace (absolute path relative
2838 * to the workspace root) or externally to the workspace (absolute path in the file system).
2840 * e.g. Here are some examples of binary path usage<ul>
2841 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code> - reference to an external JAR</li>
2842 * <li><code> "/Project/someLib.jar" </code> - reference to an internal JAR </li>
2843 * <li><code> "c:/classes/" </code> - reference to an external binary folder</li>
2845 * Note that this operation does not attempt to validate or access the
2846 * resources at the given paths.
2849 * @param path the absolute path of the binary archive
2850 * @param sourceAttachmentPath the absolute path of the corresponding source archive or folder,
2851 * or <code>null</code> if none
2852 * @param sourceAttachmentRootPath the location of the root within the source archive or folder
2853 * or <code>null</code> if this location should be automatically detected.
2854 * @param isExported indicates whether this entry is contributed to dependent
2855 * projects in addition to the output location
2856 * @return a new library classpath entry
2859 //public static IClasspathEntry newLibraryEntry(
2861 // IPath sourceAttachmentPath,
2862 // IPath sourceAttachmentRootPath,
2863 // boolean isExported) {
2865 // if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
2867 // return new ClasspathEntry(
2868 // IPackageFragmentRoot.K_BINARY,
2869 // IClasspathEntry.CPE_LIBRARY,
2870 // JavaProject.canonicalizedPath(path),
2871 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
2872 // sourceAttachmentPath,
2873 // sourceAttachmentRootPath,
2874 // null, // specific output folder
2879 * Creates and returns a new non-exported classpath entry of kind <code>CPE_PROJECT</code>
2880 * for the project identified by the given absolute path.
2882 * A project entry is used to denote a prerequisite project on a classpath.
2883 * The referenced project will be contributed as a whole, either as sources (in the Java Model, it
2884 * contributes all its package fragment roots) or as binaries (when building, it contributes its
2885 * whole output location).
2887 * A project reference allows to indirect through another project, independently from its internal layout.
2889 * The prerequisite project is referred to using an absolute path relative to the workspace root.
2891 * The resulting entry is not exported to dependent projects. This method is equivalent to
2892 * <code>newProjectEntry(_,false)</code>.
2895 * @param path the absolute path of the binary archive
2896 * @return a new project classpath entry
2898 * @see JavaCore#newProjectEntry(IPath, boolean)
2900 public static IClasspathEntry newProjectEntry(IPath path) {
2901 return newProjectEntry(path, false);
2905 * Creates and returns a new classpath entry of kind <code>CPE_PROJECT</code>
2906 * for the project identified by the given absolute path.
2908 * A project entry is used to denote a prerequisite project on a classpath.
2909 * The referenced project will be contributed as a whole, either as sources (in the Java Model, it
2910 * contributes all its package fragment roots) or as binaries (when building, it contributes its
2911 * whole output location).
2913 * A project reference allows to indirect through another project, independently from its internal layout.
2915 * The prerequisite project is referred to using an absolute path relative to the workspace root.
2918 * @param path the absolute path of the prerequisite project
2919 * @param isExported indicates whether this entry is contributed to dependent
2920 * projects in addition to the output location
2921 * @return a new project classpath entry
2924 public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) {
2926 if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
2928 return new ClasspathEntry(
2929 IPackageFragmentRoot.K_SOURCE,
2930 IClasspathEntry.CPE_PROJECT,
2932 ClasspathEntry.NO_EXCLUSION_PATTERNS,
2933 null, // source attachment
2934 null, // source attachment root
2935 null, // specific output folder
2940 * Returns a new empty region.
2942 * @return a new empty region
2944 public static IRegion newRegion() {
2945 return new Region();
2949 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
2950 * for the project's source folder identified by the given absolute
2951 * workspace-relative path. This specifies that all package fragments
2952 * within the root will have children of type <code>ICompilationUnit</code>.
2954 * The source folder is referred to using an absolute path relative to the
2955 * workspace root, e.g. <code>/Project/src</code>. A project's source
2956 * folders are located with that project. That is, a source classpath
2957 * entry specifying the path <code>/P1/src</code> is only usable for
2958 * project <code>P1</code>.
2961 * The source classpath entry created by this method includes all source
2962 * files below the given workspace-relative path. To selectively exclude
2963 * some of these source files, use the factory method
2964 * <code>JavaCore.newSourceEntry(IPath,IPath[])</code> instead.
2967 * Note that all sources/binaries inside a project are contributed as a whole through
2968 * a project entry (see <code>JavaCore.newProjectEntry</code>). Particular
2969 * source entries cannot be selectively exported.
2972 * @param path the absolute workspace-relative path of a source folder
2973 * @return a new source classpath entry with not exclusion patterns
2975 * @see #newSourceEntry(org.eclipse.core.runtime.IPath,org.eclipse.core.runtime.IPath[])
2977 public static IClasspathEntry newSourceEntry(IPath path) {
2979 return newSourceEntry(path, ClasspathEntry.NO_EXCLUSION_PATTERNS, null /*output location*/);
2983 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
2984 * for the project's source folder identified by the given absolute
2985 * workspace-relative path but excluding all source files with paths
2986 * matching any of the given patterns. This specifies that all package
2987 * fragments within the root will have children of type
2988 * <code>ICompilationUnit</code>.
2990 * The source folder is referred to using an absolute path relative to the
2991 * workspace root, e.g. <code>/Project/src</code>. A project's source
2992 * folders are located with that project. That is, a source classpath
2993 * entry specifying the path <code>/P1/src</code> is only usable for
2994 * project <code>P1</code>.
2997 * The source classpath entry created by this method includes all source
2998 * files below the given workspace-relative path except for those matched
2999 * by one (or more) of the given exclusion patterns. Each exclusion pattern
3000 * is represented by a relative path, which is interpreted as relative to
3001 * the source folder. For example, if the source folder path is
3002 * <code>/Project/src</code> and the exclusion pattern is
3003 * <code>com/xyz/tests/**</code>, then source files
3004 * like <code>/Project/src/com/xyz/Foo.java</code>
3005 * and <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3006 * whereas <code>/Project/src/com/xyz/tests/T1.java</code>
3007 * and <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3008 * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
3009 * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code>
3010 * for the full description of the syntax and semantics of exclusion
3013 * If the empty list of exclusion patterns is specified, the source folder
3014 * will automatically include all resources located inside the source
3015 * folder. In that case, the result is entirely equivalent to using the
3016 * factory method <code>JavaCore.newSourceEntry(IPath)</code>.
3019 * Note that all sources/binaries inside a project are contributed as a whole through
3020 * a project entry (see <code>JavaCore.newProjectEntry</code>). Particular
3021 * source entries cannot be selectively exported.
3024 * @param path the absolute workspace-relative path of a source folder
3025 * @param exclusionPatterns the possibly empty list of exclusion patterns
3026 * represented as relative paths
3027 * @return a new source classpath entry with the given exclusion patterns
3028 * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
3029 * @see IClasspathEntry#getExclusionPatterns
3033 public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns) {
3035 return newSourceEntry(path, exclusionPatterns, null /*output location*/);
3039 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3040 * for the project's source folder identified by the given absolute
3041 * workspace-relative path but excluding all source files with paths
3042 * matching any of the given patterns, and associated with a specific output location
3043 * (that is, ".class" files are not going to the project default output location).
3044 * All package fragments within the root will have children of type
3045 * <code>ICompilationUnit</code>.
3047 * The source folder is referred to using an absolute path relative to the
3048 * workspace root, e.g. <code>/Project/src</code>. A project's source
3049 * folders are located with that project. That is, a source classpath
3050 * entry specifying the path <code>/P1/src</code> is only usable for
3051 * project <code>P1</code>.
3054 * The source classpath entry created by this method includes all source
3055 * files below the given workspace-relative path except for those matched
3056 * by one (or more) of the given exclusion patterns. Each exclusion pattern
3057 * is represented by a relative path, which is interpreted as relative to
3058 * the source folder. For example, if the source folder path is
3059 * <code>/Project/src</code> and the exclusion pattern is
3060 * <code>com/xyz/tests/**</code>, then source files
3061 * like <code>/Project/src/com/xyz/Foo.java</code>
3062 * and <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3063 * whereas <code>/Project/src/com/xyz/tests/T1.java</code>
3064 * and <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3065 * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
3066 * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code>
3067 * for the full description of the syntax and semantics of exclusion
3070 * If the empty list of exclusion patterns is specified, the source folder
3071 * will automatically include all resources located inside the source
3072 * folder. In that case, the result is entirely equivalent to using the
3073 * factory method <code>JavaCore.newSourceEntry(IPath)</code>.
3076 * Additionally, a source entry can be associated with a specific output location.
3077 * By doing so, the Java builder will ensure that the generated ".class" files will
3078 * be issued inside this output location, as opposed to be generated into the
3079 * project default output location (when output location is <code>null</code>).
3080 * Note that multiple source entries may target the same output location.
3081 * The output location is referred to using an absolute path relative to the
3082 * workspace root, e.g. <code>"/Project/bin"</code>, it must be located inside
3083 * the same project as the source folder.
3086 * Also note that all sources/binaries inside a project are contributed as a whole through
3087 * a project entry (see <code>JavaCore.newProjectEntry</code>). Particular
3088 * source entries cannot be selectively exported.
3091 * @param path the absolute workspace-relative path of a source folder
3092 * @param exclusionPatterns the possibly empty list of exclusion patterns
3093 * represented as relative paths
3094 * @param outputLocation the specific output location for this source entry (<code>null</code> if using project default ouput location)
3095 * @return a new source classpath entry with the given exclusion patterns
3096 * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
3097 * @see IClasspathEntry#getExclusionPatterns
3098 * @see IClasspathEntry#getOutputLocation()
3102 public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns, IPath specificOutputLocation) {
3104 if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3105 if (exclusionPatterns == null) Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$
3107 return new ClasspathEntry(
3108 IPackageFragmentRoot.K_SOURCE,
3109 IClasspathEntry.CPE_SOURCE,
3112 null, // source attachment
3113 null, // source attachment root
3114 specificOutputLocation, // custom output location
3119 * Creates and returns a new non-exported classpath entry of kind <code>CPE_VARIABLE</code>
3120 * for the given path. The first segment of the path is the name of a classpath variable.
3121 * The trailing segments of the path will be appended to resolved variable path.
3123 * A variable entry allows to express indirect references on a classpath to other projects or libraries,
3124 * depending on what the classpath variable is referring.
3126 * It is possible to register an automatic initializer (<code>ClasspathVariableInitializer</code>),
3127 * which will be invoked through the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
3128 * After resolution, a classpath variable entry may either correspond to a project or a library entry. </li>
3130 * e.g. Here are some examples of variable path usage<ul>
3131 * <li> "JDTCORE" where variable <code>JDTCORE</code> is
3132 * bound to "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the library "c:\jars\jdtcore.jar"</li>
3133 * <li> "JDTCORE" where variable <code>JDTCORE</code> is
3134 * bound to "/Project_JDTCORE". The resolved classpath entry is denoting the project "/Project_JDTCORE"</li>
3135 * <li> "PLUGINS/com.example/example.jar" where variable <code>PLUGINS</code>
3136 * is bound to "c:/eclipse/plugins". The resolved classpath entry is denoting the library "c:/eclipse/plugins/com.example/example.jar"</li>
3138 * Note that this operation does not attempt to validate classpath variables
3139 * or access the resources at the given paths.
3141 * The resulting entry is not exported to dependent projects. This method is equivalent to
3142 * <code>newVariableEntry(-,-,-,false)</code>.
3145 * @param variablePath the path of the binary archive; first segment is the
3146 * name of a classpath variable
3147 * @param variableSourceAttachmentPath the path of the corresponding source archive,
3148 * or <code>null</code> if none; if present, the first segment is the
3149 * name of a classpath variable (not necessarily the same variable
3150 * as the one that begins <code>variablePath</code>)
3151 * @param sourceAttachmentRootPath the location of the root within the source archive
3152 * or <code>null</code> if <code>archivePath</code> is also <code>null</code>
3153 * @return a new library classpath entry
3155 * @see JavaCore#newVariableEntry(IPath, IPath, IPath, boolean)
3157 //public static IClasspathEntry newVariableEntry(
3158 // IPath variablePath,
3159 // IPath variableSourceAttachmentPath,
3160 // IPath sourceAttachmentRootPath) {
3162 // return newVariableEntry(variablePath, variableSourceAttachmentPath, sourceAttachmentRootPath, false);
3166 * Creates and returns a new non-exported classpath entry of kind <code>CPE_VARIABLE</code>
3167 * for the given path. The first segment of the path is the name of a classpath variable.
3168 * The trailing segments of the path will be appended to resolved variable path.
3170 * A variable entry allows to express indirect references on a classpath to other projects or libraries,
3171 * depending on what the classpath variable is referring.
3173 * It is possible to register an automatic initializer (<code>ClasspathVariableInitializer</code>),
3174 * which will be invoked through the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
3175 * After resolution, a classpath variable entry may either correspond to a project or a library entry. </li>
3177 * e.g. Here are some examples of variable path usage<ul>
3178 * <li> "JDTCORE" where variable <code>JDTCORE</code> is
3179 * bound to "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the library "c:\jars\jdtcore.jar"</li>
3180 * <li> "JDTCORE" where variable <code>JDTCORE</code> is
3181 * bound to "/Project_JDTCORE". The resolved classpath entry is denoting the project "/Project_JDTCORE"</li>
3182 * <li> "PLUGINS/com.example/example.jar" where variable <code>PLUGINS</code>
3183 * is bound to "c:/eclipse/plugins". The resolved classpath entry is denoting the library "c:/eclipse/plugins/com.example/example.jar"</li>
3185 * Note that this operation does not attempt to validate classpath variables
3186 * or access the resources at the given paths.
3189 * @param variablePath the path of the binary archive; first segment is the
3190 * name of a classpath variable
3191 * @param variableSourceAttachmentPath the path of the corresponding source archive,
3192 * or <code>null</code> if none; if present, the first segment is the
3193 * name of a classpath variable (not necessarily the same variable
3194 * as the one that begins <code>variablePath</code>)
3195 * @param sourceAttachmentRootPath the location of the root within the source archive
3196 * or <code>null</code> if <code>archivePath</code> is also <code>null</code>
3197 * @param isExported indicates whether this entry is contributed to dependent
3198 * projects in addition to the output location
3199 * @return a new variable classpath entry
3202 //public static IClasspathEntry newVariableEntry(
3203 // IPath variablePath,
3204 // IPath variableSourceAttachmentPath,
3205 // IPath variableSourceAttachmentRootPath,
3206 // boolean isExported) {
3208 // if (variablePath == null || variablePath.segmentCount() < 1) {
3211 // "Illegal classpath variable path: \'" + variablePath.makeRelative().toString() + "\', must have at least one segment"); //$NON-NLS-1$//$NON-NLS-2$
3214 // return new ClasspathEntry(
3215 // IPackageFragmentRoot.K_SOURCE,
3216 // IClasspathEntry.CPE_VARIABLE,
3218 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3219 // variableSourceAttachmentPath, // source attachment
3220 // variableSourceAttachmentRootPath, // source attachment root
3221 // null, // specific output folder
3226 * Removed the given classpath variable. Does nothing if no value was
3227 * set for this classpath variable.
3229 * This functionality cannot be used while the resource tree is locked.
3231 * Classpath variable values are persisted locally to the workspace, and
3232 * are preserved from session to session.
3235 * @param variableName the name of the classpath variable
3236 * @see #setClasspathVariable
3238 * @deprecated - use version with extra IProgressMonitor
3240 //public static void removeClasspathVariable(String variableName) {
3241 // removeClasspathVariable(variableName, null);
3245 * Removed the given classpath variable. Does nothing if no value was
3246 * set for this classpath variable.
3248 * This functionality cannot be used while the resource tree is locked.
3250 * Classpath variable values are persisted locally to the workspace, and
3251 * are preserved from session to session.
3254 * @param variableName the name of the classpath variable
3255 * @param monitor the progress monitor to report progress
3256 * @see #setClasspathVariable
3258 //public static void removeClasspathVariable(
3259 // String variableName,
3260 // IProgressMonitor monitor) {
3263 // updateVariableValues(new String[]{ variableName}, new IPath[]{ null }, monitor);
3264 // } catch (JavaModelException e) {
3269 * Removes the given element changed listener.
3270 * Has no affect if an identical listener is not registered.
3272 * @param listener the listener
3274 public static void removeElementChangedListener(IElementChangedListener listener) {
3275 JavaModelManager.getJavaModelManager().removeElementChangedListener(listener);
3279 * Bind a container reference path to some actual containers (<code>IClasspathContainer</code>).
3280 * This API must be invoked whenever changes in container need to be reflected onto the JavaModel.
3281 * Containers can have distinct values in different projects, therefore this API considers a
3282 * set of projects with their respective containers.
3284 * <code>containerPath</code> is the path under which these values can be referenced through
3285 * container classpath entries (<code>IClasspathEntry#CPE_CONTAINER</code>). A container path
3286 * is formed by a first ID segment followed with extra segments, which can be used as additional hints
3287 * for the resolution. The container ID is used to identify a <code>ClasspathContainerInitializer</code>
3288 * registered on the extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3290 * There is no assumption that each individual container value passed in argument
3291 * (<code>respectiveContainers</code>) must answer the exact same path when requested
3292 * <code>IClasspathContainer#getPath</code>.
3293 * Indeed, the containerPath is just an indication for resolving it to an actual container object. It can be
3294 * delegated to a <code>ClasspathContainerInitializer</code>, which can be activated through the extension
3295 * point "org.eclipse.jdt.core.ClasspathContainerInitializer").
3297 * In reaction to changing container values, the JavaModel will be updated to reflect the new
3298 * state of the updated container.
3300 * This functionality cannot be used while the resource tree is locked.
3302 * Classpath container values are persisted locally to the workspace, but
3303 * are not preserved from a session to another. It is thus highly recommended to register a
3304 * <code>ClasspathContainerInitializer</code> for each referenced container
3305 * (through the extension point "org.eclipse.jdt.core.ClasspathContainerInitializer").
3307 * Note: setting a container to <code>null</code> will cause it to be lazily resolved again whenever
3308 * its value is required. In particular, this will cause a registered initializer to be invoked
3311 * @param containerPath - the name of the container reference, which is being updated
3312 * @param affectedProjects - the set of projects for which this container is being bound
3313 * @param respectiveContainers - the set of respective containers for the affected projects
3314 * @param monitor a monitor to report progress
3316 * @see ClasspathContainerInitializer
3317 * @see #getClasspathContainer(IPath, IJavaProject)
3318 * @see IClasspathContainer
3321 //public static void setClasspathContainer(final IPath containerPath, IJavaProject[] affectedProjects, IClasspathContainer[] respectiveContainers, IProgressMonitor monitor) throws JavaModelException {
3323 // if (affectedProjects.length != respectiveContainers.length) Assert.isTrue(false, "Projects and containers collections should have the same size"); //$NON-NLS-1$
3325 // if (monitor != null && monitor.isCanceled()) return;
3327 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3328 // System.out.println("CPContainer SET - setting container: ["+containerPath+"] for projects: {" //$NON-NLS-1$ //$NON-NLS-2$
3329 // + (Util.toString(affectedProjects,
3330 // new Util.Displayable(){
3331 // public String displayString(Object o) { return ((IJavaProject) o).getElementName(); }
3333 // + "} with values: " //$NON-NLS-1$
3334 // + (Util.toString(respectiveContainers,
3335 // new Util.Displayable(){
3336 // public String displayString(Object o) { return ((IClasspathContainer) o).getDescription(); }
3341 // final int projectLength = affectedProjects.length;
3342 // final IJavaProject[] modifiedProjects;
3343 // System.arraycopy(affectedProjects, 0, modifiedProjects = new IJavaProject[projectLength], 0, projectLength);
3344 // final IClasspathEntry[][] oldResolvedPaths = new IClasspathEntry[projectLength][];
3346 // // filter out unmodified project containers
3347 // int remaining = 0;
3348 // for (int i = 0; i < projectLength; i++){
3350 // if (monitor != null && monitor.isCanceled()) return;
3352 // IJavaProject affectedProject = affectedProjects[i];
3353 // IClasspathContainer newContainer = respectiveContainers[i];
3354 // if (newContainer == null) newContainer = JavaModelManager.ContainerInitializationInProgress; // 30920 - prevent infinite loop
3355 // boolean found = false;
3356 // if (JavaProject.hasJavaNature(affectedProject.getProject())){
3357 // IClasspathEntry[] rawClasspath = affectedProject.getRawClasspath();
3358 // for (int j = 0, cpLength = rawClasspath.length; j <cpLength; j++) {
3359 // IClasspathEntry entry = rawClasspath[j];
3360 // if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER && entry.getPath().equals(containerPath)){
3367 // modifiedProjects[i] = null; // filter out this project - does not reference the container path, or isnt't yet Java project
3368 // JavaModelManager.containerPut(affectedProject, containerPath, newContainer);
3371 // IClasspathContainer oldContainer = JavaModelManager.containerGet(affectedProject, containerPath);
3372 // if (oldContainer == JavaModelManager.ContainerInitializationInProgress) {
3373 // Map previousContainerValues = (Map)JavaModelManager.PreviousSessionContainers.get(affectedProject);
3374 // if (previousContainerValues != null){
3375 // IClasspathContainer previousContainer = (IClasspathContainer)previousContainerValues.get(containerPath);
3376 // if (previousContainer != null) {
3377 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3378 // System.out.println("CPContainer INIT - reentering access to project container: ["+affectedProject.getElementName()+"] " + containerPath + " during its initialization, will see previous value: "+ previousContainer.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
3380 // JavaModelManager.containerPut(affectedProject, containerPath, previousContainer);
3382 // oldContainer = null; //33695 - cannot filter out restored container, must update affected project to reset cached CP
3384 // oldContainer = null;
3387 // if (oldContainer != null && oldContainer.equals(respectiveContainers[i])){// TODO: could improve to only compare entries
3388 // modifiedProjects[i] = null; // filter out this project - container did not change
3392 // oldResolvedPaths[i] = affectedProject.getResolvedClasspath(true);
3393 // JavaModelManager.containerPut(affectedProject, containerPath, newContainer);
3396 // if (remaining == 0) return;
3398 // // trigger model refresh
3400 // JavaCore.run(new IWorkspaceRunnable() {
3401 // public void run(IProgressMonitor monitor) throws CoreException {
3402 // for(int i = 0; i < projectLength; i++){
3404 // if (monitor != null && monitor.isCanceled()) return;
3406 // JavaProject affectedProject = (JavaProject)modifiedProjects[i];
3407 // if (affectedProject == null) continue; // was filtered out
3409 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3410 // System.out.println("CPContainer SET - updating affected project: ["+affectedProject.getElementName()+"] due to setting container: " + containerPath); //$NON-NLS-1$ //$NON-NLS-2$
3413 // // force a refresh of the affected project (will compute deltas)
3414 // affectedProject.setRawClasspath(
3415 // affectedProject.getRawClasspath(),
3416 // SetClasspathOperation.ReuseOutputLocation,
3418 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can save resources
3419 // oldResolvedPaths[i],
3420 // false, // updating - no validation
3421 // false); // updating - no need to save
3426 // } catch(CoreException e) {
3427 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3428 // System.out.println("CPContainer SET - FAILED DUE TO EXCEPTION: "+containerPath); //$NON-NLS-1$
3429 // e.printStackTrace();
3431 // if (e instanceof JavaModelException) {
3432 // throw (JavaModelException)e;
3434 // throw new JavaModelException(e);
3437 // for (int i = 0; i < projectLength; i++) {
3438 // if (respectiveContainers[i] == null) {
3439 // JavaModelManager.containerPut(affectedProjects[i], containerPath, null); // reset init in progress marker
3447 * Sets the value of the given classpath variable.
3448 * The path must have at least one segment.
3450 * This functionality cannot be used while the resource tree is locked.
3452 * Classpath variable values are persisted locally to the workspace, and
3453 * are preserved from session to session.
3456 * @param variableName the name of the classpath variable
3457 * @param path the path
3458 * @see #getClasspathVariable
3460 * @deprecated - use API with IProgressMonitor
3462 //public static void setClasspathVariable(String variableName, IPath path)
3463 // throws JavaModelException {
3465 // setClasspathVariable(variableName, path, null);
3469 * Sets the value of the given classpath variable.
3470 * The path must not be null.
3472 * This functionality cannot be used while the resource tree is locked.
3474 * Classpath variable values are persisted locally to the workspace, and
3475 * are preserved from session to session.
3477 * Updating a variable with the same value has no effect.
3479 * @param variableName the name of the classpath variable
3480 * @param path the path
3481 * @param monitor a monitor to report progress
3482 * @see #getClasspathVariable
3484 //public static void setClasspathVariable(
3485 // String variableName,
3487 // IProgressMonitor monitor)
3488 // throws JavaModelException {
3490 // if (path == null) Assert.isTrue(false, "Variable path cannot be null"); //$NON-NLS-1$
3491 // setClasspathVariables(new String[]{variableName}, new IPath[]{ path }, monitor);
3495 * Sets the values of all the given classpath variables at once.
3496 * Null paths can be used to request corresponding variable removal.
3498 * This functionality cannot be used while the resource tree is locked.
3500 * Classpath variable values are persisted locally to the workspace, and
3501 * are preserved from session to session.
3503 * Updating a variable with the same value has no effect.
3505 * @param variableNames an array of names for the updated classpath variables
3506 * @param paths an array of path updates for the modified classpath variables (null
3507 * meaning that the corresponding value will be removed
3508 * @param monitor a monitor to report progress
3509 * @see #getClasspathVariable
3512 //public static void setClasspathVariables(
3513 // String[] variableNames,
3515 // IProgressMonitor monitor)
3516 // throws JavaModelException {
3518 // if (variableNames.length != paths.length) Assert.isTrue(false, "Variable names and paths collections should have the same size"); //$NON-NLS-1$
3519 // //TODO: should check that null cannot be used as variable paths
3520 // updateVariableValues(variableNames, paths, monitor);
3524 * Method declared on IExecutableExtension.
3525 * Record any necessary initialization data from the plugin.
3527 public void setInitializationData(
3528 IConfigurationElement cfig,
3529 String propertyName,
3531 throws CoreException {
3535 * Sets the current table of options. All and only the options explicitly included in the given table
3536 * are remembered; all previous option settings are forgotten, including ones not explicitly
3539 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
3542 * @param newOptions the new options (key type: <code>String</code>; value type: <code>String</code>),
3543 * or <code>null</code> to reset all options to their default values
3544 * @see JavaCore#getDefaultOptions
3546 public static void setOptions(Hashtable newOptions) {
3548 // see #initializeDefaultPluginPreferences() for changing default settings
3549 Preferences preferences = getPlugin().getPluginPreferences();
3551 if (newOptions == null){
3552 newOptions = JavaCore.getDefaultOptions();
3554 Enumeration keys = newOptions.keys();
3555 while (keys.hasMoreElements()){
3556 String key = (String)keys.nextElement();
3557 if (!JavaModelManager.OptionNames.contains(key)) continue; // unrecognized option
3558 if (key.equals(CORE_ENCODING)) continue; // skipped, contributed by resource prefs
3559 String value = (String)newOptions.get(key);
3560 preferences.setValue(key, value);
3564 getPlugin().savePluginPreferences();
3568 * Shutdown the JavaCore plug-in.
3570 * De-registers the JavaModelManager as a resource changed listener and save participant.
3572 * @see org.eclipse.core.runtime.Plugin#shutdown()
3574 // moved to PHPeclipsePlugin#shutdown()
3575 //public void shutdown() {
3577 // //savePluginPreferences();
3578 // getPlugin().savePluginPreferences();
3579 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
3580 // workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaProcessor);
3581 // workspace.removeSaveParticipant(PHPeclipsePlugin.getDefault());
3583 // ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown();
3587 * Initiate the background indexing process.
3588 * This should be deferred after the plugin activation.
3590 //private void startIndexing() {
3592 // JavaModelManager.getJavaModelManager().getIndexManager().reset();
3596 * Startup of the JavaCore plug-in.
3598 * Registers the JavaModelManager as a resource changed listener and save participant.
3599 * Starts the background indexing, and restore saved classpath variable values.
3601 * @see org.eclipse.core.runtime.Plugin#startup()
3604 // moved to PHPeclipsePlugin#startup()
3605 //public void startup() {
3607 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
3609 // manager.configurePluginDebugOptions();
3611 // // request state folder creation (workaround 19885)
3612 // JavaCore.getPlugin().getStateLocation();
3614 // // retrieve variable values
3615 // JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new JavaModelManager.PluginPreferencesListener());
3616 //// TODO khartlage temp-del
3617 //// manager.loadVariablesAndContainers();
3619 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
3620 // workspace.addResourceChangeListener(
3621 // manager.deltaProcessor,
3622 // IResourceChangeEvent.PRE_AUTO_BUILD
3623 // | IResourceChangeEvent.POST_AUTO_BUILD
3624 // | IResourceChangeEvent.POST_CHANGE
3625 // | IResourceChangeEvent.PRE_DELETE
3626 // | IResourceChangeEvent.PRE_CLOSE);
3628 //// startIndexing();
3629 // workspace.addSaveParticipant(PHPeclipsePlugin.getDefault(), manager);
3631 // } catch (CoreException e) {
3632 // } catch (RuntimeException e) {
3633 // manager.shutdown();
3640 * Internal updating of a variable values (null path meaning removal), allowing to change multiple variable values at once.
3642 //private static void updateVariableValues(
3643 // String[] variableNames,
3644 // IPath[] variablePaths,
3645 // IProgressMonitor monitor) throws JavaModelException {
3647 // if (monitor != null && monitor.isCanceled()) return;
3649 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3650 // System.out.println("CPVariable SET - setting variables: {" + Util.toString(variableNames) //$NON-NLS-1$
3651 // + "} with values: " + Util.toString(variablePaths)); //$NON-NLS-1$
3654 // int varLength = variableNames.length;
3656 // // gather classpath information for updating
3657 // final HashMap affectedProjects = new HashMap(5);
3658 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
3659 // IJavaModel model = manager.getJavaModel();
3661 // // filter out unmodified variables
3662 // int discardCount = 0;
3663 // for (int i = 0; i < varLength; i++){
3664 // String variableName = variableNames[i];
3665 // IPath oldPath = (IPath)JavaModelManager.variableGet(variableName); // if reentering will provide previous session value
3666 // if (oldPath == JavaModelManager.VariableInitializationInProgress){
3667 // IPath previousPath = (IPath)JavaModelManager.PreviousSessionVariables.get(variableName);
3668 // if (previousPath != null){
3669 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3670 // System.out.println("CPVariable INIT - reentering access to variable: " + variableName+ " during its initialization, will see previous value: "+ previousPath); //$NON-NLS-1$ //$NON-NLS-2$
3672 // JavaModelManager.variablePut(variableName, previousPath); // replace value so reentering calls are seeing old value
3674 // oldPath = null; //33695 - cannot filter out restored variable, must update affected project to reset cached CP
3676 // if (oldPath != null && oldPath.equals(variablePaths[i])){
3677 // variableNames[i] = null;
3681 // if (discardCount > 0){
3682 // if (discardCount == varLength) return;
3683 // int changedLength = varLength - discardCount;
3684 // String[] changedVariableNames = new String[changedLength];
3685 // IPath[] changedVariablePaths = new IPath[changedLength];
3686 // for (int i = 0, index = 0; i < varLength; i++){
3687 // if (variableNames[i] != null){
3688 // changedVariableNames[index] = variableNames[i];
3689 // changedVariablePaths[index] = variablePaths[i];
3693 // variableNames = changedVariableNames;
3694 // variablePaths = changedVariablePaths;
3695 // varLength = changedLength;
3698 // if (monitor != null && monitor.isCanceled()) return;
3700 // if (model != null) {
3701 // IJavaProject[] projects = model.getJavaProjects();
3702 // nextProject : for (int i = 0, projectLength = projects.length; i < projectLength; i++){
3703 // IJavaProject project = projects[i];
3705 // // check to see if any of the modified variables is present on the classpath
3706 // IClasspathEntry[] classpath = project.getRawClasspath();
3707 // for (int j = 0, cpLength = classpath.length; j < cpLength; j++){
3709 // IClasspathEntry entry = classpath[j];
3710 // for (int k = 0; k < varLength; k++){
3712 // String variableName = variableNames[k];
3713 // if (entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE){
3715 // if (variableName.equals(entry.getPath().segment(0))){
3716 // affectedProjects.put(project, project.getResolvedClasspath(true));
3717 // continue nextProject;
3719 // IPath sourcePath, sourceRootPath;
3720 // if (((sourcePath = entry.getSourceAttachmentPath()) != null && variableName.equals(sourcePath.segment(0)))
3721 // || ((sourceRootPath = entry.getSourceAttachmentRootPath()) != null && variableName.equals(sourceRootPath.segment(0)))) {
3723 // affectedProjects.put(project, project.getResolvedClasspath(true));
3724 // continue nextProject;
3731 // // update variables
3732 // for (int i = 0; i < varLength; i++){
3733 // JavaModelManager.variablePut(variableNames[i], variablePaths[i]);
3735 // final String[] dbgVariableNames = variableNames;
3737 // // update affected project classpaths
3738 // if (!affectedProjects.isEmpty()) {
3740 // JavaCore_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt.run(
3741 // new IWorkspaceRunnable() {
3742 // public void run(IProgressMonitor monitor) throws CoreException {
3743 // // propagate classpath change
3744 // Iterator projectsToUpdate = affectedProjects.keySet().iterator();
3745 // while (projectsToUpdate.hasNext()) {
3747 // if (monitor != null && monitor.isCanceled()) return;
3749 // JavaProject project = (JavaProject) projectsToUpdate.next();
3751 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3752 // System.out.println("CPVariable SET - updating affected project: ["+project.getElementName()+"] due to setting variables: "+ Util.toString(dbgVariableNames)); //$NON-NLS-1$ //$NON-NLS-2$
3756 // .setRawClasspath(
3757 // project.getRawClasspath(),
3758 // SetClasspathOperation.ReuseOutputLocation,
3759 // null, // don't call beginTask on the monitor (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=3717)
3760 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can change resources
3761 // (IClasspathEntry[]) affectedProjects.get(project),
3762 // false, // updating - no validation
3763 // false); // updating - no need to save
3768 // } catch (CoreException e) {
3769 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3770 // System.out.println("CPVariable SET - FAILED DUE TO EXCEPTION: "+Util.toString(dbgVariableNames)); //$NON-NLS-1$
3771 // e.printStackTrace();
3773 // if (e instanceof JavaModelException) {
3774 // throw (JavaModelException)e;
3776 // throw new JavaModelException(e);