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;
20 //import net.sourceforge.phpdt.internal.corext.Assert;
21 import org.eclipse.core.runtime.Assert;
23 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
25 import org.eclipse.core.resources.IFile;
26 import org.eclipse.core.resources.IFolder;
27 import org.eclipse.core.resources.IMarker;
28 import org.eclipse.core.resources.IMarkerDelta;
29 import org.eclipse.core.resources.IProject;
30 import org.eclipse.core.resources.IProjectDescription;
31 import org.eclipse.core.resources.IResource;
32 import org.eclipse.core.resources.IResourceChangeListener;
33 import org.eclipse.core.resources.IWorkspaceRoot;
34 import org.eclipse.core.resources.ResourcesPlugin;
35 import org.eclipse.core.runtime.CoreException;
36 import org.eclipse.core.runtime.IConfigurationElement;
37 import org.eclipse.core.runtime.IPath;
38 import org.eclipse.core.runtime.IProgressMonitor;
39 import org.eclipse.core.runtime.Plugin;
40 import org.eclipse.core.runtime.Preferences;
42 public class JavaCore {
44 // public static HashSet OptionNames = new HashSet(20);
46 * The plug-in identifier of the Java core support (value
47 * <code>"net.sourceforge.phpeclipse"</code>)
49 // public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.core";
51 public static final String PLUGIN_ID = PHPeclipsePlugin.PLUGIN_ID;
54 * Possible configurable option ID.
56 * @see #getDefaultOptions
59 public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; //$NON-NLS-1$
62 * Possible configurable option ID.
64 * @see #getDefaultOptions
67 public static final String FORMATTER_NEWLINE_OPENING_BRACE = PLUGIN_ID
68 + ".formatter.newline.openingBrace"; //$NON-NLS-1$
71 * Possible configurable option ID.
73 * @see #getDefaultOptions
76 public static final String FORMATTER_NEWLINE_CONTROL = PLUGIN_ID
77 + ".formatter.newline.controlStatement"; //$NON-NLS-1$
80 * Possible configurable option ID.
82 * @see #getDefaultOptions
85 public static final String FORMATTER_NEWLINE_ELSE_IF = PLUGIN_ID
86 + ".formatter.newline.elseIf"; //$NON-NLS-1$
89 * Possible configurable option ID.
91 * @see #getDefaultOptions
94 public static final String FORMATTER_NEWLINE_EMPTY_BLOCK = PLUGIN_ID
95 + ".formatter.newline.emptyBlock"; //$NON-NLS-1$
98 * Possible configurable option ID.
100 * @see #getDefaultOptions
103 public static final String FORMATTER_CLEAR_BLANK_LINES = PLUGIN_ID
104 + ".formatter.newline.clearAll"; //$NON-NLS-1$
107 * Possible configurable option ID.
109 * @see #getDefaultOptions
112 public static final String FORMATTER_LINE_SPLIT = PLUGIN_ID
113 + ".formatter.lineSplit"; //$NON-NLS-1$
116 * Possible configurable option ID.
118 * @see #getDefaultOptions
121 public static final String FORMATTER_COMPACT_ASSIGNMENT = PLUGIN_ID
122 + ".formatter.style.assignment"; //$NON-NLS-1$
125 * Possible configurable option ID.
127 * @see #getDefaultOptions
130 public static final String FORMATTER_COMPACT_STRING_CONCATENATION = PLUGIN_ID
131 + ".formatter.style.compactStringConcatenation"; //$NON-NLS-1$
133 * Possible configurable option ID.
135 * @see #getDefaultOptions
138 public static final String FORMATTER_COMPACT_ARRAYS = PLUGIN_ID
139 + ".formatter.style.compactArrays"; //$NON-NLS-1$
142 * Possible configurable option ID.
144 * @see #getDefaultOptions
147 public static final String FORMATTER_TAB_CHAR = PLUGIN_ID
148 + ".formatter.tabulation.char"; //$NON-NLS-1$
151 * Possible configurable option ID.
153 * @see #getDefaultOptions
156 public static final String FORMATTER_TAB_SIZE = PLUGIN_ID
157 + ".formatter.tabulation.size"; //$NON-NLS-1$
160 * Possible configurable option value.
162 * @see #getDefaultOptions
165 public static final String INSERT = "insert"; //$NON-NLS-1$
168 * Possible configurable option value.
170 * @see #getDefaultOptions
173 public static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$
176 * Possible configurable option value.
178 * @see #getDefaultOptions
181 public static final String PRESERVE_ONE = "preserve one"; //$NON-NLS-1$
184 * Possible configurable option value.
186 * @see #getDefaultOptions
189 public static final String CLEAR_ALL = "clear all"; //$NON-NLS-1$
192 * Possible configurable option value.
194 * @see #getDefaultOptions
197 public static final String NORMAL = "normal"; //$NON-NLS-1$
200 * Possible configurable option value.
202 * @see #getDefaultOptions
205 public static final String COMPACT = "compact"; //$NON-NLS-1$
208 * Possible configurable option value.
210 * @see #getDefaultOptions
213 public static final String TAB = "tab"; //$NON-NLS-1$
216 * Possible configurable option value.
218 * @see #getDefaultOptions
221 public static final String SPACE = "space"; //$NON-NLS-1$
224 * Possible configurable option value.
226 * @see #getDefaultOptions
229 public static final String ENABLED = "enabled"; //$NON-NLS-1$
232 * Possible configurable option value.
234 * @see #getDefaultOptions
237 public static final String DISABLED = "disabled"; //$NON-NLS-1$
240 * Possible configurable option value.
242 * @see #getDefaultOptions
245 public static final String CLEAN = "clean"; //$NON-NLS-1$
248 * Possible configurable option ID.
250 * @see #getDefaultOptions
253 public static final String COMPILER_TASK_TAGS = PLUGIN_ID
254 + ".compiler.taskTags"; //$NON-NLS-1$
257 * Name of the handle id attribute in a Java marker.
259 protected static final String ATT_HANDLE_ID = "net.sourceforge.phpdt.internal.core.JavaModelManager.handleId"; //$NON-NLS-1$
261 // *************** Possible IDs for configurable options.
262 // ********************
265 * Possible configurable option ID.
267 * @see #getDefaultOptions()
269 public static final String COMPILER_LOCAL_VARIABLE_ATTR = PLUGIN_ID
270 + ".compiler.debug.localVariable"; //$NON-NLS-1$
273 * Possible configurable option ID.
275 * @see #getDefaultOptions()
277 public static final String COMPILER_LINE_NUMBER_ATTR = PLUGIN_ID
278 + ".compiler.debug.lineNumber"; //$NON-NLS-1$
281 * Possible configurable option ID.
283 * @see #getDefaultOptions
285 public static final String COMPILER_SOURCE_FILE_ATTR = PLUGIN_ID
286 + ".compiler.debug.sourceFile"; //$NON-NLS-1$
289 * Possible configurable option ID.
291 * @see #getDefaultOptions
293 public static final String COMPILER_CODEGEN_UNUSED_LOCAL = PLUGIN_ID
294 + ".compiler.codegen.unusedLocal"; //$NON-NLS-1$
297 * Possible configurable option ID.
299 * @see #getDefaultOptions
301 public static final String COMPILER_CODEGEN_TARGET_PLATFORM = PLUGIN_ID
302 + ".compiler.codegen.targetPlatform"; //$NON-NLS-1$
305 * Possible configurable option ID.
307 * @see #getDefaultOptions
309 public static final String COMPILER_PB_PHP_VAR_DEPRECATED = CompilerOptions.OPTION_PHPVarDeprecatedWarning; //$NON-NLS-1$
311 public static final String COMPILER_PB_PHP_KEYWORD = CompilerOptions.OPTION_PHPBadStyleKeywordWarning; //$NON-NLS-1$
313 public static final String COMPILER_PB_PHP_UPPERCASE_IDENTIFIER = CompilerOptions.OPTION_PHPBadStyleUppercaseIdentifierWarning; //$NON-NLS-1$
315 public static final String COMPILER_PB_PHP_FILE_NOT_EXIST = CompilerOptions.OPTION_PHPIncludeNotExistWarning; //$NON-NLS-1$
317 public static final String COMPILER_PB_UNINITIALIZED_LOCAL_VARIABLE = CompilerOptions.OPTION_UninitializedLocalVariableWarning; //$NON-NLS-1$
319 public static final String COMPILER_PB_UNREACHABLE_CODE = CompilerOptions.OPTION_CodeCannotBeReachedWarning; //$NON-NLS-1$
322 * Possible configurable option ID.
324 * @see #getDefaultOptions
326 // public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID
327 // + ".compiler.problem.unreachableCode"; //$NON-NLS-1$
329 * Possible configurable option ID.
331 * @see #getDefaultOptions
333 public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID
334 + ".compiler.problem.invalidImport"; //$NON-NLS-1$
337 * Possible configurable option ID.
339 * @see #getDefaultOptions
341 public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID
342 + ".compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
345 * Possible configurable option ID.
347 * @see #getDefaultOptions
349 public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID
350 + ".compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
353 * Possible configurable option ID.
355 * @see #getDefaultOptions
357 public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID
358 + ".compiler.problem.deprecation"; //$NON-NLS-1$
361 * Possible configurable option ID.
363 * @see #getDefaultOptions
366 public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID
367 + ".compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
370 * Possible configurable option ID.
372 * @see #getDefaultOptions
374 public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID
375 + ".compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
378 * Possible configurable option ID.
380 * @see #getDefaultOptions
382 public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID
383 + ".compiler.problem.unusedLocal"; //$NON-NLS-1$
386 * Possible configurable option ID.
388 * @see #getDefaultOptions
390 public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID
391 + ".compiler.problem.unusedParameter"; //$NON-NLS-1$
394 * Possible configurable option ID.
396 * @see #getDefaultOptions
399 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID
400 + ".compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
403 * Possible configurable option ID.
405 * @see #getDefaultOptions
408 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID
409 + ".compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
412 * Possible configurable option ID.
414 * @see #getDefaultOptions
417 public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID
418 + ".compiler.problem.unusedImport"; //$NON-NLS-1$
421 * Possible configurable option ID.
423 * @see #getDefaultOptions
425 public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID
426 + ".compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
429 * Possible configurable option ID.
431 * @see #getDefaultOptions
434 public static final String COMPILER_PB_NON_NLS_STRING_LITERAL = PLUGIN_ID
435 + ".compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
438 * Possible configurable option ID.
440 * @see #getDefaultOptions
443 public static final String COMPILER_PB_ASSERT_IDENTIFIER = PLUGIN_ID
444 + ".compiler.problem.assertIdentifier"; //$NON-NLS-1$
447 * Possible configurable option ID.
449 * @see #getDefaultOptions
452 public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID
453 + ".compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
456 * Possible configurable option ID.
458 * @see #getDefaultOptions
461 public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID
462 + ".compiler.problem.noEffectAssignment"; //$NON-NLS-1$
465 * Possible configurable option ID.
467 * @see #getDefaultOptions
470 public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID
471 + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
474 * Possible configurable option ID.
476 * @see #getDefaultOptions
479 public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID
480 + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
483 * Possible configurable option ID.
485 * @see #getDefaultOptions
488 public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID
489 + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
492 * Possible configurable option ID.
494 * @see #getDefaultOptions
497 public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID
498 + ".compiler.maxProblemPerUnit"; //$NON-NLS-1$
501 * Possible configurable option ID.
503 * @see #getDefaultOptions
506 public static final String COMPILER_SOURCE = PLUGIN_ID + ".compiler.source"; //$NON-NLS-1$
509 * Possible configurable option ID.
511 * @see #getDefaultOptions
514 public static final String COMPILER_COMPLIANCE = PLUGIN_ID
515 + ".compiler.compliance"; //$NON-NLS-1$
518 * Possible configurable option ID.
520 * @see #getDefaultOptions
523 public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID
524 + ".compiler.taskPriorities"; //$NON-NLS-1$
527 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
529 * @see #getDefaultOptions
532 public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$
535 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
537 * @see #getDefaultOptions
540 public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$
543 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
545 * @see #getDefaultOptions
548 public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$
551 * Possible configurable option ID.
553 * @see #getDefaultOptions
555 public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID
556 + ".computeJavaBuildOrder"; //$NON-NLS-1$
559 * Possible configurable option ID.
561 * @see #getDefaultOptions
564 public static final String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER = PLUGIN_ID
565 + ".builder.resourceCopyExclusionFilter"; //$NON-NLS-1$
568 * Possible configurable option ID.
570 * @see #getDefaultOptions
573 public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID
574 + ".builder.duplicateResourceTask"; //$NON-NLS-1$
577 * Possible configurable option ID.
579 * @see #getDefaultOptions
582 public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID
583 + ".builder.cleanOutputFolder"; //$NON-NLS-1$
586 * Possible configurable option ID.
588 * @see #getDefaultOptions
591 public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID
592 + ".incompleteClasspath"; //$NON-NLS-1$
595 * Possible configurable option ID.
597 * @see #getDefaultOptions
600 public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID
601 + ".circularClasspath"; //$NON-NLS-1$
604 * Possible configurable option ID.
606 * @see #getDefaultOptions
609 public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID
610 + ".builder.invalidClasspath"; //$NON-NLS-1$
613 * Possible configurable option ID.
615 * @see #getDefaultOptions
618 public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID
619 + ".classpath.exclusionPatterns"; //$NON-NLS-1$
622 * Possible configurable option ID.
624 * @see #getDefaultOptions
627 public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID
628 + ".classpath.multipleOutputLocations"; //$NON-NLS-1$
635 public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$
638 * Default task priority
642 public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; //$NON-NLS-1$
645 * Possible configurable option ID
647 * @see #getDefaultOptions
650 public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID
651 + ".formatter.space.castexpression"; //$NON-NLS-1$
654 * Possible configurable option ID.
656 * @see #getDefaultOptions
659 public static final String CODEASSIST_VISIBILITY_CHECK = PLUGIN_ID
660 + ".codeComplete.visibilityCheck"; //$NON-NLS-1$
663 * Possible configurable option ID.
665 * @see #getDefaultOptions
668 public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID
669 + ".codeComplete.forceImplicitQualification"; //$NON-NLS-1$
672 * Possible configurable option ID.
674 * @see #getDefaultOptions
677 public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID
678 + ".codeComplete.fieldPrefixes"; //$NON-NLS-1$
681 * Possible configurable option ID.
683 * @see #getDefaultOptions
686 public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID
687 + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
690 * Possible configurable option ID.
692 * @see #getDefaultOptions
695 public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID
696 + ".codeComplete.localPrefixes"; //$NON-NLS-1$
699 * Possible configurable option ID.
701 * @see #getDefaultOptions
704 public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID
705 + ".codeComplete.argumentPrefixes"; //$NON-NLS-1$
708 * Possible configurable option ID.
710 * @see #getDefaultOptions
713 public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID
714 + ".codeComplete.fieldSuffixes"; //$NON-NLS-1$
717 * Possible configurable option ID.
719 * @see #getDefaultOptions
722 public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID
723 + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
726 * Possible configurable option ID.
728 * @see #getDefaultOptions
731 public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID
732 + ".codeComplete.localSuffixes"; //$NON-NLS-1$
735 * Possible configurable option ID.
737 * @see #getDefaultOptions
740 public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID
741 + ".codeComplete.argumentSuffixes"; //$NON-NLS-1$
743 // *************** Possible values for configurable options.
744 // ********************
747 * Possible configurable option value.
749 * @see #getDefaultOptions
751 public static final String GENERATE = "generate"; //$NON-NLS-1$
754 * Possible configurable option value.
756 * @see #getDefaultOptions
758 public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
761 * Possible configurable option value.
763 * @see #getDefaultOptions
765 public static final String PRESERVE = "preserve"; //$NON-NLS-1$
768 * Possible configurable option value.
770 * @see #getDefaultOptions
772 public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
775 * Possible configurable option value.
777 * @see #getDefaultOptions
779 public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$
782 * Possible configurable option value.
784 * @see #getDefaultOptions
786 public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$
789 * Possible configurable option value.
791 * @see #getDefaultOptions
794 public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
797 * Possible configurable option value.
799 * @see #getDefaultOptions
802 public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
805 * Possible configurable option value.
807 * @see #getDefaultOptions
810 public static final String ABORT = "abort"; //$NON-NLS-1$
813 * Possible configurable option value.
815 * @see #getDefaultOptions
817 public static final String ERROR = "error"; //$NON-NLS-1$
820 * Possible configurable option value.
822 * @see #getDefaultOptions
824 public static final String WARNING = "warning"; //$NON-NLS-1$
827 * Possible configurable option value.
829 * @see #getDefaultOptions
831 public static final String IGNORE = "ignore"; //$NON-NLS-1$
834 * Possible configurable option value.
836 * @see #getDefaultOptions
838 public static final String COMPUTE = "compute"; //$NON-NLS-1$
841 * Possible configurable option value.
843 * @see #getDefaultOptions
848 * Returns a table of all known configurable options with their default
849 * values. These options allow to configure the behaviour of the underlying
850 * components. The client may safely use the result as a template that they
851 * can modify and then pass to <code>setOptions</code>.
853 * Helper constants have been defined on JavaCore for each of the option ID
854 * and their possible constant values.
856 * Note: more options might be added in further releases.
860 * RECOGNIZED OPTIONS:
861 * COMPILER / Generating Local Variable Debug Attribute
862 * When generated, this attribute will enable local variable names
863 * to be displayed in debugger, only in place where variables are
864 * definitely assigned (.class file is then bigger)
865 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.localVariable"
866 * - possible values: { "generate", "do not generate" }
867 * - default: "generate"
869 * COMPILER / Generating Line Number Debug Attribute
870 * When generated, this attribute will enable source code highlighting in debugger
871 * (.class file is then bigger).
872 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.lineNumber"
873 * - possible values: { "generate", "do not generate" }
874 * - default: "generate"
876 * COMPILER / Generating Source Debug Attribute
877 * When generated, this attribute will enable the debugger to present the
878 * corresponding source code.
879 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.sourceFile"
880 * - possible values: { "generate", "do not generate" }
881 * - default: "generate"
883 * COMPILER / Preserving Unused Local Variables
884 * Unless requested to preserve unused local variables (i.e. never read), the
885 * compiler will optimize them out, potentially altering debugging
886 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.unusedLocal"
887 * - possible values: { "preserve", "optimize out" }
888 * - default: "preserve"
890 * COMPILER / Defining Target Java Platform
891 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
892 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
893 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.targetPlatform"
894 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
895 * - default: "1.1"
897 * COMPILER / Reporting Unreachable Code
898 * Unreachable code can optionally be reported as an error, warning or simply
899 * ignored. The bytecode generation will always optimized it out.
900 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unreachableCode"
901 * - possible values: { "error", "warning", "ignore" }
902 * - default: "error"
904 * COMPILER / Reporting Invalid Import
905 * An import statement that cannot be resolved might optionally be reported
906 * as an error, as a warning or ignored.
907 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.invalidImport"
908 * - possible values: { "error", "warning", "ignore" }
909 * - default: "error"
911 * COMPILER / Reporting Attempt to Override Package-Default Method
912 * A package default method is not visible in a different package, and thus
913 * cannot be overridden. When enabling this option, the compiler will signal
914 * such scenarii either as an error or a warning.
915 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
916 * - possible values: { "error", "warning", "ignore" }
917 * - default: "warning"
919 * COMPILER / Reporting Method With Constructor Name
920 * Naming a method with a constructor name is generally considered poor
921 * style programming. When enabling this option, the compiler will signal such
922 * scenarii either as an error or a warning.
923 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.methodWithConstructorName"
924 * - possible values: { "error", "warning", "ignore" }
925 * - default: "warning"
927 * COMPILER / Reporting Deprecation
928 * When enabled, the compiler will signal use of deprecated API either as an
929 * error or a warning.
930 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecation"
931 * - possible values: { "error", "warning", "ignore" }
932 * - default: "warning"
934 * COMPILER / Reporting Deprecation Inside Deprecated Code
935 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
936 * The severity of the problem is controlled with option "org.phpeclipse.phpdt.core.compiler.problem.deprecation".
937 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
938 * - possible values: { "enabled", "disabled" }
939 * - default: "disabled"
941 * COMPILER / Reporting Hidden Catch Block
942 * Locally to a try statement, some catch blocks may hide others , e.g.
943 * try { throw new java.io.CharConversionException();
944 * } catch (java.io.CharConversionException e) {
945 * } catch (java.io.IOException e) {}.
946 * When enabling this option, the compiler will issue an error or a warning for hidden
947 * catch blocks corresponding to checked exceptions
948 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.hiddenCatchBlock"
949 * - possible values: { "error", "warning", "ignore" }
950 * - default: "warning"
952 * COMPILER / Reporting Unused Local
953 * When enabled, the compiler will issue an error or a warning for unused local
954 * variables (i.e. variables never read from)
955 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedLocal"
956 * - possible values: { "error", "warning", "ignore" }
957 * - default: "ignore"
959 * COMPILER / Reporting Unused Parameter
960 * When enabled, the compiler will issue an error or a warning for unused method
961 * parameters (i.e. parameters never read from)
962 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedParameter"
963 * - possible values: { "error", "warning", "ignore" }
964 * - default: "ignore"
966 * COMPILER / Reporting Unused Import
967 * When enabled, the compiler will issue an error or a warning for unused import
969 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedImport"
970 * - possible values: { "error", "warning", "ignore" }
971 * - default: "warning"
973 * COMPILER / Reporting Synthetic Access Emulation
974 * When enabled, the compiler will issue an error or a warning whenever it emulates
975 * access to a non-accessible member of an enclosing type. Such access can have
976 * performance implications.
977 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.syntheticAccessEmulation"
978 * - possible values: { "error", "warning", "ignore" }
979 * - default: "ignore"
981 * COMPILER / Reporting Non-Externalized String Literal
982 * When enabled, the compiler will issue an error or a warning for non externalized
983 * String literal (i.e. non tagged with //$NON-NLS-<n>$).
984 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
985 * - possible values: { "error", "warning", "ignore" }
986 * - default: "ignore"
988 * COMPILER / Reporting Usage of 'assert' Identifier
989 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
990 * used as an identifier (reserved keyword in 1.4)
991 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.assertIdentifier"
992 * - possible values: { "error", "warning", "ignore" }
993 * - default: "ignore"
995 * COMPILER / Reporting Usage of expression receiver on static invocation/field access
996 * When enabled, the compiler will issue an error or a warning whenever a static field
997 * or method is accessed with an expression receiver.
998 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.staticAccessReceiver"
999 * - possible values: { "error", "warning", "ignore" }
1000 * - default: "warning"
1002 * COMPILER / Reporting Assignment with no effect
1003 * When enabled, the compiler will issue an error or a warning whenever an assignment
1004 * has no effect (e.g 'x = x').
1005 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.noEffectAssignment"
1006 * - possible values: { "error", "warning", "ignore" }
1007 * - default: "warning"
1009 * COMPILER / Setting Source Compatibility Mode
1010 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
1011 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
1012 * level should be set to "1.4" and the compliance mode should be "1.4".
1013 * - option id: "org.phpeclipse.phpdt.core.compiler.source"
1014 * - possible values: { "1.3", "1.4" }
1015 * - default: "1.3"
1017 * COMPILER / Setting Compliance Level
1018 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
1019 * should not go beyond "1.3" level.
1020 * - option id: "org.phpeclipse.phpdt.core.compiler.compliance"
1021 * - possible values: { "1.3", "1.4" }
1022 * - default: "1.3"
1024 * COMPILER / Maximum number of problems reported per compilation unit
1025 * Specify the maximum number of problems reported on each compilation unit.
1026 * - option id: "org.phpeclipse.phpdt.core.compiler.maxProblemPerUnit"
1027 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
1028 * - default: "100"
1030 * COMPILER / Define the Automatic Task Tags
1031 * When the tag is non empty, the compiler will issue a task marker whenever it encounters
1032 * one of the corresponding tag inside any comment in Java source code.
1033 * Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed.
1034 * - option id: "org.phpeclipse.phpdt.core.compiler.taskTags"
1035 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card
1036 * - default: ""
1037 * COMPILER / Define the Automatic Task Priorities
1038 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
1039 * of the task markers issued by the compiler.
1040 * If the default is specified, the priority of each task marker is "NORMAL".
1041 * - option id: "org.phpeclipse.phpdt.core.compiler.taskPriorities"
1042 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
1043 * - default: ""
1045 * BUILDER / Specifying Filters for Resource Copying Control
1046 * Allow to specify some filters to control the resource copy process.
1047 * - option id: "org.phpeclipse.phpdt.core.builder.resourceCopyExclusionFilter"
1048 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
1049 * or the name of a folder which ends with '/'
1050 * - default: ""
1052 * BUILDER / Abort if Invalid Classpath
1053 * Allow to toggle the builder to abort if the classpath is invalid
1054 * - option id: "org.phpeclipse.phpdt.core.builder.invalidClasspath"
1055 * - possible values: { "abort", "ignore" }
1056 * - default: "ignore"
1058 * BUILDER / Cleaning Output Folder(s)
1059 * Indicate whether the JavaBuilder is allowed to clean the output folders
1060 * when performing full build operations.
1061 * - option id: "org.phpeclipse.phpdt.core.builder.cleanOutputFolder"
1062 * - possible values: { "clean", "ignore" }
1063 * - default: "clean"
1065 * JAVACORE / Computing Project Build Order
1066 * Indicate whether JavaCore should enforce the project build order to be based on
1067 * the classpath prerequisite chain. When requesting to compute, this takes over
1068 * the platform default order (based on project references).
1069 * - option id: "org.phpeclipse.phpdt.core.computeJavaBuildOrder"
1070 * - possible values: { "compute", "ignore" }
1071 * - default: "ignore"
1073 * JAVACORE / Specify Default Source Encoding Format
1074 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
1075 * to 'ResourcesPlugin.getEncoding()'.
1076 * - option id: "org.phpeclipse.phpdt.core.encoding"
1077 * - possible values: { any of the supported encoding name}.
1078 * - default: <platform default>
1080 * JAVACORE / Reporting Incomplete Classpath
1081 * An entry on the classpath doesn't exist or is not visible (e.g. a referenced project is closed).
1082 * - option id: "org.phpeclipse.phpdt.core.incompleteClasspath"
1083 * - possible values: { "error", "warning"}
1084 * - default: "error"
1086 * JAVACORE / Reporting Classpath Cycle
1087 * A project is involved in a cycle.
1088 * - option id: "org.phpeclipse.phpdt.core.circularClasspath"
1089 * - possible values: { "error", "warning" }
1090 * - default: "error"
1092 * FORMATTER / Inserting New Line Before Opening Brace
1093 * When Insert, a new line is inserted before an opening brace, otherwise nothing
1095 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.openingBrace"
1096 * - possible values: { "insert", "do not insert" }
1097 * - default: "do not insert"
1099 * FORMATTER / Inserting New Line Inside Control Statement
1100 * When Insert, a new line is inserted between } and following else, catch, finally
1101 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.controlStatement"
1102 * - possible values: { "insert", "do not insert" }
1103 * - default: "do not insert"
1105 * FORMATTER / Clearing Blank Lines
1106 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
1107 * and all others removed.
1108 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.clearAll"
1109 * - possible values: { "clear all", "preserve one" }
1110 * - default: "preserve one"
1112 * FORMATTER / Inserting New Line Between Else/If
1113 * When Insert, a blank line is inserted between an else and an if when they are
1114 * contiguous. When choosing to not insert, else-if will be kept on the same
1115 * line when possible.
1116 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.elseIf"
1117 * - possible values: { "insert", "do not insert" }
1118 * - default: "do not insert"
1120 * FORMATTER / Inserting New Line In Empty Block
1121 * When insert, a line break is inserted between contiguous { and }, if } is not followed
1123 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.emptyBlock"
1124 * - possible values: { "insert", "do not insert" }
1125 * - default: "insert"
1127 * FORMATTER / Splitting Lines Exceeding Length
1128 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
1129 * disable line splitting
1130 * - option id: "org.phpeclipse.phpdt.core.formatter.lineSplit"
1131 * - possible values: "<n>", where n is zero or a positive integer
1132 * - default: "80"
1134 * FORMATTER / Compacting Assignment
1135 * Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space
1136 * is inserted before the assignment operator
1137 * - option id: "org.phpeclipse.phpdt.core.formatter.style.assignment"
1138 * - possible values: { "compact", "normal" }
1139 * - default: "normal"
1141 * FORMATTER / Defining Indentation Character
1142 * Either choose to indent with tab characters or spaces
1143 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.char"
1144 * - possible values: { "tab", "space" }
1145 * - default: "tab"
1147 * FORMATTER / Defining Space Indentation Length
1148 * When using spaces, set the amount of space characters to use for each
1150 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.size"
1151 * - possible values: "<n>", where n is a positive integer
1152 * - default: "4"
1154 * CODEASSIST / Activate Visibility Sensitive Completion
1155 * When active, completion doesn't show that you can not see
1156 * (e.g. you can not see private methods of a super class).
1157 * - option id: "org.phpeclipse.phpdt.core.codeComplete.visibilityCheck"
1158 * - possible values: { "enabled", "disabled" }
1159 * - default: "disabled"
1161 * CODEASSIST / Automatic Qualification of Implicit Members
1162 * When active, completion automatically qualifies completion on implicit
1163 * field references and message expressions.
1164 * - option id: "org.phpeclipse.phpdt.core.codeComplete.forceImplicitQualification"
1165 * - possible values: { "enabled", "disabled" }
1166 * - default: "disabled"
1168 * CODEASSIST / Define the Prefixes for Field Name
1169 * When the prefixes is non empty, completion for field name will begin with
1170 * one of the proposed prefixes.
1171 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldPrefixes"
1172 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1173 * - default: ""
1175 * CODEASSIST / Define the Prefixes for Static Field Name
1176 * When the prefixes is non empty, completion for static field name will begin with
1177 * one of the proposed prefixes.
1178 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldPrefixes"
1179 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1180 * - default: ""
1182 * CODEASSIST / Define the Prefixes for Local Variable Name
1183 * When the prefixes is non empty, completion for local variable name will begin with
1184 * one of the proposed prefixes.
1185 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localPrefixes"
1186 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1187 * - default: ""
1189 * CODEASSIST / Define the Prefixes for Argument Name
1190 * When the prefixes is non empty, completion for argument name will begin with
1191 * one of the proposed prefixes.
1192 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentPrefixes"
1193 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1194 * - default: ""
1196 * CODEASSIST / Define the Suffixes for Field Name
1197 * When the suffixes is non empty, completion for field name will end with
1198 * one of the proposed suffixes.
1199 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldSuffixes"
1200 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1201 * - default: ""
1203 * CODEASSIST / Define the Suffixes for Static Field Name
1204 * When the suffixes is non empty, completion for static field name will end with
1205 * one of the proposed suffixes.
1206 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldSuffixes"
1207 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1208 * - default: ""
1210 * CODEASSIST / Define the Suffixes for Local Variable Name
1211 * When the suffixes is non empty, completion for local variable name will end with
1212 * one of the proposed suffixes.
1213 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localSuffixes"
1214 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1215 * - default: ""
1217 * CODEASSIST / Define the Suffixes for Argument Name
1218 * When the suffixes is non empty, completion for argument name will end with
1219 * one of the proposed suffixes.
1220 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentSuffixes"
1221 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
1222 * - default: ""
1225 * @return a mutable table containing the default settings of all known options
1238 // public static Hashtable getDefaultOptions() {
1240 // Hashtable defaultOptions = new Hashtable(10);
1242 // // see #initializeDefaultPluginPreferences() for changing default
1244 // Preferences preferences = getPlugin().getPluginPreferences();
1245 // HashSet optionNames = OptionNames;
1247 // // get preferences set to their default
1248 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1249 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1250 // String propertyName = defaultPropertyNames[i];
1251 // if (optionNames.contains(propertyName)) {
1252 // defaultOptions.put(propertyName,
1253 // preferences.getDefaultString(propertyName));
1256 // // get preferences not set to their default
1257 // String[] propertyNames = preferences.propertyNames();
1258 // for (int i = 0; i < propertyNames.length; i++) {
1259 // String propertyName = propertyNames[i];
1260 // if (optionNames.contains(propertyName)) {
1261 // defaultOptions.put(propertyName,
1262 // preferences.getDefaultString(propertyName));
1265 // // get encoding through resource plugin
1266 // defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1268 // return defaultOptions;
1271 * Helper method for returning one option value only. Equivalent to
1272 * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
1273 * may answer <code>null</code> if this option does not exist.
1275 * For a complete description of the configurable options, see
1276 * <code>getDefaultOptions</code>.
1280 * the name of an option
1281 * @return the String value of a given option
1282 * @see JavaCore#getDefaultOptions
1285 // public static String getOption(String optionName) {
1287 // if (CORE_ENCODING.equals(optionName)) {
1288 // return ResourcesPlugin.getEncoding();
1290 // if (OptionNames.contains(optionName)) {
1291 // Preferences preferences = getPlugin().getPluginPreferences();
1292 // return preferences.getString(optionName).trim();
1297 * Returns the table of the current options. Initially, all options have
1298 * their default values, and this method returns a table that includes all
1301 * For a complete description of the configurable options, see
1302 * <code>getDefaultOptions</code>.
1305 * @return table of current settings of all options (key type:
1306 * <code>String</code>; value type: <code>String</code>)
1307 * @see JavaCore#getDefaultOptions
1309 // public static Hashtable getOptions() {
1311 // Hashtable options = new Hashtable(10);
1313 // // see #initializeDefaultPluginPreferences() for changing default
1315 // Plugin plugin = getPlugin();
1316 // if (plugin != null) {
1317 // Preferences preferences = getPlugin().getPluginPreferences();
1318 // HashSet optionNames = OptionNames;
1320 // // get preferences set to their default
1321 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1322 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1323 // String propertyName = defaultPropertyNames[i];
1324 // if (optionNames.contains(propertyName)) {
1325 // options.put(propertyName, preferences.getDefaultString(propertyName));
1328 // // get preferences not set to their default
1329 // String[] propertyNames = preferences.propertyNames();
1330 // for (int i = 0; i < propertyNames.length; i++) {
1331 // String propertyName = propertyNames[i];
1332 // if (optionNames.contains(propertyName)) {
1333 // options.put(propertyName, preferences.getString(propertyName).trim());
1336 // // get encoding through resource plugin
1337 // options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1342 * Sets the current table of options. All and only the options explicitly
1343 * included in the given table are remembered; all previous option settings
1344 * are forgotten, including ones not explicitly mentioned.
1346 * For a complete description of the configurable options, see
1347 * <code>getDefaultOptions</code>.
1351 * the new options (key type: <code>String</code>; value type:
1352 * <code>String</code>), or <code>null</code> to reset all
1353 * options to their default values
1354 * @see JavaCore#getDefaultOptions
1356 // public static void setOptions(Hashtable newOptions) {
1358 // // see #initializeDefaultPluginPreferences() for changing default
1360 // Preferences preferences = getPlugin().getPluginPreferences();
1362 // if (newOptions == null) {
1363 // newOptions = getDefaultOptions();
1365 // Enumeration keys = newOptions.keys();
1366 // while (keys.hasMoreElements()) {
1367 // String key = (String) keys.nextElement();
1368 // if (!OptionNames.contains(key))
1369 // continue; // unrecognized option
1370 // if (key.equals(CORE_ENCODING))
1371 // continue; // skipped, contributed by resource prefs
1372 // String value = (String) newOptions.get(key);
1373 // preferences.setValue(key, value);
1376 // // persist options
1377 // getPlugin().savePluginPreferences();
1379 public static IProject[] getPHPProjects() {
1380 List phpProjectsList = new ArrayList();
1381 IProject[] workspaceProjects = PHPeclipsePlugin.getWorkspace()
1382 .getRoot().getProjects();
1384 for (int i = 0; i < workspaceProjects.length; i++) {
1385 IProject iProject = workspaceProjects[i];
1386 if (isPHPProject(iProject))
1387 phpProjectsList.add(iProject);
1390 IProject[] phpProjects = new IProject[phpProjectsList.size()];
1391 return (IProject[]) phpProjectsList.toArray(phpProjects);
1394 // public static PHPProject getPHPProject(String name) {
1395 // IProject aProject =
1396 // PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
1397 // if (isPHPProject(aProject)) {
1398 // PHPProject thePHPProject = new PHPProject();
1399 // thePHPProject.setProject(aProject);
1400 // return thePHPProject;
1405 public static boolean isPHPProject(IProject aProject) {
1407 return aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID);
1408 } catch (CoreException e) {
1414 // public static PHPFile create(IFile aFile) {
1415 // if (PHPFile.EXTENSION.equalsIgnoreCase(aFile.getFileExtension()))
1416 // return new PHPFile(aFile);
1417 // if (PHPFile.EXTENSION1.equalsIgnoreCase(aFile.getFileExtension()))
1418 // return new PHPFile(aFile);
1419 // if (PHPFile.EXTENSION2.equalsIgnoreCase(aFile.getFileExtension()))
1420 // return new PHPFile(aFile);
1421 // if (PHPFile.EXTENSION3.equalsIgnoreCase(aFile.getFileExtension()))
1422 // return new PHPFile(aFile);
1423 // if (PHPFile.EXTENSION4.equalsIgnoreCase(aFile.getFileExtension()))
1424 // return new PHPFile(aFile);
1425 // if (PHPFile.EXTENSION5.equalsIgnoreCase(aFile.getFileExtension()))
1426 // return new PHPFile(aFile);
1431 // public static PHPProject create(IProject aProject) {
1434 // if (aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1435 // PHPProject project = new PHPProject();
1436 // project.setProject(aProject);
1439 // } catch (CoreException e) {
1440 // System.err.println("Exception occurred in PHPCore#create(IProject): " +
1447 public static void addPHPNature(IProject project, IProgressMonitor monitor)
1448 throws CoreException {
1449 if (!project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1450 IProjectDescription description = project.getDescription();
1451 String[] prevNatures = description.getNatureIds();
1452 String[] newNatures = new String[prevNatures.length + 1];
1453 System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
1454 newNatures[prevNatures.length] = PHPeclipsePlugin.PHP_NATURE_ID;
1455 description.setNatureIds(newNatures);
1456 project.setDescription(description, monitor);
1461 * Returns the single instance of the PHP core plug-in runtime class.
1463 * @return the single instance of the PHP core plug-in runtime class
1465 public static Plugin getPlugin() {
1466 return PHPeclipsePlugin.getDefault();
1470 * Runs the given action as an atomic Java model operation.
1472 * After running a method that modifies java elements, registered listeners
1473 * receive after-the-fact notification of what just transpired, in the form
1474 * of a element changed event. This method allows clients to call a number
1475 * of methods that modify java elements and only have element changed event
1476 * notifications reported at the end of the entire batch.
1479 * If this method is called outside the dynamic scope of another such call,
1480 * this method runs the action and then reports a single element changed
1481 * event describing the net effect of all changes done to java elements by
1485 * If this method is called in the dynamic scope of another such call, this
1486 * method simply runs the action.
1490 * the action to perform
1492 * a progress monitor, or <code>null</code> if progress
1493 * reporting and cancellation are not desired
1494 * @exception CoreException
1495 * if the operation failed.
1498 // public static void run(IWorkspaceRunnable action, IProgressMonitor
1499 // monitor) throws CoreException {
1500 // run(action, ResourcesPlugin.getWorkspace().getRoot(), monitor);
1503 * Runs the given action as an atomic Java model operation.
1505 * After running a method that modifies java elements, registered listeners
1506 * receive after-the-fact notification of what just transpired, in the form
1507 * of a element changed event. This method allows clients to call a number
1508 * of methods that modify java elements and only have element changed event
1509 * notifications reported at the end of the entire batch.
1512 * If this method is called outside the dynamic scope of another such call,
1513 * this method runs the action and then reports a single element changed
1514 * event describing the net effect of all changes done to java elements by
1518 * If this method is called in the dynamic scope of another such call, this
1519 * method simply runs the action.
1522 * The supplied scheduling rule is used to determine whether this operation
1523 * can be run simultaneously with workspace changes in other threads. See
1524 * <code>IWorkspace.run(...)</code> for more details.
1528 * the action to perform
1530 * the scheduling rule to use when running this operation, or
1531 * <code>null</code> if there are no scheduling restrictions
1532 * for this operation.
1534 * a progress monitor, or <code>null</code> if progress
1535 * reporting and cancellation are not desired
1536 * @exception CoreException
1537 * if the operation failed.
1540 // public static void run(IWorkspaceRunnable action, ISchedulingRule rule,
1541 // IProgressMonitor monitor) throws CoreException {
1542 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
1543 // if (workspace.isTreeLocked()) {
1544 // new BatchOperation(action).run(monitor);
1546 // // use IWorkspace.run(...) to ensure that a build will be done in
1548 // workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE,
1553 * Adds the given listener for changes to Java elements. Has no effect if an
1554 * identical listener is already registered.
1556 * This listener will only be notified during the POST_CHANGE resource
1557 * change notification and any reconcile operation (POST_RECONCILE). For
1558 * finer control of the notification, use
1559 * <code>addElementChangedListener(IElementChangedListener,int)</code>,
1560 * which allows to specify a different eventMask.
1562 * @see ElementChangedEvent
1566 public static void addElementChangedListener(
1567 IElementChangedListener listener) {
1568 addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE
1569 | ElementChangedEvent.POST_RECONCILE);
1573 * Adds the given listener for changes to Java elements. Has no effect if an
1574 * identical listener is already registered. After completion of this
1575 * method, the given listener will be registered for exactly the specified
1576 * events. If they were previously registered for other events, they will be
1579 * Once registered, a listener starts receiving notification of changes to
1580 * java elements in the model. The listener continues to receive
1581 * notifications until it is replaced or removed.
1584 * Listeners can listen for several types of event as defined in
1585 * <code>ElementChangeEvent</code>. Clients are free to register for any
1586 * number of event types however if they register for more than one, it is
1587 * their responsibility to ensure they correctly handle the case where the
1588 * same java element change shows up in multiple notifications. Clients are
1589 * guaranteed to receive only the events for which they are registered.
1595 * the bit-wise OR of all event types of interest to the listener
1596 * @see IElementChangedListener
1597 * @see ElementChangedEvent
1598 * @see #removeElementChangedListener(IElementChangedListener)
1601 public static void addElementChangedListener(
1602 IElementChangedListener listener, int eventMask) {
1603 JavaModelManager.getJavaModelManager().addElementChangedListener(
1604 listener, eventMask);
1608 * Configures the given marker attribute map for the given Java element.
1609 * Used for markers, which denote a Java element rather than a resource.
1612 * the mutable marker attribute map (key type:
1613 * <code>String</code>, value type: <code>String</code>)
1615 * the Java element for which the marker needs to be configured
1617 public static void addJavaElementMarkerAttributes(Map attributes,
1618 IJavaElement element) {
1619 // if (element instanceof IMember)
1620 // element = ((IMember) element).getClassFile();
1621 if (attributes != null && element != null)
1622 attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier());
1626 * Adds the given listener for POST_CHANGE resource change events to the
1627 * Java core. The listener is guarantied to be notified of the POST_CHANGE
1628 * resource change event before the Java core starts processing the resource
1629 * change event itself.
1631 * Has no effect if an identical listener is already registered.
1636 * @see #removePreProcessingResourceChangedListener(IResourceChangeListener)
1639 public static void addPreProcessingResourceChangedListener(
1640 IResourceChangeListener listener) {
1641 JavaModelManager.getJavaModelManager().deltaState
1642 .addPreResourceChangedListener(listener);
1646 * Configures the given marker for the given Java element. Used for markers,
1647 * which denote a Java element rather than a resource.
1650 * the marker to be configured
1652 * the Java element for which the marker needs to be configured
1653 * @exception CoreException
1654 * if the <code>IMarker.setAttribute</code> on the marker
1657 public void configureJavaElementMarker(IMarker marker, IJavaElement element)
1658 throws CoreException {
1659 // if (element instanceof IMember)
1660 // element = ((IMember) element).getClassFile();
1661 if (marker != null && element != null)
1662 marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier());
1666 * Returns the Java model element corresponding to the given handle
1667 * identifier generated by <code>IJavaElement.getHandleIdentifier()</code>,
1668 * or <code>null</code> if unable to create the associated element.
1670 public static IJavaElement create(String handleIdentifier) {
1671 if (handleIdentifier == null) {
1675 return JavaModelManager.getJavaModelManager().getHandleFromMemento(
1677 } catch (JavaModelException e) {
1683 * Returns the Java model element corresponding to the given handle
1684 * identifier generated by <code>IJavaElement.getHandleIdentifier()</code>,
1685 * or <code>null</code> if unable to create the associated element. If the
1686 * returned Java element is an <code>ICompilationUnit</code>, its owner
1687 * is the given owner if such a working copy exists, otherwise the
1688 * compilation unit is a primary compilation unit.
1690 * @param handleIdentifier
1691 * the given handle identifier
1693 * the owner of the returned compilation unit, ignored if the
1694 * returned element is not a compilation unit
1695 * @return the Java element corresponding to the handle identifier
1698 public static IJavaElement create(String handleIdentifier,
1699 WorkingCopyOwner owner) {
1700 if (handleIdentifier == null) {
1703 MementoTokenizer memento = new MementoTokenizer(handleIdentifier);
1704 JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel();
1705 return model.getHandleFromMemento(memento, owner);
1709 * Returns the Java element corresponding to the given file, or
1710 * <code>null</code> if unable to associate the given file with a Java
1714 * The file must be one of:
1716 * <li>a <code>.java</code> file - the element returned is the
1717 * corresponding <code>ICompilationUnit</code></li>
1718 * <li>a <code>.class</code> file - the element returned is the
1719 * corresponding <code>IClassFile</code></li>
1720 * <li>a <code>.jar</code> file - the element returned is the
1721 * corresponding <code>IPackageFragmentRoot</code></li>
1724 * Creating a Java element has the side effect of creating and opening all
1725 * of the element's parents if they are not yet open.
1729 * @return the Java element corresponding to the given file, or
1730 * <code>null</code> if unable to associate the given file with a
1733 public static IJavaElement create(IFile file) {
1734 return JavaModelManager.create(file, null);
1738 * Returns the package fragment or package fragment root corresponding to
1739 * the given folder, or <code>null</code> if unable to associate the given
1740 * folder with a Java element.
1742 * Note that a package fragment root is returned rather than a default
1745 * Creating a Java element has the side effect of creating and opening all
1746 * of the element's parents if they are not yet open.
1750 * @return the package fragment or package fragment root corresponding to
1751 * the given folder, or <code>null</code> if unable to associate
1752 * the given folder with a Java element
1754 public static IJavaElement create(IFolder folder) {
1755 return JavaModelManager.create(folder, null);
1759 * Returns the Java project corresponding to the given project.
1761 * Creating a Java Project has the side effect of creating and opening all
1762 * of the project's parents if they are not yet open.
1764 * Note that no check is done at this time on the existence or the java
1765 * nature of this project.
1769 * @return the Java project corresponding to the given project, null if the
1770 * given project is null
1772 public static IJavaProject create(IProject project) {
1773 if (project == null) {
1776 JavaModel javaModel = JavaModelManager.getJavaModelManager()
1778 return javaModel.getJavaProject(project);
1782 * Returns the Java element corresponding to the given resource, or
1783 * <code>null</code> if unable to associate the given resource with a Java
1786 * The resource must be one of:
1788 * <li>a project - the element returned is the corresponding
1789 * <code>IJavaProject</code></li>
1790 * <li>a <code>.java</code> file - the element returned is the
1791 * corresponding <code>ICompilationUnit</code></li>
1792 * <li>a <code>.class</code> file - the element returned is the
1793 * corresponding <code>IClassFile</code></li>
1794 * <li>a <code>.jar</code> file - the element returned is the
1795 * corresponding <code>IPackageFragmentRoot</code></li>
1796 * <li>a folder - the element returned is the corresponding
1797 * <code>IPackageFragmentRoot</code> or <code>IPackageFragment</code>
1799 * <li>the workspace root resource - the element returned is the
1800 * <code>IJavaModel</code></li>
1803 * Creating a Java element has the side effect of creating and opening all
1804 * of the element's parents if they are not yet open.
1807 * the given resource
1808 * @return the Java element corresponding to the given resource, or
1809 * <code>null</code> if unable to associate the given resource
1810 * with a Java element
1812 public static IJavaElement create(IResource resource) {
1813 return JavaModelManager.create(resource, null);
1817 * Returns the Java model.
1821 * @return the Java model, or <code>null</code> if the root is null
1823 public static IJavaModel create(IWorkspaceRoot root) {
1827 return JavaModelManager.getJavaModelManager().getJavaModel();
1831 * Creates and returns a class file element for the given
1832 * <code>.class</code> file. Returns <code>null</code> if unable to
1833 * recognize the class file.
1836 * the given <code>.class</code> file
1837 * @return a class file element for the given <code>.class</code> file, or
1838 * <code>null</code> if unable to recognize the class file
1840 // public static IClassFile createClassFileFrom(IFile file) {
1841 // return JavaModelManager.createClassFileFrom(file, null);
1844 * Creates and returns a compilation unit element for the given
1845 * <code>.java</code> file. Returns <code>null</code> if unable to
1846 * recognize the compilation unit.
1849 * the given <code>.java</code> file
1850 * @return a compilation unit element for the given <code>.java</code>
1851 * file, or <code>null</code> if unable to recognize the
1854 public static ICompilationUnit createCompilationUnitFrom(IFile file) {
1855 return JavaModelManager.createCompilationUnitFrom(file, null);
1859 * Creates and returns a handle for the given JAR file. The Java model
1860 * associated with the JAR's project may be created as a side effect.
1863 * the given JAR file
1864 * @return a handle for the given JAR file, or <code>null</code> if unable
1865 * to create a JAR package fragment root. (for example, if the JAR
1866 * file represents a non-Java resource)
1868 // public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile
1870 // return JavaModelManager.createJarPackageFragmentRootFrom(file, null);
1873 * Answers the project specific value for a given classpath container. In
1874 * case this container path could not be resolved, then will answer
1875 * <code>null</code>. Both the container path and the project context are
1876 * supposed to be non-null.
1878 * The containerPath is a formed by a first ID segment followed with extra
1879 * segments, which can be used as additional hints for resolution. If no
1880 * container was ever recorded for this container path onto this project
1881 * (using <code>setClasspathContainer</code>, then a
1882 * <code>ClasspathContainerInitializer</code> will be activated if any was
1883 * registered for this container ID onto the extension point
1884 * "net.sourceforge.phpdt.core.classpathContainerInitializer".
1886 * There is no assumption that the returned container must answer the exact
1887 * same containerPath when requested
1888 * <code>IClasspathContainer#getPath</code>. Indeed, the containerPath is
1889 * just an indication for resolving it to an actual container object.
1891 * Classpath container values are persisted locally to the workspace, but
1892 * are not preserved from a session to another. It is thus highly
1893 * recommended to register a <code>ClasspathContainerInitializer</code>
1894 * for each referenced container (through the extension point
1895 * "net.sourceforge.phpdt.core.ClasspathContainerInitializer").
1898 * @param containerPath
1899 * the name of the container, which needs to be resolved
1901 * a specific project in which the container is being resolved
1902 * @return the corresponding classpath container or <code>null</code> if
1903 * unable to find one.
1905 * @exception JavaModelException
1906 * if an exception occurred while resolving the container, or
1907 * if the resolved container contains illegal entries
1908 * (contains CPE_CONTAINER entries or null entries).
1910 * @see ClasspathContainerInitializer
1911 * @see IClasspathContainer
1912 * @see #setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[],
1916 // public static IClasspathContainer getClasspathContainer(final IPath
1917 // containerPath, final IJavaProject project) throws JavaModelException {
1919 // IClasspathContainer container = JavaModelManager.containerGet(project,
1921 // if (container == JavaModelManager.ContainerInitializationInProgress)
1922 // return null; // break cycle
1924 // if (container == null){
1925 // final ClasspathContainerInitializer initializer =
1926 // JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
1927 // if (initializer != null){
1928 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1929 // System.out.println("CPContainer INIT - triggering initialization of:
1930 // ["+project.getElementName()+"] " + containerPath + " using initializer:
1931 // "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
1932 // new Exception("FAKE exception for dumping current CPContainer
1933 // (["+project.getElementName()+"] "+ containerPath+ ")INIT invocation stack
1934 // trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
1936 // JavaModelManager.containerPut(project, containerPath,
1937 // JavaModelManager.ContainerInitializationInProgress); // avoid
1938 // initialization cycles
1939 // boolean ok = false;
1941 // // wrap initializer call with Safe runnable in case initializer would be
1942 // causing some grief
1943 // Platform.run(new ISafeRunnable() {
1944 // public void handleException(Throwable exception) {
1945 // ProjectPrefUtil.log(exception, "Exception occurred in classpath container
1946 // initializer: "+initializer); //$NON-NLS-1$
1948 // public void run() throws Exception {
1949 // initializer.initialize(containerPath, project);
1953 // // retrieve value (if initialization was successful)
1954 // container = JavaModelManager.containerGet(project, containerPath);
1955 // if (container == JavaModelManager.ContainerInitializationInProgress)
1956 // return null; // break cycle
1959 // if (!ok) JavaModelManager.containerPut(project, containerPath, null); //
1962 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1963 // System.out.print("CPContainer INIT - after resolution:
1964 // ["+project.getElementName()+"] " + containerPath + " --> ");
1965 // //$NON-NLS-2$//$NON-NLS-1$//$NON-NLS-3$
1966 // if (container != null){
1967 // System.out.print("container: "+container.getDescription()+" {");
1968 // //$NON-NLS-2$//$NON-NLS-1$
1969 // IClasspathEntry[] entries = container.getClasspathEntries();
1970 // if (entries != null){
1971 // for (int i = 0; i < entries.length; i++){
1972 // if (i > 0) System.out.println(", ");//$NON-NLS-1$
1973 // System.out.println(entries[i]);
1976 // System.out.println("}");//$NON-NLS-1$
1978 // System.out.println("{unbound}");//$NON-NLS-1$
1982 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1983 // System.out.println("CPContainer INIT - no initializer found for:
1984 // "+project.getElementName()+"] " + containerPath); //$NON-NLS-1$
1989 // return container;
1992 * Helper method finding the classpath container initializer registered for
1993 * a given classpath container ID or <code>null</code> if none was found
1994 * while iterating over the contributions to extension point to the
1996 * "net.sourceforge.phpdt.core.classpathContainerInitializer".
1998 * A containerID is the first segment of any container path, used to
1999 * identify the registered container initializer.
2003 * a containerID identifying a registered initializer
2004 * @return ClasspathContainerInitializer - the registered classpath
2005 * container initializer or <code>null</code> if none was found.
2008 // public static ClasspathContainerInitializer
2009 // getClasspathContainerInitializer(String containerID){
2011 // Plugin jdtCorePlugin = JavaCore.getPlugin();
2012 // if (jdtCorePlugin == null) return null;
2014 // IExtensionPoint extension =
2015 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID);
2016 // if (extension != null) {
2017 // IExtension[] extensions = extension.getExtensions();
2018 // for(int i = 0; i < extensions.length; i++){
2019 // IConfigurationElement [] configElements =
2020 // extensions[i].getConfigurationElements();
2021 // for(int j = 0; j < configElements.length; j++){
2022 // String initializerID = configElements[j].getAttribute("id");
2024 // if (initializerID != null && initializerID.equals(containerID)){
2025 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
2026 // System.out.println("CPContainer INIT - found initializer: "+containerID
2028 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
2031 // Object execExt = configElements[j].createExecutableExtension("class");
2033 // if (execExt instanceof ClasspathContainerInitializer){
2034 // return (ClasspathContainerInitializer)execExt;
2036 // } catch(CoreException e) {
2045 * Returns the path held in the given classpath variable. Returns <node>null
2046 * </code> if unable to bind.
2048 * Classpath variable values are persisted locally to the workspace, and are
2049 * preserved from session to session.
2051 * Note that classpath variables can be contributed registered initializers
2052 * for, using the extension point
2053 * "net.sourceforge.phpdt.core.classpathVariableInitializer". If an
2054 * initializer is registered for a variable, its persisted value will be
2055 * ignored: its initializer will thus get the opportunity to rebind the
2056 * variable differently on each session.
2058 * @param variableName
2059 * the name of the classpath variable
2060 * @return the path, or <code>null</code> if none
2061 * @see #setClasspathVariable
2063 public static IPath getClasspathVariable(final String variableName) {
2065 IPath variablePath = JavaModelManager.variableGet(variableName);
2066 if (variablePath == JavaModelManager.VariableInitializationInProgress)
2067 return null; // break cycle
2069 if (variablePath != null) {
2070 return variablePath;
2073 // even if persisted value exists, initializer is given priority, only
2074 // if no initializer is found the persisted value is reused
2075 // final ClasspathVariableInitializer initializer =
2076 // PHPCore.getClasspathVariableInitializer(variableName);
2077 // if (initializer != null){
2078 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2079 // System.out.println("CPVariable INIT - triggering initialization of: "
2080 // + variableName+ " using initializer: "+ initializer); //$NON-NLS-1$
2082 // new Exception("FAKE exception for dumping current CPVariable
2083 // ("+variableName+ ")INIT invocation stack trace").printStackTrace();
2084 // //$NON-NLS-1$//$NON-NLS-2$
2086 // JavaModelManager.variablePut(variableName,
2087 // JavaModelManager.VariableInitializationInProgress); // avoid
2088 // initialization cycles
2089 // boolean ok = false;
2091 // // wrap initializer call with Safe runnable in case initializer would
2092 // be causing some grief
2093 // Platform.run(new ISafeRunnable() {
2094 // public void handleException(Throwable exception) {
2095 // ProjectPrefUtil.log(exception, "Exception occurred in classpath
2097 // initializer: "+initializer+" while initializing variable:
2098 // "+variableName); //$NON-NLS-1$ //$NON-NLS-2$
2100 // public void run() throws Exception {
2101 // initializer.initialize(variableName);
2104 // variablePath = (IPath) JavaModelManager.variableGet(variableName); //
2105 // initializer should have performed side-effect
2106 // if (variablePath ==
2107 // JavaModelManager.VariableInitializationInProgress) return null; //
2108 // break cycle (initializer did not init or reentering call)
2109 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2110 // System.out.println("CPVariable INIT - after initialization: " +
2111 // variableName + " --> " + variablePath); //$NON-NLS-2$//$NON-NLS-1$
2115 // if (!ok) JavaModelManager.variablePut(variableName, null); // flush
2119 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2120 // System.out.println("CPVariable INIT - no initializer found for: " +
2121 // variableName); //$NON-NLS-1$
2124 return variablePath;
2128 * Helper method finding the classpath variable initializer registered for a
2129 * given classpath variable name or <code>null</code> if none was found
2130 * while iterating over the contributions to extension point to the
2132 * "net.sourceforge.phpdt.core.classpathVariableInitializer".
2137 * @return ClasspathVariableInitializer - the registered classpath variable
2138 * initializer or <code>null</code> if none was found.
2141 public static ClasspathVariableInitializer getClasspathVariableInitializer(
2144 Plugin jdtCorePlugin = JavaCore.getPlugin();
2145 if (jdtCorePlugin == null)
2148 // IExtensionPoint extension =
2149 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID);
2150 // if (extension != null) {
2151 // IExtension[] extensions = extension.getExtensions();
2152 // for(int i = 0; i < extensions.length; i++){
2153 // IConfigurationElement [] configElements =
2154 // extensions[i].getConfigurationElements();
2155 // for(int j = 0; j < configElements.length; j++){
2157 // String varAttribute = configElements[j].getAttribute("variable");
2159 // if (variable.equals(varAttribute)) {
2160 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
2161 // System.out.println("CPVariable INIT - found initializer: "+variable+"
2163 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
2166 // configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
2167 // if (execExt instanceof ClasspathVariableInitializer){
2168 // return (ClasspathVariableInitializer)execExt;
2171 // } catch(CoreException e){
2180 * Returns the names of all known classpath variables.
2182 * Classpath variable values are persisted locally to the workspace, and are
2183 * preserved from session to session.
2186 * @return the list of classpath variable names
2187 * @see #setClasspathVariable
2189 // public static String[] getClasspathVariableNames() {
2190 // return JavaModelManager.variableNames();
2193 * Returns a table of all known configurable options with their default
2194 * values. These options allow to configure the behaviour of the underlying
2195 * components. The client may safely use the result as a template that they
2196 * can modify and then pass to <code>setOptions</code>.
2198 * Helper constants have been defined on JavaCore for each of the option ID
2199 * and their possible constant values.
2201 * Note: more options might be added in further releases.
2205 * RECOGNIZED OPTIONS:
2206 * COMPILER / Generating Local Variable Debug Attribute
2207 * When generated, this attribute will enable local variable names
2208 * to be displayed in debugger, only in place where variables are
2209 * definitely assigned (.class file is then bigger)
2210 * - option id: "net.sourceforge.phpdt.core.compiler.debug.localVariable"
2211 * - possible values: { "generate", "do not generate" }
2212 * - default: "generate"
2214 * COMPILER / Generating Line Number Debug Attribute
2215 * When generated, this attribute will enable source code highlighting in debugger
2216 * (.class file is then bigger).
2217 * - option id: "net.sourceforge.phpdt.core.compiler.debug.lineNumber"
2218 * - possible values: { "generate", "do not generate" }
2219 * - default: "generate"
2221 * COMPILER / Generating Source Debug Attribute
2222 * When generated, this attribute will enable the debugger to present the
2223 * corresponding source code.
2224 * - option id: "net.sourceforge.phpdt.core.compiler.debug.sourceFile"
2225 * - possible values: { "generate", "do not generate" }
2226 * - default: "generate"
2228 * COMPILER / Preserving Unused Local Variables
2229 * Unless requested to preserve unused local variables (that is, never read), the
2230 * compiler will optimize them out, potentially altering debugging
2231 * - option id: "net.sourceforge.phpdt.core.compiler.codegen.unusedLocal"
2232 * - possible values: { "preserve", "optimize out" }
2233 * - default: "preserve"
2235 * COMPILER / Defining Target Java Platform
2236 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
2237 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
2238 * - option id: "net.sourceforge.phpdt.core.compiler.codegen.targetPlatform"
2239 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
2240 * - default: "1.1"
2242 * COMPILER / Reporting Unreachable Code
2243 * Unreachable code can optionally be reported as an error, warning or simply
2244 * ignored. The bytecode generation will always optimized it out.
2245 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unreachableCode"
2246 * - possible values: { "error", "warning", "ignore" }
2247 * - default: "error"
2249 * COMPILER / Reporting Invalid Import
2250 * An import statement that cannot be resolved might optionally be reported
2251 * as an error, as a warning or ignored.
2252 * - option id: "net.sourceforge.phpdt.core.compiler.problem.invalidImport"
2253 * - possible values: { "error", "warning", "ignore" }
2254 * - default: "error"
2256 * COMPILER / Reporting Attempt to Override Package-Default Method
2257 * A package default method is not visible in a different package, and thus
2258 * cannot be overridden. When enabling this option, the compiler will signal
2259 * such scenarii either as an error or a warning.
2260 * - option id: "net.sourceforge.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
2261 * - possible values: { "error", "warning", "ignore" }
2262 * - default: "warning"
2264 * COMPILER / Reporting Method With Constructor Name
2265 * Naming a method with a constructor name is generally considered poor
2266 * style programming. When enabling this option, the compiler will signal such
2267 * scenarii either as an error or a warning.
2268 * - option id: "net.sourceforge.phpdt.core.compiler.problem.methodWithConstructorName"
2269 * - possible values: { "error", "warning", "ignore" }
2270 * - default: "warning"
2272 * COMPILER / Reporting Deprecation
2273 * When enabled, the compiler will signal use of deprecated API either as an
2274 * error or a warning.
2275 * - option id: "net.sourceforge.phpdt.core.compiler.problem.deprecation"
2276 * - possible values: { "error", "warning", "ignore" }
2277 * - default: "warning"
2279 * COMPILER / Reporting Deprecation Inside Deprecated Code
2280 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
2281 * The severity of the problem is controlled with option "net.sourceforge.phpdt.core.compiler.problem.deprecation".
2282 * - option id: "net.sourceforge.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
2283 * - possible values: { "enabled", "disabled" }
2284 * - default: "disabled"
2286 * COMPILER / Reporting Hidden Catch Block
2287 * Locally to a try statement, some catch blocks may hide others . For example,
2288 * try { throw new java.io.CharConversionException();
2289 * } catch (java.io.CharConversionException e) {
2290 * } catch (java.io.IOException e) {}.
2291 * When enabling this option, the compiler will issue an error or a warning for hidden
2292 * catch blocks corresponding to checked exceptions
2293 * - option id: "net.sourceforge.phpdt.core.compiler.problem.hiddenCatchBlock"
2294 * - possible values: { "error", "warning", "ignore" }
2295 * - default: "warning"
2297 * COMPILER / Reporting Unused Local
2298 * When enabled, the compiler will issue an error or a warning for unused local
2299 * variables (that is, variables never read from)
2300 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedLocal"
2301 * - possible values: { "error", "warning", "ignore" }
2302 * - default: "ignore"
2304 * COMPILER / Reporting Unused Parameter
2305 * When enabled, the compiler will issue an error or a warning for unused method
2306 * parameters (that is, parameters never read from)
2307 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedParameter"
2308 * - possible values: { "error", "warning", "ignore" }
2309 * - default: "ignore"
2311 * COMPILER / Reporting Unused Parameter if Implementing Abstract Method
2312 * When enabled, the compiler will signal unused parameters in abstract method implementations.
2313 * The severity of the problem is controlled with option "net.sourceforge.phpdt.core.compiler.problem.unusedParameter".
2314 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"
2315 * - possible values: { "enabled", "disabled" }
2316 * - default: "disabled"
2318 * COMPILER / Reporting Unused Parameter if Overriding Concrete Method
2319 * When enabled, the compiler will signal unused parameters in methods overriding concrete ones.
2320 * The severity of the problem is controlled with option "net.sourceforge.phpdt.core.compiler.problem.unusedParameter".
2321 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"
2322 * - possible values: { "enabled", "disabled" }
2323 * - default: "disabled"
2325 * COMPILER / Reporting Unused Import
2326 * When enabled, the compiler will issue an error or a warning for unused import
2328 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedImport"
2329 * - possible values: { "error", "warning", "ignore" }
2330 * - default: "warning"
2332 * COMPILER / Reporting Unused Private Members
2333 * When enabled, the compiler will issue an error or a warning whenever a private
2334 * method or field is declared but never used within the same unit.
2335 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedPrivateMember"
2336 * - possible values: { "error", "warning", "ignore" }
2337 * - default: "ignore"
2339 * COMPILER / Reporting Synthetic Access Emulation
2340 * When enabled, the compiler will issue an error or a warning whenever it emulates
2341 * access to a non-accessible member of an enclosing type. Such access can have
2342 * performance implications.
2343 * - option id: "net.sourceforge.phpdt.core.compiler.problem.syntheticAccessEmulation"
2344 * - possible values: { "error", "warning", "ignore" }
2345 * - default: "ignore"
2347 * COMPILER / Reporting Non-Externalized String Literal
2348 * When enabled, the compiler will issue an error or a warning for non externalized
2349 * String literal (that is, not tagged with //$NON-NLS-<n>$).
2350 * - option id: "net.sourceforge.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
2351 * - possible values: { "error", "warning", "ignore" }
2352 * - default: "ignore"
2354 * COMPILER / Reporting Usage of 'assert' Identifier
2355 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
2356 * used as an identifier (reserved keyword in 1.4)
2357 * - option id: "net.sourceforge.phpdt.core.compiler.problem.assertIdentifier"
2358 * - possible values: { "error", "warning", "ignore" }
2359 * - default: "ignore"
2361 * COMPILER / Reporting Non-Static Reference to a Static Member
2362 * When enabled, the compiler will issue an error or a warning whenever a static field
2363 * or method is accessed with an expression receiver. A reference to a static member should
2364 * be qualified with a type name.
2365 * - option id: "net.sourceforge.phpdt.core.compiler.problem.staticAccessReceiver"
2366 * - possible values: { "error", "warning", "ignore" }
2367 * - default: "warning"
2369 * COMPILER / Reporting Assignment with no Effect
2370 * When enabled, the compiler will issue an error or a warning whenever an assignment
2371 * has no effect (e.g 'x = x').
2372 * - option id: "net.sourceforge.phpdt.core.compiler.problem.noEffectAssignment"
2373 * - possible values: { "error", "warning", "ignore" }
2374 * - default: "warning"
2376 * COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods
2377 * When enabled, the compiler will issue an error or a warning whenever an interface
2378 * defines a method incompatible with a non-inherited Object method. Until this conflict
2379 * is resolved, such an interface cannot be implemented, For example,
2383 * - option id: "net.sourceforge.phpdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"
2384 * - possible values: { "error", "warning", "ignore" }
2385 * - default: "warning"
2387 * COMPILER / Reporting Usage of char[] Expressions in String Concatenations
2388 * When enabled, the compiler will issue an error or a warning whenever a char[] expression
2389 * is used in String concatenations (for example, "hello" + new char[]{'w','o','r','l','d'}).
2390 * - option id: "net.sourceforge.phpdt.core.compiler.problem.noImplicitStringConversion"
2391 * - possible values: { "error", "warning", "ignore" }
2392 * - default: "warning"
2394 * COMPILER / Setting Source Compatibility Mode
2395 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
2396 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
2397 * level should be set to "1.4" and the compliance mode should be "1.4".
2398 * - option id: "net.sourceforge.phpdt.core.compiler.source"
2399 * - possible values: { "1.3", "1.4" }
2400 * - default: "1.3"
2402 * COMPILER / Setting Compliance Level
2403 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
2404 * should not go beyond "1.3" level.
2405 * - option id: "net.sourceforge.phpdt.core.compiler.compliance"
2406 * - possible values: { "1.3", "1.4" }
2407 * - default: "1.3"
2409 * COMPILER / Maximum number of problems reported per compilation unit
2410 * Specify the maximum number of problems reported on each compilation unit.
2411 * - option id: "net.sourceforge.phpdt.core.compiler.maxProblemPerUnit"
2412 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
2413 * - default: "100"
2415 * COMPILER / Define the Automatic Task Tags
2416 * When the tag list is not empty, the compiler will issue a task marker whenever it encounters
2417 * one of the corresponding tag inside any comment in Java source code.
2418 * Generated task messages will include the tag, and range until the next line separator or comment ending.
2419 * Note that tasks messages are trimmed.
2420 * - option id: "net.sourceforge.phpdt.core.compiler.taskTags"
2421 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card or leading/trailing spaces
2422 * - default: ""
2424 * COMPILER / Define the Automatic Task Priorities
2425 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
2426 * of the task markers issued by the compiler.
2427 * If the default is specified, the priority of each task marker is "NORMAL".
2428 * - option id: "net.sourceforge.phpdt.core.compiler.taskPriorities"
2429 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
2430 * - default: ""
2432 * BUILDER / Specifying Filters for Resource Copying Control
2433 * Allow to specify some filters to control the resource copy process.
2434 * - option id: "net.sourceforge.phpdt.core.builder.resourceCopyExclusionFilter"
2435 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
2436 * or the name of a folder which ends with '/'
2437 * - default: ""
2439 * BUILDER / Abort if Invalid Classpath
2440 * Allow to toggle the builder to abort if the classpath is invalid
2441 * - option id: "net.sourceforge.phpdt.core.builder.invalidClasspath"
2442 * - possible values: { "abort", "ignore" }
2443 * - default: "abort"
2445 * BUILDER / Cleaning Output Folder(s)
2446 * Indicate whether the JavaBuilder is allowed to clean the output folders
2447 * when performing full build operations.
2448 * - option id: "net.sourceforge.phpdt.core.builder.cleanOutputFolder"
2449 * - possible values: { "clean", "ignore" }
2450 * - default: "clean"
2452 * BUILDER / Reporting Duplicate Resources
2453 * Indicate the severity of the problem reported when more than one occurrence
2454 * of a resource is to be copied into the output location.
2455 * - option id: "net.sourceforge.phpdt.core.builder.duplicateResourceTask"
2456 * - possible values: { "error", "warning" }
2457 * - default: "warning"
2459 * JAVACORE / Computing Project Build Order
2460 * Indicate whether JavaCore should enforce the project build order to be based on
2461 * the classpath prerequisite chain. When requesting to compute, this takes over
2462 * the platform default order (based on project references).
2463 * - option id: "net.sourceforge.phpdt.core.computeJavaBuildOrder"
2464 * - possible values: { "compute", "ignore" }
2465 * - default: "ignore"
2467 * JAVACORE / Specify Default Source Encoding Format
2468 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
2469 * to 'ResourcesPlugin.getEncoding()'.
2470 * - option id: "net.sourceforge.phpdt.core.encoding"
2471 * - possible values: { any of the supported encoding name}.
2472 * - default: <platform default>
2474 * JAVACORE / Reporting Incomplete Classpath
2475 * Indicate the severity of the problem reported when an entry on the classpath does not exist,
2476 * is not legite or is not visible (for example, a referenced project is closed).
2477 * - option id: "net.sourceforge.phpdt.core.incompleteClasspath"
2478 * - possible values: { "error", "warning"}
2479 * - default: "error"
2481 * JAVACORE / Reporting Classpath Cycle
2482 * Indicate the severity of the problem reported when a project is involved in a cycle.
2483 * - option id: "net.sourceforge.phpdt.core.circularClasspath"
2484 * - possible values: { "error", "warning" }
2485 * - default: "error"
2487 * JAVACORE / Enabling Usage of Classpath Exclusion Patterns
2488 * When disabled, no entry on a project classpath can be associated with
2489 * an exclusion pattern.
2490 * - option id: "net.sourceforge.phpdt.core.classpath.exclusionPatterns"
2491 * - possible values: { "enabled", "disabled" }
2492 * - default: "enabled"
2494 * JAVACORE / Enabling Usage of Classpath Multiple Output Locations
2495 * When disabled, no entry on a project classpath can be associated with
2496 * a specific output location, preventing thus usage of multiple output locations.
2497 * - option id: "net.sourceforge.phpdt.core.classpath.multipleOutputLocations"
2498 * - possible values: { "enabled", "disabled" }
2499 * - default: "enabled"
2501 * FORMATTER / Inserting New Line Before Opening Brace
2502 * When Insert, a new line is inserted before an opening brace, otherwise nothing
2504 * - option id: "net.sourceforge.phpdt.core.formatter.newline.openingBrace"
2505 * - possible values: { "insert", "do not insert" }
2506 * - default: "do not insert"
2508 * FORMATTER / Inserting New Line Inside Control Statement
2509 * When Insert, a new line is inserted between } and following else, catch, finally
2510 * - option id: "net.sourceforge.phpdt.core.formatter.newline.controlStatement"
2511 * - possible values: { "insert", "do not insert" }
2512 * - default: "do not insert"
2514 * FORMATTER / Clearing Blank Lines
2515 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
2516 * and all others removed.
2517 * - option id: "net.sourceforge.phpdt.core.formatter.newline.clearAll"
2518 * - possible values: { "clear all", "preserve one" }
2519 * - default: "preserve one"
2521 * FORMATTER / Inserting New Line Between Else/If
2522 * When Insert, a blank line is inserted between an else and an if when they are
2523 * contiguous. When choosing to not insert, else-if will be kept on the same
2524 * line when possible.
2525 * - option id: "net.sourceforge.phpdt.core.formatter.newline.elseIf"
2526 * - possible values: { "insert", "do not insert" }
2527 * - default: "do not insert"
2529 * FORMATTER / Inserting New Line In Empty Block
2530 * When insert, a line break is inserted between contiguous { and }, if } is not followed
2532 * - option id: "net.sourceforge.phpdt.core.formatter.newline.emptyBlock"
2533 * - possible values: { "insert", "do not insert" }
2534 * - default: "insert"
2536 * FORMATTER / Splitting Lines Exceeding Length
2537 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
2538 * disable line splitting
2539 * - option id: "net.sourceforge.phpdt.core.formatter.lineSplit"
2540 * - possible values: "<n>", where n is zero or a positive integer
2541 * - default: "80"
2543 * FORMATTER / Compacting Assignment
2544 * Assignments can be formatted asymmetrically, for example 'int x= 2;', when Normal, a space
2545 * is inserted before the assignment operator
2546 * - option id: "net.sourceforge.phpdt.core.formatter.style.assignment"
2547 * - possible values: { "compact", "normal" }
2548 * - default: "normal"
2550 * FORMATTER / Defining Indentation Character
2551 * Either choose to indent with tab characters or spaces
2552 * - option id: "net.sourceforge.phpdt.core.formatter.tabulation.char"
2553 * - possible values: { "tab", "space" }
2554 * - default: "tab"
2556 * FORMATTER / Defining Space Indentation Length
2557 * When using spaces, set the amount of space characters to use for each
2559 * - option id: "net.sourceforge.phpdt.core.formatter.tabulation.size"
2560 * - possible values: "<n>", where n is a positive integer
2561 * - default: "4"
2563 * FORMATTER / Inserting space in cast expression
2564 * When Insert, a space is added between the type and the expression in a cast expression.
2565 * - option id: "net.sourceforge.phpdt.core.formatter.space.castexpression"
2566 * - possible values: { "insert", "do not insert" }
2567 * - default: "insert"
2569 * CODEASSIST / Activate Visibility Sensitive Completion
2570 * When active, completion doesn't show that you can not see
2571 * (for example, you can not see private methods of a super class).
2572 * - option id: "net.sourceforge.phpdt.core.codeComplete.visibilityCheck"
2573 * - possible values: { "enabled", "disabled" }
2574 * - default: "disabled"
2576 * CODEASSIST / Automatic Qualification of Implicit Members
2577 * When active, completion automatically qualifies completion on implicit
2578 * field references and message expressions.
2579 * - option id: "net.sourceforge.phpdt.core.codeComplete.forceImplicitQualification"
2580 * - possible values: { "enabled", "disabled" }
2581 * - default: "disabled"
2583 * CODEASSIST / Define the Prefixes for Field Name
2584 * When the prefixes is non empty, completion for field name will begin with
2585 * one of the proposed prefixes.
2586 * - option id: "net.sourceforge.phpdt.core.codeComplete.fieldPrefixes"
2587 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2588 * - default: ""
2590 * CODEASSIST / Define the Prefixes for Static Field Name
2591 * When the prefixes is non empty, completion for static field name will begin with
2592 * one of the proposed prefixes.
2593 * - option id: "net.sourceforge.phpdt.core.codeComplete.staticFieldPrefixes"
2594 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2595 * - default: ""
2597 * CODEASSIST / Define the Prefixes for Local Variable Name
2598 * When the prefixes is non empty, completion for local variable name will begin with
2599 * one of the proposed prefixes.
2600 * - option id: "net.sourceforge.phpdt.core.codeComplete.localPrefixes"
2601 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2602 * - default: ""
2604 * CODEASSIST / Define the Prefixes for Argument Name
2605 * When the prefixes is non empty, completion for argument name will begin with
2606 * one of the proposed prefixes.
2607 * - option id: "net.sourceforge.phpdt.core.codeComplete.argumentPrefixes"
2608 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2609 * - default: ""
2611 * CODEASSIST / Define the Suffixes for Field Name
2612 * When the suffixes is non empty, completion for field name will end with
2613 * one of the proposed suffixes.
2614 * - option id: "net.sourceforge.phpdt.core.codeComplete.fieldSuffixes"
2615 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2616 * - default: ""
2618 * CODEASSIST / Define the Suffixes for Static Field Name
2619 * When the suffixes is non empty, completion for static field name will end with
2620 * one of the proposed suffixes.
2621 * - option id: "net.sourceforge.phpdt.core.codeComplete.staticFieldSuffixes"
2622 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2623 * - default: ""
2625 * CODEASSIST / Define the Suffixes for Local Variable Name
2626 * When the suffixes is non empty, completion for local variable name will end with
2627 * one of the proposed suffixes.
2628 * - option id: "net.sourceforge.phpdt.core.codeComplete.localSuffixes"
2629 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2630 * - default: ""
2632 * CODEASSIST / Define the Suffixes for Argument Name
2633 * When the suffixes is non empty, completion for argument name will end with
2634 * one of the proposed suffixes.
2635 * - option id: "net.sourceforge.phpdt.core.codeComplete.argumentSuffixes"
2636 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
2637 * - default: ""
2640 * @return a mutable table containing the default settings of all known options
2653 public static Hashtable getDefaultOptions() {
2655 Hashtable defaultOptions = new Hashtable(10);
2657 // see #initializeDefaultPluginPreferences() for changing default
2659 Preferences preferences = getPlugin().getPluginPreferences();
2660 HashSet optionNames = JavaModelManager.OptionNames;
2662 // get preferences set to their default
2663 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2664 for (int i = 0; i < defaultPropertyNames.length; i++) {
2665 String propertyName = defaultPropertyNames[i];
2666 if (optionNames.contains(propertyName)) {
2667 defaultOptions.put(propertyName, preferences
2668 .getDefaultString(propertyName));
2671 // get preferences not set to their default
2672 String[] propertyNames = preferences.propertyNames();
2673 for (int i = 0; i < propertyNames.length; i++) {
2674 String propertyName = propertyNames[i];
2675 if (optionNames.contains(propertyName)) {
2676 defaultOptions.put(propertyName, preferences
2677 .getDefaultString(propertyName));
2680 // get encoding through resource plugin
2681 defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2683 return defaultOptions;
2687 * Returns the single instance of the Java core plug-in runtime class.
2688 * Equivalent to <code>(JavaCore) getPlugin()</code>.
2690 * @return the single instance of the Java core plug-in runtime class
2692 public static PHPeclipsePlugin getJavaCore() {
2693 return (PHPeclipsePlugin) getPlugin();
2697 * Helper method for returning one option value only. Equivalent to
2698 * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
2699 * may answer <code>null</code> if this option does not exist.
2701 * For a complete description of the configurable options, see
2702 * <code>getDefaultOptions</code>.
2706 * the name of an option
2707 * @return the String value of a given option
2708 * @see JavaCore#getDefaultOptions
2711 public static String getOption(String optionName) {
2713 if (CORE_ENCODING.equals(optionName)) {
2714 return ResourcesPlugin.getEncoding();
2716 if (JavaModelManager.OptionNames.contains(optionName)) {
2717 Preferences preferences = getPlugin().getPluginPreferences();
2718 return preferences.getString(optionName).trim();
2724 * Returns the table of the current options. Initially, all options have
2725 * their default values, and this method returns a table that includes all
2728 * For a complete description of the configurable options, see
2729 * <code>getDefaultOptions</code>.
2732 * @return table of current settings of all options (key type:
2733 * <code>String</code>; value type: <code>String</code>)
2734 * @see JavaCore#getDefaultOptions
2736 public static Hashtable getOptions() {
2738 Hashtable options = new Hashtable(10);
2740 // see #initializeDefaultPluginPreferences() for changing default
2742 Plugin plugin = getPlugin();
2743 if (plugin != null) {
2744 Preferences preferences = getPlugin().getPluginPreferences();
2745 HashSet optionNames = JavaModelManager.OptionNames;
2747 // get preferences set to their default
2748 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2749 for (int i = 0; i < defaultPropertyNames.length; i++) {
2750 String propertyName = defaultPropertyNames[i];
2751 if (optionNames.contains(propertyName)) {
2752 options.put(propertyName, preferences
2753 .getDefaultString(propertyName));
2756 // get preferences not set to their default
2757 String[] propertyNames = preferences.propertyNames();
2758 for (int i = 0; i < propertyNames.length; i++) {
2759 String propertyName = propertyNames[i];
2760 if (optionNames.contains(propertyName)) {
2761 options.put(propertyName, preferences.getString(
2762 propertyName).trim());
2765 // get encoding through resource plugin
2766 options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2772 * This is a helper method, which returns the resolved classpath entry
2773 * denoted by a given entry (if it is a variable entry). It is obtained by
2774 * resolving the variable reference in the first segment. Returns <node>null
2775 * </code> if unable to resolve using the following algorithm:
2777 * <li>if variable segment cannot be resolved, returns <code>null</code>
2779 * <li>finds a project, JAR or binary folder in the workspace at the
2780 * resolved path location</li>
2781 * <li>if none finds an external JAR file or folder outside the workspace
2782 * at the resolved path location</li>
2783 * <li>if none returns <code>null</code></li>
2786 * Variable source attachment path and root path are also resolved and
2787 * recorded in the resulting classpath entry.
2789 * NOTE: This helper method does not handle classpath containers, for which
2790 * should rather be used <code>JavaCore#getClasspathContainer(IPath,
2791 * IJavaProject)</code>.
2795 * the given variable entry
2796 * @return the resolved library or project classpath entry, or <code>null
2797 * </code> if the given variable entry could not be resolved to a
2798 * valid classpath entry
2800 public static IClasspathEntry getResolvedClasspathEntry(
2801 IClasspathEntry entry) {
2803 if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
2806 IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
2807 IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath());
2808 if (resolvedPath == null)
2811 Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false);
2815 // inside the workspace
2816 if (target instanceof IResource) {
2817 IResource resolvedResource = (IResource) target;
2818 if (resolvedResource != null) {
2819 switch (resolvedResource.getType()) {
2821 case IResource.PROJECT:
2823 return JavaCore.newProjectEntry(resolvedPath, entry
2826 case IResource.FILE:
2828 // (ProjectPrefUtil.isArchiveFileName(resolvedResource.getName()))
2830 // // internal binary archive
2831 // return JavaCore.newLibraryEntry(
2833 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2834 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2835 // entry.isExported());
2839 case IResource.FOLDER:
2840 // internal binary folder
2841 // return JavaCore.newLibraryEntry(
2843 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2844 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2845 // entry.isExported());
2850 // outside the workspace
2851 if (target instanceof File) {
2852 File externalFile = (File) target;
2853 if (externalFile.isFile()) {
2854 //String fileName = externalFile.getName().toLowerCase();
2855 // if (fileName.endsWith(".jar" //$NON-NLS-1$
2856 // ) || fileName.endsWith(".zip" //$NON-NLS-1$
2857 // )) { // external binary archive
2858 // return JavaCore.newLibraryEntry(
2860 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2861 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2862 // entry.isExported());
2864 } else { // external binary folder
2865 if (resolvedPath.isAbsolute()) {
2866 // return JavaCore.newLibraryEntry(
2868 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2869 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2870 // entry.isExported());
2878 * Resolve a variable path (helper method).
2880 * @param variablePath
2881 * the given variable path
2882 * @return the resolved variable path or <code>null</code> if none
2884 public static IPath getResolvedVariablePath(IPath variablePath) {
2886 if (variablePath == null)
2888 int count = variablePath.segmentCount();
2893 String variableName = variablePath.segment(0);
2894 IPath resolvedPath = JavaCore.getClasspathVariable(variableName);
2895 if (resolvedPath == null)
2898 // append path suffix
2900 resolvedPath = resolvedPath.append(variablePath
2901 .removeFirstSegments(1));
2903 return resolvedPath;
2907 * Answers the shared working copies currently registered for this buffer
2908 * factory. Working copies can be shared by several clients using the same
2909 * buffer factory,see <code>IWorkingCopy.getSharedWorkingCopy</code>.
2912 * the given buffer factory
2913 * @return the list of shared working copies for a given buffer factory
2917 public static IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory) {
2919 // if factory is null, default factory must be used
2920 if (factory == null)
2921 factory = BufferManager.getDefaultBufferManager()
2922 .getDefaultBufferFactory();
2923 Map sharedWorkingCopies = JavaModelManager.getJavaModelManager().sharedWorkingCopies;
2925 Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
2926 if (perFactoryWorkingCopies == null)
2927 return JavaModelManager.NoWorkingCopy;
2928 Collection copies = perFactoryWorkingCopies.values();
2929 IWorkingCopy[] result = new IWorkingCopy[copies.size()];
2930 copies.toArray(result);
2935 * Initializes the default preferences settings for this plug-in.
2937 public static void initializeDefaultPluginPreferences() {
2939 Preferences preferences = PHPeclipsePlugin.getDefault()
2940 .getPluginPreferences();
2941 HashSet optionNames = JavaModelManager.OptionNames;
2943 // Compiler settings
2944 preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
2945 optionNames.add(COMPILER_LOCAL_VARIABLE_ATTR);
2947 preferences.setDefault(COMPILER_LINE_NUMBER_ATTR, GENERATE);
2948 optionNames.add(COMPILER_LINE_NUMBER_ATTR);
2950 preferences.setDefault(COMPILER_SOURCE_FILE_ATTR, GENERATE);
2951 optionNames.add(COMPILER_SOURCE_FILE_ATTR);
2953 preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE);
2954 optionNames.add(COMPILER_CODEGEN_UNUSED_LOCAL);
2956 preferences.setDefault(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1);
2957 optionNames.add(COMPILER_CODEGEN_TARGET_PLATFORM);
2959 preferences.setDefault(COMPILER_PB_PHP_VAR_DEPRECATED, IGNORE);
2960 optionNames.add(COMPILER_PB_PHP_VAR_DEPRECATED);
2961 preferences.setDefault(COMPILER_PB_PHP_KEYWORD, WARNING);
2962 optionNames.add(COMPILER_PB_PHP_KEYWORD);
2963 preferences.setDefault(COMPILER_PB_PHP_UPPERCASE_IDENTIFIER, IGNORE);
2964 optionNames.add(COMPILER_PB_PHP_UPPERCASE_IDENTIFIER);
2965 preferences.setDefault(COMPILER_PB_PHP_FILE_NOT_EXIST, WARNING);
2966 optionNames.add(COMPILER_PB_PHP_FILE_NOT_EXIST);
2967 preferences.setDefault(COMPILER_PB_UNREACHABLE_CODE, WARNING);
2968 optionNames.add(COMPILER_PB_UNREACHABLE_CODE);
2969 preferences.setDefault(COMPILER_PB_UNINITIALIZED_LOCAL_VARIABLE,
2971 optionNames.add(COMPILER_PB_UNINITIALIZED_LOCAL_VARIABLE);
2973 preferences.setDefault(COMPILER_PB_INVALID_IMPORT, ERROR);
2974 optionNames.add(COMPILER_PB_INVALID_IMPORT);
2976 preferences.setDefault(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD,
2978 optionNames.add(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD);
2980 preferences.setDefault(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME,
2982 optionNames.add(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME);
2984 preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING);
2985 optionNames.add(COMPILER_PB_DEPRECATION);
2987 preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE,
2989 optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE);
2991 preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING);
2992 optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK);
2994 preferences.setDefault(COMPILER_PB_UNUSED_LOCAL, IGNORE);
2995 optionNames.add(COMPILER_PB_UNUSED_LOCAL);
2997 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE);
2998 optionNames.add(COMPILER_PB_UNUSED_PARAMETER);
3000 preferences.setDefault(
3001 COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT,
3004 .add(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT);
3008 COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE,
3010 optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE);
3012 preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING);
3013 optionNames.add(COMPILER_PB_UNUSED_IMPORT);
3015 preferences.setDefault(COMPILER_PB_UNUSED_PRIVATE_MEMBER, IGNORE);
3016 optionNames.add(COMPILER_PB_UNUSED_PRIVATE_MEMBER);
3018 preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE);
3019 optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION);
3021 preferences.setDefault(COMPILER_PB_NON_NLS_STRING_LITERAL, IGNORE);
3022 optionNames.add(COMPILER_PB_NON_NLS_STRING_LITERAL);
3024 preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE);
3025 optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER);
3027 preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING);
3028 optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER);
3030 preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING);
3031 optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT);
3033 preferences.setDefault(
3034 COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD,
3037 .add(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD);
3039 preferences.setDefault(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION,
3041 optionNames.add(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION);
3043 preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAG); //$NON-NLS-1$
3044 optionNames.add(COMPILER_TASK_TAGS);
3046 preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITY); //$NON-NLS-1$
3047 optionNames.add(COMPILER_TASK_PRIORITIES);
3049 preferences.setDefault(COMPILER_SOURCE, VERSION_1_3);
3050 optionNames.add(COMPILER_SOURCE);
3052 preferences.setDefault(COMPILER_COMPLIANCE, VERSION_1_3);
3053 optionNames.add(COMPILER_COMPLIANCE);
3055 preferences.setDefault(COMPILER_PB_MAX_PER_UNIT, "100"); //$NON-NLS-1$
3056 optionNames.add(COMPILER_PB_MAX_PER_UNIT);
3059 preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
3060 optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
3062 preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT);
3063 optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH);
3065 preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING);
3066 optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE);
3068 preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN);
3069 optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER);
3071 // JavaCore settings
3072 preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE);
3073 optionNames.add(CORE_JAVA_BUILD_ORDER);
3075 preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR);
3076 optionNames.add(CORE_CIRCULAR_CLASSPATH);
3078 preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR);
3079 optionNames.add(CORE_INCOMPLETE_CLASSPATH);
3081 preferences.setDefault(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS,
3083 optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS);
3085 preferences.setDefault(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS,
3087 optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS);
3089 // encoding setting comes from resource plug-in
3090 optionNames.add(CORE_ENCODING);
3092 // Formatter settings
3093 preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT);
3094 optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE);
3096 preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT);
3097 optionNames.add(FORMATTER_NEWLINE_CONTROL);
3099 preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE);
3100 optionNames.add(FORMATTER_CLEAR_BLANK_LINES);
3102 preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT);
3103 optionNames.add(FORMATTER_NEWLINE_ELSE_IF);
3105 preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT);
3106 optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK);
3108 preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$
3109 optionNames.add(FORMATTER_LINE_SPLIT);
3111 preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL);
3112 optionNames.add(FORMATTER_COMPACT_ASSIGNMENT);
3114 preferences.setDefault(FORMATTER_COMPACT_ARRAYS, NORMAL);
3115 optionNames.add(FORMATTER_COMPACT_ARRAYS);
3117 preferences.setDefault(FORMATTER_COMPACT_STRING_CONCATENATION, NORMAL);
3118 optionNames.add(FORMATTER_COMPACT_STRING_CONCATENATION);
3120 preferences.setDefault(FORMATTER_TAB_CHAR, TAB);
3121 optionNames.add(FORMATTER_TAB_CHAR);
3123 preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$
3124 optionNames.add(FORMATTER_TAB_SIZE);
3126 preferences.setDefault(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$
3127 optionNames.add(FORMATTER_SPACE_CASTEXPRESSION);
3129 // CodeAssist settings
3130 preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$
3131 optionNames.add(CODEASSIST_VISIBILITY_CHECK);
3133 preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$
3134 optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION);
3136 preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
3137 optionNames.add(CODEASSIST_FIELD_PREFIXES);
3139 preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
3140 optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES);
3142 preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
3143 optionNames.add(CODEASSIST_LOCAL_PREFIXES);
3145 preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
3146 optionNames.add(CODEASSIST_ARGUMENT_PREFIXES);
3148 preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3149 optionNames.add(CODEASSIST_FIELD_SUFFIXES);
3151 preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3152 optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES);
3154 preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
3155 optionNames.add(CODEASSIST_LOCAL_SUFFIXES);
3157 preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
3158 optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES);
3162 * Returns whether the given marker references the given Java element. Used
3163 * for markers, which denote a Java element rather than a resource.
3169 * @return <code>true</code> if the marker references the element, false
3171 * @exception CoreException
3172 * if the <code>IMarker.getAttribute</code> on the marker
3175 public static boolean isReferencedBy(IJavaElement element, IMarker marker)
3176 throws CoreException {
3178 // only match units or classfiles
3179 if (element instanceof IMember) {
3180 IMember member = (IMember) element;
3181 if (member.isBinary()) {
3182 element = null; // member.getClassFile();
3184 element = member.getCompilationUnit();
3187 if (element == null)
3192 String markerHandleId = (String) marker.getAttribute(ATT_HANDLE_ID);
3193 if (markerHandleId == null)
3196 IJavaElement markerElement = JavaCore.create(markerHandleId);
3198 if (element.equals(markerElement))
3199 return true; // external elements may still be equal with
3203 // cycle through enclosing types in case marker is associated with a
3204 // classfile (15568)
3205 // if (markerElement instanceof IClassFile){
3206 // IType enclosingType =
3207 // ((IClassFile)markerElement).getType().getDeclaringType();
3208 // if (enclosingType != null){
3209 // markerElement = enclosingType.getClassFile(); // retry with immediate
3210 // enclosing classfile
3220 * Returns whether the given marker delta references the given Java element.
3221 * Used for markers deltas, which denote a Java element rather than a
3226 * @param markerDelta
3228 * @return <code>true</code> if the marker delta references the element
3229 * @exception CoreException
3230 * if the <code>IMarkerDelta.getAttribute</code> on the
3231 * marker delta fails
3233 public static boolean isReferencedBy(IJavaElement element,
3234 IMarkerDelta markerDelta) throws CoreException {
3236 // only match units or classfiles
3237 if (element instanceof IMember) {
3238 IMember member = (IMember) element;
3239 if (member.isBinary()) {
3240 element = null; // member.getClassFile();
3242 element = member.getCompilationUnit();
3245 if (element == null)
3247 if (markerDelta == null)
3250 String markerDeltarHandleId = (String) markerDelta
3251 .getAttribute(ATT_HANDLE_ID);
3252 if (markerDeltarHandleId == null)
3255 IJavaElement markerElement = JavaCore.create(markerDeltarHandleId);
3257 if (element.equals(markerElement))
3258 return true; // external elements may still be equal with
3262 // cycle through enclosing types in case marker is associated with a
3263 // classfile (15568)
3264 // if (markerElement instanceof IClassFile){
3265 // IType enclosingType =
3266 // ((IClassFile)markerElement).getType().getDeclaringType();
3267 // if (enclosingType != null){
3268 // markerElement = enclosingType.getClassFile(); // retry with immediate
3269 // enclosing classfile
3279 * Creates and returns a new classpath entry of kind
3280 * <code>CPE_CONTAINER</code> for the given path. The path of the
3281 * container will be used during resolution so as to map this container
3282 * entry to a set of other classpath entries the container is acting for.
3284 * A container entry allows to express indirect references to a set of
3285 * libraries, projects and variable entries, which can be interpreted
3286 * differently for each Java project where it is used. A classpath container
3287 * entry can be resolved using
3288 * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3289 * <code>JavaCore.classpathContainerChanged</code>
3291 * A container is exclusively resolved by a
3292 * <code>ClasspathContainerInitializer</code> registered onto the
3294 * "net.sourceforge.phpdt.core.classpathContainerInitializer".
3296 * A container path must be formed of at least one segment, where:
3298 * <li>the first segment is a unique ID identifying the target container,
3299 * there must be a container initializer registered onto this ID through the
3301 * "net.sourceforge.phpdt.core.classpathContainerInitializer". </li>
3302 * <li>the remaining segments will be passed onto the initializer, and can
3303 * be used as additional hints during the initialization phase.</li>
3306 * Example of an ClasspathContainerInitializer for a classpath container
3307 * denoting a default JDK container:
3309 * containerEntry = JavaCore.newContainerEntry(new
3310 * Path("MyProvidedJDK/default"));
3313 * point="net.sourceforge.phpdt.core.classpathContainerInitializer">
3314 * <containerInitializer id="MyProvidedJDK"
3315 * class="com.example.MyInitializer"/>
3317 * Note that this operation does not attempt to validate classpath
3318 * containers or access the resources at the given paths.
3320 * The resulting entry is not exported to dependent projects. This method is
3321 * equivalent to <code>newContainerEntry(-,false)</code>.
3324 * @param containerPath
3325 * the path identifying the container, it must be formed of two
3327 * @return a new container classpath entry
3329 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3330 * @see JavaCore#newContainerEntry(IPath, boolean)
3333 public static IClasspathEntry newContainerEntry(IPath containerPath) {
3335 return newContainerEntry(containerPath, false);
3339 * Creates and returns a new classpath entry of kind
3340 * <code>CPE_CONTAINER</code> for the given path. The path of the
3341 * container will be used during resolution so as to map this container
3342 * entry to a set of other classpath entries the container is acting for.
3344 * A container entry allows to express indirect references to a set of
3345 * libraries, projects and variable entries, which can be interpreted
3346 * differently for each Java project where it is used. A classpath container
3347 * entry can be resolved using
3348 * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3349 * <code>JavaCore.classpathContainerChanged</code>
3351 * A container is exclusively resolved by a
3352 * <code>ClasspathContainerInitializer</code> registered onto the
3354 * "net.sourceforge.phpdt.core.classpathContainerInitializer".
3356 * A container path must be formed of at least one segment, where:
3358 * <li>the first segment is a unique ID identifying the target container,
3359 * there must be a container initializer registered onto this ID through the
3361 * "net.sourceforge.phpdt.core.classpathContainerInitializer". </li>
3362 * <li>the remaining segments will be passed onto the initializer, and can
3363 * be used as additional hints during the initialization phase.</li>
3366 * Example of an ClasspathContainerInitializer for a classpath container
3367 * denoting a default JDK container:
3369 * containerEntry = JavaCore.newContainerEntry(new
3370 * Path("MyProvidedJDK/default"));
3373 * point="net.sourceforge.phpdt.core.classpathContainerInitializer">
3374 * <containerInitializer id="MyProvidedJDK"
3375 * class="com.example.MyInitializer"/>
3377 * Note that this operation does not attempt to validate classpath
3378 * containers or access the resources at the given paths.
3381 * @param containerPath
3382 * the path identifying the container, it must be formed of at
3383 * least one segment (ID+hints)
3385 * a boolean indicating whether this entry is contributed to
3386 * dependent projects in addition to the output location
3387 * @return a new container classpath entry
3389 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3390 * @see JavaCore#setClasspathContainer(IPath, IJavaProject[],
3391 * IClasspathContainer[], IProgressMonitor)
3392 * @see JavaCore#newContainerEntry(IPath, boolean)
3396 public static IClasspathEntry newContainerEntry(IPath containerPath,
3397 boolean isExported) {
3399 if (containerPath == null)
3400 Assert.isTrue(false, "Container path cannot be null"); //$NON-NLS-1$
3401 if (containerPath.segmentCount() < 1) {
3405 "Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$
3407 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3408 IClasspathEntry.CPE_CONTAINER, containerPath,
3409 ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, null, // source
3411 null, // source attachment root
3412 null, // specific output folder
3417 * Creates and returns a new non-exported classpath entry of kind
3418 * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3419 * absolute path. This specifies that all package fragments within the root
3420 * will have children of type <code>IClassFile</code>.
3422 * A library entry is used to denote a prerequisite JAR or root folder
3423 * containing binaries. The target JAR or folder can either be defined
3424 * internally to the workspace (absolute path relative to the workspace
3425 * root) or externally to the workspace (absolute path in the file system).
3427 * e.g. Here are some examples of binary path usage
3429 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3431 * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3433 * <li><code> "c:/classes/" </code>- reference to an external binary
3436 * Note that this operation does not attempt to validate or access the
3437 * resources at the given paths.
3439 * The resulting entry is not exported to dependent projects. This method is
3440 * equivalent to <code>newLibraryEntry(-,-,-,false)</code>.
3444 * the absolute path of the binary archive
3445 * @param sourceAttachmentPath
3446 * the absolute path of the corresponding source archive or
3447 * folder, or <code>null</code> if none
3448 * @param sourceAttachmentRootPath
3449 * the location of the root within the source archive or folder
3450 * or <code>null</code> if this location should be
3451 * automatically detected.
3452 * @return a new library classpath entry
3454 * @see #newLibraryEntry(IPath, IPath, IPath, boolean)
3456 // public static IClasspathEntry newLibraryEntry(
3458 // IPath sourceAttachmentPath,
3459 // IPath sourceAttachmentRootPath) {
3461 // return newLibraryEntry(path, sourceAttachmentPath,
3462 // sourceAttachmentRootPath, false);
3465 * Creates and returns a new classpath entry of kind
3466 * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3467 * absolute path. This specifies that all package fragments within the root
3468 * will have children of type <code>IClassFile</code>.
3470 * A library entry is used to denote a prerequisite JAR or root folder
3471 * containing binaries. The target JAR or folder can either be defined
3472 * internally to the workspace (absolute path relative to the workspace
3473 * root) or externally to the workspace (absolute path in the file system).
3475 * e.g. Here are some examples of binary path usage
3477 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3479 * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3481 * <li><code> "c:/classes/" </code>- reference to an external binary
3484 * Note that this operation does not attempt to validate or access the
3485 * resources at the given paths.
3489 * the absolute path of the binary archive
3490 * @param sourceAttachmentPath
3491 * the absolute path of the corresponding source archive or
3492 * folder, or <code>null</code> if none
3493 * @param sourceAttachmentRootPath
3494 * the location of the root within the source archive or folder
3495 * or <code>null</code> if this location should be
3496 * automatically detected.
3498 * indicates whether this entry is contributed to dependent
3499 * projects in addition to the output location
3500 * @return a new library classpath entry
3503 // public static IClasspathEntry newLibraryEntry(
3505 // IPath sourceAttachmentPath,
3506 // IPath sourceAttachmentRootPath,
3507 // boolean isExported) {
3509 // if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry
3510 // must be absolute"); //$NON-NLS-1$
3512 // return new ClasspathEntry(
3513 // IPackageFragmentRoot.K_BINARY,
3514 // IClasspathEntry.CPE_LIBRARY,
3515 // JavaProject.canonicalizedPath(path),
3516 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3517 // sourceAttachmentPath,
3518 // sourceAttachmentRootPath,
3519 // null, // specific output folder
3523 * Creates and returns a new non-exported classpath entry of kind
3524 * <code>CPE_PROJECT</code> for the project identified by the given
3527 * A project entry is used to denote a prerequisite project on a classpath.
3528 * The referenced project will be contributed as a whole, either as sources
3529 * (in the Java Model, it contributes all its package fragment roots) or as
3530 * binaries (when building, it contributes its whole output location).
3532 * A project reference allows to indirect through another project,
3533 * independently from its internal layout.
3535 * The prerequisite project is referred to using an absolute path relative
3536 * to the workspace root.
3538 * The resulting entry is not exported to dependent projects. This method is
3539 * equivalent to <code>newProjectEntry(_,false)</code>.
3543 * the absolute path of the binary archive
3544 * @return a new project classpath entry
3546 * @see JavaCore#newProjectEntry(IPath, boolean)
3548 public static IClasspathEntry newProjectEntry(IPath path) {
3549 return newProjectEntry(path, false);
3553 * Creates and returns a new classpath entry of kind
3554 * <code>CPE_PROJECT</code> for the project identified by the given
3557 * A project entry is used to denote a prerequisite project on a classpath.
3558 * The referenced project will be contributed as a whole, either as sources
3559 * (in the Java Model, it contributes all its package fragment roots) or as
3560 * binaries (when building, it contributes its whole output location).
3562 * A project reference allows to indirect through another project,
3563 * independently from its internal layout.
3565 * The prerequisite project is referred to using an absolute path relative
3566 * to the workspace root.
3570 * the absolute path of the prerequisite project
3572 * indicates whether this entry is contributed to dependent
3573 * projects in addition to the output location
3574 * @return a new project classpath entry
3577 public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) {
3579 if (!path.isAbsolute())
3580 Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3582 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3583 IClasspathEntry.CPE_PROJECT, path, ClasspathEntry.INCLUDE_ALL,
3584 ClasspathEntry.EXCLUDE_NONE, null, // source attachment
3585 null, // source attachment root
3586 null, // specific output folder
3591 * Returns a new empty region.
3593 * @return a new empty region
3595 public static IRegion newRegion() {
3596 return new Region();
3600 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3601 * for all files in the project's source folder identified by the given
3602 * absolute workspace-relative path.
3604 * The convenience method is fully equivalent to:
3607 * newSourceEntry(path, new IPath[] {}, new IPath[] {}, null);
3613 * the absolute workspace-relative path of a source folder
3614 * @return a new source classpath entry
3615 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath)
3617 public static IClasspathEntry newSourceEntry(IPath path) {
3619 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL,
3620 ClasspathEntry.EXCLUDE_NONE, null /* output location */);
3624 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3625 * for the project's source folder identified by the given absolute
3626 * workspace-relative path but excluding all source files with paths
3627 * matching any of the given patterns.
3629 * The convenience method is fully equivalent to:
3632 * newSourceEntry(path, new IPath[] {}, exclusionPatterns, null);
3638 * the absolute workspace-relative path of a source folder
3639 * @param exclusionPatterns
3640 * the possibly empty list of exclusion patterns represented as
3642 * @return a new source classpath entry
3643 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath)
3646 public static IClasspathEntry newSourceEntry(IPath path,
3647 IPath[] exclusionPatterns) {
3649 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL,
3650 exclusionPatterns, null /* output location */);
3654 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3655 * for the project's source folder identified by the given absolute
3656 * workspace-relative path but excluding all source files with paths
3657 * matching any of the given patterns, and associated with a specific output
3658 * location (that is, ".class" files are not going to the project default
3661 * The convenience method is fully equivalent to:
3664 * newSourceEntry(path, new IPath[] {}, exclusionPatterns, specificOutputLocation);
3670 * the absolute workspace-relative path of a source folder
3671 * @param exclusionPatterns
3672 * the possibly empty list of exclusion patterns represented as
3674 * @param specificOutputLocation
3675 * the specific output location for this source entry (<code>null</code>
3676 * if using project default ouput location)
3677 * @return a new source classpath entry
3678 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath)
3681 public static IClasspathEntry newSourceEntry(IPath path,
3682 IPath[] exclusionPatterns, IPath specificOutputLocation) {
3684 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL,
3685 exclusionPatterns, specificOutputLocation);
3689 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3690 * for the project's source folder identified by the given absolute
3691 * workspace-relative path using the given inclusion and exclusion patterns
3692 * to determine which source files are included, and the given output path
3693 * to control the output location of generated files.
3695 * The source folder is referred to using an absolute path relative to the
3696 * workspace root, e.g. <code>/Project/src</code>. A project's source
3697 * folders are located with that project. That is, a source classpath entry
3698 * specifying the path <code>/P1/src</code> is only usable for project
3702 * The inclusion patterns determines the initial set of source files that
3703 * are to be included; the exclusion patterns are then used to reduce this
3704 * set. When no inclusion patterns are specified, the initial file set
3705 * includes all relevent files in the resource tree rooted at the source
3706 * entry's path. On the other hand, specifying one or more inclusion
3707 * patterns means that all <b>and only</b> files matching at least one of
3708 * the specified patterns are to be included. If exclusion patterns are
3709 * specified, the initial set of files is then reduced by eliminating files
3710 * matched by at least one of the exclusion patterns. Inclusion and
3711 * exclusion patterns look like relative file paths with wildcards and are
3712 * interpreted relative to the source entry's path. File patterns are
3713 * case-sensitive can contain '**', '*' or '?' wildcards (see
3714 * {@link IClasspathEntry#getExclusionPatterns()} for the full description
3715 * of their syntax and semantics). The resulting set of files are included
3716 * in the corresponding package fragment root; all package fragments within
3717 * the root will have children of type <code>ICompilationUnit</code>.
3720 * For example, if the source folder path is <code>/Project/src</code>,
3721 * there are no inclusion filters, and the exclusion pattern is
3722 * <code>com/xyz/tests/**</code>, then source files like
3723 * <code>/Project/src/com/xyz/Foo.java</code> and
3724 * <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3725 * whereas <code>/Project/src/com/xyz/tests/T1.java</code> and
3726 * <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3730 * Additionally, a source entry can be associated with a specific output
3731 * location. By doing so, the Java builder will ensure that the generated
3732 * ".class" files will be issued inside this output location, as opposed to
3733 * be generated into the project default output location (when output
3734 * location is <code>null</code>). Note that multiple source entries may
3735 * target the same output location. The output location is referred to using
3736 * an absolute path relative to the workspace root, e.g.
3737 * <code>"/Project/bin"</code>, it must be located inside the same
3738 * project as the source folder.
3741 * Also note that all sources/binaries inside a project are contributed as a
3742 * whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
3743 * Particular source entries cannot be selectively exported.
3747 * the absolute workspace-relative path of a source folder
3748 * @param inclusionPatterns
3749 * the possibly empty list of inclusion patterns represented as
3751 * @param exclusionPatterns
3752 * the possibly empty list of exclusion patterns represented as
3754 * @param specificOutputLocation
3755 * the specific output location for this source entry (<code>null</code>
3756 * if using project default ouput location)
3757 * @return a new source classpath entry with the given exclusion patterns
3758 * @see IClasspathEntry#getInclusionPatterns()
3759 * @see IClasspathEntry#getExclusionPatterns()
3760 * @see IClasspathEntry#getOutputLocation()
3763 public static IClasspathEntry newSourceEntry(IPath path,
3764 IPath[] inclusionPatterns, IPath[] exclusionPatterns,
3765 IPath specificOutputLocation) {
3768 Assert.isTrue(false, "Source path cannot be null"); //$NON-NLS-1$
3769 if (!path.isAbsolute())
3770 Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3771 if (exclusionPatterns == null)
3772 Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$
3773 if (inclusionPatterns == null)
3774 Assert.isTrue(false, "Inclusion pattern set cannot be null"); //$NON-NLS-1$
3776 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3777 IClasspathEntry.CPE_SOURCE, path, inclusionPatterns,
3778 exclusionPatterns, null, // source attachment
3779 null, // source attachment root
3780 specificOutputLocation, // custom output location
3785 * Creates and returns a new non-exported classpath entry of kind
3786 * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3787 * path is the name of a classpath variable. The trailing segments of the
3788 * path will be appended to resolved variable path.
3790 * A variable entry allows to express indirect references on a classpath to
3791 * other projects or libraries, depending on what the classpath variable is
3794 * It is possible to register an automatic initializer (
3795 * <code>ClasspathVariableInitializer</code>), which will be invoked
3796 * through the extension point
3797 * "net.sourceforge.phpdt.core.classpathVariableInitializer". After
3798 * resolution, a classpath variable entry may either correspond to a project
3799 * or a library entry.</li>
3801 * e.g. Here are some examples of variable path usage
3803 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3804 * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3805 * library "c:\jars\jdtcore.jar"</li>
3806 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3807 * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3808 * "/Project_JDTCORE"</li>
3809 * <li>"PLUGINS/com.example/example.jar" where variable
3810 * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3811 * classpath entry is denoting the library
3812 * "c:/eclipse/plugins/com.example/example.jar"</li>
3814 * Note that this operation does not attempt to validate classpath variables
3815 * or access the resources at the given paths.
3817 * The resulting entry is not exported to dependent projects. This method is
3818 * equivalent to <code>newVariableEntry(-,-,-,false)</code>.
3821 * @param variablePath
3822 * the path of the binary archive; first segment is the name of a
3823 * classpath variable
3824 * @param variableSourceAttachmentPath
3825 * the path of the corresponding source archive, or
3826 * <code>null</code> if none; if present, the first segment is
3827 * the name of a classpath variable (not necessarily the same
3828 * variable as the one that begins <code>variablePath</code>)
3829 * @param sourceAttachmentRootPath
3830 * the location of the root within the source archive or
3831 * <code>null</code> if <code>archivePath</code> is also
3833 * @return a new library classpath entry
3835 * @see JavaCore#newVariableEntry(IPath, IPath, IPath, boolean)
3837 // public static IClasspathEntry newVariableEntry(
3838 // IPath variablePath,
3839 // IPath variableSourceAttachmentPath,
3840 // IPath sourceAttachmentRootPath) {
3842 // return newVariableEntry(variablePath, variableSourceAttachmentPath,
3843 // sourceAttachmentRootPath, false);
3846 * Creates and returns a new non-exported classpath entry of kind
3847 * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3848 * path is the name of a classpath variable. The trailing segments of the
3849 * path will be appended to resolved variable path.
3851 * A variable entry allows to express indirect references on a classpath to
3852 * other projects or libraries, depending on what the classpath variable is
3855 * It is possible to register an automatic initializer (
3856 * <code>ClasspathVariableInitializer</code>), which will be invoked
3857 * through the extension point
3858 * "net.sourceforge.phpdt.core.classpathVariableInitializer". After
3859 * resolution, a classpath variable entry may either correspond to a project
3860 * or a library entry.</li>
3862 * e.g. Here are some examples of variable path usage
3864 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3865 * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3866 * library "c:\jars\jdtcore.jar"</li>
3867 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3868 * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3869 * "/Project_JDTCORE"</li>
3870 * <li>"PLUGINS/com.example/example.jar" where variable
3871 * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3872 * classpath entry is denoting the library
3873 * "c:/eclipse/plugins/com.example/example.jar"</li>
3875 * Note that this operation does not attempt to validate classpath variables
3876 * or access the resources at the given paths.
3879 * @param variablePath
3880 * the path of the binary archive; first segment is the name of a
3881 * classpath variable
3882 * @param variableSourceAttachmentPath
3883 * the path of the corresponding source archive, or
3884 * <code>null</code> if none; if present, the first segment is
3885 * the name of a classpath variable (not necessarily the same
3886 * variable as the one that begins <code>variablePath</code>)
3887 * @param sourceAttachmentRootPath
3888 * the location of the root within the source archive or
3889 * <code>null</code> if <code>archivePath</code> is also
3892 * indicates whether this entry is contributed to dependent
3893 * projects in addition to the output location
3894 * @return a new variable classpath entry
3897 // public static IClasspathEntry newVariableEntry(
3898 // IPath variablePath,
3899 // IPath variableSourceAttachmentPath,
3900 // IPath variableSourceAttachmentRootPath,
3901 // boolean isExported) {
3903 // if (variablePath == null || variablePath.segmentCount() < 1) {
3906 // "Illegal classpath variable path: \'" +
3907 // variablePath.makeRelative().toString() + "\', must have at least one
3908 // segment"); //$NON-NLS-1$//$NON-NLS-2$
3911 // return new ClasspathEntry(
3912 // IPackageFragmentRoot.K_SOURCE,
3913 // IClasspathEntry.CPE_VARIABLE,
3915 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3916 // variableSourceAttachmentPath, // source attachment
3917 // variableSourceAttachmentRootPath, // source attachment root
3918 // null, // specific output folder
3922 * Removed the given classpath variable. Does nothing if no value was set
3923 * for this classpath variable.
3925 * This functionality cannot be used while the resource tree is locked.
3927 * Classpath variable values are persisted locally to the workspace, and are
3928 * preserved from session to session.
3931 * @param variableName
3932 * the name of the classpath variable
3933 * @see #setClasspathVariable
3935 * @deprecated - use version with extra IProgressMonitor
3937 // public static void removeClasspathVariable(String variableName) {
3938 // removeClasspathVariable(variableName, null);
3941 * Removed the given classpath variable. Does nothing if no value was set
3942 * for this classpath variable.
3944 * This functionality cannot be used while the resource tree is locked.
3946 * Classpath variable values are persisted locally to the workspace, and are
3947 * preserved from session to session.
3950 * @param variableName
3951 * the name of the classpath variable
3953 * the progress monitor to report progress
3954 * @see #setClasspathVariable
3956 // public static void removeClasspathVariable(
3957 // String variableName,
3958 // IProgressMonitor monitor) {
3961 // updateVariableValues(new String[]{ variableName}, new IPath[]{ null },
3963 // } catch (JavaModelException e) {
3967 * Removes the given element changed listener. Has no affect if an identical
3968 * listener is not registered.
3973 public static void removeElementChangedListener(
3974 IElementChangedListener listener) {
3975 JavaModelManager.getJavaModelManager().removeElementChangedListener(
3980 * Bind a container reference path to some actual containers (
3981 * <code>IClasspathContainer</code>). This API must be invoked whenever
3982 * changes in container need to be reflected onto the JavaModel. Containers
3983 * can have distinct values in different projects, therefore this API
3984 * considers a set of projects with their respective containers.
3986 * <code>containerPath</code> is the path under which these values can be
3987 * referenced through container classpath entries (
3988 * <code>IClasspathEntry#CPE_CONTAINER</code>). A container path is
3989 * formed by a first ID segment followed with extra segments, which can be
3990 * used as additional hints for the resolution. The container ID is used to
3991 * identify a <code>ClasspathContainerInitializer</code> registered on the
3993 * "net.sourceforge.phpdt.core.classpathContainerInitializer".
3995 * There is no assumption that each individual container value passed in
3996 * argument (<code>respectiveContainers</code>) must answer the exact
3997 * same path when requested <code>IClasspathContainer#getPath</code>.
3998 * Indeed, the containerPath is just an indication for resolving it to an
3999 * actual container object. It can be delegated to a
4000 * <code>ClasspathContainerInitializer</code>, which can be activated
4001 * through the extension point
4002 * "net.sourceforge.phpdt.core.ClasspathContainerInitializer").
4004 * In reaction to changing container values, the JavaModel will be updated
4005 * to reflect the new state of the updated container.
4007 * This functionality cannot be used while the resource tree is locked.
4009 * Classpath container values are persisted locally to the workspace, but
4010 * are not preserved from a session to another. It is thus highly
4011 * recommended to register a <code>ClasspathContainerInitializer</code>
4012 * for each referenced container (through the extension point
4013 * "net.sourceforge.phpdt.core.ClasspathContainerInitializer").
4015 * Note: setting a container to <code>null</code> will cause it to be
4016 * lazily resolved again whenever its value is required. In particular, this
4017 * will cause a registered initializer to be invoked again.
4020 * @param containerPath -
4021 * the name of the container reference, which is being updated
4022 * @param affectedProjects -
4023 * the set of projects for which this container is being bound
4024 * @param respectiveContainers -
4025 * the set of respective containers for the affected projects
4027 * a monitor to report progress
4029 * @see ClasspathContainerInitializer
4030 * @see #getClasspathContainer(IPath, IJavaProject)
4031 * @see IClasspathContainer
4034 // public static void setClasspathContainer(final IPath containerPath,
4035 // IJavaProject[] affectedProjects, IClasspathContainer[]
4036 // respectiveContainers, IProgressMonitor monitor) throws JavaModelException
4039 // if (affectedProjects.length != respectiveContainers.length)
4040 // Assert.isTrue(false, "Projects and containers collections should have the
4041 // same size"); //$NON-NLS-1$
4043 // if (monitor != null && monitor.isCanceled()) return;
4045 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4046 // System.out.println("CPContainer SET - setting container:
4047 // ["+containerPath+"] for projects: {" //$NON-NLS-1$ //$NON-NLS-2$
4048 // + (ProjectPrefUtil.toString(affectedProjects,
4049 // new ProjectPrefUtil.Displayable(){
4050 // public String displayString(Object o) { return ((IJavaProject)
4051 // o).getElementName(); }
4053 // + "} with values: " //$NON-NLS-1$
4054 // + (ProjectPrefUtil.toString(respectiveContainers,
4055 // new ProjectPrefUtil.Displayable(){
4056 // public String displayString(Object o) { return ((IClasspathContainer)
4057 // o).getDescription(); }
4062 // final int projectLength = affectedProjects.length;
4063 // final IJavaProject[] modifiedProjects;
4064 // System.arraycopy(affectedProjects, 0, modifiedProjects = new
4065 // IJavaProject[projectLength], 0, projectLength);
4066 // final IClasspathEntry[][] oldResolvedPaths = new
4067 // IClasspathEntry[projectLength][];
4069 // // filter out unmodified project containers
4070 // int remaining = 0;
4071 // for (int i = 0; i < projectLength; i++){
4073 // if (monitor != null && monitor.isCanceled()) return;
4075 // IJavaProject affectedProject = affectedProjects[i];
4076 // IClasspathContainer newContainer = respectiveContainers[i];
4077 // if (newContainer == null) newContainer =
4078 // JavaModelManager.ContainerInitializationInProgress; // 30920 - prevent
4080 // boolean found = false;
4081 // if (JavaProject.hasJavaNature(affectedProject.getProject())){
4082 // IClasspathEntry[] rawClasspath = affectedProject.getRawClasspath();
4083 // for (int j = 0, cpLength = rawClasspath.length; j <cpLength; j++) {
4084 // IClasspathEntry entry = rawClasspath[j];
4085 // if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER &&
4086 // entry.getPath().equals(containerPath)){
4093 // modifiedProjects[i] = null; // filter out this project - does not
4094 // reference the container path, or isnt't yet Java project
4095 // JavaModelManager.containerPut(affectedProject, containerPath,
4099 // IClasspathContainer oldContainer =
4100 // JavaModelManager.containerGet(affectedProject, containerPath);
4101 // if (oldContainer == JavaModelManager.ContainerInitializationInProgress) {
4102 // Map previousContainerValues =
4103 // (Map)JavaModelManager.PreviousSessionContainers.get(affectedProject);
4104 // if (previousContainerValues != null){
4105 // IClasspathContainer previousContainer =
4106 // (IClasspathContainer)previousContainerValues.get(containerPath);
4107 // if (previousContainer != null) {
4108 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4109 // System.out.println("CPContainer INIT - reentering access to project
4110 // container: ["+affectedProject.getElementName()+"] " + containerPath + "
4111 // during its initialization, will see previous value: "+
4112 // previousContainer.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
4115 // JavaModelManager.containerPut(affectedProject, containerPath,
4116 // previousContainer);
4118 // oldContainer = null; //33695 - cannot filter out restored container, must
4119 // update affected project to reset cached CP
4121 // oldContainer = null;
4124 // if (oldContainer != null &&
4125 // oldContainer.equals(respectiveContainers[i])){// TODO: could improve to
4126 // only compare entries
4127 // modifiedProjects[i] = null; // filter out this project - container did
4132 // oldResolvedPaths[i] = affectedProject.getResolvedClasspath(true);
4133 // JavaModelManager.containerPut(affectedProject, containerPath,
4137 // if (remaining == 0) return;
4139 // // trigger model refresh
4141 // JavaCore.run(new IWorkspaceRunnable() {
4142 // public void run(IProgressMonitor monitor) throws CoreException {
4143 // for(int i = 0; i < projectLength; i++){
4145 // if (monitor != null && monitor.isCanceled()) return;
4147 // JavaProject affectedProject = (JavaProject)modifiedProjects[i];
4148 // if (affectedProject == null) continue; // was filtered out
4150 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4151 // System.out.println("CPContainer SET - updating affected project:
4152 // ["+affectedProject.getElementName()+"] due to setting container: " +
4153 // containerPath); //$NON-NLS-1$ //$NON-NLS-2$
4156 // // force a refresh of the affected project (will compute deltas)
4157 // affectedProject.setRawClasspath(
4158 // affectedProject.getRawClasspath(),
4159 // SetClasspathOperation.ReuseOutputLocation,
4161 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can save resources
4162 // oldResolvedPaths[i],
4163 // false, // updating - no validation
4164 // false); // updating - no need to save
4169 // } catch(CoreException e) {
4170 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4171 // System.out.println("CPContainer SET - FAILED DUE TO EXCEPTION:
4172 // "+containerPath); //$NON-NLS-1$
4173 // e.printStackTrace();
4175 // if (e instanceof JavaModelException) {
4176 // throw (JavaModelException)e;
4178 // throw new JavaModelException(e);
4181 // for (int i = 0; i < projectLength; i++) {
4182 // if (respectiveContainers[i] == null) {
4183 // JavaModelManager.containerPut(affectedProjects[i], containerPath, null);
4184 // // reset init in progress marker
4191 * Sets the value of the given classpath variable. The path must have at
4192 * least one segment.
4194 * This functionality cannot be used while the resource tree is locked.
4196 * Classpath variable values are persisted locally to the workspace, and are
4197 * preserved from session to session.
4200 * @param variableName
4201 * the name of the classpath variable
4204 * @see #getClasspathVariable
4206 * @deprecated - use API with IProgressMonitor
4208 // public static void setClasspathVariable(String variableName, IPath path)
4209 // throws JavaModelException {
4211 // setClasspathVariable(variableName, path, null);
4214 * Sets the value of the given classpath variable. The path must not be
4217 * This functionality cannot be used while the resource tree is locked.
4219 * Classpath variable values are persisted locally to the workspace, and are
4220 * preserved from session to session.
4222 * Updating a variable with the same value has no effect.
4224 * @param variableName
4225 * the name of the classpath variable
4229 * a monitor to report progress
4230 * @see #getClasspathVariable
4232 // public static void setClasspathVariable(
4233 // String variableName,
4235 // IProgressMonitor monitor)
4236 // throws JavaModelException {
4238 // if (path == null) Assert.isTrue(false, "Variable path cannot be null");
4240 // setClasspathVariables(new String[]{variableName}, new IPath[]{ path },
4244 * Sets the values of all the given classpath variables at once. Null paths
4245 * can be used to request corresponding variable removal.
4247 * This functionality cannot be used while the resource tree is locked.
4249 * Classpath variable values are persisted locally to the workspace, and are
4250 * preserved from session to session.
4252 * Updating a variable with the same value has no effect.
4254 * @param variableNames
4255 * an array of names for the updated classpath variables
4257 * an array of path updates for the modified classpath variables
4258 * (null meaning that the corresponding value will be removed
4260 * a monitor to report progress
4261 * @see #getClasspathVariable
4264 // public static void setClasspathVariables(
4265 // String[] variableNames,
4267 // IProgressMonitor monitor)
4268 // throws JavaModelException {
4270 // if (variableNames.length != paths.length) Assert.isTrue(false, "Variable
4271 // names and paths collections should have the same size"); //$NON-NLS-1$
4272 // //TODO: should check that null cannot be used as variable paths
4273 // updateVariableValues(variableNames, paths, monitor);
4276 * (non-Javadoc) Method declared on IExecutableExtension. Record any
4277 * necessary initialization data from the plugin.
4279 public void setInitializationData(IConfigurationElement cfig,
4280 String propertyName, Object data) throws CoreException {
4284 * Sets the current table of options. All and only the options explicitly
4285 * included in the given table are remembered; all previous option settings
4286 * are forgotten, including ones not explicitly mentioned.
4288 * For a complete description of the configurable options, see
4289 * <code>getDefaultOptions</code>.
4293 * the new options (key type: <code>String</code>; value type:
4294 * <code>String</code>), or <code>null</code> to reset all
4295 * options to their default values
4296 * @see JavaCore#getDefaultOptions
4298 public static void setOptions(Hashtable newOptions) {
4300 // see #initializeDefaultPluginPreferences() for changing default
4302 Preferences preferences = getPlugin().getPluginPreferences();
4304 if (newOptions == null) {
4305 newOptions = JavaCore.getDefaultOptions();
4307 Enumeration keys = newOptions.keys();
4308 while (keys.hasMoreElements()) {
4309 String key = (String) keys.nextElement();
4310 if (!JavaModelManager.OptionNames.contains(key))
4311 continue; // unrecognized option
4312 if (key.equals(CORE_ENCODING))
4313 continue; // skipped, contributed by resource prefs
4314 String value = (String) newOptions.get(key);
4315 preferences.setValue(key, value);
4319 getPlugin().savePluginPreferences();
4323 * Shutdown the JavaCore plug-in.
4325 * De-registers the JavaModelManager as a resource changed listener and save
4329 * @see org.eclipse.core.runtime.Plugin#shutdown()
4331 // moved to PHPeclipsePlugin#shutdown()
4332 // public void shutdown() {
4334 // //savePluginPreferences();
4335 // getPlugin().savePluginPreferences();
4336 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4337 // workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaProcessor);
4338 // workspace.removeSaveParticipant(PHPeclipsePlugin.getDefault());
4340 // ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown();
4343 * Initiate the background indexing process. This should be deferred after
4344 * the plugin activation.
4346 // private void startIndexing() {
4348 // JavaModelManager.getJavaModelManager().getIndexManager().reset();
4351 * Startup of the JavaCore plug-in.
4353 * Registers the JavaModelManager as a resource changed listener and save
4354 * participant. Starts the background indexing, and restore saved classpath
4358 * @see org.eclipse.core.runtime.Plugin#startup()
4361 // moved to PHPeclipsePlugin#startup()
4362 // public void startup() {
4364 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
4366 // manager.configurePluginDebugOptions();
4368 // // request state folder creation (workaround 19885)
4369 // JavaCore.getPlugin().getStateLocation();
4371 // // retrieve variable values
4372 // JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4373 // JavaModelManager.PluginPreferencesListener());
4374 // // TODO : jsurfer temp-del
4375 // // manager.loadVariablesAndContainers();
4377 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4378 // workspace.addResourceChangeListener(
4379 // manager.deltaProcessor,
4380 // IResourceChangeEvent.PRE_AUTO_BUILD
4381 // | IResourceChangeEvent.POST_AUTO_BUILD
4382 // | IResourceChangeEvent.POST_CHANGE
4383 // | IResourceChangeEvent.PRE_DELETE
4384 // | IResourceChangeEvent.PRE_CLOSE);
4386 // // startIndexing();
4387 // workspace.addSaveParticipant(PHPeclipsePlugin.getDefault(), manager);
4389 // } catch (CoreException e) {
4390 // } catch (RuntimeException e) {
4391 // manager.shutdown();
4396 * Internal updating of a variable values (null path meaning removal),
4397 * allowing to change multiple variable values at once.
4399 // private static void updateVariableValues(
4400 // String[] variableNames,
4401 // IPath[] variablePaths,
4402 // IProgressMonitor monitor) throws JavaModelException {
4404 // if (monitor != null && monitor.isCanceled()) return;
4406 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4407 // System.out.println("CPVariable SET - setting variables: {" +
4408 // ProjectPrefUtil.toString(variableNames) //$NON-NLS-1$
4409 // + "} with values: " + ProjectPrefUtil.toString(variablePaths));
4413 // int varLength = variableNames.length;
4415 // // gather classpath information for updating
4416 // final HashMap affectedProjects = new HashMap(5);
4417 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
4418 // IJavaModel model = manager.getJavaModel();
4420 // // filter out unmodified variables
4421 // int discardCount = 0;
4422 // for (int i = 0; i < varLength; i++){
4423 // String variableName = variableNames[i];
4424 // IPath oldPath = (IPath)JavaModelManager.variableGet(variableName); // if
4425 // reentering will provide previous session value
4426 // if (oldPath == JavaModelManager.VariableInitializationInProgress){
4427 // IPath previousPath =
4428 // (IPath)JavaModelManager.PreviousSessionVariables.get(variableName);
4429 // if (previousPath != null){
4430 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4431 // System.out.println("CPVariable INIT - reentering access to variable: " +
4432 // variableName+ " during its initialization, will see previous value: "+
4433 // previousPath); //$NON-NLS-1$ //$NON-NLS-2$
4435 // JavaModelManager.variablePut(variableName, previousPath); // replace
4436 // value so reentering calls are seeing old value
4438 // oldPath = null; //33695 - cannot filter out restored variable, must
4439 // update affected project to reset cached CP
4441 // if (oldPath != null && oldPath.equals(variablePaths[i])){
4442 // variableNames[i] = null;
4446 // if (discardCount > 0){
4447 // if (discardCount == varLength) return;
4448 // int changedLength = varLength - discardCount;
4449 // String[] changedVariableNames = new String[changedLength];
4450 // IPath[] changedVariablePaths = new IPath[changedLength];
4451 // for (int i = 0, index = 0; i < varLength; i++){
4452 // if (variableNames[i] != null){
4453 // changedVariableNames[index] = variableNames[i];
4454 // changedVariablePaths[index] = variablePaths[i];
4458 // variableNames = changedVariableNames;
4459 // variablePaths = changedVariablePaths;
4460 // varLength = changedLength;
4463 // if (monitor != null && monitor.isCanceled()) return;
4465 // if (model != null) {
4466 // IJavaProject[] projects = model.getJavaProjects();
4467 // nextProject : for (int i = 0, projectLength = projects.length; i <
4468 // projectLength; i++){
4469 // IJavaProject project = projects[i];
4471 // // check to see if any of the modified variables is present on the
4473 // IClasspathEntry[] classpath = project.getRawClasspath();
4474 // for (int j = 0, cpLength = classpath.length; j < cpLength; j++){
4476 // IClasspathEntry entry = classpath[j];
4477 // for (int k = 0; k < varLength; k++){
4479 // String variableName = variableNames[k];
4480 // if (entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE){
4482 // if (variableName.equals(entry.getPath().segment(0))){
4483 // affectedProjects.put(project, project.getResolvedClasspath(true));
4484 // continue nextProject;
4486 // IPath sourcePath, sourceRootPath;
4487 // if (((sourcePath = entry.getSourceAttachmentPath()) != null &&
4488 // variableName.equals(sourcePath.segment(0)))
4489 // || ((sourceRootPath = entry.getSourceAttachmentRootPath()) != null &&
4490 // variableName.equals(sourceRootPath.segment(0)))) {
4492 // affectedProjects.put(project, project.getResolvedClasspath(true));
4493 // continue nextProject;
4500 // // update variables
4501 // for (int i = 0; i < varLength; i++){
4502 // JavaModelManager.variablePut(variableNames[i], variablePaths[i]);
4504 // final String[] dbgVariableNames = variableNames;
4506 // // update affected project classpaths
4507 // if (!affectedProjects.isEmpty()) {
4509 // JavaCore_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt.run(
4510 // new IWorkspaceRunnable() {
4511 // public void run(IProgressMonitor monitor) throws CoreException {
4512 // // propagate classpath change
4513 // Iterator projectsToUpdate = affectedProjects.keySet().iterator();
4514 // while (projectsToUpdate.hasNext()) {
4516 // if (monitor != null && monitor.isCanceled()) return;
4518 // JavaProject project = (JavaProject) projectsToUpdate.next();
4520 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4521 // System.out.println("CPVariable SET - updating affected project:
4522 // ["+project.getElementName()+"] due to setting variables: "+
4523 // ProjectPrefUtil.toString(dbgVariableNames)); //$NON-NLS-1$ //$NON-NLS-2$
4527 // .setRawClasspath(
4528 // project.getRawClasspath(),
4529 // SetClasspathOperation.ReuseOutputLocation,
4530 // null, // don't call beginTask on the monitor (see
4531 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=3717)
4532 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can change resources
4533 // (IClasspathEntry[]) affectedProjects.get(project),
4534 // false, // updating - no validation
4535 // false); // updating - no need to save
4540 // } catch (CoreException e) {
4541 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4542 // System.out.println("CPVariable SET - FAILED DUE TO EXCEPTION:
4543 // "+ProjectPrefUtil.toString(dbgVariableNames)); //$NON-NLS-1$
4544 // e.printStackTrace();
4546 // if (e instanceof JavaModelException) {
4547 // throw (JavaModelException)e;
4549 // throw new JavaModelException(e);
4555 * (non-Javadoc) Startup the JavaCore plug-in. <p> Registers the
4556 * JavaModelManager as a resource changed listener and save participant.
4557 * Starts the background indexing, and restore saved classpath variable
4558 * values. <p> @throws Exception
4560 * @see org.eclipse.core.runtime.Plugin#start(BundleContext)
4562 // public static void start(final Plugin plugin, BundleContext context)
4563 // throws Exception {
4564 // // super.start(context);
4566 // final JavaModelManager manager = JavaModelManager.getJavaModelManager();
4568 // manager.configurePluginDebugOptions();
4570 // // request state folder creation (workaround 19885)
4571 // JavaCore.getPlugin().getStateLocation();
4573 // // retrieve variable values
4574 // //JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4575 // JavaModelManager.PluginPreferencesListener());
4576 // // manager.loadVariablesAndContainers();
4578 // final IWorkspace workspace = ResourcesPlugin.getWorkspace();
4579 // workspace.addResourceChangeListener(
4580 // manager.deltaState,
4581 // IResourceChangeEvent.PRE_BUILD
4582 // | IResourceChangeEvent.POST_BUILD
4583 // | IResourceChangeEvent.POST_CHANGE
4584 // | IResourceChangeEvent.PRE_DELETE
4585 // | IResourceChangeEvent.PRE_CLOSE);
4587 // // startIndexing();
4589 // // process deltas since last activated in indexer thread so that indexes
4591 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658
4592 // Job processSavedState = new
4593 // Job(ProjectPrefUtil.bind("savedState.jobName")) {
4595 // protected IStatus run(IProgressMonitor monitor) {
4597 // // add save participant and process delta atomically
4598 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59937
4600 // new IWorkspaceRunnable() {
4601 // public void run(IProgressMonitor progress) throws CoreException {
4602 // // ISavedState savedState = workspace.addSaveParticipant(JavaCore.this,
4604 // ISavedState savedState = workspace.addSaveParticipant(plugin, manager);
4605 // if (savedState != null) {
4606 // // the event type coming from the saved state is always POST_AUTO_BUILD
4607 // // force it to be POST_CHANGE so that the delta processor can handle it
4608 // manager.deltaState.getDeltaProcessor().overridenEventType =
4609 // IResourceChangeEvent.POST_CHANGE;
4610 // savedState.processResourceChangeEvents(manager.deltaState);
4615 // } catch (CoreException e) {
4616 // return e.getStatus();
4618 // return Status.OK_STATUS;
4621 // processSavedState.setSystem(true);
4622 // processSavedState.setPriority(Job.SHORT); // process asap
4623 // processSavedState.schedule();
4624 // } catch (RuntimeException e) {
4625 // manager.shutdown();
4630 * (non-Javadoc) Shutdown the JavaCore plug-in. <p> De-registers the
4631 * JavaModelManager as a resource changed listener and save participant. <p>
4633 * @see org.eclipse.core.runtime.Plugin#stop(BundleContext)
4635 // public static void stop(Plugin plugin, BundleContext context)
4636 // throws Exception {
4638 // plugin.savePluginPreferences();
4639 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4640 // workspace.removeResourceChangeListener(JavaModelManager
4641 // .getJavaModelManager().deltaState);
4642 // workspace.removeSaveParticipant(plugin);
4644 // JavaModelManager.getJavaModelManager().shutdown();
4646 // // ensure we call super.stop as the last thing
4647 // // super.stop(context);