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.ISavedState;
30 import org.eclipse.core.resources.IWorkspace;
31 import org.eclipse.core.resources.IWorkspaceRoot;
32 import org.eclipse.core.resources.IWorkspaceRunnable;
33 import org.eclipse.core.resources.ResourcesPlugin;
34 import org.eclipse.core.runtime.CoreException;
35 import org.eclipse.core.runtime.IConfigurationElement;
36 import org.eclipse.core.runtime.IPath;
37 import org.eclipse.core.runtime.IProgressMonitor;
38 import org.eclipse.core.runtime.IStatus;
39 import org.eclipse.core.runtime.Plugin;
40 import org.eclipse.core.runtime.Preferences;
41 import org.eclipse.core.runtime.Status;
42 import org.eclipse.core.runtime.jobs.ISchedulingRule;
43 import org.eclipse.core.runtime.jobs.Job;
44 import net.sourceforge.phpdt.internal.core.util.Util;
45 import org.osgi.framework.BundleContext;
47 public class JavaCore {
49 // public static HashSet OptionNames = new HashSet(20);
51 * The plug-in identifier of the Java core support (value
52 * <code>"net.sourceforge.phpeclipse"</code>)
54 // public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.core";
56 public static final String PLUGIN_ID = PHPeclipsePlugin.PLUGIN_ID;
59 * Possible configurable option ID.
61 * @see #getDefaultOptions
64 public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; //$NON-NLS-1$
67 * Possible configurable option ID.
69 * @see #getDefaultOptions
72 public static final String FORMATTER_NEWLINE_OPENING_BRACE = PLUGIN_ID
73 + ".formatter.newline.openingBrace"; //$NON-NLS-1$
76 * Possible configurable option ID.
78 * @see #getDefaultOptions
81 public static final String FORMATTER_NEWLINE_CONTROL = PLUGIN_ID
82 + ".formatter.newline.controlStatement"; //$NON-NLS-1$
85 * Possible configurable option ID.
87 * @see #getDefaultOptions
90 public static final String FORMATTER_NEWLINE_ELSE_IF = PLUGIN_ID
91 + ".formatter.newline.elseIf"; //$NON-NLS-1$
94 * Possible configurable option ID.
96 * @see #getDefaultOptions
99 public static final String FORMATTER_NEWLINE_EMPTY_BLOCK = PLUGIN_ID
100 + ".formatter.newline.emptyBlock"; //$NON-NLS-1$
103 * Possible configurable option ID.
105 * @see #getDefaultOptions
108 public static final String FORMATTER_CLEAR_BLANK_LINES = PLUGIN_ID
109 + ".formatter.newline.clearAll"; //$NON-NLS-1$
112 * Possible configurable option ID.
114 * @see #getDefaultOptions
117 public static final String FORMATTER_LINE_SPLIT = PLUGIN_ID
118 + ".formatter.lineSplit"; //$NON-NLS-1$
121 * Possible configurable option ID.
123 * @see #getDefaultOptions
126 public static final String FORMATTER_COMPACT_ASSIGNMENT = PLUGIN_ID
127 + ".formatter.style.assignment"; //$NON-NLS-1$
130 * Possible configurable option ID.
132 * @see #getDefaultOptions
135 public static final String FORMATTER_TAB_CHAR = PLUGIN_ID
136 + ".formatter.tabulation.char"; //$NON-NLS-1$
139 * Possible configurable option ID.
141 * @see #getDefaultOptions
144 public static final String FORMATTER_TAB_SIZE = PLUGIN_ID
145 + ".formatter.tabulation.size"; //$NON-NLS-1$
148 * Possible configurable option value.
150 * @see #getDefaultOptions
153 public static final String INSERT = "insert"; //$NON-NLS-1$
156 * Possible configurable option value.
158 * @see #getDefaultOptions
161 public static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$
164 * Possible configurable option value.
166 * @see #getDefaultOptions
169 public static final String PRESERVE_ONE = "preserve one"; //$NON-NLS-1$
172 * Possible configurable option value.
174 * @see #getDefaultOptions
177 public static final String CLEAR_ALL = "clear all"; //$NON-NLS-1$
180 * Possible configurable option value.
182 * @see #getDefaultOptions
185 public static final String NORMAL = "normal"; //$NON-NLS-1$
188 * Possible configurable option value.
190 * @see #getDefaultOptions
193 public static final String COMPACT = "compact"; //$NON-NLS-1$
196 * Possible configurable option value.
198 * @see #getDefaultOptions
201 public static final String TAB = "tab"; //$NON-NLS-1$
204 * Possible configurable option value.
206 * @see #getDefaultOptions
209 public static final String SPACE = "space"; //$NON-NLS-1$
212 * Possible configurable option value.
214 * @see #getDefaultOptions
217 public static final String ENABLED = "enabled"; //$NON-NLS-1$
220 * Possible configurable option value.
222 * @see #getDefaultOptions
225 public static final String DISABLED = "disabled"; //$NON-NLS-1$
228 * Possible configurable option value.
230 * @see #getDefaultOptions
233 public static final String CLEAN = "clean"; //$NON-NLS-1$
236 * Possible configurable option ID.
238 * @see #getDefaultOptions
241 public static final String COMPILER_TASK_TAGS = PLUGIN_ID
242 + ".compiler.taskTags"; //$NON-NLS-1$
245 * Name of the handle id attribute in a Java marker.
247 protected static final String ATT_HANDLE_ID = "net.sourceforge.phpdt.internal.core.JavaModelManager.handleId"; //$NON-NLS-1$
249 // *************** Possible IDs for configurable options.
250 // ********************
253 * Possible configurable option ID.
255 * @see #getDefaultOptions()
257 public static final String COMPILER_LOCAL_VARIABLE_ATTR = PLUGIN_ID
258 + ".compiler.debug.localVariable"; //$NON-NLS-1$
261 * Possible configurable option ID.
263 * @see #getDefaultOptions()
265 public static final String COMPILER_LINE_NUMBER_ATTR = PLUGIN_ID
266 + ".compiler.debug.lineNumber"; //$NON-NLS-1$
269 * Possible configurable option ID.
271 * @see #getDefaultOptions
273 public static final String COMPILER_SOURCE_FILE_ATTR = PLUGIN_ID
274 + ".compiler.debug.sourceFile"; //$NON-NLS-1$
277 * Possible configurable option ID.
279 * @see #getDefaultOptions
281 public static final String COMPILER_CODEGEN_UNUSED_LOCAL = PLUGIN_ID
282 + ".compiler.codegen.unusedLocal"; //$NON-NLS-1$
285 * Possible configurable option ID.
287 * @see #getDefaultOptions
289 public static final String COMPILER_CODEGEN_TARGET_PLATFORM = PLUGIN_ID
290 + ".compiler.codegen.targetPlatform"; //$NON-NLS-1$
293 * Possible configurable option ID.
295 * @see #getDefaultOptions
297 public static final String COMPILER_PB_PHP_VAR_DEPRECATED = PLUGIN_ID
298 + ".compiler.problem.phpVarDeprecatedWarning"; //$NON-NLS-1$
301 * Possible configurable option ID.
303 * @see #getDefaultOptions
305 public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID
306 + ".compiler.problem.unreachableCode"; //$NON-NLS-1$
309 * Possible configurable option ID.
311 * @see #getDefaultOptions
313 public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID
314 + ".compiler.problem.invalidImport"; //$NON-NLS-1$
317 * Possible configurable option ID.
319 * @see #getDefaultOptions
321 public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID
322 + ".compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
325 * Possible configurable option ID.
327 * @see #getDefaultOptions
329 public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID
330 + ".compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
333 * Possible configurable option ID.
335 * @see #getDefaultOptions
337 public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID
338 + ".compiler.problem.deprecation"; //$NON-NLS-1$
341 * Possible configurable option ID.
343 * @see #getDefaultOptions
346 public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID
347 + ".compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
350 * Possible configurable option ID.
352 * @see #getDefaultOptions
354 public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID
355 + ".compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
358 * Possible configurable option ID.
360 * @see #getDefaultOptions
362 public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID
363 + ".compiler.problem.unusedLocal"; //$NON-NLS-1$
366 * Possible configurable option ID.
368 * @see #getDefaultOptions
370 public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID
371 + ".compiler.problem.unusedParameter"; //$NON-NLS-1$
374 * Possible configurable option ID.
376 * @see #getDefaultOptions
379 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID
380 + ".compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
383 * Possible configurable option ID.
385 * @see #getDefaultOptions
388 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID
389 + ".compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
392 * Possible configurable option ID.
394 * @see #getDefaultOptions
397 public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID
398 + ".compiler.problem.unusedImport"; //$NON-NLS-1$
401 * Possible configurable option ID.
403 * @see #getDefaultOptions
405 public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID
406 + ".compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
409 * Possible configurable option ID.
411 * @see #getDefaultOptions
414 public static final String COMPILER_PB_NON_NLS_STRING_LITERAL = PLUGIN_ID
415 + ".compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
418 * Possible configurable option ID.
420 * @see #getDefaultOptions
423 public static final String COMPILER_PB_ASSERT_IDENTIFIER = PLUGIN_ID
424 + ".compiler.problem.assertIdentifier"; //$NON-NLS-1$
427 * Possible configurable option ID.
429 * @see #getDefaultOptions
432 public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID
433 + ".compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
436 * Possible configurable option ID.
438 * @see #getDefaultOptions
441 public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID
442 + ".compiler.problem.noEffectAssignment"; //$NON-NLS-1$
445 * Possible configurable option ID.
447 * @see #getDefaultOptions
450 public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID
451 + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
454 * Possible configurable option ID.
456 * @see #getDefaultOptions
459 public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID
460 + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
463 * Possible configurable option ID.
465 * @see #getDefaultOptions
468 public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID
469 + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
472 * Possible configurable option ID.
474 * @see #getDefaultOptions
477 public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID
478 + ".compiler.maxProblemPerUnit"; //$NON-NLS-1$
481 * Possible configurable option ID.
483 * @see #getDefaultOptions
486 public static final String COMPILER_SOURCE = PLUGIN_ID + ".compiler.source"; //$NON-NLS-1$
489 * Possible configurable option ID.
491 * @see #getDefaultOptions
494 public static final String COMPILER_COMPLIANCE = PLUGIN_ID
495 + ".compiler.compliance"; //$NON-NLS-1$
498 * Possible configurable option ID.
500 * @see #getDefaultOptions
503 public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID
504 + ".compiler.taskPriorities"; //$NON-NLS-1$
507 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
509 * @see #getDefaultOptions
512 public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$
515 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
517 * @see #getDefaultOptions
520 public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$
523 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
525 * @see #getDefaultOptions
528 public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$
531 * Possible configurable option ID.
533 * @see #getDefaultOptions
535 public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID
536 + ".computeJavaBuildOrder"; //$NON-NLS-1$
539 * Possible configurable option ID.
541 * @see #getDefaultOptions
544 public static final String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER = PLUGIN_ID
545 + ".builder.resourceCopyExclusionFilter"; //$NON-NLS-1$
548 * Possible configurable option ID.
550 * @see #getDefaultOptions
553 public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID
554 + ".builder.duplicateResourceTask"; //$NON-NLS-1$
557 * Possible configurable option ID.
559 * @see #getDefaultOptions
562 public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID
563 + ".builder.cleanOutputFolder"; //$NON-NLS-1$
566 * Possible configurable option ID.
568 * @see #getDefaultOptions
571 public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID
572 + ".incompleteClasspath"; //$NON-NLS-1$
575 * Possible configurable option ID.
577 * @see #getDefaultOptions
580 public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID
581 + ".circularClasspath"; //$NON-NLS-1$
584 * Possible configurable option ID.
586 * @see #getDefaultOptions
589 public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID
590 + ".builder.invalidClasspath"; //$NON-NLS-1$
593 * Possible configurable option ID.
595 * @see #getDefaultOptions
598 public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID
599 + ".classpath.exclusionPatterns"; //$NON-NLS-1$
602 * Possible configurable option ID.
604 * @see #getDefaultOptions
607 public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID
608 + ".classpath.multipleOutputLocations"; //$NON-NLS-1$
615 public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$
618 * Default task priority
622 public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; //$NON-NLS-1$
625 * Possible configurable option ID
627 * @see #getDefaultOptions
630 public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID
631 + ".formatter.space.castexpression"; //$NON-NLS-1$
634 * Possible configurable option ID.
636 * @see #getDefaultOptions
639 public static final String CODEASSIST_VISIBILITY_CHECK = PLUGIN_ID
640 + ".codeComplete.visibilityCheck"; //$NON-NLS-1$
643 * Possible configurable option ID.
645 * @see #getDefaultOptions
648 public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID
649 + ".codeComplete.forceImplicitQualification"; //$NON-NLS-1$
652 * Possible configurable option ID.
654 * @see #getDefaultOptions
657 public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID
658 + ".codeComplete.fieldPrefixes"; //$NON-NLS-1$
661 * Possible configurable option ID.
663 * @see #getDefaultOptions
666 public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID
667 + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
670 * Possible configurable option ID.
672 * @see #getDefaultOptions
675 public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID
676 + ".codeComplete.localPrefixes"; //$NON-NLS-1$
679 * Possible configurable option ID.
681 * @see #getDefaultOptions
684 public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID
685 + ".codeComplete.argumentPrefixes"; //$NON-NLS-1$
688 * Possible configurable option ID.
690 * @see #getDefaultOptions
693 public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID
694 + ".codeComplete.fieldSuffixes"; //$NON-NLS-1$
697 * Possible configurable option ID.
699 * @see #getDefaultOptions
702 public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID
703 + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
706 * Possible configurable option ID.
708 * @see #getDefaultOptions
711 public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID
712 + ".codeComplete.localSuffixes"; //$NON-NLS-1$
715 * Possible configurable option ID.
717 * @see #getDefaultOptions
720 public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID
721 + ".codeComplete.argumentSuffixes"; //$NON-NLS-1$
723 // *************** Possible values for configurable options.
724 // ********************
727 * Possible configurable option value.
729 * @see #getDefaultOptions
731 public static final String GENERATE = "generate"; //$NON-NLS-1$
734 * Possible configurable option value.
736 * @see #getDefaultOptions
738 public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
741 * Possible configurable option value.
743 * @see #getDefaultOptions
745 public static final String PRESERVE = "preserve"; //$NON-NLS-1$
748 * Possible configurable option value.
750 * @see #getDefaultOptions
752 public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
755 * Possible configurable option value.
757 * @see #getDefaultOptions
759 public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$
762 * Possible configurable option value.
764 * @see #getDefaultOptions
766 public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$
769 * Possible configurable option value.
771 * @see #getDefaultOptions
774 public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
777 * Possible configurable option value.
779 * @see #getDefaultOptions
782 public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
785 * Possible configurable option value.
787 * @see #getDefaultOptions
790 public static final String ABORT = "abort"; //$NON-NLS-1$
793 * Possible configurable option value.
795 * @see #getDefaultOptions
797 public static final String ERROR = "error"; //$NON-NLS-1$
800 * Possible configurable option value.
802 * @see #getDefaultOptions
804 public static final String WARNING = "warning"; //$NON-NLS-1$
807 * Possible configurable option value.
809 * @see #getDefaultOptions
811 public static final String IGNORE = "ignore"; //$NON-NLS-1$
814 * Possible configurable option value.
816 * @see #getDefaultOptions
818 public static final String COMPUTE = "compute"; //$NON-NLS-1$
821 * Possible configurable option value.
823 * @see #getDefaultOptions
828 * Returns a table of all known configurable options with their default
829 * values. These options allow to configure the behaviour of the underlying
830 * components. The client may safely use the result as a template that they
831 * can modify and then pass to <code>setOptions</code>.
833 * Helper constants have been defined on JavaCore for each of the option ID
834 * and their possible constant values.
836 * Note: more options might be added in further releases.
840 * RECOGNIZED OPTIONS:
841 * COMPILER / Generating Local Variable Debug Attribute
842 * When generated, this attribute will enable local variable names
843 * to be displayed in debugger, only in place where variables are
844 * definitely assigned (.class file is then bigger)
845 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.localVariable"
846 * - possible values: { "generate", "do not generate" }
847 * - default: "generate"
849 * COMPILER / Generating Line Number Debug Attribute
850 * When generated, this attribute will enable source code highlighting in debugger
851 * (.class file is then bigger).
852 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.lineNumber"
853 * - possible values: { "generate", "do not generate" }
854 * - default: "generate"
856 * COMPILER / Generating Source Debug Attribute
857 * When generated, this attribute will enable the debugger to present the
858 * corresponding source code.
859 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.sourceFile"
860 * - possible values: { "generate", "do not generate" }
861 * - default: "generate"
863 * COMPILER / Preserving Unused Local Variables
864 * Unless requested to preserve unused local variables (i.e. never read), the
865 * compiler will optimize them out, potentially altering debugging
866 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.unusedLocal"
867 * - possible values: { "preserve", "optimize out" }
868 * - default: "preserve"
870 * COMPILER / Defining Target Java Platform
871 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
872 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
873 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.targetPlatform"
874 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
875 * - default: "1.1"
877 * COMPILER / Reporting Unreachable Code
878 * Unreachable code can optionally be reported as an error, warning or simply
879 * ignored. The bytecode generation will always optimized it out.
880 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unreachableCode"
881 * - possible values: { "error", "warning", "ignore" }
882 * - default: "error"
884 * COMPILER / Reporting Invalid Import
885 * An import statement that cannot be resolved might optionally be reported
886 * as an error, as a warning or ignored.
887 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.invalidImport"
888 * - possible values: { "error", "warning", "ignore" }
889 * - default: "error"
891 * COMPILER / Reporting Attempt to Override Package-Default Method
892 * A package default method is not visible in a different package, and thus
893 * cannot be overridden. When enabling this option, the compiler will signal
894 * such scenarii either as an error or a warning.
895 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
896 * - possible values: { "error", "warning", "ignore" }
897 * - default: "warning"
899 * COMPILER / Reporting Method With Constructor Name
900 * Naming a method with a constructor name is generally considered poor
901 * style programming. When enabling this option, the compiler will signal such
902 * scenarii either as an error or a warning.
903 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.methodWithConstructorName"
904 * - possible values: { "error", "warning", "ignore" }
905 * - default: "warning"
907 * COMPILER / Reporting Deprecation
908 * When enabled, the compiler will signal use of deprecated API either as an
909 * error or a warning.
910 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecation"
911 * - possible values: { "error", "warning", "ignore" }
912 * - default: "warning"
914 * COMPILER / Reporting Deprecation Inside Deprecated Code
915 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
916 * The severity of the problem is controlled with option "org.phpeclipse.phpdt.core.compiler.problem.deprecation".
917 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
918 * - possible values: { "enabled", "disabled" }
919 * - default: "disabled"
921 * COMPILER / Reporting Hidden Catch Block
922 * Locally to a try statement, some catch blocks may hide others , e.g.
923 * try { throw new java.io.CharConversionException();
924 * } catch (java.io.CharConversionException e) {
925 * } catch (java.io.IOException e) {}.
926 * When enabling this option, the compiler will issue an error or a warning for hidden
927 * catch blocks corresponding to checked exceptions
928 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.hiddenCatchBlock"
929 * - possible values: { "error", "warning", "ignore" }
930 * - default: "warning"
932 * COMPILER / Reporting Unused Local
933 * When enabled, the compiler will issue an error or a warning for unused local
934 * variables (i.e. variables never read from)
935 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedLocal"
936 * - possible values: { "error", "warning", "ignore" }
937 * - default: "ignore"
939 * COMPILER / Reporting Unused Parameter
940 * When enabled, the compiler will issue an error or a warning for unused method
941 * parameters (i.e. parameters never read from)
942 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedParameter"
943 * - possible values: { "error", "warning", "ignore" }
944 * - default: "ignore"
946 * COMPILER / Reporting Unused Import
947 * When enabled, the compiler will issue an error or a warning for unused import
949 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedImport"
950 * - possible values: { "error", "warning", "ignore" }
951 * - default: "warning"
953 * COMPILER / Reporting Synthetic Access Emulation
954 * When enabled, the compiler will issue an error or a warning whenever it emulates
955 * access to a non-accessible member of an enclosing type. Such access can have
956 * performance implications.
957 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.syntheticAccessEmulation"
958 * - possible values: { "error", "warning", "ignore" }
959 * - default: "ignore"
961 * COMPILER / Reporting Non-Externalized String Literal
962 * When enabled, the compiler will issue an error or a warning for non externalized
963 * String literal (i.e. non tagged with //$NON-NLS-<n>$).
964 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
965 * - possible values: { "error", "warning", "ignore" }
966 * - default: "ignore"
968 * COMPILER / Reporting Usage of 'assert' Identifier
969 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
970 * used as an identifier (reserved keyword in 1.4)
971 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.assertIdentifier"
972 * - possible values: { "error", "warning", "ignore" }
973 * - default: "ignore"
975 * COMPILER / Reporting Usage of expression receiver on static invocation/field access
976 * When enabled, the compiler will issue an error or a warning whenever a static field
977 * or method is accessed with an expression receiver.
978 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.staticAccessReceiver"
979 * - possible values: { "error", "warning", "ignore" }
980 * - default: "warning"
982 * COMPILER / Reporting Assignment with no effect
983 * When enabled, the compiler will issue an error or a warning whenever an assignment
984 * has no effect (e.g 'x = x').
985 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.noEffectAssignment"
986 * - possible values: { "error", "warning", "ignore" }
987 * - default: "warning"
989 * COMPILER / Setting Source Compatibility Mode
990 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
991 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
992 * level should be set to "1.4" and the compliance mode should be "1.4".
993 * - option id: "org.phpeclipse.phpdt.core.compiler.source"
994 * - possible values: { "1.3", "1.4" }
995 * - default: "1.3"
997 * COMPILER / Setting Compliance Level
998 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
999 * should not go beyond "1.3" level.
1000 * - option id: "org.phpeclipse.phpdt.core.compiler.compliance"
1001 * - possible values: { "1.3", "1.4" }
1002 * - default: "1.3"
1004 * COMPILER / Maximum number of problems reported per compilation unit
1005 * Specify the maximum number of problems reported on each compilation unit.
1006 * - option id: "org.phpeclipse.phpdt.core.compiler.maxProblemPerUnit"
1007 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
1008 * - default: "100"
1010 * COMPILER / Define the Automatic Task Tags
1011 * When the tag is non empty, the compiler will issue a task marker whenever it encounters
1012 * one of the corresponding tag inside any comment in Java source code.
1013 * Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed.
1014 * - option id: "org.phpeclipse.phpdt.core.compiler.taskTags"
1015 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card
1016 * - default: ""
1017 * COMPILER / Define the Automatic Task Priorities
1018 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
1019 * of the task markers issued by the compiler.
1020 * If the default is specified, the priority of each task marker is "NORMAL".
1021 * - option id: "org.phpeclipse.phpdt.core.compiler.taskPriorities"
1022 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
1023 * - default: ""
1025 * BUILDER / Specifying Filters for Resource Copying Control
1026 * Allow to specify some filters to control the resource copy process.
1027 * - option id: "org.phpeclipse.phpdt.core.builder.resourceCopyExclusionFilter"
1028 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
1029 * or the name of a folder which ends with '/'
1030 * - default: ""
1032 * BUILDER / Abort if Invalid Classpath
1033 * Allow to toggle the builder to abort if the classpath is invalid
1034 * - option id: "org.phpeclipse.phpdt.core.builder.invalidClasspath"
1035 * - possible values: { "abort", "ignore" }
1036 * - default: "ignore"
1038 * BUILDER / Cleaning Output Folder(s)
1039 * Indicate whether the JavaBuilder is allowed to clean the output folders
1040 * when performing full build operations.
1041 * - option id: "org.phpeclipse.phpdt.core.builder.cleanOutputFolder"
1042 * - possible values: { "clean", "ignore" }
1043 * - default: "clean"
1045 * JAVACORE / Computing Project Build Order
1046 * Indicate whether JavaCore should enforce the project build order to be based on
1047 * the classpath prerequisite chain. When requesting to compute, this takes over
1048 * the platform default order (based on project references).
1049 * - option id: "org.phpeclipse.phpdt.core.computeJavaBuildOrder"
1050 * - possible values: { "compute", "ignore" }
1051 * - default: "ignore"
1053 * JAVACORE / Specify Default Source Encoding Format
1054 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
1055 * to 'ResourcesPlugin.getEncoding()'.
1056 * - option id: "org.phpeclipse.phpdt.core.encoding"
1057 * - possible values: { any of the supported encoding name}.
1058 * - default: <platform default>
1060 * JAVACORE / Reporting Incomplete Classpath
1061 * An entry on the classpath doesn't exist or is not visible (e.g. a referenced project is closed).
1062 * - option id: "org.phpeclipse.phpdt.core.incompleteClasspath"
1063 * - possible values: { "error", "warning"}
1064 * - default: "error"
1066 * JAVACORE / Reporting Classpath Cycle
1067 * A project is involved in a cycle.
1068 * - option id: "org.phpeclipse.phpdt.core.circularClasspath"
1069 * - possible values: { "error", "warning" }
1070 * - default: "error"
1072 * FORMATTER / Inserting New Line Before Opening Brace
1073 * When Insert, a new line is inserted before an opening brace, otherwise nothing
1075 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.openingBrace"
1076 * - possible values: { "insert", "do not insert" }
1077 * - default: "do not insert"
1079 * FORMATTER / Inserting New Line Inside Control Statement
1080 * When Insert, a new line is inserted between } and following else, catch, finally
1081 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.controlStatement"
1082 * - possible values: { "insert", "do not insert" }
1083 * - default: "do not insert"
1085 * FORMATTER / Clearing Blank Lines
1086 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
1087 * and all others removed.
1088 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.clearAll"
1089 * - possible values: { "clear all", "preserve one" }
1090 * - default: "preserve one"
1092 * FORMATTER / Inserting New Line Between Else/If
1093 * When Insert, a blank line is inserted between an else and an if when they are
1094 * contiguous. When choosing to not insert, else-if will be kept on the same
1095 * line when possible.
1096 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.elseIf"
1097 * - possible values: { "insert", "do not insert" }
1098 * - default: "do not insert"
1100 * FORMATTER / Inserting New Line In Empty Block
1101 * When insert, a line break is inserted between contiguous { and }, if } is not followed
1103 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.emptyBlock"
1104 * - possible values: { "insert", "do not insert" }
1105 * - default: "insert"
1107 * FORMATTER / Splitting Lines Exceeding Length
1108 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
1109 * disable line splitting
1110 * - option id: "org.phpeclipse.phpdt.core.formatter.lineSplit"
1111 * - possible values: "<n>", where n is zero or a positive integer
1112 * - default: "80"
1114 * FORMATTER / Compacting Assignment
1115 * Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space
1116 * is inserted before the assignment operator
1117 * - option id: "org.phpeclipse.phpdt.core.formatter.style.assignment"
1118 * - possible values: { "compact", "normal" }
1119 * - default: "normal"
1121 * FORMATTER / Defining Indentation Character
1122 * Either choose to indent with tab characters or spaces
1123 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.char"
1124 * - possible values: { "tab", "space" }
1125 * - default: "tab"
1127 * FORMATTER / Defining Space Indentation Length
1128 * When using spaces, set the amount of space characters to use for each
1130 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.size"
1131 * - possible values: "<n>", where n is a positive integer
1132 * - default: "4"
1134 * CODEASSIST / Activate Visibility Sensitive Completion
1135 * When active, completion doesn't show that you can not see
1136 * (e.g. you can not see private methods of a super class).
1137 * - option id: "org.phpeclipse.phpdt.core.codeComplete.visibilityCheck"
1138 * - possible values: { "enabled", "disabled" }
1139 * - default: "disabled"
1141 * CODEASSIST / Automatic Qualification of Implicit Members
1142 * When active, completion automatically qualifies completion on implicit
1143 * field references and message expressions.
1144 * - option id: "org.phpeclipse.phpdt.core.codeComplete.forceImplicitQualification"
1145 * - possible values: { "enabled", "disabled" }
1146 * - default: "disabled"
1148 * CODEASSIST / Define the Prefixes for Field Name
1149 * When the prefixes is non empty, completion for field name will begin with
1150 * one of the proposed prefixes.
1151 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldPrefixes"
1152 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1153 * - default: ""
1155 * CODEASSIST / Define the Prefixes for Static Field Name
1156 * When the prefixes is non empty, completion for static field name will begin with
1157 * one of the proposed prefixes.
1158 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldPrefixes"
1159 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1160 * - default: ""
1162 * CODEASSIST / Define the Prefixes for Local Variable Name
1163 * When the prefixes is non empty, completion for local variable name will begin with
1164 * one of the proposed prefixes.
1165 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localPrefixes"
1166 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1167 * - default: ""
1169 * CODEASSIST / Define the Prefixes for Argument Name
1170 * When the prefixes is non empty, completion for argument name will begin with
1171 * one of the proposed prefixes.
1172 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentPrefixes"
1173 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1174 * - default: ""
1176 * CODEASSIST / Define the Suffixes for Field Name
1177 * When the suffixes is non empty, completion for field name will end with
1178 * one of the proposed suffixes.
1179 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldSuffixes"
1180 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1181 * - default: ""
1183 * CODEASSIST / Define the Suffixes for Static Field Name
1184 * When the suffixes is non empty, completion for static field name will end with
1185 * one of the proposed suffixes.
1186 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldSuffixes"
1187 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1188 * - default: ""
1190 * CODEASSIST / Define the Suffixes for Local Variable Name
1191 * When the suffixes is non empty, completion for local variable name will end with
1192 * one of the proposed suffixes.
1193 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localSuffixes"
1194 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1195 * - default: ""
1197 * CODEASSIST / Define the Suffixes for Argument Name
1198 * When the suffixes is non empty, completion for argument name will end with
1199 * one of the proposed suffixes.
1200 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentSuffixes"
1201 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
1202 * - default: ""
1205 * @return a mutable table containing the default settings of all known options
1218 // public static Hashtable getDefaultOptions() {
1220 // Hashtable defaultOptions = new Hashtable(10);
1222 // // see #initializeDefaultPluginPreferences() for changing default
1224 // Preferences preferences = getPlugin().getPluginPreferences();
1225 // HashSet optionNames = OptionNames;
1227 // // get preferences set to their default
1228 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1229 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1230 // String propertyName = defaultPropertyNames[i];
1231 // if (optionNames.contains(propertyName)) {
1232 // defaultOptions.put(propertyName,
1233 // preferences.getDefaultString(propertyName));
1236 // // get preferences not set to their default
1237 // String[] propertyNames = preferences.propertyNames();
1238 // for (int i = 0; i < propertyNames.length; i++) {
1239 // String propertyName = propertyNames[i];
1240 // if (optionNames.contains(propertyName)) {
1241 // defaultOptions.put(propertyName,
1242 // preferences.getDefaultString(propertyName));
1245 // // get encoding through resource plugin
1246 // defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1248 // return defaultOptions;
1251 * Helper method for returning one option value only. Equivalent to
1252 * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
1253 * may answer <code>null</code> if this option does not exist.
1255 * For a complete description of the configurable options, see
1256 * <code>getDefaultOptions</code>.
1260 * the name of an option
1261 * @return the String value of a given option
1262 * @see JavaCore#getDefaultOptions
1265 // public static String getOption(String optionName) {
1267 // if (CORE_ENCODING.equals(optionName)) {
1268 // return ResourcesPlugin.getEncoding();
1270 // if (OptionNames.contains(optionName)) {
1271 // Preferences preferences = getPlugin().getPluginPreferences();
1272 // return preferences.getString(optionName).trim();
1277 * Returns the table of the current options. Initially, all options have
1278 * their default values, and this method returns a table that includes all
1281 * For a complete description of the configurable options, see
1282 * <code>getDefaultOptions</code>.
1285 * @return table of current settings of all options (key type:
1286 * <code>String</code>; value type: <code>String</code>)
1287 * @see JavaCore#getDefaultOptions
1289 // public static Hashtable getOptions() {
1291 // Hashtable options = new Hashtable(10);
1293 // // see #initializeDefaultPluginPreferences() for changing default
1295 // Plugin plugin = getPlugin();
1296 // if (plugin != null) {
1297 // Preferences preferences = getPlugin().getPluginPreferences();
1298 // HashSet optionNames = OptionNames;
1300 // // get preferences set to their default
1301 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1302 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1303 // String propertyName = defaultPropertyNames[i];
1304 // if (optionNames.contains(propertyName)) {
1305 // options.put(propertyName, preferences.getDefaultString(propertyName));
1308 // // get preferences not set to their default
1309 // String[] propertyNames = preferences.propertyNames();
1310 // for (int i = 0; i < propertyNames.length; i++) {
1311 // String propertyName = propertyNames[i];
1312 // if (optionNames.contains(propertyName)) {
1313 // options.put(propertyName, preferences.getString(propertyName).trim());
1316 // // get encoding through resource plugin
1317 // options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1322 * Sets the current table of options. All and only the options explicitly
1323 * included in the given table are remembered; all previous option settings
1324 * are forgotten, including ones not explicitly mentioned.
1326 * For a complete description of the configurable options, see
1327 * <code>getDefaultOptions</code>.
1331 * the new options (key type: <code>String</code>; value type:
1332 * <code>String</code>), or <code>null</code> to reset all
1333 * options to their default values
1334 * @see JavaCore#getDefaultOptions
1336 // public static void setOptions(Hashtable newOptions) {
1338 // // see #initializeDefaultPluginPreferences() for changing default
1340 // Preferences preferences = getPlugin().getPluginPreferences();
1342 // if (newOptions == null) {
1343 // newOptions = getDefaultOptions();
1345 // Enumeration keys = newOptions.keys();
1346 // while (keys.hasMoreElements()) {
1347 // String key = (String) keys.nextElement();
1348 // if (!OptionNames.contains(key))
1349 // continue; // unrecognized option
1350 // if (key.equals(CORE_ENCODING))
1351 // continue; // skipped, contributed by resource prefs
1352 // String value = (String) newOptions.get(key);
1353 // preferences.setValue(key, value);
1356 // // persist options
1357 // getPlugin().savePluginPreferences();
1359 public static IProject[] getPHPProjects() {
1360 List phpProjectsList = new ArrayList();
1361 IProject[] workspaceProjects = PHPeclipsePlugin.getWorkspace()
1362 .getRoot().getProjects();
1364 for (int i = 0; i < workspaceProjects.length; i++) {
1365 IProject iProject = workspaceProjects[i];
1366 if (isPHPProject(iProject))
1367 phpProjectsList.add(iProject);
1370 IProject[] phpProjects = new IProject[phpProjectsList.size()];
1371 return (IProject[]) phpProjectsList.toArray(phpProjects);
1374 // public static PHPProject getPHPProject(String name) {
1375 // IProject aProject =
1376 // PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
1377 // if (isPHPProject(aProject)) {
1378 // PHPProject thePHPProject = new PHPProject();
1379 // thePHPProject.setProject(aProject);
1380 // return thePHPProject;
1385 public static boolean isPHPProject(IProject aProject) {
1387 return aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID);
1388 } catch (CoreException e) {
1394 // public static PHPFile create(IFile aFile) {
1395 // if (PHPFile.EXTENSION.equalsIgnoreCase(aFile.getFileExtension()))
1396 // return new PHPFile(aFile);
1397 // if (PHPFile.EXTENSION1.equalsIgnoreCase(aFile.getFileExtension()))
1398 // return new PHPFile(aFile);
1399 // if (PHPFile.EXTENSION2.equalsIgnoreCase(aFile.getFileExtension()))
1400 // return new PHPFile(aFile);
1401 // if (PHPFile.EXTENSION3.equalsIgnoreCase(aFile.getFileExtension()))
1402 // return new PHPFile(aFile);
1403 // if (PHPFile.EXTENSION4.equalsIgnoreCase(aFile.getFileExtension()))
1404 // return new PHPFile(aFile);
1405 // if (PHPFile.EXTENSION5.equalsIgnoreCase(aFile.getFileExtension()))
1406 // return new PHPFile(aFile);
1411 // public static PHPProject create(IProject aProject) {
1414 // if (aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1415 // PHPProject project = new PHPProject();
1416 // project.setProject(aProject);
1419 // } catch (CoreException e) {
1420 // System.err.println("Exception occurred in PHPCore#create(IProject): " +
1427 public static void addPHPNature(IProject project, IProgressMonitor monitor)
1428 throws CoreException {
1429 if (!project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1430 IProjectDescription description = project.getDescription();
1431 String[] prevNatures = description.getNatureIds();
1432 String[] newNatures = new String[prevNatures.length + 1];
1433 System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
1434 newNatures[prevNatures.length] = PHPeclipsePlugin.PHP_NATURE_ID;
1435 description.setNatureIds(newNatures);
1436 project.setDescription(description, monitor);
1441 * Returns the single instance of the PHP core plug-in runtime class.
1443 * @return the single instance of the PHP core plug-in runtime class
1445 public static Plugin getPlugin() {
1446 return PHPeclipsePlugin.getDefault();
1450 * Runs the given action as an atomic Java model operation.
1452 * After running a method that modifies java elements, registered listeners
1453 * receive after-the-fact notification of what just transpired, in the form
1454 * of a element changed event. This method allows clients to call a number
1455 * of methods that modify java elements and only have element changed event
1456 * notifications reported at the end of the entire batch.
1459 * If this method is called outside the dynamic scope of another such call,
1460 * this method runs the action and then reports a single element changed
1461 * event describing the net effect of all changes done to java elements by
1465 * If this method is called in the dynamic scope of another such call, this
1466 * method simply runs the action.
1470 * the action to perform
1472 * a progress monitor, or <code>null</code> if progress
1473 * reporting and cancellation are not desired
1474 * @exception CoreException
1475 * if the operation failed.
1478 // public static void run(IWorkspaceRunnable action, IProgressMonitor
1479 // monitor) throws CoreException {
1480 // run(action, ResourcesPlugin.getWorkspace().getRoot(), monitor);
1483 * Runs the given action as an atomic Java model operation.
1485 * After running a method that modifies java elements, registered listeners
1486 * receive after-the-fact notification of what just transpired, in the form
1487 * of a element changed event. This method allows clients to call a number
1488 * of methods that modify java elements and only have element changed event
1489 * notifications reported at the end of the entire batch.
1492 * If this method is called outside the dynamic scope of another such call,
1493 * this method runs the action and then reports a single element changed
1494 * event describing the net effect of all changes done to java elements by
1498 * If this method is called in the dynamic scope of another such call, this
1499 * method simply runs the action.
1502 * The supplied scheduling rule is used to determine whether this operation
1503 * can be run simultaneously with workspace changes in other threads. See
1504 * <code>IWorkspace.run(...)</code> for more details.
1508 * the action to perform
1510 * the scheduling rule to use when running this operation, or
1511 * <code>null</code> if there are no scheduling restrictions
1512 * for this operation.
1514 * a progress monitor, or <code>null</code> if progress
1515 * reporting and cancellation are not desired
1516 * @exception CoreException
1517 * if the operation failed.
1520 // public static void run(IWorkspaceRunnable action, ISchedulingRule rule,
1521 // IProgressMonitor monitor) throws CoreException {
1522 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
1523 // if (workspace.isTreeLocked()) {
1524 // new BatchOperation(action).run(monitor);
1526 // // use IWorkspace.run(...) to ensure that a build will be done in
1528 // workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE,
1534 * Adds the given listener for changes to Java elements. Has no effect if an
1535 * identical listener is already registered.
1537 * This listener will only be notified during the POST_CHANGE resource
1538 * change notification and any reconcile operation (POST_RECONCILE). For
1539 * finer control of the notification, use
1540 * <code>addElementChangedListener(IElementChangedListener,int)</code>,
1541 * which allows to specify a different eventMask.
1543 * @see ElementChangedEvent
1547 public static void addElementChangedListener(
1548 IElementChangedListener listener) {
1549 addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE
1550 | ElementChangedEvent.POST_RECONCILE);
1554 * Adds the given listener for changes to Java elements. Has no effect if an
1555 * identical listener is already registered. After completion of this
1556 * method, the given listener will be registered for exactly the specified
1557 * events. If they were previously registered for other events, they will be
1560 * Once registered, a listener starts receiving notification of changes to
1561 * java elements in the model. The listener continues to receive
1562 * notifications until it is replaced or removed.
1565 * Listeners can listen for several types of event as defined in
1566 * <code>ElementChangeEvent</code>. Clients are free to register for any
1567 * number of event types however if they register for more than one, it is
1568 * their responsibility to ensure they correctly handle the case where the
1569 * same java element change shows up in multiple notifications. Clients are
1570 * guaranteed to receive only the events for which they are registered.
1576 * the bit-wise OR of all event types of interest to the listener
1577 * @see IElementChangedListener
1578 * @see ElementChangedEvent
1579 * @see #removeElementChangedListener(IElementChangedListener)
1582 public static void addElementChangedListener(
1583 IElementChangedListener listener, int eventMask) {
1584 JavaModelManager.getJavaModelManager().addElementChangedListener(
1585 listener, eventMask);
1589 * Configures the given marker attribute map for the given Java element.
1590 * Used for markers, which denote a Java element rather than a resource.
1593 * the mutable marker attribute map (key type:
1594 * <code>String</code>, value type: <code>String</code>)
1596 * the Java element for which the marker needs to be configured
1598 public static void addJavaElementMarkerAttributes(Map attributes,
1599 IJavaElement element) {
1600 // if (element instanceof IMember)
1601 // element = ((IMember) element).getClassFile();
1602 if (attributes != null && element != null)
1603 attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier());
1607 * Configures the given marker for the given Java element. Used for markers,
1608 * which denote a Java element rather than a resource.
1611 * the marker to be configured
1613 * the Java element for which the marker needs to be configured
1614 * @exception CoreException
1615 * if the <code>IMarker.setAttribute</code> on the marker
1618 public void configureJavaElementMarker(IMarker marker, IJavaElement element)
1619 throws CoreException {
1620 // if (element instanceof IMember)
1621 // element = ((IMember) element).getClassFile();
1622 if (marker != null && element != null)
1623 marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier());
1627 * Returns the Java model element corresponding to the given handle
1628 * identifier generated by <code>IJavaElement.getHandleIdentifier()</code>,
1629 * or <code>null</code> if unable to create the associated element.
1631 public static IJavaElement create(String handleIdentifier) {
1632 if (handleIdentifier == null) {
1636 return JavaModelManager.getJavaModelManager().getHandleFromMemento(
1638 } catch (JavaModelException e) {
1644 * Returns the Java element corresponding to the given file, or
1645 * <code>null</code> if unable to associate the given file with a Java
1649 * The file must be one of:
1651 * <li>a <code>.java</code> file - the element returned is the
1652 * corresponding <code>ICompilationUnit</code></li>
1653 * <li>a <code>.class</code> file - the element returned is the
1654 * corresponding <code>IClassFile</code></li>
1655 * <li>a <code>.jar</code> file - the element returned is the
1656 * corresponding <code>IPackageFragmentRoot</code></li>
1659 * Creating a Java element has the side effect of creating and opening all
1660 * of the element's parents if they are not yet open.
1664 * @return the Java element corresponding to the given file, or
1665 * <code>null</code> if unable to associate the given file with a
1668 public static IJavaElement create(IFile file) {
1669 return JavaModelManager.create(file, null);
1673 * Returns the package fragment or package fragment root corresponding to
1674 * the given folder, or <code>null</code> if unable to associate the given
1675 * folder with a Java element.
1677 * Note that a package fragment root is returned rather than a default
1680 * Creating a Java element has the side effect of creating and opening all
1681 * of the element's parents if they are not yet open.
1685 * @return the package fragment or package fragment root corresponding to
1686 * the given folder, or <code>null</code> if unable to associate
1687 * the given folder with a Java element
1689 public static IJavaElement create(IFolder folder) {
1690 return JavaModelManager.create(folder, null);
1694 * Returns the Java project corresponding to the given project.
1696 * Creating a Java Project has the side effect of creating and opening all
1697 * of the project's parents if they are not yet open.
1699 * Note that no check is done at this time on the existence or the java
1700 * nature of this project.
1704 * @return the Java project corresponding to the given project, null if the
1705 * given project is null
1707 public static IJavaProject create(IProject project) {
1708 if (project == null) {
1711 JavaModel javaModel = JavaModelManager.getJavaModelManager()
1713 return javaModel.getJavaProject(project);
1717 * Returns the Java element corresponding to the given resource, or
1718 * <code>null</code> if unable to associate the given resource with a Java
1721 * The resource must be one of:
1723 * <li>a project - the element returned is the corresponding
1724 * <code>IJavaProject</code></li>
1725 * <li>a <code>.java</code> file - the element returned is the
1726 * corresponding <code>ICompilationUnit</code></li>
1727 * <li>a <code>.class</code> file - the element returned is the
1728 * corresponding <code>IClassFile</code></li>
1729 * <li>a <code>.jar</code> file - the element returned is the
1730 * corresponding <code>IPackageFragmentRoot</code></li>
1731 * <li>a folder - the element returned is the corresponding
1732 * <code>IPackageFragmentRoot</code> or <code>IPackageFragment</code>
1734 * <li>the workspace root resource - the element returned is the
1735 * <code>IJavaModel</code></li>
1738 * Creating a Java element has the side effect of creating and opening all
1739 * of the element's parents if they are not yet open.
1742 * the given resource
1743 * @return the Java element corresponding to the given resource, or
1744 * <code>null</code> if unable to associate the given resource
1745 * with a Java element
1747 public static IJavaElement create(IResource resource) {
1748 return JavaModelManager.create(resource, null);
1752 * Returns the Java model.
1756 * @return the Java model, or <code>null</code> if the root is null
1758 public static IJavaModel create(IWorkspaceRoot root) {
1762 return JavaModelManager.getJavaModelManager().getJavaModel();
1766 * Creates and returns a class file element for the given
1767 * <code>.class</code> file. Returns <code>null</code> if unable to
1768 * recognize the class file.
1771 * the given <code>.class</code> file
1772 * @return a class file element for the given <code>.class</code> file, or
1773 * <code>null</code> if unable to recognize the class file
1775 //public static IClassFile createClassFileFrom(IFile file) {
1776 // return JavaModelManager.createClassFileFrom(file, null);
1779 * Creates and returns a compilation unit element for the given
1780 * <code>.java</code> file. Returns <code>null</code> if unable to
1781 * recognize the compilation unit.
1784 * the given <code>.java</code> file
1785 * @return a compilation unit element for the given <code>.java</code>
1786 * file, or <code>null</code> if unable to recognize the
1789 public static ICompilationUnit createCompilationUnitFrom(IFile file) {
1790 return JavaModelManager.createCompilationUnitFrom(file, null);
1794 * Creates and returns a handle for the given JAR file. The Java model
1795 * associated with the JAR's project may be created as a side effect.
1798 * the given JAR file
1799 * @return a handle for the given JAR file, or <code>null</code> if unable
1800 * to create a JAR package fragment root. (for example, if the JAR
1801 * file represents a non-Java resource)
1803 //public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile
1805 // return JavaModelManager.createJarPackageFragmentRootFrom(file, null);
1808 * Answers the project specific value for a given classpath container. In
1809 * case this container path could not be resolved, then will answer
1810 * <code>null</code>. Both the container path and the project context are
1811 * supposed to be non-null.
1813 * The containerPath is a formed by a first ID segment followed with extra
1814 * segments, which can be used as additional hints for resolution. If no
1815 * container was ever recorded for this container path onto this project
1816 * (using <code>setClasspathContainer</code>, then a
1817 * <code>ClasspathContainerInitializer</code> will be activated if any was
1818 * registered for this container ID onto the extension point
1819 * "org.eclipse.jdt.core.classpathContainerInitializer".
1821 * There is no assumption that the returned container must answer the exact
1822 * same containerPath when requested
1823 * <code>IClasspathContainer#getPath</code>. Indeed, the containerPath is
1824 * just an indication for resolving it to an actual container object.
1826 * Classpath container values are persisted locally to the workspace, but
1827 * are not preserved from a session to another. It is thus highly
1828 * recommended to register a <code>ClasspathContainerInitializer</code>
1829 * for each referenced container (through the extension point
1830 * "org.eclipse.jdt.core.ClasspathContainerInitializer").
1833 * @param containerPath
1834 * the name of the container, which needs to be resolved
1836 * a specific project in which the container is being resolved
1837 * @return the corresponding classpath container or <code>null</code> if
1838 * unable to find one.
1840 * @exception JavaModelException
1841 * if an exception occurred while resolving the container, or
1842 * if the resolved container contains illegal entries
1843 * (contains CPE_CONTAINER entries or null entries).
1845 * @see ClasspathContainerInitializer
1846 * @see IClasspathContainer
1847 * @see #setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[],
1851 //public static IClasspathContainer getClasspathContainer(final IPath
1852 // containerPath, final IJavaProject project) throws JavaModelException {
1854 // IClasspathContainer container = JavaModelManager.containerGet(project,
1856 // if (container == JavaModelManager.ContainerInitializationInProgress)
1857 // return null; // break cycle
1859 // if (container == null){
1860 // final ClasspathContainerInitializer initializer =
1861 // JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
1862 // if (initializer != null){
1863 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1864 // System.out.println("CPContainer INIT - triggering initialization of:
1865 // ["+project.getElementName()+"] " + containerPath + " using initializer:
1866 // "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
1867 // new Exception("FAKE exception for dumping current CPContainer
1868 // (["+project.getElementName()+"] "+ containerPath+ ")INIT invocation stack
1869 // trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
1871 // JavaModelManager.containerPut(project, containerPath,
1872 // JavaModelManager.ContainerInitializationInProgress); // avoid
1873 // initialization cycles
1874 // boolean ok = false;
1876 // // wrap initializer call with Safe runnable in case initializer would be
1877 // causing some grief
1878 // Platform.run(new ISafeRunnable() {
1879 // public void handleException(Throwable exception) {
1880 // Util.log(exception, "Exception occurred in classpath container
1881 // initializer: "+initializer); //$NON-NLS-1$
1883 // public void run() throws Exception {
1884 // initializer.initialize(containerPath, project);
1888 // // retrieve value (if initialization was successful)
1889 // container = JavaModelManager.containerGet(project, containerPath);
1890 // if (container == JavaModelManager.ContainerInitializationInProgress)
1891 // return null; // break cycle
1894 // if (!ok) JavaModelManager.containerPut(project, containerPath, null); //
1897 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1898 // System.out.print("CPContainer INIT - after resolution:
1899 // ["+project.getElementName()+"] " + containerPath + " --> ");
1900 // //$NON-NLS-2$//$NON-NLS-1$//$NON-NLS-3$
1901 // if (container != null){
1902 // System.out.print("container: "+container.getDescription()+" {");
1903 // //$NON-NLS-2$//$NON-NLS-1$
1904 // IClasspathEntry[] entries = container.getClasspathEntries();
1905 // if (entries != null){
1906 // for (int i = 0; i < entries.length; i++){
1907 // if (i > 0) System.out.println(", ");//$NON-NLS-1$
1908 // System.out.println(entries[i]);
1911 // System.out.println("}");//$NON-NLS-1$
1913 // System.out.println("{unbound}");//$NON-NLS-1$
1917 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1918 // System.out.println("CPContainer INIT - no initializer found for:
1919 // "+project.getElementName()+"] " + containerPath); //$NON-NLS-1$
1924 // return container;
1927 * Helper method finding the classpath container initializer registered for
1928 * a given classpath container ID or <code>null</code> if none was found
1929 * while iterating over the contributions to extension point to the
1930 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
1932 * A containerID is the first segment of any container path, used to
1933 * identify the registered container initializer.
1937 * a containerID identifying a registered initializer
1938 * @return ClasspathContainerInitializer - the registered classpath
1939 * container initializer or <code>null</code> if none was found.
1942 //public static ClasspathContainerInitializer
1943 // getClasspathContainerInitializer(String containerID){
1945 // Plugin jdtCorePlugin = JavaCore.getPlugin();
1946 // if (jdtCorePlugin == null) return null;
1948 // IExtensionPoint extension =
1949 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID);
1950 // if (extension != null) {
1951 // IExtension[] extensions = extension.getExtensions();
1952 // for(int i = 0; i < extensions.length; i++){
1953 // IConfigurationElement [] configElements =
1954 // extensions[i].getConfigurationElements();
1955 // for(int j = 0; j < configElements.length; j++){
1956 // String initializerID = configElements[j].getAttribute("id");
1958 // if (initializerID != null && initializerID.equals(containerID)){
1959 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
1960 // System.out.println("CPContainer INIT - found initializer: "+containerID
1962 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
1965 // Object execExt = configElements[j].createExecutableExtension("class");
1967 // if (execExt instanceof ClasspathContainerInitializer){
1968 // return (ClasspathContainerInitializer)execExt;
1970 // } catch(CoreException e) {
1979 * Returns the path held in the given classpath variable. Returns <node>null
1980 * </code> if unable to bind.
1982 * Classpath variable values are persisted locally to the workspace, and are
1983 * preserved from session to session.
1985 * Note that classpath variables can be contributed registered initializers
1986 * for, using the extension point
1987 * "org.eclipse.jdt.core.classpathVariableInitializer". If an initializer is
1988 * registered for a variable, its persisted value will be ignored: its
1989 * initializer will thus get the opportunity to rebind the variable
1990 * differently on each session.
1992 * @param variableName
1993 * the name of the classpath variable
1994 * @return the path, or <code>null</code> if none
1995 * @see #setClasspathVariable
1997 public static IPath getClasspathVariable(final String variableName) {
1999 IPath variablePath = JavaModelManager.variableGet(variableName);
2000 if (variablePath == JavaModelManager.VariableInitializationInProgress)
2001 return null; // break cycle
2003 if (variablePath != null) {
2004 return variablePath;
2007 // even if persisted value exists, initializer is given priority, only
2008 // if no initializer is found the persisted value is reused
2009 // final ClasspathVariableInitializer initializer =
2010 // PHPCore.getClasspathVariableInitializer(variableName);
2011 // if (initializer != null){
2012 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2013 // System.out.println("CPVariable INIT - triggering initialization of: "
2014 // + variableName+ " using initializer: "+ initializer); //$NON-NLS-1$
2016 // new Exception("FAKE exception for dumping current CPVariable
2017 // ("+variableName+ ")INIT invocation stack trace").printStackTrace();
2018 // //$NON-NLS-1$//$NON-NLS-2$
2020 // JavaModelManager.variablePut(variableName,
2021 // JavaModelManager.VariableInitializationInProgress); // avoid
2022 // initialization cycles
2023 // boolean ok = false;
2025 // // wrap initializer call with Safe runnable in case initializer would
2026 // be causing some grief
2027 // Platform.run(new ISafeRunnable() {
2028 // public void handleException(Throwable exception) {
2029 // Util.log(exception, "Exception occurred in classpath variable
2030 // initializer: "+initializer+" while initializing variable:
2031 // "+variableName); //$NON-NLS-1$ //$NON-NLS-2$
2033 // public void run() throws Exception {
2034 // initializer.initialize(variableName);
2037 // variablePath = (IPath) JavaModelManager.variableGet(variableName); //
2038 // initializer should have performed side-effect
2039 // if (variablePath ==
2040 // JavaModelManager.VariableInitializationInProgress) return null; //
2041 // break cycle (initializer did not init or reentering call)
2042 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2043 // System.out.println("CPVariable INIT - after initialization: " +
2044 // variableName + " --> " + variablePath); //$NON-NLS-2$//$NON-NLS-1$
2048 // if (!ok) JavaModelManager.variablePut(variableName, null); // flush
2052 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2053 // System.out.println("CPVariable INIT - no initializer found for: " +
2054 // variableName); //$NON-NLS-1$
2057 return variablePath;
2061 * Helper method finding the classpath variable initializer registered for a
2062 * given classpath variable name or <code>null</code> if none was found
2063 * while iterating over the contributions to extension point to the
2064 * extension point "org.eclipse.jdt.core.classpathVariableInitializer".
2069 * @return ClasspathVariableInitializer - the registered classpath variable
2070 * initializer or <code>null</code> if none was found.
2073 public static ClasspathVariableInitializer getClasspathVariableInitializer(
2076 Plugin jdtCorePlugin = JavaCore.getPlugin();
2077 if (jdtCorePlugin == null)
2080 // IExtensionPoint extension =
2081 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID);
2082 // if (extension != null) {
2083 // IExtension[] extensions = extension.getExtensions();
2084 // for(int i = 0; i < extensions.length; i++){
2085 // IConfigurationElement [] configElements =
2086 // extensions[i].getConfigurationElements();
2087 // for(int j = 0; j < configElements.length; j++){
2089 // String varAttribute = configElements[j].getAttribute("variable");
2091 // if (variable.equals(varAttribute)) {
2092 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
2093 // System.out.println("CPVariable INIT - found initializer: "+variable+"
2095 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
2098 // configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
2099 // if (execExt instanceof ClasspathVariableInitializer){
2100 // return (ClasspathVariableInitializer)execExt;
2103 // } catch(CoreException e){
2112 * Returns the names of all known classpath variables.
2114 * Classpath variable values are persisted locally to the workspace, and are
2115 * preserved from session to session.
2118 * @return the list of classpath variable names
2119 * @see #setClasspathVariable
2121 //public static String[] getClasspathVariableNames() {
2122 // return JavaModelManager.variableNames();
2125 * Returns a table of all known configurable options with their default
2126 * values. These options allow to configure the behaviour of the underlying
2127 * components. The client may safely use the result as a template that they
2128 * can modify and then pass to <code>setOptions</code>.
2130 * Helper constants have been defined on JavaCore for each of the option ID
2131 * and their possible constant values.
2133 * Note: more options might be added in further releases.
2137 * RECOGNIZED OPTIONS:
2138 * COMPILER / Generating Local Variable Debug Attribute
2139 * When generated, this attribute will enable local variable names
2140 * to be displayed in debugger, only in place where variables are
2141 * definitely assigned (.class file is then bigger)
2142 * - option id: "org.eclipse.jdt.core.compiler.debug.localVariable"
2143 * - possible values: { "generate", "do not generate" }
2144 * - default: "generate"
2146 * COMPILER / Generating Line Number Debug Attribute
2147 * When generated, this attribute will enable source code highlighting in debugger
2148 * (.class file is then bigger).
2149 * - option id: "org.eclipse.jdt.core.compiler.debug.lineNumber"
2150 * - possible values: { "generate", "do not generate" }
2151 * - default: "generate"
2153 * COMPILER / Generating Source Debug Attribute
2154 * When generated, this attribute will enable the debugger to present the
2155 * corresponding source code.
2156 * - option id: "org.eclipse.jdt.core.compiler.debug.sourceFile"
2157 * - possible values: { "generate", "do not generate" }
2158 * - default: "generate"
2160 * COMPILER / Preserving Unused Local Variables
2161 * Unless requested to preserve unused local variables (that is, never read), the
2162 * compiler will optimize them out, potentially altering debugging
2163 * - option id: "org.eclipse.jdt.core.compiler.codegen.unusedLocal"
2164 * - possible values: { "preserve", "optimize out" }
2165 * - default: "preserve"
2167 * COMPILER / Defining Target Java Platform
2168 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
2169 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
2170 * - option id: "org.eclipse.jdt.core.compiler.codegen.targetPlatform"
2171 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
2172 * - default: "1.1"
2174 * COMPILER / Reporting Unreachable Code
2175 * Unreachable code can optionally be reported as an error, warning or simply
2176 * ignored. The bytecode generation will always optimized it out.
2177 * - option id: "org.eclipse.jdt.core.compiler.problem.unreachableCode"
2178 * - possible values: { "error", "warning", "ignore" }
2179 * - default: "error"
2181 * COMPILER / Reporting Invalid Import
2182 * An import statement that cannot be resolved might optionally be reported
2183 * as an error, as a warning or ignored.
2184 * - option id: "org.eclipse.jdt.core.compiler.problem.invalidImport"
2185 * - possible values: { "error", "warning", "ignore" }
2186 * - default: "error"
2188 * COMPILER / Reporting Attempt to Override Package-Default Method
2189 * A package default method is not visible in a different package, and thus
2190 * cannot be overridden. When enabling this option, the compiler will signal
2191 * such scenarii either as an error or a warning.
2192 * - option id: "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"
2193 * - possible values: { "error", "warning", "ignore" }
2194 * - default: "warning"
2196 * COMPILER / Reporting Method With Constructor Name
2197 * Naming a method with a constructor name is generally considered poor
2198 * style programming. When enabling this option, the compiler will signal such
2199 * scenarii either as an error or a warning.
2200 * - option id: "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"
2201 * - possible values: { "error", "warning", "ignore" }
2202 * - default: "warning"
2204 * COMPILER / Reporting Deprecation
2205 * When enabled, the compiler will signal use of deprecated API either as an
2206 * error or a warning.
2207 * - option id: "org.eclipse.jdt.core.compiler.problem.deprecation"
2208 * - possible values: { "error", "warning", "ignore" }
2209 * - default: "warning"
2211 * COMPILER / Reporting Deprecation Inside Deprecated Code
2212 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
2213 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.deprecation".
2214 * - option id: "org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode"
2215 * - possible values: { "enabled", "disabled" }
2216 * - default: "disabled"
2218 * COMPILER / Reporting Hidden Catch Block
2219 * Locally to a try statement, some catch blocks may hide others . For example,
2220 * try { throw new java.io.CharConversionException();
2221 * } catch (java.io.CharConversionException e) {
2222 * } catch (java.io.IOException e) {}.
2223 * When enabling this option, the compiler will issue an error or a warning for hidden
2224 * catch blocks corresponding to checked exceptions
2225 * - option id: "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"
2226 * - possible values: { "error", "warning", "ignore" }
2227 * - default: "warning"
2229 * COMPILER / Reporting Unused Local
2230 * When enabled, the compiler will issue an error or a warning for unused local
2231 * variables (that is, variables never read from)
2232 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedLocal"
2233 * - possible values: { "error", "warning", "ignore" }
2234 * - default: "ignore"
2236 * COMPILER / Reporting Unused Parameter
2237 * When enabled, the compiler will issue an error or a warning for unused method
2238 * parameters (that is, parameters never read from)
2239 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameter"
2240 * - possible values: { "error", "warning", "ignore" }
2241 * - default: "ignore"
2243 * COMPILER / Reporting Unused Parameter if Implementing Abstract Method
2244 * When enabled, the compiler will signal unused parameters in abstract method implementations.
2245 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
2246 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"
2247 * - possible values: { "enabled", "disabled" }
2248 * - default: "disabled"
2250 * COMPILER / Reporting Unused Parameter if Overriding Concrete Method
2251 * When enabled, the compiler will signal unused parameters in methods overriding concrete ones.
2252 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
2253 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"
2254 * - possible values: { "enabled", "disabled" }
2255 * - default: "disabled"
2257 * COMPILER / Reporting Unused Import
2258 * When enabled, the compiler will issue an error or a warning for unused import
2260 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedImport"
2261 * - possible values: { "error", "warning", "ignore" }
2262 * - default: "warning"
2264 * COMPILER / Reporting Unused Private Members
2265 * When enabled, the compiler will issue an error or a warning whenever a private
2266 * method or field is declared but never used within the same unit.
2267 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"
2268 * - possible values: { "error", "warning", "ignore" }
2269 * - default: "ignore"
2271 * COMPILER / Reporting Synthetic Access Emulation
2272 * When enabled, the compiler will issue an error or a warning whenever it emulates
2273 * access to a non-accessible member of an enclosing type. Such access can have
2274 * performance implications.
2275 * - option id: "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"
2276 * - possible values: { "error", "warning", "ignore" }
2277 * - default: "ignore"
2279 * COMPILER / Reporting Non-Externalized String Literal
2280 * When enabled, the compiler will issue an error or a warning for non externalized
2281 * String literal (that is, not tagged with //$NON-NLS-<n>$).
2282 * - option id: "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"
2283 * - possible values: { "error", "warning", "ignore" }
2284 * - default: "ignore"
2286 * COMPILER / Reporting Usage of 'assert' Identifier
2287 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
2288 * used as an identifier (reserved keyword in 1.4)
2289 * - option id: "org.eclipse.jdt.core.compiler.problem.assertIdentifier"
2290 * - possible values: { "error", "warning", "ignore" }
2291 * - default: "ignore"
2293 * COMPILER / Reporting Non-Static Reference to a Static Member
2294 * When enabled, the compiler will issue an error or a warning whenever a static field
2295 * or method is accessed with an expression receiver. A reference to a static member should
2296 * be qualified with a type name.
2297 * - option id: "org.eclipse.jdt.core.compiler.problem.staticAccessReceiver"
2298 * - possible values: { "error", "warning", "ignore" }
2299 * - default: "warning"
2301 * COMPILER / Reporting Assignment with no Effect
2302 * When enabled, the compiler will issue an error or a warning whenever an assignment
2303 * has no effect (e.g 'x = x').
2304 * - option id: "org.eclipse.jdt.core.compiler.problem.noEffectAssignment"
2305 * - possible values: { "error", "warning", "ignore" }
2306 * - default: "warning"
2308 * COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods
2309 * When enabled, the compiler will issue an error or a warning whenever an interface
2310 * defines a method incompatible with a non-inherited Object method. Until this conflict
2311 * is resolved, such an interface cannot be implemented, For example,
2315 * - option id: "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"
2316 * - possible values: { "error", "warning", "ignore" }
2317 * - default: "warning"
2319 * COMPILER / Reporting Usage of char[] Expressions in String Concatenations
2320 * When enabled, the compiler will issue an error or a warning whenever a char[] expression
2321 * is used in String concatenations (for example, "hello" + new char[]{'w','o','r','l','d'}).
2322 * - option id: "org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion"
2323 * - possible values: { "error", "warning", "ignore" }
2324 * - default: "warning"
2326 * COMPILER / Setting Source Compatibility Mode
2327 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
2328 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
2329 * level should be set to "1.4" and the compliance mode should be "1.4".
2330 * - option id: "org.eclipse.jdt.core.compiler.source"
2331 * - possible values: { "1.3", "1.4" }
2332 * - default: "1.3"
2334 * COMPILER / Setting Compliance Level
2335 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
2336 * should not go beyond "1.3" level.
2337 * - option id: "org.eclipse.jdt.core.compiler.compliance"
2338 * - possible values: { "1.3", "1.4" }
2339 * - default: "1.3"
2341 * COMPILER / Maximum number of problems reported per compilation unit
2342 * Specify the maximum number of problems reported on each compilation unit.
2343 * - option id: "org.eclipse.jdt.core.compiler.maxProblemPerUnit"
2344 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
2345 * - default: "100"
2347 * COMPILER / Define the Automatic Task Tags
2348 * When the tag list is not empty, the compiler will issue a task marker whenever it encounters
2349 * one of the corresponding tag inside any comment in Java source code.
2350 * Generated task messages will include the tag, and range until the next line separator or comment ending.
2351 * Note that tasks messages are trimmed.
2352 * - option id: "org.eclipse.jdt.core.compiler.taskTags"
2353 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card or leading/trailing spaces
2354 * - default: ""
2356 * COMPILER / Define the Automatic Task Priorities
2357 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
2358 * of the task markers issued by the compiler.
2359 * If the default is specified, the priority of each task marker is "NORMAL".
2360 * - option id: "org.eclipse.jdt.core.compiler.taskPriorities"
2361 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
2362 * - default: ""
2364 * BUILDER / Specifying Filters for Resource Copying Control
2365 * Allow to specify some filters to control the resource copy process.
2366 * - option id: "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
2367 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
2368 * or the name of a folder which ends with '/'
2369 * - default: ""
2371 * BUILDER / Abort if Invalid Classpath
2372 * Allow to toggle the builder to abort if the classpath is invalid
2373 * - option id: "org.eclipse.jdt.core.builder.invalidClasspath"
2374 * - possible values: { "abort", "ignore" }
2375 * - default: "abort"
2377 * BUILDER / Cleaning Output Folder(s)
2378 * Indicate whether the JavaBuilder is allowed to clean the output folders
2379 * when performing full build operations.
2380 * - option id: "org.eclipse.jdt.core.builder.cleanOutputFolder"
2381 * - possible values: { "clean", "ignore" }
2382 * - default: "clean"
2384 * BUILDER / Reporting Duplicate Resources
2385 * Indicate the severity of the problem reported when more than one occurrence
2386 * of a resource is to be copied into the output location.
2387 * - option id: "org.eclipse.jdt.core.builder.duplicateResourceTask"
2388 * - possible values: { "error", "warning" }
2389 * - default: "warning"
2391 * JAVACORE / Computing Project Build Order
2392 * Indicate whether JavaCore should enforce the project build order to be based on
2393 * the classpath prerequisite chain. When requesting to compute, this takes over
2394 * the platform default order (based on project references).
2395 * - option id: "org.eclipse.jdt.core.computeJavaBuildOrder"
2396 * - possible values: { "compute", "ignore" }
2397 * - default: "ignore"
2399 * JAVACORE / Specify Default Source Encoding Format
2400 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
2401 * to 'ResourcesPlugin.getEncoding()'.
2402 * - option id: "org.eclipse.jdt.core.encoding"
2403 * - possible values: { any of the supported encoding name}.
2404 * - default: <platform default>
2406 * JAVACORE / Reporting Incomplete Classpath
2407 * Indicate the severity of the problem reported when an entry on the classpath does not exist,
2408 * is not legite or is not visible (for example, a referenced project is closed).
2409 * - option id: "org.eclipse.jdt.core.incompleteClasspath"
2410 * - possible values: { "error", "warning"}
2411 * - default: "error"
2413 * JAVACORE / Reporting Classpath Cycle
2414 * Indicate the severity of the problem reported when a project is involved in a cycle.
2415 * - option id: "org.eclipse.jdt.core.circularClasspath"
2416 * - possible values: { "error", "warning" }
2417 * - default: "error"
2419 * JAVACORE / Enabling Usage of Classpath Exclusion Patterns
2420 * When disabled, no entry on a project classpath can be associated with
2421 * an exclusion pattern.
2422 * - option id: "org.eclipse.jdt.core.classpath.exclusionPatterns"
2423 * - possible values: { "enabled", "disabled" }
2424 * - default: "enabled"
2426 * JAVACORE / Enabling Usage of Classpath Multiple Output Locations
2427 * When disabled, no entry on a project classpath can be associated with
2428 * a specific output location, preventing thus usage of multiple output locations.
2429 * - option id: "org.eclipse.jdt.core.classpath.multipleOutputLocations"
2430 * - possible values: { "enabled", "disabled" }
2431 * - default: "enabled"
2433 * FORMATTER / Inserting New Line Before Opening Brace
2434 * When Insert, a new line is inserted before an opening brace, otherwise nothing
2436 * - option id: "org.eclipse.jdt.core.formatter.newline.openingBrace"
2437 * - possible values: { "insert", "do not insert" }
2438 * - default: "do not insert"
2440 * FORMATTER / Inserting New Line Inside Control Statement
2441 * When Insert, a new line is inserted between } and following else, catch, finally
2442 * - option id: "org.eclipse.jdt.core.formatter.newline.controlStatement"
2443 * - possible values: { "insert", "do not insert" }
2444 * - default: "do not insert"
2446 * FORMATTER / Clearing Blank Lines
2447 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
2448 * and all others removed.
2449 * - option id: "org.eclipse.jdt.core.formatter.newline.clearAll"
2450 * - possible values: { "clear all", "preserve one" }
2451 * - default: "preserve one"
2453 * FORMATTER / Inserting New Line Between Else/If
2454 * When Insert, a blank line is inserted between an else and an if when they are
2455 * contiguous. When choosing to not insert, else-if will be kept on the same
2456 * line when possible.
2457 * - option id: "org.eclipse.jdt.core.formatter.newline.elseIf"
2458 * - possible values: { "insert", "do not insert" }
2459 * - default: "do not insert"
2461 * FORMATTER / Inserting New Line In Empty Block
2462 * When insert, a line break is inserted between contiguous { and }, if } is not followed
2464 * - option id: "org.eclipse.jdt.core.formatter.newline.emptyBlock"
2465 * - possible values: { "insert", "do not insert" }
2466 * - default: "insert"
2468 * FORMATTER / Splitting Lines Exceeding Length
2469 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
2470 * disable line splitting
2471 * - option id: "org.eclipse.jdt.core.formatter.lineSplit"
2472 * - possible values: "<n>", where n is zero or a positive integer
2473 * - default: "80"
2475 * FORMATTER / Compacting Assignment
2476 * Assignments can be formatted asymmetrically, for example 'int x= 2;', when Normal, a space
2477 * is inserted before the assignment operator
2478 * - option id: "org.eclipse.jdt.core.formatter.style.assignment"
2479 * - possible values: { "compact", "normal" }
2480 * - default: "normal"
2482 * FORMATTER / Defining Indentation Character
2483 * Either choose to indent with tab characters or spaces
2484 * - option id: "org.eclipse.jdt.core.formatter.tabulation.char"
2485 * - possible values: { "tab", "space" }
2486 * - default: "tab"
2488 * FORMATTER / Defining Space Indentation Length
2489 * When using spaces, set the amount of space characters to use for each
2491 * - option id: "org.eclipse.jdt.core.formatter.tabulation.size"
2492 * - possible values: "<n>", where n is a positive integer
2493 * - default: "4"
2495 * FORMATTER / Inserting space in cast expression
2496 * When Insert, a space is added between the type and the expression in a cast expression.
2497 * - option id: "org.eclipse.jdt.core.formatter.space.castexpression"
2498 * - possible values: { "insert", "do not insert" }
2499 * - default: "insert"
2501 * CODEASSIST / Activate Visibility Sensitive Completion
2502 * When active, completion doesn't show that you can not see
2503 * (for example, you can not see private methods of a super class).
2504 * - option id: "org.eclipse.jdt.core.codeComplete.visibilityCheck"
2505 * - possible values: { "enabled", "disabled" }
2506 * - default: "disabled"
2508 * CODEASSIST / Automatic Qualification of Implicit Members
2509 * When active, completion automatically qualifies completion on implicit
2510 * field references and message expressions.
2511 * - option id: "org.eclipse.jdt.core.codeComplete.forceImplicitQualification"
2512 * - possible values: { "enabled", "disabled" }
2513 * - default: "disabled"
2515 * CODEASSIST / Define the Prefixes for Field Name
2516 * When the prefixes is non empty, completion for field name will begin with
2517 * one of the proposed prefixes.
2518 * - option id: "org.eclipse.jdt.core.codeComplete.fieldPrefixes"
2519 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2520 * - default: ""
2522 * CODEASSIST / Define the Prefixes for Static Field Name
2523 * When the prefixes is non empty, completion for static field name will begin with
2524 * one of the proposed prefixes.
2525 * - option id: "org.eclipse.jdt.core.codeComplete.staticFieldPrefixes"
2526 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2527 * - default: ""
2529 * CODEASSIST / Define the Prefixes for Local Variable Name
2530 * When the prefixes is non empty, completion for local variable name will begin with
2531 * one of the proposed prefixes.
2532 * - option id: "org.eclipse.jdt.core.codeComplete.localPrefixes"
2533 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2534 * - default: ""
2536 * CODEASSIST / Define the Prefixes for Argument Name
2537 * When the prefixes is non empty, completion for argument name will begin with
2538 * one of the proposed prefixes.
2539 * - option id: "org.eclipse.jdt.core.codeComplete.argumentPrefixes"
2540 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2541 * - default: ""
2543 * CODEASSIST / Define the Suffixes for Field Name
2544 * When the suffixes is non empty, completion for field name will end with
2545 * one of the proposed suffixes.
2546 * - option id: "org.eclipse.jdt.core.codeComplete.fieldSuffixes"
2547 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2548 * - default: ""
2550 * CODEASSIST / Define the Suffixes for Static Field Name
2551 * When the suffixes is non empty, completion for static field name will end with
2552 * one of the proposed suffixes.
2553 * - option id: "org.eclipse.jdt.core.codeComplete.staticFieldSuffixes"
2554 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2555 * - default: ""
2557 * CODEASSIST / Define the Suffixes for Local Variable Name
2558 * When the suffixes is non empty, completion for local variable name will end with
2559 * one of the proposed suffixes.
2560 * - option id: "org.eclipse.jdt.core.codeComplete.localSuffixes"
2561 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2562 * - default: ""
2564 * CODEASSIST / Define the Suffixes for Argument Name
2565 * When the suffixes is non empty, completion for argument name will end with
2566 * one of the proposed suffixes.
2567 * - option id: "org.eclipse.jdt.core.codeComplete.argumentSuffixes"
2568 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
2569 * - default: ""
2572 * @return a mutable table containing the default settings of all known options
2585 public static Hashtable getDefaultOptions() {
2587 Hashtable defaultOptions = new Hashtable(10);
2589 // see #initializeDefaultPluginPreferences() for changing default
2591 Preferences preferences = getPlugin().getPluginPreferences();
2592 HashSet optionNames = JavaModelManager.OptionNames;
2594 // get preferences set to their default
2595 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2596 for (int i = 0; i < defaultPropertyNames.length; i++) {
2597 String propertyName = defaultPropertyNames[i];
2598 if (optionNames.contains(propertyName)) {
2599 defaultOptions.put(propertyName, preferences
2600 .getDefaultString(propertyName));
2603 // get preferences not set to their default
2604 String[] propertyNames = preferences.propertyNames();
2605 for (int i = 0; i < propertyNames.length; i++) {
2606 String propertyName = propertyNames[i];
2607 if (optionNames.contains(propertyName)) {
2608 defaultOptions.put(propertyName, preferences
2609 .getDefaultString(propertyName));
2612 // get encoding through resource plugin
2613 defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2615 return defaultOptions;
2619 * Returns the single instance of the Java core plug-in runtime class.
2620 * Equivalent to <code>(JavaCore) getPlugin()</code>.
2622 * @return the single instance of the Java core plug-in runtime class
2624 public static PHPeclipsePlugin getJavaCore() {
2625 return (PHPeclipsePlugin) getPlugin();
2629 * Helper method for returning one option value only. Equivalent to
2630 * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
2631 * may answer <code>null</code> if this option does not exist.
2633 * For a complete description of the configurable options, see
2634 * <code>getDefaultOptions</code>.
2638 * the name of an option
2639 * @return the String value of a given option
2640 * @see JavaCore#getDefaultOptions
2643 public static String getOption(String optionName) {
2645 if (CORE_ENCODING.equals(optionName)) {
2646 return ResourcesPlugin.getEncoding();
2648 if (JavaModelManager.OptionNames.contains(optionName)) {
2649 Preferences preferences = getPlugin().getPluginPreferences();
2650 return preferences.getString(optionName).trim();
2656 * Returns the table of the current options. Initially, all options have
2657 * their default values, and this method returns a table that includes all
2660 * For a complete description of the configurable options, see
2661 * <code>getDefaultOptions</code>.
2664 * @return table of current settings of all options (key type:
2665 * <code>String</code>; value type: <code>String</code>)
2666 * @see JavaCore#getDefaultOptions
2668 public static Hashtable getOptions() {
2670 Hashtable options = new Hashtable(10);
2672 // see #initializeDefaultPluginPreferences() for changing default
2674 Plugin plugin = getPlugin();
2675 if (plugin != null) {
2676 Preferences preferences = getPlugin().getPluginPreferences();
2677 HashSet optionNames = JavaModelManager.OptionNames;
2679 // get preferences set to their default
2680 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2681 for (int i = 0; i < defaultPropertyNames.length; i++) {
2682 String propertyName = defaultPropertyNames[i];
2683 if (optionNames.contains(propertyName)) {
2684 options.put(propertyName, preferences
2685 .getDefaultString(propertyName));
2688 // get preferences not set to their default
2689 String[] propertyNames = preferences.propertyNames();
2690 for (int i = 0; i < propertyNames.length; i++) {
2691 String propertyName = propertyNames[i];
2692 if (optionNames.contains(propertyName)) {
2693 options.put(propertyName, preferences.getString(
2694 propertyName).trim());
2697 // get encoding through resource plugin
2698 options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2704 * This is a helper method, which returns the resolved classpath entry
2705 * denoted by a given entry (if it is a variable entry). It is obtained by
2706 * resolving the variable reference in the first segment. Returns <node>null
2707 * </code> if unable to resolve using the following algorithm:
2709 * <li>if variable segment cannot be resolved, returns <code>null</code>
2711 * <li>finds a project, JAR or binary folder in the workspace at the
2712 * resolved path location</li>
2713 * <li>if none finds an external JAR file or folder outside the workspace
2714 * at the resolved path location</li>
2715 * <li>if none returns <code>null</code></li>
2718 * Variable source attachment path and root path are also resolved and
2719 * recorded in the resulting classpath entry.
2721 * NOTE: This helper method does not handle classpath containers, for which
2722 * should rather be used <code>JavaCore#getClasspathContainer(IPath,
2723 * IJavaProject)</code>.
2727 * the given variable entry
2728 * @return the resolved library or project classpath entry, or <code>null
2729 * </code> if the given variable entry could not be resolved to a
2730 * valid classpath entry
2732 public static IClasspathEntry getResolvedClasspathEntry(
2733 IClasspathEntry entry) {
2735 if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
2738 IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
2739 IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath());
2740 if (resolvedPath == null)
2743 Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false);
2747 // inside the workspace
2748 if (target instanceof IResource) {
2749 IResource resolvedResource = (IResource) target;
2750 if (resolvedResource != null) {
2751 switch (resolvedResource.getType()) {
2753 case IResource.PROJECT:
2755 return JavaCore.newProjectEntry(resolvedPath, entry
2758 case IResource.FILE:
2759 // if (Util.isArchiveFileName(resolvedResource.getName())) {
2760 // // internal binary archive
2761 // return JavaCore.newLibraryEntry(
2763 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2764 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2765 // entry.isExported());
2769 case IResource.FOLDER:
2770 // internal binary folder
2771 // return JavaCore.newLibraryEntry(
2773 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2774 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2775 // entry.isExported());
2780 // outside the workspace
2781 if (target instanceof File) {
2782 File externalFile = (File) target;
2783 if (externalFile.isFile()) {
2784 String fileName = externalFile.getName().toLowerCase();
2785 // if (fileName.endsWith(".jar" //$NON-NLS-1$
2786 // ) || fileName.endsWith(".zip" //$NON-NLS-1$
2787 // )) { // external binary archive
2788 // return JavaCore.newLibraryEntry(
2790 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2791 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2792 // entry.isExported());
2794 } else { // external binary folder
2795 if (resolvedPath.isAbsolute()) {
2796 // return JavaCore.newLibraryEntry(
2798 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2799 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2800 // entry.isExported());
2808 * Resolve a variable path (helper method).
2810 * @param variablePath
2811 * the given variable path
2812 * @return the resolved variable path or <code>null</code> if none
2814 public static IPath getResolvedVariablePath(IPath variablePath) {
2816 if (variablePath == null)
2818 int count = variablePath.segmentCount();
2823 String variableName = variablePath.segment(0);
2824 IPath resolvedPath = JavaCore.getClasspathVariable(variableName);
2825 if (resolvedPath == null)
2828 // append path suffix
2830 resolvedPath = resolvedPath.append(variablePath
2831 .removeFirstSegments(1));
2833 return resolvedPath;
2837 * Answers the shared working copies currently registered for this buffer
2838 * factory. Working copies can be shared by several clients using the same
2839 * buffer factory,see <code>IWorkingCopy.getSharedWorkingCopy</code>.
2842 * the given buffer factory
2843 * @return the list of shared working copies for a given buffer factory
2847 public static IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory) {
2849 // if factory is null, default factory must be used
2850 if (factory == null)
2851 factory = BufferManager.getDefaultBufferManager()
2852 .getDefaultBufferFactory();
2853 Map sharedWorkingCopies = JavaModelManager.getJavaModelManager().sharedWorkingCopies;
2855 Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
2856 if (perFactoryWorkingCopies == null)
2857 return JavaModelManager.NoWorkingCopy;
2858 Collection copies = perFactoryWorkingCopies.values();
2859 IWorkingCopy[] result = new IWorkingCopy[copies.size()];
2860 copies.toArray(result);
2865 * Initializes the default preferences settings for this plug-in.
2867 public static void initializeDefaultPluginPreferences() {
2869 Preferences preferences = PHPeclipsePlugin.getDefault()
2870 .getPluginPreferences();
2871 HashSet optionNames = JavaModelManager.OptionNames;
2873 // Compiler settings
2874 preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
2875 optionNames.add(COMPILER_LOCAL_VARIABLE_ATTR);
2877 preferences.setDefault(COMPILER_LINE_NUMBER_ATTR, GENERATE);
2878 optionNames.add(COMPILER_LINE_NUMBER_ATTR);
2880 preferences.setDefault(COMPILER_SOURCE_FILE_ATTR, GENERATE);
2881 optionNames.add(COMPILER_SOURCE_FILE_ATTR);
2883 preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE);
2884 optionNames.add(COMPILER_CODEGEN_UNUSED_LOCAL);
2886 preferences.setDefault(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1);
2887 optionNames.add(COMPILER_CODEGEN_TARGET_PLATFORM);
2889 preferences.setDefault(COMPILER_PB_PHP_VAR_DEPRECATED, WARNING);
2890 optionNames.add(COMPILER_PB_PHP_VAR_DEPRECATED);
2892 preferences.setDefault(COMPILER_PB_UNREACHABLE_CODE, ERROR);
2893 optionNames.add(COMPILER_PB_UNREACHABLE_CODE);
2895 preferences.setDefault(COMPILER_PB_INVALID_IMPORT, ERROR);
2896 optionNames.add(COMPILER_PB_INVALID_IMPORT);
2898 preferences.setDefault(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD,
2900 optionNames.add(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD);
2902 preferences.setDefault(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME,
2904 optionNames.add(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME);
2906 preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING);
2907 optionNames.add(COMPILER_PB_DEPRECATION);
2909 preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE,
2911 optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE);
2913 preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING);
2914 optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK);
2916 preferences.setDefault(COMPILER_PB_UNUSED_LOCAL, IGNORE);
2917 optionNames.add(COMPILER_PB_UNUSED_LOCAL);
2919 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE);
2920 optionNames.add(COMPILER_PB_UNUSED_PARAMETER);
2922 preferences.setDefault(
2923 COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT,
2926 .add(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT);
2930 COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE,
2932 optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE);
2934 preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING);
2935 optionNames.add(COMPILER_PB_UNUSED_IMPORT);
2937 preferences.setDefault(COMPILER_PB_UNUSED_PRIVATE_MEMBER, IGNORE);
2938 optionNames.add(COMPILER_PB_UNUSED_PRIVATE_MEMBER);
2940 preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE);
2941 optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION);
2943 preferences.setDefault(COMPILER_PB_NON_NLS_STRING_LITERAL, IGNORE);
2944 optionNames.add(COMPILER_PB_NON_NLS_STRING_LITERAL);
2946 preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE);
2947 optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER);
2949 preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING);
2950 optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER);
2952 preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING);
2953 optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT);
2955 preferences.setDefault(
2956 COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD,
2959 .add(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD);
2961 preferences.setDefault(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION,
2963 optionNames.add(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION);
2965 preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAG); //$NON-NLS-1$
2966 optionNames.add(COMPILER_TASK_TAGS);
2968 preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITY); //$NON-NLS-1$
2969 optionNames.add(COMPILER_TASK_PRIORITIES);
2971 preferences.setDefault(COMPILER_SOURCE, VERSION_1_3);
2972 optionNames.add(COMPILER_SOURCE);
2974 preferences.setDefault(COMPILER_COMPLIANCE, VERSION_1_3);
2975 optionNames.add(COMPILER_COMPLIANCE);
2977 preferences.setDefault(COMPILER_PB_MAX_PER_UNIT, "100"); //$NON-NLS-1$
2978 optionNames.add(COMPILER_PB_MAX_PER_UNIT);
2981 preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
2982 optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
2984 preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT);
2985 optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH);
2987 preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING);
2988 optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE);
2990 preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN);
2991 optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER);
2993 // JavaCore settings
2994 preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE);
2995 optionNames.add(CORE_JAVA_BUILD_ORDER);
2997 preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR);
2998 optionNames.add(CORE_CIRCULAR_CLASSPATH);
3000 preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR);
3001 optionNames.add(CORE_INCOMPLETE_CLASSPATH);
3003 preferences.setDefault(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS,
3005 optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS);
3007 preferences.setDefault(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS,
3009 optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS);
3011 // encoding setting comes from resource plug-in
3012 optionNames.add(CORE_ENCODING);
3014 // Formatter settings
3015 preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT);
3016 optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE);
3018 preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT);
3019 optionNames.add(FORMATTER_NEWLINE_CONTROL);
3021 preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE);
3022 optionNames.add(FORMATTER_CLEAR_BLANK_LINES);
3024 preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT);
3025 optionNames.add(FORMATTER_NEWLINE_ELSE_IF);
3027 preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT);
3028 optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK);
3030 preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$
3031 optionNames.add(FORMATTER_LINE_SPLIT);
3033 preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL);
3034 optionNames.add(FORMATTER_COMPACT_ASSIGNMENT);
3036 preferences.setDefault(FORMATTER_TAB_CHAR, TAB);
3037 optionNames.add(FORMATTER_TAB_CHAR);
3039 preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$
3040 optionNames.add(FORMATTER_TAB_SIZE);
3042 preferences.setDefault(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$
3043 optionNames.add(FORMATTER_SPACE_CASTEXPRESSION);
3045 // CodeAssist settings
3046 preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$
3047 optionNames.add(CODEASSIST_VISIBILITY_CHECK);
3049 preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$
3050 optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION);
3052 preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
3053 optionNames.add(CODEASSIST_FIELD_PREFIXES);
3055 preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
3056 optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES);
3058 preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
3059 optionNames.add(CODEASSIST_LOCAL_PREFIXES);
3061 preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
3062 optionNames.add(CODEASSIST_ARGUMENT_PREFIXES);
3064 preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3065 optionNames.add(CODEASSIST_FIELD_SUFFIXES);
3067 preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3068 optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES);
3070 preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
3071 optionNames.add(CODEASSIST_LOCAL_SUFFIXES);
3073 preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
3074 optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES);
3078 * Returns whether the given marker references the given Java element. Used
3079 * for markers, which denote a Java element rather than a resource.
3085 * @return <code>true</code> if the marker references the element, false
3087 * @exception CoreException
3088 * if the <code>IMarker.getAttribute</code> on the marker
3091 public static boolean isReferencedBy(IJavaElement element, IMarker marker)
3092 throws CoreException {
3094 // only match units or classfiles
3095 if (element instanceof IMember) {
3096 IMember member = (IMember) element;
3097 if (member.isBinary()) {
3098 element = null; //member.getClassFile();
3100 element = member.getCompilationUnit();
3103 if (element == null)
3108 String markerHandleId = (String) marker.getAttribute(ATT_HANDLE_ID);
3109 if (markerHandleId == null)
3112 IJavaElement markerElement = JavaCore.create(markerHandleId);
3114 if (element.equals(markerElement))
3115 return true; // external elements may still be equal with different
3118 // cycle through enclosing types in case marker is associated with a
3119 // classfile (15568)
3120 // if (markerElement instanceof IClassFile){
3121 // IType enclosingType =
3122 // ((IClassFile)markerElement).getType().getDeclaringType();
3123 // if (enclosingType != null){
3124 // markerElement = enclosingType.getClassFile(); // retry with immediate
3125 // enclosing classfile
3135 * Returns whether the given marker delta references the given Java element.
3136 * Used for markers deltas, which denote a Java element rather than a
3141 * @param markerDelta
3143 * @return <code>true</code> if the marker delta references the element
3144 * @exception CoreException
3145 * if the <code>IMarkerDelta.getAttribute</code> on the
3146 * marker delta fails
3148 public static boolean isReferencedBy(IJavaElement element,
3149 IMarkerDelta markerDelta) throws CoreException {
3151 // only match units or classfiles
3152 if (element instanceof IMember) {
3153 IMember member = (IMember) element;
3154 if (member.isBinary()) {
3155 element = null; //member.getClassFile();
3157 element = member.getCompilationUnit();
3160 if (element == null)
3162 if (markerDelta == null)
3165 String markerDeltarHandleId = (String) markerDelta
3166 .getAttribute(ATT_HANDLE_ID);
3167 if (markerDeltarHandleId == null)
3170 IJavaElement markerElement = JavaCore.create(markerDeltarHandleId);
3172 if (element.equals(markerElement))
3173 return true; // external elements may still be equal with different
3176 // cycle through enclosing types in case marker is associated with a
3177 // classfile (15568)
3178 // if (markerElement instanceof IClassFile){
3179 // IType enclosingType =
3180 // ((IClassFile)markerElement).getType().getDeclaringType();
3181 // if (enclosingType != null){
3182 // markerElement = enclosingType.getClassFile(); // retry with immediate
3183 // enclosing classfile
3193 * Creates and returns a new classpath entry of kind
3194 * <code>CPE_CONTAINER</code> for the given path. The path of the
3195 * container will be used during resolution so as to map this container
3196 * entry to a set of other classpath entries the container is acting for.
3198 * A container entry allows to express indirect references to a set of
3199 * libraries, projects and variable entries, which can be interpreted
3200 * differently for each Java project where it is used. A classpath container
3201 * entry can be resolved using
3202 * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3203 * <code>JavaCore.classpathContainerChanged</code>
3205 * A container is exclusively resolved by a
3206 * <code>ClasspathContainerInitializer</code> registered onto the
3207 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3209 * A container path must be formed of at least one segment, where:
3211 * <li>the first segment is a unique ID identifying the target container,
3212 * there must be a container initializer registered onto this ID through the
3213 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3215 * <li>the remaining segments will be passed onto the initializer, and can
3216 * be used as additional hints during the initialization phase.</li>
3219 * Example of an ClasspathContainerInitializer for a classpath container
3220 * denoting a default JDK container:
3222 * containerEntry = JavaCore.newContainerEntry(new
3223 * Path("MyProvidedJDK/default"));
3225 * <extension point="org.eclipse.jdt.core.classpathContainerInitializer">
3226 * <containerInitializer id="MyProvidedJDK"
3227 * class="com.example.MyInitializer"/>
3229 * Note that this operation does not attempt to validate classpath
3230 * containers or access the resources at the given paths.
3232 * The resulting entry is not exported to dependent projects. This method is
3233 * equivalent to <code>newContainerEntry(-,false)</code>.
3236 * @param containerPath
3237 * the path identifying the container, it must be formed of two
3239 * @return a new container classpath entry
3241 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3242 * @see JavaCore#newContainerEntry(IPath, boolean)
3245 public static IClasspathEntry newContainerEntry(IPath containerPath) {
3247 return newContainerEntry(containerPath, false);
3251 * Creates and returns a new classpath entry of kind
3252 * <code>CPE_CONTAINER</code> for the given path. The path of the
3253 * container will be used during resolution so as to map this container
3254 * entry to a set of other classpath entries the container is acting for.
3256 * A container entry allows to express indirect references to a set of
3257 * libraries, projects and variable entries, which can be interpreted
3258 * differently for each Java project where it is used. A classpath container
3259 * entry can be resolved using
3260 * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3261 * <code>JavaCore.classpathContainerChanged</code>
3263 * A container is exclusively resolved by a
3264 * <code>ClasspathContainerInitializer</code> registered onto the
3265 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3267 * A container path must be formed of at least one segment, where:
3269 * <li>the first segment is a unique ID identifying the target container,
3270 * there must be a container initializer registered onto this ID through the
3271 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3273 * <li>the remaining segments will be passed onto the initializer, and can
3274 * be used as additional hints during the initialization phase.</li>
3277 * Example of an ClasspathContainerInitializer for a classpath container
3278 * denoting a default JDK container:
3280 * containerEntry = JavaCore.newContainerEntry(new
3281 * Path("MyProvidedJDK/default"));
3283 * <extension point="org.eclipse.jdt.core.classpathContainerInitializer">
3284 * <containerInitializer id="MyProvidedJDK"
3285 * class="com.example.MyInitializer"/>
3287 * Note that this operation does not attempt to validate classpath
3288 * containers or access the resources at the given paths.
3291 * @param containerPath
3292 * the path identifying the container, it must be formed of at
3293 * least one segment (ID+hints)
3295 * a boolean indicating whether this entry is contributed to
3296 * dependent projects in addition to the output location
3297 * @return a new container classpath entry
3299 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3300 * @see JavaCore#setClasspathContainer(IPath, IJavaProject[],
3301 * IClasspathContainer[], IProgressMonitor)
3302 * @see JavaCore#newContainerEntry(IPath, boolean)
3305 public static IClasspathEntry newContainerEntry(IPath containerPath,
3306 boolean isExported) {
3308 if (containerPath == null || containerPath.segmentCount() < 1) {
3312 "Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$
3314 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3315 IClasspathEntry.CPE_CONTAINER, containerPath,
3316 ClasspathEntry.NO_EXCLUSION_PATTERNS, null, // source attachment
3317 null, // source attachment root
3318 null, // specific output folder
3323 * Creates and returns a new non-exported classpath entry of kind
3324 * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3325 * absolute path. This specifies that all package fragments within the root
3326 * will have children of type <code>IClassFile</code>.
3328 * A library entry is used to denote a prerequisite JAR or root folder
3329 * containing binaries. The target JAR or folder can either be defined
3330 * internally to the workspace (absolute path relative to the workspace
3331 * root) or externally to the workspace (absolute path in the file system).
3333 * e.g. Here are some examples of binary path usage
3335 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3337 * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3339 * <li><code> "c:/classes/" </code>- reference to an external binary
3342 * Note that this operation does not attempt to validate or access the
3343 * resources at the given paths.
3345 * The resulting entry is not exported to dependent projects. This method is
3346 * equivalent to <code>newLibraryEntry(-,-,-,false)</code>.
3350 * the absolute path of the binary archive
3351 * @param sourceAttachmentPath
3352 * the absolute path of the corresponding source archive or
3353 * folder, or <code>null</code> if none
3354 * @param sourceAttachmentRootPath
3355 * the location of the root within the source archive or folder
3356 * or <code>null</code> if this location should be
3357 * automatically detected.
3358 * @return a new library classpath entry
3360 * @see #newLibraryEntry(IPath, IPath, IPath, boolean)
3362 //public static IClasspathEntry newLibraryEntry(
3364 // IPath sourceAttachmentPath,
3365 // IPath sourceAttachmentRootPath) {
3367 // return newLibraryEntry(path, sourceAttachmentPath,
3368 // sourceAttachmentRootPath, false);
3371 * Creates and returns a new classpath entry of kind
3372 * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3373 * absolute path. This specifies that all package fragments within the root
3374 * will have children of type <code>IClassFile</code>.
3376 * A library entry is used to denote a prerequisite JAR or root folder
3377 * containing binaries. The target JAR or folder can either be defined
3378 * internally to the workspace (absolute path relative to the workspace
3379 * root) or externally to the workspace (absolute path in the file system).
3381 * e.g. Here are some examples of binary path usage
3383 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3385 * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3387 * <li><code> "c:/classes/" </code>- reference to an external binary
3390 * Note that this operation does not attempt to validate or access the
3391 * resources at the given paths.
3395 * the absolute path of the binary archive
3396 * @param sourceAttachmentPath
3397 * the absolute path of the corresponding source archive or
3398 * folder, or <code>null</code> if none
3399 * @param sourceAttachmentRootPath
3400 * the location of the root within the source archive or folder
3401 * or <code>null</code> if this location should be
3402 * automatically detected.
3404 * indicates whether this entry is contributed to dependent
3405 * projects in addition to the output location
3406 * @return a new library classpath entry
3409 //public static IClasspathEntry newLibraryEntry(
3411 // IPath sourceAttachmentPath,
3412 // IPath sourceAttachmentRootPath,
3413 // boolean isExported) {
3415 // if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry
3416 // must be absolute"); //$NON-NLS-1$
3418 // return new ClasspathEntry(
3419 // IPackageFragmentRoot.K_BINARY,
3420 // IClasspathEntry.CPE_LIBRARY,
3421 // JavaProject.canonicalizedPath(path),
3422 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3423 // sourceAttachmentPath,
3424 // sourceAttachmentRootPath,
3425 // null, // specific output folder
3429 * Creates and returns a new non-exported classpath entry of kind
3430 * <code>CPE_PROJECT</code> for the project identified by the given
3433 * A project entry is used to denote a prerequisite project on a classpath.
3434 * The referenced project will be contributed as a whole, either as sources
3435 * (in the Java Model, it contributes all its package fragment roots) or as
3436 * binaries (when building, it contributes its whole output location).
3438 * A project reference allows to indirect through another project,
3439 * independently from its internal layout.
3441 * The prerequisite project is referred to using an absolute path relative
3442 * to the workspace root.
3444 * The resulting entry is not exported to dependent projects. This method is
3445 * equivalent to <code>newProjectEntry(_,false)</code>.
3449 * the absolute path of the binary archive
3450 * @return a new project classpath entry
3452 * @see JavaCore#newProjectEntry(IPath, boolean)
3454 public static IClasspathEntry newProjectEntry(IPath path) {
3455 return newProjectEntry(path, false);
3459 * Creates and returns a new classpath entry of kind
3460 * <code>CPE_PROJECT</code> for the project identified by the given
3463 * A project entry is used to denote a prerequisite project on a classpath.
3464 * The referenced project will be contributed as a whole, either as sources
3465 * (in the Java Model, it contributes all its package fragment roots) or as
3466 * binaries (when building, it contributes its whole output location).
3468 * A project reference allows to indirect through another project,
3469 * independently from its internal layout.
3471 * The prerequisite project is referred to using an absolute path relative
3472 * to the workspace root.
3476 * the absolute path of the prerequisite project
3478 * indicates whether this entry is contributed to dependent
3479 * projects in addition to the output location
3480 * @return a new project classpath entry
3483 public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) {
3485 if (!path.isAbsolute())
3486 Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3488 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3489 IClasspathEntry.CPE_PROJECT, path,
3490 ClasspathEntry.NO_EXCLUSION_PATTERNS, null, // source attachment
3491 null, // source attachment root
3492 null, // specific output folder
3497 * Returns a new empty region.
3499 * @return a new empty region
3501 public static IRegion newRegion() {
3502 return new Region();
3506 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3507 * for the project's source folder identified by the given absolute
3508 * workspace-relative path. This specifies that all package fragments within
3509 * the root will have children of type <code>ICompilationUnit</code>.
3511 * The source folder is referred to using an absolute path relative to the
3512 * workspace root, e.g. <code>/Project/src</code>. A project's source
3513 * folders are located with that project. That is, a source classpath entry
3514 * specifying the path <code>/P1/src</code> is only usable for project
3518 * The source classpath entry created by this method includes all source
3519 * files below the given workspace-relative path. To selectively exclude
3520 * some of these source files, use the factory method
3521 * <code>JavaCore.newSourceEntry(IPath,IPath[])</code> instead.
3524 * Note that all sources/binaries inside a project are contributed as a
3525 * whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
3526 * Particular source entries cannot be selectively exported.
3530 * the absolute workspace-relative path of a source folder
3531 * @return a new source classpath entry with not exclusion patterns
3533 * @see #newSourceEntry(org.eclipse.core.runtime.IPath,org.eclipse.core.runtime.IPath[])
3535 public static IClasspathEntry newSourceEntry(IPath path) {
3537 return newSourceEntry(path, ClasspathEntry.NO_EXCLUSION_PATTERNS, null /*
3544 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3545 * for the project's source folder identified by the given absolute
3546 * workspace-relative path but excluding all source files with paths
3547 * matching any of the given patterns. This specifies that all package
3548 * fragments within the root will have children of type
3549 * <code>ICompilationUnit</code>.
3551 * The source folder is referred to using an absolute path relative to the
3552 * workspace root, e.g. <code>/Project/src</code>. A project's source
3553 * folders are located with that project. That is, a source classpath entry
3554 * specifying the path <code>/P1/src</code> is only usable for project
3558 * The source classpath entry created by this method includes all source
3559 * files below the given workspace-relative path except for those matched by
3560 * one (or more) of the given exclusion patterns. Each exclusion pattern is
3561 * represented by a relative path, which is interpreted as relative to the
3562 * source folder. For example, if the source folder path is
3563 * <code>/Project/src</code> and the exclusion pattern is
3564 * <code>com/xyz/tests/**</code>, then source files like
3565 * <code>/Project/src/com/xyz/Foo.java</code> and
3566 * <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3567 * whereas <code>/Project/src/com/xyz/tests/T1.java</code> and
3568 * <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3569 * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
3570 * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code> for
3571 * the full description of the syntax and semantics of exclusion patterns.
3573 * If the empty list of exclusion patterns is specified, the source folder
3574 * will automatically include all resources located inside the source
3575 * folder. In that case, the result is entirely equivalent to using the
3576 * factory method <code>JavaCore.newSourceEntry(IPath)</code>.
3579 * Note that all sources/binaries inside a project are contributed as a
3580 * whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
3581 * Particular source entries cannot be selectively exported.
3585 * the absolute workspace-relative path of a source folder
3586 * @param exclusionPatterns
3587 * the possibly empty list of exclusion patterns represented as
3589 * @return a new source classpath entry with the given exclusion patterns
3590 * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
3591 * @see IClasspathEntry#getExclusionPatterns
3595 public static IClasspathEntry newSourceEntry(IPath path,
3596 IPath[] exclusionPatterns) {
3598 return newSourceEntry(path, exclusionPatterns, null /* output location */);
3602 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3603 * for the project's source folder identified by the given absolute
3604 * workspace-relative path but excluding all source files with paths
3605 * matching any of the given patterns, and associated with a specific output
3606 * location (that is, ".class" files are not going to the project default
3607 * output location). All package fragments within the root will have
3608 * children of type <code>ICompilationUnit</code>.
3610 * The source folder is referred to using an absolute path relative to the
3611 * workspace root, e.g. <code>/Project/src</code>. A project's source
3612 * folders are located with that project. That is, a source classpath entry
3613 * specifying the path <code>/P1/src</code> is only usable for project
3617 * The source classpath entry created by this method includes all source
3618 * files below the given workspace-relative path except for those matched by
3619 * one (or more) of the given exclusion patterns. Each exclusion pattern is
3620 * represented by a relative path, which is interpreted as relative to the
3621 * source folder. For example, if the source folder path is
3622 * <code>/Project/src</code> and the exclusion pattern is
3623 * <code>com/xyz/tests/**</code>, then source files like
3624 * <code>/Project/src/com/xyz/Foo.java</code> and
3625 * <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3626 * whereas <code>/Project/src/com/xyz/tests/T1.java</code> and
3627 * <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3628 * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
3629 * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code> for
3630 * the full description of the syntax and semantics of exclusion patterns.
3632 * If the empty list of exclusion patterns is specified, the source folder
3633 * will automatically include all resources located inside the source
3634 * folder. In that case, the result is entirely equivalent to using the
3635 * factory method <code>JavaCore.newSourceEntry(IPath)</code>.
3638 * Additionally, a source entry can be associated with a specific output
3639 * location. By doing so, the Java builder will ensure that the generated
3640 * ".class" files will be issued inside this output location, as opposed to
3641 * be generated into the project default output location (when output
3642 * location is <code>null</code>). Note that multiple source entries may
3643 * target the same output location. The output location is referred to using
3644 * an absolute path relative to the workspace root, e.g.
3645 * <code>"/Project/bin"</code>, it must be located inside the same
3646 * project as the source folder.
3649 * Also note that all sources/binaries inside a project are contributed as a
3650 * whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
3651 * Particular source entries cannot be selectively exported.
3655 * the absolute workspace-relative path of a source folder
3656 * @param exclusionPatterns
3657 * the possibly empty list of exclusion patterns represented as
3659 * @param outputLocation
3660 * the specific output location for this source entry (
3661 * <code>null</code> if using project default ouput location)
3662 * @return a new source classpath entry with the given exclusion patterns
3663 * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
3664 * @see IClasspathEntry#getExclusionPatterns
3665 * @see IClasspathEntry#getOutputLocation()
3669 public static IClasspathEntry newSourceEntry(IPath path,
3670 IPath[] exclusionPatterns, IPath specificOutputLocation) {
3672 if (!path.isAbsolute())
3673 Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3674 if (exclusionPatterns == null)
3675 Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$
3677 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3678 IClasspathEntry.CPE_SOURCE, path, exclusionPatterns, null, // source
3680 null, // source attachment root
3681 specificOutputLocation, // custom output location
3686 * Creates and returns a new non-exported classpath entry of kind
3687 * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3688 * path is the name of a classpath variable. The trailing segments of the
3689 * path will be appended to resolved variable path.
3691 * A variable entry allows to express indirect references on a classpath to
3692 * other projects or libraries, depending on what the classpath variable is
3695 * It is possible to register an automatic initializer (
3696 * <code>ClasspathVariableInitializer</code>), which will be invoked
3697 * through the extension point
3698 * "org.eclipse.jdt.core.classpathVariableInitializer". After resolution, a
3699 * classpath variable entry may either correspond to a project or a library
3702 * e.g. Here are some examples of variable path usage
3704 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3705 * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3706 * library "c:\jars\jdtcore.jar"</li>
3707 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3708 * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3709 * "/Project_JDTCORE"</li>
3710 * <li>"PLUGINS/com.example/example.jar" where variable
3711 * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3712 * classpath entry is denoting the library
3713 * "c:/eclipse/plugins/com.example/example.jar"</li>
3715 * Note that this operation does not attempt to validate classpath variables
3716 * or access the resources at the given paths.
3718 * The resulting entry is not exported to dependent projects. This method is
3719 * equivalent to <code>newVariableEntry(-,-,-,false)</code>.
3722 * @param variablePath
3723 * the path of the binary archive; first segment is the name of a
3724 * classpath variable
3725 * @param variableSourceAttachmentPath
3726 * the path of the corresponding source archive, or
3727 * <code>null</code> if none; if present, the first segment is
3728 * the name of a classpath variable (not necessarily the same
3729 * variable as the one that begins <code>variablePath</code>)
3730 * @param sourceAttachmentRootPath
3731 * the location of the root within the source archive or
3732 * <code>null</code> if <code>archivePath</code> is also
3734 * @return a new library classpath entry
3736 * @see JavaCore#newVariableEntry(IPath, IPath, IPath, boolean)
3738 //public static IClasspathEntry newVariableEntry(
3739 // IPath variablePath,
3740 // IPath variableSourceAttachmentPath,
3741 // IPath sourceAttachmentRootPath) {
3743 // return newVariableEntry(variablePath, variableSourceAttachmentPath,
3744 // sourceAttachmentRootPath, false);
3747 * Creates and returns a new non-exported classpath entry of kind
3748 * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3749 * path is the name of a classpath variable. The trailing segments of the
3750 * path will be appended to resolved variable path.
3752 * A variable entry allows to express indirect references on a classpath to
3753 * other projects or libraries, depending on what the classpath variable is
3756 * It is possible to register an automatic initializer (
3757 * <code>ClasspathVariableInitializer</code>), which will be invoked
3758 * through the extension point
3759 * "org.eclipse.jdt.core.classpathVariableInitializer". After resolution, a
3760 * classpath variable entry may either correspond to a project or a library
3763 * e.g. Here are some examples of variable path usage
3765 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3766 * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3767 * library "c:\jars\jdtcore.jar"</li>
3768 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3769 * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3770 * "/Project_JDTCORE"</li>
3771 * <li>"PLUGINS/com.example/example.jar" where variable
3772 * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3773 * classpath entry is denoting the library
3774 * "c:/eclipse/plugins/com.example/example.jar"</li>
3776 * Note that this operation does not attempt to validate classpath variables
3777 * or access the resources at the given paths.
3780 * @param variablePath
3781 * the path of the binary archive; first segment is the name of a
3782 * classpath variable
3783 * @param variableSourceAttachmentPath
3784 * the path of the corresponding source archive, or
3785 * <code>null</code> if none; if present, the first segment is
3786 * the name of a classpath variable (not necessarily the same
3787 * variable as the one that begins <code>variablePath</code>)
3788 * @param sourceAttachmentRootPath
3789 * the location of the root within the source archive or
3790 * <code>null</code> if <code>archivePath</code> is also
3793 * indicates whether this entry is contributed to dependent
3794 * projects in addition to the output location
3795 * @return a new variable classpath entry
3798 //public static IClasspathEntry newVariableEntry(
3799 // IPath variablePath,
3800 // IPath variableSourceAttachmentPath,
3801 // IPath variableSourceAttachmentRootPath,
3802 // boolean isExported) {
3804 // if (variablePath == null || variablePath.segmentCount() < 1) {
3807 // "Illegal classpath variable path: \'" +
3808 // variablePath.makeRelative().toString() + "\', must have at least one
3809 // segment"); //$NON-NLS-1$//$NON-NLS-2$
3812 // return new ClasspathEntry(
3813 // IPackageFragmentRoot.K_SOURCE,
3814 // IClasspathEntry.CPE_VARIABLE,
3816 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3817 // variableSourceAttachmentPath, // source attachment
3818 // variableSourceAttachmentRootPath, // source attachment root
3819 // null, // specific output folder
3823 * Removed the given classpath variable. Does nothing if no value was set
3824 * for this classpath variable.
3826 * This functionality cannot be used while the resource tree is locked.
3828 * Classpath variable values are persisted locally to the workspace, and are
3829 * preserved from session to session.
3832 * @param variableName
3833 * the name of the classpath variable
3834 * @see #setClasspathVariable
3836 * @deprecated - use version with extra IProgressMonitor
3838 //public static void removeClasspathVariable(String variableName) {
3839 // removeClasspathVariable(variableName, null);
3842 * Removed the given classpath variable. Does nothing if no value was set
3843 * for this classpath variable.
3845 * This functionality cannot be used while the resource tree is locked.
3847 * Classpath variable values are persisted locally to the workspace, and are
3848 * preserved from session to session.
3851 * @param variableName
3852 * the name of the classpath variable
3854 * the progress monitor to report progress
3855 * @see #setClasspathVariable
3857 //public static void removeClasspathVariable(
3858 // String variableName,
3859 // IProgressMonitor monitor) {
3862 // updateVariableValues(new String[]{ variableName}, new IPath[]{ null },
3864 // } catch (JavaModelException e) {
3868 * Removes the given element changed listener. Has no affect if an identical
3869 * listener is not registered.
3874 public static void removeElementChangedListener(
3875 IElementChangedListener listener) {
3876 JavaModelManager.getJavaModelManager().removeElementChangedListener(
3881 * Bind a container reference path to some actual containers (
3882 * <code>IClasspathContainer</code>). This API must be invoked whenever
3883 * changes in container need to be reflected onto the JavaModel. Containers
3884 * can have distinct values in different projects, therefore this API
3885 * considers a set of projects with their respective containers.
3887 * <code>containerPath</code> is the path under which these values can be
3888 * referenced through container classpath entries (
3889 * <code>IClasspathEntry#CPE_CONTAINER</code>). A container path is
3890 * formed by a first ID segment followed with extra segments, which can be
3891 * used as additional hints for the resolution. The container ID is used to
3892 * identify a <code>ClasspathContainerInitializer</code> registered on the
3893 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3895 * There is no assumption that each individual container value passed in
3896 * argument (<code>respectiveContainers</code>) must answer the exact
3897 * same path when requested <code>IClasspathContainer#getPath</code>.
3898 * Indeed, the containerPath is just an indication for resolving it to an
3899 * actual container object. It can be delegated to a
3900 * <code>ClasspathContainerInitializer</code>, which can be activated
3901 * through the extension point
3902 * "org.eclipse.jdt.core.ClasspathContainerInitializer").
3904 * In reaction to changing container values, the JavaModel will be updated
3905 * to reflect the new state of the updated container.
3907 * This functionality cannot be used while the resource tree is locked.
3909 * Classpath container values are persisted locally to the workspace, but
3910 * are not preserved from a session to another. It is thus highly
3911 * recommended to register a <code>ClasspathContainerInitializer</code>
3912 * for each referenced container (through the extension point
3913 * "org.eclipse.jdt.core.ClasspathContainerInitializer").
3915 * Note: setting a container to <code>null</code> will cause it to be
3916 * lazily resolved again whenever its value is required. In particular, this
3917 * will cause a registered initializer to be invoked again.
3920 * @param containerPath -
3921 * the name of the container reference, which is being updated
3922 * @param affectedProjects -
3923 * the set of projects for which this container is being bound
3924 * @param respectiveContainers -
3925 * the set of respective containers for the affected projects
3927 * a monitor to report progress
3929 * @see ClasspathContainerInitializer
3930 * @see #getClasspathContainer(IPath, IJavaProject)
3931 * @see IClasspathContainer
3934 //public static void setClasspathContainer(final IPath containerPath,
3935 // IJavaProject[] affectedProjects, IClasspathContainer[]
3936 // respectiveContainers, IProgressMonitor monitor) throws JavaModelException
3939 // if (affectedProjects.length != respectiveContainers.length)
3940 // Assert.isTrue(false, "Projects and containers collections should have the
3941 // same size"); //$NON-NLS-1$
3943 // if (monitor != null && monitor.isCanceled()) return;
3945 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3946 // System.out.println("CPContainer SET - setting container:
3947 // ["+containerPath+"] for projects: {" //$NON-NLS-1$ //$NON-NLS-2$
3948 // + (Util.toString(affectedProjects,
3949 // new Util.Displayable(){
3950 // public String displayString(Object o) { return ((IJavaProject)
3951 // o).getElementName(); }
3953 // + "} with values: " //$NON-NLS-1$
3954 // + (Util.toString(respectiveContainers,
3955 // new Util.Displayable(){
3956 // public String displayString(Object o) { return ((IClasspathContainer)
3957 // o).getDescription(); }
3962 // final int projectLength = affectedProjects.length;
3963 // final IJavaProject[] modifiedProjects;
3964 // System.arraycopy(affectedProjects, 0, modifiedProjects = new
3965 // IJavaProject[projectLength], 0, projectLength);
3966 // final IClasspathEntry[][] oldResolvedPaths = new
3967 // IClasspathEntry[projectLength][];
3969 // // filter out unmodified project containers
3970 // int remaining = 0;
3971 // for (int i = 0; i < projectLength; i++){
3973 // if (monitor != null && monitor.isCanceled()) return;
3975 // IJavaProject affectedProject = affectedProjects[i];
3976 // IClasspathContainer newContainer = respectiveContainers[i];
3977 // if (newContainer == null) newContainer =
3978 // JavaModelManager.ContainerInitializationInProgress; // 30920 - prevent
3980 // boolean found = false;
3981 // if (JavaProject.hasJavaNature(affectedProject.getProject())){
3982 // IClasspathEntry[] rawClasspath = affectedProject.getRawClasspath();
3983 // for (int j = 0, cpLength = rawClasspath.length; j <cpLength; j++) {
3984 // IClasspathEntry entry = rawClasspath[j];
3985 // if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER &&
3986 // entry.getPath().equals(containerPath)){
3993 // modifiedProjects[i] = null; // filter out this project - does not
3994 // reference the container path, or isnt't yet Java project
3995 // JavaModelManager.containerPut(affectedProject, containerPath,
3999 // IClasspathContainer oldContainer =
4000 // JavaModelManager.containerGet(affectedProject, containerPath);
4001 // if (oldContainer == JavaModelManager.ContainerInitializationInProgress) {
4002 // Map previousContainerValues =
4003 // (Map)JavaModelManager.PreviousSessionContainers.get(affectedProject);
4004 // if (previousContainerValues != null){
4005 // IClasspathContainer previousContainer =
4006 // (IClasspathContainer)previousContainerValues.get(containerPath);
4007 // if (previousContainer != null) {
4008 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4009 // System.out.println("CPContainer INIT - reentering access to project
4010 // container: ["+affectedProject.getElementName()+"] " + containerPath + "
4011 // during its initialization, will see previous value: "+
4012 // previousContainer.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
4015 // JavaModelManager.containerPut(affectedProject, containerPath,
4016 // previousContainer);
4018 // oldContainer = null; //33695 - cannot filter out restored container, must
4019 // update affected project to reset cached CP
4021 // oldContainer = null;
4024 // if (oldContainer != null &&
4025 // oldContainer.equals(respectiveContainers[i])){// TODO: could improve to
4026 // only compare entries
4027 // modifiedProjects[i] = null; // filter out this project - container did
4032 // oldResolvedPaths[i] = affectedProject.getResolvedClasspath(true);
4033 // JavaModelManager.containerPut(affectedProject, containerPath,
4037 // if (remaining == 0) return;
4039 // // trigger model refresh
4041 // JavaCore.run(new IWorkspaceRunnable() {
4042 // public void run(IProgressMonitor monitor) throws CoreException {
4043 // for(int i = 0; i < projectLength; i++){
4045 // if (monitor != null && monitor.isCanceled()) return;
4047 // JavaProject affectedProject = (JavaProject)modifiedProjects[i];
4048 // if (affectedProject == null) continue; // was filtered out
4050 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4051 // System.out.println("CPContainer SET - updating affected project:
4052 // ["+affectedProject.getElementName()+"] due to setting container: " +
4053 // containerPath); //$NON-NLS-1$ //$NON-NLS-2$
4056 // // force a refresh of the affected project (will compute deltas)
4057 // affectedProject.setRawClasspath(
4058 // affectedProject.getRawClasspath(),
4059 // SetClasspathOperation.ReuseOutputLocation,
4061 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can save resources
4062 // oldResolvedPaths[i],
4063 // false, // updating - no validation
4064 // false); // updating - no need to save
4069 // } catch(CoreException e) {
4070 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4071 // System.out.println("CPContainer SET - FAILED DUE TO EXCEPTION:
4072 // "+containerPath); //$NON-NLS-1$
4073 // e.printStackTrace();
4075 // if (e instanceof JavaModelException) {
4076 // throw (JavaModelException)e;
4078 // throw new JavaModelException(e);
4081 // for (int i = 0; i < projectLength; i++) {
4082 // if (respectiveContainers[i] == null) {
4083 // JavaModelManager.containerPut(affectedProjects[i], containerPath, null);
4084 // // reset init in progress marker
4091 * Sets the value of the given classpath variable. The path must have at
4092 * least one segment.
4094 * This functionality cannot be used while the resource tree is locked.
4096 * Classpath variable values are persisted locally to the workspace, and are
4097 * preserved from session to session.
4100 * @param variableName
4101 * the name of the classpath variable
4104 * @see #getClasspathVariable
4106 * @deprecated - use API with IProgressMonitor
4108 //public static void setClasspathVariable(String variableName, IPath path)
4109 // throws JavaModelException {
4111 // setClasspathVariable(variableName, path, null);
4114 * Sets the value of the given classpath variable. The path must not be
4117 * This functionality cannot be used while the resource tree is locked.
4119 * Classpath variable values are persisted locally to the workspace, and are
4120 * preserved from session to session.
4122 * Updating a variable with the same value has no effect.
4124 * @param variableName
4125 * the name of the classpath variable
4129 * a monitor to report progress
4130 * @see #getClasspathVariable
4132 //public static void setClasspathVariable(
4133 // String variableName,
4135 // IProgressMonitor monitor)
4136 // throws JavaModelException {
4138 // if (path == null) Assert.isTrue(false, "Variable path cannot be null");
4140 // setClasspathVariables(new String[]{variableName}, new IPath[]{ path },
4144 * Sets the values of all the given classpath variables at once. Null paths
4145 * can be used to request corresponding variable removal.
4147 * This functionality cannot be used while the resource tree is locked.
4149 * Classpath variable values are persisted locally to the workspace, and are
4150 * preserved from session to session.
4152 * Updating a variable with the same value has no effect.
4154 * @param variableNames
4155 * an array of names for the updated classpath variables
4157 * an array of path updates for the modified classpath variables
4158 * (null meaning that the corresponding value will be removed
4160 * a monitor to report progress
4161 * @see #getClasspathVariable
4164 //public static void setClasspathVariables(
4165 // String[] variableNames,
4167 // IProgressMonitor monitor)
4168 // throws JavaModelException {
4170 // if (variableNames.length != paths.length) Assert.isTrue(false, "Variable
4171 // names and paths collections should have the same size"); //$NON-NLS-1$
4172 // //TODO: should check that null cannot be used as variable paths
4173 // updateVariableValues(variableNames, paths, monitor);
4176 * (non-Javadoc) Method declared on IExecutableExtension. Record any
4177 * necessary initialization data from the plugin.
4179 public void setInitializationData(IConfigurationElement cfig,
4180 String propertyName, Object data) throws CoreException {
4184 * Sets the current table of options. All and only the options explicitly
4185 * included in the given table are remembered; all previous option settings
4186 * are forgotten, including ones not explicitly mentioned.
4188 * For a complete description of the configurable options, see
4189 * <code>getDefaultOptions</code>.
4193 * the new options (key type: <code>String</code>; value type:
4194 * <code>String</code>), or <code>null</code> to reset all
4195 * options to their default values
4196 * @see JavaCore#getDefaultOptions
4198 public static void setOptions(Hashtable newOptions) {
4200 // see #initializeDefaultPluginPreferences() for changing default
4202 Preferences preferences = getPlugin().getPluginPreferences();
4204 if (newOptions == null) {
4205 newOptions = JavaCore.getDefaultOptions();
4207 Enumeration keys = newOptions.keys();
4208 while (keys.hasMoreElements()) {
4209 String key = (String) keys.nextElement();
4210 if (!JavaModelManager.OptionNames.contains(key))
4211 continue; // unrecognized option
4212 if (key.equals(CORE_ENCODING))
4213 continue; // skipped, contributed by resource prefs
4214 String value = (String) newOptions.get(key);
4215 preferences.setValue(key, value);
4219 getPlugin().savePluginPreferences();
4223 * Shutdown the JavaCore plug-in.
4225 * De-registers the JavaModelManager as a resource changed listener and save
4229 * @see org.eclipse.core.runtime.Plugin#shutdown()
4231 // moved to PHPeclipsePlugin#shutdown()
4232 //public void shutdown() {
4234 // //savePluginPreferences();
4235 // getPlugin().savePluginPreferences();
4236 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4237 // workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaProcessor);
4238 // workspace.removeSaveParticipant(PHPeclipsePlugin.getDefault());
4240 // ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown();
4243 * Initiate the background indexing process. This should be deferred after
4244 * the plugin activation.
4246 //private void startIndexing() {
4248 // JavaModelManager.getJavaModelManager().getIndexManager().reset();
4251 * Startup of the JavaCore plug-in.
4253 * Registers the JavaModelManager as a resource changed listener and save
4254 * participant. Starts the background indexing, and restore saved classpath
4258 * @see org.eclipse.core.runtime.Plugin#startup()
4261 // moved to PHPeclipsePlugin#startup()
4262 //public void startup() {
4264 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
4266 // manager.configurePluginDebugOptions();
4268 // // request state folder creation (workaround 19885)
4269 // JavaCore.getPlugin().getStateLocation();
4271 // // retrieve variable values
4272 // JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4273 // JavaModelManager.PluginPreferencesListener());
4274 //// TODO : jsurfer temp-del
4275 //// manager.loadVariablesAndContainers();
4277 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4278 // workspace.addResourceChangeListener(
4279 // manager.deltaProcessor,
4280 // IResourceChangeEvent.PRE_AUTO_BUILD
4281 // | IResourceChangeEvent.POST_AUTO_BUILD
4282 // | IResourceChangeEvent.POST_CHANGE
4283 // | IResourceChangeEvent.PRE_DELETE
4284 // | IResourceChangeEvent.PRE_CLOSE);
4286 //// startIndexing();
4287 // workspace.addSaveParticipant(PHPeclipsePlugin.getDefault(), manager);
4289 // } catch (CoreException e) {
4290 // } catch (RuntimeException e) {
4291 // manager.shutdown();
4296 * Internal updating of a variable values (null path meaning removal),
4297 * allowing to change multiple variable values at once.
4299 //private static void updateVariableValues(
4300 // String[] variableNames,
4301 // IPath[] variablePaths,
4302 // IProgressMonitor monitor) throws JavaModelException {
4304 // if (monitor != null && monitor.isCanceled()) return;
4306 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4307 // System.out.println("CPVariable SET - setting variables: {" +
4308 // Util.toString(variableNames) //$NON-NLS-1$
4309 // + "} with values: " + Util.toString(variablePaths)); //$NON-NLS-1$
4312 // int varLength = variableNames.length;
4314 // // gather classpath information for updating
4315 // final HashMap affectedProjects = new HashMap(5);
4316 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
4317 // IJavaModel model = manager.getJavaModel();
4319 // // filter out unmodified variables
4320 // int discardCount = 0;
4321 // for (int i = 0; i < varLength; i++){
4322 // String variableName = variableNames[i];
4323 // IPath oldPath = (IPath)JavaModelManager.variableGet(variableName); // if
4324 // reentering will provide previous session value
4325 // if (oldPath == JavaModelManager.VariableInitializationInProgress){
4326 // IPath previousPath =
4327 // (IPath)JavaModelManager.PreviousSessionVariables.get(variableName);
4328 // if (previousPath != null){
4329 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4330 // System.out.println("CPVariable INIT - reentering access to variable: " +
4331 // variableName+ " during its initialization, will see previous value: "+
4332 // previousPath); //$NON-NLS-1$ //$NON-NLS-2$
4334 // JavaModelManager.variablePut(variableName, previousPath); // replace
4335 // value so reentering calls are seeing old value
4337 // oldPath = null; //33695 - cannot filter out restored variable, must
4338 // update affected project to reset cached CP
4340 // if (oldPath != null && oldPath.equals(variablePaths[i])){
4341 // variableNames[i] = null;
4345 // if (discardCount > 0){
4346 // if (discardCount == varLength) return;
4347 // int changedLength = varLength - discardCount;
4348 // String[] changedVariableNames = new String[changedLength];
4349 // IPath[] changedVariablePaths = new IPath[changedLength];
4350 // for (int i = 0, index = 0; i < varLength; i++){
4351 // if (variableNames[i] != null){
4352 // changedVariableNames[index] = variableNames[i];
4353 // changedVariablePaths[index] = variablePaths[i];
4357 // variableNames = changedVariableNames;
4358 // variablePaths = changedVariablePaths;
4359 // varLength = changedLength;
4362 // if (monitor != null && monitor.isCanceled()) return;
4364 // if (model != null) {
4365 // IJavaProject[] projects = model.getJavaProjects();
4366 // nextProject : for (int i = 0, projectLength = projects.length; i <
4367 // projectLength; i++){
4368 // IJavaProject project = projects[i];
4370 // // check to see if any of the modified variables is present on the
4372 // IClasspathEntry[] classpath = project.getRawClasspath();
4373 // for (int j = 0, cpLength = classpath.length; j < cpLength; j++){
4375 // IClasspathEntry entry = classpath[j];
4376 // for (int k = 0; k < varLength; k++){
4378 // String variableName = variableNames[k];
4379 // if (entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE){
4381 // if (variableName.equals(entry.getPath().segment(0))){
4382 // affectedProjects.put(project, project.getResolvedClasspath(true));
4383 // continue nextProject;
4385 // IPath sourcePath, sourceRootPath;
4386 // if (((sourcePath = entry.getSourceAttachmentPath()) != null &&
4387 // variableName.equals(sourcePath.segment(0)))
4388 // || ((sourceRootPath = entry.getSourceAttachmentRootPath()) != null &&
4389 // variableName.equals(sourceRootPath.segment(0)))) {
4391 // affectedProjects.put(project, project.getResolvedClasspath(true));
4392 // continue nextProject;
4399 // // update variables
4400 // for (int i = 0; i < varLength; i++){
4401 // JavaModelManager.variablePut(variableNames[i], variablePaths[i]);
4403 // final String[] dbgVariableNames = variableNames;
4405 // // update affected project classpaths
4406 // if (!affectedProjects.isEmpty()) {
4408 // JavaCore_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt.run(
4409 // new IWorkspaceRunnable() {
4410 // public void run(IProgressMonitor monitor) throws CoreException {
4411 // // propagate classpath change
4412 // Iterator projectsToUpdate = affectedProjects.keySet().iterator();
4413 // while (projectsToUpdate.hasNext()) {
4415 // if (monitor != null && monitor.isCanceled()) return;
4417 // JavaProject project = (JavaProject) projectsToUpdate.next();
4419 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4420 // System.out.println("CPVariable SET - updating affected project:
4421 // ["+project.getElementName()+"] due to setting variables: "+
4422 // Util.toString(dbgVariableNames)); //$NON-NLS-1$ //$NON-NLS-2$
4426 // .setRawClasspath(
4427 // project.getRawClasspath(),
4428 // SetClasspathOperation.ReuseOutputLocation,
4429 // null, // don't call beginTask on the monitor (see
4430 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=3717)
4431 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can change resources
4432 // (IClasspathEntry[]) affectedProjects.get(project),
4433 // false, // updating - no validation
4434 // false); // updating - no need to save
4439 // } catch (CoreException e) {
4440 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4441 // System.out.println("CPVariable SET - FAILED DUE TO EXCEPTION:
4442 // "+Util.toString(dbgVariableNames)); //$NON-NLS-1$
4443 // e.printStackTrace();
4445 // if (e instanceof JavaModelException) {
4446 // throw (JavaModelException)e;
4448 // throw new JavaModelException(e);
4454 * (non-Javadoc) Startup the JavaCore plug-in. <p> Registers the
4455 * JavaModelManager as a resource changed listener and save participant.
4456 * Starts the background indexing, and restore saved classpath variable
4457 * values. <p> @throws Exception
4459 * @see org.eclipse.core.runtime.Plugin#start(BundleContext)
4461 //public static void start(final Plugin plugin, BundleContext context)
4462 // throws Exception {
4463 //// super.start(context);
4465 // final JavaModelManager manager = JavaModelManager.getJavaModelManager();
4467 // manager.configurePluginDebugOptions();
4469 // // request state folder creation (workaround 19885)
4470 // JavaCore.getPlugin().getStateLocation();
4472 // // retrieve variable values
4473 // //JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4474 // JavaModelManager.PluginPreferencesListener());
4475 //// manager.loadVariablesAndContainers();
4477 // final IWorkspace workspace = ResourcesPlugin.getWorkspace();
4478 // workspace.addResourceChangeListener(
4479 // manager.deltaState,
4480 // IResourceChangeEvent.PRE_BUILD
4481 // | IResourceChangeEvent.POST_BUILD
4482 // | IResourceChangeEvent.POST_CHANGE
4483 // | IResourceChangeEvent.PRE_DELETE
4484 // | IResourceChangeEvent.PRE_CLOSE);
4486 //// startIndexing();
4488 // // process deltas since last activated in indexer thread so that indexes
4490 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658
4491 // Job processSavedState = new Job(Util.bind("savedState.jobName")) {
4493 // protected IStatus run(IProgressMonitor monitor) {
4495 // // add save participant and process delta atomically
4496 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59937
4498 // new IWorkspaceRunnable() {
4499 // public void run(IProgressMonitor progress) throws CoreException {
4500 //// ISavedState savedState = workspace.addSaveParticipant(JavaCore.this,
4502 // ISavedState savedState = workspace.addSaveParticipant(plugin, manager);
4503 // if (savedState != null) {
4504 // // the event type coming from the saved state is always POST_AUTO_BUILD
4505 // // force it to be POST_CHANGE so that the delta processor can handle it
4506 // manager.deltaState.getDeltaProcessor().overridenEventType =
4507 // IResourceChangeEvent.POST_CHANGE;
4508 // savedState.processResourceChangeEvents(manager.deltaState);
4513 // } catch (CoreException e) {
4514 // return e.getStatus();
4516 // return Status.OK_STATUS;
4519 // processSavedState.setSystem(true);
4520 // processSavedState.setPriority(Job.SHORT); // process asap
4521 // processSavedState.schedule();
4522 // } catch (RuntimeException e) {
4523 // manager.shutdown();
4528 * (non-Javadoc) Shutdown the JavaCore plug-in. <p> De-registers the
4529 * JavaModelManager as a resource changed listener and save participant. <p>
4531 * @see org.eclipse.core.runtime.Plugin#stop(BundleContext)
4533 // public static void stop(Plugin plugin, BundleContext context)
4534 // throws Exception {
4536 // plugin.savePluginPreferences();
4537 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4538 // workspace.removeResourceChangeListener(JavaModelManager
4539 // .getJavaModelManager().deltaState);
4540 // workspace.removeSaveParticipant(plugin);
4542 // JavaModelManager.getJavaModelManager().shutdown();
4544 // // ensure we call super.stop as the last thing
4545 // // super.stop(context);