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>"org.phpeclipse.phpdt.core"</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$
219 * Possible configurable option ID.
220 * @see #getDefaultOptions
222 public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID + ".compiler.problem.unreachableCode"; //$NON-NLS-1$
224 * Possible configurable option ID.
225 * @see #getDefaultOptions
227 public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID + ".compiler.problem.invalidImport"; //$NON-NLS-1$
229 * Possible configurable option ID.
230 * @see #getDefaultOptions
232 public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID + ".compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
234 * Possible configurable option ID.
235 * @see #getDefaultOptions
237 public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID + ".compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
239 * Possible configurable option ID.
240 * @see #getDefaultOptions
242 public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID + ".compiler.problem.deprecation"; //$NON-NLS-1$
244 * Possible configurable option ID.
245 * @see #getDefaultOptions
248 public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID + ".compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
250 * Possible configurable option ID.
251 * @see #getDefaultOptions
253 public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID + ".compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
255 * Possible configurable option ID.
256 * @see #getDefaultOptions
258 public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID + ".compiler.problem.unusedLocal"; //$NON-NLS-1$
260 * Possible configurable option ID.
261 * @see #getDefaultOptions
263 public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID + ".compiler.problem.unusedParameter"; //$NON-NLS-1$
265 * Possible configurable option ID.
266 * @see #getDefaultOptions
269 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID + ".compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
271 * Possible configurable option ID.
272 * @see #getDefaultOptions
275 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID + ".compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
277 * Possible configurable option ID.
278 * @see #getDefaultOptions
281 public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID + ".compiler.problem.unusedImport"; //$NON-NLS-1$
283 * Possible configurable option ID.
284 * @see #getDefaultOptions
286 public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID + ".compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
288 * Possible configurable option ID.
289 * @see #getDefaultOptions
292 public static final String COMPILER_PB_NON_NLS_STRING_LITERAL = PLUGIN_ID + ".compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
294 * Possible configurable option ID.
295 * @see #getDefaultOptions
298 public static final String COMPILER_PB_ASSERT_IDENTIFIER = PLUGIN_ID + ".compiler.problem.assertIdentifier"; //$NON-NLS-1$
300 * Possible configurable option ID.
301 * @see #getDefaultOptions
304 public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID + ".compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
306 * Possible configurable option ID.
307 * @see #getDefaultOptions
310 public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID + ".compiler.problem.noEffectAssignment"; //$NON-NLS-1$
312 * Possible configurable option ID.
313 * @see #getDefaultOptions
316 public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
318 * Possible configurable option ID.
319 * @see #getDefaultOptions
322 public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
324 * Possible configurable option ID.
325 * @see #getDefaultOptions
328 public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
330 * Possible configurable option ID.
331 * @see #getDefaultOptions
334 public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID + ".compiler.maxProblemPerUnit"; //$NON-NLS-1$
336 * Possible configurable option ID.
337 * @see #getDefaultOptions
340 public static final String COMPILER_SOURCE = PLUGIN_ID + ".compiler.source"; //$NON-NLS-1$
342 * Possible configurable option ID.
343 * @see #getDefaultOptions
346 public static final String COMPILER_COMPLIANCE = PLUGIN_ID + ".compiler.compliance"; //$NON-NLS-1$
348 * Possible configurable option ID.
349 * @see #getDefaultOptions
352 public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID + ".compiler.taskPriorities"; //$NON-NLS-1$
354 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
355 * @see #getDefaultOptions
358 public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$
360 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
361 * @see #getDefaultOptions
364 public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$
366 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
367 * @see #getDefaultOptions
370 public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$
372 * Possible configurable option ID.
373 * @see #getDefaultOptions
375 public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder"; //$NON-NLS-1$
377 * Possible configurable option ID.
378 * @see #getDefaultOptions
381 public static final String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER = PLUGIN_ID + ".builder.resourceCopyExclusionFilter"; //$NON-NLS-1$
383 * Possible configurable option ID.
384 * @see #getDefaultOptions
387 public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID + ".builder.duplicateResourceTask"; //$NON-NLS-1$
389 * Possible configurable option ID.
390 * @see #getDefaultOptions
393 public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID + ".builder.cleanOutputFolder"; //$NON-NLS-1$
395 * Possible configurable option ID.
396 * @see #getDefaultOptions
399 public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID + ".incompleteClasspath"; //$NON-NLS-1$
401 * Possible configurable option ID.
402 * @see #getDefaultOptions
405 public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID + ".circularClasspath"; //$NON-NLS-1$
407 * Possible configurable option ID.
408 * @see #getDefaultOptions
411 public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID + ".builder.invalidClasspath"; //$NON-NLS-1$
413 * Possible configurable option ID.
414 * @see #getDefaultOptions
417 public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID + ".classpath.exclusionPatterns"; //$NON-NLS-1$
419 * Possible configurable option ID.
420 * @see #getDefaultOptions
423 public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID + ".classpath.multipleOutputLocations"; //$NON-NLS-1$
428 public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$
430 * Default task priority
433 public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; //$NON-NLS-1$
435 * Possible configurable option ID
436 * @see #getDefaultOptions
439 public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID + ".formatter.space.castexpression"; //$NON-NLS-1$
441 * Possible configurable option ID.
442 * @see #getDefaultOptions
445 public static final String CODEASSIST_VISIBILITY_CHECK = PLUGIN_ID + ".codeComplete.visibilityCheck"; //$NON-NLS-1$
447 * Possible configurable option ID.
448 * @see #getDefaultOptions
451 public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID + ".codeComplete.forceImplicitQualification"; //$NON-NLS-1$
453 * Possible configurable option ID.
454 * @see #getDefaultOptions
457 public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.fieldPrefixes"; //$NON-NLS-1$
459 * Possible configurable option ID.
460 * @see #getDefaultOptions
463 public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
465 * Possible configurable option ID.
466 * @see #getDefaultOptions
469 public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID + ".codeComplete.localPrefixes"; //$NON-NLS-1$
471 * Possible configurable option ID.
472 * @see #getDefaultOptions
475 public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID + ".codeComplete.argumentPrefixes"; //$NON-NLS-1$
477 * Possible configurable option ID.
478 * @see #getDefaultOptions
481 public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.fieldSuffixes"; //$NON-NLS-1$
483 * Possible configurable option ID.
484 * @see #getDefaultOptions
487 public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
489 * Possible configurable option ID.
490 * @see #getDefaultOptions
493 public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID + ".codeComplete.localSuffixes"; //$NON-NLS-1$
495 * Possible configurable option ID.
496 * @see #getDefaultOptions
499 public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID + ".codeComplete.argumentSuffixes"; //$NON-NLS-1$
501 // *************** Possible values for configurable options. ********************
504 * Possible configurable option value.
505 * @see #getDefaultOptions
507 public static final String GENERATE = "generate"; //$NON-NLS-1$
509 * Possible configurable option value.
510 * @see #getDefaultOptions
512 public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
514 * Possible configurable option value.
515 * @see #getDefaultOptions
517 public static final String PRESERVE = "preserve"; //$NON-NLS-1$
519 * Possible configurable option value.
520 * @see #getDefaultOptions
522 public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
524 * Possible configurable option value.
525 * @see #getDefaultOptions
527 public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$
529 * Possible configurable option value.
530 * @see #getDefaultOptions
532 public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$
534 * Possible configurable option value.
535 * @see #getDefaultOptions
538 public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
540 * Possible configurable option value.
541 * @see #getDefaultOptions
544 public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
546 * Possible configurable option value.
547 * @see #getDefaultOptions
550 public static final String ABORT = "abort"; //$NON-NLS-1$
552 * Possible configurable option value.
553 * @see #getDefaultOptions
555 public static final String ERROR = "error"; //$NON-NLS-1$
557 * Possible configurable option value.
558 * @see #getDefaultOptions
560 public static final String WARNING = "warning"; //$NON-NLS-1$
562 * Possible configurable option value.
563 * @see #getDefaultOptions
565 public static final String IGNORE = "ignore"; //$NON-NLS-1$
567 * Possible configurable option value.
568 * @see #getDefaultOptions
570 public static final String COMPUTE = "compute"; //$NON-NLS-1$
572 * Possible configurable option value.
573 * @see #getDefaultOptions
579 * Returns a table of all known configurable options with their default values.
580 * These options allow to configure the behaviour of the underlying components.
581 * The client may safely use the result as a template that they can modify and
582 * then pass to <code>setOptions</code>.
584 * Helper constants have been defined on JavaCore for each of the option ID and
585 * their possible constant values.
587 * Note: more options might be added in further releases.
589 * RECOGNIZED OPTIONS:
590 * COMPILER / Generating Local Variable Debug Attribute
591 * When generated, this attribute will enable local variable names
592 * to be displayed in debugger, only in place where variables are
593 * definitely assigned (.class file is then bigger)
594 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.localVariable"
595 * - possible values: { "generate", "do not generate" }
596 * - default: "generate"
598 * COMPILER / Generating Line Number Debug Attribute
599 * When generated, this attribute will enable source code highlighting in debugger
600 * (.class file is then bigger).
601 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.lineNumber"
602 * - possible values: { "generate", "do not generate" }
603 * - default: "generate"
605 * COMPILER / Generating Source Debug Attribute
606 * When generated, this attribute will enable the debugger to present the
607 * corresponding source code.
608 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.sourceFile"
609 * - possible values: { "generate", "do not generate" }
610 * - default: "generate"
612 * COMPILER / Preserving Unused Local Variables
613 * Unless requested to preserve unused local variables (i.e. never read), the
614 * compiler will optimize them out, potentially altering debugging
615 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.unusedLocal"
616 * - possible values: { "preserve", "optimize out" }
617 * - default: "preserve"
619 * COMPILER / Defining Target Java Platform
620 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
621 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
622 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.targetPlatform"
623 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
626 * COMPILER / Reporting Unreachable Code
627 * Unreachable code can optionally be reported as an error, warning or simply
628 * ignored. The bytecode generation will always optimized it out.
629 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unreachableCode"
630 * - possible values: { "error", "warning", "ignore" }
633 * COMPILER / Reporting Invalid Import
634 * An import statement that cannot be resolved might optionally be reported
635 * as an error, as a warning or ignored.
636 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.invalidImport"
637 * - possible values: { "error", "warning", "ignore" }
640 * COMPILER / Reporting Attempt to Override Package-Default Method
641 * A package default method is not visible in a different package, and thus
642 * cannot be overridden. When enabling this option, the compiler will signal
643 * such scenarii either as an error or a warning.
644 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
645 * - possible values: { "error", "warning", "ignore" }
646 * - default: "warning"
648 * COMPILER / Reporting Method With Constructor Name
649 * Naming a method with a constructor name is generally considered poor
650 * style programming. When enabling this option, the compiler will signal such
651 * scenarii either as an error or a warning.
652 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.methodWithConstructorName"
653 * - possible values: { "error", "warning", "ignore" }
654 * - default: "warning"
656 * COMPILER / Reporting Deprecation
657 * When enabled, the compiler will signal use of deprecated API either as an
658 * error or a warning.
659 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecation"
660 * - possible values: { "error", "warning", "ignore" }
661 * - default: "warning"
663 * COMPILER / Reporting Deprecation Inside Deprecated Code
664 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
665 * The severity of the problem is controlled with option "org.phpeclipse.phpdt.core.compiler.problem.deprecation".
666 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
667 * - possible values: { "enabled", "disabled" }
668 * - default: "disabled"
670 * COMPILER / Reporting Hidden Catch Block
671 * Locally to a try statement, some catch blocks may hide others , e.g.
672 * try { throw new java.io.CharConversionException();
673 * } catch (java.io.CharConversionException e) {
674 * } catch (java.io.IOException e) {}.
675 * When enabling this option, the compiler will issue an error or a warning for hidden
676 * catch blocks corresponding to checked exceptions
677 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.hiddenCatchBlock"
678 * - possible values: { "error", "warning", "ignore" }
679 * - default: "warning"
681 * COMPILER / Reporting Unused Local
682 * When enabled, the compiler will issue an error or a warning for unused local
683 * variables (i.e. variables never read from)
684 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedLocal"
685 * - possible values: { "error", "warning", "ignore" }
686 * - default: "ignore"
688 * COMPILER / Reporting Unused Parameter
689 * When enabled, the compiler will issue an error or a warning for unused method
690 * parameters (i.e. parameters never read from)
691 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedParameter"
692 * - possible values: { "error", "warning", "ignore" }
693 * - default: "ignore"
695 * COMPILER / Reporting Unused Import
696 * When enabled, the compiler will issue an error or a warning for unused import
698 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedImport"
699 * - possible values: { "error", "warning", "ignore" }
700 * - default: "warning"
702 * COMPILER / Reporting Synthetic Access Emulation
703 * When enabled, the compiler will issue an error or a warning whenever it emulates
704 * access to a non-accessible member of an enclosing type. Such access can have
705 * performance implications.
706 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.syntheticAccessEmulation"
707 * - possible values: { "error", "warning", "ignore" }
708 * - default: "ignore"
710 * COMPILER / Reporting Non-Externalized String Literal
711 * When enabled, the compiler will issue an error or a warning for non externalized
712 * String literal (i.e. non tagged with //$NON-NLS-<n>$).
713 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
714 * - possible values: { "error", "warning", "ignore" }
715 * - default: "ignore"
717 * COMPILER / Reporting Usage of 'assert' Identifier
718 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
719 * used as an identifier (reserved keyword in 1.4)
720 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.assertIdentifier"
721 * - possible values: { "error", "warning", "ignore" }
722 * - default: "ignore"
724 * COMPILER / Reporting Usage of expression receiver on static invocation/field access
725 * When enabled, the compiler will issue an error or a warning whenever a static field
726 * or method is accessed with an expression receiver.
727 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.staticAccessReceiver"
728 * - possible values: { "error", "warning", "ignore" }
729 * - default: "warning"
731 * COMPILER / Reporting Assignment with no effect
732 * When enabled, the compiler will issue an error or a warning whenever an assignment
733 * has no effect (e.g 'x = x').
734 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.noEffectAssignment"
735 * - possible values: { "error", "warning", "ignore" }
736 * - default: "warning"
738 * COMPILER / Setting Source Compatibility Mode
739 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
740 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
741 * level should be set to "1.4" and the compliance mode should be "1.4".
742 * - option id: "org.phpeclipse.phpdt.core.compiler.source"
743 * - possible values: { "1.3", "1.4" }
746 * COMPILER / Setting Compliance Level
747 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
748 * should not go beyond "1.3" level.
749 * - option id: "org.phpeclipse.phpdt.core.compiler.compliance"
750 * - possible values: { "1.3", "1.4" }
753 * COMPILER / Maximum number of problems reported per compilation unit
754 * Specify the maximum number of problems reported on each compilation unit.
755 * - option id: "org.phpeclipse.phpdt.core.compiler.maxProblemPerUnit"
756 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
759 * COMPILER / Define the Automatic Task Tags
760 * When the tag is non empty, the compiler will issue a task marker whenever it encounters
761 * one of the corresponding tag inside any comment in Java source code.
762 * Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed.
763 * - option id: "org.phpeclipse.phpdt.core.compiler.taskTags"
764 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card
766 * COMPILER / Define the Automatic Task Priorities
767 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
768 * of the task markers issued by the compiler.
769 * If the default is specified, the priority of each task marker is "NORMAL".
770 * - option id: "org.phpeclipse.phpdt.core.compiler.taskPriorities"
771 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
774 * BUILDER / Specifying Filters for Resource Copying Control
775 * Allow to specify some filters to control the resource copy process.
776 * - option id: "org.phpeclipse.phpdt.core.builder.resourceCopyExclusionFilter"
777 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
778 * or the name of a folder which ends with '/'
781 * BUILDER / Abort if Invalid Classpath
782 * Allow to toggle the builder to abort if the classpath is invalid
783 * - option id: "org.phpeclipse.phpdt.core.builder.invalidClasspath"
784 * - possible values: { "abort", "ignore" }
785 * - default: "ignore"
787 * BUILDER / Cleaning Output Folder(s)
788 * Indicate whether the JavaBuilder is allowed to clean the output folders
789 * when performing full build operations.
790 * - option id: "org.phpeclipse.phpdt.core.builder.cleanOutputFolder"
791 * - possible values: { "clean", "ignore" }
794 * JAVACORE / Computing Project Build Order
795 * Indicate whether JavaCore should enforce the project build order to be based on
796 * the classpath prerequisite chain. When requesting to compute, this takes over
797 * the platform default order (based on project references).
798 * - option id: "org.phpeclipse.phpdt.core.computeJavaBuildOrder"
799 * - possible values: { "compute", "ignore" }
800 * - default: "ignore"
802 * JAVACORE / Specify Default Source Encoding Format
803 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
804 * to 'ResourcesPlugin.getEncoding()'.
805 * - option id: "org.phpeclipse.phpdt.core.encoding"
806 * - possible values: { any of the supported encoding name}.
807 * - default: <platform default>
809 * JAVACORE / Reporting Incomplete Classpath
810 * An entry on the classpath doesn't exist or is not visible (e.g. a referenced project is closed).
811 * - option id: "org.phpeclipse.phpdt.core.incompleteClasspath"
812 * - possible values: { "error", "warning"}
815 * JAVACORE / Reporting Classpath Cycle
816 * A project is involved in a cycle.
817 * - option id: "org.phpeclipse.phpdt.core.circularClasspath"
818 * - possible values: { "error", "warning" }
821 * FORMATTER / Inserting New Line Before Opening Brace
822 * When Insert, a new line is inserted before an opening brace, otherwise nothing
824 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.openingBrace"
825 * - possible values: { "insert", "do not insert" }
826 * - default: "do not insert"
828 * FORMATTER / Inserting New Line Inside Control Statement
829 * When Insert, a new line is inserted between } and following else, catch, finally
830 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.controlStatement"
831 * - possible values: { "insert", "do not insert" }
832 * - default: "do not insert"
834 * FORMATTER / Clearing Blank Lines
835 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
836 * and all others removed.
837 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.clearAll"
838 * - possible values: { "clear all", "preserve one" }
839 * - default: "preserve one"
841 * FORMATTER / Inserting New Line Between Else/If
842 * When Insert, a blank line is inserted between an else and an if when they are
843 * contiguous. When choosing to not insert, else-if will be kept on the same
844 * line when possible.
845 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.elseIf"
846 * - possible values: { "insert", "do not insert" }
847 * - default: "do not insert"
849 * FORMATTER / Inserting New Line In Empty Block
850 * When insert, a line break is inserted between contiguous { and }, if } is not followed
852 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.emptyBlock"
853 * - possible values: { "insert", "do not insert" }
854 * - default: "insert"
856 * FORMATTER / Splitting Lines Exceeding Length
857 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
858 * disable line splitting
859 * - option id: "org.phpeclipse.phpdt.core.formatter.lineSplit"
860 * - possible values: "<n>", where n is zero or a positive integer
863 * FORMATTER / Compacting Assignment
864 * Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space
865 * is inserted before the assignment operator
866 * - option id: "org.phpeclipse.phpdt.core.formatter.style.assignment"
867 * - possible values: { "compact", "normal" }
868 * - default: "normal"
870 * FORMATTER / Defining Indentation Character
871 * Either choose to indent with tab characters or spaces
872 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.char"
873 * - possible values: { "tab", "space" }
876 * FORMATTER / Defining Space Indentation Length
877 * When using spaces, set the amount of space characters to use for each
879 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.size"
880 * - possible values: "<n>", where n is a positive integer
883 * CODEASSIST / Activate Visibility Sensitive Completion
884 * When active, completion doesn't show that you can not see
885 * (e.g. you can not see private methods of a super class).
886 * - option id: "org.phpeclipse.phpdt.core.codeComplete.visibilityCheck"
887 * - possible values: { "enabled", "disabled" }
888 * - default: "disabled"
890 * CODEASSIST / Automatic Qualification of Implicit Members
891 * When active, completion automatically qualifies completion on implicit
892 * field references and message expressions.
893 * - option id: "org.phpeclipse.phpdt.core.codeComplete.forceImplicitQualification"
894 * - possible values: { "enabled", "disabled" }
895 * - default: "disabled"
897 * CODEASSIST / Define the Prefixes for Field Name
898 * When the prefixes is non empty, completion for field name will begin with
899 * one of the proposed prefixes.
900 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldPrefixes"
901 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
904 * CODEASSIST / Define the Prefixes for Static Field Name
905 * When the prefixes is non empty, completion for static field name will begin with
906 * one of the proposed prefixes.
907 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldPrefixes"
908 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
911 * CODEASSIST / Define the Prefixes for Local Variable Name
912 * When the prefixes is non empty, completion for local variable name will begin with
913 * one of the proposed prefixes.
914 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localPrefixes"
915 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
918 * CODEASSIST / Define the Prefixes for Argument Name
919 * When the prefixes is non empty, completion for argument name will begin with
920 * one of the proposed prefixes.
921 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentPrefixes"
922 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
925 * CODEASSIST / Define the Suffixes for Field Name
926 * When the suffixes is non empty, completion for field name will end with
927 * one of the proposed suffixes.
928 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldSuffixes"
929 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
932 * CODEASSIST / Define the Suffixes for Static Field Name
933 * When the suffixes is non empty, completion for static field name will end with
934 * one of the proposed suffixes.
935 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldSuffixes"
936 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
939 * CODEASSIST / Define the Suffixes for Local Variable Name
940 * When the suffixes is non empty, completion for local variable name will end with
941 * one of the proposed suffixes.
942 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localSuffixes"
943 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
946 * CODEASSIST / Define the Suffixes for Argument Name
947 * When the suffixes is non empty, completion for argument name will end with
948 * one of the proposed suffixes.
949 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentSuffixes"
950 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
954 * @return a mutable table containing the default settings of all known options
955 * (key type: <code>String</code>; value type: <code>String</code>)
958 // public static Hashtable getDefaultOptions() {
960 // Hashtable defaultOptions = new Hashtable(10);
962 // // see #initializeDefaultPluginPreferences() for changing default settings
963 // Preferences preferences = getPlugin().getPluginPreferences();
964 // HashSet optionNames = OptionNames;
966 // // get preferences set to their default
967 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
968 // for (int i = 0; i < defaultPropertyNames.length; i++) {
969 // String propertyName = defaultPropertyNames[i];
970 // if (optionNames.contains(propertyName)) {
971 // defaultOptions.put(propertyName, preferences.getDefaultString(propertyName));
974 // // get preferences not set to their default
975 // String[] propertyNames = preferences.propertyNames();
976 // for (int i = 0; i < propertyNames.length; i++) {
977 // String propertyName = propertyNames[i];
978 // if (optionNames.contains(propertyName)) {
979 // defaultOptions.put(propertyName, preferences.getDefaultString(propertyName));
982 // // get encoding through resource plugin
983 // defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
985 // return defaultOptions;
988 * Helper method for returning one option value only. Equivalent to <code>(String)JavaCore.getOptions().get(optionName)</code>
989 * Note that it may answer <code>null</code> if this option does not exist.
991 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
994 * @param optionName the name of an option
995 * @return the String value of a given option
996 * @see JavaCore#getDefaultOptions
999 // public static String getOption(String optionName) {
1001 // if (CORE_ENCODING.equals(optionName)) {
1002 // return ResourcesPlugin.getEncoding();
1004 // if (OptionNames.contains(optionName)) {
1005 // Preferences preferences = getPlugin().getPluginPreferences();
1006 // return preferences.getString(optionName).trim();
1012 * Returns the table of the current options. Initially, all options have their default values,
1013 * and this method returns a table that includes all known options.
1015 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
1018 * @return table of current settings of all options
1019 * (key type: <code>String</code>; value type: <code>String</code>)
1020 * @see JavaCore#getDefaultOptions
1022 // public static Hashtable getOptions() {
1024 // Hashtable options = new Hashtable(10);
1026 // // see #initializeDefaultPluginPreferences() for changing default settings
1027 // Plugin plugin = getPlugin();
1028 // if (plugin != null) {
1029 // Preferences preferences = getPlugin().getPluginPreferences();
1030 // HashSet optionNames = OptionNames;
1032 // // get preferences set to their default
1033 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1034 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1035 // String propertyName = defaultPropertyNames[i];
1036 // if (optionNames.contains(propertyName)) {
1037 // options.put(propertyName, preferences.getDefaultString(propertyName));
1040 // // get preferences not set to their default
1041 // String[] propertyNames = preferences.propertyNames();
1042 // for (int i = 0; i < propertyNames.length; i++) {
1043 // String propertyName = propertyNames[i];
1044 // if (optionNames.contains(propertyName)) {
1045 // options.put(propertyName, preferences.getString(propertyName).trim());
1048 // // get encoding through resource plugin
1049 // options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1054 * Sets the current table of options. All and only the options explicitly included in the given table
1055 * are remembered; all previous option settings are forgotten, including ones not explicitly
1058 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
1061 * @param newOptions the new options (key type: <code>String</code>; value type: <code>String</code>),
1062 * or <code>null</code> to reset all options to their default values
1063 * @see JavaCore#getDefaultOptions
1065 // public static void setOptions(Hashtable newOptions) {
1067 // // see #initializeDefaultPluginPreferences() for changing default settings
1068 // Preferences preferences = getPlugin().getPluginPreferences();
1070 // if (newOptions == null) {
1071 // newOptions = getDefaultOptions();
1073 // Enumeration keys = newOptions.keys();
1074 // while (keys.hasMoreElements()) {
1075 // String key = (String) keys.nextElement();
1076 // if (!OptionNames.contains(key))
1077 // continue; // unrecognized option
1078 // if (key.equals(CORE_ENCODING))
1079 // continue; // skipped, contributed by resource prefs
1080 // String value = (String) newOptions.get(key);
1081 // preferences.setValue(key, value);
1084 // // persist options
1085 // getPlugin().savePluginPreferences();
1087 public static IProject[] getPHPProjects() {
1088 List phpProjectsList = new ArrayList();
1089 IProject[] workspaceProjects = PHPeclipsePlugin.getWorkspace().getRoot().getProjects();
1091 for (int i = 0; i < workspaceProjects.length; i++) {
1092 IProject iProject = workspaceProjects[i];
1093 if (isPHPProject(iProject))
1094 phpProjectsList.add(iProject);
1097 IProject[] phpProjects = new IProject[phpProjectsList.size()];
1098 return (IProject[]) phpProjectsList.toArray(phpProjects);
1101 // public static PHPProject getPHPProject(String name) {
1102 // IProject aProject = PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
1103 // if (isPHPProject(aProject)) {
1104 // PHPProject thePHPProject = new PHPProject();
1105 // thePHPProject.setProject(aProject);
1106 // return thePHPProject;
1111 public static boolean isPHPProject(IProject aProject) {
1113 return aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID);
1114 } catch (CoreException e) {
1120 // public static PHPFile create(IFile aFile) {
1121 // if (PHPFile.EXTENSION.equalsIgnoreCase(aFile.getFileExtension()))
1122 // return new PHPFile(aFile);
1123 // if (PHPFile.EXTENSION1.equalsIgnoreCase(aFile.getFileExtension()))
1124 // return new PHPFile(aFile);
1125 // if (PHPFile.EXTENSION2.equalsIgnoreCase(aFile.getFileExtension()))
1126 // return new PHPFile(aFile);
1127 // if (PHPFile.EXTENSION3.equalsIgnoreCase(aFile.getFileExtension()))
1128 // return new PHPFile(aFile);
1129 // if (PHPFile.EXTENSION4.equalsIgnoreCase(aFile.getFileExtension()))
1130 // return new PHPFile(aFile);
1131 // if (PHPFile.EXTENSION5.equalsIgnoreCase(aFile.getFileExtension()))
1132 // return new PHPFile(aFile);
1137 // public static PHPProject create(IProject aProject) {
1140 // if (aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1141 // PHPProject project = new PHPProject();
1142 // project.setProject(aProject);
1145 // } catch (CoreException e) {
1146 // System.err.println("Exception occurred in PHPCore#create(IProject): " + e.toString());
1152 public static void addPHPNature(IProject project, IProgressMonitor monitor) throws CoreException {
1153 if (!project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1154 IProjectDescription description = project.getDescription();
1155 String[] prevNatures = description.getNatureIds();
1156 String[] newNatures = new String[prevNatures.length + 1];
1157 System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
1158 newNatures[prevNatures.length] = PHPeclipsePlugin.PHP_NATURE_ID;
1159 description.setNatureIds(newNatures);
1160 project.setDescription(description, monitor);
1165 * Returns the single instance of the PHP core plug-in runtime class.
1167 * @return the single instance of the PHP core plug-in runtime class
1169 public static Plugin getPlugin() {
1170 return PHPeclipsePlugin.getDefault();
1174 * Initializes the default preferences settings for this plug-in.
1178 * Runs the given action as an atomic Java model operation.
1180 * After running a method that modifies Java elements,
1181 * registered listeners receive after-the-fact notification of
1182 * what just transpired, in the form of a element changed event.
1183 * This method allows clients to call a number of
1184 * methods that modify java elements and only have element
1185 * changed event notifications reported at the end of the entire
1189 * If this method is called outside the dynamic scope of another such
1190 * call, this method runs the action and then reports a single
1191 * element changed event describing the net effect of all changes
1192 * done to java elements by the action.
1195 * If this method is called in the dynamic scope of another such
1196 * call, this method simply runs the action.
1199 * @param action the action to perform
1200 * @param monitor a progress monitor, or <code>null</code> if progress
1201 * reporting and cancellation are not desired
1202 * @exception CoreException if the operation failed.
1205 public static void run(IWorkspaceRunnable action, IProgressMonitor monitor) throws CoreException {
1206 IWorkspace workspace = ResourcesPlugin.getWorkspace();
1207 if (workspace.isTreeLocked()) {
1208 new BatchOperation(action).run(monitor);
1210 // use IWorkspace.run(...) to ensure that a build will be done in autobuild mode
1211 workspace.run(new BatchOperation(action), monitor);
1216 * Adds the given listener for changes to Java elements.
1217 * Has no effect if an identical listener is already registered.
1219 * This listener will only be notified during the POST_CHANGE resource change notification
1220 * and any reconcile operation (POST_RECONCILE).
1221 * For finer control of the notification, use <code>addElementChangedListener(IElementChangedListener,int)</code>,
1222 * which allows to specify a different eventMask.
1224 * @see ElementChangedEvent
1225 * @param listener the listener
1227 public static void addElementChangedListener(IElementChangedListener listener) {
1228 addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE | ElementChangedEvent.POST_RECONCILE);
1232 * Adds the given listener for changes to Java elements.
1233 * Has no effect if an identical listener is already registered.
1234 * After completion of this method, the given listener will be registered for exactly
1235 * the specified events. If they were previously registered for other events, they
1236 * will be deregistered.
1238 * Once registered, a listener starts receiving notification of changes to
1239 * java elements in the model. The listener continues to receive
1240 * notifications until it is replaced or removed.
1243 * Listeners can listen for several types of event as defined in <code>ElementChangeEvent</code>.
1244 * Clients are free to register for any number of event types however if they register
1245 * for more than one, it is their responsibility to ensure they correctly handle the
1246 * case where the same java element change shows up in multiple notifications.
1247 * Clients are guaranteed to receive only the events for which they are registered.
1250 * @param listener the listener
1251 * @param eventMask the bit-wise OR of all event types of interest to the listener
1252 * @see IElementChangedListener
1253 * @see ElementChangedEvent
1254 * @see #removeElementChangedListener(IElementChangedListener)
1257 public static void addElementChangedListener(IElementChangedListener listener, int eventMask) {
1258 JavaModelManager.getJavaModelManager().addElementChangedListener(listener, eventMask);
1262 * Configures the given marker attribute map for the given Java element.
1263 * Used for markers, which denote a Java element rather than a resource.
1265 * @param attributes the mutable marker attribute map (key type: <code>String</code>,
1266 * value type: <code>String</code>)
1267 * @param element the Java element for which the marker needs to be configured
1269 public static void addJavaElementMarkerAttributes(
1271 IJavaElement element) {
1272 // if (element instanceof IMember)
1273 // element = ((IMember) element).getClassFile();
1274 if (attributes != null && element != null)
1275 attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier());
1279 * Configures the given marker for the given Java element.
1280 * Used for markers, which denote a Java element rather than a resource.
1282 * @param marker the marker to be configured
1283 * @param element the Java element for which the marker needs to be configured
1284 * @exception CoreException if the <code>IMarker.setAttribute</code> on the marker fails
1286 public void configureJavaElementMarker(IMarker marker, IJavaElement element)
1287 throws CoreException {
1288 // if (element instanceof IMember)
1289 // element = ((IMember) element).getClassFile();
1290 if (marker != null && element != null)
1291 marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier());
1295 * Returns the Java model element corresponding to the given handle identifier
1296 * generated by <code>IJavaElement.getHandleIdentifier()</code>, or
1297 * <code>null</code> if unable to create the associated element.
1299 public static IJavaElement create(String handleIdentifier) {
1300 if (handleIdentifier == null) {
1304 return JavaModelManager.getJavaModelManager().getHandleFromMemento(handleIdentifier);
1305 } catch (JavaModelException e) {
1310 * Returns the Java element corresponding to the given file, or
1311 * <code>null</code> if unable to associate the given file
1312 * with a Java element.
1314 * <p>The file must be one of:<ul>
1315 * <li>a <code>.java</code> file - the element returned is the corresponding <code>ICompilationUnit</code></li>
1316 * <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li>
1317 * <li>a <code>.jar</code> file - the element returned is the corresponding <code>IPackageFragmentRoot</code></li>
1320 * Creating a Java element has the side effect of creating and opening all of the
1321 * element's parents if they are not yet open.
1323 * @param the given file
1324 * @return the Java element corresponding to the given file, or
1325 * <code>null</code> if unable to associate the given file
1326 * with a Java element
1328 public static IJavaElement create(IFile file) {
1329 return JavaModelManager.create(file, null);
1332 * Returns the package fragment or package fragment root corresponding to the given folder, or
1333 * <code>null</code> if unable to associate the given folder with a Java element.
1335 * Note that a package fragment root is returned rather than a default package.
1337 * Creating a Java element has the side effect of creating and opening all of the
1338 * element's parents if they are not yet open.
1340 * @param the given folder
1341 * @return the package fragment or package fragment root corresponding to the given folder, or
1342 * <code>null</code> if unable to associate the given folder with a Java element
1344 public static IJavaElement create(IFolder folder) {
1345 return JavaModelManager.create(folder, null);
1348 * Returns the Java project corresponding to the given project.
1350 * Creating a Java Project has the side effect of creating and opening all of the
1351 * project's parents if they are not yet open.
1353 * Note that no check is done at this time on the existence or the java nature of this project.
1355 * @param project the given project
1356 * @return the Java project corresponding to the given project, null if the given project is null
1358 public static IJavaProject create(IProject project) {
1359 if (project == null) {
1362 JavaModel javaModel = JavaModelManager.getJavaModelManager().getJavaModel();
1363 return javaModel.getJavaProject(project);
1366 * Returns the Java element corresponding to the given resource, or
1367 * <code>null</code> if unable to associate the given resource
1368 * with a Java element.
1370 * The resource must be one of:<ul>
1371 * <li>a project - the element returned is the corresponding <code>IJavaProject</code></li>
1372 * <li>a <code>.java</code> file - the element returned is the corresponding <code>ICompilationUnit</code></li>
1373 * <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li>
1374 * <li>a <code>.jar</code> file - the element returned is the corresponding <code>IPackageFragmentRoot</code></li>
1375 * <li>a folder - the element returned is the corresponding <code>IPackageFragmentRoot</code>
1376 * or <code>IPackageFragment</code></li>
1377 * <li>the workspace root resource - the element returned is the <code>IJavaModel</code></li>
1380 * Creating a Java element has the side effect of creating and opening all of the
1381 * element's parents if they are not yet open.
1383 * @param resource the given resource
1384 * @return the Java element corresponding to the given resource, or
1385 * <code>null</code> if unable to associate the given resource
1386 * with a Java element
1388 public static IJavaElement create(IResource resource) {
1389 return JavaModelManager.create(resource, null);
1392 * Returns the Java model.
1394 * @param root the given root
1395 * @return the Java model, or <code>null</code> if the root is null
1397 public static IJavaModel create(IWorkspaceRoot root) {
1401 return JavaModelManager.getJavaModelManager().getJavaModel();
1404 * Creates and returns a class file element for
1405 * the given <code>.class</code> file. Returns <code>null</code> if unable
1406 * to recognize the class file.
1408 * @param file the given <code>.class</code> file
1409 * @return a class file element for the given <code>.class</code> file, or <code>null</code> if unable
1410 * to recognize the class file
1412 //public static IClassFile createClassFileFrom(IFile file) {
1413 // return JavaModelManager.createClassFileFrom(file, null);
1416 * Creates and returns a compilation unit element for
1417 * the given <code>.java</code> file. Returns <code>null</code> if unable
1418 * to recognize the compilation unit.
1420 * @param file the given <code>.java</code> file
1421 * @return a compilation unit element for the given <code>.java</code> file, or <code>null</code> if unable
1422 * to recognize the compilation unit
1424 public static ICompilationUnit createCompilationUnitFrom(IFile file) {
1425 return JavaModelManager.createCompilationUnitFrom(file, null);
1428 * Creates and returns a handle for the given JAR file.
1429 * The Java model associated with the JAR's project may be
1430 * created as a side effect.
1432 * @param file the given JAR file
1433 * @return a handle for the given JAR file, or <code>null</code> if unable to create a JAR package fragment root.
1434 * (for example, if the JAR file represents a non-Java resource)
1436 //public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile file) {
1437 // return JavaModelManager.createJarPackageFragmentRootFrom(file, null);
1441 * Answers the project specific value for a given classpath container.
1442 * In case this container path could not be resolved, then will answer <code>null</code>.
1443 * Both the container path and the project context are supposed to be non-null.
1445 * The containerPath is a formed by a first ID segment followed with extra segments, which can be
1446 * used as additional hints for resolution. If no container was ever recorded for this container path
1447 * onto this project (using <code>setClasspathContainer</code>, then a
1448 * <code>ClasspathContainerInitializer</code> will be activated if any was registered for this container
1449 * ID onto the extension point "org.eclipse.jdt.core.classpathContainerInitializer".
1451 * There is no assumption that the returned container must answer the exact same containerPath
1452 * when requested <code>IClasspathContainer#getPath</code>.
1453 * Indeed, the containerPath is just an indication for resolving it to an actual container object.
1455 * Classpath container values are persisted locally to the workspace, but
1456 * are not preserved from a session to another. It is thus highly recommended to register a
1457 * <code>ClasspathContainerInitializer</code> for each referenced container
1458 * (through the extension point "org.eclipse.jdt.core.ClasspathContainerInitializer").
1460 * @param containerPath the name of the container, which needs to be resolved
1461 * @param project a specific project in which the container is being resolved
1462 * @return the corresponding classpath container or <code>null</code> if unable to find one.
1464 * @exception JavaModelException if an exception occurred while resolving the container, or if the resolved container
1465 * contains illegal entries (contains CPE_CONTAINER entries or null entries).
1467 * @see ClasspathContainerInitializer
1468 * @see IClasspathContainer
1469 * @see #setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor)
1472 //public static IClasspathContainer getClasspathContainer(final IPath containerPath, final IJavaProject project) throws JavaModelException {
1474 // IClasspathContainer container = JavaModelManager.containerGet(project, containerPath);
1475 // if (container == JavaModelManager.ContainerInitializationInProgress) return null; // break cycle
1477 // if (container == null){
1478 // final ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
1479 // if (initializer != null){
1480 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1481 // System.out.println("CPContainer INIT - triggering initialization of: ["+project.getElementName()+"] " + containerPath + " using initializer: "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
1482 // 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$
1484 // JavaModelManager.containerPut(project, containerPath, JavaModelManager.ContainerInitializationInProgress); // avoid initialization cycles
1485 // boolean ok = false;
1487 // // wrap initializer call with Safe runnable in case initializer would be causing some grief
1488 // Platform.run(new ISafeRunnable() {
1489 // public void handleException(Throwable exception) {
1490 // Util.log(exception, "Exception occurred in classpath container initializer: "+initializer); //$NON-NLS-1$
1492 // public void run() throws Exception {
1493 // initializer.initialize(containerPath, project);
1497 // // retrieve value (if initialization was successful)
1498 // container = JavaModelManager.containerGet(project, containerPath);
1499 // if (container == JavaModelManager.ContainerInitializationInProgress) return null; // break cycle
1502 // if (!ok) JavaModelManager.containerPut(project, containerPath, null); // flush cache
1504 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1505 // System.out.print("CPContainer INIT - after resolution: ["+project.getElementName()+"] " + containerPath + " --> "); //$NON-NLS-2$//$NON-NLS-1$//$NON-NLS-3$
1506 // if (container != null){
1507 // System.out.print("container: "+container.getDescription()+" {"); //$NON-NLS-2$//$NON-NLS-1$
1508 // IClasspathEntry[] entries = container.getClasspathEntries();
1509 // if (entries != null){
1510 // for (int i = 0; i < entries.length; i++){
1511 // if (i > 0) System.out.println(", ");//$NON-NLS-1$
1512 // System.out.println(entries[i]);
1515 // System.out.println("}");//$NON-NLS-1$
1517 // System.out.println("{unbound}");//$NON-NLS-1$
1521 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1522 // System.out.println("CPContainer INIT - no initializer found for: "+project.getElementName()+"] " + containerPath); //$NON-NLS-1$ //$NON-NLS-2$
1526 // return container;
1530 * Helper method finding the classpath container initializer registered for a given classpath container ID
1531 * or <code>null</code> if none was found while iterating over the contributions to extension point to
1532 * the extension point "org.eclipse.jdt.core.classpathContainerInitializer".
1534 * A containerID is the first segment of any container path, used to identify the registered container initializer.
1536 * @param String - a containerID identifying a registered initializer
1537 * @return ClasspathContainerInitializer - the registered classpath container initializer or <code>null</code> if
1541 //public static ClasspathContainerInitializer getClasspathContainerInitializer(String containerID){
1543 // Plugin jdtCorePlugin = JavaCore.getPlugin();
1544 // if (jdtCorePlugin == null) return null;
1546 // IExtensionPoint extension = jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID);
1547 // if (extension != null) {
1548 // IExtension[] extensions = extension.getExtensions();
1549 // for(int i = 0; i < extensions.length; i++){
1550 // IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
1551 // for(int j = 0; j < configElements.length; j++){
1552 // String initializerID = configElements[j].getAttribute("id"); //$NON-NLS-1$
1553 // if (initializerID != null && initializerID.equals(containerID)){
1554 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
1555 // System.out.println("CPContainer INIT - found initializer: "+containerID +" --> " + configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
1558 // Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
1559 // if (execExt instanceof ClasspathContainerInitializer){
1560 // return (ClasspathContainerInitializer)execExt;
1562 // } catch(CoreException e) {
1572 * Returns the path held in the given classpath variable.
1573 * Returns <node>null</code> if unable to bind.
1575 * Classpath variable values are persisted locally to the workspace, and
1576 * are preserved from session to session.
1578 * Note that classpath variables can be contributed registered initializers for,
1579 * using the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
1580 * If an initializer is registered for a variable, its persisted value will be ignored:
1581 * its initializer will thus get the opportunity to rebind the variable differently on
1584 * @param variableName the name of the classpath variable
1585 * @return the path, or <code>null</code> if none
1586 * @see #setClasspathVariable
1588 public static IPath getClasspathVariable(final String variableName) {
1590 IPath variablePath = JavaModelManager.variableGet(variableName);
1591 if (variablePath == JavaModelManager.VariableInitializationInProgress) return null; // break cycle
1593 if (variablePath != null) {
1594 return variablePath;
1597 // even if persisted value exists, initializer is given priority, only if no initializer is found the persisted value is reused
1598 // final ClasspathVariableInitializer initializer = PHPCore.getClasspathVariableInitializer(variableName);
1599 // if (initializer != null){
1600 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1601 // System.out.println("CPVariable INIT - triggering initialization of: " + variableName+ " using initializer: "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$
1602 // new Exception("FAKE exception for dumping current CPVariable ("+variableName+ ")INIT invocation stack trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$
1604 // JavaModelManager.variablePut(variableName, JavaModelManager.VariableInitializationInProgress); // avoid initialization cycles
1605 // boolean ok = false;
1607 // // wrap initializer call with Safe runnable in case initializer would be causing some grief
1608 // Platform.run(new ISafeRunnable() {
1609 // public void handleException(Throwable exception) {
1610 // Util.log(exception, "Exception occurred in classpath variable initializer: "+initializer+" while initializing variable: "+variableName); //$NON-NLS-1$ //$NON-NLS-2$
1612 // public void run() throws Exception {
1613 // initializer.initialize(variableName);
1616 // variablePath = (IPath) JavaModelManager.variableGet(variableName); // initializer should have performed side-effect
1617 // if (variablePath == JavaModelManager.VariableInitializationInProgress) return null; // break cycle (initializer did not init or reentering call)
1618 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1619 // System.out.println("CPVariable INIT - after initialization: " + variableName + " --> " + variablePath); //$NON-NLS-2$//$NON-NLS-1$
1623 // if (!ok) JavaModelManager.variablePut(variableName, null); // flush cache
1626 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1627 // System.out.println("CPVariable INIT - no initializer found for: " + variableName); //$NON-NLS-1$
1630 return variablePath;
1634 * Helper method finding the classpath variable initializer registered for a given classpath variable name
1635 * or <code>null</code> if none was found while iterating over the contributions to extension point to
1636 * the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
1638 * @param the given variable
1639 * @return ClasspathVariableInitializer - the registered classpath variable initializer or <code>null</code> if
1643 public static ClasspathVariableInitializer getClasspathVariableInitializer(String variable){
1645 Plugin jdtCorePlugin = JavaCore.getPlugin();
1646 if (jdtCorePlugin == null) return null;
1648 // IExtensionPoint extension = jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID);
1649 // if (extension != null) {
1650 // IExtension[] extensions = extension.getExtensions();
1651 // for(int i = 0; i < extensions.length; i++){
1652 // IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
1653 // for(int j = 0; j < configElements.length; j++){
1655 // String varAttribute = configElements[j].getAttribute("variable"); //$NON-NLS-1$
1656 // if (variable.equals(varAttribute)) {
1657 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
1658 // System.out.println("CPVariable INIT - found initializer: "+variable+" --> " + configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
1660 // Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
1661 // if (execExt instanceof ClasspathVariableInitializer){
1662 // return (ClasspathVariableInitializer)execExt;
1665 // } catch(CoreException e){
1674 * Returns the names of all known classpath variables.
1676 * Classpath variable values are persisted locally to the workspace, and
1677 * are preserved from session to session.
1680 * @return the list of classpath variable names
1681 * @see #setClasspathVariable
1683 //public static String[] getClasspathVariableNames() {
1684 // return JavaModelManager.variableNames();
1688 * Returns a table of all known configurable options with their default values.
1689 * These options allow to configure the behaviour of the underlying components.
1690 * The client may safely use the result as a template that they can modify and
1691 * then pass to <code>setOptions</code>.
1693 * Helper constants have been defined on JavaCore for each of the option ID and
1694 * their possible constant values.
1696 * Note: more options might be added in further releases.
1698 * RECOGNIZED OPTIONS:
1699 * COMPILER / Generating Local Variable Debug Attribute
1700 * When generated, this attribute will enable local variable names
1701 * to be displayed in debugger, only in place where variables are
1702 * definitely assigned (.class file is then bigger)
1703 * - option id: "org.eclipse.jdt.core.compiler.debug.localVariable"
1704 * - possible values: { "generate", "do not generate" }
1705 * - default: "generate"
1707 * COMPILER / Generating Line Number Debug Attribute
1708 * When generated, this attribute will enable source code highlighting in debugger
1709 * (.class file is then bigger).
1710 * - option id: "org.eclipse.jdt.core.compiler.debug.lineNumber"
1711 * - possible values: { "generate", "do not generate" }
1712 * - default: "generate"
1714 * COMPILER / Generating Source Debug Attribute
1715 * When generated, this attribute will enable the debugger to present the
1716 * corresponding source code.
1717 * - option id: "org.eclipse.jdt.core.compiler.debug.sourceFile"
1718 * - possible values: { "generate", "do not generate" }
1719 * - default: "generate"
1721 * COMPILER / Preserving Unused Local Variables
1722 * Unless requested to preserve unused local variables (that is, never read), the
1723 * compiler will optimize them out, potentially altering debugging
1724 * - option id: "org.eclipse.jdt.core.compiler.codegen.unusedLocal"
1725 * - possible values: { "preserve", "optimize out" }
1726 * - default: "preserve"
1728 * COMPILER / Defining Target Java Platform
1729 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
1730 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
1731 * - option id: "org.eclipse.jdt.core.compiler.codegen.targetPlatform"
1732 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
1735 * COMPILER / Reporting Unreachable Code
1736 * Unreachable code can optionally be reported as an error, warning or simply
1737 * ignored. The bytecode generation will always optimized it out.
1738 * - option id: "org.eclipse.jdt.core.compiler.problem.unreachableCode"
1739 * - possible values: { "error", "warning", "ignore" }
1740 * - default: "error"
1742 * COMPILER / Reporting Invalid Import
1743 * An import statement that cannot be resolved might optionally be reported
1744 * as an error, as a warning or ignored.
1745 * - option id: "org.eclipse.jdt.core.compiler.problem.invalidImport"
1746 * - possible values: { "error", "warning", "ignore" }
1747 * - default: "error"
1749 * COMPILER / Reporting Attempt to Override Package-Default Method
1750 * A package default method is not visible in a different package, and thus
1751 * cannot be overridden. When enabling this option, the compiler will signal
1752 * such scenarii either as an error or a warning.
1753 * - option id: "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"
1754 * - possible values: { "error", "warning", "ignore" }
1755 * - default: "warning"
1757 * COMPILER / Reporting Method With Constructor Name
1758 * Naming a method with a constructor name is generally considered poor
1759 * style programming. When enabling this option, the compiler will signal such
1760 * scenarii either as an error or a warning.
1761 * - option id: "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"
1762 * - possible values: { "error", "warning", "ignore" }
1763 * - default: "warning"
1765 * COMPILER / Reporting Deprecation
1766 * When enabled, the compiler will signal use of deprecated API either as an
1767 * error or a warning.
1768 * - option id: "org.eclipse.jdt.core.compiler.problem.deprecation"
1769 * - possible values: { "error", "warning", "ignore" }
1770 * - default: "warning"
1772 * COMPILER / Reporting Deprecation Inside Deprecated Code
1773 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
1774 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.deprecation".
1775 * - option id: "org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode"
1776 * - possible values: { "enabled", "disabled" }
1777 * - default: "disabled"
1779 * COMPILER / Reporting Hidden Catch Block
1780 * Locally to a try statement, some catch blocks may hide others . For example,
1781 * try { throw new java.io.CharConversionException();
1782 * } catch (java.io.CharConversionException e) {
1783 * } catch (java.io.IOException e) {}.
1784 * When enabling this option, the compiler will issue an error or a warning for hidden
1785 * catch blocks corresponding to checked exceptions
1786 * - option id: "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"
1787 * - possible values: { "error", "warning", "ignore" }
1788 * - default: "warning"
1790 * COMPILER / Reporting Unused Local
1791 * When enabled, the compiler will issue an error or a warning for unused local
1792 * variables (that is, variables never read from)
1793 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedLocal"
1794 * - possible values: { "error", "warning", "ignore" }
1795 * - default: "ignore"
1797 * COMPILER / Reporting Unused Parameter
1798 * When enabled, the compiler will issue an error or a warning for unused method
1799 * parameters (that is, parameters never read from)
1800 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameter"
1801 * - possible values: { "error", "warning", "ignore" }
1802 * - default: "ignore"
1804 * COMPILER / Reporting Unused Parameter if Implementing Abstract Method
1805 * When enabled, the compiler will signal unused parameters in abstract method implementations.
1806 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
1807 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"
1808 * - possible values: { "enabled", "disabled" }
1809 * - default: "disabled"
1811 * COMPILER / Reporting Unused Parameter if Overriding Concrete Method
1812 * When enabled, the compiler will signal unused parameters in methods overriding concrete ones.
1813 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
1814 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"
1815 * - possible values: { "enabled", "disabled" }
1816 * - default: "disabled"
1818 * COMPILER / Reporting Unused Import
1819 * When enabled, the compiler will issue an error or a warning for unused import
1821 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedImport"
1822 * - possible values: { "error", "warning", "ignore" }
1823 * - default: "warning"
1825 * COMPILER / Reporting Unused Private Members
1826 * When enabled, the compiler will issue an error or a warning whenever a private
1827 * method or field is declared but never used within the same unit.
1828 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"
1829 * - possible values: { "error", "warning", "ignore" }
1830 * - default: "ignore"
1832 * COMPILER / Reporting Synthetic Access Emulation
1833 * When enabled, the compiler will issue an error or a warning whenever it emulates
1834 * access to a non-accessible member of an enclosing type. Such access can have
1835 * performance implications.
1836 * - option id: "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"
1837 * - possible values: { "error", "warning", "ignore" }
1838 * - default: "ignore"
1840 * COMPILER / Reporting Non-Externalized String Literal
1841 * When enabled, the compiler will issue an error or a warning for non externalized
1842 * String literal (that is, not tagged with //$NON-NLS-<n>$).
1843 * - option id: "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"
1844 * - possible values: { "error", "warning", "ignore" }
1845 * - default: "ignore"
1847 * COMPILER / Reporting Usage of 'assert' Identifier
1848 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
1849 * used as an identifier (reserved keyword in 1.4)
1850 * - option id: "org.eclipse.jdt.core.compiler.problem.assertIdentifier"
1851 * - possible values: { "error", "warning", "ignore" }
1852 * - default: "ignore"
1854 * COMPILER / Reporting Non-Static Reference to a Static Member
1855 * When enabled, the compiler will issue an error or a warning whenever a static field
1856 * or method is accessed with an expression receiver. A reference to a static member should
1857 * be qualified with a type name.
1858 * - option id: "org.eclipse.jdt.core.compiler.problem.staticAccessReceiver"
1859 * - possible values: { "error", "warning", "ignore" }
1860 * - default: "warning"
1862 * COMPILER / Reporting Assignment with no Effect
1863 * When enabled, the compiler will issue an error or a warning whenever an assignment
1864 * has no effect (e.g 'x = x').
1865 * - option id: "org.eclipse.jdt.core.compiler.problem.noEffectAssignment"
1866 * - possible values: { "error", "warning", "ignore" }
1867 * - default: "warning"
1869 * COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods
1870 * When enabled, the compiler will issue an error or a warning whenever an interface
1871 * defines a method incompatible with a non-inherited Object method. Until this conflict
1872 * is resolved, such an interface cannot be implemented, For example,
1876 * - option id: "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"
1877 * - possible values: { "error", "warning", "ignore" }
1878 * - default: "warning"
1880 * COMPILER / Reporting Usage of char[] Expressions in String Concatenations
1881 * When enabled, the compiler will issue an error or a warning whenever a char[] expression
1882 * is used in String concatenations (for example, "hello" + new char[]{'w','o','r','l','d'}).
1883 * - option id: "org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion"
1884 * - possible values: { "error", "warning", "ignore" }
1885 * - default: "warning"
1887 * COMPILER / Setting Source Compatibility Mode
1888 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
1889 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
1890 * level should be set to "1.4" and the compliance mode should be "1.4".
1891 * - option id: "org.eclipse.jdt.core.compiler.source"
1892 * - possible values: { "1.3", "1.4" }
1895 * COMPILER / Setting Compliance Level
1896 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
1897 * should not go beyond "1.3" level.
1898 * - option id: "org.eclipse.jdt.core.compiler.compliance"
1899 * - possible values: { "1.3", "1.4" }
1902 * COMPILER / Maximum number of problems reported per compilation unit
1903 * Specify the maximum number of problems reported on each compilation unit.
1904 * - option id: "org.eclipse.jdt.core.compiler.maxProblemPerUnit"
1905 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
1908 * COMPILER / Define the Automatic Task Tags
1909 * When the tag list is not empty, the compiler will issue a task marker whenever it encounters
1910 * one of the corresponding tag inside any comment in Java source code.
1911 * Generated task messages will include the tag, and range until the next line separator or comment ending.
1912 * Note that tasks messages are trimmed.
1913 * - option id: "org.eclipse.jdt.core.compiler.taskTags"
1914 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card or leading/trailing spaces
1917 * COMPILER / Define the Automatic Task Priorities
1918 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
1919 * of the task markers issued by the compiler.
1920 * If the default is specified, the priority of each task marker is "NORMAL".
1921 * - option id: "org.eclipse.jdt.core.compiler.taskPriorities"
1922 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
1925 * BUILDER / Specifying Filters for Resource Copying Control
1926 * Allow to specify some filters to control the resource copy process.
1927 * - option id: "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
1928 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
1929 * or the name of a folder which ends with '/'
1932 * BUILDER / Abort if Invalid Classpath
1933 * Allow to toggle the builder to abort if the classpath is invalid
1934 * - option id: "org.eclipse.jdt.core.builder.invalidClasspath"
1935 * - possible values: { "abort", "ignore" }
1936 * - default: "abort"
1938 * BUILDER / Cleaning Output Folder(s)
1939 * Indicate whether the JavaBuilder is allowed to clean the output folders
1940 * when performing full build operations.
1941 * - option id: "org.eclipse.jdt.core.builder.cleanOutputFolder"
1942 * - possible values: { "clean", "ignore" }
1943 * - default: "clean"
1945 * BUILDER / Reporting Duplicate Resources
1946 * Indicate the severity of the problem reported when more than one occurrence
1947 * of a resource is to be copied into the output location.
1948 * - option id: "org.eclipse.jdt.core.builder.duplicateResourceTask"
1949 * - possible values: { "error", "warning" }
1950 * - default: "warning"
1952 * JAVACORE / Computing Project Build Order
1953 * Indicate whether JavaCore should enforce the project build order to be based on
1954 * the classpath prerequisite chain. When requesting to compute, this takes over
1955 * the platform default order (based on project references).
1956 * - option id: "org.eclipse.jdt.core.computeJavaBuildOrder"
1957 * - possible values: { "compute", "ignore" }
1958 * - default: "ignore"
1960 * JAVACORE / Specify Default Source Encoding Format
1961 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
1962 * to 'ResourcesPlugin.getEncoding()'.
1963 * - option id: "org.eclipse.jdt.core.encoding"
1964 * - possible values: { any of the supported encoding name}.
1965 * - default: <platform default>
1967 * JAVACORE / Reporting Incomplete Classpath
1968 * Indicate the severity of the problem reported when an entry on the classpath does not exist,
1969 * is not legite or is not visible (for example, a referenced project is closed).
1970 * - option id: "org.eclipse.jdt.core.incompleteClasspath"
1971 * - possible values: { "error", "warning"}
1972 * - default: "error"
1974 * JAVACORE / Reporting Classpath Cycle
1975 * Indicate the severity of the problem reported when a project is involved in a cycle.
1976 * - option id: "org.eclipse.jdt.core.circularClasspath"
1977 * - possible values: { "error", "warning" }
1978 * - default: "error"
1980 * JAVACORE / Enabling Usage of Classpath Exclusion Patterns
1981 * When disabled, no entry on a project classpath can be associated with
1982 * an exclusion pattern.
1983 * - option id: "org.eclipse.jdt.core.classpath.exclusionPatterns"
1984 * - possible values: { "enabled", "disabled" }
1985 * - default: "enabled"
1987 * JAVACORE / Enabling Usage of Classpath Multiple Output Locations
1988 * When disabled, no entry on a project classpath can be associated with
1989 * a specific output location, preventing thus usage of multiple output locations.
1990 * - option id: "org.eclipse.jdt.core.classpath.multipleOutputLocations"
1991 * - possible values: { "enabled", "disabled" }
1992 * - default: "enabled"
1994 * FORMATTER / Inserting New Line Before Opening Brace
1995 * When Insert, a new line is inserted before an opening brace, otherwise nothing
1997 * - option id: "org.eclipse.jdt.core.formatter.newline.openingBrace"
1998 * - possible values: { "insert", "do not insert" }
1999 * - default: "do not insert"
2001 * FORMATTER / Inserting New Line Inside Control Statement
2002 * When Insert, a new line is inserted between } and following else, catch, finally
2003 * - option id: "org.eclipse.jdt.core.formatter.newline.controlStatement"
2004 * - possible values: { "insert", "do not insert" }
2005 * - default: "do not insert"
2007 * FORMATTER / Clearing Blank Lines
2008 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
2009 * and all others removed.
2010 * - option id: "org.eclipse.jdt.core.formatter.newline.clearAll"
2011 * - possible values: { "clear all", "preserve one" }
2012 * - default: "preserve one"
2014 * FORMATTER / Inserting New Line Between Else/If
2015 * When Insert, a blank line is inserted between an else and an if when they are
2016 * contiguous. When choosing to not insert, else-if will be kept on the same
2017 * line when possible.
2018 * - option id: "org.eclipse.jdt.core.formatter.newline.elseIf"
2019 * - possible values: { "insert", "do not insert" }
2020 * - default: "do not insert"
2022 * FORMATTER / Inserting New Line In Empty Block
2023 * When insert, a line break is inserted between contiguous { and }, if } is not followed
2025 * - option id: "org.eclipse.jdt.core.formatter.newline.emptyBlock"
2026 * - possible values: { "insert", "do not insert" }
2027 * - default: "insert"
2029 * FORMATTER / Splitting Lines Exceeding Length
2030 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
2031 * disable line splitting
2032 * - option id: "org.eclipse.jdt.core.formatter.lineSplit"
2033 * - possible values: "<n>", where n is zero or a positive integer
2036 * FORMATTER / Compacting Assignment
2037 * Assignments can be formatted asymmetrically, for example 'int x= 2;', when Normal, a space
2038 * is inserted before the assignment operator
2039 * - option id: "org.eclipse.jdt.core.formatter.style.assignment"
2040 * - possible values: { "compact", "normal" }
2041 * - default: "normal"
2043 * FORMATTER / Defining Indentation Character
2044 * Either choose to indent with tab characters or spaces
2045 * - option id: "org.eclipse.jdt.core.formatter.tabulation.char"
2046 * - possible values: { "tab", "space" }
2049 * FORMATTER / Defining Space Indentation Length
2050 * When using spaces, set the amount of space characters to use for each
2052 * - option id: "org.eclipse.jdt.core.formatter.tabulation.size"
2053 * - possible values: "<n>", where n is a positive integer
2056 * FORMATTER / Inserting space in cast expression
2057 * When Insert, a space is added between the type and the expression in a cast expression.
2058 * - option id: "org.eclipse.jdt.core.formatter.space.castexpression"
2059 * - possible values: { "insert", "do not insert" }
2060 * - default: "insert"
2062 * CODEASSIST / Activate Visibility Sensitive Completion
2063 * When active, completion doesn't show that you can not see
2064 * (for example, you can not see private methods of a super class).
2065 * - option id: "org.eclipse.jdt.core.codeComplete.visibilityCheck"
2066 * - possible values: { "enabled", "disabled" }
2067 * - default: "disabled"
2069 * CODEASSIST / Automatic Qualification of Implicit Members
2070 * When active, completion automatically qualifies completion on implicit
2071 * field references and message expressions.
2072 * - option id: "org.eclipse.jdt.core.codeComplete.forceImplicitQualification"
2073 * - possible values: { "enabled", "disabled" }
2074 * - default: "disabled"
2076 * CODEASSIST / Define the Prefixes for Field Name
2077 * When the prefixes is non empty, completion for field name will begin with
2078 * one of the proposed prefixes.
2079 * - option id: "org.eclipse.jdt.core.codeComplete.fieldPrefixes"
2080 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2083 * CODEASSIST / Define the Prefixes for Static Field Name
2084 * When the prefixes is non empty, completion for static field name will begin with
2085 * one of the proposed prefixes.
2086 * - option id: "org.eclipse.jdt.core.codeComplete.staticFieldPrefixes"
2087 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2090 * CODEASSIST / Define the Prefixes for Local Variable Name
2091 * When the prefixes is non empty, completion for local variable name will begin with
2092 * one of the proposed prefixes.
2093 * - option id: "org.eclipse.jdt.core.codeComplete.localPrefixes"
2094 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2097 * CODEASSIST / Define the Prefixes for Argument Name
2098 * When the prefixes is non empty, completion for argument name will begin with
2099 * one of the proposed prefixes.
2100 * - option id: "org.eclipse.jdt.core.codeComplete.argumentPrefixes"
2101 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2104 * CODEASSIST / Define the Suffixes for Field Name
2105 * When the suffixes is non empty, completion for field name will end with
2106 * one of the proposed suffixes.
2107 * - option id: "org.eclipse.jdt.core.codeComplete.fieldSuffixes"
2108 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2111 * CODEASSIST / Define the Suffixes for Static Field Name
2112 * When the suffixes is non empty, completion for static field name will end with
2113 * one of the proposed suffixes.
2114 * - option id: "org.eclipse.jdt.core.codeComplete.staticFieldSuffixes"
2115 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2118 * CODEASSIST / Define the Suffixes for Local Variable Name
2119 * When the suffixes is non empty, completion for local variable name will end with
2120 * one of the proposed suffixes.
2121 * - option id: "org.eclipse.jdt.core.codeComplete.localSuffixes"
2122 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2125 * CODEASSIST / Define the Suffixes for Argument Name
2126 * When the suffixes is non empty, completion for argument name will end with
2127 * one of the proposed suffixes.
2128 * - option id: "org.eclipse.jdt.core.codeComplete.argumentSuffixes"
2129 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
2133 * @return a mutable table containing the default settings of all known options
2134 * (key type: <code>String</code>; value type: <code>String</code>)
2137 public static Hashtable getDefaultOptions(){
2139 Hashtable defaultOptions = new Hashtable(10);
2141 // see #initializeDefaultPluginPreferences() for changing default settings
2142 Preferences preferences = getPlugin().getPluginPreferences();
2143 HashSet optionNames = JavaModelManager.OptionNames;
2145 // get preferences set to their default
2146 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2147 for (int i = 0; i < defaultPropertyNames.length; i++){
2148 String propertyName = defaultPropertyNames[i];
2149 if (optionNames.contains(propertyName)) {
2150 defaultOptions.put(propertyName, preferences.getDefaultString(propertyName));
2153 // get preferences not set to their default
2154 String[] propertyNames = preferences.propertyNames();
2155 for (int i = 0; i < propertyNames.length; i++){
2156 String propertyName = propertyNames[i];
2157 if (optionNames.contains(propertyName)) {
2158 defaultOptions.put(propertyName, preferences.getDefaultString(propertyName));
2161 // get encoding through resource plugin
2162 defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2164 return defaultOptions;
2168 * Returns the single instance of the Java core plug-in runtime class.
2169 * Equivalent to <code>(JavaCore) getPlugin()</code>.
2171 * @return the single instance of the Java core plug-in runtime class
2173 public static PHPeclipsePlugin getJavaCore() {
2174 return (PHPeclipsePlugin) getPlugin();
2178 * Helper method for returning one option value only. Equivalent to <code>(String)JavaCore.getOptions().get(optionName)</code>
2179 * Note that it may answer <code>null</code> if this option does not exist.
2181 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
2184 * @param optionName the name of an option
2185 * @return the String value of a given option
2186 * @see JavaCore#getDefaultOptions
2189 public static String getOption(String optionName) {
2191 if (CORE_ENCODING.equals(optionName)){
2192 return ResourcesPlugin.getEncoding();
2194 if (JavaModelManager.OptionNames.contains(optionName)){
2195 Preferences preferences = getPlugin().getPluginPreferences();
2196 return preferences.getString(optionName).trim();
2202 * Returns the table of the current options. Initially, all options have their default values,
2203 * and this method returns a table that includes all known options.
2205 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
2208 * @return table of current settings of all options
2209 * (key type: <code>String</code>; value type: <code>String</code>)
2210 * @see JavaCore#getDefaultOptions
2212 public static Hashtable getOptions() {
2214 Hashtable options = new Hashtable(10);
2216 // see #initializeDefaultPluginPreferences() for changing default settings
2217 Plugin plugin = getPlugin();
2218 if (plugin != null) {
2219 Preferences preferences = getPlugin().getPluginPreferences();
2220 HashSet optionNames = JavaModelManager.OptionNames;
2222 // get preferences set to their default
2223 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2224 for (int i = 0; i < defaultPropertyNames.length; i++){
2225 String propertyName = defaultPropertyNames[i];
2226 if (optionNames.contains(propertyName)){
2227 options.put(propertyName, preferences.getDefaultString(propertyName));
2230 // get preferences not set to their default
2231 String[] propertyNames = preferences.propertyNames();
2232 for (int i = 0; i < propertyNames.length; i++){
2233 String propertyName = propertyNames[i];
2234 if (optionNames.contains(propertyName)){
2235 options.put(propertyName, preferences.getString(propertyName).trim());
2238 // get encoding through resource plugin
2239 options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2245 * This is a helper method, which returns the resolved classpath entry denoted
2246 * by a given entry (if it is a variable entry). It is obtained by resolving the variable
2247 * reference in the first segment. Returns <node>null</code> if unable to resolve using
2248 * the following algorithm:
2250 * <li> if variable segment cannot be resolved, returns <code>null</code></li>
2251 * <li> finds a project, JAR or binary folder in the workspace at the resolved path location</li>
2252 * <li> if none finds an external JAR file or folder outside the workspace at the resolved path location </li>
2253 * <li> if none returns <code>null</code></li>
2256 * Variable source attachment path and root path are also resolved and recorded in the resulting classpath entry.
2258 * NOTE: This helper method does not handle classpath containers, for which should rather be used
2259 * <code>JavaCore#getClasspathContainer(IPath, IJavaProject)</code>.
2262 * @param entry the given variable entry
2263 * @return the resolved library or project classpath entry, or <code>null</code>
2264 * if the given variable entry could not be resolved to a valid classpath entry
2266 public static IClasspathEntry getResolvedClasspathEntry(IClasspathEntry entry) {
2268 if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
2271 IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
2272 IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath());
2273 if (resolvedPath == null)
2276 Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false);
2280 // inside the workspace
2281 if (target instanceof IResource) {
2282 IResource resolvedResource = (IResource) target;
2283 if (resolvedResource != null) {
2284 switch (resolvedResource.getType()) {
2286 case IResource.PROJECT :
2288 return JavaCore.newProjectEntry(resolvedPath, entry.isExported());
2290 case IResource.FILE :
2291 // if (Util.isArchiveFileName(resolvedResource.getName())) {
2292 // // internal binary archive
2293 // return JavaCore.newLibraryEntry(
2295 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2296 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2297 // entry.isExported());
2301 case IResource.FOLDER :
2302 // internal binary folder
2303 // return JavaCore.newLibraryEntry(
2305 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2306 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2307 // entry.isExported());
2312 // outside the workspace
2313 if (target instanceof File) {
2314 File externalFile = (File) target;
2315 if (externalFile.isFile()) {
2316 String fileName = externalFile.getName().toLowerCase();
2317 // if (fileName.endsWith(".jar" //$NON-NLS-1$
2318 // ) || fileName.endsWith(".zip" //$NON-NLS-1$
2319 // )) { // external binary archive
2320 // return JavaCore.newLibraryEntry(
2322 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2323 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2324 // entry.isExported());
2326 } else { // external binary folder
2327 if (resolvedPath.isAbsolute()){
2328 // return JavaCore.newLibraryEntry(
2330 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2331 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2332 // entry.isExported());
2341 * Resolve a variable path (helper method).
2343 * @param variablePath the given variable path
2344 * @return the resolved variable path or <code>null</code> if none
2346 public static IPath getResolvedVariablePath(IPath variablePath) {
2348 if (variablePath == null)
2350 int count = variablePath.segmentCount();
2355 String variableName = variablePath.segment(0);
2356 IPath resolvedPath = JavaCore.getClasspathVariable(variableName);
2357 if (resolvedPath == null)
2360 // append path suffix
2362 resolvedPath = resolvedPath.append(variablePath.removeFirstSegments(1));
2364 return resolvedPath;
2368 * Answers the shared working copies currently registered for this buffer factory.
2369 * Working copies can be shared by several clients using the same buffer factory,see
2370 * <code>IWorkingCopy.getSharedWorkingCopy</code>.
2372 * @param factory the given buffer factory
2373 * @return the list of shared working copies for a given buffer factory
2377 public static IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory){
2379 // if factory is null, default factory must be used
2380 if (factory == null) factory = BufferManager.getDefaultBufferManager().getDefaultBufferFactory();
2381 Map sharedWorkingCopies = JavaModelManager.getJavaModelManager().sharedWorkingCopies;
2383 Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
2384 if (perFactoryWorkingCopies == null) return JavaModelManager.NoWorkingCopy;
2385 Collection copies = perFactoryWorkingCopies.values();
2386 IWorkingCopy[] result = new IWorkingCopy[copies.size()];
2387 copies.toArray(result);
2392 * Initializes the default preferences settings for this plug-in.
2394 public static void initializeDefaultPluginPreferences() {
2396 Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
2397 HashSet optionNames = JavaModelManager.OptionNames;
2399 // Compiler settings
2400 preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
2401 optionNames.add(COMPILER_LOCAL_VARIABLE_ATTR);
2403 preferences.setDefault(COMPILER_LINE_NUMBER_ATTR, GENERATE);
2404 optionNames.add(COMPILER_LINE_NUMBER_ATTR);
2406 preferences.setDefault(COMPILER_SOURCE_FILE_ATTR, GENERATE);
2407 optionNames.add(COMPILER_SOURCE_FILE_ATTR);
2409 preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE);
2410 optionNames.add(COMPILER_CODEGEN_UNUSED_LOCAL);
2412 preferences.setDefault(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1);
2413 optionNames.add(COMPILER_CODEGEN_TARGET_PLATFORM);
2415 preferences.setDefault(COMPILER_PB_UNREACHABLE_CODE, ERROR);
2416 optionNames.add(COMPILER_PB_UNREACHABLE_CODE);
2418 preferences.setDefault(COMPILER_PB_INVALID_IMPORT, ERROR);
2419 optionNames.add(COMPILER_PB_INVALID_IMPORT);
2421 preferences.setDefault(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, WARNING);
2422 optionNames.add(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD);
2424 preferences.setDefault(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME, WARNING);
2425 optionNames.add(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME);
2427 preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING);
2428 optionNames.add(COMPILER_PB_DEPRECATION);
2430 preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE, DISABLED);
2431 optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE);
2433 preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING);
2434 optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK);
2436 preferences.setDefault(COMPILER_PB_UNUSED_LOCAL, IGNORE);
2437 optionNames.add(COMPILER_PB_UNUSED_LOCAL);
2439 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE);
2440 optionNames.add(COMPILER_PB_UNUSED_PARAMETER);
2442 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT, DISABLED);
2443 optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT);
2445 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE, DISABLED);
2446 optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE);
2448 preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING);
2449 optionNames.add(COMPILER_PB_UNUSED_IMPORT);
2451 preferences.setDefault(COMPILER_PB_UNUSED_PRIVATE_MEMBER, IGNORE);
2452 optionNames.add(COMPILER_PB_UNUSED_PRIVATE_MEMBER);
2454 preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE);
2455 optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION);
2457 preferences.setDefault(COMPILER_PB_NON_NLS_STRING_LITERAL, IGNORE);
2458 optionNames.add(COMPILER_PB_NON_NLS_STRING_LITERAL);
2460 preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE);
2461 optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER);
2463 preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING);
2464 optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER);
2466 preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING);
2467 optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT);
2469 preferences.setDefault(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD, WARNING);
2470 optionNames.add(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD);
2472 preferences.setDefault(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION, WARNING);
2473 optionNames.add(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION);
2475 preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAG); //$NON-NLS-1$
2476 optionNames.add(COMPILER_TASK_TAGS);
2478 preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITY); //$NON-NLS-1$
2479 optionNames.add(COMPILER_TASK_PRIORITIES);
2481 preferences.setDefault(COMPILER_SOURCE, VERSION_1_3);
2482 optionNames.add(COMPILER_SOURCE);
2484 preferences.setDefault(COMPILER_COMPLIANCE, VERSION_1_3);
2485 optionNames.add(COMPILER_COMPLIANCE);
2487 preferences.setDefault(COMPILER_PB_MAX_PER_UNIT, "100"); //$NON-NLS-1$
2488 optionNames.add(COMPILER_PB_MAX_PER_UNIT);
2491 preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
2492 optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
2494 preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT);
2495 optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH);
2497 preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING);
2498 optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE);
2500 preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN);
2501 optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER);
2503 // JavaCore settings
2504 preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE);
2505 optionNames.add(CORE_JAVA_BUILD_ORDER);
2507 preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR);
2508 optionNames.add(CORE_CIRCULAR_CLASSPATH);
2510 preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR);
2511 optionNames.add(CORE_INCOMPLETE_CLASSPATH);
2513 preferences.setDefault(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, ENABLED);
2514 optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS);
2516 preferences.setDefault(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, ENABLED);
2517 optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS);
2519 // encoding setting comes from resource plug-in
2520 optionNames.add(CORE_ENCODING);
2522 // Formatter settings
2523 preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT);
2524 optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE);
2526 preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT);
2527 optionNames.add(FORMATTER_NEWLINE_CONTROL);
2529 preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE);
2530 optionNames.add(FORMATTER_CLEAR_BLANK_LINES);
2532 preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT);
2533 optionNames.add(FORMATTER_NEWLINE_ELSE_IF);
2535 preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT);
2536 optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK);
2538 preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$
2539 optionNames.add(FORMATTER_LINE_SPLIT);
2541 preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL);
2542 optionNames.add(FORMATTER_COMPACT_ASSIGNMENT);
2544 preferences.setDefault(FORMATTER_TAB_CHAR, TAB);
2545 optionNames.add(FORMATTER_TAB_CHAR);
2547 preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$
2548 optionNames.add(FORMATTER_TAB_SIZE);
2550 preferences.setDefault(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$
2551 optionNames.add(FORMATTER_SPACE_CASTEXPRESSION);
2553 // CodeAssist settings
2554 preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$
2555 optionNames.add(CODEASSIST_VISIBILITY_CHECK);
2557 preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$
2558 optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION);
2560 preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
2561 optionNames.add(CODEASSIST_FIELD_PREFIXES);
2563 preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
2564 optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES);
2566 preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
2567 optionNames.add(CODEASSIST_LOCAL_PREFIXES);
2569 preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
2570 optionNames.add(CODEASSIST_ARGUMENT_PREFIXES);
2572 preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
2573 optionNames.add(CODEASSIST_FIELD_SUFFIXES);
2575 preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
2576 optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES);
2578 preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
2579 optionNames.add(CODEASSIST_LOCAL_SUFFIXES);
2581 preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
2582 optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES);
2586 * Returns whether the given marker references the given Java element.
2587 * Used for markers, which denote a Java element rather than a resource.
2589 * @param element the element
2590 * @param marker the marker
2591 * @return <code>true</code> if the marker references the element, false otherwise
2592 * @exception CoreException if the <code>IMarker.getAttribute</code> on the marker fails
2594 public static boolean isReferencedBy(IJavaElement element, IMarker marker) throws CoreException {
2596 // only match units or classfiles
2597 if (element instanceof IMember){
2598 IMember member = (IMember) element;
2599 if (member.isBinary()){
2600 element = null; //member.getClassFile();
2602 element = member.getCompilationUnit();
2605 if (element == null) return false;
2606 if (marker == null) return false;
2608 String markerHandleId = (String)marker.getAttribute(ATT_HANDLE_ID);
2609 if (markerHandleId == null) return false;
2611 IJavaElement markerElement = JavaCore.create(markerHandleId);
2613 if (element.equals(markerElement)) return true; // external elements may still be equal with different handleIDs.
2615 // cycle through enclosing types in case marker is associated with a classfile (15568)
2616 // if (markerElement instanceof IClassFile){
2617 // IType enclosingType = ((IClassFile)markerElement).getType().getDeclaringType();
2618 // if (enclosingType != null){
2619 // markerElement = enclosingType.getClassFile(); // retry with immediate enclosing classfile
2629 * Returns whether the given marker delta references the given Java element.
2630 * Used for markers deltas, which denote a Java element rather than a resource.
2632 * @param element the element
2633 * @param markerDelta the marker delta
2634 * @return <code>true</code> if the marker delta references the element
2635 * @exception CoreException if the <code>IMarkerDelta.getAttribute</code> on the marker delta fails
2637 public static boolean isReferencedBy(IJavaElement element, IMarkerDelta markerDelta) throws CoreException {
2639 // only match units or classfiles
2640 if (element instanceof IMember){
2641 IMember member = (IMember) element;
2642 if (member.isBinary()){
2643 element = null; //member.getClassFile();
2645 element = member.getCompilationUnit();
2648 if (element == null) return false;
2649 if (markerDelta == null) return false;
2651 String markerDeltarHandleId = (String)markerDelta.getAttribute(ATT_HANDLE_ID);
2652 if (markerDeltarHandleId == null) return false;
2654 IJavaElement markerElement = JavaCore.create(markerDeltarHandleId);
2656 if (element.equals(markerElement)) return true; // external elements may still be equal with different handleIDs.
2658 // cycle through enclosing types in case marker is associated with a classfile (15568)
2659 // if (markerElement instanceof IClassFile){
2660 // IType enclosingType = ((IClassFile)markerElement).getType().getDeclaringType();
2661 // if (enclosingType != null){
2662 // markerElement = enclosingType.getClassFile(); // retry with immediate enclosing classfile
2672 * Creates and returns a new classpath entry of kind <code>CPE_CONTAINER</code>
2673 * for the given path. The path of the container will be used during resolution so as to map this
2674 * container entry to a set of other classpath entries the container is acting for.
2676 * A container entry allows to express indirect references to a set of libraries, projects and variable entries,
2677 * which can be interpreted differently for each Java project where it is used.
2678 * A classpath container entry can be resolved using <code>JavaCore.getResolvedClasspathContainer</code>,
2679 * and updated with <code>JavaCore.classpathContainerChanged</code>
2681 * A container is exclusively resolved by a <code>ClasspathContainerInitializer</code> registered onto the
2682 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
2684 * A container path must be formed of at least one segment, where: <ul>
2685 * <li> the first segment is a unique ID identifying the target container, there must be a container initializer registered
2686 * onto this ID through the extension point "org.eclipse.jdt.core.classpathContainerInitializer". </li>
2687 * <li> the remaining segments will be passed onto the initializer, and can be used as additional
2688 * hints during the initialization phase. </li>
2691 * Example of an ClasspathContainerInitializer for a classpath container denoting a default JDK container:
2693 * containerEntry = JavaCore.newContainerEntry(new Path("MyProvidedJDK/default"));
2696 * point="org.eclipse.jdt.core.classpathContainerInitializer">
2697 * <containerInitializer
2698 * id="MyProvidedJDK"
2699 * class="com.example.MyInitializer"/>
2701 * Note that this operation does not attempt to validate classpath containers
2702 * or access the resources at the given paths.
2704 * The resulting entry is not exported to dependent projects. This method is equivalent to
2705 * <code>newContainerEntry(-,false)</code>.
2707 * @param containerPath the path identifying the container, it must be formed of two
2709 * @return a new container classpath entry
2711 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
2712 * @see JavaCore#newContainerEntry(IPath, boolean)
2715 public static IClasspathEntry newContainerEntry(IPath containerPath) {
2717 return newContainerEntry(containerPath, false);
2721 * Creates and returns a new classpath entry of kind <code>CPE_CONTAINER</code>
2722 * for the given path. The path of the container will be used during resolution so as to map this
2723 * container entry to a set of other classpath entries the container is acting for.
2725 * A container entry allows to express indirect references to a set of libraries, projects and variable entries,
2726 * which can be interpreted differently for each Java project where it is used.
2727 * A classpath container entry can be resolved using <code>JavaCore.getResolvedClasspathContainer</code>,
2728 * and updated with <code>JavaCore.classpathContainerChanged</code>
2730 * A container is exclusively resolved by a <code>ClasspathContainerInitializer</code> registered onto the
2731 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
2733 * A container path must be formed of at least one segment, where: <ul>
2734 * <li> the first segment is a unique ID identifying the target container, there must be a container initializer registered
2735 * onto this ID through the extension point "org.eclipse.jdt.core.classpathContainerInitializer". </li>
2736 * <li> the remaining segments will be passed onto the initializer, and can be used as additional
2737 * hints during the initialization phase. </li>
2740 * Example of an ClasspathContainerInitializer for a classpath container denoting a default JDK container:
2742 * containerEntry = JavaCore.newContainerEntry(new Path("MyProvidedJDK/default"));
2745 * point="org.eclipse.jdt.core.classpathContainerInitializer">
2746 * <containerInitializer
2747 * id="MyProvidedJDK"
2748 * class="com.example.MyInitializer"/>
2750 * Note that this operation does not attempt to validate classpath containers
2751 * or access the resources at the given paths.
2753 * @param containerPath the path identifying the container, it must be formed of at least
2754 * one segment (ID+hints)
2755 * @param isExported a boolean indicating whether this entry is contributed to dependent
2756 * projects in addition to the output location
2757 * @return a new container classpath entry
2759 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
2760 * @see JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor)
2761 * @see JavaCore#newContainerEntry(IPath, boolean)
2764 public static IClasspathEntry newContainerEntry(IPath containerPath, boolean isExported) {
2766 if (containerPath == null || containerPath.segmentCount() < 1) {
2769 "Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$
2771 return new ClasspathEntry(
2772 IPackageFragmentRoot.K_SOURCE,
2773 IClasspathEntry.CPE_CONTAINER,
2775 ClasspathEntry.NO_EXCLUSION_PATTERNS,
2776 null, // source attachment
2777 null, // source attachment root
2778 null, // specific output folder
2783 * Creates and returns a new non-exported classpath entry of kind <code>CPE_LIBRARY</code> for the
2784 * JAR or folder identified by the given absolute path. This specifies that all package fragments
2785 * within the root will have children of type <code>IClassFile</code>.
2787 * A library entry is used to denote a prerequisite JAR or root folder containing binaries.
2788 * The target JAR or folder can either be defined internally to the workspace (absolute path relative
2789 * to the workspace root) or externally to the workspace (absolute path in the file system).
2791 * e.g. Here are some examples of binary path usage<ul>
2792 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code> - reference to an external JAR</li>
2793 * <li><code> "/Project/someLib.jar" </code> - reference to an internal JAR </li>
2794 * <li><code> "c:/classes/" </code> - reference to an external binary folder</li>
2796 * Note that this operation does not attempt to validate or access the
2797 * resources at the given paths.
2799 * The resulting entry is not exported to dependent projects. This method is equivalent to
2800 * <code>newLibraryEntry(-,-,-,false)</code>.
2803 * @param path the absolute path of the binary archive
2804 * @param sourceAttachmentPath the absolute path of the corresponding source archive or folder,
2805 * or <code>null</code> if none
2806 * @param sourceAttachmentRootPath the location of the root within the source archive or folder
2807 * or <code>null</code> if this location should be automatically detected.
2808 * @return a new library classpath entry
2810 * @see #newLibraryEntry(IPath, IPath, IPath, boolean)
2812 //public static IClasspathEntry newLibraryEntry(
2814 // IPath sourceAttachmentPath,
2815 // IPath sourceAttachmentRootPath) {
2817 // return newLibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath, false);
2821 * Creates and returns a new classpath entry of kind <code>CPE_LIBRARY</code> for the JAR or folder
2822 * identified by the given absolute path. This specifies that all package fragments within the root
2823 * will have children of type <code>IClassFile</code>.
2825 * A library entry is used to denote a prerequisite JAR or root folder containing binaries.
2826 * The target JAR or folder can either be defined internally to the workspace (absolute path relative
2827 * to the workspace root) or externally to the workspace (absolute path in the file system).
2829 * e.g. Here are some examples of binary path usage<ul>
2830 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code> - reference to an external JAR</li>
2831 * <li><code> "/Project/someLib.jar" </code> - reference to an internal JAR </li>
2832 * <li><code> "c:/classes/" </code> - reference to an external binary folder</li>
2834 * Note that this operation does not attempt to validate or access the
2835 * resources at the given paths.
2838 * @param path the absolute path of the binary archive
2839 * @param sourceAttachmentPath the absolute path of the corresponding source archive or folder,
2840 * or <code>null</code> if none
2841 * @param sourceAttachmentRootPath the location of the root within the source archive or folder
2842 * or <code>null</code> if this location should be automatically detected.
2843 * @param isExported indicates whether this entry is contributed to dependent
2844 * projects in addition to the output location
2845 * @return a new library classpath entry
2848 //public static IClasspathEntry newLibraryEntry(
2850 // IPath sourceAttachmentPath,
2851 // IPath sourceAttachmentRootPath,
2852 // boolean isExported) {
2854 // if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
2856 // return new ClasspathEntry(
2857 // IPackageFragmentRoot.K_BINARY,
2858 // IClasspathEntry.CPE_LIBRARY,
2859 // JavaProject.canonicalizedPath(path),
2860 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
2861 // sourceAttachmentPath,
2862 // sourceAttachmentRootPath,
2863 // null, // specific output folder
2868 * Creates and returns a new non-exported classpath entry of kind <code>CPE_PROJECT</code>
2869 * for the project identified by the given absolute path.
2871 * A project entry is used to denote a prerequisite project on a classpath.
2872 * The referenced project will be contributed as a whole, either as sources (in the Java Model, it
2873 * contributes all its package fragment roots) or as binaries (when building, it contributes its
2874 * whole output location).
2876 * A project reference allows to indirect through another project, independently from its internal layout.
2878 * The prerequisite project is referred to using an absolute path relative to the workspace root.
2880 * The resulting entry is not exported to dependent projects. This method is equivalent to
2881 * <code>newProjectEntry(_,false)</code>.
2884 * @param path the absolute path of the binary archive
2885 * @return a new project classpath entry
2887 * @see JavaCore#newProjectEntry(IPath, boolean)
2889 public static IClasspathEntry newProjectEntry(IPath path) {
2890 return newProjectEntry(path, false);
2894 * Creates and returns a new classpath entry of kind <code>CPE_PROJECT</code>
2895 * for the project identified by the given absolute path.
2897 * A project entry is used to denote a prerequisite project on a classpath.
2898 * The referenced project will be contributed as a whole, either as sources (in the Java Model, it
2899 * contributes all its package fragment roots) or as binaries (when building, it contributes its
2900 * whole output location).
2902 * A project reference allows to indirect through another project, independently from its internal layout.
2904 * The prerequisite project is referred to using an absolute path relative to the workspace root.
2907 * @param path the absolute path of the prerequisite project
2908 * @param isExported indicates whether this entry is contributed to dependent
2909 * projects in addition to the output location
2910 * @return a new project classpath entry
2913 public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) {
2915 if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
2917 return new ClasspathEntry(
2918 IPackageFragmentRoot.K_SOURCE,
2919 IClasspathEntry.CPE_PROJECT,
2921 ClasspathEntry.NO_EXCLUSION_PATTERNS,
2922 null, // source attachment
2923 null, // source attachment root
2924 null, // specific output folder
2929 * Returns a new empty region.
2931 * @return a new empty region
2933 public static IRegion newRegion() {
2934 return new Region();
2938 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
2939 * for the project's source folder identified by the given absolute
2940 * workspace-relative path. This specifies that all package fragments
2941 * within the root will have children of type <code>ICompilationUnit</code>.
2943 * The source folder is referred to using an absolute path relative to the
2944 * workspace root, e.g. <code>/Project/src</code>. A project's source
2945 * folders are located with that project. That is, a source classpath
2946 * entry specifying the path <code>/P1/src</code> is only usable for
2947 * project <code>P1</code>.
2950 * The source classpath entry created by this method includes all source
2951 * files below the given workspace-relative path. To selectively exclude
2952 * some of these source files, use the factory method
2953 * <code>JavaCore.newSourceEntry(IPath,IPath[])</code> instead.
2956 * Note that all sources/binaries inside a project are contributed as a whole through
2957 * a project entry (see <code>JavaCore.newProjectEntry</code>). Particular
2958 * source entries cannot be selectively exported.
2961 * @param path the absolute workspace-relative path of a source folder
2962 * @return a new source classpath entry with not exclusion patterns
2964 * @see #newSourceEntry(org.eclipse.core.runtime.IPath,org.eclipse.core.runtime.IPath[])
2966 public static IClasspathEntry newSourceEntry(IPath path) {
2968 return newSourceEntry(path, ClasspathEntry.NO_EXCLUSION_PATTERNS, null /*output location*/);
2972 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
2973 * for the project's source folder identified by the given absolute
2974 * workspace-relative path but excluding all source files with paths
2975 * matching any of the given patterns. This specifies that all package
2976 * fragments within the root will have children of type
2977 * <code>ICompilationUnit</code>.
2979 * The source folder is referred to using an absolute path relative to the
2980 * workspace root, e.g. <code>/Project/src</code>. A project's source
2981 * folders are located with that project. That is, a source classpath
2982 * entry specifying the path <code>/P1/src</code> is only usable for
2983 * project <code>P1</code>.
2986 * The source classpath entry created by this method includes all source
2987 * files below the given workspace-relative path except for those matched
2988 * by one (or more) of the given exclusion patterns. Each exclusion pattern
2989 * is represented by a relative path, which is interpreted as relative to
2990 * the source folder. For example, if the source folder path is
2991 * <code>/Project/src</code> and the exclusion pattern is
2992 * <code>com/xyz/tests/**</code>, then source files
2993 * like <code>/Project/src/com/xyz/Foo.java</code>
2994 * and <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
2995 * whereas <code>/Project/src/com/xyz/tests/T1.java</code>
2996 * and <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
2997 * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
2998 * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code>
2999 * for the full description of the syntax and semantics of exclusion
3002 * If the empty list of exclusion patterns is specified, the source folder
3003 * will automatically include all resources located inside the source
3004 * folder. In that case, the result is entirely equivalent to using the
3005 * factory method <code>JavaCore.newSourceEntry(IPath)</code>.
3008 * Note that all sources/binaries inside a project are contributed as a whole through
3009 * a project entry (see <code>JavaCore.newProjectEntry</code>). Particular
3010 * source entries cannot be selectively exported.
3013 * @param path the absolute workspace-relative path of a source folder
3014 * @param exclusionPatterns the possibly empty list of exclusion patterns
3015 * represented as relative paths
3016 * @return a new source classpath entry with the given exclusion patterns
3017 * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
3018 * @see IClasspathEntry#getExclusionPatterns
3022 public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns) {
3024 return newSourceEntry(path, exclusionPatterns, null /*output location*/);
3028 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3029 * for the project's source folder identified by the given absolute
3030 * workspace-relative path but excluding all source files with paths
3031 * matching any of the given patterns, and associated with a specific output location
3032 * (that is, ".class" files are not going to the project default output location).
3033 * All package fragments within the root will have children of type
3034 * <code>ICompilationUnit</code>.
3036 * The source folder is referred to using an absolute path relative to the
3037 * workspace root, e.g. <code>/Project/src</code>. A project's source
3038 * folders are located with that project. That is, a source classpath
3039 * entry specifying the path <code>/P1/src</code> is only usable for
3040 * project <code>P1</code>.
3043 * The source classpath entry created by this method includes all source
3044 * files below the given workspace-relative path except for those matched
3045 * by one (or more) of the given exclusion patterns. Each exclusion pattern
3046 * is represented by a relative path, which is interpreted as relative to
3047 * the source folder. For example, if the source folder path is
3048 * <code>/Project/src</code> and the exclusion pattern is
3049 * <code>com/xyz/tests/**</code>, then source files
3050 * like <code>/Project/src/com/xyz/Foo.java</code>
3051 * and <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3052 * whereas <code>/Project/src/com/xyz/tests/T1.java</code>
3053 * and <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3054 * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
3055 * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code>
3056 * for the full description of the syntax and semantics of exclusion
3059 * If the empty list of exclusion patterns is specified, the source folder
3060 * will automatically include all resources located inside the source
3061 * folder. In that case, the result is entirely equivalent to using the
3062 * factory method <code>JavaCore.newSourceEntry(IPath)</code>.
3065 * Additionally, a source entry can be associated with a specific output location.
3066 * By doing so, the Java builder will ensure that the generated ".class" files will
3067 * be issued inside this output location, as opposed to be generated into the
3068 * project default output location (when output location is <code>null</code>).
3069 * Note that multiple source entries may target the same output location.
3070 * The output location is referred to using an absolute path relative to the
3071 * workspace root, e.g. <code>"/Project/bin"</code>, it must be located inside
3072 * the same project as the source folder.
3075 * Also note that all sources/binaries inside a project are contributed as a whole through
3076 * a project entry (see <code>JavaCore.newProjectEntry</code>). Particular
3077 * source entries cannot be selectively exported.
3080 * @param path the absolute workspace-relative path of a source folder
3081 * @param exclusionPatterns the possibly empty list of exclusion patterns
3082 * represented as relative paths
3083 * @param outputLocation the specific output location for this source entry (<code>null</code> if using project default ouput location)
3084 * @return a new source classpath entry with the given exclusion patterns
3085 * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
3086 * @see IClasspathEntry#getExclusionPatterns
3087 * @see IClasspathEntry#getOutputLocation()
3091 public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns, IPath specificOutputLocation) {
3093 if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3094 if (exclusionPatterns == null) Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$
3096 return new ClasspathEntry(
3097 IPackageFragmentRoot.K_SOURCE,
3098 IClasspathEntry.CPE_SOURCE,
3101 null, // source attachment
3102 null, // source attachment root
3103 specificOutputLocation, // custom output location
3108 * Creates and returns a new non-exported classpath entry of kind <code>CPE_VARIABLE</code>
3109 * for the given path. The first segment of the path is the name of a classpath variable.
3110 * The trailing segments of the path will be appended to resolved variable path.
3112 * A variable entry allows to express indirect references on a classpath to other projects or libraries,
3113 * depending on what the classpath variable is referring.
3115 * It is possible to register an automatic initializer (<code>ClasspathVariableInitializer</code>),
3116 * which will be invoked through the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
3117 * After resolution, a classpath variable entry may either correspond to a project or a library entry. </li>
3119 * e.g. Here are some examples of variable path usage<ul>
3120 * <li> "JDTCORE" where variable <code>JDTCORE</code> is
3121 * bound to "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the library "c:\jars\jdtcore.jar"</li>
3122 * <li> "JDTCORE" where variable <code>JDTCORE</code> is
3123 * bound to "/Project_JDTCORE". The resolved classpath entry is denoting the project "/Project_JDTCORE"</li>
3124 * <li> "PLUGINS/com.example/example.jar" where variable <code>PLUGINS</code>
3125 * is bound to "c:/eclipse/plugins". The resolved classpath entry is denoting the library "c:/eclipse/plugins/com.example/example.jar"</li>
3127 * Note that this operation does not attempt to validate classpath variables
3128 * or access the resources at the given paths.
3130 * The resulting entry is not exported to dependent projects. This method is equivalent to
3131 * <code>newVariableEntry(-,-,-,false)</code>.
3134 * @param variablePath the path of the binary archive; first segment is the
3135 * name of a classpath variable
3136 * @param variableSourceAttachmentPath the path of the corresponding source archive,
3137 * or <code>null</code> if none; if present, the first segment is the
3138 * name of a classpath variable (not necessarily the same variable
3139 * as the one that begins <code>variablePath</code>)
3140 * @param sourceAttachmentRootPath the location of the root within the source archive
3141 * or <code>null</code> if <code>archivePath</code> is also <code>null</code>
3142 * @return a new library classpath entry
3144 * @see JavaCore#newVariableEntry(IPath, IPath, IPath, boolean)
3146 //public static IClasspathEntry newVariableEntry(
3147 // IPath variablePath,
3148 // IPath variableSourceAttachmentPath,
3149 // IPath sourceAttachmentRootPath) {
3151 // return newVariableEntry(variablePath, variableSourceAttachmentPath, sourceAttachmentRootPath, false);
3155 * Creates and returns a new non-exported classpath entry of kind <code>CPE_VARIABLE</code>
3156 * for the given path. The first segment of the path is the name of a classpath variable.
3157 * The trailing segments of the path will be appended to resolved variable path.
3159 * A variable entry allows to express indirect references on a classpath to other projects or libraries,
3160 * depending on what the classpath variable is referring.
3162 * It is possible to register an automatic initializer (<code>ClasspathVariableInitializer</code>),
3163 * which will be invoked through the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
3164 * After resolution, a classpath variable entry may either correspond to a project or a library entry. </li>
3166 * e.g. Here are some examples of variable path usage<ul>
3167 * <li> "JDTCORE" where variable <code>JDTCORE</code> is
3168 * bound to "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the library "c:\jars\jdtcore.jar"</li>
3169 * <li> "JDTCORE" where variable <code>JDTCORE</code> is
3170 * bound to "/Project_JDTCORE". The resolved classpath entry is denoting the project "/Project_JDTCORE"</li>
3171 * <li> "PLUGINS/com.example/example.jar" where variable <code>PLUGINS</code>
3172 * is bound to "c:/eclipse/plugins". The resolved classpath entry is denoting the library "c:/eclipse/plugins/com.example/example.jar"</li>
3174 * Note that this operation does not attempt to validate classpath variables
3175 * or access the resources at the given paths.
3178 * @param variablePath the path of the binary archive; first segment is the
3179 * name of a classpath variable
3180 * @param variableSourceAttachmentPath the path of the corresponding source archive,
3181 * or <code>null</code> if none; if present, the first segment is the
3182 * name of a classpath variable (not necessarily the same variable
3183 * as the one that begins <code>variablePath</code>)
3184 * @param sourceAttachmentRootPath the location of the root within the source archive
3185 * or <code>null</code> if <code>archivePath</code> is also <code>null</code>
3186 * @param isExported indicates whether this entry is contributed to dependent
3187 * projects in addition to the output location
3188 * @return a new variable classpath entry
3191 //public static IClasspathEntry newVariableEntry(
3192 // IPath variablePath,
3193 // IPath variableSourceAttachmentPath,
3194 // IPath variableSourceAttachmentRootPath,
3195 // boolean isExported) {
3197 // if (variablePath == null || variablePath.segmentCount() < 1) {
3200 // "Illegal classpath variable path: \'" + variablePath.makeRelative().toString() + "\', must have at least one segment"); //$NON-NLS-1$//$NON-NLS-2$
3203 // return new ClasspathEntry(
3204 // IPackageFragmentRoot.K_SOURCE,
3205 // IClasspathEntry.CPE_VARIABLE,
3207 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3208 // variableSourceAttachmentPath, // source attachment
3209 // variableSourceAttachmentRootPath, // source attachment root
3210 // null, // specific output folder
3215 * Removed the given classpath variable. Does nothing if no value was
3216 * set for this classpath variable.
3218 * This functionality cannot be used while the resource tree is locked.
3220 * Classpath variable values are persisted locally to the workspace, and
3221 * are preserved from session to session.
3224 * @param variableName the name of the classpath variable
3225 * @see #setClasspathVariable
3227 * @deprecated - use version with extra IProgressMonitor
3229 //public static void removeClasspathVariable(String variableName) {
3230 // removeClasspathVariable(variableName, null);
3234 * Removed the given classpath variable. Does nothing if no value was
3235 * set for this classpath variable.
3237 * This functionality cannot be used while the resource tree is locked.
3239 * Classpath variable values are persisted locally to the workspace, and
3240 * are preserved from session to session.
3243 * @param variableName the name of the classpath variable
3244 * @param monitor the progress monitor to report progress
3245 * @see #setClasspathVariable
3247 //public static void removeClasspathVariable(
3248 // String variableName,
3249 // IProgressMonitor monitor) {
3252 // updateVariableValues(new String[]{ variableName}, new IPath[]{ null }, monitor);
3253 // } catch (JavaModelException e) {
3258 * Removes the given element changed listener.
3259 * Has no affect if an identical listener is not registered.
3261 * @param listener the listener
3263 public static void removeElementChangedListener(IElementChangedListener listener) {
3264 JavaModelManager.getJavaModelManager().removeElementChangedListener(listener);
3268 * Bind a container reference path to some actual containers (<code>IClasspathContainer</code>).
3269 * This API must be invoked whenever changes in container need to be reflected onto the JavaModel.
3270 * Containers can have distinct values in different projects, therefore this API considers a
3271 * set of projects with their respective containers.
3273 * <code>containerPath</code> is the path under which these values can be referenced through
3274 * container classpath entries (<code>IClasspathEntry#CPE_CONTAINER</code>). A container path
3275 * is formed by a first ID segment followed with extra segments, which can be used as additional hints
3276 * for the resolution. The container ID is used to identify a <code>ClasspathContainerInitializer</code>
3277 * registered on the extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3279 * There is no assumption that each individual container value passed in argument
3280 * (<code>respectiveContainers</code>) must answer the exact same path when requested
3281 * <code>IClasspathContainer#getPath</code>.
3282 * Indeed, the containerPath is just an indication for resolving it to an actual container object. It can be
3283 * delegated to a <code>ClasspathContainerInitializer</code>, which can be activated through the extension
3284 * point "org.eclipse.jdt.core.ClasspathContainerInitializer").
3286 * In reaction to changing container values, the JavaModel will be updated to reflect the new
3287 * state of the updated container.
3289 * This functionality cannot be used while the resource tree is locked.
3291 * Classpath container values are persisted locally to the workspace, but
3292 * are not preserved from a session to another. It is thus highly recommended to register a
3293 * <code>ClasspathContainerInitializer</code> for each referenced container
3294 * (through the extension point "org.eclipse.jdt.core.ClasspathContainerInitializer").
3296 * Note: setting a container to <code>null</code> will cause it to be lazily resolved again whenever
3297 * its value is required. In particular, this will cause a registered initializer to be invoked
3300 * @param containerPath - the name of the container reference, which is being updated
3301 * @param affectedProjects - the set of projects for which this container is being bound
3302 * @param respectiveContainers - the set of respective containers for the affected projects
3303 * @param monitor a monitor to report progress
3305 * @see ClasspathContainerInitializer
3306 * @see #getClasspathContainer(IPath, IJavaProject)
3307 * @see IClasspathContainer
3310 //public static void setClasspathContainer(final IPath containerPath, IJavaProject[] affectedProjects, IClasspathContainer[] respectiveContainers, IProgressMonitor monitor) throws JavaModelException {
3312 // if (affectedProjects.length != respectiveContainers.length) Assert.isTrue(false, "Projects and containers collections should have the same size"); //$NON-NLS-1$
3314 // if (monitor != null && monitor.isCanceled()) return;
3316 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3317 // System.out.println("CPContainer SET - setting container: ["+containerPath+"] for projects: {" //$NON-NLS-1$ //$NON-NLS-2$
3318 // + (Util.toString(affectedProjects,
3319 // new Util.Displayable(){
3320 // public String displayString(Object o) { return ((IJavaProject) o).getElementName(); }
3322 // + "} with values: " //$NON-NLS-1$
3323 // + (Util.toString(respectiveContainers,
3324 // new Util.Displayable(){
3325 // public String displayString(Object o) { return ((IClasspathContainer) o).getDescription(); }
3330 // final int projectLength = affectedProjects.length;
3331 // final IJavaProject[] modifiedProjects;
3332 // System.arraycopy(affectedProjects, 0, modifiedProjects = new IJavaProject[projectLength], 0, projectLength);
3333 // final IClasspathEntry[][] oldResolvedPaths = new IClasspathEntry[projectLength][];
3335 // // filter out unmodified project containers
3336 // int remaining = 0;
3337 // for (int i = 0; i < projectLength; i++){
3339 // if (monitor != null && monitor.isCanceled()) return;
3341 // IJavaProject affectedProject = affectedProjects[i];
3342 // IClasspathContainer newContainer = respectiveContainers[i];
3343 // if (newContainer == null) newContainer = JavaModelManager.ContainerInitializationInProgress; // 30920 - prevent infinite loop
3344 // boolean found = false;
3345 // if (JavaProject.hasJavaNature(affectedProject.getProject())){
3346 // IClasspathEntry[] rawClasspath = affectedProject.getRawClasspath();
3347 // for (int j = 0, cpLength = rawClasspath.length; j <cpLength; j++) {
3348 // IClasspathEntry entry = rawClasspath[j];
3349 // if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER && entry.getPath().equals(containerPath)){
3356 // modifiedProjects[i] = null; // filter out this project - does not reference the container path, or isnt't yet Java project
3357 // JavaModelManager.containerPut(affectedProject, containerPath, newContainer);
3360 // IClasspathContainer oldContainer = JavaModelManager.containerGet(affectedProject, containerPath);
3361 // if (oldContainer == JavaModelManager.ContainerInitializationInProgress) {
3362 // Map previousContainerValues = (Map)JavaModelManager.PreviousSessionContainers.get(affectedProject);
3363 // if (previousContainerValues != null){
3364 // IClasspathContainer previousContainer = (IClasspathContainer)previousContainerValues.get(containerPath);
3365 // if (previousContainer != null) {
3366 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3367 // 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$
3369 // JavaModelManager.containerPut(affectedProject, containerPath, previousContainer);
3371 // oldContainer = null; //33695 - cannot filter out restored container, must update affected project to reset cached CP
3373 // oldContainer = null;
3376 // if (oldContainer != null && oldContainer.equals(respectiveContainers[i])){// TODO: could improve to only compare entries
3377 // modifiedProjects[i] = null; // filter out this project - container did not change
3381 // oldResolvedPaths[i] = affectedProject.getResolvedClasspath(true);
3382 // JavaModelManager.containerPut(affectedProject, containerPath, newContainer);
3385 // if (remaining == 0) return;
3387 // // trigger model refresh
3389 // JavaCore.run(new IWorkspaceRunnable() {
3390 // public void run(IProgressMonitor monitor) throws CoreException {
3391 // for(int i = 0; i < projectLength; i++){
3393 // if (monitor != null && monitor.isCanceled()) return;
3395 // JavaProject affectedProject = (JavaProject)modifiedProjects[i];
3396 // if (affectedProject == null) continue; // was filtered out
3398 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3399 // System.out.println("CPContainer SET - updating affected project: ["+affectedProject.getElementName()+"] due to setting container: " + containerPath); //$NON-NLS-1$ //$NON-NLS-2$
3402 // // force a refresh of the affected project (will compute deltas)
3403 // affectedProject.setRawClasspath(
3404 // affectedProject.getRawClasspath(),
3405 // SetClasspathOperation.ReuseOutputLocation,
3407 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can save resources
3408 // oldResolvedPaths[i],
3409 // false, // updating - no validation
3410 // false); // updating - no need to save
3415 // } catch(CoreException e) {
3416 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3417 // System.out.println("CPContainer SET - FAILED DUE TO EXCEPTION: "+containerPath); //$NON-NLS-1$
3418 // e.printStackTrace();
3420 // if (e instanceof JavaModelException) {
3421 // throw (JavaModelException)e;
3423 // throw new JavaModelException(e);
3426 // for (int i = 0; i < projectLength; i++) {
3427 // if (respectiveContainers[i] == null) {
3428 // JavaModelManager.containerPut(affectedProjects[i], containerPath, null); // reset init in progress marker
3436 * Sets the value of the given classpath variable.
3437 * The path must have at least one segment.
3439 * This functionality cannot be used while the resource tree is locked.
3441 * Classpath variable values are persisted locally to the workspace, and
3442 * are preserved from session to session.
3445 * @param variableName the name of the classpath variable
3446 * @param path the path
3447 * @see #getClasspathVariable
3449 * @deprecated - use API with IProgressMonitor
3451 //public static void setClasspathVariable(String variableName, IPath path)
3452 // throws JavaModelException {
3454 // setClasspathVariable(variableName, path, null);
3458 * Sets the value of the given classpath variable.
3459 * The path must not be null.
3461 * This functionality cannot be used while the resource tree is locked.
3463 * Classpath variable values are persisted locally to the workspace, and
3464 * are preserved from session to session.
3466 * Updating a variable with the same value has no effect.
3468 * @param variableName the name of the classpath variable
3469 * @param path the path
3470 * @param monitor a monitor to report progress
3471 * @see #getClasspathVariable
3473 //public static void setClasspathVariable(
3474 // String variableName,
3476 // IProgressMonitor monitor)
3477 // throws JavaModelException {
3479 // if (path == null) Assert.isTrue(false, "Variable path cannot be null"); //$NON-NLS-1$
3480 // setClasspathVariables(new String[]{variableName}, new IPath[]{ path }, monitor);
3484 * Sets the values of all the given classpath variables at once.
3485 * Null paths can be used to request corresponding variable removal.
3487 * This functionality cannot be used while the resource tree is locked.
3489 * Classpath variable values are persisted locally to the workspace, and
3490 * are preserved from session to session.
3492 * Updating a variable with the same value has no effect.
3494 * @param variableNames an array of names for the updated classpath variables
3495 * @param paths an array of path updates for the modified classpath variables (null
3496 * meaning that the corresponding value will be removed
3497 * @param monitor a monitor to report progress
3498 * @see #getClasspathVariable
3501 //public static void setClasspathVariables(
3502 // String[] variableNames,
3504 // IProgressMonitor monitor)
3505 // throws JavaModelException {
3507 // if (variableNames.length != paths.length) Assert.isTrue(false, "Variable names and paths collections should have the same size"); //$NON-NLS-1$
3508 // //TODO: should check that null cannot be used as variable paths
3509 // updateVariableValues(variableNames, paths, monitor);
3513 * Method declared on IExecutableExtension.
3514 * Record any necessary initialization data from the plugin.
3516 public void setInitializationData(
3517 IConfigurationElement cfig,
3518 String propertyName,
3520 throws CoreException {
3524 * Sets the current table of options. All and only the options explicitly included in the given table
3525 * are remembered; all previous option settings are forgotten, including ones not explicitly
3528 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
3531 * @param newOptions the new options (key type: <code>String</code>; value type: <code>String</code>),
3532 * or <code>null</code> to reset all options to their default values
3533 * @see JavaCore#getDefaultOptions
3535 public static void setOptions(Hashtable newOptions) {
3537 // see #initializeDefaultPluginPreferences() for changing default settings
3538 Preferences preferences = getPlugin().getPluginPreferences();
3540 if (newOptions == null){
3541 newOptions = JavaCore.getDefaultOptions();
3543 Enumeration keys = newOptions.keys();
3544 while (keys.hasMoreElements()){
3545 String key = (String)keys.nextElement();
3546 if (!JavaModelManager.OptionNames.contains(key)) continue; // unrecognized option
3547 if (key.equals(CORE_ENCODING)) continue; // skipped, contributed by resource prefs
3548 String value = (String)newOptions.get(key);
3549 preferences.setValue(key, value);
3553 getPlugin().savePluginPreferences();
3557 * Shutdown the JavaCore plug-in.
3559 * De-registers the JavaModelManager as a resource changed listener and save participant.
3561 * @see org.eclipse.core.runtime.Plugin#shutdown()
3563 // moved to PHPeclipsePlugin#shutdown()
3564 //public void shutdown() {
3566 // //savePluginPreferences();
3567 // getPlugin().savePluginPreferences();
3568 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
3569 // workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaProcessor);
3570 // workspace.removeSaveParticipant(PHPeclipsePlugin.getDefault());
3572 // ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown();
3576 * Initiate the background indexing process.
3577 * This should be deferred after the plugin activation.
3579 //private void startIndexing() {
3581 // JavaModelManager.getJavaModelManager().getIndexManager().reset();
3585 * Startup of the JavaCore plug-in.
3587 * Registers the JavaModelManager as a resource changed listener and save participant.
3588 * Starts the background indexing, and restore saved classpath variable values.
3590 * @see org.eclipse.core.runtime.Plugin#startup()
3593 // moved to PHPeclipsePlugin#startup()
3594 //public void startup() {
3596 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
3598 // manager.configurePluginDebugOptions();
3600 // // request state folder creation (workaround 19885)
3601 // JavaCore.getPlugin().getStateLocation();
3603 // // retrieve variable values
3604 // JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new JavaModelManager.PluginPreferencesListener());
3605 //// TODO khartlage temp-del
3606 //// manager.loadVariablesAndContainers();
3608 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
3609 // workspace.addResourceChangeListener(
3610 // manager.deltaProcessor,
3611 // IResourceChangeEvent.PRE_AUTO_BUILD
3612 // | IResourceChangeEvent.POST_AUTO_BUILD
3613 // | IResourceChangeEvent.POST_CHANGE
3614 // | IResourceChangeEvent.PRE_DELETE
3615 // | IResourceChangeEvent.PRE_CLOSE);
3617 //// startIndexing();
3618 // workspace.addSaveParticipant(PHPeclipsePlugin.getDefault(), manager);
3620 // } catch (CoreException e) {
3621 // } catch (RuntimeException e) {
3622 // manager.shutdown();
3629 * Internal updating of a variable values (null path meaning removal), allowing to change multiple variable values at once.
3631 //private static void updateVariableValues(
3632 // String[] variableNames,
3633 // IPath[] variablePaths,
3634 // IProgressMonitor monitor) throws JavaModelException {
3636 // if (monitor != null && monitor.isCanceled()) return;
3638 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3639 // System.out.println("CPVariable SET - setting variables: {" + Util.toString(variableNames) //$NON-NLS-1$
3640 // + "} with values: " + Util.toString(variablePaths)); //$NON-NLS-1$
3643 // int varLength = variableNames.length;
3645 // // gather classpath information for updating
3646 // final HashMap affectedProjects = new HashMap(5);
3647 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
3648 // IJavaModel model = manager.getJavaModel();
3650 // // filter out unmodified variables
3651 // int discardCount = 0;
3652 // for (int i = 0; i < varLength; i++){
3653 // String variableName = variableNames[i];
3654 // IPath oldPath = (IPath)JavaModelManager.variableGet(variableName); // if reentering will provide previous session value
3655 // if (oldPath == JavaModelManager.VariableInitializationInProgress){
3656 // IPath previousPath = (IPath)JavaModelManager.PreviousSessionVariables.get(variableName);
3657 // if (previousPath != null){
3658 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3659 // System.out.println("CPVariable INIT - reentering access to variable: " + variableName+ " during its initialization, will see previous value: "+ previousPath); //$NON-NLS-1$ //$NON-NLS-2$
3661 // JavaModelManager.variablePut(variableName, previousPath); // replace value so reentering calls are seeing old value
3663 // oldPath = null; //33695 - cannot filter out restored variable, must update affected project to reset cached CP
3665 // if (oldPath != null && oldPath.equals(variablePaths[i])){
3666 // variableNames[i] = null;
3670 // if (discardCount > 0){
3671 // if (discardCount == varLength) return;
3672 // int changedLength = varLength - discardCount;
3673 // String[] changedVariableNames = new String[changedLength];
3674 // IPath[] changedVariablePaths = new IPath[changedLength];
3675 // for (int i = 0, index = 0; i < varLength; i++){
3676 // if (variableNames[i] != null){
3677 // changedVariableNames[index] = variableNames[i];
3678 // changedVariablePaths[index] = variablePaths[i];
3682 // variableNames = changedVariableNames;
3683 // variablePaths = changedVariablePaths;
3684 // varLength = changedLength;
3687 // if (monitor != null && monitor.isCanceled()) return;
3689 // if (model != null) {
3690 // IJavaProject[] projects = model.getJavaProjects();
3691 // nextProject : for (int i = 0, projectLength = projects.length; i < projectLength; i++){
3692 // IJavaProject project = projects[i];
3694 // // check to see if any of the modified variables is present on the classpath
3695 // IClasspathEntry[] classpath = project.getRawClasspath();
3696 // for (int j = 0, cpLength = classpath.length; j < cpLength; j++){
3698 // IClasspathEntry entry = classpath[j];
3699 // for (int k = 0; k < varLength; k++){
3701 // String variableName = variableNames[k];
3702 // if (entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE){
3704 // if (variableName.equals(entry.getPath().segment(0))){
3705 // affectedProjects.put(project, project.getResolvedClasspath(true));
3706 // continue nextProject;
3708 // IPath sourcePath, sourceRootPath;
3709 // if (((sourcePath = entry.getSourceAttachmentPath()) != null && variableName.equals(sourcePath.segment(0)))
3710 // || ((sourceRootPath = entry.getSourceAttachmentRootPath()) != null && variableName.equals(sourceRootPath.segment(0)))) {
3712 // affectedProjects.put(project, project.getResolvedClasspath(true));
3713 // continue nextProject;
3720 // // update variables
3721 // for (int i = 0; i < varLength; i++){
3722 // JavaModelManager.variablePut(variableNames[i], variablePaths[i]);
3724 // final String[] dbgVariableNames = variableNames;
3726 // // update affected project classpaths
3727 // if (!affectedProjects.isEmpty()) {
3729 // JavaCore_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt.run(
3730 // new IWorkspaceRunnable() {
3731 // public void run(IProgressMonitor monitor) throws CoreException {
3732 // // propagate classpath change
3733 // Iterator projectsToUpdate = affectedProjects.keySet().iterator();
3734 // while (projectsToUpdate.hasNext()) {
3736 // if (monitor != null && monitor.isCanceled()) return;
3738 // JavaProject project = (JavaProject) projectsToUpdate.next();
3740 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3741 // System.out.println("CPVariable SET - updating affected project: ["+project.getElementName()+"] due to setting variables: "+ Util.toString(dbgVariableNames)); //$NON-NLS-1$ //$NON-NLS-2$
3745 // .setRawClasspath(
3746 // project.getRawClasspath(),
3747 // SetClasspathOperation.ReuseOutputLocation,
3748 // null, // don't call beginTask on the monitor (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=3717)
3749 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can change resources
3750 // (IClasspathEntry[]) affectedProjects.get(project),
3751 // false, // updating - no validation
3752 // false); // updating - no need to save
3757 // } catch (CoreException e) {
3758 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3759 // System.out.println("CPVariable SET - FAILED DUE TO EXCEPTION: "+Util.toString(dbgVariableNames)); //$NON-NLS-1$
3760 // e.printStackTrace();
3762 // if (e instanceof JavaModelException) {
3763 // throw (JavaModelException)e;
3765 // throw new JavaModelException(e);