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.IResourceChangeListener;
30 import org.eclipse.core.resources.ISavedState;
31 import org.eclipse.core.resources.IWorkspace;
32 import org.eclipse.core.resources.IWorkspaceRoot;
33 import org.eclipse.core.resources.IWorkspaceRunnable;
34 import org.eclipse.core.resources.ResourcesPlugin;
35 import org.eclipse.core.runtime.CoreException;
36 import org.eclipse.core.runtime.IConfigurationElement;
37 import org.eclipse.core.runtime.IPath;
38 import org.eclipse.core.runtime.IProgressMonitor;
39 import org.eclipse.core.runtime.IStatus;
40 import org.eclipse.core.runtime.Plugin;
41 import org.eclipse.core.runtime.Preferences;
42 import org.eclipse.core.runtime.Status;
43 import org.eclipse.core.runtime.jobs.ISchedulingRule;
44 import org.eclipse.core.runtime.jobs.Job;
45 import net.sourceforge.phpdt.internal.core.util.Util;
46 import org.osgi.framework.BundleContext;
48 public class JavaCore {
50 // public static HashSet OptionNames = new HashSet(20);
52 * The plug-in identifier of the Java core support (value
53 * <code>"net.sourceforge.phpeclipse"</code>)
55 // public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.core";
57 public static final String PLUGIN_ID = PHPeclipsePlugin.PLUGIN_ID;
60 * Possible configurable option ID.
62 * @see #getDefaultOptions
65 public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; //$NON-NLS-1$
68 * Possible configurable option ID.
70 * @see #getDefaultOptions
73 public static final String FORMATTER_NEWLINE_OPENING_BRACE = PLUGIN_ID
74 + ".formatter.newline.openingBrace"; //$NON-NLS-1$
77 * Possible configurable option ID.
79 * @see #getDefaultOptions
82 public static final String FORMATTER_NEWLINE_CONTROL = PLUGIN_ID
83 + ".formatter.newline.controlStatement"; //$NON-NLS-1$
86 * Possible configurable option ID.
88 * @see #getDefaultOptions
91 public static final String FORMATTER_NEWLINE_ELSE_IF = PLUGIN_ID
92 + ".formatter.newline.elseIf"; //$NON-NLS-1$
95 * Possible configurable option ID.
97 * @see #getDefaultOptions
100 public static final String FORMATTER_NEWLINE_EMPTY_BLOCK = PLUGIN_ID
101 + ".formatter.newline.emptyBlock"; //$NON-NLS-1$
104 * Possible configurable option ID.
106 * @see #getDefaultOptions
109 public static final String FORMATTER_CLEAR_BLANK_LINES = PLUGIN_ID
110 + ".formatter.newline.clearAll"; //$NON-NLS-1$
113 * Possible configurable option ID.
115 * @see #getDefaultOptions
118 public static final String FORMATTER_LINE_SPLIT = PLUGIN_ID
119 + ".formatter.lineSplit"; //$NON-NLS-1$
122 * Possible configurable option ID.
124 * @see #getDefaultOptions
127 public static final String FORMATTER_COMPACT_ASSIGNMENT = PLUGIN_ID
128 + ".formatter.style.assignment"; //$NON-NLS-1$
131 * Possible configurable option ID.
133 * @see #getDefaultOptions
136 public static final String FORMATTER_TAB_CHAR = PLUGIN_ID
137 + ".formatter.tabulation.char"; //$NON-NLS-1$
140 * Possible configurable option ID.
142 * @see #getDefaultOptions
145 public static final String FORMATTER_TAB_SIZE = PLUGIN_ID
146 + ".formatter.tabulation.size"; //$NON-NLS-1$
149 * Possible configurable option value.
151 * @see #getDefaultOptions
154 public static final String INSERT = "insert"; //$NON-NLS-1$
157 * Possible configurable option value.
159 * @see #getDefaultOptions
162 public static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$
165 * Possible configurable option value.
167 * @see #getDefaultOptions
170 public static final String PRESERVE_ONE = "preserve one"; //$NON-NLS-1$
173 * Possible configurable option value.
175 * @see #getDefaultOptions
178 public static final String CLEAR_ALL = "clear all"; //$NON-NLS-1$
181 * Possible configurable option value.
183 * @see #getDefaultOptions
186 public static final String NORMAL = "normal"; //$NON-NLS-1$
189 * Possible configurable option value.
191 * @see #getDefaultOptions
194 public static final String COMPACT = "compact"; //$NON-NLS-1$
197 * Possible configurable option value.
199 * @see #getDefaultOptions
202 public static final String TAB = "tab"; //$NON-NLS-1$
205 * Possible configurable option value.
207 * @see #getDefaultOptions
210 public static final String SPACE = "space"; //$NON-NLS-1$
213 * Possible configurable option value.
215 * @see #getDefaultOptions
218 public static final String ENABLED = "enabled"; //$NON-NLS-1$
221 * Possible configurable option value.
223 * @see #getDefaultOptions
226 public static final String DISABLED = "disabled"; //$NON-NLS-1$
229 * Possible configurable option value.
231 * @see #getDefaultOptions
234 public static final String CLEAN = "clean"; //$NON-NLS-1$
237 * Possible configurable option ID.
239 * @see #getDefaultOptions
242 public static final String COMPILER_TASK_TAGS = PLUGIN_ID
243 + ".compiler.taskTags"; //$NON-NLS-1$
246 * Name of the handle id attribute in a Java marker.
248 protected static final String ATT_HANDLE_ID = "net.sourceforge.phpdt.internal.core.JavaModelManager.handleId"; //$NON-NLS-1$
250 // *************** Possible IDs for configurable options.
251 // ********************
254 * Possible configurable option ID.
256 * @see #getDefaultOptions()
258 public static final String COMPILER_LOCAL_VARIABLE_ATTR = PLUGIN_ID
259 + ".compiler.debug.localVariable"; //$NON-NLS-1$
262 * Possible configurable option ID.
264 * @see #getDefaultOptions()
266 public static final String COMPILER_LINE_NUMBER_ATTR = PLUGIN_ID
267 + ".compiler.debug.lineNumber"; //$NON-NLS-1$
270 * Possible configurable option ID.
272 * @see #getDefaultOptions
274 public static final String COMPILER_SOURCE_FILE_ATTR = PLUGIN_ID
275 + ".compiler.debug.sourceFile"; //$NON-NLS-1$
278 * Possible configurable option ID.
280 * @see #getDefaultOptions
282 public static final String COMPILER_CODEGEN_UNUSED_LOCAL = PLUGIN_ID
283 + ".compiler.codegen.unusedLocal"; //$NON-NLS-1$
286 * Possible configurable option ID.
288 * @see #getDefaultOptions
290 public static final String COMPILER_CODEGEN_TARGET_PLATFORM = PLUGIN_ID
291 + ".compiler.codegen.targetPlatform"; //$NON-NLS-1$
294 * Possible configurable option ID.
296 * @see #getDefaultOptions
298 public static final String COMPILER_PB_PHP_VAR_DEPRECATED = PLUGIN_ID
299 + ".compiler.problem.phpVarDeprecatedWarning"; //$NON-NLS-1$
301 public static final String COMPILER_PB_PHP_KEYWORD = PLUGIN_ID
302 + ".compiler.problem.phpBadStyleKeywordWarning"; //$NON-NLS-1$
304 public static final String COMPILER_PB_PHP_UPPERCASE_IDENTIFIER = PLUGIN_ID
305 + ".compiler.problem.phpBadStyleUppercaseIdentifierWarning"; //$NON-NLS-1$
308 * Possible configurable option ID.
310 * @see #getDefaultOptions
312 public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID
313 + ".compiler.problem.unreachableCode"; //$NON-NLS-1$
316 * Possible configurable option ID.
318 * @see #getDefaultOptions
320 public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID
321 + ".compiler.problem.invalidImport"; //$NON-NLS-1$
324 * Possible configurable option ID.
326 * @see #getDefaultOptions
328 public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID
329 + ".compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
332 * Possible configurable option ID.
334 * @see #getDefaultOptions
336 public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID
337 + ".compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
340 * Possible configurable option ID.
342 * @see #getDefaultOptions
344 public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID
345 + ".compiler.problem.deprecation"; //$NON-NLS-1$
348 * Possible configurable option ID.
350 * @see #getDefaultOptions
353 public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID
354 + ".compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
357 * Possible configurable option ID.
359 * @see #getDefaultOptions
361 public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID
362 + ".compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
365 * Possible configurable option ID.
367 * @see #getDefaultOptions
369 public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID
370 + ".compiler.problem.unusedLocal"; //$NON-NLS-1$
373 * Possible configurable option ID.
375 * @see #getDefaultOptions
377 public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID
378 + ".compiler.problem.unusedParameter"; //$NON-NLS-1$
381 * Possible configurable option ID.
383 * @see #getDefaultOptions
386 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID
387 + ".compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
390 * Possible configurable option ID.
392 * @see #getDefaultOptions
395 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID
396 + ".compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
399 * Possible configurable option ID.
401 * @see #getDefaultOptions
404 public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID
405 + ".compiler.problem.unusedImport"; //$NON-NLS-1$
408 * Possible configurable option ID.
410 * @see #getDefaultOptions
412 public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID
413 + ".compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
416 * Possible configurable option ID.
418 * @see #getDefaultOptions
421 public static final String COMPILER_PB_NON_NLS_STRING_LITERAL = PLUGIN_ID
422 + ".compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
425 * Possible configurable option ID.
427 * @see #getDefaultOptions
430 public static final String COMPILER_PB_ASSERT_IDENTIFIER = PLUGIN_ID
431 + ".compiler.problem.assertIdentifier"; //$NON-NLS-1$
434 * Possible configurable option ID.
436 * @see #getDefaultOptions
439 public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID
440 + ".compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
443 * Possible configurable option ID.
445 * @see #getDefaultOptions
448 public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID
449 + ".compiler.problem.noEffectAssignment"; //$NON-NLS-1$
452 * Possible configurable option ID.
454 * @see #getDefaultOptions
457 public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID
458 + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
461 * Possible configurable option ID.
463 * @see #getDefaultOptions
466 public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID
467 + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
470 * Possible configurable option ID.
472 * @see #getDefaultOptions
475 public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID
476 + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
479 * Possible configurable option ID.
481 * @see #getDefaultOptions
484 public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID
485 + ".compiler.maxProblemPerUnit"; //$NON-NLS-1$
488 * Possible configurable option ID.
490 * @see #getDefaultOptions
493 public static final String COMPILER_SOURCE = PLUGIN_ID + ".compiler.source"; //$NON-NLS-1$
496 * Possible configurable option ID.
498 * @see #getDefaultOptions
501 public static final String COMPILER_COMPLIANCE = PLUGIN_ID
502 + ".compiler.compliance"; //$NON-NLS-1$
505 * Possible configurable option ID.
507 * @see #getDefaultOptions
510 public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID
511 + ".compiler.taskPriorities"; //$NON-NLS-1$
514 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
516 * @see #getDefaultOptions
519 public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$
522 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
524 * @see #getDefaultOptions
527 public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$
530 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
532 * @see #getDefaultOptions
535 public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$
538 * Possible configurable option ID.
540 * @see #getDefaultOptions
542 public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID
543 + ".computeJavaBuildOrder"; //$NON-NLS-1$
546 * Possible configurable option ID.
548 * @see #getDefaultOptions
551 public static final String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER = PLUGIN_ID
552 + ".builder.resourceCopyExclusionFilter"; //$NON-NLS-1$
555 * Possible configurable option ID.
557 * @see #getDefaultOptions
560 public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID
561 + ".builder.duplicateResourceTask"; //$NON-NLS-1$
564 * Possible configurable option ID.
566 * @see #getDefaultOptions
569 public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID
570 + ".builder.cleanOutputFolder"; //$NON-NLS-1$
573 * Possible configurable option ID.
575 * @see #getDefaultOptions
578 public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID
579 + ".incompleteClasspath"; //$NON-NLS-1$
582 * Possible configurable option ID.
584 * @see #getDefaultOptions
587 public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID
588 + ".circularClasspath"; //$NON-NLS-1$
591 * Possible configurable option ID.
593 * @see #getDefaultOptions
596 public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID
597 + ".builder.invalidClasspath"; //$NON-NLS-1$
600 * Possible configurable option ID.
602 * @see #getDefaultOptions
605 public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID
606 + ".classpath.exclusionPatterns"; //$NON-NLS-1$
609 * Possible configurable option ID.
611 * @see #getDefaultOptions
614 public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID
615 + ".classpath.multipleOutputLocations"; //$NON-NLS-1$
622 public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$
625 * Default task priority
629 public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; //$NON-NLS-1$
632 * Possible configurable option ID
634 * @see #getDefaultOptions
637 public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID
638 + ".formatter.space.castexpression"; //$NON-NLS-1$
641 * Possible configurable option ID.
643 * @see #getDefaultOptions
646 public static final String CODEASSIST_VISIBILITY_CHECK = PLUGIN_ID
647 + ".codeComplete.visibilityCheck"; //$NON-NLS-1$
650 * Possible configurable option ID.
652 * @see #getDefaultOptions
655 public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID
656 + ".codeComplete.forceImplicitQualification"; //$NON-NLS-1$
659 * Possible configurable option ID.
661 * @see #getDefaultOptions
664 public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID
665 + ".codeComplete.fieldPrefixes"; //$NON-NLS-1$
668 * Possible configurable option ID.
670 * @see #getDefaultOptions
673 public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID
674 + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
677 * Possible configurable option ID.
679 * @see #getDefaultOptions
682 public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID
683 + ".codeComplete.localPrefixes"; //$NON-NLS-1$
686 * Possible configurable option ID.
688 * @see #getDefaultOptions
691 public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID
692 + ".codeComplete.argumentPrefixes"; //$NON-NLS-1$
695 * Possible configurable option ID.
697 * @see #getDefaultOptions
700 public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID
701 + ".codeComplete.fieldSuffixes"; //$NON-NLS-1$
704 * Possible configurable option ID.
706 * @see #getDefaultOptions
709 public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID
710 + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
713 * Possible configurable option ID.
715 * @see #getDefaultOptions
718 public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID
719 + ".codeComplete.localSuffixes"; //$NON-NLS-1$
722 * Possible configurable option ID.
724 * @see #getDefaultOptions
727 public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID
728 + ".codeComplete.argumentSuffixes"; //$NON-NLS-1$
730 // *************** Possible values for configurable options.
731 // ********************
734 * Possible configurable option value.
736 * @see #getDefaultOptions
738 public static final String GENERATE = "generate"; //$NON-NLS-1$
741 * Possible configurable option value.
743 * @see #getDefaultOptions
745 public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
748 * Possible configurable option value.
750 * @see #getDefaultOptions
752 public static final String PRESERVE = "preserve"; //$NON-NLS-1$
755 * Possible configurable option value.
757 * @see #getDefaultOptions
759 public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
762 * Possible configurable option value.
764 * @see #getDefaultOptions
766 public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$
769 * Possible configurable option value.
771 * @see #getDefaultOptions
773 public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$
776 * Possible configurable option value.
778 * @see #getDefaultOptions
781 public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
784 * Possible configurable option value.
786 * @see #getDefaultOptions
789 public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
792 * Possible configurable option value.
794 * @see #getDefaultOptions
797 public static final String ABORT = "abort"; //$NON-NLS-1$
800 * Possible configurable option value.
802 * @see #getDefaultOptions
804 public static final String ERROR = "error"; //$NON-NLS-1$
807 * Possible configurable option value.
809 * @see #getDefaultOptions
811 public static final String WARNING = "warning"; //$NON-NLS-1$
814 * Possible configurable option value.
816 * @see #getDefaultOptions
818 public static final String IGNORE = "ignore"; //$NON-NLS-1$
821 * Possible configurable option value.
823 * @see #getDefaultOptions
825 public static final String COMPUTE = "compute"; //$NON-NLS-1$
828 * Possible configurable option value.
830 * @see #getDefaultOptions
835 * Returns a table of all known configurable options with their default
836 * values. These options allow to configure the behaviour of the underlying
837 * components. The client may safely use the result as a template that they
838 * can modify and then pass to <code>setOptions</code>.
840 * Helper constants have been defined on JavaCore for each of the option ID
841 * and their possible constant values.
843 * Note: more options might be added in further releases.
847 * RECOGNIZED OPTIONS:
848 * COMPILER / Generating Local Variable Debug Attribute
849 * When generated, this attribute will enable local variable names
850 * to be displayed in debugger, only in place where variables are
851 * definitely assigned (.class file is then bigger)
852 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.localVariable"
853 * - possible values: { "generate", "do not generate" }
854 * - default: "generate"
856 * COMPILER / Generating Line Number Debug Attribute
857 * When generated, this attribute will enable source code highlighting in debugger
858 * (.class file is then bigger).
859 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.lineNumber"
860 * - possible values: { "generate", "do not generate" }
861 * - default: "generate"
863 * COMPILER / Generating Source Debug Attribute
864 * When generated, this attribute will enable the debugger to present the
865 * corresponding source code.
866 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.sourceFile"
867 * - possible values: { "generate", "do not generate" }
868 * - default: "generate"
870 * COMPILER / Preserving Unused Local Variables
871 * Unless requested to preserve unused local variables (i.e. never read), the
872 * compiler will optimize them out, potentially altering debugging
873 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.unusedLocal"
874 * - possible values: { "preserve", "optimize out" }
875 * - default: "preserve"
877 * COMPILER / Defining Target Java Platform
878 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
879 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
880 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.targetPlatform"
881 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
882 * - default: "1.1"
884 * COMPILER / Reporting Unreachable Code
885 * Unreachable code can optionally be reported as an error, warning or simply
886 * ignored. The bytecode generation will always optimized it out.
887 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unreachableCode"
888 * - possible values: { "error", "warning", "ignore" }
889 * - default: "error"
891 * COMPILER / Reporting Invalid Import
892 * An import statement that cannot be resolved might optionally be reported
893 * as an error, as a warning or ignored.
894 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.invalidImport"
895 * - possible values: { "error", "warning", "ignore" }
896 * - default: "error"
898 * COMPILER / Reporting Attempt to Override Package-Default Method
899 * A package default method is not visible in a different package, and thus
900 * cannot be overridden. When enabling this option, the compiler will signal
901 * such scenarii either as an error or a warning.
902 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
903 * - possible values: { "error", "warning", "ignore" }
904 * - default: "warning"
906 * COMPILER / Reporting Method With Constructor Name
907 * Naming a method with a constructor name is generally considered poor
908 * style programming. When enabling this option, the compiler will signal such
909 * scenarii either as an error or a warning.
910 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.methodWithConstructorName"
911 * - possible values: { "error", "warning", "ignore" }
912 * - default: "warning"
914 * COMPILER / Reporting Deprecation
915 * When enabled, the compiler will signal use of deprecated API either as an
916 * error or a warning.
917 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecation"
918 * - possible values: { "error", "warning", "ignore" }
919 * - default: "warning"
921 * COMPILER / Reporting Deprecation Inside Deprecated Code
922 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
923 * The severity of the problem is controlled with option "org.phpeclipse.phpdt.core.compiler.problem.deprecation".
924 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
925 * - possible values: { "enabled", "disabled" }
926 * - default: "disabled"
928 * COMPILER / Reporting Hidden Catch Block
929 * Locally to a try statement, some catch blocks may hide others , e.g.
930 * try { throw new java.io.CharConversionException();
931 * } catch (java.io.CharConversionException e) {
932 * } catch (java.io.IOException e) {}.
933 * When enabling this option, the compiler will issue an error or a warning for hidden
934 * catch blocks corresponding to checked exceptions
935 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.hiddenCatchBlock"
936 * - possible values: { "error", "warning", "ignore" }
937 * - default: "warning"
939 * COMPILER / Reporting Unused Local
940 * When enabled, the compiler will issue an error or a warning for unused local
941 * variables (i.e. variables never read from)
942 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedLocal"
943 * - possible values: { "error", "warning", "ignore" }
944 * - default: "ignore"
946 * COMPILER / Reporting Unused Parameter
947 * When enabled, the compiler will issue an error or a warning for unused method
948 * parameters (i.e. parameters never read from)
949 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedParameter"
950 * - possible values: { "error", "warning", "ignore" }
951 * - default: "ignore"
953 * COMPILER / Reporting Unused Import
954 * When enabled, the compiler will issue an error or a warning for unused import
956 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedImport"
957 * - possible values: { "error", "warning", "ignore" }
958 * - default: "warning"
960 * COMPILER / Reporting Synthetic Access Emulation
961 * When enabled, the compiler will issue an error or a warning whenever it emulates
962 * access to a non-accessible member of an enclosing type. Such access can have
963 * performance implications.
964 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.syntheticAccessEmulation"
965 * - possible values: { "error", "warning", "ignore" }
966 * - default: "ignore"
968 * COMPILER / Reporting Non-Externalized String Literal
969 * When enabled, the compiler will issue an error or a warning for non externalized
970 * String literal (i.e. non tagged with //$NON-NLS-<n>$).
971 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
972 * - possible values: { "error", "warning", "ignore" }
973 * - default: "ignore"
975 * COMPILER / Reporting Usage of 'assert' Identifier
976 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
977 * used as an identifier (reserved keyword in 1.4)
978 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.assertIdentifier"
979 * - possible values: { "error", "warning", "ignore" }
980 * - default: "ignore"
982 * COMPILER / Reporting Usage of expression receiver on static invocation/field access
983 * When enabled, the compiler will issue an error or a warning whenever a static field
984 * or method is accessed with an expression receiver.
985 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.staticAccessReceiver"
986 * - possible values: { "error", "warning", "ignore" }
987 * - default: "warning"
989 * COMPILER / Reporting Assignment with no effect
990 * When enabled, the compiler will issue an error or a warning whenever an assignment
991 * has no effect (e.g 'x = x').
992 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.noEffectAssignment"
993 * - possible values: { "error", "warning", "ignore" }
994 * - default: "warning"
996 * COMPILER / Setting Source Compatibility Mode
997 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
998 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
999 * level should be set to "1.4" and the compliance mode should be "1.4".
1000 * - option id: "org.phpeclipse.phpdt.core.compiler.source"
1001 * - possible values: { "1.3", "1.4" }
1002 * - default: "1.3"
1004 * COMPILER / Setting Compliance Level
1005 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
1006 * should not go beyond "1.3" level.
1007 * - option id: "org.phpeclipse.phpdt.core.compiler.compliance"
1008 * - possible values: { "1.3", "1.4" }
1009 * - default: "1.3"
1011 * COMPILER / Maximum number of problems reported per compilation unit
1012 * Specify the maximum number of problems reported on each compilation unit.
1013 * - option id: "org.phpeclipse.phpdt.core.compiler.maxProblemPerUnit"
1014 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
1015 * - default: "100"
1017 * COMPILER / Define the Automatic Task Tags
1018 * When the tag is non empty, the compiler will issue a task marker whenever it encounters
1019 * one of the corresponding tag inside any comment in Java source code.
1020 * Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed.
1021 * - option id: "org.phpeclipse.phpdt.core.compiler.taskTags"
1022 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card
1023 * - default: ""
1024 * COMPILER / Define the Automatic Task Priorities
1025 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
1026 * of the task markers issued by the compiler.
1027 * If the default is specified, the priority of each task marker is "NORMAL".
1028 * - option id: "org.phpeclipse.phpdt.core.compiler.taskPriorities"
1029 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
1030 * - default: ""
1032 * BUILDER / Specifying Filters for Resource Copying Control
1033 * Allow to specify some filters to control the resource copy process.
1034 * - option id: "org.phpeclipse.phpdt.core.builder.resourceCopyExclusionFilter"
1035 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
1036 * or the name of a folder which ends with '/'
1037 * - default: ""
1039 * BUILDER / Abort if Invalid Classpath
1040 * Allow to toggle the builder to abort if the classpath is invalid
1041 * - option id: "org.phpeclipse.phpdt.core.builder.invalidClasspath"
1042 * - possible values: { "abort", "ignore" }
1043 * - default: "ignore"
1045 * BUILDER / Cleaning Output Folder(s)
1046 * Indicate whether the JavaBuilder is allowed to clean the output folders
1047 * when performing full build operations.
1048 * - option id: "org.phpeclipse.phpdt.core.builder.cleanOutputFolder"
1049 * - possible values: { "clean", "ignore" }
1050 * - default: "clean"
1052 * JAVACORE / Computing Project Build Order
1053 * Indicate whether JavaCore should enforce the project build order to be based on
1054 * the classpath prerequisite chain. When requesting to compute, this takes over
1055 * the platform default order (based on project references).
1056 * - option id: "org.phpeclipse.phpdt.core.computeJavaBuildOrder"
1057 * - possible values: { "compute", "ignore" }
1058 * - default: "ignore"
1060 * JAVACORE / Specify Default Source Encoding Format
1061 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
1062 * to 'ResourcesPlugin.getEncoding()'.
1063 * - option id: "org.phpeclipse.phpdt.core.encoding"
1064 * - possible values: { any of the supported encoding name}.
1065 * - default: <platform default>
1067 * JAVACORE / Reporting Incomplete Classpath
1068 * An entry on the classpath doesn't exist or is not visible (e.g. a referenced project is closed).
1069 * - option id: "org.phpeclipse.phpdt.core.incompleteClasspath"
1070 * - possible values: { "error", "warning"}
1071 * - default: "error"
1073 * JAVACORE / Reporting Classpath Cycle
1074 * A project is involved in a cycle.
1075 * - option id: "org.phpeclipse.phpdt.core.circularClasspath"
1076 * - possible values: { "error", "warning" }
1077 * - default: "error"
1079 * FORMATTER / Inserting New Line Before Opening Brace
1080 * When Insert, a new line is inserted before an opening brace, otherwise nothing
1082 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.openingBrace"
1083 * - possible values: { "insert", "do not insert" }
1084 * - default: "do not insert"
1086 * FORMATTER / Inserting New Line Inside Control Statement
1087 * When Insert, a new line is inserted between } and following else, catch, finally
1088 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.controlStatement"
1089 * - possible values: { "insert", "do not insert" }
1090 * - default: "do not insert"
1092 * FORMATTER / Clearing Blank Lines
1093 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
1094 * and all others removed.
1095 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.clearAll"
1096 * - possible values: { "clear all", "preserve one" }
1097 * - default: "preserve one"
1099 * FORMATTER / Inserting New Line Between Else/If
1100 * When Insert, a blank line is inserted between an else and an if when they are
1101 * contiguous. When choosing to not insert, else-if will be kept on the same
1102 * line when possible.
1103 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.elseIf"
1104 * - possible values: { "insert", "do not insert" }
1105 * - default: "do not insert"
1107 * FORMATTER / Inserting New Line In Empty Block
1108 * When insert, a line break is inserted between contiguous { and }, if } is not followed
1110 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.emptyBlock"
1111 * - possible values: { "insert", "do not insert" }
1112 * - default: "insert"
1114 * FORMATTER / Splitting Lines Exceeding Length
1115 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
1116 * disable line splitting
1117 * - option id: "org.phpeclipse.phpdt.core.formatter.lineSplit"
1118 * - possible values: "<n>", where n is zero or a positive integer
1119 * - default: "80"
1121 * FORMATTER / Compacting Assignment
1122 * Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space
1123 * is inserted before the assignment operator
1124 * - option id: "org.phpeclipse.phpdt.core.formatter.style.assignment"
1125 * - possible values: { "compact", "normal" }
1126 * - default: "normal"
1128 * FORMATTER / Defining Indentation Character
1129 * Either choose to indent with tab characters or spaces
1130 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.char"
1131 * - possible values: { "tab", "space" }
1132 * - default: "tab"
1134 * FORMATTER / Defining Space Indentation Length
1135 * When using spaces, set the amount of space characters to use for each
1137 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.size"
1138 * - possible values: "<n>", where n is a positive integer
1139 * - default: "4"
1141 * CODEASSIST / Activate Visibility Sensitive Completion
1142 * When active, completion doesn't show that you can not see
1143 * (e.g. you can not see private methods of a super class).
1144 * - option id: "org.phpeclipse.phpdt.core.codeComplete.visibilityCheck"
1145 * - possible values: { "enabled", "disabled" }
1146 * - default: "disabled"
1148 * CODEASSIST / Automatic Qualification of Implicit Members
1149 * When active, completion automatically qualifies completion on implicit
1150 * field references and message expressions.
1151 * - option id: "org.phpeclipse.phpdt.core.codeComplete.forceImplicitQualification"
1152 * - possible values: { "enabled", "disabled" }
1153 * - default: "disabled"
1155 * CODEASSIST / Define the Prefixes for Field Name
1156 * When the prefixes is non empty, completion for field name will begin with
1157 * one of the proposed prefixes.
1158 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldPrefixes"
1159 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1160 * - default: ""
1162 * CODEASSIST / Define the Prefixes for Static Field Name
1163 * When the prefixes is non empty, completion for static field name will begin with
1164 * one of the proposed prefixes.
1165 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldPrefixes"
1166 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1167 * - default: ""
1169 * CODEASSIST / Define the Prefixes for Local Variable Name
1170 * When the prefixes is non empty, completion for local variable name will begin with
1171 * one of the proposed prefixes.
1172 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localPrefixes"
1173 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1174 * - default: ""
1176 * CODEASSIST / Define the Prefixes for Argument Name
1177 * When the prefixes is non empty, completion for argument name will begin with
1178 * one of the proposed prefixes.
1179 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentPrefixes"
1180 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1181 * - default: ""
1183 * CODEASSIST / Define the Suffixes for Field Name
1184 * When the suffixes is non empty, completion for field name will end with
1185 * one of the proposed suffixes.
1186 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldSuffixes"
1187 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1188 * - default: ""
1190 * CODEASSIST / Define the Suffixes for Static Field Name
1191 * When the suffixes is non empty, completion for static field name will end with
1192 * one of the proposed suffixes.
1193 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldSuffixes"
1194 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1195 * - default: ""
1197 * CODEASSIST / Define the Suffixes for Local Variable Name
1198 * When the suffixes is non empty, completion for local variable name will end with
1199 * one of the proposed suffixes.
1200 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localSuffixes"
1201 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1202 * - default: ""
1204 * CODEASSIST / Define the Suffixes for Argument Name
1205 * When the suffixes is non empty, completion for argument name will end with
1206 * one of the proposed suffixes.
1207 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentSuffixes"
1208 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
1209 * - default: ""
1212 * @return a mutable table containing the default settings of all known options
1225 // public static Hashtable getDefaultOptions() {
1227 // Hashtable defaultOptions = new Hashtable(10);
1229 // // see #initializeDefaultPluginPreferences() for changing default
1231 // Preferences preferences = getPlugin().getPluginPreferences();
1232 // HashSet optionNames = OptionNames;
1234 // // get preferences set to their default
1235 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1236 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1237 // String propertyName = defaultPropertyNames[i];
1238 // if (optionNames.contains(propertyName)) {
1239 // defaultOptions.put(propertyName,
1240 // preferences.getDefaultString(propertyName));
1243 // // get preferences not set to their default
1244 // String[] propertyNames = preferences.propertyNames();
1245 // for (int i = 0; i < propertyNames.length; i++) {
1246 // String propertyName = propertyNames[i];
1247 // if (optionNames.contains(propertyName)) {
1248 // defaultOptions.put(propertyName,
1249 // preferences.getDefaultString(propertyName));
1252 // // get encoding through resource plugin
1253 // defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1255 // return defaultOptions;
1258 * Helper method for returning one option value only. Equivalent to
1259 * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
1260 * may answer <code>null</code> if this option does not exist.
1262 * For a complete description of the configurable options, see
1263 * <code>getDefaultOptions</code>.
1267 * the name of an option
1268 * @return the String value of a given option
1269 * @see JavaCore#getDefaultOptions
1272 // public static String getOption(String optionName) {
1274 // if (CORE_ENCODING.equals(optionName)) {
1275 // return ResourcesPlugin.getEncoding();
1277 // if (OptionNames.contains(optionName)) {
1278 // Preferences preferences = getPlugin().getPluginPreferences();
1279 // return preferences.getString(optionName).trim();
1284 * Returns the table of the current options. Initially, all options have
1285 * their default values, and this method returns a table that includes all
1288 * For a complete description of the configurable options, see
1289 * <code>getDefaultOptions</code>.
1292 * @return table of current settings of all options (key type:
1293 * <code>String</code>; value type: <code>String</code>)
1294 * @see JavaCore#getDefaultOptions
1296 // public static Hashtable getOptions() {
1298 // Hashtable options = new Hashtable(10);
1300 // // see #initializeDefaultPluginPreferences() for changing default
1302 // Plugin plugin = getPlugin();
1303 // if (plugin != null) {
1304 // Preferences preferences = getPlugin().getPluginPreferences();
1305 // HashSet optionNames = OptionNames;
1307 // // get preferences set to their default
1308 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1309 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1310 // String propertyName = defaultPropertyNames[i];
1311 // if (optionNames.contains(propertyName)) {
1312 // options.put(propertyName, preferences.getDefaultString(propertyName));
1315 // // get preferences not set to their default
1316 // String[] propertyNames = preferences.propertyNames();
1317 // for (int i = 0; i < propertyNames.length; i++) {
1318 // String propertyName = propertyNames[i];
1319 // if (optionNames.contains(propertyName)) {
1320 // options.put(propertyName, preferences.getString(propertyName).trim());
1323 // // get encoding through resource plugin
1324 // options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1329 * Sets the current table of options. All and only the options explicitly
1330 * included in the given table are remembered; all previous option settings
1331 * are forgotten, including ones not explicitly mentioned.
1333 * For a complete description of the configurable options, see
1334 * <code>getDefaultOptions</code>.
1338 * the new options (key type: <code>String</code>; value type:
1339 * <code>String</code>), or <code>null</code> to reset all
1340 * options to their default values
1341 * @see JavaCore#getDefaultOptions
1343 // public static void setOptions(Hashtable newOptions) {
1345 // // see #initializeDefaultPluginPreferences() for changing default
1347 // Preferences preferences = getPlugin().getPluginPreferences();
1349 // if (newOptions == null) {
1350 // newOptions = getDefaultOptions();
1352 // Enumeration keys = newOptions.keys();
1353 // while (keys.hasMoreElements()) {
1354 // String key = (String) keys.nextElement();
1355 // if (!OptionNames.contains(key))
1356 // continue; // unrecognized option
1357 // if (key.equals(CORE_ENCODING))
1358 // continue; // skipped, contributed by resource prefs
1359 // String value = (String) newOptions.get(key);
1360 // preferences.setValue(key, value);
1363 // // persist options
1364 // getPlugin().savePluginPreferences();
1366 public static IProject[] getPHPProjects() {
1367 List phpProjectsList = new ArrayList();
1368 IProject[] workspaceProjects = PHPeclipsePlugin.getWorkspace()
1369 .getRoot().getProjects();
1371 for (int i = 0; i < workspaceProjects.length; i++) {
1372 IProject iProject = workspaceProjects[i];
1373 if (isPHPProject(iProject))
1374 phpProjectsList.add(iProject);
1377 IProject[] phpProjects = new IProject[phpProjectsList.size()];
1378 return (IProject[]) phpProjectsList.toArray(phpProjects);
1381 // public static PHPProject getPHPProject(String name) {
1382 // IProject aProject =
1383 // PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
1384 // if (isPHPProject(aProject)) {
1385 // PHPProject thePHPProject = new PHPProject();
1386 // thePHPProject.setProject(aProject);
1387 // return thePHPProject;
1392 public static boolean isPHPProject(IProject aProject) {
1394 return aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID);
1395 } catch (CoreException e) {
1401 // public static PHPFile create(IFile aFile) {
1402 // if (PHPFile.EXTENSION.equalsIgnoreCase(aFile.getFileExtension()))
1403 // return new PHPFile(aFile);
1404 // if (PHPFile.EXTENSION1.equalsIgnoreCase(aFile.getFileExtension()))
1405 // return new PHPFile(aFile);
1406 // if (PHPFile.EXTENSION2.equalsIgnoreCase(aFile.getFileExtension()))
1407 // return new PHPFile(aFile);
1408 // if (PHPFile.EXTENSION3.equalsIgnoreCase(aFile.getFileExtension()))
1409 // return new PHPFile(aFile);
1410 // if (PHPFile.EXTENSION4.equalsIgnoreCase(aFile.getFileExtension()))
1411 // return new PHPFile(aFile);
1412 // if (PHPFile.EXTENSION5.equalsIgnoreCase(aFile.getFileExtension()))
1413 // return new PHPFile(aFile);
1418 // public static PHPProject create(IProject aProject) {
1421 // if (aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1422 // PHPProject project = new PHPProject();
1423 // project.setProject(aProject);
1426 // } catch (CoreException e) {
1427 // System.err.println("Exception occurred in PHPCore#create(IProject): " +
1434 public static void addPHPNature(IProject project, IProgressMonitor monitor)
1435 throws CoreException {
1436 if (!project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1437 IProjectDescription description = project.getDescription();
1438 String[] prevNatures = description.getNatureIds();
1439 String[] newNatures = new String[prevNatures.length + 1];
1440 System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
1441 newNatures[prevNatures.length] = PHPeclipsePlugin.PHP_NATURE_ID;
1442 description.setNatureIds(newNatures);
1443 project.setDescription(description, monitor);
1448 * Returns the single instance of the PHP core plug-in runtime class.
1450 * @return the single instance of the PHP core plug-in runtime class
1452 public static Plugin getPlugin() {
1453 return PHPeclipsePlugin.getDefault();
1457 * Runs the given action as an atomic Java model operation.
1459 * After running a method that modifies java elements, registered listeners
1460 * receive after-the-fact notification of what just transpired, in the form
1461 * of a element changed event. This method allows clients to call a number
1462 * of methods that modify java elements and only have element changed event
1463 * notifications reported at the end of the entire batch.
1466 * If this method is called outside the dynamic scope of another such call,
1467 * this method runs the action and then reports a single element changed
1468 * event describing the net effect of all changes done to java elements by
1472 * If this method is called in the dynamic scope of another such call, this
1473 * method simply runs the action.
1477 * the action to perform
1479 * a progress monitor, or <code>null</code> if progress
1480 * reporting and cancellation are not desired
1481 * @exception CoreException
1482 * if the operation failed.
1485 // public static void run(IWorkspaceRunnable action, IProgressMonitor
1486 // monitor) throws CoreException {
1487 // run(action, ResourcesPlugin.getWorkspace().getRoot(), monitor);
1490 * Runs the given action as an atomic Java model operation.
1492 * After running a method that modifies java elements, registered listeners
1493 * receive after-the-fact notification of what just transpired, in the form
1494 * of a element changed event. This method allows clients to call a number
1495 * of methods that modify java elements and only have element changed event
1496 * notifications reported at the end of the entire batch.
1499 * If this method is called outside the dynamic scope of another such call,
1500 * this method runs the action and then reports a single element changed
1501 * event describing the net effect of all changes done to java elements by
1505 * If this method is called in the dynamic scope of another such call, this
1506 * method simply runs the action.
1509 * The supplied scheduling rule is used to determine whether this operation
1510 * can be run simultaneously with workspace changes in other threads. See
1511 * <code>IWorkspace.run(...)</code> for more details.
1515 * the action to perform
1517 * the scheduling rule to use when running this operation, or
1518 * <code>null</code> if there are no scheduling restrictions
1519 * for this operation.
1521 * a progress monitor, or <code>null</code> if progress
1522 * reporting and cancellation are not desired
1523 * @exception CoreException
1524 * if the operation failed.
1527 // public static void run(IWorkspaceRunnable action, ISchedulingRule rule,
1528 // IProgressMonitor monitor) throws CoreException {
1529 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
1530 // if (workspace.isTreeLocked()) {
1531 // new BatchOperation(action).run(monitor);
1533 // // use IWorkspace.run(...) to ensure that a build will be done in
1535 // workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE,
1541 * Adds the given listener for changes to Java elements. Has no effect if an
1542 * identical listener is already registered.
1544 * This listener will only be notified during the POST_CHANGE resource
1545 * change notification and any reconcile operation (POST_RECONCILE). For
1546 * finer control of the notification, use
1547 * <code>addElementChangedListener(IElementChangedListener,int)</code>,
1548 * which allows to specify a different eventMask.
1550 * @see ElementChangedEvent
1554 public static void addElementChangedListener(
1555 IElementChangedListener listener) {
1556 addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE
1557 | ElementChangedEvent.POST_RECONCILE);
1561 * Adds the given listener for changes to Java elements. Has no effect if an
1562 * identical listener is already registered. After completion of this
1563 * method, the given listener will be registered for exactly the specified
1564 * events. If they were previously registered for other events, they will be
1567 * Once registered, a listener starts receiving notification of changes to
1568 * java elements in the model. The listener continues to receive
1569 * notifications until it is replaced or removed.
1572 * Listeners can listen for several types of event as defined in
1573 * <code>ElementChangeEvent</code>. Clients are free to register for any
1574 * number of event types however if they register for more than one, it is
1575 * their responsibility to ensure they correctly handle the case where the
1576 * same java element change shows up in multiple notifications. Clients are
1577 * guaranteed to receive only the events for which they are registered.
1583 * the bit-wise OR of all event types of interest to the listener
1584 * @see IElementChangedListener
1585 * @see ElementChangedEvent
1586 * @see #removeElementChangedListener(IElementChangedListener)
1589 public static void addElementChangedListener(
1590 IElementChangedListener listener, int eventMask) {
1591 JavaModelManager.getJavaModelManager().addElementChangedListener(
1592 listener, eventMask);
1596 * Configures the given marker attribute map for the given Java element.
1597 * Used for markers, which denote a Java element rather than a resource.
1600 * the mutable marker attribute map (key type:
1601 * <code>String</code>, value type: <code>String</code>)
1603 * the Java element for which the marker needs to be configured
1605 public static void addJavaElementMarkerAttributes(Map attributes,
1606 IJavaElement element) {
1607 // if (element instanceof IMember)
1608 // element = ((IMember) element).getClassFile();
1609 if (attributes != null && element != null)
1610 attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier());
1614 * Adds the given listener for POST_CHANGE resource change events to the Java core.
1615 * The listener is guarantied to be notified of the POST_CHANGE resource change event before
1616 * the Java core starts processing the resource change event itself.
1618 * Has no effect if an identical listener is already registered.
1621 * @param listener the listener
1622 * @see #removePreProcessingResourceChangedListener(IResourceChangeListener)
1625 public static void addPreProcessingResourceChangedListener(IResourceChangeListener listener) {
1626 JavaModelManager.getJavaModelManager().deltaState.addPreResourceChangedListener(listener);
1629 * Configures the given marker for the given Java element. Used for markers,
1630 * which denote a Java element rather than a resource.
1633 * the marker to be configured
1635 * the Java element for which the marker needs to be configured
1636 * @exception CoreException
1637 * if the <code>IMarker.setAttribute</code> on the marker
1640 public void configureJavaElementMarker(IMarker marker, IJavaElement element)
1641 throws CoreException {
1642 // if (element instanceof IMember)
1643 // element = ((IMember) element).getClassFile();
1644 if (marker != null && element != null)
1645 marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier());
1649 * Returns the Java model element corresponding to the given handle
1650 * identifier generated by <code>IJavaElement.getHandleIdentifier()</code>,
1651 * or <code>null</code> if unable to create the associated element.
1653 public static IJavaElement create(String handleIdentifier) {
1654 if (handleIdentifier == null) {
1658 return JavaModelManager.getJavaModelManager().getHandleFromMemento(
1660 } catch (JavaModelException e) {
1666 * Returns the Java element corresponding to the given file, or
1667 * <code>null</code> if unable to associate the given file with a Java
1671 * The file must be one of:
1673 * <li>a <code>.java</code> file - the element returned is the
1674 * corresponding <code>ICompilationUnit</code></li>
1675 * <li>a <code>.class</code> file - the element returned is the
1676 * corresponding <code>IClassFile</code></li>
1677 * <li>a <code>.jar</code> file - the element returned is the
1678 * corresponding <code>IPackageFragmentRoot</code></li>
1681 * Creating a Java element has the side effect of creating and opening all
1682 * of the element's parents if they are not yet open.
1686 * @return the Java element corresponding to the given file, or
1687 * <code>null</code> if unable to associate the given file with a
1690 public static IJavaElement create(IFile file) {
1691 return JavaModelManager.create(file, null);
1695 * Returns the package fragment or package fragment root corresponding to
1696 * the given folder, or <code>null</code> if unable to associate the given
1697 * folder with a Java element.
1699 * Note that a package fragment root is returned rather than a default
1702 * Creating a Java element has the side effect of creating and opening all
1703 * of the element's parents if they are not yet open.
1707 * @return the package fragment or package fragment root corresponding to
1708 * the given folder, or <code>null</code> if unable to associate
1709 * the given folder with a Java element
1711 public static IJavaElement create(IFolder folder) {
1712 return JavaModelManager.create(folder, null);
1716 * Returns the Java project corresponding to the given project.
1718 * Creating a Java Project has the side effect of creating and opening all
1719 * of the project's parents if they are not yet open.
1721 * Note that no check is done at this time on the existence or the java
1722 * nature of this project.
1726 * @return the Java project corresponding to the given project, null if the
1727 * given project is null
1729 public static IJavaProject create(IProject project) {
1730 if (project == null) {
1733 JavaModel javaModel = JavaModelManager.getJavaModelManager()
1735 return javaModel.getJavaProject(project);
1739 * Returns the Java element corresponding to the given resource, or
1740 * <code>null</code> if unable to associate the given resource with a Java
1743 * The resource must be one of:
1745 * <li>a project - the element returned is the corresponding
1746 * <code>IJavaProject</code></li>
1747 * <li>a <code>.java</code> file - the element returned is the
1748 * corresponding <code>ICompilationUnit</code></li>
1749 * <li>a <code>.class</code> file - the element returned is the
1750 * corresponding <code>IClassFile</code></li>
1751 * <li>a <code>.jar</code> file - the element returned is the
1752 * corresponding <code>IPackageFragmentRoot</code></li>
1753 * <li>a folder - the element returned is the corresponding
1754 * <code>IPackageFragmentRoot</code> or <code>IPackageFragment</code>
1756 * <li>the workspace root resource - the element returned is the
1757 * <code>IJavaModel</code></li>
1760 * Creating a Java element has the side effect of creating and opening all
1761 * of the element's parents if they are not yet open.
1764 * the given resource
1765 * @return the Java element corresponding to the given resource, or
1766 * <code>null</code> if unable to associate the given resource
1767 * with a Java element
1769 public static IJavaElement create(IResource resource) {
1770 return JavaModelManager.create(resource, null);
1774 * Returns the Java model.
1778 * @return the Java model, or <code>null</code> if the root is null
1780 public static IJavaModel create(IWorkspaceRoot root) {
1784 return JavaModelManager.getJavaModelManager().getJavaModel();
1788 * Creates and returns a class file element for the given
1789 * <code>.class</code> file. Returns <code>null</code> if unable to
1790 * recognize the class file.
1793 * the given <code>.class</code> file
1794 * @return a class file element for the given <code>.class</code> file, or
1795 * <code>null</code> if unable to recognize the class file
1797 //public static IClassFile createClassFileFrom(IFile file) {
1798 // return JavaModelManager.createClassFileFrom(file, null);
1801 * Creates and returns a compilation unit element for the given
1802 * <code>.java</code> file. Returns <code>null</code> if unable to
1803 * recognize the compilation unit.
1806 * the given <code>.java</code> file
1807 * @return a compilation unit element for the given <code>.java</code>
1808 * file, or <code>null</code> if unable to recognize the
1811 public static ICompilationUnit createCompilationUnitFrom(IFile file) {
1812 return JavaModelManager.createCompilationUnitFrom(file, null);
1816 * Creates and returns a handle for the given JAR file. The Java model
1817 * associated with the JAR's project may be created as a side effect.
1820 * the given JAR file
1821 * @return a handle for the given JAR file, or <code>null</code> if unable
1822 * to create a JAR package fragment root. (for example, if the JAR
1823 * file represents a non-Java resource)
1825 //public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile
1827 // return JavaModelManager.createJarPackageFragmentRootFrom(file, null);
1830 * Answers the project specific value for a given classpath container. In
1831 * case this container path could not be resolved, then will answer
1832 * <code>null</code>. Both the container path and the project context are
1833 * supposed to be non-null.
1835 * The containerPath is a formed by a first ID segment followed with extra
1836 * segments, which can be used as additional hints for resolution. If no
1837 * container was ever recorded for this container path onto this project
1838 * (using <code>setClasspathContainer</code>, then a
1839 * <code>ClasspathContainerInitializer</code> will be activated if any was
1840 * registered for this container ID onto the extension point
1841 * "org.eclipse.jdt.core.classpathContainerInitializer".
1843 * There is no assumption that the returned container must answer the exact
1844 * same containerPath when requested
1845 * <code>IClasspathContainer#getPath</code>. Indeed, the containerPath is
1846 * just an indication for resolving it to an actual container object.
1848 * Classpath container values are persisted locally to the workspace, but
1849 * are not preserved from a session to another. It is thus highly
1850 * recommended to register a <code>ClasspathContainerInitializer</code>
1851 * for each referenced container (through the extension point
1852 * "org.eclipse.jdt.core.ClasspathContainerInitializer").
1855 * @param containerPath
1856 * the name of the container, which needs to be resolved
1858 * a specific project in which the container is being resolved
1859 * @return the corresponding classpath container or <code>null</code> if
1860 * unable to find one.
1862 * @exception JavaModelException
1863 * if an exception occurred while resolving the container, or
1864 * if the resolved container contains illegal entries
1865 * (contains CPE_CONTAINER entries or null entries).
1867 * @see ClasspathContainerInitializer
1868 * @see IClasspathContainer
1869 * @see #setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[],
1873 //public static IClasspathContainer getClasspathContainer(final IPath
1874 // containerPath, final IJavaProject project) throws JavaModelException {
1876 // IClasspathContainer container = JavaModelManager.containerGet(project,
1878 // if (container == JavaModelManager.ContainerInitializationInProgress)
1879 // return null; // break cycle
1881 // if (container == null){
1882 // final ClasspathContainerInitializer initializer =
1883 // JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
1884 // if (initializer != null){
1885 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1886 // System.out.println("CPContainer INIT - triggering initialization of:
1887 // ["+project.getElementName()+"] " + containerPath + " using initializer:
1888 // "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
1889 // new Exception("FAKE exception for dumping current CPContainer
1890 // (["+project.getElementName()+"] "+ containerPath+ ")INIT invocation stack
1891 // trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
1893 // JavaModelManager.containerPut(project, containerPath,
1894 // JavaModelManager.ContainerInitializationInProgress); // avoid
1895 // initialization cycles
1896 // boolean ok = false;
1898 // // wrap initializer call with Safe runnable in case initializer would be
1899 // causing some grief
1900 // Platform.run(new ISafeRunnable() {
1901 // public void handleException(Throwable exception) {
1902 // Util.log(exception, "Exception occurred in classpath container
1903 // initializer: "+initializer); //$NON-NLS-1$
1905 // public void run() throws Exception {
1906 // initializer.initialize(containerPath, project);
1910 // // retrieve value (if initialization was successful)
1911 // container = JavaModelManager.containerGet(project, containerPath);
1912 // if (container == JavaModelManager.ContainerInitializationInProgress)
1913 // return null; // break cycle
1916 // if (!ok) JavaModelManager.containerPut(project, containerPath, null); //
1919 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1920 // System.out.print("CPContainer INIT - after resolution:
1921 // ["+project.getElementName()+"] " + containerPath + " --> ");
1922 // //$NON-NLS-2$//$NON-NLS-1$//$NON-NLS-3$
1923 // if (container != null){
1924 // System.out.print("container: "+container.getDescription()+" {");
1925 // //$NON-NLS-2$//$NON-NLS-1$
1926 // IClasspathEntry[] entries = container.getClasspathEntries();
1927 // if (entries != null){
1928 // for (int i = 0; i < entries.length; i++){
1929 // if (i > 0) System.out.println(", ");//$NON-NLS-1$
1930 // System.out.println(entries[i]);
1933 // System.out.println("}");//$NON-NLS-1$
1935 // System.out.println("{unbound}");//$NON-NLS-1$
1939 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1940 // System.out.println("CPContainer INIT - no initializer found for:
1941 // "+project.getElementName()+"] " + containerPath); //$NON-NLS-1$
1946 // return container;
1949 * Helper method finding the classpath container initializer registered for
1950 * a given classpath container ID or <code>null</code> if none was found
1951 * while iterating over the contributions to extension point to the
1952 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
1954 * A containerID is the first segment of any container path, used to
1955 * identify the registered container initializer.
1959 * a containerID identifying a registered initializer
1960 * @return ClasspathContainerInitializer - the registered classpath
1961 * container initializer or <code>null</code> if none was found.
1964 //public static ClasspathContainerInitializer
1965 // getClasspathContainerInitializer(String containerID){
1967 // Plugin jdtCorePlugin = JavaCore.getPlugin();
1968 // if (jdtCorePlugin == null) return null;
1970 // IExtensionPoint extension =
1971 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID);
1972 // if (extension != null) {
1973 // IExtension[] extensions = extension.getExtensions();
1974 // for(int i = 0; i < extensions.length; i++){
1975 // IConfigurationElement [] configElements =
1976 // extensions[i].getConfigurationElements();
1977 // for(int j = 0; j < configElements.length; j++){
1978 // String initializerID = configElements[j].getAttribute("id");
1980 // if (initializerID != null && initializerID.equals(containerID)){
1981 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
1982 // System.out.println("CPContainer INIT - found initializer: "+containerID
1984 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
1987 // Object execExt = configElements[j].createExecutableExtension("class");
1989 // if (execExt instanceof ClasspathContainerInitializer){
1990 // return (ClasspathContainerInitializer)execExt;
1992 // } catch(CoreException e) {
2001 * Returns the path held in the given classpath variable. Returns <node>null
2002 * </code> if unable to bind.
2004 * Classpath variable values are persisted locally to the workspace, and are
2005 * preserved from session to session.
2007 * Note that classpath variables can be contributed registered initializers
2008 * for, using the extension point
2009 * "org.eclipse.jdt.core.classpathVariableInitializer". If an initializer is
2010 * registered for a variable, its persisted value will be ignored: its
2011 * initializer will thus get the opportunity to rebind the variable
2012 * differently on each session.
2014 * @param variableName
2015 * the name of the classpath variable
2016 * @return the path, or <code>null</code> if none
2017 * @see #setClasspathVariable
2019 public static IPath getClasspathVariable(final String variableName) {
2021 IPath variablePath = JavaModelManager.variableGet(variableName);
2022 if (variablePath == JavaModelManager.VariableInitializationInProgress)
2023 return null; // break cycle
2025 if (variablePath != null) {
2026 return variablePath;
2029 // even if persisted value exists, initializer is given priority, only
2030 // if no initializer is found the persisted value is reused
2031 // final ClasspathVariableInitializer initializer =
2032 // PHPCore.getClasspathVariableInitializer(variableName);
2033 // if (initializer != null){
2034 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2035 // System.out.println("CPVariable INIT - triggering initialization of: "
2036 // + variableName+ " using initializer: "+ initializer); //$NON-NLS-1$
2038 // new Exception("FAKE exception for dumping current CPVariable
2039 // ("+variableName+ ")INIT invocation stack trace").printStackTrace();
2040 // //$NON-NLS-1$//$NON-NLS-2$
2042 // JavaModelManager.variablePut(variableName,
2043 // JavaModelManager.VariableInitializationInProgress); // avoid
2044 // initialization cycles
2045 // boolean ok = false;
2047 // // wrap initializer call with Safe runnable in case initializer would
2048 // be causing some grief
2049 // Platform.run(new ISafeRunnable() {
2050 // public void handleException(Throwable exception) {
2051 // Util.log(exception, "Exception occurred in classpath variable
2052 // initializer: "+initializer+" while initializing variable:
2053 // "+variableName); //$NON-NLS-1$ //$NON-NLS-2$
2055 // public void run() throws Exception {
2056 // initializer.initialize(variableName);
2059 // variablePath = (IPath) JavaModelManager.variableGet(variableName); //
2060 // initializer should have performed side-effect
2061 // if (variablePath ==
2062 // JavaModelManager.VariableInitializationInProgress) return null; //
2063 // break cycle (initializer did not init or reentering call)
2064 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2065 // System.out.println("CPVariable INIT - after initialization: " +
2066 // variableName + " --> " + variablePath); //$NON-NLS-2$//$NON-NLS-1$
2070 // if (!ok) JavaModelManager.variablePut(variableName, null); // flush
2074 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2075 // System.out.println("CPVariable INIT - no initializer found for: " +
2076 // variableName); //$NON-NLS-1$
2079 return variablePath;
2083 * Helper method finding the classpath variable initializer registered for a
2084 * given classpath variable name or <code>null</code> if none was found
2085 * while iterating over the contributions to extension point to the
2086 * extension point "org.eclipse.jdt.core.classpathVariableInitializer".
2091 * @return ClasspathVariableInitializer - the registered classpath variable
2092 * initializer or <code>null</code> if none was found.
2095 public static ClasspathVariableInitializer getClasspathVariableInitializer(
2098 Plugin jdtCorePlugin = JavaCore.getPlugin();
2099 if (jdtCorePlugin == null)
2102 // IExtensionPoint extension =
2103 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID);
2104 // if (extension != null) {
2105 // IExtension[] extensions = extension.getExtensions();
2106 // for(int i = 0; i < extensions.length; i++){
2107 // IConfigurationElement [] configElements =
2108 // extensions[i].getConfigurationElements();
2109 // for(int j = 0; j < configElements.length; j++){
2111 // String varAttribute = configElements[j].getAttribute("variable");
2113 // if (variable.equals(varAttribute)) {
2114 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
2115 // System.out.println("CPVariable INIT - found initializer: "+variable+"
2117 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
2120 // configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
2121 // if (execExt instanceof ClasspathVariableInitializer){
2122 // return (ClasspathVariableInitializer)execExt;
2125 // } catch(CoreException e){
2134 * Returns the names of all known classpath variables.
2136 * Classpath variable values are persisted locally to the workspace, and are
2137 * preserved from session to session.
2140 * @return the list of classpath variable names
2141 * @see #setClasspathVariable
2143 //public static String[] getClasspathVariableNames() {
2144 // return JavaModelManager.variableNames();
2147 * Returns a table of all known configurable options with their default
2148 * values. These options allow to configure the behaviour of the underlying
2149 * components. The client may safely use the result as a template that they
2150 * can modify and then pass to <code>setOptions</code>.
2152 * Helper constants have been defined on JavaCore for each of the option ID
2153 * and their possible constant values.
2155 * Note: more options might be added in further releases.
2159 * RECOGNIZED OPTIONS:
2160 * COMPILER / Generating Local Variable Debug Attribute
2161 * When generated, this attribute will enable local variable names
2162 * to be displayed in debugger, only in place where variables are
2163 * definitely assigned (.class file is then bigger)
2164 * - option id: "org.eclipse.jdt.core.compiler.debug.localVariable"
2165 * - possible values: { "generate", "do not generate" }
2166 * - default: "generate"
2168 * COMPILER / Generating Line Number Debug Attribute
2169 * When generated, this attribute will enable source code highlighting in debugger
2170 * (.class file is then bigger).
2171 * - option id: "org.eclipse.jdt.core.compiler.debug.lineNumber"
2172 * - possible values: { "generate", "do not generate" }
2173 * - default: "generate"
2175 * COMPILER / Generating Source Debug Attribute
2176 * When generated, this attribute will enable the debugger to present the
2177 * corresponding source code.
2178 * - option id: "org.eclipse.jdt.core.compiler.debug.sourceFile"
2179 * - possible values: { "generate", "do not generate" }
2180 * - default: "generate"
2182 * COMPILER / Preserving Unused Local Variables
2183 * Unless requested to preserve unused local variables (that is, never read), the
2184 * compiler will optimize them out, potentially altering debugging
2185 * - option id: "org.eclipse.jdt.core.compiler.codegen.unusedLocal"
2186 * - possible values: { "preserve", "optimize out" }
2187 * - default: "preserve"
2189 * COMPILER / Defining Target Java Platform
2190 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
2191 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
2192 * - option id: "org.eclipse.jdt.core.compiler.codegen.targetPlatform"
2193 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
2194 * - default: "1.1"
2196 * COMPILER / Reporting Unreachable Code
2197 * Unreachable code can optionally be reported as an error, warning or simply
2198 * ignored. The bytecode generation will always optimized it out.
2199 * - option id: "org.eclipse.jdt.core.compiler.problem.unreachableCode"
2200 * - possible values: { "error", "warning", "ignore" }
2201 * - default: "error"
2203 * COMPILER / Reporting Invalid Import
2204 * An import statement that cannot be resolved might optionally be reported
2205 * as an error, as a warning or ignored.
2206 * - option id: "org.eclipse.jdt.core.compiler.problem.invalidImport"
2207 * - possible values: { "error", "warning", "ignore" }
2208 * - default: "error"
2210 * COMPILER / Reporting Attempt to Override Package-Default Method
2211 * A package default method is not visible in a different package, and thus
2212 * cannot be overridden. When enabling this option, the compiler will signal
2213 * such scenarii either as an error or a warning.
2214 * - option id: "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"
2215 * - possible values: { "error", "warning", "ignore" }
2216 * - default: "warning"
2218 * COMPILER / Reporting Method With Constructor Name
2219 * Naming a method with a constructor name is generally considered poor
2220 * style programming. When enabling this option, the compiler will signal such
2221 * scenarii either as an error or a warning.
2222 * - option id: "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"
2223 * - possible values: { "error", "warning", "ignore" }
2224 * - default: "warning"
2226 * COMPILER / Reporting Deprecation
2227 * When enabled, the compiler will signal use of deprecated API either as an
2228 * error or a warning.
2229 * - option id: "org.eclipse.jdt.core.compiler.problem.deprecation"
2230 * - possible values: { "error", "warning", "ignore" }
2231 * - default: "warning"
2233 * COMPILER / Reporting Deprecation Inside Deprecated Code
2234 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
2235 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.deprecation".
2236 * - option id: "org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode"
2237 * - possible values: { "enabled", "disabled" }
2238 * - default: "disabled"
2240 * COMPILER / Reporting Hidden Catch Block
2241 * Locally to a try statement, some catch blocks may hide others . For example,
2242 * try { throw new java.io.CharConversionException();
2243 * } catch (java.io.CharConversionException e) {
2244 * } catch (java.io.IOException e) {}.
2245 * When enabling this option, the compiler will issue an error or a warning for hidden
2246 * catch blocks corresponding to checked exceptions
2247 * - option id: "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"
2248 * - possible values: { "error", "warning", "ignore" }
2249 * - default: "warning"
2251 * COMPILER / Reporting Unused Local
2252 * When enabled, the compiler will issue an error or a warning for unused local
2253 * variables (that is, variables never read from)
2254 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedLocal"
2255 * - possible values: { "error", "warning", "ignore" }
2256 * - default: "ignore"
2258 * COMPILER / Reporting Unused Parameter
2259 * When enabled, the compiler will issue an error or a warning for unused method
2260 * parameters (that is, parameters never read from)
2261 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameter"
2262 * - possible values: { "error", "warning", "ignore" }
2263 * - default: "ignore"
2265 * COMPILER / Reporting Unused Parameter if Implementing Abstract Method
2266 * When enabled, the compiler will signal unused parameters in abstract method implementations.
2267 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
2268 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"
2269 * - possible values: { "enabled", "disabled" }
2270 * - default: "disabled"
2272 * COMPILER / Reporting Unused Parameter if Overriding Concrete Method
2273 * When enabled, the compiler will signal unused parameters in methods overriding concrete ones.
2274 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
2275 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"
2276 * - possible values: { "enabled", "disabled" }
2277 * - default: "disabled"
2279 * COMPILER / Reporting Unused Import
2280 * When enabled, the compiler will issue an error or a warning for unused import
2282 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedImport"
2283 * - possible values: { "error", "warning", "ignore" }
2284 * - default: "warning"
2286 * COMPILER / Reporting Unused Private Members
2287 * When enabled, the compiler will issue an error or a warning whenever a private
2288 * method or field is declared but never used within the same unit.
2289 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"
2290 * - possible values: { "error", "warning", "ignore" }
2291 * - default: "ignore"
2293 * COMPILER / Reporting Synthetic Access Emulation
2294 * When enabled, the compiler will issue an error or a warning whenever it emulates
2295 * access to a non-accessible member of an enclosing type. Such access can have
2296 * performance implications.
2297 * - option id: "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"
2298 * - possible values: { "error", "warning", "ignore" }
2299 * - default: "ignore"
2301 * COMPILER / Reporting Non-Externalized String Literal
2302 * When enabled, the compiler will issue an error or a warning for non externalized
2303 * String literal (that is, not tagged with //$NON-NLS-<n>$).
2304 * - option id: "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"
2305 * - possible values: { "error", "warning", "ignore" }
2306 * - default: "ignore"
2308 * COMPILER / Reporting Usage of 'assert' Identifier
2309 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
2310 * used as an identifier (reserved keyword in 1.4)
2311 * - option id: "org.eclipse.jdt.core.compiler.problem.assertIdentifier"
2312 * - possible values: { "error", "warning", "ignore" }
2313 * - default: "ignore"
2315 * COMPILER / Reporting Non-Static Reference to a Static Member
2316 * When enabled, the compiler will issue an error or a warning whenever a static field
2317 * or method is accessed with an expression receiver. A reference to a static member should
2318 * be qualified with a type name.
2319 * - option id: "org.eclipse.jdt.core.compiler.problem.staticAccessReceiver"
2320 * - possible values: { "error", "warning", "ignore" }
2321 * - default: "warning"
2323 * COMPILER / Reporting Assignment with no Effect
2324 * When enabled, the compiler will issue an error or a warning whenever an assignment
2325 * has no effect (e.g 'x = x').
2326 * - option id: "org.eclipse.jdt.core.compiler.problem.noEffectAssignment"
2327 * - possible values: { "error", "warning", "ignore" }
2328 * - default: "warning"
2330 * COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods
2331 * When enabled, the compiler will issue an error or a warning whenever an interface
2332 * defines a method incompatible with a non-inherited Object method. Until this conflict
2333 * is resolved, such an interface cannot be implemented, For example,
2337 * - option id: "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"
2338 * - possible values: { "error", "warning", "ignore" }
2339 * - default: "warning"
2341 * COMPILER / Reporting Usage of char[] Expressions in String Concatenations
2342 * When enabled, the compiler will issue an error or a warning whenever a char[] expression
2343 * is used in String concatenations (for example, "hello" + new char[]{'w','o','r','l','d'}).
2344 * - option id: "org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion"
2345 * - possible values: { "error", "warning", "ignore" }
2346 * - default: "warning"
2348 * COMPILER / Setting Source Compatibility Mode
2349 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
2350 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
2351 * level should be set to "1.4" and the compliance mode should be "1.4".
2352 * - option id: "org.eclipse.jdt.core.compiler.source"
2353 * - possible values: { "1.3", "1.4" }
2354 * - default: "1.3"
2356 * COMPILER / Setting Compliance Level
2357 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
2358 * should not go beyond "1.3" level.
2359 * - option id: "org.eclipse.jdt.core.compiler.compliance"
2360 * - possible values: { "1.3", "1.4" }
2361 * - default: "1.3"
2363 * COMPILER / Maximum number of problems reported per compilation unit
2364 * Specify the maximum number of problems reported on each compilation unit.
2365 * - option id: "org.eclipse.jdt.core.compiler.maxProblemPerUnit"
2366 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
2367 * - default: "100"
2369 * COMPILER / Define the Automatic Task Tags
2370 * When the tag list is not empty, the compiler will issue a task marker whenever it encounters
2371 * one of the corresponding tag inside any comment in Java source code.
2372 * Generated task messages will include the tag, and range until the next line separator or comment ending.
2373 * Note that tasks messages are trimmed.
2374 * - option id: "org.eclipse.jdt.core.compiler.taskTags"
2375 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card or leading/trailing spaces
2376 * - default: ""
2378 * COMPILER / Define the Automatic Task Priorities
2379 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
2380 * of the task markers issued by the compiler.
2381 * If the default is specified, the priority of each task marker is "NORMAL".
2382 * - option id: "org.eclipse.jdt.core.compiler.taskPriorities"
2383 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
2384 * - default: ""
2386 * BUILDER / Specifying Filters for Resource Copying Control
2387 * Allow to specify some filters to control the resource copy process.
2388 * - option id: "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
2389 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
2390 * or the name of a folder which ends with '/'
2391 * - default: ""
2393 * BUILDER / Abort if Invalid Classpath
2394 * Allow to toggle the builder to abort if the classpath is invalid
2395 * - option id: "org.eclipse.jdt.core.builder.invalidClasspath"
2396 * - possible values: { "abort", "ignore" }
2397 * - default: "abort"
2399 * BUILDER / Cleaning Output Folder(s)
2400 * Indicate whether the JavaBuilder is allowed to clean the output folders
2401 * when performing full build operations.
2402 * - option id: "org.eclipse.jdt.core.builder.cleanOutputFolder"
2403 * - possible values: { "clean", "ignore" }
2404 * - default: "clean"
2406 * BUILDER / Reporting Duplicate Resources
2407 * Indicate the severity of the problem reported when more than one occurrence
2408 * of a resource is to be copied into the output location.
2409 * - option id: "org.eclipse.jdt.core.builder.duplicateResourceTask"
2410 * - possible values: { "error", "warning" }
2411 * - default: "warning"
2413 * JAVACORE / Computing Project Build Order
2414 * Indicate whether JavaCore should enforce the project build order to be based on
2415 * the classpath prerequisite chain. When requesting to compute, this takes over
2416 * the platform default order (based on project references).
2417 * - option id: "org.eclipse.jdt.core.computeJavaBuildOrder"
2418 * - possible values: { "compute", "ignore" }
2419 * - default: "ignore"
2421 * JAVACORE / Specify Default Source Encoding Format
2422 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
2423 * to 'ResourcesPlugin.getEncoding()'.
2424 * - option id: "org.eclipse.jdt.core.encoding"
2425 * - possible values: { any of the supported encoding name}.
2426 * - default: <platform default>
2428 * JAVACORE / Reporting Incomplete Classpath
2429 * Indicate the severity of the problem reported when an entry on the classpath does not exist,
2430 * is not legite or is not visible (for example, a referenced project is closed).
2431 * - option id: "org.eclipse.jdt.core.incompleteClasspath"
2432 * - possible values: { "error", "warning"}
2433 * - default: "error"
2435 * JAVACORE / Reporting Classpath Cycle
2436 * Indicate the severity of the problem reported when a project is involved in a cycle.
2437 * - option id: "org.eclipse.jdt.core.circularClasspath"
2438 * - possible values: { "error", "warning" }
2439 * - default: "error"
2441 * JAVACORE / Enabling Usage of Classpath Exclusion Patterns
2442 * When disabled, no entry on a project classpath can be associated with
2443 * an exclusion pattern.
2444 * - option id: "org.eclipse.jdt.core.classpath.exclusionPatterns"
2445 * - possible values: { "enabled", "disabled" }
2446 * - default: "enabled"
2448 * JAVACORE / Enabling Usage of Classpath Multiple Output Locations
2449 * When disabled, no entry on a project classpath can be associated with
2450 * a specific output location, preventing thus usage of multiple output locations.
2451 * - option id: "org.eclipse.jdt.core.classpath.multipleOutputLocations"
2452 * - possible values: { "enabled", "disabled" }
2453 * - default: "enabled"
2455 * FORMATTER / Inserting New Line Before Opening Brace
2456 * When Insert, a new line is inserted before an opening brace, otherwise nothing
2458 * - option id: "org.eclipse.jdt.core.formatter.newline.openingBrace"
2459 * - possible values: { "insert", "do not insert" }
2460 * - default: "do not insert"
2462 * FORMATTER / Inserting New Line Inside Control Statement
2463 * When Insert, a new line is inserted between } and following else, catch, finally
2464 * - option id: "org.eclipse.jdt.core.formatter.newline.controlStatement"
2465 * - possible values: { "insert", "do not insert" }
2466 * - default: "do not insert"
2468 * FORMATTER / Clearing Blank Lines
2469 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
2470 * and all others removed.
2471 * - option id: "org.eclipse.jdt.core.formatter.newline.clearAll"
2472 * - possible values: { "clear all", "preserve one" }
2473 * - default: "preserve one"
2475 * FORMATTER / Inserting New Line Between Else/If
2476 * When Insert, a blank line is inserted between an else and an if when they are
2477 * contiguous. When choosing to not insert, else-if will be kept on the same
2478 * line when possible.
2479 * - option id: "org.eclipse.jdt.core.formatter.newline.elseIf"
2480 * - possible values: { "insert", "do not insert" }
2481 * - default: "do not insert"
2483 * FORMATTER / Inserting New Line In Empty Block
2484 * When insert, a line break is inserted between contiguous { and }, if } is not followed
2486 * - option id: "org.eclipse.jdt.core.formatter.newline.emptyBlock"
2487 * - possible values: { "insert", "do not insert" }
2488 * - default: "insert"
2490 * FORMATTER / Splitting Lines Exceeding Length
2491 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
2492 * disable line splitting
2493 * - option id: "org.eclipse.jdt.core.formatter.lineSplit"
2494 * - possible values: "<n>", where n is zero or a positive integer
2495 * - default: "80"
2497 * FORMATTER / Compacting Assignment
2498 * Assignments can be formatted asymmetrically, for example 'int x= 2;', when Normal, a space
2499 * is inserted before the assignment operator
2500 * - option id: "org.eclipse.jdt.core.formatter.style.assignment"
2501 * - possible values: { "compact", "normal" }
2502 * - default: "normal"
2504 * FORMATTER / Defining Indentation Character
2505 * Either choose to indent with tab characters or spaces
2506 * - option id: "org.eclipse.jdt.core.formatter.tabulation.char"
2507 * - possible values: { "tab", "space" }
2508 * - default: "tab"
2510 * FORMATTER / Defining Space Indentation Length
2511 * When using spaces, set the amount of space characters to use for each
2513 * - option id: "org.eclipse.jdt.core.formatter.tabulation.size"
2514 * - possible values: "<n>", where n is a positive integer
2515 * - default: "4"
2517 * FORMATTER / Inserting space in cast expression
2518 * When Insert, a space is added between the type and the expression in a cast expression.
2519 * - option id: "org.eclipse.jdt.core.formatter.space.castexpression"
2520 * - possible values: { "insert", "do not insert" }
2521 * - default: "insert"
2523 * CODEASSIST / Activate Visibility Sensitive Completion
2524 * When active, completion doesn't show that you can not see
2525 * (for example, you can not see private methods of a super class).
2526 * - option id: "org.eclipse.jdt.core.codeComplete.visibilityCheck"
2527 * - possible values: { "enabled", "disabled" }
2528 * - default: "disabled"
2530 * CODEASSIST / Automatic Qualification of Implicit Members
2531 * When active, completion automatically qualifies completion on implicit
2532 * field references and message expressions.
2533 * - option id: "org.eclipse.jdt.core.codeComplete.forceImplicitQualification"
2534 * - possible values: { "enabled", "disabled" }
2535 * - default: "disabled"
2537 * CODEASSIST / Define the Prefixes for Field Name
2538 * When the prefixes is non empty, completion for field name will begin with
2539 * one of the proposed prefixes.
2540 * - option id: "org.eclipse.jdt.core.codeComplete.fieldPrefixes"
2541 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2542 * - default: ""
2544 * CODEASSIST / Define the Prefixes for Static Field Name
2545 * When the prefixes is non empty, completion for static field name will begin with
2546 * one of the proposed prefixes.
2547 * - option id: "org.eclipse.jdt.core.codeComplete.staticFieldPrefixes"
2548 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2549 * - default: ""
2551 * CODEASSIST / Define the Prefixes for Local Variable Name
2552 * When the prefixes is non empty, completion for local variable name will begin with
2553 * one of the proposed prefixes.
2554 * - option id: "org.eclipse.jdt.core.codeComplete.localPrefixes"
2555 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2556 * - default: ""
2558 * CODEASSIST / Define the Prefixes for Argument Name
2559 * When the prefixes is non empty, completion for argument name will begin with
2560 * one of the proposed prefixes.
2561 * - option id: "org.eclipse.jdt.core.codeComplete.argumentPrefixes"
2562 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2563 * - default: ""
2565 * CODEASSIST / Define the Suffixes for Field Name
2566 * When the suffixes is non empty, completion for field name will end with
2567 * one of the proposed suffixes.
2568 * - option id: "org.eclipse.jdt.core.codeComplete.fieldSuffixes"
2569 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2570 * - default: ""
2572 * CODEASSIST / Define the Suffixes for Static Field Name
2573 * When the suffixes is non empty, completion for static field name will end with
2574 * one of the proposed suffixes.
2575 * - option id: "org.eclipse.jdt.core.codeComplete.staticFieldSuffixes"
2576 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2577 * - default: ""
2579 * CODEASSIST / Define the Suffixes for Local Variable Name
2580 * When the suffixes is non empty, completion for local variable name will end with
2581 * one of the proposed suffixes.
2582 * - option id: "org.eclipse.jdt.core.codeComplete.localSuffixes"
2583 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2584 * - default: ""
2586 * CODEASSIST / Define the Suffixes for Argument Name
2587 * When the suffixes is non empty, completion for argument name will end with
2588 * one of the proposed suffixes.
2589 * - option id: "org.eclipse.jdt.core.codeComplete.argumentSuffixes"
2590 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
2591 * - default: ""
2594 * @return a mutable table containing the default settings of all known options
2607 public static Hashtable getDefaultOptions() {
2609 Hashtable defaultOptions = new Hashtable(10);
2611 // see #initializeDefaultPluginPreferences() for changing default
2613 Preferences preferences = getPlugin().getPluginPreferences();
2614 HashSet optionNames = JavaModelManager.OptionNames;
2616 // get preferences set to their default
2617 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2618 for (int i = 0; i < defaultPropertyNames.length; i++) {
2619 String propertyName = defaultPropertyNames[i];
2620 if (optionNames.contains(propertyName)) {
2621 defaultOptions.put(propertyName, preferences
2622 .getDefaultString(propertyName));
2625 // get preferences not set to their default
2626 String[] propertyNames = preferences.propertyNames();
2627 for (int i = 0; i < propertyNames.length; i++) {
2628 String propertyName = propertyNames[i];
2629 if (optionNames.contains(propertyName)) {
2630 defaultOptions.put(propertyName, preferences
2631 .getDefaultString(propertyName));
2634 // get encoding through resource plugin
2635 defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2637 return defaultOptions;
2641 * Returns the single instance of the Java core plug-in runtime class.
2642 * Equivalent to <code>(JavaCore) getPlugin()</code>.
2644 * @return the single instance of the Java core plug-in runtime class
2646 public static PHPeclipsePlugin getJavaCore() {
2647 return (PHPeclipsePlugin) getPlugin();
2651 * Helper method for returning one option value only. Equivalent to
2652 * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
2653 * may answer <code>null</code> if this option does not exist.
2655 * For a complete description of the configurable options, see
2656 * <code>getDefaultOptions</code>.
2660 * the name of an option
2661 * @return the String value of a given option
2662 * @see JavaCore#getDefaultOptions
2665 public static String getOption(String optionName) {
2667 if (CORE_ENCODING.equals(optionName)) {
2668 return ResourcesPlugin.getEncoding();
2670 if (JavaModelManager.OptionNames.contains(optionName)) {
2671 Preferences preferences = getPlugin().getPluginPreferences();
2672 return preferences.getString(optionName).trim();
2678 * Returns the table of the current options. Initially, all options have
2679 * their default values, and this method returns a table that includes all
2682 * For a complete description of the configurable options, see
2683 * <code>getDefaultOptions</code>.
2686 * @return table of current settings of all options (key type:
2687 * <code>String</code>; value type: <code>String</code>)
2688 * @see JavaCore#getDefaultOptions
2690 public static Hashtable getOptions() {
2692 Hashtable options = new Hashtable(10);
2694 // see #initializeDefaultPluginPreferences() for changing default
2696 Plugin plugin = getPlugin();
2697 if (plugin != null) {
2698 Preferences preferences = getPlugin().getPluginPreferences();
2699 HashSet optionNames = JavaModelManager.OptionNames;
2701 // get preferences set to their default
2702 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2703 for (int i = 0; i < defaultPropertyNames.length; i++) {
2704 String propertyName = defaultPropertyNames[i];
2705 if (optionNames.contains(propertyName)) {
2706 options.put(propertyName, preferences
2707 .getDefaultString(propertyName));
2710 // get preferences not set to their default
2711 String[] propertyNames = preferences.propertyNames();
2712 for (int i = 0; i < propertyNames.length; i++) {
2713 String propertyName = propertyNames[i];
2714 if (optionNames.contains(propertyName)) {
2715 options.put(propertyName, preferences.getString(
2716 propertyName).trim());
2719 // get encoding through resource plugin
2720 options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2726 * This is a helper method, which returns the resolved classpath entry
2727 * denoted by a given entry (if it is a variable entry). It is obtained by
2728 * resolving the variable reference in the first segment. Returns <node>null
2729 * </code> if unable to resolve using the following algorithm:
2731 * <li>if variable segment cannot be resolved, returns <code>null</code>
2733 * <li>finds a project, JAR or binary folder in the workspace at the
2734 * resolved path location</li>
2735 * <li>if none finds an external JAR file or folder outside the workspace
2736 * at the resolved path location</li>
2737 * <li>if none returns <code>null</code></li>
2740 * Variable source attachment path and root path are also resolved and
2741 * recorded in the resulting classpath entry.
2743 * NOTE: This helper method does not handle classpath containers, for which
2744 * should rather be used <code>JavaCore#getClasspathContainer(IPath,
2745 * IJavaProject)</code>.
2749 * the given variable entry
2750 * @return the resolved library or project classpath entry, or <code>null
2751 * </code> if the given variable entry could not be resolved to a
2752 * valid classpath entry
2754 public static IClasspathEntry getResolvedClasspathEntry(
2755 IClasspathEntry entry) {
2757 if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
2760 IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
2761 IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath());
2762 if (resolvedPath == null)
2765 Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false);
2769 // inside the workspace
2770 if (target instanceof IResource) {
2771 IResource resolvedResource = (IResource) target;
2772 if (resolvedResource != null) {
2773 switch (resolvedResource.getType()) {
2775 case IResource.PROJECT:
2777 return JavaCore.newProjectEntry(resolvedPath, entry
2780 case IResource.FILE:
2781 // if (Util.isArchiveFileName(resolvedResource.getName())) {
2782 // // internal binary archive
2783 // return JavaCore.newLibraryEntry(
2785 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2786 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2787 // entry.isExported());
2791 case IResource.FOLDER:
2792 // internal binary folder
2793 // return JavaCore.newLibraryEntry(
2795 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2796 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2797 // entry.isExported());
2802 // outside the workspace
2803 if (target instanceof File) {
2804 File externalFile = (File) target;
2805 if (externalFile.isFile()) {
2806 String fileName = externalFile.getName().toLowerCase();
2807 // if (fileName.endsWith(".jar" //$NON-NLS-1$
2808 // ) || fileName.endsWith(".zip" //$NON-NLS-1$
2809 // )) { // external binary archive
2810 // return JavaCore.newLibraryEntry(
2812 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2813 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2814 // entry.isExported());
2816 } else { // external binary folder
2817 if (resolvedPath.isAbsolute()) {
2818 // return JavaCore.newLibraryEntry(
2820 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2821 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2822 // entry.isExported());
2830 * Resolve a variable path (helper method).
2832 * @param variablePath
2833 * the given variable path
2834 * @return the resolved variable path or <code>null</code> if none
2836 public static IPath getResolvedVariablePath(IPath variablePath) {
2838 if (variablePath == null)
2840 int count = variablePath.segmentCount();
2845 String variableName = variablePath.segment(0);
2846 IPath resolvedPath = JavaCore.getClasspathVariable(variableName);
2847 if (resolvedPath == null)
2850 // append path suffix
2852 resolvedPath = resolvedPath.append(variablePath
2853 .removeFirstSegments(1));
2855 return resolvedPath;
2859 * Answers the shared working copies currently registered for this buffer
2860 * factory. Working copies can be shared by several clients using the same
2861 * buffer factory,see <code>IWorkingCopy.getSharedWorkingCopy</code>.
2864 * the given buffer factory
2865 * @return the list of shared working copies for a given buffer factory
2869 public static IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory) {
2871 // if factory is null, default factory must be used
2872 if (factory == null)
2873 factory = BufferManager.getDefaultBufferManager()
2874 .getDefaultBufferFactory();
2875 Map sharedWorkingCopies = JavaModelManager.getJavaModelManager().sharedWorkingCopies;
2877 Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
2878 if (perFactoryWorkingCopies == null)
2879 return JavaModelManager.NoWorkingCopy;
2880 Collection copies = perFactoryWorkingCopies.values();
2881 IWorkingCopy[] result = new IWorkingCopy[copies.size()];
2882 copies.toArray(result);
2887 * Initializes the default preferences settings for this plug-in.
2889 public static void initializeDefaultPluginPreferences() {
2891 Preferences preferences = PHPeclipsePlugin.getDefault()
2892 .getPluginPreferences();
2893 HashSet optionNames = JavaModelManager.OptionNames;
2895 // Compiler settings
2896 preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
2897 optionNames.add(COMPILER_LOCAL_VARIABLE_ATTR);
2899 preferences.setDefault(COMPILER_LINE_NUMBER_ATTR, GENERATE);
2900 optionNames.add(COMPILER_LINE_NUMBER_ATTR);
2902 preferences.setDefault(COMPILER_SOURCE_FILE_ATTR, GENERATE);
2903 optionNames.add(COMPILER_SOURCE_FILE_ATTR);
2905 preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE);
2906 optionNames.add(COMPILER_CODEGEN_UNUSED_LOCAL);
2908 preferences.setDefault(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1);
2909 optionNames.add(COMPILER_CODEGEN_TARGET_PLATFORM);
2911 preferences.setDefault(COMPILER_PB_PHP_VAR_DEPRECATED, WARNING);
2912 optionNames.add(COMPILER_PB_PHP_VAR_DEPRECATED);
2913 preferences.setDefault(COMPILER_PB_PHP_KEYWORD, WARNING);
2914 optionNames.add(COMPILER_PB_PHP_KEYWORD);
2915 preferences.setDefault(COMPILER_PB_PHP_UPPERCASE_IDENTIFIER, IGNORE);
2916 optionNames.add(COMPILER_PB_PHP_UPPERCASE_IDENTIFIER);
2918 preferences.setDefault(COMPILER_PB_UNREACHABLE_CODE, ERROR);
2919 optionNames.add(COMPILER_PB_UNREACHABLE_CODE);
2921 preferences.setDefault(COMPILER_PB_INVALID_IMPORT, ERROR);
2922 optionNames.add(COMPILER_PB_INVALID_IMPORT);
2924 preferences.setDefault(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD,
2926 optionNames.add(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD);
2928 preferences.setDefault(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME,
2930 optionNames.add(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME);
2932 preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING);
2933 optionNames.add(COMPILER_PB_DEPRECATION);
2935 preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE,
2937 optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE);
2939 preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING);
2940 optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK);
2942 preferences.setDefault(COMPILER_PB_UNUSED_LOCAL, IGNORE);
2943 optionNames.add(COMPILER_PB_UNUSED_LOCAL);
2945 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE);
2946 optionNames.add(COMPILER_PB_UNUSED_PARAMETER);
2948 preferences.setDefault(
2949 COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT,
2952 .add(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT);
2956 COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE,
2958 optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE);
2960 preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING);
2961 optionNames.add(COMPILER_PB_UNUSED_IMPORT);
2963 preferences.setDefault(COMPILER_PB_UNUSED_PRIVATE_MEMBER, IGNORE);
2964 optionNames.add(COMPILER_PB_UNUSED_PRIVATE_MEMBER);
2966 preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE);
2967 optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION);
2969 preferences.setDefault(COMPILER_PB_NON_NLS_STRING_LITERAL, IGNORE);
2970 optionNames.add(COMPILER_PB_NON_NLS_STRING_LITERAL);
2972 preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE);
2973 optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER);
2975 preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING);
2976 optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER);
2978 preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING);
2979 optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT);
2981 preferences.setDefault(
2982 COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD,
2985 .add(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD);
2987 preferences.setDefault(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION,
2989 optionNames.add(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION);
2991 preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAG); //$NON-NLS-1$
2992 optionNames.add(COMPILER_TASK_TAGS);
2994 preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITY); //$NON-NLS-1$
2995 optionNames.add(COMPILER_TASK_PRIORITIES);
2997 preferences.setDefault(COMPILER_SOURCE, VERSION_1_3);
2998 optionNames.add(COMPILER_SOURCE);
3000 preferences.setDefault(COMPILER_COMPLIANCE, VERSION_1_3);
3001 optionNames.add(COMPILER_COMPLIANCE);
3003 preferences.setDefault(COMPILER_PB_MAX_PER_UNIT, "100"); //$NON-NLS-1$
3004 optionNames.add(COMPILER_PB_MAX_PER_UNIT);
3007 preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
3008 optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
3010 preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT);
3011 optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH);
3013 preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING);
3014 optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE);
3016 preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN);
3017 optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER);
3019 // JavaCore settings
3020 preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE);
3021 optionNames.add(CORE_JAVA_BUILD_ORDER);
3023 preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR);
3024 optionNames.add(CORE_CIRCULAR_CLASSPATH);
3026 preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR);
3027 optionNames.add(CORE_INCOMPLETE_CLASSPATH);
3029 preferences.setDefault(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS,
3031 optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS);
3033 preferences.setDefault(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS,
3035 optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS);
3037 // encoding setting comes from resource plug-in
3038 optionNames.add(CORE_ENCODING);
3040 // Formatter settings
3041 preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT);
3042 optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE);
3044 preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT);
3045 optionNames.add(FORMATTER_NEWLINE_CONTROL);
3047 preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE);
3048 optionNames.add(FORMATTER_CLEAR_BLANK_LINES);
3050 preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT);
3051 optionNames.add(FORMATTER_NEWLINE_ELSE_IF);
3053 preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT);
3054 optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK);
3056 preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$
3057 optionNames.add(FORMATTER_LINE_SPLIT);
3059 preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL);
3060 optionNames.add(FORMATTER_COMPACT_ASSIGNMENT);
3062 preferences.setDefault(FORMATTER_TAB_CHAR, TAB);
3063 optionNames.add(FORMATTER_TAB_CHAR);
3065 preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$
3066 optionNames.add(FORMATTER_TAB_SIZE);
3068 preferences.setDefault(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$
3069 optionNames.add(FORMATTER_SPACE_CASTEXPRESSION);
3071 // CodeAssist settings
3072 preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$
3073 optionNames.add(CODEASSIST_VISIBILITY_CHECK);
3075 preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$
3076 optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION);
3078 preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
3079 optionNames.add(CODEASSIST_FIELD_PREFIXES);
3081 preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
3082 optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES);
3084 preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
3085 optionNames.add(CODEASSIST_LOCAL_PREFIXES);
3087 preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
3088 optionNames.add(CODEASSIST_ARGUMENT_PREFIXES);
3090 preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3091 optionNames.add(CODEASSIST_FIELD_SUFFIXES);
3093 preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3094 optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES);
3096 preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
3097 optionNames.add(CODEASSIST_LOCAL_SUFFIXES);
3099 preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
3100 optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES);
3104 * Returns whether the given marker references the given Java element. Used
3105 * for markers, which denote a Java element rather than a resource.
3111 * @return <code>true</code> if the marker references the element, false
3113 * @exception CoreException
3114 * if the <code>IMarker.getAttribute</code> on the marker
3117 public static boolean isReferencedBy(IJavaElement element, IMarker marker)
3118 throws CoreException {
3120 // only match units or classfiles
3121 if (element instanceof IMember) {
3122 IMember member = (IMember) element;
3123 if (member.isBinary()) {
3124 element = null; //member.getClassFile();
3126 element = member.getCompilationUnit();
3129 if (element == null)
3134 String markerHandleId = (String) marker.getAttribute(ATT_HANDLE_ID);
3135 if (markerHandleId == null)
3138 IJavaElement markerElement = JavaCore.create(markerHandleId);
3140 if (element.equals(markerElement))
3141 return true; // external elements may still be equal with different
3144 // cycle through enclosing types in case marker is associated with a
3145 // classfile (15568)
3146 // if (markerElement instanceof IClassFile){
3147 // IType enclosingType =
3148 // ((IClassFile)markerElement).getType().getDeclaringType();
3149 // if (enclosingType != null){
3150 // markerElement = enclosingType.getClassFile(); // retry with immediate
3151 // enclosing classfile
3161 * Returns whether the given marker delta references the given Java element.
3162 * Used for markers deltas, which denote a Java element rather than a
3167 * @param markerDelta
3169 * @return <code>true</code> if the marker delta references the element
3170 * @exception CoreException
3171 * if the <code>IMarkerDelta.getAttribute</code> on the
3172 * marker delta fails
3174 public static boolean isReferencedBy(IJavaElement element,
3175 IMarkerDelta markerDelta) throws CoreException {
3177 // only match units or classfiles
3178 if (element instanceof IMember) {
3179 IMember member = (IMember) element;
3180 if (member.isBinary()) {
3181 element = null; //member.getClassFile();
3183 element = member.getCompilationUnit();
3186 if (element == null)
3188 if (markerDelta == null)
3191 String markerDeltarHandleId = (String) markerDelta
3192 .getAttribute(ATT_HANDLE_ID);
3193 if (markerDeltarHandleId == null)
3196 IJavaElement markerElement = JavaCore.create(markerDeltarHandleId);
3198 if (element.equals(markerElement))
3199 return true; // external elements may still be equal with different
3202 // cycle through enclosing types in case marker is associated with a
3203 // classfile (15568)
3204 // if (markerElement instanceof IClassFile){
3205 // IType enclosingType =
3206 // ((IClassFile)markerElement).getType().getDeclaringType();
3207 // if (enclosingType != null){
3208 // markerElement = enclosingType.getClassFile(); // retry with immediate
3209 // enclosing classfile
3219 * Creates and returns a new classpath entry of kind
3220 * <code>CPE_CONTAINER</code> for the given path. The path of the
3221 * container will be used during resolution so as to map this container
3222 * entry to a set of other classpath entries the container is acting for.
3224 * A container entry allows to express indirect references to a set of
3225 * libraries, projects and variable entries, which can be interpreted
3226 * differently for each Java project where it is used. A classpath container
3227 * entry can be resolved using
3228 * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3229 * <code>JavaCore.classpathContainerChanged</code>
3231 * A container is exclusively resolved by a
3232 * <code>ClasspathContainerInitializer</code> registered onto the
3233 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3235 * A container path must be formed of at least one segment, where:
3237 * <li>the first segment is a unique ID identifying the target container,
3238 * there must be a container initializer registered onto this ID through the
3239 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3241 * <li>the remaining segments will be passed onto the initializer, and can
3242 * be used as additional hints during the initialization phase.</li>
3245 * Example of an ClasspathContainerInitializer for a classpath container
3246 * denoting a default JDK container:
3248 * containerEntry = JavaCore.newContainerEntry(new
3249 * Path("MyProvidedJDK/default"));
3251 * <extension point="org.eclipse.jdt.core.classpathContainerInitializer">
3252 * <containerInitializer id="MyProvidedJDK"
3253 * class="com.example.MyInitializer"/>
3255 * Note that this operation does not attempt to validate classpath
3256 * containers or access the resources at the given paths.
3258 * The resulting entry is not exported to dependent projects. This method is
3259 * equivalent to <code>newContainerEntry(-,false)</code>.
3262 * @param containerPath
3263 * the path identifying the container, it must be formed of two
3265 * @return a new container classpath entry
3267 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3268 * @see JavaCore#newContainerEntry(IPath, boolean)
3271 public static IClasspathEntry newContainerEntry(IPath containerPath) {
3273 return newContainerEntry(containerPath, false);
3277 * Creates and returns a new classpath entry of kind
3278 * <code>CPE_CONTAINER</code> for the given path. The path of the
3279 * container will be used during resolution so as to map this container
3280 * entry to a set of other classpath entries the container is acting for.
3282 * A container entry allows to express indirect references to a set of
3283 * libraries, projects and variable entries, which can be interpreted
3284 * differently for each Java project where it is used. A classpath container
3285 * entry can be resolved using
3286 * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3287 * <code>JavaCore.classpathContainerChanged</code>
3289 * A container is exclusively resolved by a
3290 * <code>ClasspathContainerInitializer</code> registered onto the
3291 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3293 * A container path must be formed of at least one segment, where:
3295 * <li>the first segment is a unique ID identifying the target container,
3296 * there must be a container initializer registered onto this ID through the
3297 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3299 * <li>the remaining segments will be passed onto the initializer, and can
3300 * be used as additional hints during the initialization phase.</li>
3303 * Example of an ClasspathContainerInitializer for a classpath container
3304 * denoting a default JDK container:
3306 * containerEntry = JavaCore.newContainerEntry(new
3307 * Path("MyProvidedJDK/default"));
3309 * <extension point="org.eclipse.jdt.core.classpathContainerInitializer">
3310 * <containerInitializer id="MyProvidedJDK"
3311 * class="com.example.MyInitializer"/>
3313 * Note that this operation does not attempt to validate classpath
3314 * containers or access the resources at the given paths.
3317 * @param containerPath
3318 * the path identifying the container, it must be formed of at
3319 * least one segment (ID+hints)
3321 * a boolean indicating whether this entry is contributed to
3322 * dependent projects in addition to the output location
3323 * @return a new container classpath entry
3325 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3326 * @see JavaCore#setClasspathContainer(IPath, IJavaProject[],
3327 * IClasspathContainer[], IProgressMonitor)
3328 * @see JavaCore#newContainerEntry(IPath, boolean)
3331 public static IClasspathEntry newContainerEntry(IPath containerPath,
3332 boolean isExported) {
3334 if (containerPath == null || containerPath.segmentCount() < 1) {
3338 "Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$
3340 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3341 IClasspathEntry.CPE_CONTAINER, containerPath,
3342 ClasspathEntry.NO_EXCLUSION_PATTERNS, null, // source attachment
3343 null, // source attachment root
3344 null, // specific output folder
3349 * Creates and returns a new non-exported classpath entry of kind
3350 * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3351 * absolute path. This specifies that all package fragments within the root
3352 * will have children of type <code>IClassFile</code>.
3354 * A library entry is used to denote a prerequisite JAR or root folder
3355 * containing binaries. The target JAR or folder can either be defined
3356 * internally to the workspace (absolute path relative to the workspace
3357 * root) or externally to the workspace (absolute path in the file system).
3359 * e.g. Here are some examples of binary path usage
3361 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3363 * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3365 * <li><code> "c:/classes/" </code>- reference to an external binary
3368 * Note that this operation does not attempt to validate or access the
3369 * resources at the given paths.
3371 * The resulting entry is not exported to dependent projects. This method is
3372 * equivalent to <code>newLibraryEntry(-,-,-,false)</code>.
3376 * the absolute path of the binary archive
3377 * @param sourceAttachmentPath
3378 * the absolute path of the corresponding source archive or
3379 * folder, or <code>null</code> if none
3380 * @param sourceAttachmentRootPath
3381 * the location of the root within the source archive or folder
3382 * or <code>null</code> if this location should be
3383 * automatically detected.
3384 * @return a new library classpath entry
3386 * @see #newLibraryEntry(IPath, IPath, IPath, boolean)
3388 //public static IClasspathEntry newLibraryEntry(
3390 // IPath sourceAttachmentPath,
3391 // IPath sourceAttachmentRootPath) {
3393 // return newLibraryEntry(path, sourceAttachmentPath,
3394 // sourceAttachmentRootPath, false);
3397 * Creates and returns a new classpath entry of kind
3398 * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3399 * absolute path. This specifies that all package fragments within the root
3400 * will have children of type <code>IClassFile</code>.
3402 * A library entry is used to denote a prerequisite JAR or root folder
3403 * containing binaries. The target JAR or folder can either be defined
3404 * internally to the workspace (absolute path relative to the workspace
3405 * root) or externally to the workspace (absolute path in the file system).
3407 * e.g. Here are some examples of binary path usage
3409 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3411 * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3413 * <li><code> "c:/classes/" </code>- reference to an external binary
3416 * Note that this operation does not attempt to validate or access the
3417 * resources at the given paths.
3421 * the absolute path of the binary archive
3422 * @param sourceAttachmentPath
3423 * the absolute path of the corresponding source archive or
3424 * folder, or <code>null</code> if none
3425 * @param sourceAttachmentRootPath
3426 * the location of the root within the source archive or folder
3427 * or <code>null</code> if this location should be
3428 * automatically detected.
3430 * indicates whether this entry is contributed to dependent
3431 * projects in addition to the output location
3432 * @return a new library classpath entry
3435 //public static IClasspathEntry newLibraryEntry(
3437 // IPath sourceAttachmentPath,
3438 // IPath sourceAttachmentRootPath,
3439 // boolean isExported) {
3441 // if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry
3442 // must be absolute"); //$NON-NLS-1$
3444 // return new ClasspathEntry(
3445 // IPackageFragmentRoot.K_BINARY,
3446 // IClasspathEntry.CPE_LIBRARY,
3447 // JavaProject.canonicalizedPath(path),
3448 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3449 // sourceAttachmentPath,
3450 // sourceAttachmentRootPath,
3451 // null, // specific output folder
3455 * Creates and returns a new non-exported classpath entry of kind
3456 * <code>CPE_PROJECT</code> for the project identified by the given
3459 * A project entry is used to denote a prerequisite project on a classpath.
3460 * The referenced project will be contributed as a whole, either as sources
3461 * (in the Java Model, it contributes all its package fragment roots) or as
3462 * binaries (when building, it contributes its whole output location).
3464 * A project reference allows to indirect through another project,
3465 * independently from its internal layout.
3467 * The prerequisite project is referred to using an absolute path relative
3468 * to the workspace root.
3470 * The resulting entry is not exported to dependent projects. This method is
3471 * equivalent to <code>newProjectEntry(_,false)</code>.
3475 * the absolute path of the binary archive
3476 * @return a new project classpath entry
3478 * @see JavaCore#newProjectEntry(IPath, boolean)
3480 public static IClasspathEntry newProjectEntry(IPath path) {
3481 return newProjectEntry(path, false);
3485 * Creates and returns a new classpath entry of kind
3486 * <code>CPE_PROJECT</code> for the project identified by the given
3489 * A project entry is used to denote a prerequisite project on a classpath.
3490 * The referenced project will be contributed as a whole, either as sources
3491 * (in the Java Model, it contributes all its package fragment roots) or as
3492 * binaries (when building, it contributes its whole output location).
3494 * A project reference allows to indirect through another project,
3495 * independently from its internal layout.
3497 * The prerequisite project is referred to using an absolute path relative
3498 * to the workspace root.
3502 * the absolute path of the prerequisite project
3504 * indicates whether this entry is contributed to dependent
3505 * projects in addition to the output location
3506 * @return a new project classpath entry
3509 public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) {
3511 if (!path.isAbsolute())
3512 Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3514 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3515 IClasspathEntry.CPE_PROJECT, path,
3516 ClasspathEntry.NO_EXCLUSION_PATTERNS, null, // source attachment
3517 null, // source attachment root
3518 null, // specific output folder
3523 * Returns a new empty region.
3525 * @return a new empty region
3527 public static IRegion newRegion() {
3528 return new Region();
3532 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3533 * for the project's source folder identified by the given absolute
3534 * workspace-relative path. This specifies that all package fragments within
3535 * the root will have children of type <code>ICompilationUnit</code>.
3537 * The source folder is referred to using an absolute path relative to the
3538 * workspace root, e.g. <code>/Project/src</code>. A project's source
3539 * folders are located with that project. That is, a source classpath entry
3540 * specifying the path <code>/P1/src</code> is only usable for project
3544 * The source classpath entry created by this method includes all source
3545 * files below the given workspace-relative path. To selectively exclude
3546 * some of these source files, use the factory method
3547 * <code>JavaCore.newSourceEntry(IPath,IPath[])</code> instead.
3550 * Note that all sources/binaries inside a project are contributed as a
3551 * whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
3552 * Particular source entries cannot be selectively exported.
3556 * the absolute workspace-relative path of a source folder
3557 * @return a new source classpath entry with not exclusion patterns
3559 * @see #newSourceEntry(org.eclipse.core.runtime.IPath,org.eclipse.core.runtime.IPath[])
3561 public static IClasspathEntry newSourceEntry(IPath path) {
3563 return newSourceEntry(path, ClasspathEntry.NO_EXCLUSION_PATTERNS, null /*
3570 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3571 * for the project's source folder identified by the given absolute
3572 * workspace-relative path but excluding all source files with paths
3573 * matching any of the given patterns. This specifies that all package
3574 * fragments within the root will have children of type
3575 * <code>ICompilationUnit</code>.
3577 * The source folder is referred to using an absolute path relative to the
3578 * workspace root, e.g. <code>/Project/src</code>. A project's source
3579 * folders are located with that project. That is, a source classpath entry
3580 * specifying the path <code>/P1/src</code> is only usable for project
3584 * The source classpath entry created by this method includes all source
3585 * files below the given workspace-relative path except for those matched by
3586 * one (or more) of the given exclusion patterns. Each exclusion pattern is
3587 * represented by a relative path, which is interpreted as relative to the
3588 * source folder. For example, if the source folder path is
3589 * <code>/Project/src</code> and the exclusion pattern is
3590 * <code>com/xyz/tests/**</code>, then source files like
3591 * <code>/Project/src/com/xyz/Foo.java</code> and
3592 * <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3593 * whereas <code>/Project/src/com/xyz/tests/T1.java</code> and
3594 * <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3595 * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
3596 * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code> for
3597 * the full description of the syntax and semantics of exclusion patterns.
3599 * If the empty list of exclusion patterns is specified, the source folder
3600 * will automatically include all resources located inside the source
3601 * folder. In that case, the result is entirely equivalent to using the
3602 * factory method <code>JavaCore.newSourceEntry(IPath)</code>.
3605 * Note that all sources/binaries inside a project are contributed as a
3606 * whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
3607 * Particular source entries cannot be selectively exported.
3611 * the absolute workspace-relative path of a source folder
3612 * @param exclusionPatterns
3613 * the possibly empty list of exclusion patterns represented as
3615 * @return a new source classpath entry with the given exclusion patterns
3616 * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
3617 * @see IClasspathEntry#getExclusionPatterns
3621 public static IClasspathEntry newSourceEntry(IPath path,
3622 IPath[] exclusionPatterns) {
3624 return newSourceEntry(path, exclusionPatterns, null /* output location */);
3628 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3629 * for the project's source folder identified by the given absolute
3630 * workspace-relative path but excluding all source files with paths
3631 * matching any of the given patterns, and associated with a specific output
3632 * location (that is, ".class" files are not going to the project default
3633 * output location). All package fragments within the root will have
3634 * children of type <code>ICompilationUnit</code>.
3636 * The source folder is referred to using an absolute path relative to the
3637 * workspace root, e.g. <code>/Project/src</code>. A project's source
3638 * folders are located with that project. That is, a source classpath entry
3639 * specifying the path <code>/P1/src</code> is only usable for project
3643 * The source classpath entry created by this method includes all source
3644 * files below the given workspace-relative path except for those matched by
3645 * one (or more) of the given exclusion patterns. Each exclusion pattern is
3646 * represented by a relative path, which is interpreted as relative to the
3647 * source folder. For example, if the source folder path is
3648 * <code>/Project/src</code> and the exclusion pattern is
3649 * <code>com/xyz/tests/**</code>, then source files like
3650 * <code>/Project/src/com/xyz/Foo.java</code> and
3651 * <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3652 * whereas <code>/Project/src/com/xyz/tests/T1.java</code> and
3653 * <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3654 * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
3655 * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code> for
3656 * the full description of the syntax and semantics of exclusion patterns.
3658 * If the empty list of exclusion patterns is specified, the source folder
3659 * will automatically include all resources located inside the source
3660 * folder. In that case, the result is entirely equivalent to using the
3661 * factory method <code>JavaCore.newSourceEntry(IPath)</code>.
3664 * Additionally, a source entry can be associated with a specific output
3665 * location. By doing so, the Java builder will ensure that the generated
3666 * ".class" files will be issued inside this output location, as opposed to
3667 * be generated into the project default output location (when output
3668 * location is <code>null</code>). Note that multiple source entries may
3669 * target the same output location. The output location is referred to using
3670 * an absolute path relative to the workspace root, e.g.
3671 * <code>"/Project/bin"</code>, it must be located inside the same
3672 * project as the source folder.
3675 * Also note that all sources/binaries inside a project are contributed as a
3676 * whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
3677 * Particular source entries cannot be selectively exported.
3681 * the absolute workspace-relative path of a source folder
3682 * @param exclusionPatterns
3683 * the possibly empty list of exclusion patterns represented as
3685 * @param outputLocation
3686 * the specific output location for this source entry (
3687 * <code>null</code> if using project default ouput location)
3688 * @return a new source classpath entry with the given exclusion patterns
3689 * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
3690 * @see IClasspathEntry#getExclusionPatterns
3691 * @see IClasspathEntry#getOutputLocation()
3695 public static IClasspathEntry newSourceEntry(IPath path,
3696 IPath[] exclusionPatterns, IPath specificOutputLocation) {
3698 if (!path.isAbsolute())
3699 Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3700 if (exclusionPatterns == null)
3701 Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$
3703 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3704 IClasspathEntry.CPE_SOURCE, path, exclusionPatterns, null, // source
3706 null, // source attachment root
3707 specificOutputLocation, // custom output location
3712 * Creates and returns a new non-exported classpath entry of kind
3713 * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3714 * path is the name of a classpath variable. The trailing segments of the
3715 * path will be appended to resolved variable path.
3717 * A variable entry allows to express indirect references on a classpath to
3718 * other projects or libraries, depending on what the classpath variable is
3721 * It is possible to register an automatic initializer (
3722 * <code>ClasspathVariableInitializer</code>), which will be invoked
3723 * through the extension point
3724 * "org.eclipse.jdt.core.classpathVariableInitializer". After resolution, a
3725 * classpath variable entry may either correspond to a project or a library
3728 * e.g. Here are some examples of variable path usage
3730 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3731 * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3732 * library "c:\jars\jdtcore.jar"</li>
3733 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3734 * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3735 * "/Project_JDTCORE"</li>
3736 * <li>"PLUGINS/com.example/example.jar" where variable
3737 * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3738 * classpath entry is denoting the library
3739 * "c:/eclipse/plugins/com.example/example.jar"</li>
3741 * Note that this operation does not attempt to validate classpath variables
3742 * or access the resources at the given paths.
3744 * The resulting entry is not exported to dependent projects. This method is
3745 * equivalent to <code>newVariableEntry(-,-,-,false)</code>.
3748 * @param variablePath
3749 * the path of the binary archive; first segment is the name of a
3750 * classpath variable
3751 * @param variableSourceAttachmentPath
3752 * the path of the corresponding source archive, or
3753 * <code>null</code> if none; if present, the first segment is
3754 * the name of a classpath variable (not necessarily the same
3755 * variable as the one that begins <code>variablePath</code>)
3756 * @param sourceAttachmentRootPath
3757 * the location of the root within the source archive or
3758 * <code>null</code> if <code>archivePath</code> is also
3760 * @return a new library classpath entry
3762 * @see JavaCore#newVariableEntry(IPath, IPath, IPath, boolean)
3764 //public static IClasspathEntry newVariableEntry(
3765 // IPath variablePath,
3766 // IPath variableSourceAttachmentPath,
3767 // IPath sourceAttachmentRootPath) {
3769 // return newVariableEntry(variablePath, variableSourceAttachmentPath,
3770 // sourceAttachmentRootPath, false);
3773 * Creates and returns a new non-exported classpath entry of kind
3774 * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3775 * path is the name of a classpath variable. The trailing segments of the
3776 * path will be appended to resolved variable path.
3778 * A variable entry allows to express indirect references on a classpath to
3779 * other projects or libraries, depending on what the classpath variable is
3782 * It is possible to register an automatic initializer (
3783 * <code>ClasspathVariableInitializer</code>), which will be invoked
3784 * through the extension point
3785 * "org.eclipse.jdt.core.classpathVariableInitializer". After resolution, a
3786 * classpath variable entry may either correspond to a project or a library
3789 * e.g. Here are some examples of variable path usage
3791 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3792 * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3793 * library "c:\jars\jdtcore.jar"</li>
3794 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3795 * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3796 * "/Project_JDTCORE"</li>
3797 * <li>"PLUGINS/com.example/example.jar" where variable
3798 * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3799 * classpath entry is denoting the library
3800 * "c:/eclipse/plugins/com.example/example.jar"</li>
3802 * Note that this operation does not attempt to validate classpath variables
3803 * or access the resources at the given paths.
3806 * @param variablePath
3807 * the path of the binary archive; first segment is the name of a
3808 * classpath variable
3809 * @param variableSourceAttachmentPath
3810 * the path of the corresponding source archive, or
3811 * <code>null</code> if none; if present, the first segment is
3812 * the name of a classpath variable (not necessarily the same
3813 * variable as the one that begins <code>variablePath</code>)
3814 * @param sourceAttachmentRootPath
3815 * the location of the root within the source archive or
3816 * <code>null</code> if <code>archivePath</code> is also
3819 * indicates whether this entry is contributed to dependent
3820 * projects in addition to the output location
3821 * @return a new variable classpath entry
3824 //public static IClasspathEntry newVariableEntry(
3825 // IPath variablePath,
3826 // IPath variableSourceAttachmentPath,
3827 // IPath variableSourceAttachmentRootPath,
3828 // boolean isExported) {
3830 // if (variablePath == null || variablePath.segmentCount() < 1) {
3833 // "Illegal classpath variable path: \'" +
3834 // variablePath.makeRelative().toString() + "\', must have at least one
3835 // segment"); //$NON-NLS-1$//$NON-NLS-2$
3838 // return new ClasspathEntry(
3839 // IPackageFragmentRoot.K_SOURCE,
3840 // IClasspathEntry.CPE_VARIABLE,
3842 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3843 // variableSourceAttachmentPath, // source attachment
3844 // variableSourceAttachmentRootPath, // source attachment root
3845 // null, // specific output folder
3849 * Removed the given classpath variable. Does nothing if no value was set
3850 * for this classpath variable.
3852 * This functionality cannot be used while the resource tree is locked.
3854 * Classpath variable values are persisted locally to the workspace, and are
3855 * preserved from session to session.
3858 * @param variableName
3859 * the name of the classpath variable
3860 * @see #setClasspathVariable
3862 * @deprecated - use version with extra IProgressMonitor
3864 //public static void removeClasspathVariable(String variableName) {
3865 // removeClasspathVariable(variableName, null);
3868 * Removed the given classpath variable. Does nothing if no value was set
3869 * for this classpath variable.
3871 * This functionality cannot be used while the resource tree is locked.
3873 * Classpath variable values are persisted locally to the workspace, and are
3874 * preserved from session to session.
3877 * @param variableName
3878 * the name of the classpath variable
3880 * the progress monitor to report progress
3881 * @see #setClasspathVariable
3883 //public static void removeClasspathVariable(
3884 // String variableName,
3885 // IProgressMonitor monitor) {
3888 // updateVariableValues(new String[]{ variableName}, new IPath[]{ null },
3890 // } catch (JavaModelException e) {
3894 * Removes the given element changed listener. Has no affect if an identical
3895 * listener is not registered.
3900 public static void removeElementChangedListener(
3901 IElementChangedListener listener) {
3902 JavaModelManager.getJavaModelManager().removeElementChangedListener(
3907 * Bind a container reference path to some actual containers (
3908 * <code>IClasspathContainer</code>). This API must be invoked whenever
3909 * changes in container need to be reflected onto the JavaModel. Containers
3910 * can have distinct values in different projects, therefore this API
3911 * considers a set of projects with their respective containers.
3913 * <code>containerPath</code> is the path under which these values can be
3914 * referenced through container classpath entries (
3915 * <code>IClasspathEntry#CPE_CONTAINER</code>). A container path is
3916 * formed by a first ID segment followed with extra segments, which can be
3917 * used as additional hints for the resolution. The container ID is used to
3918 * identify a <code>ClasspathContainerInitializer</code> registered on the
3919 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3921 * There is no assumption that each individual container value passed in
3922 * argument (<code>respectiveContainers</code>) must answer the exact
3923 * same path when requested <code>IClasspathContainer#getPath</code>.
3924 * Indeed, the containerPath is just an indication for resolving it to an
3925 * actual container object. It can be delegated to a
3926 * <code>ClasspathContainerInitializer</code>, which can be activated
3927 * through the extension point
3928 * "org.eclipse.jdt.core.ClasspathContainerInitializer").
3930 * In reaction to changing container values, the JavaModel will be updated
3931 * to reflect the new state of the updated container.
3933 * This functionality cannot be used while the resource tree is locked.
3935 * Classpath container values are persisted locally to the workspace, but
3936 * are not preserved from a session to another. It is thus highly
3937 * recommended to register a <code>ClasspathContainerInitializer</code>
3938 * for each referenced container (through the extension point
3939 * "org.eclipse.jdt.core.ClasspathContainerInitializer").
3941 * Note: setting a container to <code>null</code> will cause it to be
3942 * lazily resolved again whenever its value is required. In particular, this
3943 * will cause a registered initializer to be invoked again.
3946 * @param containerPath -
3947 * the name of the container reference, which is being updated
3948 * @param affectedProjects -
3949 * the set of projects for which this container is being bound
3950 * @param respectiveContainers -
3951 * the set of respective containers for the affected projects
3953 * a monitor to report progress
3955 * @see ClasspathContainerInitializer
3956 * @see #getClasspathContainer(IPath, IJavaProject)
3957 * @see IClasspathContainer
3960 //public static void setClasspathContainer(final IPath containerPath,
3961 // IJavaProject[] affectedProjects, IClasspathContainer[]
3962 // respectiveContainers, IProgressMonitor monitor) throws JavaModelException
3965 // if (affectedProjects.length != respectiveContainers.length)
3966 // Assert.isTrue(false, "Projects and containers collections should have the
3967 // same size"); //$NON-NLS-1$
3969 // if (monitor != null && monitor.isCanceled()) return;
3971 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3972 // System.out.println("CPContainer SET - setting container:
3973 // ["+containerPath+"] for projects: {" //$NON-NLS-1$ //$NON-NLS-2$
3974 // + (Util.toString(affectedProjects,
3975 // new Util.Displayable(){
3976 // public String displayString(Object o) { return ((IJavaProject)
3977 // o).getElementName(); }
3979 // + "} with values: " //$NON-NLS-1$
3980 // + (Util.toString(respectiveContainers,
3981 // new Util.Displayable(){
3982 // public String displayString(Object o) { return ((IClasspathContainer)
3983 // o).getDescription(); }
3988 // final int projectLength = affectedProjects.length;
3989 // final IJavaProject[] modifiedProjects;
3990 // System.arraycopy(affectedProjects, 0, modifiedProjects = new
3991 // IJavaProject[projectLength], 0, projectLength);
3992 // final IClasspathEntry[][] oldResolvedPaths = new
3993 // IClasspathEntry[projectLength][];
3995 // // filter out unmodified project containers
3996 // int remaining = 0;
3997 // for (int i = 0; i < projectLength; i++){
3999 // if (monitor != null && monitor.isCanceled()) return;
4001 // IJavaProject affectedProject = affectedProjects[i];
4002 // IClasspathContainer newContainer = respectiveContainers[i];
4003 // if (newContainer == null) newContainer =
4004 // JavaModelManager.ContainerInitializationInProgress; // 30920 - prevent
4006 // boolean found = false;
4007 // if (JavaProject.hasJavaNature(affectedProject.getProject())){
4008 // IClasspathEntry[] rawClasspath = affectedProject.getRawClasspath();
4009 // for (int j = 0, cpLength = rawClasspath.length; j <cpLength; j++) {
4010 // IClasspathEntry entry = rawClasspath[j];
4011 // if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER &&
4012 // entry.getPath().equals(containerPath)){
4019 // modifiedProjects[i] = null; // filter out this project - does not
4020 // reference the container path, or isnt't yet Java project
4021 // JavaModelManager.containerPut(affectedProject, containerPath,
4025 // IClasspathContainer oldContainer =
4026 // JavaModelManager.containerGet(affectedProject, containerPath);
4027 // if (oldContainer == JavaModelManager.ContainerInitializationInProgress) {
4028 // Map previousContainerValues =
4029 // (Map)JavaModelManager.PreviousSessionContainers.get(affectedProject);
4030 // if (previousContainerValues != null){
4031 // IClasspathContainer previousContainer =
4032 // (IClasspathContainer)previousContainerValues.get(containerPath);
4033 // if (previousContainer != null) {
4034 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4035 // System.out.println("CPContainer INIT - reentering access to project
4036 // container: ["+affectedProject.getElementName()+"] " + containerPath + "
4037 // during its initialization, will see previous value: "+
4038 // previousContainer.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
4041 // JavaModelManager.containerPut(affectedProject, containerPath,
4042 // previousContainer);
4044 // oldContainer = null; //33695 - cannot filter out restored container, must
4045 // update affected project to reset cached CP
4047 // oldContainer = null;
4050 // if (oldContainer != null &&
4051 // oldContainer.equals(respectiveContainers[i])){// TODO: could improve to
4052 // only compare entries
4053 // modifiedProjects[i] = null; // filter out this project - container did
4058 // oldResolvedPaths[i] = affectedProject.getResolvedClasspath(true);
4059 // JavaModelManager.containerPut(affectedProject, containerPath,
4063 // if (remaining == 0) return;
4065 // // trigger model refresh
4067 // JavaCore.run(new IWorkspaceRunnable() {
4068 // public void run(IProgressMonitor monitor) throws CoreException {
4069 // for(int i = 0; i < projectLength; i++){
4071 // if (monitor != null && monitor.isCanceled()) return;
4073 // JavaProject affectedProject = (JavaProject)modifiedProjects[i];
4074 // if (affectedProject == null) continue; // was filtered out
4076 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4077 // System.out.println("CPContainer SET - updating affected project:
4078 // ["+affectedProject.getElementName()+"] due to setting container: " +
4079 // containerPath); //$NON-NLS-1$ //$NON-NLS-2$
4082 // // force a refresh of the affected project (will compute deltas)
4083 // affectedProject.setRawClasspath(
4084 // affectedProject.getRawClasspath(),
4085 // SetClasspathOperation.ReuseOutputLocation,
4087 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can save resources
4088 // oldResolvedPaths[i],
4089 // false, // updating - no validation
4090 // false); // updating - no need to save
4095 // } catch(CoreException e) {
4096 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4097 // System.out.println("CPContainer SET - FAILED DUE TO EXCEPTION:
4098 // "+containerPath); //$NON-NLS-1$
4099 // e.printStackTrace();
4101 // if (e instanceof JavaModelException) {
4102 // throw (JavaModelException)e;
4104 // throw new JavaModelException(e);
4107 // for (int i = 0; i < projectLength; i++) {
4108 // if (respectiveContainers[i] == null) {
4109 // JavaModelManager.containerPut(affectedProjects[i], containerPath, null);
4110 // // reset init in progress marker
4117 * Sets the value of the given classpath variable. The path must have at
4118 * least one segment.
4120 * This functionality cannot be used while the resource tree is locked.
4122 * Classpath variable values are persisted locally to the workspace, and are
4123 * preserved from session to session.
4126 * @param variableName
4127 * the name of the classpath variable
4130 * @see #getClasspathVariable
4132 * @deprecated - use API with IProgressMonitor
4134 //public static void setClasspathVariable(String variableName, IPath path)
4135 // throws JavaModelException {
4137 // setClasspathVariable(variableName, path, null);
4140 * Sets the value of the given classpath variable. The path must not be
4143 * This functionality cannot be used while the resource tree is locked.
4145 * Classpath variable values are persisted locally to the workspace, and are
4146 * preserved from session to session.
4148 * Updating a variable with the same value has no effect.
4150 * @param variableName
4151 * the name of the classpath variable
4155 * a monitor to report progress
4156 * @see #getClasspathVariable
4158 //public static void setClasspathVariable(
4159 // String variableName,
4161 // IProgressMonitor monitor)
4162 // throws JavaModelException {
4164 // if (path == null) Assert.isTrue(false, "Variable path cannot be null");
4166 // setClasspathVariables(new String[]{variableName}, new IPath[]{ path },
4170 * Sets the values of all the given classpath variables at once. Null paths
4171 * can be used to request corresponding variable removal.
4173 * This functionality cannot be used while the resource tree is locked.
4175 * Classpath variable values are persisted locally to the workspace, and are
4176 * preserved from session to session.
4178 * Updating a variable with the same value has no effect.
4180 * @param variableNames
4181 * an array of names for the updated classpath variables
4183 * an array of path updates for the modified classpath variables
4184 * (null meaning that the corresponding value will be removed
4186 * a monitor to report progress
4187 * @see #getClasspathVariable
4190 //public static void setClasspathVariables(
4191 // String[] variableNames,
4193 // IProgressMonitor monitor)
4194 // throws JavaModelException {
4196 // if (variableNames.length != paths.length) Assert.isTrue(false, "Variable
4197 // names and paths collections should have the same size"); //$NON-NLS-1$
4198 // //TODO: should check that null cannot be used as variable paths
4199 // updateVariableValues(variableNames, paths, monitor);
4202 * (non-Javadoc) Method declared on IExecutableExtension. Record any
4203 * necessary initialization data from the plugin.
4205 public void setInitializationData(IConfigurationElement cfig,
4206 String propertyName, Object data) throws CoreException {
4210 * Sets the current table of options. All and only the options explicitly
4211 * included in the given table are remembered; all previous option settings
4212 * are forgotten, including ones not explicitly mentioned.
4214 * For a complete description of the configurable options, see
4215 * <code>getDefaultOptions</code>.
4219 * the new options (key type: <code>String</code>; value type:
4220 * <code>String</code>), or <code>null</code> to reset all
4221 * options to their default values
4222 * @see JavaCore#getDefaultOptions
4224 public static void setOptions(Hashtable newOptions) {
4226 // see #initializeDefaultPluginPreferences() for changing default
4228 Preferences preferences = getPlugin().getPluginPreferences();
4230 if (newOptions == null) {
4231 newOptions = JavaCore.getDefaultOptions();
4233 Enumeration keys = newOptions.keys();
4234 while (keys.hasMoreElements()) {
4235 String key = (String) keys.nextElement();
4236 if (!JavaModelManager.OptionNames.contains(key))
4237 continue; // unrecognized option
4238 if (key.equals(CORE_ENCODING))
4239 continue; // skipped, contributed by resource prefs
4240 String value = (String) newOptions.get(key);
4241 preferences.setValue(key, value);
4245 getPlugin().savePluginPreferences();
4249 * Shutdown the JavaCore plug-in.
4251 * De-registers the JavaModelManager as a resource changed listener and save
4255 * @see org.eclipse.core.runtime.Plugin#shutdown()
4257 // moved to PHPeclipsePlugin#shutdown()
4258 //public void shutdown() {
4260 // //savePluginPreferences();
4261 // getPlugin().savePluginPreferences();
4262 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4263 // workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaProcessor);
4264 // workspace.removeSaveParticipant(PHPeclipsePlugin.getDefault());
4266 // ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown();
4269 * Initiate the background indexing process. This should be deferred after
4270 * the plugin activation.
4272 //private void startIndexing() {
4274 // JavaModelManager.getJavaModelManager().getIndexManager().reset();
4277 * Startup of the JavaCore plug-in.
4279 * Registers the JavaModelManager as a resource changed listener and save
4280 * participant. Starts the background indexing, and restore saved classpath
4284 * @see org.eclipse.core.runtime.Plugin#startup()
4287 // moved to PHPeclipsePlugin#startup()
4288 //public void startup() {
4290 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
4292 // manager.configurePluginDebugOptions();
4294 // // request state folder creation (workaround 19885)
4295 // JavaCore.getPlugin().getStateLocation();
4297 // // retrieve variable values
4298 // JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4299 // JavaModelManager.PluginPreferencesListener());
4300 //// TODO : jsurfer temp-del
4301 //// manager.loadVariablesAndContainers();
4303 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4304 // workspace.addResourceChangeListener(
4305 // manager.deltaProcessor,
4306 // IResourceChangeEvent.PRE_AUTO_BUILD
4307 // | IResourceChangeEvent.POST_AUTO_BUILD
4308 // | IResourceChangeEvent.POST_CHANGE
4309 // | IResourceChangeEvent.PRE_DELETE
4310 // | IResourceChangeEvent.PRE_CLOSE);
4312 //// startIndexing();
4313 // workspace.addSaveParticipant(PHPeclipsePlugin.getDefault(), manager);
4315 // } catch (CoreException e) {
4316 // } catch (RuntimeException e) {
4317 // manager.shutdown();
4322 * Internal updating of a variable values (null path meaning removal),
4323 * allowing to change multiple variable values at once.
4325 //private static void updateVariableValues(
4326 // String[] variableNames,
4327 // IPath[] variablePaths,
4328 // IProgressMonitor monitor) throws JavaModelException {
4330 // if (monitor != null && monitor.isCanceled()) return;
4332 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4333 // System.out.println("CPVariable SET - setting variables: {" +
4334 // Util.toString(variableNames) //$NON-NLS-1$
4335 // + "} with values: " + Util.toString(variablePaths)); //$NON-NLS-1$
4338 // int varLength = variableNames.length;
4340 // // gather classpath information for updating
4341 // final HashMap affectedProjects = new HashMap(5);
4342 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
4343 // IJavaModel model = manager.getJavaModel();
4345 // // filter out unmodified variables
4346 // int discardCount = 0;
4347 // for (int i = 0; i < varLength; i++){
4348 // String variableName = variableNames[i];
4349 // IPath oldPath = (IPath)JavaModelManager.variableGet(variableName); // if
4350 // reentering will provide previous session value
4351 // if (oldPath == JavaModelManager.VariableInitializationInProgress){
4352 // IPath previousPath =
4353 // (IPath)JavaModelManager.PreviousSessionVariables.get(variableName);
4354 // if (previousPath != null){
4355 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4356 // System.out.println("CPVariable INIT - reentering access to variable: " +
4357 // variableName+ " during its initialization, will see previous value: "+
4358 // previousPath); //$NON-NLS-1$ //$NON-NLS-2$
4360 // JavaModelManager.variablePut(variableName, previousPath); // replace
4361 // value so reentering calls are seeing old value
4363 // oldPath = null; //33695 - cannot filter out restored variable, must
4364 // update affected project to reset cached CP
4366 // if (oldPath != null && oldPath.equals(variablePaths[i])){
4367 // variableNames[i] = null;
4371 // if (discardCount > 0){
4372 // if (discardCount == varLength) return;
4373 // int changedLength = varLength - discardCount;
4374 // String[] changedVariableNames = new String[changedLength];
4375 // IPath[] changedVariablePaths = new IPath[changedLength];
4376 // for (int i = 0, index = 0; i < varLength; i++){
4377 // if (variableNames[i] != null){
4378 // changedVariableNames[index] = variableNames[i];
4379 // changedVariablePaths[index] = variablePaths[i];
4383 // variableNames = changedVariableNames;
4384 // variablePaths = changedVariablePaths;
4385 // varLength = changedLength;
4388 // if (monitor != null && monitor.isCanceled()) return;
4390 // if (model != null) {
4391 // IJavaProject[] projects = model.getJavaProjects();
4392 // nextProject : for (int i = 0, projectLength = projects.length; i <
4393 // projectLength; i++){
4394 // IJavaProject project = projects[i];
4396 // // check to see if any of the modified variables is present on the
4398 // IClasspathEntry[] classpath = project.getRawClasspath();
4399 // for (int j = 0, cpLength = classpath.length; j < cpLength; j++){
4401 // IClasspathEntry entry = classpath[j];
4402 // for (int k = 0; k < varLength; k++){
4404 // String variableName = variableNames[k];
4405 // if (entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE){
4407 // if (variableName.equals(entry.getPath().segment(0))){
4408 // affectedProjects.put(project, project.getResolvedClasspath(true));
4409 // continue nextProject;
4411 // IPath sourcePath, sourceRootPath;
4412 // if (((sourcePath = entry.getSourceAttachmentPath()) != null &&
4413 // variableName.equals(sourcePath.segment(0)))
4414 // || ((sourceRootPath = entry.getSourceAttachmentRootPath()) != null &&
4415 // variableName.equals(sourceRootPath.segment(0)))) {
4417 // affectedProjects.put(project, project.getResolvedClasspath(true));
4418 // continue nextProject;
4425 // // update variables
4426 // for (int i = 0; i < varLength; i++){
4427 // JavaModelManager.variablePut(variableNames[i], variablePaths[i]);
4429 // final String[] dbgVariableNames = variableNames;
4431 // // update affected project classpaths
4432 // if (!affectedProjects.isEmpty()) {
4434 // JavaCore_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt.run(
4435 // new IWorkspaceRunnable() {
4436 // public void run(IProgressMonitor monitor) throws CoreException {
4437 // // propagate classpath change
4438 // Iterator projectsToUpdate = affectedProjects.keySet().iterator();
4439 // while (projectsToUpdate.hasNext()) {
4441 // if (monitor != null && monitor.isCanceled()) return;
4443 // JavaProject project = (JavaProject) projectsToUpdate.next();
4445 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4446 // System.out.println("CPVariable SET - updating affected project:
4447 // ["+project.getElementName()+"] due to setting variables: "+
4448 // Util.toString(dbgVariableNames)); //$NON-NLS-1$ //$NON-NLS-2$
4452 // .setRawClasspath(
4453 // project.getRawClasspath(),
4454 // SetClasspathOperation.ReuseOutputLocation,
4455 // null, // don't call beginTask on the monitor (see
4456 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=3717)
4457 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can change resources
4458 // (IClasspathEntry[]) affectedProjects.get(project),
4459 // false, // updating - no validation
4460 // false); // updating - no need to save
4465 // } catch (CoreException e) {
4466 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4467 // System.out.println("CPVariable SET - FAILED DUE TO EXCEPTION:
4468 // "+Util.toString(dbgVariableNames)); //$NON-NLS-1$
4469 // e.printStackTrace();
4471 // if (e instanceof JavaModelException) {
4472 // throw (JavaModelException)e;
4474 // throw new JavaModelException(e);
4480 * (non-Javadoc) Startup the JavaCore plug-in. <p> Registers the
4481 * JavaModelManager as a resource changed listener and save participant.
4482 * Starts the background indexing, and restore saved classpath variable
4483 * values. <p> @throws Exception
4485 * @see org.eclipse.core.runtime.Plugin#start(BundleContext)
4487 //public static void start(final Plugin plugin, BundleContext context)
4488 // throws Exception {
4489 //// super.start(context);
4491 // final JavaModelManager manager = JavaModelManager.getJavaModelManager();
4493 // manager.configurePluginDebugOptions();
4495 // // request state folder creation (workaround 19885)
4496 // JavaCore.getPlugin().getStateLocation();
4498 // // retrieve variable values
4499 // //JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4500 // JavaModelManager.PluginPreferencesListener());
4501 //// manager.loadVariablesAndContainers();
4503 // final IWorkspace workspace = ResourcesPlugin.getWorkspace();
4504 // workspace.addResourceChangeListener(
4505 // manager.deltaState,
4506 // IResourceChangeEvent.PRE_BUILD
4507 // | IResourceChangeEvent.POST_BUILD
4508 // | IResourceChangeEvent.POST_CHANGE
4509 // | IResourceChangeEvent.PRE_DELETE
4510 // | IResourceChangeEvent.PRE_CLOSE);
4512 //// startIndexing();
4514 // // process deltas since last activated in indexer thread so that indexes
4516 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658
4517 // Job processSavedState = new Job(Util.bind("savedState.jobName")) {
4519 // protected IStatus run(IProgressMonitor monitor) {
4521 // // add save participant and process delta atomically
4522 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59937
4524 // new IWorkspaceRunnable() {
4525 // public void run(IProgressMonitor progress) throws CoreException {
4526 //// ISavedState savedState = workspace.addSaveParticipant(JavaCore.this,
4528 // ISavedState savedState = workspace.addSaveParticipant(plugin, manager);
4529 // if (savedState != null) {
4530 // // the event type coming from the saved state is always POST_AUTO_BUILD
4531 // // force it to be POST_CHANGE so that the delta processor can handle it
4532 // manager.deltaState.getDeltaProcessor().overridenEventType =
4533 // IResourceChangeEvent.POST_CHANGE;
4534 // savedState.processResourceChangeEvents(manager.deltaState);
4539 // } catch (CoreException e) {
4540 // return e.getStatus();
4542 // return Status.OK_STATUS;
4545 // processSavedState.setSystem(true);
4546 // processSavedState.setPriority(Job.SHORT); // process asap
4547 // processSavedState.schedule();
4548 // } catch (RuntimeException e) {
4549 // manager.shutdown();
4554 * (non-Javadoc) Shutdown the JavaCore plug-in. <p> De-registers the
4555 * JavaModelManager as a resource changed listener and save participant. <p>
4557 * @see org.eclipse.core.runtime.Plugin#stop(BundleContext)
4559 // public static void stop(Plugin plugin, BundleContext context)
4560 // throws Exception {
4562 // plugin.savePluginPreferences();
4563 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4564 // workspace.removeResourceChangeListener(JavaModelManager
4565 // .getJavaModelManager().deltaState);
4566 // workspace.removeSaveParticipant(plugin);
4568 // JavaModelManager.getJavaModelManager().shutdown();
4570 // // ensure we call super.stop as the last thing
4571 // // super.stop(context);