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.compiler.impl.CompilerOptions;
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.core.util.MementoTokenizer;
19 import net.sourceforge.phpdt.internal.corext.Assert;
20 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
22 import org.eclipse.core.resources.IFile;
23 import org.eclipse.core.resources.IFolder;
24 import org.eclipse.core.resources.IMarker;
25 import org.eclipse.core.resources.IMarkerDelta;
26 import org.eclipse.core.resources.IProject;
27 import org.eclipse.core.resources.IProjectDescription;
28 import org.eclipse.core.resources.IResource;
29 import org.eclipse.core.resources.IResourceChangeListener;
30 import org.eclipse.core.resources.IWorkspaceRoot;
31 import org.eclipse.core.resources.ResourcesPlugin;
32 import org.eclipse.core.runtime.CoreException;
33 import org.eclipse.core.runtime.IConfigurationElement;
34 import org.eclipse.core.runtime.IPath;
35 import org.eclipse.core.runtime.IProgressMonitor;
36 import org.eclipse.core.runtime.Plugin;
37 import org.eclipse.core.runtime.Preferences;
39 public class JavaCore {
41 // public static HashSet OptionNames = new HashSet(20);
43 * The plug-in identifier of the Java core support (value
44 * <code>"net.sourceforge.phpeclipse"</code>)
46 // public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.core";
48 public static final String PLUGIN_ID = PHPeclipsePlugin.PLUGIN_ID;
51 * Possible configurable option ID.
53 * @see #getDefaultOptions
56 public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; //$NON-NLS-1$
59 * Possible configurable option ID.
61 * @see #getDefaultOptions
64 public static final String FORMATTER_NEWLINE_OPENING_BRACE = PLUGIN_ID
65 + ".formatter.newline.openingBrace"; //$NON-NLS-1$
68 * Possible configurable option ID.
70 * @see #getDefaultOptions
73 public static final String FORMATTER_NEWLINE_CONTROL = PLUGIN_ID
74 + ".formatter.newline.controlStatement"; //$NON-NLS-1$
77 * Possible configurable option ID.
79 * @see #getDefaultOptions
82 public static final String FORMATTER_NEWLINE_ELSE_IF = PLUGIN_ID
83 + ".formatter.newline.elseIf"; //$NON-NLS-1$
86 * Possible configurable option ID.
88 * @see #getDefaultOptions
91 public static final String FORMATTER_NEWLINE_EMPTY_BLOCK = PLUGIN_ID
92 + ".formatter.newline.emptyBlock"; //$NON-NLS-1$
95 * Possible configurable option ID.
97 * @see #getDefaultOptions
100 public static final String FORMATTER_CLEAR_BLANK_LINES = PLUGIN_ID
101 + ".formatter.newline.clearAll"; //$NON-NLS-1$
104 * Possible configurable option ID.
106 * @see #getDefaultOptions
109 public static final String FORMATTER_LINE_SPLIT = PLUGIN_ID
110 + ".formatter.lineSplit"; //$NON-NLS-1$
113 * Possible configurable option ID.
115 * @see #getDefaultOptions
118 public static final String FORMATTER_COMPACT_ASSIGNMENT = PLUGIN_ID
119 + ".formatter.style.assignment"; //$NON-NLS-1$
122 * Possible configurable option ID.
124 * @see #getDefaultOptions
127 public static final String FORMATTER_COMPACT_STRING_CONCATENATION = PLUGIN_ID
128 + ".formatter.style.compactStringConcatenation"; //$NON-NLS-1$
130 * Possible configurable option ID.
132 * @see #getDefaultOptions
135 public static final String FORMATTER_COMPACT_ARRAYS = PLUGIN_ID
136 + ".formatter.style.compactArrays"; //$NON-NLS-1$
139 * Possible configurable option ID.
141 * @see #getDefaultOptions
144 public static final String FORMATTER_TAB_CHAR = PLUGIN_ID
145 + ".formatter.tabulation.char"; //$NON-NLS-1$
148 * Possible configurable option ID.
150 * @see #getDefaultOptions
153 public static final String FORMATTER_TAB_SIZE = PLUGIN_ID
154 + ".formatter.tabulation.size"; //$NON-NLS-1$
157 * Possible configurable option value.
159 * @see #getDefaultOptions
162 public static final String INSERT = "insert"; //$NON-NLS-1$
165 * Possible configurable option value.
167 * @see #getDefaultOptions
170 public static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$
173 * Possible configurable option value.
175 * @see #getDefaultOptions
178 public static final String PRESERVE_ONE = "preserve one"; //$NON-NLS-1$
181 * Possible configurable option value.
183 * @see #getDefaultOptions
186 public static final String CLEAR_ALL = "clear all"; //$NON-NLS-1$
189 * Possible configurable option value.
191 * @see #getDefaultOptions
194 public static final String NORMAL = "normal"; //$NON-NLS-1$
197 * Possible configurable option value.
199 * @see #getDefaultOptions
202 public static final String COMPACT = "compact"; //$NON-NLS-1$
205 * Possible configurable option value.
207 * @see #getDefaultOptions
210 public static final String TAB = "tab"; //$NON-NLS-1$
213 * Possible configurable option value.
215 * @see #getDefaultOptions
218 public static final String SPACE = "space"; //$NON-NLS-1$
221 * Possible configurable option value.
223 * @see #getDefaultOptions
226 public static final String ENABLED = "enabled"; //$NON-NLS-1$
229 * Possible configurable option value.
231 * @see #getDefaultOptions
234 public static final String DISABLED = "disabled"; //$NON-NLS-1$
237 * Possible configurable option value.
239 * @see #getDefaultOptions
242 public static final String CLEAN = "clean"; //$NON-NLS-1$
245 * Possible configurable option ID.
247 * @see #getDefaultOptions
250 public static final String COMPILER_TASK_TAGS = PLUGIN_ID
251 + ".compiler.taskTags"; //$NON-NLS-1$
254 * Name of the handle id attribute in a Java marker.
256 protected static final String ATT_HANDLE_ID = "net.sourceforge.phpdt.internal.core.JavaModelManager.handleId"; //$NON-NLS-1$
258 // *************** Possible IDs for configurable options.
259 // ********************
262 * Possible configurable option ID.
264 * @see #getDefaultOptions()
266 public static final String COMPILER_LOCAL_VARIABLE_ATTR = PLUGIN_ID
267 + ".compiler.debug.localVariable"; //$NON-NLS-1$
270 * Possible configurable option ID.
272 * @see #getDefaultOptions()
274 public static final String COMPILER_LINE_NUMBER_ATTR = PLUGIN_ID
275 + ".compiler.debug.lineNumber"; //$NON-NLS-1$
278 * Possible configurable option ID.
280 * @see #getDefaultOptions
282 public static final String COMPILER_SOURCE_FILE_ATTR = PLUGIN_ID
283 + ".compiler.debug.sourceFile"; //$NON-NLS-1$
286 * Possible configurable option ID.
288 * @see #getDefaultOptions
290 public static final String COMPILER_CODEGEN_UNUSED_LOCAL = PLUGIN_ID
291 + ".compiler.codegen.unusedLocal"; //$NON-NLS-1$
294 * Possible configurable option ID.
296 * @see #getDefaultOptions
298 public static final String COMPILER_CODEGEN_TARGET_PLATFORM = PLUGIN_ID
299 + ".compiler.codegen.targetPlatform"; //$NON-NLS-1$
302 * Possible configurable option ID.
304 * @see #getDefaultOptions
306 public static final String COMPILER_PB_PHP_VAR_DEPRECATED = CompilerOptions.OPTION_PHPVarDeprecatedWarning; //$NON-NLS-1$
308 public static final String COMPILER_PB_PHP_KEYWORD = CompilerOptions.OPTION_PHPBadStyleKeywordWarning; //$NON-NLS-1$
310 public static final String COMPILER_PB_PHP_UPPERCASE_IDENTIFIER = CompilerOptions.OPTION_PHPBadStyleUppercaseIdentifierWarning; //$NON-NLS-1$
312 public static final String COMPILER_PB_PHP_FILE_NOT_EXIST = CompilerOptions.OPTION_PHPIncludeNotExistWarning; //$NON-NLS-1$
314 public static final String COMPILER_PB_UNINITIALIZED_LOCAL_VARIABLE = CompilerOptions.OPTION_UninitializedLocalVariableWarning; //$NON-NLS-1$
316 public static final String COMPILER_PB_UNREACHABLE_CODE = CompilerOptions.OPTION_CodeCannotBeReachedWarning; //$NON-NLS-1$
319 * Possible configurable option ID.
321 * @see #getDefaultOptions
323 // public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID
324 // + ".compiler.problem.unreachableCode"; //$NON-NLS-1$
326 * Possible configurable option ID.
328 * @see #getDefaultOptions
330 public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID
331 + ".compiler.problem.invalidImport"; //$NON-NLS-1$
334 * Possible configurable option ID.
336 * @see #getDefaultOptions
338 public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID
339 + ".compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
342 * Possible configurable option ID.
344 * @see #getDefaultOptions
346 public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID
347 + ".compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
350 * Possible configurable option ID.
352 * @see #getDefaultOptions
354 public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID
355 + ".compiler.problem.deprecation"; //$NON-NLS-1$
358 * Possible configurable option ID.
360 * @see #getDefaultOptions
363 public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID
364 + ".compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
367 * Possible configurable option ID.
369 * @see #getDefaultOptions
371 public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID
372 + ".compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
375 * Possible configurable option ID.
377 * @see #getDefaultOptions
379 public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID
380 + ".compiler.problem.unusedLocal"; //$NON-NLS-1$
383 * Possible configurable option ID.
385 * @see #getDefaultOptions
387 public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID
388 + ".compiler.problem.unusedParameter"; //$NON-NLS-1$
391 * Possible configurable option ID.
393 * @see #getDefaultOptions
396 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID
397 + ".compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
400 * Possible configurable option ID.
402 * @see #getDefaultOptions
405 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID
406 + ".compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
409 * Possible configurable option ID.
411 * @see #getDefaultOptions
414 public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID
415 + ".compiler.problem.unusedImport"; //$NON-NLS-1$
418 * Possible configurable option ID.
420 * @see #getDefaultOptions
422 public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID
423 + ".compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
426 * Possible configurable option ID.
428 * @see #getDefaultOptions
431 public static final String COMPILER_PB_NON_NLS_STRING_LITERAL = PLUGIN_ID
432 + ".compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
435 * Possible configurable option ID.
437 * @see #getDefaultOptions
440 public static final String COMPILER_PB_ASSERT_IDENTIFIER = PLUGIN_ID
441 + ".compiler.problem.assertIdentifier"; //$NON-NLS-1$
444 * Possible configurable option ID.
446 * @see #getDefaultOptions
449 public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID
450 + ".compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
453 * Possible configurable option ID.
455 * @see #getDefaultOptions
458 public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID
459 + ".compiler.problem.noEffectAssignment"; //$NON-NLS-1$
462 * Possible configurable option ID.
464 * @see #getDefaultOptions
467 public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID
468 + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
471 * Possible configurable option ID.
473 * @see #getDefaultOptions
476 public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID
477 + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
480 * Possible configurable option ID.
482 * @see #getDefaultOptions
485 public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID
486 + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
489 * Possible configurable option ID.
491 * @see #getDefaultOptions
494 public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID
495 + ".compiler.maxProblemPerUnit"; //$NON-NLS-1$
498 * Possible configurable option ID.
500 * @see #getDefaultOptions
503 public static final String COMPILER_SOURCE = PLUGIN_ID + ".compiler.source"; //$NON-NLS-1$
506 * Possible configurable option ID.
508 * @see #getDefaultOptions
511 public static final String COMPILER_COMPLIANCE = PLUGIN_ID
512 + ".compiler.compliance"; //$NON-NLS-1$
515 * Possible configurable option ID.
517 * @see #getDefaultOptions
520 public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID
521 + ".compiler.taskPriorities"; //$NON-NLS-1$
524 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
526 * @see #getDefaultOptions
529 public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$
532 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
534 * @see #getDefaultOptions
537 public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$
540 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
542 * @see #getDefaultOptions
545 public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$
548 * Possible configurable option ID.
550 * @see #getDefaultOptions
552 public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID
553 + ".computeJavaBuildOrder"; //$NON-NLS-1$
556 * Possible configurable option ID.
558 * @see #getDefaultOptions
561 public static final String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER = PLUGIN_ID
562 + ".builder.resourceCopyExclusionFilter"; //$NON-NLS-1$
565 * Possible configurable option ID.
567 * @see #getDefaultOptions
570 public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID
571 + ".builder.duplicateResourceTask"; //$NON-NLS-1$
574 * Possible configurable option ID.
576 * @see #getDefaultOptions
579 public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID
580 + ".builder.cleanOutputFolder"; //$NON-NLS-1$
583 * Possible configurable option ID.
585 * @see #getDefaultOptions
588 public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID
589 + ".incompleteClasspath"; //$NON-NLS-1$
592 * Possible configurable option ID.
594 * @see #getDefaultOptions
597 public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID
598 + ".circularClasspath"; //$NON-NLS-1$
601 * Possible configurable option ID.
603 * @see #getDefaultOptions
606 public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID
607 + ".builder.invalidClasspath"; //$NON-NLS-1$
610 * Possible configurable option ID.
612 * @see #getDefaultOptions
615 public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID
616 + ".classpath.exclusionPatterns"; //$NON-NLS-1$
619 * Possible configurable option ID.
621 * @see #getDefaultOptions
624 public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID
625 + ".classpath.multipleOutputLocations"; //$NON-NLS-1$
632 public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$
635 * Default task priority
639 public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; //$NON-NLS-1$
642 * Possible configurable option ID
644 * @see #getDefaultOptions
647 public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID
648 + ".formatter.space.castexpression"; //$NON-NLS-1$
651 * Possible configurable option ID.
653 * @see #getDefaultOptions
656 public static final String CODEASSIST_VISIBILITY_CHECK = PLUGIN_ID
657 + ".codeComplete.visibilityCheck"; //$NON-NLS-1$
660 * Possible configurable option ID.
662 * @see #getDefaultOptions
665 public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID
666 + ".codeComplete.forceImplicitQualification"; //$NON-NLS-1$
669 * Possible configurable option ID.
671 * @see #getDefaultOptions
674 public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID
675 + ".codeComplete.fieldPrefixes"; //$NON-NLS-1$
678 * Possible configurable option ID.
680 * @see #getDefaultOptions
683 public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID
684 + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
687 * Possible configurable option ID.
689 * @see #getDefaultOptions
692 public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID
693 + ".codeComplete.localPrefixes"; //$NON-NLS-1$
696 * Possible configurable option ID.
698 * @see #getDefaultOptions
701 public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID
702 + ".codeComplete.argumentPrefixes"; //$NON-NLS-1$
705 * Possible configurable option ID.
707 * @see #getDefaultOptions
710 public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID
711 + ".codeComplete.fieldSuffixes"; //$NON-NLS-1$
714 * Possible configurable option ID.
716 * @see #getDefaultOptions
719 public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID
720 + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
723 * Possible configurable option ID.
725 * @see #getDefaultOptions
728 public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID
729 + ".codeComplete.localSuffixes"; //$NON-NLS-1$
732 * Possible configurable option ID.
734 * @see #getDefaultOptions
737 public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID
738 + ".codeComplete.argumentSuffixes"; //$NON-NLS-1$
740 // *************** Possible values for configurable options.
741 // ********************
744 * Possible configurable option value.
746 * @see #getDefaultOptions
748 public static final String GENERATE = "generate"; //$NON-NLS-1$
751 * Possible configurable option value.
753 * @see #getDefaultOptions
755 public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
758 * Possible configurable option value.
760 * @see #getDefaultOptions
762 public static final String PRESERVE = "preserve"; //$NON-NLS-1$
765 * Possible configurable option value.
767 * @see #getDefaultOptions
769 public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
772 * Possible configurable option value.
774 * @see #getDefaultOptions
776 public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$
779 * Possible configurable option value.
781 * @see #getDefaultOptions
783 public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$
786 * Possible configurable option value.
788 * @see #getDefaultOptions
791 public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
794 * Possible configurable option value.
796 * @see #getDefaultOptions
799 public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
802 * Possible configurable option value.
804 * @see #getDefaultOptions
807 public static final String ABORT = "abort"; //$NON-NLS-1$
810 * Possible configurable option value.
812 * @see #getDefaultOptions
814 public static final String ERROR = "error"; //$NON-NLS-1$
817 * Possible configurable option value.
819 * @see #getDefaultOptions
821 public static final String WARNING = "warning"; //$NON-NLS-1$
824 * Possible configurable option value.
826 * @see #getDefaultOptions
828 public static final String IGNORE = "ignore"; //$NON-NLS-1$
831 * Possible configurable option value.
833 * @see #getDefaultOptions
835 public static final String COMPUTE = "compute"; //$NON-NLS-1$
838 * Possible configurable option value.
840 * @see #getDefaultOptions
845 * Returns a table of all known configurable options with their default
846 * values. These options allow to configure the behaviour of the underlying
847 * components. The client may safely use the result as a template that they
848 * can modify and then pass to <code>setOptions</code>.
850 * Helper constants have been defined on JavaCore for each of the option ID
851 * and their possible constant values.
853 * Note: more options might be added in further releases.
857 * RECOGNIZED OPTIONS:
858 * COMPILER / Generating Local Variable Debug Attribute
859 * When generated, this attribute will enable local variable names
860 * to be displayed in debugger, only in place where variables are
861 * definitely assigned (.class file is then bigger)
862 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.localVariable"
863 * - possible values: { "generate", "do not generate" }
864 * - default: "generate"
866 * COMPILER / Generating Line Number Debug Attribute
867 * When generated, this attribute will enable source code highlighting in debugger
868 * (.class file is then bigger).
869 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.lineNumber"
870 * - possible values: { "generate", "do not generate" }
871 * - default: "generate"
873 * COMPILER / Generating Source Debug Attribute
874 * When generated, this attribute will enable the debugger to present the
875 * corresponding source code.
876 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.sourceFile"
877 * - possible values: { "generate", "do not generate" }
878 * - default: "generate"
880 * COMPILER / Preserving Unused Local Variables
881 * Unless requested to preserve unused local variables (i.e. never read), the
882 * compiler will optimize them out, potentially altering debugging
883 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.unusedLocal"
884 * - possible values: { "preserve", "optimize out" }
885 * - default: "preserve"
887 * COMPILER / Defining Target Java Platform
888 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
889 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
890 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.targetPlatform"
891 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
892 * - default: "1.1"
894 * COMPILER / Reporting Unreachable Code
895 * Unreachable code can optionally be reported as an error, warning or simply
896 * ignored. The bytecode generation will always optimized it out.
897 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unreachableCode"
898 * - possible values: { "error", "warning", "ignore" }
899 * - default: "error"
901 * COMPILER / Reporting Invalid Import
902 * An import statement that cannot be resolved might optionally be reported
903 * as an error, as a warning or ignored.
904 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.invalidImport"
905 * - possible values: { "error", "warning", "ignore" }
906 * - default: "error"
908 * COMPILER / Reporting Attempt to Override Package-Default Method
909 * A package default method is not visible in a different package, and thus
910 * cannot be overridden. When enabling this option, the compiler will signal
911 * such scenarii either as an error or a warning.
912 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
913 * - possible values: { "error", "warning", "ignore" }
914 * - default: "warning"
916 * COMPILER / Reporting Method With Constructor Name
917 * Naming a method with a constructor name is generally considered poor
918 * style programming. When enabling this option, the compiler will signal such
919 * scenarii either as an error or a warning.
920 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.methodWithConstructorName"
921 * - possible values: { "error", "warning", "ignore" }
922 * - default: "warning"
924 * COMPILER / Reporting Deprecation
925 * When enabled, the compiler will signal use of deprecated API either as an
926 * error or a warning.
927 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecation"
928 * - possible values: { "error", "warning", "ignore" }
929 * - default: "warning"
931 * COMPILER / Reporting Deprecation Inside Deprecated Code
932 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
933 * The severity of the problem is controlled with option "org.phpeclipse.phpdt.core.compiler.problem.deprecation".
934 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
935 * - possible values: { "enabled", "disabled" }
936 * - default: "disabled"
938 * COMPILER / Reporting Hidden Catch Block
939 * Locally to a try statement, some catch blocks may hide others , e.g.
940 * try { throw new java.io.CharConversionException();
941 * } catch (java.io.CharConversionException e) {
942 * } catch (java.io.IOException e) {}.
943 * When enabling this option, the compiler will issue an error or a warning for hidden
944 * catch blocks corresponding to checked exceptions
945 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.hiddenCatchBlock"
946 * - possible values: { "error", "warning", "ignore" }
947 * - default: "warning"
949 * COMPILER / Reporting Unused Local
950 * When enabled, the compiler will issue an error or a warning for unused local
951 * variables (i.e. variables never read from)
952 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedLocal"
953 * - possible values: { "error", "warning", "ignore" }
954 * - default: "ignore"
956 * COMPILER / Reporting Unused Parameter
957 * When enabled, the compiler will issue an error or a warning for unused method
958 * parameters (i.e. parameters never read from)
959 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedParameter"
960 * - possible values: { "error", "warning", "ignore" }
961 * - default: "ignore"
963 * COMPILER / Reporting Unused Import
964 * When enabled, the compiler will issue an error or a warning for unused import
966 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedImport"
967 * - possible values: { "error", "warning", "ignore" }
968 * - default: "warning"
970 * COMPILER / Reporting Synthetic Access Emulation
971 * When enabled, the compiler will issue an error or a warning whenever it emulates
972 * access to a non-accessible member of an enclosing type. Such access can have
973 * performance implications.
974 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.syntheticAccessEmulation"
975 * - possible values: { "error", "warning", "ignore" }
976 * - default: "ignore"
978 * COMPILER / Reporting Non-Externalized String Literal
979 * When enabled, the compiler will issue an error or a warning for non externalized
980 * String literal (i.e. non tagged with //$NON-NLS-<n>$).
981 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
982 * - possible values: { "error", "warning", "ignore" }
983 * - default: "ignore"
985 * COMPILER / Reporting Usage of 'assert' Identifier
986 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
987 * used as an identifier (reserved keyword in 1.4)
988 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.assertIdentifier"
989 * - possible values: { "error", "warning", "ignore" }
990 * - default: "ignore"
992 * COMPILER / Reporting Usage of expression receiver on static invocation/field access
993 * When enabled, the compiler will issue an error or a warning whenever a static field
994 * or method is accessed with an expression receiver.
995 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.staticAccessReceiver"
996 * - possible values: { "error", "warning", "ignore" }
997 * - default: "warning"
999 * COMPILER / Reporting Assignment with no effect
1000 * When enabled, the compiler will issue an error or a warning whenever an assignment
1001 * has no effect (e.g 'x = x').
1002 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.noEffectAssignment"
1003 * - possible values: { "error", "warning", "ignore" }
1004 * - default: "warning"
1006 * COMPILER / Setting Source Compatibility Mode
1007 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
1008 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
1009 * level should be set to "1.4" and the compliance mode should be "1.4".
1010 * - option id: "org.phpeclipse.phpdt.core.compiler.source"
1011 * - possible values: { "1.3", "1.4" }
1012 * - default: "1.3"
1014 * COMPILER / Setting Compliance Level
1015 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
1016 * should not go beyond "1.3" level.
1017 * - option id: "org.phpeclipse.phpdt.core.compiler.compliance"
1018 * - possible values: { "1.3", "1.4" }
1019 * - default: "1.3"
1021 * COMPILER / Maximum number of problems reported per compilation unit
1022 * Specify the maximum number of problems reported on each compilation unit.
1023 * - option id: "org.phpeclipse.phpdt.core.compiler.maxProblemPerUnit"
1024 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
1025 * - default: "100"
1027 * COMPILER / Define the Automatic Task Tags
1028 * When the tag is non empty, the compiler will issue a task marker whenever it encounters
1029 * one of the corresponding tag inside any comment in Java source code.
1030 * Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed.
1031 * - option id: "org.phpeclipse.phpdt.core.compiler.taskTags"
1032 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card
1033 * - default: ""
1034 * COMPILER / Define the Automatic Task Priorities
1035 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
1036 * of the task markers issued by the compiler.
1037 * If the default is specified, the priority of each task marker is "NORMAL".
1038 * - option id: "org.phpeclipse.phpdt.core.compiler.taskPriorities"
1039 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
1040 * - default: ""
1042 * BUILDER / Specifying Filters for Resource Copying Control
1043 * Allow to specify some filters to control the resource copy process.
1044 * - option id: "org.phpeclipse.phpdt.core.builder.resourceCopyExclusionFilter"
1045 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
1046 * or the name of a folder which ends with '/'
1047 * - default: ""
1049 * BUILDER / Abort if Invalid Classpath
1050 * Allow to toggle the builder to abort if the classpath is invalid
1051 * - option id: "org.phpeclipse.phpdt.core.builder.invalidClasspath"
1052 * - possible values: { "abort", "ignore" }
1053 * - default: "ignore"
1055 * BUILDER / Cleaning Output Folder(s)
1056 * Indicate whether the JavaBuilder is allowed to clean the output folders
1057 * when performing full build operations.
1058 * - option id: "org.phpeclipse.phpdt.core.builder.cleanOutputFolder"
1059 * - possible values: { "clean", "ignore" }
1060 * - default: "clean"
1062 * JAVACORE / Computing Project Build Order
1063 * Indicate whether JavaCore should enforce the project build order to be based on
1064 * the classpath prerequisite chain. When requesting to compute, this takes over
1065 * the platform default order (based on project references).
1066 * - option id: "org.phpeclipse.phpdt.core.computeJavaBuildOrder"
1067 * - possible values: { "compute", "ignore" }
1068 * - default: "ignore"
1070 * JAVACORE / Specify Default Source Encoding Format
1071 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
1072 * to 'ResourcesPlugin.getEncoding()'.
1073 * - option id: "org.phpeclipse.phpdt.core.encoding"
1074 * - possible values: { any of the supported encoding name}.
1075 * - default: <platform default>
1077 * JAVACORE / Reporting Incomplete Classpath
1078 * An entry on the classpath doesn't exist or is not visible (e.g. a referenced project is closed).
1079 * - option id: "org.phpeclipse.phpdt.core.incompleteClasspath"
1080 * - possible values: { "error", "warning"}
1081 * - default: "error"
1083 * JAVACORE / Reporting Classpath Cycle
1084 * A project is involved in a cycle.
1085 * - option id: "org.phpeclipse.phpdt.core.circularClasspath"
1086 * - possible values: { "error", "warning" }
1087 * - default: "error"
1089 * FORMATTER / Inserting New Line Before Opening Brace
1090 * When Insert, a new line is inserted before an opening brace, otherwise nothing
1092 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.openingBrace"
1093 * - possible values: { "insert", "do not insert" }
1094 * - default: "do not insert"
1096 * FORMATTER / Inserting New Line Inside Control Statement
1097 * When Insert, a new line is inserted between } and following else, catch, finally
1098 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.controlStatement"
1099 * - possible values: { "insert", "do not insert" }
1100 * - default: "do not insert"
1102 * FORMATTER / Clearing Blank Lines
1103 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
1104 * and all others removed.
1105 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.clearAll"
1106 * - possible values: { "clear all", "preserve one" }
1107 * - default: "preserve one"
1109 * FORMATTER / Inserting New Line Between Else/If
1110 * When Insert, a blank line is inserted between an else and an if when they are
1111 * contiguous. When choosing to not insert, else-if will be kept on the same
1112 * line when possible.
1113 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.elseIf"
1114 * - possible values: { "insert", "do not insert" }
1115 * - default: "do not insert"
1117 * FORMATTER / Inserting New Line In Empty Block
1118 * When insert, a line break is inserted between contiguous { and }, if } is not followed
1120 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.emptyBlock"
1121 * - possible values: { "insert", "do not insert" }
1122 * - default: "insert"
1124 * FORMATTER / Splitting Lines Exceeding Length
1125 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
1126 * disable line splitting
1127 * - option id: "org.phpeclipse.phpdt.core.formatter.lineSplit"
1128 * - possible values: "<n>", where n is zero or a positive integer
1129 * - default: "80"
1131 * FORMATTER / Compacting Assignment
1132 * Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space
1133 * is inserted before the assignment operator
1134 * - option id: "org.phpeclipse.phpdt.core.formatter.style.assignment"
1135 * - possible values: { "compact", "normal" }
1136 * - default: "normal"
1138 * FORMATTER / Defining Indentation Character
1139 * Either choose to indent with tab characters or spaces
1140 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.char"
1141 * - possible values: { "tab", "space" }
1142 * - default: "tab"
1144 * FORMATTER / Defining Space Indentation Length
1145 * When using spaces, set the amount of space characters to use for each
1147 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.size"
1148 * - possible values: "<n>", where n is a positive integer
1149 * - default: "4"
1151 * CODEASSIST / Activate Visibility Sensitive Completion
1152 * When active, completion doesn't show that you can not see
1153 * (e.g. you can not see private methods of a super class).
1154 * - option id: "org.phpeclipse.phpdt.core.codeComplete.visibilityCheck"
1155 * - possible values: { "enabled", "disabled" }
1156 * - default: "disabled"
1158 * CODEASSIST / Automatic Qualification of Implicit Members
1159 * When active, completion automatically qualifies completion on implicit
1160 * field references and message expressions.
1161 * - option id: "org.phpeclipse.phpdt.core.codeComplete.forceImplicitQualification"
1162 * - possible values: { "enabled", "disabled" }
1163 * - default: "disabled"
1165 * CODEASSIST / Define the Prefixes for Field Name
1166 * When the prefixes is non empty, completion for field name will begin with
1167 * one of the proposed prefixes.
1168 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldPrefixes"
1169 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1170 * - default: ""
1172 * CODEASSIST / Define the Prefixes for Static Field Name
1173 * When the prefixes is non empty, completion for static field name will begin with
1174 * one of the proposed prefixes.
1175 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldPrefixes"
1176 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1177 * - default: ""
1179 * CODEASSIST / Define the Prefixes for Local Variable Name
1180 * When the prefixes is non empty, completion for local variable name will begin with
1181 * one of the proposed prefixes.
1182 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localPrefixes"
1183 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1184 * - default: ""
1186 * CODEASSIST / Define the Prefixes for Argument Name
1187 * When the prefixes is non empty, completion for argument name will begin with
1188 * one of the proposed prefixes.
1189 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentPrefixes"
1190 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1191 * - default: ""
1193 * CODEASSIST / Define the Suffixes for Field Name
1194 * When the suffixes is non empty, completion for field name will end with
1195 * one of the proposed suffixes.
1196 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldSuffixes"
1197 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1198 * - default: ""
1200 * CODEASSIST / Define the Suffixes for Static Field Name
1201 * When the suffixes is non empty, completion for static field name will end with
1202 * one of the proposed suffixes.
1203 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldSuffixes"
1204 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1205 * - default: ""
1207 * CODEASSIST / Define the Suffixes for Local Variable Name
1208 * When the suffixes is non empty, completion for local variable name will end with
1209 * one of the proposed suffixes.
1210 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localSuffixes"
1211 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1212 * - default: ""
1214 * CODEASSIST / Define the Suffixes for Argument Name
1215 * When the suffixes is non empty, completion for argument name will end with
1216 * one of the proposed suffixes.
1217 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentSuffixes"
1218 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
1219 * - default: ""
1222 * @return a mutable table containing the default settings of all known options
1235 // public static Hashtable getDefaultOptions() {
1237 // Hashtable defaultOptions = new Hashtable(10);
1239 // // see #initializeDefaultPluginPreferences() for changing default
1241 // Preferences preferences = getPlugin().getPluginPreferences();
1242 // HashSet optionNames = OptionNames;
1244 // // get preferences set to their default
1245 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1246 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1247 // String propertyName = defaultPropertyNames[i];
1248 // if (optionNames.contains(propertyName)) {
1249 // defaultOptions.put(propertyName,
1250 // preferences.getDefaultString(propertyName));
1253 // // get preferences not set to their default
1254 // String[] propertyNames = preferences.propertyNames();
1255 // for (int i = 0; i < propertyNames.length; i++) {
1256 // String propertyName = propertyNames[i];
1257 // if (optionNames.contains(propertyName)) {
1258 // defaultOptions.put(propertyName,
1259 // preferences.getDefaultString(propertyName));
1262 // // get encoding through resource plugin
1263 // defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1265 // return defaultOptions;
1268 * Helper method for returning one option value only. Equivalent to
1269 * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
1270 * may answer <code>null</code> if this option does not exist.
1272 * For a complete description of the configurable options, see
1273 * <code>getDefaultOptions</code>.
1277 * the name of an option
1278 * @return the String value of a given option
1279 * @see JavaCore#getDefaultOptions
1282 // public static String getOption(String optionName) {
1284 // if (CORE_ENCODING.equals(optionName)) {
1285 // return ResourcesPlugin.getEncoding();
1287 // if (OptionNames.contains(optionName)) {
1288 // Preferences preferences = getPlugin().getPluginPreferences();
1289 // return preferences.getString(optionName).trim();
1294 * Returns the table of the current options. Initially, all options have
1295 * their default values, and this method returns a table that includes all
1298 * For a complete description of the configurable options, see
1299 * <code>getDefaultOptions</code>.
1302 * @return table of current settings of all options (key type:
1303 * <code>String</code>; value type: <code>String</code>)
1304 * @see JavaCore#getDefaultOptions
1306 // public static Hashtable getOptions() {
1308 // Hashtable options = new Hashtable(10);
1310 // // see #initializeDefaultPluginPreferences() for changing default
1312 // Plugin plugin = getPlugin();
1313 // if (plugin != null) {
1314 // Preferences preferences = getPlugin().getPluginPreferences();
1315 // HashSet optionNames = OptionNames;
1317 // // get preferences set to their default
1318 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1319 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1320 // String propertyName = defaultPropertyNames[i];
1321 // if (optionNames.contains(propertyName)) {
1322 // options.put(propertyName, preferences.getDefaultString(propertyName));
1325 // // get preferences not set to their default
1326 // String[] propertyNames = preferences.propertyNames();
1327 // for (int i = 0; i < propertyNames.length; i++) {
1328 // String propertyName = propertyNames[i];
1329 // if (optionNames.contains(propertyName)) {
1330 // options.put(propertyName, preferences.getString(propertyName).trim());
1333 // // get encoding through resource plugin
1334 // options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1339 * Sets the current table of options. All and only the options explicitly
1340 * included in the given table are remembered; all previous option settings
1341 * are forgotten, including ones not explicitly mentioned.
1343 * For a complete description of the configurable options, see
1344 * <code>getDefaultOptions</code>.
1348 * the new options (key type: <code>String</code>; value type:
1349 * <code>String</code>), or <code>null</code> to reset all
1350 * options to their default values
1351 * @see JavaCore#getDefaultOptions
1353 // public static void setOptions(Hashtable newOptions) {
1355 // // see #initializeDefaultPluginPreferences() for changing default
1357 // Preferences preferences = getPlugin().getPluginPreferences();
1359 // if (newOptions == null) {
1360 // newOptions = getDefaultOptions();
1362 // Enumeration keys = newOptions.keys();
1363 // while (keys.hasMoreElements()) {
1364 // String key = (String) keys.nextElement();
1365 // if (!OptionNames.contains(key))
1366 // continue; // unrecognized option
1367 // if (key.equals(CORE_ENCODING))
1368 // continue; // skipped, contributed by resource prefs
1369 // String value = (String) newOptions.get(key);
1370 // preferences.setValue(key, value);
1373 // // persist options
1374 // getPlugin().savePluginPreferences();
1376 public static IProject[] getPHPProjects() {
1377 List phpProjectsList = new ArrayList();
1378 IProject[] workspaceProjects = PHPeclipsePlugin.getWorkspace()
1379 .getRoot().getProjects();
1381 for (int i = 0; i < workspaceProjects.length; i++) {
1382 IProject iProject = workspaceProjects[i];
1383 if (isPHPProject(iProject))
1384 phpProjectsList.add(iProject);
1387 IProject[] phpProjects = new IProject[phpProjectsList.size()];
1388 return (IProject[]) phpProjectsList.toArray(phpProjects);
1391 // public static PHPProject getPHPProject(String name) {
1392 // IProject aProject =
1393 // PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
1394 // if (isPHPProject(aProject)) {
1395 // PHPProject thePHPProject = new PHPProject();
1396 // thePHPProject.setProject(aProject);
1397 // return thePHPProject;
1402 public static boolean isPHPProject(IProject aProject) {
1404 return aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID);
1405 } catch (CoreException e) {
1411 // public static PHPFile create(IFile aFile) {
1412 // if (PHPFile.EXTENSION.equalsIgnoreCase(aFile.getFileExtension()))
1413 // return new PHPFile(aFile);
1414 // if (PHPFile.EXTENSION1.equalsIgnoreCase(aFile.getFileExtension()))
1415 // return new PHPFile(aFile);
1416 // if (PHPFile.EXTENSION2.equalsIgnoreCase(aFile.getFileExtension()))
1417 // return new PHPFile(aFile);
1418 // if (PHPFile.EXTENSION3.equalsIgnoreCase(aFile.getFileExtension()))
1419 // return new PHPFile(aFile);
1420 // if (PHPFile.EXTENSION4.equalsIgnoreCase(aFile.getFileExtension()))
1421 // return new PHPFile(aFile);
1422 // if (PHPFile.EXTENSION5.equalsIgnoreCase(aFile.getFileExtension()))
1423 // return new PHPFile(aFile);
1428 // public static PHPProject create(IProject aProject) {
1431 // if (aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1432 // PHPProject project = new PHPProject();
1433 // project.setProject(aProject);
1436 // } catch (CoreException e) {
1437 // System.err.println("Exception occurred in PHPCore#create(IProject): " +
1444 public static void addPHPNature(IProject project, IProgressMonitor monitor)
1445 throws CoreException {
1446 if (!project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1447 IProjectDescription description = project.getDescription();
1448 String[] prevNatures = description.getNatureIds();
1449 String[] newNatures = new String[prevNatures.length + 1];
1450 System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
1451 newNatures[prevNatures.length] = PHPeclipsePlugin.PHP_NATURE_ID;
1452 description.setNatureIds(newNatures);
1453 project.setDescription(description, monitor);
1458 * Returns the single instance of the PHP core plug-in runtime class.
1460 * @return the single instance of the PHP core plug-in runtime class
1462 public static Plugin getPlugin() {
1463 return PHPeclipsePlugin.getDefault();
1467 * Runs the given action as an atomic Java model operation.
1469 * After running a method that modifies java elements, registered listeners
1470 * receive after-the-fact notification of what just transpired, in the form
1471 * of a element changed event. This method allows clients to call a number
1472 * of methods that modify java elements and only have element changed event
1473 * notifications reported at the end of the entire batch.
1476 * If this method is called outside the dynamic scope of another such call,
1477 * this method runs the action and then reports a single element changed
1478 * event describing the net effect of all changes done to java elements by
1482 * If this method is called in the dynamic scope of another such call, this
1483 * method simply runs the action.
1487 * the action to perform
1489 * a progress monitor, or <code>null</code> if progress
1490 * reporting and cancellation are not desired
1491 * @exception CoreException
1492 * if the operation failed.
1495 // public static void run(IWorkspaceRunnable action, IProgressMonitor
1496 // monitor) throws CoreException {
1497 // run(action, ResourcesPlugin.getWorkspace().getRoot(), monitor);
1500 * Runs the given action as an atomic Java model operation.
1502 * After running a method that modifies java elements, registered listeners
1503 * receive after-the-fact notification of what just transpired, in the form
1504 * of a element changed event. This method allows clients to call a number
1505 * of methods that modify java elements and only have element changed event
1506 * notifications reported at the end of the entire batch.
1509 * If this method is called outside the dynamic scope of another such call,
1510 * this method runs the action and then reports a single element changed
1511 * event describing the net effect of all changes done to java elements by
1515 * If this method is called in the dynamic scope of another such call, this
1516 * method simply runs the action.
1519 * The supplied scheduling rule is used to determine whether this operation
1520 * can be run simultaneously with workspace changes in other threads. See
1521 * <code>IWorkspace.run(...)</code> for more details.
1525 * the action to perform
1527 * the scheduling rule to use when running this operation, or
1528 * <code>null</code> if there are no scheduling restrictions
1529 * for this operation.
1531 * a progress monitor, or <code>null</code> if progress
1532 * reporting and cancellation are not desired
1533 * @exception CoreException
1534 * if the operation failed.
1537 // public static void run(IWorkspaceRunnable action, ISchedulingRule rule,
1538 // IProgressMonitor monitor) throws CoreException {
1539 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
1540 // if (workspace.isTreeLocked()) {
1541 // new BatchOperation(action).run(monitor);
1543 // // use IWorkspace.run(...) to ensure that a build will be done in
1545 // workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE,
1550 * Adds the given listener for changes to Java elements. Has no effect if an
1551 * identical listener is already registered.
1553 * This listener will only be notified during the POST_CHANGE resource
1554 * change notification and any reconcile operation (POST_RECONCILE). For
1555 * finer control of the notification, use
1556 * <code>addElementChangedListener(IElementChangedListener,int)</code>,
1557 * which allows to specify a different eventMask.
1559 * @see ElementChangedEvent
1563 public static void addElementChangedListener(
1564 IElementChangedListener listener) {
1565 addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE
1566 | ElementChangedEvent.POST_RECONCILE);
1570 * Adds the given listener for changes to Java elements. Has no effect if an
1571 * identical listener is already registered. After completion of this
1572 * method, the given listener will be registered for exactly the specified
1573 * events. If they were previously registered for other events, they will be
1576 * Once registered, a listener starts receiving notification of changes to
1577 * java elements in the model. The listener continues to receive
1578 * notifications until it is replaced or removed.
1581 * Listeners can listen for several types of event as defined in
1582 * <code>ElementChangeEvent</code>. Clients are free to register for any
1583 * number of event types however if they register for more than one, it is
1584 * their responsibility to ensure they correctly handle the case where the
1585 * same java element change shows up in multiple notifications. Clients are
1586 * guaranteed to receive only the events for which they are registered.
1592 * the bit-wise OR of all event types of interest to the listener
1593 * @see IElementChangedListener
1594 * @see ElementChangedEvent
1595 * @see #removeElementChangedListener(IElementChangedListener)
1598 public static void addElementChangedListener(
1599 IElementChangedListener listener, int eventMask) {
1600 JavaModelManager.getJavaModelManager().addElementChangedListener(
1601 listener, eventMask);
1605 * Configures the given marker attribute map for the given Java element.
1606 * Used for markers, which denote a Java element rather than a resource.
1609 * the mutable marker attribute map (key type:
1610 * <code>String</code>, value type: <code>String</code>)
1612 * the Java element for which the marker needs to be configured
1614 public static void addJavaElementMarkerAttributes(Map attributes,
1615 IJavaElement element) {
1616 // if (element instanceof IMember)
1617 // element = ((IMember) element).getClassFile();
1618 if (attributes != null && element != null)
1619 attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier());
1623 * Adds the given listener for POST_CHANGE resource change events to the
1624 * Java core. The listener is guarantied to be notified of the POST_CHANGE
1625 * resource change event before the Java core starts processing the resource
1626 * change event itself.
1628 * Has no effect if an identical listener is already registered.
1633 * @see #removePreProcessingResourceChangedListener(IResourceChangeListener)
1636 public static void addPreProcessingResourceChangedListener(
1637 IResourceChangeListener listener) {
1638 JavaModelManager.getJavaModelManager().deltaState
1639 .addPreResourceChangedListener(listener);
1643 * Configures the given marker for the given Java element. Used for markers,
1644 * which denote a Java element rather than a resource.
1647 * the marker to be configured
1649 * the Java element for which the marker needs to be configured
1650 * @exception CoreException
1651 * if the <code>IMarker.setAttribute</code> on the marker
1654 public void configureJavaElementMarker(IMarker marker, IJavaElement element)
1655 throws CoreException {
1656 // if (element instanceof IMember)
1657 // element = ((IMember) element).getClassFile();
1658 if (marker != null && element != null)
1659 marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier());
1663 * Returns the Java model element corresponding to the given handle
1664 * identifier generated by <code>IJavaElement.getHandleIdentifier()</code>,
1665 * or <code>null</code> if unable to create the associated element.
1667 public static IJavaElement create(String handleIdentifier) {
1668 if (handleIdentifier == null) {
1672 return JavaModelManager.getJavaModelManager().getHandleFromMemento(
1674 } catch (JavaModelException e) {
1680 * Returns the Java model element corresponding to the given handle
1681 * identifier generated by <code>IJavaElement.getHandleIdentifier()</code>,
1682 * or <code>null</code> if unable to create the associated element. If the
1683 * returned Java element is an <code>ICompilationUnit</code>, its owner
1684 * is the given owner if such a working copy exists, otherwise the
1685 * compilation unit is a primary compilation unit.
1687 * @param handleIdentifier
1688 * the given handle identifier
1690 * the owner of the returned compilation unit, ignored if the
1691 * returned element is not a compilation unit
1692 * @return the Java element corresponding to the handle identifier
1695 public static IJavaElement create(String handleIdentifier,
1696 WorkingCopyOwner owner) {
1697 if (handleIdentifier == null) {
1700 MementoTokenizer memento = new MementoTokenizer(handleIdentifier);
1701 JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel();
1702 return model.getHandleFromMemento(memento, owner);
1706 * Returns the Java element corresponding to the given file, or
1707 * <code>null</code> if unable to associate the given file with a Java
1711 * The file must be one of:
1713 * <li>a <code>.java</code> file - the element returned is the
1714 * corresponding <code>ICompilationUnit</code></li>
1715 * <li>a <code>.class</code> file - the element returned is the
1716 * corresponding <code>IClassFile</code></li>
1717 * <li>a <code>.jar</code> file - the element returned is the
1718 * corresponding <code>IPackageFragmentRoot</code></li>
1721 * Creating a Java element has the side effect of creating and opening all
1722 * of the element's parents if they are not yet open.
1726 * @return the Java element corresponding to the given file, or
1727 * <code>null</code> if unable to associate the given file with a
1730 public static IJavaElement create(IFile file) {
1731 return JavaModelManager.create(file, null);
1735 * Returns the package fragment or package fragment root corresponding to
1736 * the given folder, or <code>null</code> if unable to associate the given
1737 * folder with a Java element.
1739 * Note that a package fragment root is returned rather than a default
1742 * Creating a Java element has the side effect of creating and opening all
1743 * of the element's parents if they are not yet open.
1747 * @return the package fragment or package fragment root corresponding to
1748 * the given folder, or <code>null</code> if unable to associate
1749 * the given folder with a Java element
1751 public static IJavaElement create(IFolder folder) {
1752 return JavaModelManager.create(folder, null);
1756 * Returns the Java project corresponding to the given project.
1758 * Creating a Java Project has the side effect of creating and opening all
1759 * of the project's parents if they are not yet open.
1761 * Note that no check is done at this time on the existence or the java
1762 * nature of this project.
1766 * @return the Java project corresponding to the given project, null if the
1767 * given project is null
1769 public static IJavaProject create(IProject project) {
1770 if (project == null) {
1773 JavaModel javaModel = JavaModelManager.getJavaModelManager()
1775 return javaModel.getJavaProject(project);
1779 * Returns the Java element corresponding to the given resource, or
1780 * <code>null</code> if unable to associate the given resource with a Java
1783 * The resource must be one of:
1785 * <li>a project - the element returned is the corresponding
1786 * <code>IJavaProject</code></li>
1787 * <li>a <code>.java</code> file - the element returned is the
1788 * corresponding <code>ICompilationUnit</code></li>
1789 * <li>a <code>.class</code> file - the element returned is the
1790 * corresponding <code>IClassFile</code></li>
1791 * <li>a <code>.jar</code> file - the element returned is the
1792 * corresponding <code>IPackageFragmentRoot</code></li>
1793 * <li>a folder - the element returned is the corresponding
1794 * <code>IPackageFragmentRoot</code> or <code>IPackageFragment</code>
1796 * <li>the workspace root resource - the element returned is the
1797 * <code>IJavaModel</code></li>
1800 * Creating a Java element has the side effect of creating and opening all
1801 * of the element's parents if they are not yet open.
1804 * the given resource
1805 * @return the Java element corresponding to the given resource, or
1806 * <code>null</code> if unable to associate the given resource
1807 * with a Java element
1809 public static IJavaElement create(IResource resource) {
1810 return JavaModelManager.create(resource, null);
1814 * Returns the Java model.
1818 * @return the Java model, or <code>null</code> if the root is null
1820 public static IJavaModel create(IWorkspaceRoot root) {
1824 return JavaModelManager.getJavaModelManager().getJavaModel();
1828 * Creates and returns a class file element for the given
1829 * <code>.class</code> file. Returns <code>null</code> if unable to
1830 * recognize the class file.
1833 * the given <code>.class</code> file
1834 * @return a class file element for the given <code>.class</code> file, or
1835 * <code>null</code> if unable to recognize the class file
1837 // public static IClassFile createClassFileFrom(IFile file) {
1838 // return JavaModelManager.createClassFileFrom(file, null);
1841 * Creates and returns a compilation unit element for the given
1842 * <code>.java</code> file. Returns <code>null</code> if unable to
1843 * recognize the compilation unit.
1846 * the given <code>.java</code> file
1847 * @return a compilation unit element for the given <code>.java</code>
1848 * file, or <code>null</code> if unable to recognize the
1851 public static ICompilationUnit createCompilationUnitFrom(IFile file) {
1852 return JavaModelManager.createCompilationUnitFrom(file, null);
1856 * Creates and returns a handle for the given JAR file. The Java model
1857 * associated with the JAR's project may be created as a side effect.
1860 * the given JAR file
1861 * @return a handle for the given JAR file, or <code>null</code> if unable
1862 * to create a JAR package fragment root. (for example, if the JAR
1863 * file represents a non-Java resource)
1865 // public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile
1867 // return JavaModelManager.createJarPackageFragmentRootFrom(file, null);
1870 * Answers the project specific value for a given classpath container. In
1871 * case this container path could not be resolved, then will answer
1872 * <code>null</code>. Both the container path and the project context are
1873 * supposed to be non-null.
1875 * The containerPath is a formed by a first ID segment followed with extra
1876 * segments, which can be used as additional hints for resolution. If no
1877 * container was ever recorded for this container path onto this project
1878 * (using <code>setClasspathContainer</code>, then a
1879 * <code>ClasspathContainerInitializer</code> will be activated if any was
1880 * registered for this container ID onto the extension point
1881 * "net.sourceforge.phpdt.core.classpathContainerInitializer".
1883 * There is no assumption that the returned container must answer the exact
1884 * same containerPath when requested
1885 * <code>IClasspathContainer#getPath</code>. Indeed, the containerPath is
1886 * just an indication for resolving it to an actual container object.
1888 * Classpath container values are persisted locally to the workspace, but
1889 * are not preserved from a session to another. It is thus highly
1890 * recommended to register a <code>ClasspathContainerInitializer</code>
1891 * for each referenced container (through the extension point
1892 * "net.sourceforge.phpdt.core.ClasspathContainerInitializer").
1895 * @param containerPath
1896 * the name of the container, which needs to be resolved
1898 * a specific project in which the container is being resolved
1899 * @return the corresponding classpath container or <code>null</code> if
1900 * unable to find one.
1902 * @exception JavaModelException
1903 * if an exception occurred while resolving the container, or
1904 * if the resolved container contains illegal entries
1905 * (contains CPE_CONTAINER entries or null entries).
1907 * @see ClasspathContainerInitializer
1908 * @see IClasspathContainer
1909 * @see #setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[],
1913 // public static IClasspathContainer getClasspathContainer(final IPath
1914 // containerPath, final IJavaProject project) throws JavaModelException {
1916 // IClasspathContainer container = JavaModelManager.containerGet(project,
1918 // if (container == JavaModelManager.ContainerInitializationInProgress)
1919 // return null; // break cycle
1921 // if (container == null){
1922 // final ClasspathContainerInitializer initializer =
1923 // JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
1924 // if (initializer != null){
1925 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1926 // System.out.println("CPContainer INIT - triggering initialization of:
1927 // ["+project.getElementName()+"] " + containerPath + " using initializer:
1928 // "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
1929 // new Exception("FAKE exception for dumping current CPContainer
1930 // (["+project.getElementName()+"] "+ containerPath+ ")INIT invocation stack
1931 // trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
1933 // JavaModelManager.containerPut(project, containerPath,
1934 // JavaModelManager.ContainerInitializationInProgress); // avoid
1935 // initialization cycles
1936 // boolean ok = false;
1938 // // wrap initializer call with Safe runnable in case initializer would be
1939 // causing some grief
1940 // Platform.run(new ISafeRunnable() {
1941 // public void handleException(Throwable exception) {
1942 // ProjectPrefUtil.log(exception, "Exception occurred in classpath container
1943 // initializer: "+initializer); //$NON-NLS-1$
1945 // public void run() throws Exception {
1946 // initializer.initialize(containerPath, project);
1950 // // retrieve value (if initialization was successful)
1951 // container = JavaModelManager.containerGet(project, containerPath);
1952 // if (container == JavaModelManager.ContainerInitializationInProgress)
1953 // return null; // break cycle
1956 // if (!ok) JavaModelManager.containerPut(project, containerPath, null); //
1959 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1960 // System.out.print("CPContainer INIT - after resolution:
1961 // ["+project.getElementName()+"] " + containerPath + " --> ");
1962 // //$NON-NLS-2$//$NON-NLS-1$//$NON-NLS-3$
1963 // if (container != null){
1964 // System.out.print("container: "+container.getDescription()+" {");
1965 // //$NON-NLS-2$//$NON-NLS-1$
1966 // IClasspathEntry[] entries = container.getClasspathEntries();
1967 // if (entries != null){
1968 // for (int i = 0; i < entries.length; i++){
1969 // if (i > 0) System.out.println(", ");//$NON-NLS-1$
1970 // System.out.println(entries[i]);
1973 // System.out.println("}");//$NON-NLS-1$
1975 // System.out.println("{unbound}");//$NON-NLS-1$
1979 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1980 // System.out.println("CPContainer INIT - no initializer found for:
1981 // "+project.getElementName()+"] " + containerPath); //$NON-NLS-1$
1986 // return container;
1989 * Helper method finding the classpath container initializer registered for
1990 * a given classpath container ID or <code>null</code> if none was found
1991 * while iterating over the contributions to extension point to the
1993 * "net.sourceforge.phpdt.core.classpathContainerInitializer".
1995 * A containerID is the first segment of any container path, used to
1996 * identify the registered container initializer.
2000 * a containerID identifying a registered initializer
2001 * @return ClasspathContainerInitializer - the registered classpath
2002 * container initializer or <code>null</code> if none was found.
2005 // public static ClasspathContainerInitializer
2006 // getClasspathContainerInitializer(String containerID){
2008 // Plugin jdtCorePlugin = JavaCore.getPlugin();
2009 // if (jdtCorePlugin == null) return null;
2011 // IExtensionPoint extension =
2012 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID);
2013 // if (extension != null) {
2014 // IExtension[] extensions = extension.getExtensions();
2015 // for(int i = 0; i < extensions.length; i++){
2016 // IConfigurationElement [] configElements =
2017 // extensions[i].getConfigurationElements();
2018 // for(int j = 0; j < configElements.length; j++){
2019 // String initializerID = configElements[j].getAttribute("id");
2021 // if (initializerID != null && initializerID.equals(containerID)){
2022 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
2023 // System.out.println("CPContainer INIT - found initializer: "+containerID
2025 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
2028 // Object execExt = configElements[j].createExecutableExtension("class");
2030 // if (execExt instanceof ClasspathContainerInitializer){
2031 // return (ClasspathContainerInitializer)execExt;
2033 // } catch(CoreException e) {
2042 * Returns the path held in the given classpath variable. Returns <node>null
2043 * </code> if unable to bind.
2045 * Classpath variable values are persisted locally to the workspace, and are
2046 * preserved from session to session.
2048 * Note that classpath variables can be contributed registered initializers
2049 * for, using the extension point
2050 * "net.sourceforge.phpdt.core.classpathVariableInitializer". If an
2051 * initializer is registered for a variable, its persisted value will be
2052 * ignored: its initializer will thus get the opportunity to rebind the
2053 * variable differently on each session.
2055 * @param variableName
2056 * the name of the classpath variable
2057 * @return the path, or <code>null</code> if none
2058 * @see #setClasspathVariable
2060 public static IPath getClasspathVariable(final String variableName) {
2062 IPath variablePath = JavaModelManager.variableGet(variableName);
2063 if (variablePath == JavaModelManager.VariableInitializationInProgress)
2064 return null; // break cycle
2066 if (variablePath != null) {
2067 return variablePath;
2070 // even if persisted value exists, initializer is given priority, only
2071 // if no initializer is found the persisted value is reused
2072 // final ClasspathVariableInitializer initializer =
2073 // PHPCore.getClasspathVariableInitializer(variableName);
2074 // if (initializer != null){
2075 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2076 // System.out.println("CPVariable INIT - triggering initialization of: "
2077 // + variableName+ " using initializer: "+ initializer); //$NON-NLS-1$
2079 // new Exception("FAKE exception for dumping current CPVariable
2080 // ("+variableName+ ")INIT invocation stack trace").printStackTrace();
2081 // //$NON-NLS-1$//$NON-NLS-2$
2083 // JavaModelManager.variablePut(variableName,
2084 // JavaModelManager.VariableInitializationInProgress); // avoid
2085 // initialization cycles
2086 // boolean ok = false;
2088 // // wrap initializer call with Safe runnable in case initializer would
2089 // be causing some grief
2090 // Platform.run(new ISafeRunnable() {
2091 // public void handleException(Throwable exception) {
2092 // ProjectPrefUtil.log(exception, "Exception occurred in classpath
2094 // initializer: "+initializer+" while initializing variable:
2095 // "+variableName); //$NON-NLS-1$ //$NON-NLS-2$
2097 // public void run() throws Exception {
2098 // initializer.initialize(variableName);
2101 // variablePath = (IPath) JavaModelManager.variableGet(variableName); //
2102 // initializer should have performed side-effect
2103 // if (variablePath ==
2104 // JavaModelManager.VariableInitializationInProgress) return null; //
2105 // break cycle (initializer did not init or reentering call)
2106 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2107 // System.out.println("CPVariable INIT - after initialization: " +
2108 // variableName + " --> " + variablePath); //$NON-NLS-2$//$NON-NLS-1$
2112 // if (!ok) JavaModelManager.variablePut(variableName, null); // flush
2116 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2117 // System.out.println("CPVariable INIT - no initializer found for: " +
2118 // variableName); //$NON-NLS-1$
2121 return variablePath;
2125 * Helper method finding the classpath variable initializer registered for a
2126 * given classpath variable name or <code>null</code> if none was found
2127 * while iterating over the contributions to extension point to the
2129 * "net.sourceforge.phpdt.core.classpathVariableInitializer".
2134 * @return ClasspathVariableInitializer - the registered classpath variable
2135 * initializer or <code>null</code> if none was found.
2138 public static ClasspathVariableInitializer getClasspathVariableInitializer(
2141 Plugin jdtCorePlugin = JavaCore.getPlugin();
2142 if (jdtCorePlugin == null)
2145 // IExtensionPoint extension =
2146 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID);
2147 // if (extension != null) {
2148 // IExtension[] extensions = extension.getExtensions();
2149 // for(int i = 0; i < extensions.length; i++){
2150 // IConfigurationElement [] configElements =
2151 // extensions[i].getConfigurationElements();
2152 // for(int j = 0; j < configElements.length; j++){
2154 // String varAttribute = configElements[j].getAttribute("variable");
2156 // if (variable.equals(varAttribute)) {
2157 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
2158 // System.out.println("CPVariable INIT - found initializer: "+variable+"
2160 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
2163 // configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
2164 // if (execExt instanceof ClasspathVariableInitializer){
2165 // return (ClasspathVariableInitializer)execExt;
2168 // } catch(CoreException e){
2177 * Returns the names of all known classpath variables.
2179 * Classpath variable values are persisted locally to the workspace, and are
2180 * preserved from session to session.
2183 * @return the list of classpath variable names
2184 * @see #setClasspathVariable
2186 // public static String[] getClasspathVariableNames() {
2187 // return JavaModelManager.variableNames();
2190 * Returns a table of all known configurable options with their default
2191 * values. These options allow to configure the behaviour of the underlying
2192 * components. The client may safely use the result as a template that they
2193 * can modify and then pass to <code>setOptions</code>.
2195 * Helper constants have been defined on JavaCore for each of the option ID
2196 * and their possible constant values.
2198 * Note: more options might be added in further releases.
2202 * RECOGNIZED OPTIONS:
2203 * COMPILER / Generating Local Variable Debug Attribute
2204 * When generated, this attribute will enable local variable names
2205 * to be displayed in debugger, only in place where variables are
2206 * definitely assigned (.class file is then bigger)
2207 * - option id: "net.sourceforge.phpdt.core.compiler.debug.localVariable"
2208 * - possible values: { "generate", "do not generate" }
2209 * - default: "generate"
2211 * COMPILER / Generating Line Number Debug Attribute
2212 * When generated, this attribute will enable source code highlighting in debugger
2213 * (.class file is then bigger).
2214 * - option id: "net.sourceforge.phpdt.core.compiler.debug.lineNumber"
2215 * - possible values: { "generate", "do not generate" }
2216 * - default: "generate"
2218 * COMPILER / Generating Source Debug Attribute
2219 * When generated, this attribute will enable the debugger to present the
2220 * corresponding source code.
2221 * - option id: "net.sourceforge.phpdt.core.compiler.debug.sourceFile"
2222 * - possible values: { "generate", "do not generate" }
2223 * - default: "generate"
2225 * COMPILER / Preserving Unused Local Variables
2226 * Unless requested to preserve unused local variables (that is, never read), the
2227 * compiler will optimize them out, potentially altering debugging
2228 * - option id: "net.sourceforge.phpdt.core.compiler.codegen.unusedLocal"
2229 * - possible values: { "preserve", "optimize out" }
2230 * - default: "preserve"
2232 * COMPILER / Defining Target Java Platform
2233 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
2234 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
2235 * - option id: "net.sourceforge.phpdt.core.compiler.codegen.targetPlatform"
2236 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
2237 * - default: "1.1"
2239 * COMPILER / Reporting Unreachable Code
2240 * Unreachable code can optionally be reported as an error, warning or simply
2241 * ignored. The bytecode generation will always optimized it out.
2242 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unreachableCode"
2243 * - possible values: { "error", "warning", "ignore" }
2244 * - default: "error"
2246 * COMPILER / Reporting Invalid Import
2247 * An import statement that cannot be resolved might optionally be reported
2248 * as an error, as a warning or ignored.
2249 * - option id: "net.sourceforge.phpdt.core.compiler.problem.invalidImport"
2250 * - possible values: { "error", "warning", "ignore" }
2251 * - default: "error"
2253 * COMPILER / Reporting Attempt to Override Package-Default Method
2254 * A package default method is not visible in a different package, and thus
2255 * cannot be overridden. When enabling this option, the compiler will signal
2256 * such scenarii either as an error or a warning.
2257 * - option id: "net.sourceforge.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
2258 * - possible values: { "error", "warning", "ignore" }
2259 * - default: "warning"
2261 * COMPILER / Reporting Method With Constructor Name
2262 * Naming a method with a constructor name is generally considered poor
2263 * style programming. When enabling this option, the compiler will signal such
2264 * scenarii either as an error or a warning.
2265 * - option id: "net.sourceforge.phpdt.core.compiler.problem.methodWithConstructorName"
2266 * - possible values: { "error", "warning", "ignore" }
2267 * - default: "warning"
2269 * COMPILER / Reporting Deprecation
2270 * When enabled, the compiler will signal use of deprecated API either as an
2271 * error or a warning.
2272 * - option id: "net.sourceforge.phpdt.core.compiler.problem.deprecation"
2273 * - possible values: { "error", "warning", "ignore" }
2274 * - default: "warning"
2276 * COMPILER / Reporting Deprecation Inside Deprecated Code
2277 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
2278 * The severity of the problem is controlled with option "net.sourceforge.phpdt.core.compiler.problem.deprecation".
2279 * - option id: "net.sourceforge.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
2280 * - possible values: { "enabled", "disabled" }
2281 * - default: "disabled"
2283 * COMPILER / Reporting Hidden Catch Block
2284 * Locally to a try statement, some catch blocks may hide others . For example,
2285 * try { throw new java.io.CharConversionException();
2286 * } catch (java.io.CharConversionException e) {
2287 * } catch (java.io.IOException e) {}.
2288 * When enabling this option, the compiler will issue an error or a warning for hidden
2289 * catch blocks corresponding to checked exceptions
2290 * - option id: "net.sourceforge.phpdt.core.compiler.problem.hiddenCatchBlock"
2291 * - possible values: { "error", "warning", "ignore" }
2292 * - default: "warning"
2294 * COMPILER / Reporting Unused Local
2295 * When enabled, the compiler will issue an error or a warning for unused local
2296 * variables (that is, variables never read from)
2297 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedLocal"
2298 * - possible values: { "error", "warning", "ignore" }
2299 * - default: "ignore"
2301 * COMPILER / Reporting Unused Parameter
2302 * When enabled, the compiler will issue an error or a warning for unused method
2303 * parameters (that is, parameters never read from)
2304 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedParameter"
2305 * - possible values: { "error", "warning", "ignore" }
2306 * - default: "ignore"
2308 * COMPILER / Reporting Unused Parameter if Implementing Abstract Method
2309 * When enabled, the compiler will signal unused parameters in abstract method implementations.
2310 * The severity of the problem is controlled with option "net.sourceforge.phpdt.core.compiler.problem.unusedParameter".
2311 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"
2312 * - possible values: { "enabled", "disabled" }
2313 * - default: "disabled"
2315 * COMPILER / Reporting Unused Parameter if Overriding Concrete Method
2316 * When enabled, the compiler will signal unused parameters in methods overriding concrete ones.
2317 * The severity of the problem is controlled with option "net.sourceforge.phpdt.core.compiler.problem.unusedParameter".
2318 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"
2319 * - possible values: { "enabled", "disabled" }
2320 * - default: "disabled"
2322 * COMPILER / Reporting Unused Import
2323 * When enabled, the compiler will issue an error or a warning for unused import
2325 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedImport"
2326 * - possible values: { "error", "warning", "ignore" }
2327 * - default: "warning"
2329 * COMPILER / Reporting Unused Private Members
2330 * When enabled, the compiler will issue an error or a warning whenever a private
2331 * method or field is declared but never used within the same unit.
2332 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedPrivateMember"
2333 * - possible values: { "error", "warning", "ignore" }
2334 * - default: "ignore"
2336 * COMPILER / Reporting Synthetic Access Emulation
2337 * When enabled, the compiler will issue an error or a warning whenever it emulates
2338 * access to a non-accessible member of an enclosing type. Such access can have
2339 * performance implications.
2340 * - option id: "net.sourceforge.phpdt.core.compiler.problem.syntheticAccessEmulation"
2341 * - possible values: { "error", "warning", "ignore" }
2342 * - default: "ignore"
2344 * COMPILER / Reporting Non-Externalized String Literal
2345 * When enabled, the compiler will issue an error or a warning for non externalized
2346 * String literal (that is, not tagged with //$NON-NLS-<n>$).
2347 * - option id: "net.sourceforge.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
2348 * - possible values: { "error", "warning", "ignore" }
2349 * - default: "ignore"
2351 * COMPILER / Reporting Usage of 'assert' Identifier
2352 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
2353 * used as an identifier (reserved keyword in 1.4)
2354 * - option id: "net.sourceforge.phpdt.core.compiler.problem.assertIdentifier"
2355 * - possible values: { "error", "warning", "ignore" }
2356 * - default: "ignore"
2358 * COMPILER / Reporting Non-Static Reference to a Static Member
2359 * When enabled, the compiler will issue an error or a warning whenever a static field
2360 * or method is accessed with an expression receiver. A reference to a static member should
2361 * be qualified with a type name.
2362 * - option id: "net.sourceforge.phpdt.core.compiler.problem.staticAccessReceiver"
2363 * - possible values: { "error", "warning", "ignore" }
2364 * - default: "warning"
2366 * COMPILER / Reporting Assignment with no Effect
2367 * When enabled, the compiler will issue an error or a warning whenever an assignment
2368 * has no effect (e.g 'x = x').
2369 * - option id: "net.sourceforge.phpdt.core.compiler.problem.noEffectAssignment"
2370 * - possible values: { "error", "warning", "ignore" }
2371 * - default: "warning"
2373 * COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods
2374 * When enabled, the compiler will issue an error or a warning whenever an interface
2375 * defines a method incompatible with a non-inherited Object method. Until this conflict
2376 * is resolved, such an interface cannot be implemented, For example,
2380 * - option id: "net.sourceforge.phpdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"
2381 * - possible values: { "error", "warning", "ignore" }
2382 * - default: "warning"
2384 * COMPILER / Reporting Usage of char[] Expressions in String Concatenations
2385 * When enabled, the compiler will issue an error or a warning whenever a char[] expression
2386 * is used in String concatenations (for example, "hello" + new char[]{'w','o','r','l','d'}).
2387 * - option id: "net.sourceforge.phpdt.core.compiler.problem.noImplicitStringConversion"
2388 * - possible values: { "error", "warning", "ignore" }
2389 * - default: "warning"
2391 * COMPILER / Setting Source Compatibility Mode
2392 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
2393 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
2394 * level should be set to "1.4" and the compliance mode should be "1.4".
2395 * - option id: "net.sourceforge.phpdt.core.compiler.source"
2396 * - possible values: { "1.3", "1.4" }
2397 * - default: "1.3"
2399 * COMPILER / Setting Compliance Level
2400 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
2401 * should not go beyond "1.3" level.
2402 * - option id: "net.sourceforge.phpdt.core.compiler.compliance"
2403 * - possible values: { "1.3", "1.4" }
2404 * - default: "1.3"
2406 * COMPILER / Maximum number of problems reported per compilation unit
2407 * Specify the maximum number of problems reported on each compilation unit.
2408 * - option id: "net.sourceforge.phpdt.core.compiler.maxProblemPerUnit"
2409 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
2410 * - default: "100"
2412 * COMPILER / Define the Automatic Task Tags
2413 * When the tag list is not empty, the compiler will issue a task marker whenever it encounters
2414 * one of the corresponding tag inside any comment in Java source code.
2415 * Generated task messages will include the tag, and range until the next line separator or comment ending.
2416 * Note that tasks messages are trimmed.
2417 * - option id: "net.sourceforge.phpdt.core.compiler.taskTags"
2418 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card or leading/trailing spaces
2419 * - default: ""
2421 * COMPILER / Define the Automatic Task Priorities
2422 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
2423 * of the task markers issued by the compiler.
2424 * If the default is specified, the priority of each task marker is "NORMAL".
2425 * - option id: "net.sourceforge.phpdt.core.compiler.taskPriorities"
2426 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
2427 * - default: ""
2429 * BUILDER / Specifying Filters for Resource Copying Control
2430 * Allow to specify some filters to control the resource copy process.
2431 * - option id: "net.sourceforge.phpdt.core.builder.resourceCopyExclusionFilter"
2432 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
2433 * or the name of a folder which ends with '/'
2434 * - default: ""
2436 * BUILDER / Abort if Invalid Classpath
2437 * Allow to toggle the builder to abort if the classpath is invalid
2438 * - option id: "net.sourceforge.phpdt.core.builder.invalidClasspath"
2439 * - possible values: { "abort", "ignore" }
2440 * - default: "abort"
2442 * BUILDER / Cleaning Output Folder(s)
2443 * Indicate whether the JavaBuilder is allowed to clean the output folders
2444 * when performing full build operations.
2445 * - option id: "net.sourceforge.phpdt.core.builder.cleanOutputFolder"
2446 * - possible values: { "clean", "ignore" }
2447 * - default: "clean"
2449 * BUILDER / Reporting Duplicate Resources
2450 * Indicate the severity of the problem reported when more than one occurrence
2451 * of a resource is to be copied into the output location.
2452 * - option id: "net.sourceforge.phpdt.core.builder.duplicateResourceTask"
2453 * - possible values: { "error", "warning" }
2454 * - default: "warning"
2456 * JAVACORE / Computing Project Build Order
2457 * Indicate whether JavaCore should enforce the project build order to be based on
2458 * the classpath prerequisite chain. When requesting to compute, this takes over
2459 * the platform default order (based on project references).
2460 * - option id: "net.sourceforge.phpdt.core.computeJavaBuildOrder"
2461 * - possible values: { "compute", "ignore" }
2462 * - default: "ignore"
2464 * JAVACORE / Specify Default Source Encoding Format
2465 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
2466 * to 'ResourcesPlugin.getEncoding()'.
2467 * - option id: "net.sourceforge.phpdt.core.encoding"
2468 * - possible values: { any of the supported encoding name}.
2469 * - default: <platform default>
2471 * JAVACORE / Reporting Incomplete Classpath
2472 * Indicate the severity of the problem reported when an entry on the classpath does not exist,
2473 * is not legite or is not visible (for example, a referenced project is closed).
2474 * - option id: "net.sourceforge.phpdt.core.incompleteClasspath"
2475 * - possible values: { "error", "warning"}
2476 * - default: "error"
2478 * JAVACORE / Reporting Classpath Cycle
2479 * Indicate the severity of the problem reported when a project is involved in a cycle.
2480 * - option id: "net.sourceforge.phpdt.core.circularClasspath"
2481 * - possible values: { "error", "warning" }
2482 * - default: "error"
2484 * JAVACORE / Enabling Usage of Classpath Exclusion Patterns
2485 * When disabled, no entry on a project classpath can be associated with
2486 * an exclusion pattern.
2487 * - option id: "net.sourceforge.phpdt.core.classpath.exclusionPatterns"
2488 * - possible values: { "enabled", "disabled" }
2489 * - default: "enabled"
2491 * JAVACORE / Enabling Usage of Classpath Multiple Output Locations
2492 * When disabled, no entry on a project classpath can be associated with
2493 * a specific output location, preventing thus usage of multiple output locations.
2494 * - option id: "net.sourceforge.phpdt.core.classpath.multipleOutputLocations"
2495 * - possible values: { "enabled", "disabled" }
2496 * - default: "enabled"
2498 * FORMATTER / Inserting New Line Before Opening Brace
2499 * When Insert, a new line is inserted before an opening brace, otherwise nothing
2501 * - option id: "net.sourceforge.phpdt.core.formatter.newline.openingBrace"
2502 * - possible values: { "insert", "do not insert" }
2503 * - default: "do not insert"
2505 * FORMATTER / Inserting New Line Inside Control Statement
2506 * When Insert, a new line is inserted between } and following else, catch, finally
2507 * - option id: "net.sourceforge.phpdt.core.formatter.newline.controlStatement"
2508 * - possible values: { "insert", "do not insert" }
2509 * - default: "do not insert"
2511 * FORMATTER / Clearing Blank Lines
2512 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
2513 * and all others removed.
2514 * - option id: "net.sourceforge.phpdt.core.formatter.newline.clearAll"
2515 * - possible values: { "clear all", "preserve one" }
2516 * - default: "preserve one"
2518 * FORMATTER / Inserting New Line Between Else/If
2519 * When Insert, a blank line is inserted between an else and an if when they are
2520 * contiguous. When choosing to not insert, else-if will be kept on the same
2521 * line when possible.
2522 * - option id: "net.sourceforge.phpdt.core.formatter.newline.elseIf"
2523 * - possible values: { "insert", "do not insert" }
2524 * - default: "do not insert"
2526 * FORMATTER / Inserting New Line In Empty Block
2527 * When insert, a line break is inserted between contiguous { and }, if } is not followed
2529 * - option id: "net.sourceforge.phpdt.core.formatter.newline.emptyBlock"
2530 * - possible values: { "insert", "do not insert" }
2531 * - default: "insert"
2533 * FORMATTER / Splitting Lines Exceeding Length
2534 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
2535 * disable line splitting
2536 * - option id: "net.sourceforge.phpdt.core.formatter.lineSplit"
2537 * - possible values: "<n>", where n is zero or a positive integer
2538 * - default: "80"
2540 * FORMATTER / Compacting Assignment
2541 * Assignments can be formatted asymmetrically, for example 'int x= 2;', when Normal, a space
2542 * is inserted before the assignment operator
2543 * - option id: "net.sourceforge.phpdt.core.formatter.style.assignment"
2544 * - possible values: { "compact", "normal" }
2545 * - default: "normal"
2547 * FORMATTER / Defining Indentation Character
2548 * Either choose to indent with tab characters or spaces
2549 * - option id: "net.sourceforge.phpdt.core.formatter.tabulation.char"
2550 * - possible values: { "tab", "space" }
2551 * - default: "tab"
2553 * FORMATTER / Defining Space Indentation Length
2554 * When using spaces, set the amount of space characters to use for each
2556 * - option id: "net.sourceforge.phpdt.core.formatter.tabulation.size"
2557 * - possible values: "<n>", where n is a positive integer
2558 * - default: "4"
2560 * FORMATTER / Inserting space in cast expression
2561 * When Insert, a space is added between the type and the expression in a cast expression.
2562 * - option id: "net.sourceforge.phpdt.core.formatter.space.castexpression"
2563 * - possible values: { "insert", "do not insert" }
2564 * - default: "insert"
2566 * CODEASSIST / Activate Visibility Sensitive Completion
2567 * When active, completion doesn't show that you can not see
2568 * (for example, you can not see private methods of a super class).
2569 * - option id: "net.sourceforge.phpdt.core.codeComplete.visibilityCheck"
2570 * - possible values: { "enabled", "disabled" }
2571 * - default: "disabled"
2573 * CODEASSIST / Automatic Qualification of Implicit Members
2574 * When active, completion automatically qualifies completion on implicit
2575 * field references and message expressions.
2576 * - option id: "net.sourceforge.phpdt.core.codeComplete.forceImplicitQualification"
2577 * - possible values: { "enabled", "disabled" }
2578 * - default: "disabled"
2580 * CODEASSIST / Define the Prefixes for Field Name
2581 * When the prefixes is non empty, completion for field name will begin with
2582 * one of the proposed prefixes.
2583 * - option id: "net.sourceforge.phpdt.core.codeComplete.fieldPrefixes"
2584 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2585 * - default: ""
2587 * CODEASSIST / Define the Prefixes for Static Field Name
2588 * When the prefixes is non empty, completion for static field name will begin with
2589 * one of the proposed prefixes.
2590 * - option id: "net.sourceforge.phpdt.core.codeComplete.staticFieldPrefixes"
2591 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2592 * - default: ""
2594 * CODEASSIST / Define the Prefixes for Local Variable Name
2595 * When the prefixes is non empty, completion for local variable name will begin with
2596 * one of the proposed prefixes.
2597 * - option id: "net.sourceforge.phpdt.core.codeComplete.localPrefixes"
2598 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2599 * - default: ""
2601 * CODEASSIST / Define the Prefixes for Argument Name
2602 * When the prefixes is non empty, completion for argument name will begin with
2603 * one of the proposed prefixes.
2604 * - option id: "net.sourceforge.phpdt.core.codeComplete.argumentPrefixes"
2605 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2606 * - default: ""
2608 * CODEASSIST / Define the Suffixes for Field Name
2609 * When the suffixes is non empty, completion for field name will end with
2610 * one of the proposed suffixes.
2611 * - option id: "net.sourceforge.phpdt.core.codeComplete.fieldSuffixes"
2612 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2613 * - default: ""
2615 * CODEASSIST / Define the Suffixes for Static Field Name
2616 * When the suffixes is non empty, completion for static field name will end with
2617 * one of the proposed suffixes.
2618 * - option id: "net.sourceforge.phpdt.core.codeComplete.staticFieldSuffixes"
2619 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2620 * - default: ""
2622 * CODEASSIST / Define the Suffixes for Local Variable Name
2623 * When the suffixes is non empty, completion for local variable name will end with
2624 * one of the proposed suffixes.
2625 * - option id: "net.sourceforge.phpdt.core.codeComplete.localSuffixes"
2626 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2627 * - default: ""
2629 * CODEASSIST / Define the Suffixes for Argument Name
2630 * When the suffixes is non empty, completion for argument name will end with
2631 * one of the proposed suffixes.
2632 * - option id: "net.sourceforge.phpdt.core.codeComplete.argumentSuffixes"
2633 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
2634 * - default: ""
2637 * @return a mutable table containing the default settings of all known options
2650 public static Hashtable getDefaultOptions() {
2652 Hashtable defaultOptions = new Hashtable(10);
2654 // see #initializeDefaultPluginPreferences() for changing default
2656 Preferences preferences = getPlugin().getPluginPreferences();
2657 HashSet optionNames = JavaModelManager.OptionNames;
2659 // get preferences set to their default
2660 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2661 for (int i = 0; i < defaultPropertyNames.length; i++) {
2662 String propertyName = defaultPropertyNames[i];
2663 if (optionNames.contains(propertyName)) {
2664 defaultOptions.put(propertyName, preferences
2665 .getDefaultString(propertyName));
2668 // get preferences not set to their default
2669 String[] propertyNames = preferences.propertyNames();
2670 for (int i = 0; i < propertyNames.length; i++) {
2671 String propertyName = propertyNames[i];
2672 if (optionNames.contains(propertyName)) {
2673 defaultOptions.put(propertyName, preferences
2674 .getDefaultString(propertyName));
2677 // get encoding through resource plugin
2678 defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2680 return defaultOptions;
2684 * Returns the single instance of the Java core plug-in runtime class.
2685 * Equivalent to <code>(JavaCore) getPlugin()</code>.
2687 * @return the single instance of the Java core plug-in runtime class
2689 public static PHPeclipsePlugin getJavaCore() {
2690 return (PHPeclipsePlugin) getPlugin();
2694 * Helper method for returning one option value only. Equivalent to
2695 * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
2696 * may answer <code>null</code> if this option does not exist.
2698 * For a complete description of the configurable options, see
2699 * <code>getDefaultOptions</code>.
2703 * the name of an option
2704 * @return the String value of a given option
2705 * @see JavaCore#getDefaultOptions
2708 public static String getOption(String optionName) {
2710 if (CORE_ENCODING.equals(optionName)) {
2711 return ResourcesPlugin.getEncoding();
2713 if (JavaModelManager.OptionNames.contains(optionName)) {
2714 Preferences preferences = getPlugin().getPluginPreferences();
2715 return preferences.getString(optionName).trim();
2721 * Returns the table of the current options. Initially, all options have
2722 * their default values, and this method returns a table that includes all
2725 * For a complete description of the configurable options, see
2726 * <code>getDefaultOptions</code>.
2729 * @return table of current settings of all options (key type:
2730 * <code>String</code>; value type: <code>String</code>)
2731 * @see JavaCore#getDefaultOptions
2733 public static Hashtable getOptions() {
2735 Hashtable options = new Hashtable(10);
2737 // see #initializeDefaultPluginPreferences() for changing default
2739 Plugin plugin = getPlugin();
2740 if (plugin != null) {
2741 Preferences preferences = getPlugin().getPluginPreferences();
2742 HashSet optionNames = JavaModelManager.OptionNames;
2744 // get preferences set to their default
2745 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2746 for (int i = 0; i < defaultPropertyNames.length; i++) {
2747 String propertyName = defaultPropertyNames[i];
2748 if (optionNames.contains(propertyName)) {
2749 options.put(propertyName, preferences
2750 .getDefaultString(propertyName));
2753 // get preferences not set to their default
2754 String[] propertyNames = preferences.propertyNames();
2755 for (int i = 0; i < propertyNames.length; i++) {
2756 String propertyName = propertyNames[i];
2757 if (optionNames.contains(propertyName)) {
2758 options.put(propertyName, preferences.getString(
2759 propertyName).trim());
2762 // get encoding through resource plugin
2763 options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2769 * This is a helper method, which returns the resolved classpath entry
2770 * denoted by a given entry (if it is a variable entry). It is obtained by
2771 * resolving the variable reference in the first segment. Returns <node>null
2772 * </code> if unable to resolve using the following algorithm:
2774 * <li>if variable segment cannot be resolved, returns <code>null</code>
2776 * <li>finds a project, JAR or binary folder in the workspace at the
2777 * resolved path location</li>
2778 * <li>if none finds an external JAR file or folder outside the workspace
2779 * at the resolved path location</li>
2780 * <li>if none returns <code>null</code></li>
2783 * Variable source attachment path and root path are also resolved and
2784 * recorded in the resulting classpath entry.
2786 * NOTE: This helper method does not handle classpath containers, for which
2787 * should rather be used <code>JavaCore#getClasspathContainer(IPath,
2788 * IJavaProject)</code>.
2792 * the given variable entry
2793 * @return the resolved library or project classpath entry, or <code>null
2794 * </code> if the given variable entry could not be resolved to a
2795 * valid classpath entry
2797 public static IClasspathEntry getResolvedClasspathEntry(
2798 IClasspathEntry entry) {
2800 if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
2803 IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
2804 IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath());
2805 if (resolvedPath == null)
2808 Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false);
2812 // inside the workspace
2813 if (target instanceof IResource) {
2814 IResource resolvedResource = (IResource) target;
2815 if (resolvedResource != null) {
2816 switch (resolvedResource.getType()) {
2818 case IResource.PROJECT:
2820 return JavaCore.newProjectEntry(resolvedPath, entry
2823 case IResource.FILE:
2825 // (ProjectPrefUtil.isArchiveFileName(resolvedResource.getName()))
2827 // // internal binary archive
2828 // return JavaCore.newLibraryEntry(
2830 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2831 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2832 // entry.isExported());
2836 case IResource.FOLDER:
2837 // internal binary folder
2838 // return JavaCore.newLibraryEntry(
2840 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2841 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2842 // entry.isExported());
2847 // outside the workspace
2848 if (target instanceof File) {
2849 File externalFile = (File) target;
2850 if (externalFile.isFile()) {
2851 String fileName = externalFile.getName().toLowerCase();
2852 // if (fileName.endsWith(".jar" //$NON-NLS-1$
2853 // ) || fileName.endsWith(".zip" //$NON-NLS-1$
2854 // )) { // external binary archive
2855 // return JavaCore.newLibraryEntry(
2857 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2858 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2859 // entry.isExported());
2861 } else { // external binary folder
2862 if (resolvedPath.isAbsolute()) {
2863 // return JavaCore.newLibraryEntry(
2865 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2866 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2867 // entry.isExported());
2875 * Resolve a variable path (helper method).
2877 * @param variablePath
2878 * the given variable path
2879 * @return the resolved variable path or <code>null</code> if none
2881 public static IPath getResolvedVariablePath(IPath variablePath) {
2883 if (variablePath == null)
2885 int count = variablePath.segmentCount();
2890 String variableName = variablePath.segment(0);
2891 IPath resolvedPath = JavaCore.getClasspathVariable(variableName);
2892 if (resolvedPath == null)
2895 // append path suffix
2897 resolvedPath = resolvedPath.append(variablePath
2898 .removeFirstSegments(1));
2900 return resolvedPath;
2904 * Answers the shared working copies currently registered for this buffer
2905 * factory. Working copies can be shared by several clients using the same
2906 * buffer factory,see <code>IWorkingCopy.getSharedWorkingCopy</code>.
2909 * the given buffer factory
2910 * @return the list of shared working copies for a given buffer factory
2914 public static IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory) {
2916 // if factory is null, default factory must be used
2917 if (factory == null)
2918 factory = BufferManager.getDefaultBufferManager()
2919 .getDefaultBufferFactory();
2920 Map sharedWorkingCopies = JavaModelManager.getJavaModelManager().sharedWorkingCopies;
2922 Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
2923 if (perFactoryWorkingCopies == null)
2924 return JavaModelManager.NoWorkingCopy;
2925 Collection copies = perFactoryWorkingCopies.values();
2926 IWorkingCopy[] result = new IWorkingCopy[copies.size()];
2927 copies.toArray(result);
2932 * Initializes the default preferences settings for this plug-in.
2934 public static void initializeDefaultPluginPreferences() {
2936 Preferences preferences = PHPeclipsePlugin.getDefault()
2937 .getPluginPreferences();
2938 HashSet optionNames = JavaModelManager.OptionNames;
2940 // Compiler settings
2941 preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
2942 optionNames.add(COMPILER_LOCAL_VARIABLE_ATTR);
2944 preferences.setDefault(COMPILER_LINE_NUMBER_ATTR, GENERATE);
2945 optionNames.add(COMPILER_LINE_NUMBER_ATTR);
2947 preferences.setDefault(COMPILER_SOURCE_FILE_ATTR, GENERATE);
2948 optionNames.add(COMPILER_SOURCE_FILE_ATTR);
2950 preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE);
2951 optionNames.add(COMPILER_CODEGEN_UNUSED_LOCAL);
2953 preferences.setDefault(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1);
2954 optionNames.add(COMPILER_CODEGEN_TARGET_PLATFORM);
2956 preferences.setDefault(COMPILER_PB_PHP_VAR_DEPRECATED, IGNORE);
2957 optionNames.add(COMPILER_PB_PHP_VAR_DEPRECATED);
2958 preferences.setDefault(COMPILER_PB_PHP_KEYWORD, WARNING);
2959 optionNames.add(COMPILER_PB_PHP_KEYWORD);
2960 preferences.setDefault(COMPILER_PB_PHP_UPPERCASE_IDENTIFIER, IGNORE);
2961 optionNames.add(COMPILER_PB_PHP_UPPERCASE_IDENTIFIER);
2962 preferences.setDefault(COMPILER_PB_PHP_FILE_NOT_EXIST, WARNING);
2963 optionNames.add(COMPILER_PB_PHP_FILE_NOT_EXIST);
2964 preferences.setDefault(COMPILER_PB_UNREACHABLE_CODE, WARNING);
2965 optionNames.add(COMPILER_PB_UNREACHABLE_CODE);
2966 preferences.setDefault(COMPILER_PB_UNINITIALIZED_LOCAL_VARIABLE,
2968 optionNames.add(COMPILER_PB_UNINITIALIZED_LOCAL_VARIABLE);
2970 preferences.setDefault(COMPILER_PB_INVALID_IMPORT, ERROR);
2971 optionNames.add(COMPILER_PB_INVALID_IMPORT);
2973 preferences.setDefault(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD,
2975 optionNames.add(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD);
2977 preferences.setDefault(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME,
2979 optionNames.add(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME);
2981 preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING);
2982 optionNames.add(COMPILER_PB_DEPRECATION);
2984 preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE,
2986 optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE);
2988 preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING);
2989 optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK);
2991 preferences.setDefault(COMPILER_PB_UNUSED_LOCAL, IGNORE);
2992 optionNames.add(COMPILER_PB_UNUSED_LOCAL);
2994 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE);
2995 optionNames.add(COMPILER_PB_UNUSED_PARAMETER);
2997 preferences.setDefault(
2998 COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT,
3001 .add(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT);
3005 COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE,
3007 optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE);
3009 preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING);
3010 optionNames.add(COMPILER_PB_UNUSED_IMPORT);
3012 preferences.setDefault(COMPILER_PB_UNUSED_PRIVATE_MEMBER, IGNORE);
3013 optionNames.add(COMPILER_PB_UNUSED_PRIVATE_MEMBER);
3015 preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE);
3016 optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION);
3018 preferences.setDefault(COMPILER_PB_NON_NLS_STRING_LITERAL, IGNORE);
3019 optionNames.add(COMPILER_PB_NON_NLS_STRING_LITERAL);
3021 preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE);
3022 optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER);
3024 preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING);
3025 optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER);
3027 preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING);
3028 optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT);
3030 preferences.setDefault(
3031 COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD,
3034 .add(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD);
3036 preferences.setDefault(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION,
3038 optionNames.add(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION);
3040 preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAG); //$NON-NLS-1$
3041 optionNames.add(COMPILER_TASK_TAGS);
3043 preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITY); //$NON-NLS-1$
3044 optionNames.add(COMPILER_TASK_PRIORITIES);
3046 preferences.setDefault(COMPILER_SOURCE, VERSION_1_3);
3047 optionNames.add(COMPILER_SOURCE);
3049 preferences.setDefault(COMPILER_COMPLIANCE, VERSION_1_3);
3050 optionNames.add(COMPILER_COMPLIANCE);
3052 preferences.setDefault(COMPILER_PB_MAX_PER_UNIT, "100"); //$NON-NLS-1$
3053 optionNames.add(COMPILER_PB_MAX_PER_UNIT);
3056 preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
3057 optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
3059 preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT);
3060 optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH);
3062 preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING);
3063 optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE);
3065 preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN);
3066 optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER);
3068 // JavaCore settings
3069 preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE);
3070 optionNames.add(CORE_JAVA_BUILD_ORDER);
3072 preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR);
3073 optionNames.add(CORE_CIRCULAR_CLASSPATH);
3075 preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR);
3076 optionNames.add(CORE_INCOMPLETE_CLASSPATH);
3078 preferences.setDefault(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS,
3080 optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS);
3082 preferences.setDefault(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS,
3084 optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS);
3086 // encoding setting comes from resource plug-in
3087 optionNames.add(CORE_ENCODING);
3089 // Formatter settings
3090 preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT);
3091 optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE);
3093 preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT);
3094 optionNames.add(FORMATTER_NEWLINE_CONTROL);
3096 preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE);
3097 optionNames.add(FORMATTER_CLEAR_BLANK_LINES);
3099 preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT);
3100 optionNames.add(FORMATTER_NEWLINE_ELSE_IF);
3102 preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT);
3103 optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK);
3105 preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$
3106 optionNames.add(FORMATTER_LINE_SPLIT);
3108 preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL);
3109 optionNames.add(FORMATTER_COMPACT_ASSIGNMENT);
3111 preferences.setDefault(FORMATTER_COMPACT_ARRAYS, NORMAL);
3112 optionNames.add(FORMATTER_COMPACT_ARRAYS);
3114 preferences.setDefault(FORMATTER_COMPACT_STRING_CONCATENATION, NORMAL);
3115 optionNames.add(FORMATTER_COMPACT_STRING_CONCATENATION);
3117 preferences.setDefault(FORMATTER_TAB_CHAR, TAB);
3118 optionNames.add(FORMATTER_TAB_CHAR);
3120 preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$
3121 optionNames.add(FORMATTER_TAB_SIZE);
3123 preferences.setDefault(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$
3124 optionNames.add(FORMATTER_SPACE_CASTEXPRESSION);
3126 // CodeAssist settings
3127 preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$
3128 optionNames.add(CODEASSIST_VISIBILITY_CHECK);
3130 preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$
3131 optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION);
3133 preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
3134 optionNames.add(CODEASSIST_FIELD_PREFIXES);
3136 preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
3137 optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES);
3139 preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
3140 optionNames.add(CODEASSIST_LOCAL_PREFIXES);
3142 preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
3143 optionNames.add(CODEASSIST_ARGUMENT_PREFIXES);
3145 preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3146 optionNames.add(CODEASSIST_FIELD_SUFFIXES);
3148 preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3149 optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES);
3151 preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
3152 optionNames.add(CODEASSIST_LOCAL_SUFFIXES);
3154 preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
3155 optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES);
3159 * Returns whether the given marker references the given Java element. Used
3160 * for markers, which denote a Java element rather than a resource.
3166 * @return <code>true</code> if the marker references the element, false
3168 * @exception CoreException
3169 * if the <code>IMarker.getAttribute</code> on the marker
3172 public static boolean isReferencedBy(IJavaElement element, IMarker marker)
3173 throws CoreException {
3175 // only match units or classfiles
3176 if (element instanceof IMember) {
3177 IMember member = (IMember) element;
3178 if (member.isBinary()) {
3179 element = null; // member.getClassFile();
3181 element = member.getCompilationUnit();
3184 if (element == null)
3189 String markerHandleId = (String) marker.getAttribute(ATT_HANDLE_ID);
3190 if (markerHandleId == null)
3193 IJavaElement markerElement = JavaCore.create(markerHandleId);
3195 if (element.equals(markerElement))
3196 return true; // external elements may still be equal with
3200 // cycle through enclosing types in case marker is associated with a
3201 // classfile (15568)
3202 // if (markerElement instanceof IClassFile){
3203 // IType enclosingType =
3204 // ((IClassFile)markerElement).getType().getDeclaringType();
3205 // if (enclosingType != null){
3206 // markerElement = enclosingType.getClassFile(); // retry with immediate
3207 // enclosing classfile
3217 * Returns whether the given marker delta references the given Java element.
3218 * Used for markers deltas, which denote a Java element rather than a
3223 * @param markerDelta
3225 * @return <code>true</code> if the marker delta references the element
3226 * @exception CoreException
3227 * if the <code>IMarkerDelta.getAttribute</code> on the
3228 * marker delta fails
3230 public static boolean isReferencedBy(IJavaElement element,
3231 IMarkerDelta markerDelta) throws CoreException {
3233 // only match units or classfiles
3234 if (element instanceof IMember) {
3235 IMember member = (IMember) element;
3236 if (member.isBinary()) {
3237 element = null; // member.getClassFile();
3239 element = member.getCompilationUnit();
3242 if (element == null)
3244 if (markerDelta == null)
3247 String markerDeltarHandleId = (String) markerDelta
3248 .getAttribute(ATT_HANDLE_ID);
3249 if (markerDeltarHandleId == null)
3252 IJavaElement markerElement = JavaCore.create(markerDeltarHandleId);
3254 if (element.equals(markerElement))
3255 return true; // external elements may still be equal with
3259 // cycle through enclosing types in case marker is associated with a
3260 // classfile (15568)
3261 // if (markerElement instanceof IClassFile){
3262 // IType enclosingType =
3263 // ((IClassFile)markerElement).getType().getDeclaringType();
3264 // if (enclosingType != null){
3265 // markerElement = enclosingType.getClassFile(); // retry with immediate
3266 // enclosing classfile
3276 * Creates and returns a new classpath entry of kind
3277 * <code>CPE_CONTAINER</code> for the given path. The path of the
3278 * container will be used during resolution so as to map this container
3279 * entry to a set of other classpath entries the container is acting for.
3281 * A container entry allows to express indirect references to a set of
3282 * libraries, projects and variable entries, which can be interpreted
3283 * differently for each Java project where it is used. A classpath container
3284 * entry can be resolved using
3285 * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3286 * <code>JavaCore.classpathContainerChanged</code>
3288 * A container is exclusively resolved by a
3289 * <code>ClasspathContainerInitializer</code> registered onto the
3291 * "net.sourceforge.phpdt.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
3298 * "net.sourceforge.phpdt.core.classpathContainerInitializer". </li>
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"));
3310 * point="net.sourceforge.phpdt.core.classpathContainerInitializer">
3311 * <containerInitializer id="MyProvidedJDK"
3312 * class="com.example.MyInitializer"/>
3314 * Note that this operation does not attempt to validate classpath
3315 * containers or access the resources at the given paths.
3317 * The resulting entry is not exported to dependent projects. This method is
3318 * equivalent to <code>newContainerEntry(-,false)</code>.
3321 * @param containerPath
3322 * the path identifying the container, it must be formed of two
3324 * @return a new container classpath entry
3326 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3327 * @see JavaCore#newContainerEntry(IPath, boolean)
3330 public static IClasspathEntry newContainerEntry(IPath containerPath) {
3332 return newContainerEntry(containerPath, false);
3336 * Creates and returns a new classpath entry of kind
3337 * <code>CPE_CONTAINER</code> for the given path. The path of the
3338 * container will be used during resolution so as to map this container
3339 * entry to a set of other classpath entries the container is acting for.
3341 * A container entry allows to express indirect references to a set of
3342 * libraries, projects and variable entries, which can be interpreted
3343 * differently for each Java project where it is used. A classpath container
3344 * entry can be resolved using
3345 * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3346 * <code>JavaCore.classpathContainerChanged</code>
3348 * A container is exclusively resolved by a
3349 * <code>ClasspathContainerInitializer</code> registered onto the
3351 * "net.sourceforge.phpdt.core.classpathContainerInitializer".
3353 * A container path must be formed of at least one segment, where:
3355 * <li>the first segment is a unique ID identifying the target container,
3356 * there must be a container initializer registered onto this ID through the
3358 * "net.sourceforge.phpdt.core.classpathContainerInitializer". </li>
3359 * <li>the remaining segments will be passed onto the initializer, and can
3360 * be used as additional hints during the initialization phase.</li>
3363 * Example of an ClasspathContainerInitializer for a classpath container
3364 * denoting a default JDK container:
3366 * containerEntry = JavaCore.newContainerEntry(new
3367 * Path("MyProvidedJDK/default"));
3370 * point="net.sourceforge.phpdt.core.classpathContainerInitializer">
3371 * <containerInitializer id="MyProvidedJDK"
3372 * class="com.example.MyInitializer"/>
3374 * Note that this operation does not attempt to validate classpath
3375 * containers or access the resources at the given paths.
3378 * @param containerPath
3379 * the path identifying the container, it must be formed of at
3380 * least one segment (ID+hints)
3382 * a boolean indicating whether this entry is contributed to
3383 * dependent projects in addition to the output location
3384 * @return a new container classpath entry
3386 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3387 * @see JavaCore#setClasspathContainer(IPath, IJavaProject[],
3388 * IClasspathContainer[], IProgressMonitor)
3389 * @see JavaCore#newContainerEntry(IPath, boolean)
3393 public static IClasspathEntry newContainerEntry(IPath containerPath,
3394 boolean isExported) {
3396 if (containerPath == null)
3397 Assert.isTrue(false, "Container path cannot be null"); //$NON-NLS-1$
3398 if (containerPath.segmentCount() < 1) {
3402 "Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$
3404 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3405 IClasspathEntry.CPE_CONTAINER, containerPath,
3406 ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, null, // source
3408 null, // source attachment root
3409 null, // specific output folder
3414 * Creates and returns a new non-exported classpath entry of kind
3415 * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3416 * absolute path. This specifies that all package fragments within the root
3417 * will have children of type <code>IClassFile</code>.
3419 * A library entry is used to denote a prerequisite JAR or root folder
3420 * containing binaries. The target JAR or folder can either be defined
3421 * internally to the workspace (absolute path relative to the workspace
3422 * root) or externally to the workspace (absolute path in the file system).
3424 * e.g. Here are some examples of binary path usage
3426 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3428 * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3430 * <li><code> "c:/classes/" </code>- reference to an external binary
3433 * Note that this operation does not attempt to validate or access the
3434 * resources at the given paths.
3436 * The resulting entry is not exported to dependent projects. This method is
3437 * equivalent to <code>newLibraryEntry(-,-,-,false)</code>.
3441 * the absolute path of the binary archive
3442 * @param sourceAttachmentPath
3443 * the absolute path of the corresponding source archive or
3444 * folder, or <code>null</code> if none
3445 * @param sourceAttachmentRootPath
3446 * the location of the root within the source archive or folder
3447 * or <code>null</code> if this location should be
3448 * automatically detected.
3449 * @return a new library classpath entry
3451 * @see #newLibraryEntry(IPath, IPath, IPath, boolean)
3453 // public static IClasspathEntry newLibraryEntry(
3455 // IPath sourceAttachmentPath,
3456 // IPath sourceAttachmentRootPath) {
3458 // return newLibraryEntry(path, sourceAttachmentPath,
3459 // sourceAttachmentRootPath, false);
3462 * Creates and returns a new classpath entry of kind
3463 * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3464 * absolute path. This specifies that all package fragments within the root
3465 * will have children of type <code>IClassFile</code>.
3467 * A library entry is used to denote a prerequisite JAR or root folder
3468 * containing binaries. The target JAR or folder can either be defined
3469 * internally to the workspace (absolute path relative to the workspace
3470 * root) or externally to the workspace (absolute path in the file system).
3472 * e.g. Here are some examples of binary path usage
3474 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3476 * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3478 * <li><code> "c:/classes/" </code>- reference to an external binary
3481 * Note that this operation does not attempt to validate or access the
3482 * resources at the given paths.
3486 * the absolute path of the binary archive
3487 * @param sourceAttachmentPath
3488 * the absolute path of the corresponding source archive or
3489 * folder, or <code>null</code> if none
3490 * @param sourceAttachmentRootPath
3491 * the location of the root within the source archive or folder
3492 * or <code>null</code> if this location should be
3493 * automatically detected.
3495 * indicates whether this entry is contributed to dependent
3496 * projects in addition to the output location
3497 * @return a new library classpath entry
3500 // public static IClasspathEntry newLibraryEntry(
3502 // IPath sourceAttachmentPath,
3503 // IPath sourceAttachmentRootPath,
3504 // boolean isExported) {
3506 // if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry
3507 // must be absolute"); //$NON-NLS-1$
3509 // return new ClasspathEntry(
3510 // IPackageFragmentRoot.K_BINARY,
3511 // IClasspathEntry.CPE_LIBRARY,
3512 // JavaProject.canonicalizedPath(path),
3513 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3514 // sourceAttachmentPath,
3515 // sourceAttachmentRootPath,
3516 // null, // specific output folder
3520 * Creates and returns a new non-exported classpath entry of kind
3521 * <code>CPE_PROJECT</code> for the project identified by the given
3524 * A project entry is used to denote a prerequisite project on a classpath.
3525 * The referenced project will be contributed as a whole, either as sources
3526 * (in the Java Model, it contributes all its package fragment roots) or as
3527 * binaries (when building, it contributes its whole output location).
3529 * A project reference allows to indirect through another project,
3530 * independently from its internal layout.
3532 * The prerequisite project is referred to using an absolute path relative
3533 * to the workspace root.
3535 * The resulting entry is not exported to dependent projects. This method is
3536 * equivalent to <code>newProjectEntry(_,false)</code>.
3540 * the absolute path of the binary archive
3541 * @return a new project classpath entry
3543 * @see JavaCore#newProjectEntry(IPath, boolean)
3545 public static IClasspathEntry newProjectEntry(IPath path) {
3546 return newProjectEntry(path, false);
3550 * Creates and returns a new classpath entry of kind
3551 * <code>CPE_PROJECT</code> for the project identified by the given
3554 * A project entry is used to denote a prerequisite project on a classpath.
3555 * The referenced project will be contributed as a whole, either as sources
3556 * (in the Java Model, it contributes all its package fragment roots) or as
3557 * binaries (when building, it contributes its whole output location).
3559 * A project reference allows to indirect through another project,
3560 * independently from its internal layout.
3562 * The prerequisite project is referred to using an absolute path relative
3563 * to the workspace root.
3567 * the absolute path of the prerequisite project
3569 * indicates whether this entry is contributed to dependent
3570 * projects in addition to the output location
3571 * @return a new project classpath entry
3574 public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) {
3576 if (!path.isAbsolute())
3577 Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3579 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3580 IClasspathEntry.CPE_PROJECT, path, ClasspathEntry.INCLUDE_ALL,
3581 ClasspathEntry.EXCLUDE_NONE, null, // source attachment
3582 null, // source attachment root
3583 null, // specific output folder
3588 * Returns a new empty region.
3590 * @return a new empty region
3592 public static IRegion newRegion() {
3593 return new Region();
3597 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3598 * for all files in the project's source folder identified by the given
3599 * absolute workspace-relative path.
3601 * The convenience method is fully equivalent to:
3604 * newSourceEntry(path, new IPath[] {}, new IPath[] {}, null);
3610 * the absolute workspace-relative path of a source folder
3611 * @return a new source classpath entry
3612 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath)
3614 public static IClasspathEntry newSourceEntry(IPath path) {
3616 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL,
3617 ClasspathEntry.EXCLUDE_NONE, null /* output location */);
3621 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3622 * for the project's source folder identified by the given absolute
3623 * workspace-relative path but excluding all source files with paths
3624 * matching any of the given patterns.
3626 * The convenience method is fully equivalent to:
3629 * newSourceEntry(path, new IPath[] {}, exclusionPatterns, null);
3635 * the absolute workspace-relative path of a source folder
3636 * @param exclusionPatterns
3637 * the possibly empty list of exclusion patterns represented as
3639 * @return a new source classpath entry
3640 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath)
3643 public static IClasspathEntry newSourceEntry(IPath path,
3644 IPath[] exclusionPatterns) {
3646 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL,
3647 exclusionPatterns, null /* output location */);
3651 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3652 * for the project's source folder identified by the given absolute
3653 * workspace-relative path but excluding all source files with paths
3654 * matching any of the given patterns, and associated with a specific output
3655 * location (that is, ".class" files are not going to the project default
3658 * The convenience method is fully equivalent to:
3661 * newSourceEntry(path, new IPath[] {}, exclusionPatterns, specificOutputLocation);
3667 * the absolute workspace-relative path of a source folder
3668 * @param exclusionPatterns
3669 * the possibly empty list of exclusion patterns represented as
3671 * @param specificOutputLocation
3672 * the specific output location for this source entry (<code>null</code>
3673 * if using project default ouput location)
3674 * @return a new source classpath entry
3675 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath)
3678 public static IClasspathEntry newSourceEntry(IPath path,
3679 IPath[] exclusionPatterns, IPath specificOutputLocation) {
3681 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL,
3682 exclusionPatterns, specificOutputLocation);
3686 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3687 * for the project's source folder identified by the given absolute
3688 * workspace-relative path using the given inclusion and exclusion patterns
3689 * to determine which source files are included, and the given output path
3690 * to control the output location of generated files.
3692 * The source folder is referred to using an absolute path relative to the
3693 * workspace root, e.g. <code>/Project/src</code>. A project's source
3694 * folders are located with that project. That is, a source classpath entry
3695 * specifying the path <code>/P1/src</code> is only usable for project
3699 * The inclusion patterns determines the initial set of source files that
3700 * are to be included; the exclusion patterns are then used to reduce this
3701 * set. When no inclusion patterns are specified, the initial file set
3702 * includes all relevent files in the resource tree rooted at the source
3703 * entry's path. On the other hand, specifying one or more inclusion
3704 * patterns means that all <b>and only</b> files matching at least one of
3705 * the specified patterns are to be included. If exclusion patterns are
3706 * specified, the initial set of files is then reduced by eliminating files
3707 * matched by at least one of the exclusion patterns. Inclusion and
3708 * exclusion patterns look like relative file paths with wildcards and are
3709 * interpreted relative to the source entry's path. File patterns are
3710 * case-sensitive can contain '**', '*' or '?' wildcards (see
3711 * {@link IClasspathEntry#getExclusionPatterns()} for the full description
3712 * of their syntax and semantics). The resulting set of files are included
3713 * in the corresponding package fragment root; all package fragments within
3714 * the root will have children of type <code>ICompilationUnit</code>.
3717 * For example, if the source folder path is <code>/Project/src</code>,
3718 * there are no inclusion filters, and the exclusion pattern is
3719 * <code>com/xyz/tests/**</code>, then source files like
3720 * <code>/Project/src/com/xyz/Foo.java</code> and
3721 * <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3722 * whereas <code>/Project/src/com/xyz/tests/T1.java</code> and
3723 * <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3727 * Additionally, a source entry can be associated with a specific output
3728 * location. By doing so, the Java builder will ensure that the generated
3729 * ".class" files will be issued inside this output location, as opposed to
3730 * be generated into the project default output location (when output
3731 * location is <code>null</code>). Note that multiple source entries may
3732 * target the same output location. The output location is referred to using
3733 * an absolute path relative to the workspace root, e.g.
3734 * <code>"/Project/bin"</code>, it must be located inside the same
3735 * project as the source folder.
3738 * Also note that all sources/binaries inside a project are contributed as a
3739 * whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
3740 * Particular source entries cannot be selectively exported.
3744 * the absolute workspace-relative path of a source folder
3745 * @param inclusionPatterns
3746 * the possibly empty list of inclusion patterns represented as
3748 * @param exclusionPatterns
3749 * the possibly empty list of exclusion patterns represented as
3751 * @param specificOutputLocation
3752 * the specific output location for this source entry (<code>null</code>
3753 * if using project default ouput location)
3754 * @return a new source classpath entry with the given exclusion patterns
3755 * @see IClasspathEntry#getInclusionPatterns()
3756 * @see IClasspathEntry#getExclusionPatterns()
3757 * @see IClasspathEntry#getOutputLocation()
3760 public static IClasspathEntry newSourceEntry(IPath path,
3761 IPath[] inclusionPatterns, IPath[] exclusionPatterns,
3762 IPath specificOutputLocation) {
3765 Assert.isTrue(false, "Source path cannot be null"); //$NON-NLS-1$
3766 if (!path.isAbsolute())
3767 Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3768 if (exclusionPatterns == null)
3769 Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$
3770 if (inclusionPatterns == null)
3771 Assert.isTrue(false, "Inclusion pattern set cannot be null"); //$NON-NLS-1$
3773 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3774 IClasspathEntry.CPE_SOURCE, path, inclusionPatterns,
3775 exclusionPatterns, null, // source attachment
3776 null, // source attachment root
3777 specificOutputLocation, // custom output location
3782 * Creates and returns a new non-exported classpath entry of kind
3783 * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3784 * path is the name of a classpath variable. The trailing segments of the
3785 * path will be appended to resolved variable path.
3787 * A variable entry allows to express indirect references on a classpath to
3788 * other projects or libraries, depending on what the classpath variable is
3791 * It is possible to register an automatic initializer (
3792 * <code>ClasspathVariableInitializer</code>), which will be invoked
3793 * through the extension point
3794 * "net.sourceforge.phpdt.core.classpathVariableInitializer". After
3795 * resolution, a classpath variable entry may either correspond to a project
3796 * or a library entry.</li>
3798 * e.g. Here are some examples of variable path usage
3800 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3801 * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3802 * library "c:\jars\jdtcore.jar"</li>
3803 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3804 * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3805 * "/Project_JDTCORE"</li>
3806 * <li>"PLUGINS/com.example/example.jar" where variable
3807 * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3808 * classpath entry is denoting the library
3809 * "c:/eclipse/plugins/com.example/example.jar"</li>
3811 * Note that this operation does not attempt to validate classpath variables
3812 * or access the resources at the given paths.
3814 * The resulting entry is not exported to dependent projects. This method is
3815 * equivalent to <code>newVariableEntry(-,-,-,false)</code>.
3818 * @param variablePath
3819 * the path of the binary archive; first segment is the name of a
3820 * classpath variable
3821 * @param variableSourceAttachmentPath
3822 * the path of the corresponding source archive, or
3823 * <code>null</code> if none; if present, the first segment is
3824 * the name of a classpath variable (not necessarily the same
3825 * variable as the one that begins <code>variablePath</code>)
3826 * @param sourceAttachmentRootPath
3827 * the location of the root within the source archive or
3828 * <code>null</code> if <code>archivePath</code> is also
3830 * @return a new library classpath entry
3832 * @see JavaCore#newVariableEntry(IPath, IPath, IPath, boolean)
3834 // public static IClasspathEntry newVariableEntry(
3835 // IPath variablePath,
3836 // IPath variableSourceAttachmentPath,
3837 // IPath sourceAttachmentRootPath) {
3839 // return newVariableEntry(variablePath, variableSourceAttachmentPath,
3840 // sourceAttachmentRootPath, false);
3843 * Creates and returns a new non-exported classpath entry of kind
3844 * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3845 * path is the name of a classpath variable. The trailing segments of the
3846 * path will be appended to resolved variable path.
3848 * A variable entry allows to express indirect references on a classpath to
3849 * other projects or libraries, depending on what the classpath variable is
3852 * It is possible to register an automatic initializer (
3853 * <code>ClasspathVariableInitializer</code>), which will be invoked
3854 * through the extension point
3855 * "net.sourceforge.phpdt.core.classpathVariableInitializer". After
3856 * resolution, a classpath variable entry may either correspond to a project
3857 * or a library entry.</li>
3859 * e.g. Here are some examples of variable path usage
3861 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3862 * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3863 * library "c:\jars\jdtcore.jar"</li>
3864 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3865 * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3866 * "/Project_JDTCORE"</li>
3867 * <li>"PLUGINS/com.example/example.jar" where variable
3868 * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3869 * classpath entry is denoting the library
3870 * "c:/eclipse/plugins/com.example/example.jar"</li>
3872 * Note that this operation does not attempt to validate classpath variables
3873 * or access the resources at the given paths.
3876 * @param variablePath
3877 * the path of the binary archive; first segment is the name of a
3878 * classpath variable
3879 * @param variableSourceAttachmentPath
3880 * the path of the corresponding source archive, or
3881 * <code>null</code> if none; if present, the first segment is
3882 * the name of a classpath variable (not necessarily the same
3883 * variable as the one that begins <code>variablePath</code>)
3884 * @param sourceAttachmentRootPath
3885 * the location of the root within the source archive or
3886 * <code>null</code> if <code>archivePath</code> is also
3889 * indicates whether this entry is contributed to dependent
3890 * projects in addition to the output location
3891 * @return a new variable classpath entry
3894 // public static IClasspathEntry newVariableEntry(
3895 // IPath variablePath,
3896 // IPath variableSourceAttachmentPath,
3897 // IPath variableSourceAttachmentRootPath,
3898 // boolean isExported) {
3900 // if (variablePath == null || variablePath.segmentCount() < 1) {
3903 // "Illegal classpath variable path: \'" +
3904 // variablePath.makeRelative().toString() + "\', must have at least one
3905 // segment"); //$NON-NLS-1$//$NON-NLS-2$
3908 // return new ClasspathEntry(
3909 // IPackageFragmentRoot.K_SOURCE,
3910 // IClasspathEntry.CPE_VARIABLE,
3912 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3913 // variableSourceAttachmentPath, // source attachment
3914 // variableSourceAttachmentRootPath, // source attachment root
3915 // null, // specific output folder
3919 * Removed the given classpath variable. Does nothing if no value was set
3920 * for this classpath variable.
3922 * This functionality cannot be used while the resource tree is locked.
3924 * Classpath variable values are persisted locally to the workspace, and are
3925 * preserved from session to session.
3928 * @param variableName
3929 * the name of the classpath variable
3930 * @see #setClasspathVariable
3932 * @deprecated - use version with extra IProgressMonitor
3934 // public static void removeClasspathVariable(String variableName) {
3935 // removeClasspathVariable(variableName, null);
3938 * Removed the given classpath variable. Does nothing if no value was set
3939 * for this classpath variable.
3941 * This functionality cannot be used while the resource tree is locked.
3943 * Classpath variable values are persisted locally to the workspace, and are
3944 * preserved from session to session.
3947 * @param variableName
3948 * the name of the classpath variable
3950 * the progress monitor to report progress
3951 * @see #setClasspathVariable
3953 // public static void removeClasspathVariable(
3954 // String variableName,
3955 // IProgressMonitor monitor) {
3958 // updateVariableValues(new String[]{ variableName}, new IPath[]{ null },
3960 // } catch (JavaModelException e) {
3964 * Removes the given element changed listener. Has no affect if an identical
3965 * listener is not registered.
3970 public static void removeElementChangedListener(
3971 IElementChangedListener listener) {
3972 JavaModelManager.getJavaModelManager().removeElementChangedListener(
3977 * Bind a container reference path to some actual containers (
3978 * <code>IClasspathContainer</code>). This API must be invoked whenever
3979 * changes in container need to be reflected onto the JavaModel. Containers
3980 * can have distinct values in different projects, therefore this API
3981 * considers a set of projects with their respective containers.
3983 * <code>containerPath</code> is the path under which these values can be
3984 * referenced through container classpath entries (
3985 * <code>IClasspathEntry#CPE_CONTAINER</code>). A container path is
3986 * formed by a first ID segment followed with extra segments, which can be
3987 * used as additional hints for the resolution. The container ID is used to
3988 * identify a <code>ClasspathContainerInitializer</code> registered on the
3990 * "net.sourceforge.phpdt.core.classpathContainerInitializer".
3992 * There is no assumption that each individual container value passed in
3993 * argument (<code>respectiveContainers</code>) must answer the exact
3994 * same path when requested <code>IClasspathContainer#getPath</code>.
3995 * Indeed, the containerPath is just an indication for resolving it to an
3996 * actual container object. It can be delegated to a
3997 * <code>ClasspathContainerInitializer</code>, which can be activated
3998 * through the extension point
3999 * "net.sourceforge.phpdt.core.ClasspathContainerInitializer").
4001 * In reaction to changing container values, the JavaModel will be updated
4002 * to reflect the new state of the updated container.
4004 * This functionality cannot be used while the resource tree is locked.
4006 * Classpath container values are persisted locally to the workspace, but
4007 * are not preserved from a session to another. It is thus highly
4008 * recommended to register a <code>ClasspathContainerInitializer</code>
4009 * for each referenced container (through the extension point
4010 * "net.sourceforge.phpdt.core.ClasspathContainerInitializer").
4012 * Note: setting a container to <code>null</code> will cause it to be
4013 * lazily resolved again whenever its value is required. In particular, this
4014 * will cause a registered initializer to be invoked again.
4017 * @param containerPath -
4018 * the name of the container reference, which is being updated
4019 * @param affectedProjects -
4020 * the set of projects for which this container is being bound
4021 * @param respectiveContainers -
4022 * the set of respective containers for the affected projects
4024 * a monitor to report progress
4026 * @see ClasspathContainerInitializer
4027 * @see #getClasspathContainer(IPath, IJavaProject)
4028 * @see IClasspathContainer
4031 // public static void setClasspathContainer(final IPath containerPath,
4032 // IJavaProject[] affectedProjects, IClasspathContainer[]
4033 // respectiveContainers, IProgressMonitor monitor) throws JavaModelException
4036 // if (affectedProjects.length != respectiveContainers.length)
4037 // Assert.isTrue(false, "Projects and containers collections should have the
4038 // same size"); //$NON-NLS-1$
4040 // if (monitor != null && monitor.isCanceled()) return;
4042 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4043 // System.out.println("CPContainer SET - setting container:
4044 // ["+containerPath+"] for projects: {" //$NON-NLS-1$ //$NON-NLS-2$
4045 // + (ProjectPrefUtil.toString(affectedProjects,
4046 // new ProjectPrefUtil.Displayable(){
4047 // public String displayString(Object o) { return ((IJavaProject)
4048 // o).getElementName(); }
4050 // + "} with values: " //$NON-NLS-1$
4051 // + (ProjectPrefUtil.toString(respectiveContainers,
4052 // new ProjectPrefUtil.Displayable(){
4053 // public String displayString(Object o) { return ((IClasspathContainer)
4054 // o).getDescription(); }
4059 // final int projectLength = affectedProjects.length;
4060 // final IJavaProject[] modifiedProjects;
4061 // System.arraycopy(affectedProjects, 0, modifiedProjects = new
4062 // IJavaProject[projectLength], 0, projectLength);
4063 // final IClasspathEntry[][] oldResolvedPaths = new
4064 // IClasspathEntry[projectLength][];
4066 // // filter out unmodified project containers
4067 // int remaining = 0;
4068 // for (int i = 0; i < projectLength; i++){
4070 // if (monitor != null && monitor.isCanceled()) return;
4072 // IJavaProject affectedProject = affectedProjects[i];
4073 // IClasspathContainer newContainer = respectiveContainers[i];
4074 // if (newContainer == null) newContainer =
4075 // JavaModelManager.ContainerInitializationInProgress; // 30920 - prevent
4077 // boolean found = false;
4078 // if (JavaProject.hasJavaNature(affectedProject.getProject())){
4079 // IClasspathEntry[] rawClasspath = affectedProject.getRawClasspath();
4080 // for (int j = 0, cpLength = rawClasspath.length; j <cpLength; j++) {
4081 // IClasspathEntry entry = rawClasspath[j];
4082 // if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER &&
4083 // entry.getPath().equals(containerPath)){
4090 // modifiedProjects[i] = null; // filter out this project - does not
4091 // reference the container path, or isnt't yet Java project
4092 // JavaModelManager.containerPut(affectedProject, containerPath,
4096 // IClasspathContainer oldContainer =
4097 // JavaModelManager.containerGet(affectedProject, containerPath);
4098 // if (oldContainer == JavaModelManager.ContainerInitializationInProgress) {
4099 // Map previousContainerValues =
4100 // (Map)JavaModelManager.PreviousSessionContainers.get(affectedProject);
4101 // if (previousContainerValues != null){
4102 // IClasspathContainer previousContainer =
4103 // (IClasspathContainer)previousContainerValues.get(containerPath);
4104 // if (previousContainer != null) {
4105 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4106 // System.out.println("CPContainer INIT - reentering access to project
4107 // container: ["+affectedProject.getElementName()+"] " + containerPath + "
4108 // during its initialization, will see previous value: "+
4109 // previousContainer.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
4112 // JavaModelManager.containerPut(affectedProject, containerPath,
4113 // previousContainer);
4115 // oldContainer = null; //33695 - cannot filter out restored container, must
4116 // update affected project to reset cached CP
4118 // oldContainer = null;
4121 // if (oldContainer != null &&
4122 // oldContainer.equals(respectiveContainers[i])){// TODO: could improve to
4123 // only compare entries
4124 // modifiedProjects[i] = null; // filter out this project - container did
4129 // oldResolvedPaths[i] = affectedProject.getResolvedClasspath(true);
4130 // JavaModelManager.containerPut(affectedProject, containerPath,
4134 // if (remaining == 0) return;
4136 // // trigger model refresh
4138 // JavaCore.run(new IWorkspaceRunnable() {
4139 // public void run(IProgressMonitor monitor) throws CoreException {
4140 // for(int i = 0; i < projectLength; i++){
4142 // if (monitor != null && monitor.isCanceled()) return;
4144 // JavaProject affectedProject = (JavaProject)modifiedProjects[i];
4145 // if (affectedProject == null) continue; // was filtered out
4147 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4148 // System.out.println("CPContainer SET - updating affected project:
4149 // ["+affectedProject.getElementName()+"] due to setting container: " +
4150 // containerPath); //$NON-NLS-1$ //$NON-NLS-2$
4153 // // force a refresh of the affected project (will compute deltas)
4154 // affectedProject.setRawClasspath(
4155 // affectedProject.getRawClasspath(),
4156 // SetClasspathOperation.ReuseOutputLocation,
4158 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can save resources
4159 // oldResolvedPaths[i],
4160 // false, // updating - no validation
4161 // false); // updating - no need to save
4166 // } catch(CoreException e) {
4167 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4168 // System.out.println("CPContainer SET - FAILED DUE TO EXCEPTION:
4169 // "+containerPath); //$NON-NLS-1$
4170 // e.printStackTrace();
4172 // if (e instanceof JavaModelException) {
4173 // throw (JavaModelException)e;
4175 // throw new JavaModelException(e);
4178 // for (int i = 0; i < projectLength; i++) {
4179 // if (respectiveContainers[i] == null) {
4180 // JavaModelManager.containerPut(affectedProjects[i], containerPath, null);
4181 // // reset init in progress marker
4188 * Sets the value of the given classpath variable. The path must have at
4189 * least one segment.
4191 * This functionality cannot be used while the resource tree is locked.
4193 * Classpath variable values are persisted locally to the workspace, and are
4194 * preserved from session to session.
4197 * @param variableName
4198 * the name of the classpath variable
4201 * @see #getClasspathVariable
4203 * @deprecated - use API with IProgressMonitor
4205 // public static void setClasspathVariable(String variableName, IPath path)
4206 // throws JavaModelException {
4208 // setClasspathVariable(variableName, path, null);
4211 * Sets the value of the given classpath variable. The path must not be
4214 * This functionality cannot be used while the resource tree is locked.
4216 * Classpath variable values are persisted locally to the workspace, and are
4217 * preserved from session to session.
4219 * Updating a variable with the same value has no effect.
4221 * @param variableName
4222 * the name of the classpath variable
4226 * a monitor to report progress
4227 * @see #getClasspathVariable
4229 // public static void setClasspathVariable(
4230 // String variableName,
4232 // IProgressMonitor monitor)
4233 // throws JavaModelException {
4235 // if (path == null) Assert.isTrue(false, "Variable path cannot be null");
4237 // setClasspathVariables(new String[]{variableName}, new IPath[]{ path },
4241 * Sets the values of all the given classpath variables at once. Null paths
4242 * can be used to request corresponding variable removal.
4244 * This functionality cannot be used while the resource tree is locked.
4246 * Classpath variable values are persisted locally to the workspace, and are
4247 * preserved from session to session.
4249 * Updating a variable with the same value has no effect.
4251 * @param variableNames
4252 * an array of names for the updated classpath variables
4254 * an array of path updates for the modified classpath variables
4255 * (null meaning that the corresponding value will be removed
4257 * a monitor to report progress
4258 * @see #getClasspathVariable
4261 // public static void setClasspathVariables(
4262 // String[] variableNames,
4264 // IProgressMonitor monitor)
4265 // throws JavaModelException {
4267 // if (variableNames.length != paths.length) Assert.isTrue(false, "Variable
4268 // names and paths collections should have the same size"); //$NON-NLS-1$
4269 // //TODO: should check that null cannot be used as variable paths
4270 // updateVariableValues(variableNames, paths, monitor);
4273 * (non-Javadoc) Method declared on IExecutableExtension. Record any
4274 * necessary initialization data from the plugin.
4276 public void setInitializationData(IConfigurationElement cfig,
4277 String propertyName, Object data) throws CoreException {
4281 * Sets the current table of options. All and only the options explicitly
4282 * included in the given table are remembered; all previous option settings
4283 * are forgotten, including ones not explicitly mentioned.
4285 * For a complete description of the configurable options, see
4286 * <code>getDefaultOptions</code>.
4290 * the new options (key type: <code>String</code>; value type:
4291 * <code>String</code>), or <code>null</code> to reset all
4292 * options to their default values
4293 * @see JavaCore#getDefaultOptions
4295 public static void setOptions(Hashtable newOptions) {
4297 // see #initializeDefaultPluginPreferences() for changing default
4299 Preferences preferences = getPlugin().getPluginPreferences();
4301 if (newOptions == null) {
4302 newOptions = JavaCore.getDefaultOptions();
4304 Enumeration keys = newOptions.keys();
4305 while (keys.hasMoreElements()) {
4306 String key = (String) keys.nextElement();
4307 if (!JavaModelManager.OptionNames.contains(key))
4308 continue; // unrecognized option
4309 if (key.equals(CORE_ENCODING))
4310 continue; // skipped, contributed by resource prefs
4311 String value = (String) newOptions.get(key);
4312 preferences.setValue(key, value);
4316 getPlugin().savePluginPreferences();
4320 * Shutdown the JavaCore plug-in.
4322 * De-registers the JavaModelManager as a resource changed listener and save
4326 * @see org.eclipse.core.runtime.Plugin#shutdown()
4328 // moved to PHPeclipsePlugin#shutdown()
4329 // public void shutdown() {
4331 // //savePluginPreferences();
4332 // getPlugin().savePluginPreferences();
4333 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4334 // workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaProcessor);
4335 // workspace.removeSaveParticipant(PHPeclipsePlugin.getDefault());
4337 // ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown();
4340 * Initiate the background indexing process. This should be deferred after
4341 * the plugin activation.
4343 // private void startIndexing() {
4345 // JavaModelManager.getJavaModelManager().getIndexManager().reset();
4348 * Startup of the JavaCore plug-in.
4350 * Registers the JavaModelManager as a resource changed listener and save
4351 * participant. Starts the background indexing, and restore saved classpath
4355 * @see org.eclipse.core.runtime.Plugin#startup()
4358 // moved to PHPeclipsePlugin#startup()
4359 // public void startup() {
4361 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
4363 // manager.configurePluginDebugOptions();
4365 // // request state folder creation (workaround 19885)
4366 // JavaCore.getPlugin().getStateLocation();
4368 // // retrieve variable values
4369 // JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4370 // JavaModelManager.PluginPreferencesListener());
4371 // // TODO : jsurfer temp-del
4372 // // manager.loadVariablesAndContainers();
4374 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4375 // workspace.addResourceChangeListener(
4376 // manager.deltaProcessor,
4377 // IResourceChangeEvent.PRE_AUTO_BUILD
4378 // | IResourceChangeEvent.POST_AUTO_BUILD
4379 // | IResourceChangeEvent.POST_CHANGE
4380 // | IResourceChangeEvent.PRE_DELETE
4381 // | IResourceChangeEvent.PRE_CLOSE);
4383 // // startIndexing();
4384 // workspace.addSaveParticipant(PHPeclipsePlugin.getDefault(), manager);
4386 // } catch (CoreException e) {
4387 // } catch (RuntimeException e) {
4388 // manager.shutdown();
4393 * Internal updating of a variable values (null path meaning removal),
4394 * allowing to change multiple variable values at once.
4396 // private static void updateVariableValues(
4397 // String[] variableNames,
4398 // IPath[] variablePaths,
4399 // IProgressMonitor monitor) throws JavaModelException {
4401 // if (monitor != null && monitor.isCanceled()) return;
4403 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4404 // System.out.println("CPVariable SET - setting variables: {" +
4405 // ProjectPrefUtil.toString(variableNames) //$NON-NLS-1$
4406 // + "} with values: " + ProjectPrefUtil.toString(variablePaths));
4410 // int varLength = variableNames.length;
4412 // // gather classpath information for updating
4413 // final HashMap affectedProjects = new HashMap(5);
4414 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
4415 // IJavaModel model = manager.getJavaModel();
4417 // // filter out unmodified variables
4418 // int discardCount = 0;
4419 // for (int i = 0; i < varLength; i++){
4420 // String variableName = variableNames[i];
4421 // IPath oldPath = (IPath)JavaModelManager.variableGet(variableName); // if
4422 // reentering will provide previous session value
4423 // if (oldPath == JavaModelManager.VariableInitializationInProgress){
4424 // IPath previousPath =
4425 // (IPath)JavaModelManager.PreviousSessionVariables.get(variableName);
4426 // if (previousPath != null){
4427 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4428 // System.out.println("CPVariable INIT - reentering access to variable: " +
4429 // variableName+ " during its initialization, will see previous value: "+
4430 // previousPath); //$NON-NLS-1$ //$NON-NLS-2$
4432 // JavaModelManager.variablePut(variableName, previousPath); // replace
4433 // value so reentering calls are seeing old value
4435 // oldPath = null; //33695 - cannot filter out restored variable, must
4436 // update affected project to reset cached CP
4438 // if (oldPath != null && oldPath.equals(variablePaths[i])){
4439 // variableNames[i] = null;
4443 // if (discardCount > 0){
4444 // if (discardCount == varLength) return;
4445 // int changedLength = varLength - discardCount;
4446 // String[] changedVariableNames = new String[changedLength];
4447 // IPath[] changedVariablePaths = new IPath[changedLength];
4448 // for (int i = 0, index = 0; i < varLength; i++){
4449 // if (variableNames[i] != null){
4450 // changedVariableNames[index] = variableNames[i];
4451 // changedVariablePaths[index] = variablePaths[i];
4455 // variableNames = changedVariableNames;
4456 // variablePaths = changedVariablePaths;
4457 // varLength = changedLength;
4460 // if (monitor != null && monitor.isCanceled()) return;
4462 // if (model != null) {
4463 // IJavaProject[] projects = model.getJavaProjects();
4464 // nextProject : for (int i = 0, projectLength = projects.length; i <
4465 // projectLength; i++){
4466 // IJavaProject project = projects[i];
4468 // // check to see if any of the modified variables is present on the
4470 // IClasspathEntry[] classpath = project.getRawClasspath();
4471 // for (int j = 0, cpLength = classpath.length; j < cpLength; j++){
4473 // IClasspathEntry entry = classpath[j];
4474 // for (int k = 0; k < varLength; k++){
4476 // String variableName = variableNames[k];
4477 // if (entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE){
4479 // if (variableName.equals(entry.getPath().segment(0))){
4480 // affectedProjects.put(project, project.getResolvedClasspath(true));
4481 // continue nextProject;
4483 // IPath sourcePath, sourceRootPath;
4484 // if (((sourcePath = entry.getSourceAttachmentPath()) != null &&
4485 // variableName.equals(sourcePath.segment(0)))
4486 // || ((sourceRootPath = entry.getSourceAttachmentRootPath()) != null &&
4487 // variableName.equals(sourceRootPath.segment(0)))) {
4489 // affectedProjects.put(project, project.getResolvedClasspath(true));
4490 // continue nextProject;
4497 // // update variables
4498 // for (int i = 0; i < varLength; i++){
4499 // JavaModelManager.variablePut(variableNames[i], variablePaths[i]);
4501 // final String[] dbgVariableNames = variableNames;
4503 // // update affected project classpaths
4504 // if (!affectedProjects.isEmpty()) {
4506 // JavaCore_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt.run(
4507 // new IWorkspaceRunnable() {
4508 // public void run(IProgressMonitor monitor) throws CoreException {
4509 // // propagate classpath change
4510 // Iterator projectsToUpdate = affectedProjects.keySet().iterator();
4511 // while (projectsToUpdate.hasNext()) {
4513 // if (monitor != null && monitor.isCanceled()) return;
4515 // JavaProject project = (JavaProject) projectsToUpdate.next();
4517 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4518 // System.out.println("CPVariable SET - updating affected project:
4519 // ["+project.getElementName()+"] due to setting variables: "+
4520 // ProjectPrefUtil.toString(dbgVariableNames)); //$NON-NLS-1$ //$NON-NLS-2$
4524 // .setRawClasspath(
4525 // project.getRawClasspath(),
4526 // SetClasspathOperation.ReuseOutputLocation,
4527 // null, // don't call beginTask on the monitor (see
4528 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=3717)
4529 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can change resources
4530 // (IClasspathEntry[]) affectedProjects.get(project),
4531 // false, // updating - no validation
4532 // false); // updating - no need to save
4537 // } catch (CoreException e) {
4538 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4539 // System.out.println("CPVariable SET - FAILED DUE TO EXCEPTION:
4540 // "+ProjectPrefUtil.toString(dbgVariableNames)); //$NON-NLS-1$
4541 // e.printStackTrace();
4543 // if (e instanceof JavaModelException) {
4544 // throw (JavaModelException)e;
4546 // throw new JavaModelException(e);
4552 * (non-Javadoc) Startup the JavaCore plug-in. <p> Registers the
4553 * JavaModelManager as a resource changed listener and save participant.
4554 * Starts the background indexing, and restore saved classpath variable
4555 * values. <p> @throws Exception
4557 * @see org.eclipse.core.runtime.Plugin#start(BundleContext)
4559 // public static void start(final Plugin plugin, BundleContext context)
4560 // throws Exception {
4561 // // super.start(context);
4563 // final JavaModelManager manager = JavaModelManager.getJavaModelManager();
4565 // manager.configurePluginDebugOptions();
4567 // // request state folder creation (workaround 19885)
4568 // JavaCore.getPlugin().getStateLocation();
4570 // // retrieve variable values
4571 // //JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4572 // JavaModelManager.PluginPreferencesListener());
4573 // // manager.loadVariablesAndContainers();
4575 // final IWorkspace workspace = ResourcesPlugin.getWorkspace();
4576 // workspace.addResourceChangeListener(
4577 // manager.deltaState,
4578 // IResourceChangeEvent.PRE_BUILD
4579 // | IResourceChangeEvent.POST_BUILD
4580 // | IResourceChangeEvent.POST_CHANGE
4581 // | IResourceChangeEvent.PRE_DELETE
4582 // | IResourceChangeEvent.PRE_CLOSE);
4584 // // startIndexing();
4586 // // process deltas since last activated in indexer thread so that indexes
4588 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658
4589 // Job processSavedState = new
4590 // Job(ProjectPrefUtil.bind("savedState.jobName")) {
4592 // protected IStatus run(IProgressMonitor monitor) {
4594 // // add save participant and process delta atomically
4595 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59937
4597 // new IWorkspaceRunnable() {
4598 // public void run(IProgressMonitor progress) throws CoreException {
4599 // // ISavedState savedState = workspace.addSaveParticipant(JavaCore.this,
4601 // ISavedState savedState = workspace.addSaveParticipant(plugin, manager);
4602 // if (savedState != null) {
4603 // // the event type coming from the saved state is always POST_AUTO_BUILD
4604 // // force it to be POST_CHANGE so that the delta processor can handle it
4605 // manager.deltaState.getDeltaProcessor().overridenEventType =
4606 // IResourceChangeEvent.POST_CHANGE;
4607 // savedState.processResourceChangeEvents(manager.deltaState);
4612 // } catch (CoreException e) {
4613 // return e.getStatus();
4615 // return Status.OK_STATUS;
4618 // processSavedState.setSystem(true);
4619 // processSavedState.setPriority(Job.SHORT); // process asap
4620 // processSavedState.schedule();
4621 // } catch (RuntimeException e) {
4622 // manager.shutdown();
4627 * (non-Javadoc) Shutdown the JavaCore plug-in. <p> De-registers the
4628 * JavaModelManager as a resource changed listener and save participant. <p>
4630 * @see org.eclipse.core.runtime.Plugin#stop(BundleContext)
4632 // public static void stop(Plugin plugin, BundleContext context)
4633 // throws Exception {
4635 // plugin.savePluginPreferences();
4636 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4637 // workspace.removeResourceChangeListener(JavaModelManager
4638 // .getJavaModelManager().deltaState);
4639 // workspace.removeSaveParticipant(plugin);
4641 // JavaModelManager.getJavaModelManager().shutdown();
4643 // // ensure we call super.stop as the last thing
4644 // // super.stop(context);