1 package net.sourceforge.phpdt.core;
4 import java.util.ArrayList;
5 import java.util.Collection;
6 import java.util.Enumeration;
7 import java.util.HashSet;
8 import java.util.Hashtable;
12 import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
13 import net.sourceforge.phpdt.internal.core.BufferManager;
14 import net.sourceforge.phpdt.internal.core.ClasspathEntry;
15 import net.sourceforge.phpdt.internal.core.JavaModel;
16 import net.sourceforge.phpdt.internal.core.JavaModelManager;
17 import net.sourceforge.phpdt.internal.core.Region;
18 import net.sourceforge.phpdt.internal.core.util.MementoTokenizer;
19 import net.sourceforge.phpdt.internal.corext.Assert;
20 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
22 import org.eclipse.core.resources.IFile;
23 import org.eclipse.core.resources.IFolder;
24 import org.eclipse.core.resources.IMarker;
25 import org.eclipse.core.resources.IMarkerDelta;
26 import org.eclipse.core.resources.IProject;
27 import org.eclipse.core.resources.IProjectDescription;
28 import org.eclipse.core.resources.IResource;
29 import org.eclipse.core.resources.IResourceChangeListener;
30 import org.eclipse.core.resources.IWorkspaceRoot;
31 import org.eclipse.core.resources.ResourcesPlugin;
32 import org.eclipse.core.runtime.CoreException;
33 import org.eclipse.core.runtime.IConfigurationElement;
34 import org.eclipse.core.runtime.IPath;
35 import org.eclipse.core.runtime.IProgressMonitor;
36 import org.eclipse.core.runtime.Plugin;
37 import org.eclipse.core.runtime.Preferences;
39 public class JavaCore {
41 // public static HashSet OptionNames = new HashSet(20);
43 * The plug-in identifier of the Java core support (value
44 * <code>"net.sourceforge.phpeclipse"</code>)
46 // public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.core";
48 public static final String PLUGIN_ID = PHPeclipsePlugin.PLUGIN_ID;
51 * Possible configurable option ID.
53 * @see #getDefaultOptions
56 public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; //$NON-NLS-1$
59 * Possible configurable option ID.
61 * @see #getDefaultOptions
64 public static final String FORMATTER_NEWLINE_OPENING_BRACE = PLUGIN_ID
65 + ".formatter.newline.openingBrace"; //$NON-NLS-1$
68 * Possible configurable option ID.
70 * @see #getDefaultOptions
73 public static final String FORMATTER_NEWLINE_CONTROL = PLUGIN_ID
74 + ".formatter.newline.controlStatement"; //$NON-NLS-1$
77 * Possible configurable option ID.
79 * @see #getDefaultOptions
82 public static final String FORMATTER_NEWLINE_ELSE_IF = PLUGIN_ID
83 + ".formatter.newline.elseIf"; //$NON-NLS-1$
86 * Possible configurable option ID.
88 * @see #getDefaultOptions
91 public static final String FORMATTER_NEWLINE_EMPTY_BLOCK = PLUGIN_ID
92 + ".formatter.newline.emptyBlock"; //$NON-NLS-1$
95 * Possible configurable option ID.
97 * @see #getDefaultOptions
100 public static final String FORMATTER_CLEAR_BLANK_LINES = PLUGIN_ID
101 + ".formatter.newline.clearAll"; //$NON-NLS-1$
104 * Possible configurable option ID.
106 * @see #getDefaultOptions
109 public static final String FORMATTER_LINE_SPLIT = PLUGIN_ID
110 + ".formatter.lineSplit"; //$NON-NLS-1$
113 * Possible configurable option ID.
115 * @see #getDefaultOptions
118 public static final String FORMATTER_COMPACT_ASSIGNMENT = PLUGIN_ID
119 + ".formatter.style.assignment"; //$NON-NLS-1$
122 * Possible configurable option ID.
124 * @see #getDefaultOptions
127 public static final String FORMATTER_TAB_CHAR = PLUGIN_ID
128 + ".formatter.tabulation.char"; //$NON-NLS-1$
131 * Possible configurable option ID.
133 * @see #getDefaultOptions
136 public static final String FORMATTER_TAB_SIZE = PLUGIN_ID
137 + ".formatter.tabulation.size"; //$NON-NLS-1$
140 * Possible configurable option value.
142 * @see #getDefaultOptions
145 public static final String INSERT = "insert"; //$NON-NLS-1$
148 * Possible configurable option value.
150 * @see #getDefaultOptions
153 public static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$
156 * Possible configurable option value.
158 * @see #getDefaultOptions
161 public static final String PRESERVE_ONE = "preserve one"; //$NON-NLS-1$
164 * Possible configurable option value.
166 * @see #getDefaultOptions
169 public static final String CLEAR_ALL = "clear all"; //$NON-NLS-1$
172 * Possible configurable option value.
174 * @see #getDefaultOptions
177 public static final String NORMAL = "normal"; //$NON-NLS-1$
180 * Possible configurable option value.
182 * @see #getDefaultOptions
185 public static final String COMPACT = "compact"; //$NON-NLS-1$
188 * Possible configurable option value.
190 * @see #getDefaultOptions
193 public static final String TAB = "tab"; //$NON-NLS-1$
196 * Possible configurable option value.
198 * @see #getDefaultOptions
201 public static final String SPACE = "space"; //$NON-NLS-1$
204 * Possible configurable option value.
206 * @see #getDefaultOptions
209 public static final String ENABLED = "enabled"; //$NON-NLS-1$
212 * Possible configurable option value.
214 * @see #getDefaultOptions
217 public static final String DISABLED = "disabled"; //$NON-NLS-1$
220 * Possible configurable option value.
222 * @see #getDefaultOptions
225 public static final String CLEAN = "clean"; //$NON-NLS-1$
228 * Possible configurable option ID.
230 * @see #getDefaultOptions
233 public static final String COMPILER_TASK_TAGS = PLUGIN_ID
234 + ".compiler.taskTags"; //$NON-NLS-1$
237 * Name of the handle id attribute in a Java marker.
239 protected static final String ATT_HANDLE_ID = "net.sourceforge.phpdt.internal.core.JavaModelManager.handleId"; //$NON-NLS-1$
241 // *************** Possible IDs for configurable options.
242 // ********************
245 * Possible configurable option ID.
247 * @see #getDefaultOptions()
249 public static final String COMPILER_LOCAL_VARIABLE_ATTR = PLUGIN_ID
250 + ".compiler.debug.localVariable"; //$NON-NLS-1$
253 * Possible configurable option ID.
255 * @see #getDefaultOptions()
257 public static final String COMPILER_LINE_NUMBER_ATTR = PLUGIN_ID
258 + ".compiler.debug.lineNumber"; //$NON-NLS-1$
261 * Possible configurable option ID.
263 * @see #getDefaultOptions
265 public static final String COMPILER_SOURCE_FILE_ATTR = PLUGIN_ID
266 + ".compiler.debug.sourceFile"; //$NON-NLS-1$
269 * Possible configurable option ID.
271 * @see #getDefaultOptions
273 public static final String COMPILER_CODEGEN_UNUSED_LOCAL = PLUGIN_ID
274 + ".compiler.codegen.unusedLocal"; //$NON-NLS-1$
277 * Possible configurable option ID.
279 * @see #getDefaultOptions
281 public static final String COMPILER_CODEGEN_TARGET_PLATFORM = PLUGIN_ID
282 + ".compiler.codegen.targetPlatform"; //$NON-NLS-1$
285 * Possible configurable option ID.
287 * @see #getDefaultOptions
289 public static final String COMPILER_PB_PHP_VAR_DEPRECATED = CompilerOptions.OPTION_PHPVarDeprecatedWarning; //$NON-NLS-1$
291 public static final String COMPILER_PB_PHP_KEYWORD = CompilerOptions.OPTION_PHPBadStyleKeywordWarning; //$NON-NLS-1$
293 public static final String COMPILER_PB_PHP_UPPERCASE_IDENTIFIER = CompilerOptions.OPTION_PHPBadStyleUppercaseIdentifierWarning; //$NON-NLS-1$
295 public static final String COMPILER_PB_PHP_FILE_NOT_EXIST = CompilerOptions.OPTION_PHPIncludeNotExistWarning; //$NON-NLS-1$
297 public static final String COMPILER_PB_UNINITIALIZED_LOCAL_VARIABLE = CompilerOptions.OPTION_UninitializedLocalVariableWarning; //$NON-NLS-1$
299 public static final String COMPILER_PB_UNREACHABLE_CODE = CompilerOptions.OPTION_CodeCannotBeReachedWarning; //$NON-NLS-1$
302 * Possible configurable option ID.
304 * @see #getDefaultOptions
306 // public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID
307 // + ".compiler.problem.unreachableCode"; //$NON-NLS-1$
309 * Possible configurable option ID.
311 * @see #getDefaultOptions
313 public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID
314 + ".compiler.problem.invalidImport"; //$NON-NLS-1$
317 * Possible configurable option ID.
319 * @see #getDefaultOptions
321 public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID
322 + ".compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
325 * Possible configurable option ID.
327 * @see #getDefaultOptions
329 public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID
330 + ".compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
333 * Possible configurable option ID.
335 * @see #getDefaultOptions
337 public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID
338 + ".compiler.problem.deprecation"; //$NON-NLS-1$
341 * Possible configurable option ID.
343 * @see #getDefaultOptions
346 public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID
347 + ".compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
350 * Possible configurable option ID.
352 * @see #getDefaultOptions
354 public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID
355 + ".compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
358 * Possible configurable option ID.
360 * @see #getDefaultOptions
362 public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID
363 + ".compiler.problem.unusedLocal"; //$NON-NLS-1$
366 * Possible configurable option ID.
368 * @see #getDefaultOptions
370 public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID
371 + ".compiler.problem.unusedParameter"; //$NON-NLS-1$
374 * Possible configurable option ID.
376 * @see #getDefaultOptions
379 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID
380 + ".compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
383 * Possible configurable option ID.
385 * @see #getDefaultOptions
388 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID
389 + ".compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
392 * Possible configurable option ID.
394 * @see #getDefaultOptions
397 public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID
398 + ".compiler.problem.unusedImport"; //$NON-NLS-1$
401 * Possible configurable option ID.
403 * @see #getDefaultOptions
405 public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID
406 + ".compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
409 * Possible configurable option ID.
411 * @see #getDefaultOptions
414 public static final String COMPILER_PB_NON_NLS_STRING_LITERAL = PLUGIN_ID
415 + ".compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
418 * Possible configurable option ID.
420 * @see #getDefaultOptions
423 public static final String COMPILER_PB_ASSERT_IDENTIFIER = PLUGIN_ID
424 + ".compiler.problem.assertIdentifier"; //$NON-NLS-1$
427 * Possible configurable option ID.
429 * @see #getDefaultOptions
432 public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID
433 + ".compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
436 * Possible configurable option ID.
438 * @see #getDefaultOptions
441 public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID
442 + ".compiler.problem.noEffectAssignment"; //$NON-NLS-1$
445 * Possible configurable option ID.
447 * @see #getDefaultOptions
450 public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID
451 + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
454 * Possible configurable option ID.
456 * @see #getDefaultOptions
459 public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID
460 + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
463 * Possible configurable option ID.
465 * @see #getDefaultOptions
468 public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID
469 + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
472 * Possible configurable option ID.
474 * @see #getDefaultOptions
477 public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID
478 + ".compiler.maxProblemPerUnit"; //$NON-NLS-1$
481 * Possible configurable option ID.
483 * @see #getDefaultOptions
486 public static final String COMPILER_SOURCE = PLUGIN_ID + ".compiler.source"; //$NON-NLS-1$
489 * Possible configurable option ID.
491 * @see #getDefaultOptions
494 public static final String COMPILER_COMPLIANCE = PLUGIN_ID
495 + ".compiler.compliance"; //$NON-NLS-1$
498 * Possible configurable option ID.
500 * @see #getDefaultOptions
503 public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID
504 + ".compiler.taskPriorities"; //$NON-NLS-1$
507 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
509 * @see #getDefaultOptions
512 public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$
515 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
517 * @see #getDefaultOptions
520 public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$
523 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
525 * @see #getDefaultOptions
528 public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$
531 * Possible configurable option ID.
533 * @see #getDefaultOptions
535 public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID
536 + ".computeJavaBuildOrder"; //$NON-NLS-1$
539 * Possible configurable option ID.
541 * @see #getDefaultOptions
544 public static final String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER = PLUGIN_ID
545 + ".builder.resourceCopyExclusionFilter"; //$NON-NLS-1$
548 * Possible configurable option ID.
550 * @see #getDefaultOptions
553 public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID
554 + ".builder.duplicateResourceTask"; //$NON-NLS-1$
557 * Possible configurable option ID.
559 * @see #getDefaultOptions
562 public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID
563 + ".builder.cleanOutputFolder"; //$NON-NLS-1$
566 * Possible configurable option ID.
568 * @see #getDefaultOptions
571 public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID
572 + ".incompleteClasspath"; //$NON-NLS-1$
575 * Possible configurable option ID.
577 * @see #getDefaultOptions
580 public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID
581 + ".circularClasspath"; //$NON-NLS-1$
584 * Possible configurable option ID.
586 * @see #getDefaultOptions
589 public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID
590 + ".builder.invalidClasspath"; //$NON-NLS-1$
593 * Possible configurable option ID.
595 * @see #getDefaultOptions
598 public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID
599 + ".classpath.exclusionPatterns"; //$NON-NLS-1$
602 * Possible configurable option ID.
604 * @see #getDefaultOptions
607 public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID
608 + ".classpath.multipleOutputLocations"; //$NON-NLS-1$
615 public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$
618 * Default task priority
622 public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; //$NON-NLS-1$
625 * Possible configurable option ID
627 * @see #getDefaultOptions
630 public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID
631 + ".formatter.space.castexpression"; //$NON-NLS-1$
634 * Possible configurable option ID.
636 * @see #getDefaultOptions
639 public static final String CODEASSIST_VISIBILITY_CHECK = PLUGIN_ID
640 + ".codeComplete.visibilityCheck"; //$NON-NLS-1$
643 * Possible configurable option ID.
645 * @see #getDefaultOptions
648 public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID
649 + ".codeComplete.forceImplicitQualification"; //$NON-NLS-1$
652 * Possible configurable option ID.
654 * @see #getDefaultOptions
657 public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID
658 + ".codeComplete.fieldPrefixes"; //$NON-NLS-1$
661 * Possible configurable option ID.
663 * @see #getDefaultOptions
666 public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID
667 + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
670 * Possible configurable option ID.
672 * @see #getDefaultOptions
675 public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID
676 + ".codeComplete.localPrefixes"; //$NON-NLS-1$
679 * Possible configurable option ID.
681 * @see #getDefaultOptions
684 public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID
685 + ".codeComplete.argumentPrefixes"; //$NON-NLS-1$
688 * Possible configurable option ID.
690 * @see #getDefaultOptions
693 public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID
694 + ".codeComplete.fieldSuffixes"; //$NON-NLS-1$
697 * Possible configurable option ID.
699 * @see #getDefaultOptions
702 public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID
703 + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
706 * Possible configurable option ID.
708 * @see #getDefaultOptions
711 public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID
712 + ".codeComplete.localSuffixes"; //$NON-NLS-1$
715 * Possible configurable option ID.
717 * @see #getDefaultOptions
720 public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID
721 + ".codeComplete.argumentSuffixes"; //$NON-NLS-1$
723 // *************** Possible values for configurable options.
724 // ********************
727 * Possible configurable option value.
729 * @see #getDefaultOptions
731 public static final String GENERATE = "generate"; //$NON-NLS-1$
734 * Possible configurable option value.
736 * @see #getDefaultOptions
738 public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
741 * Possible configurable option value.
743 * @see #getDefaultOptions
745 public static final String PRESERVE = "preserve"; //$NON-NLS-1$
748 * Possible configurable option value.
750 * @see #getDefaultOptions
752 public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
755 * Possible configurable option value.
757 * @see #getDefaultOptions
759 public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$
762 * Possible configurable option value.
764 * @see #getDefaultOptions
766 public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$
769 * Possible configurable option value.
771 * @see #getDefaultOptions
774 public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
777 * Possible configurable option value.
779 * @see #getDefaultOptions
782 public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
785 * Possible configurable option value.
787 * @see #getDefaultOptions
790 public static final String ABORT = "abort"; //$NON-NLS-1$
793 * Possible configurable option value.
795 * @see #getDefaultOptions
797 public static final String ERROR = "error"; //$NON-NLS-1$
800 * Possible configurable option value.
802 * @see #getDefaultOptions
804 public static final String WARNING = "warning"; //$NON-NLS-1$
807 * Possible configurable option value.
809 * @see #getDefaultOptions
811 public static final String IGNORE = "ignore"; //$NON-NLS-1$
814 * Possible configurable option value.
816 * @see #getDefaultOptions
818 public static final String COMPUTE = "compute"; //$NON-NLS-1$
821 * Possible configurable option value.
823 * @see #getDefaultOptions
828 * Returns a table of all known configurable options with their default
829 * values. These options allow to configure the behaviour of the underlying
830 * components. The client may safely use the result as a template that they
831 * can modify and then pass to <code>setOptions</code>.
833 * Helper constants have been defined on JavaCore for each of the option ID
834 * and their possible constant values.
836 * Note: more options might be added in further releases.
840 * RECOGNIZED OPTIONS:
841 * COMPILER / Generating Local Variable Debug Attribute
842 * When generated, this attribute will enable local variable names
843 * to be displayed in debugger, only in place where variables are
844 * definitely assigned (.class file is then bigger)
845 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.localVariable"
846 * - possible values: { "generate", "do not generate" }
847 * - default: "generate"
849 * COMPILER / Generating Line Number Debug Attribute
850 * When generated, this attribute will enable source code highlighting in debugger
851 * (.class file is then bigger).
852 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.lineNumber"
853 * - possible values: { "generate", "do not generate" }
854 * - default: "generate"
856 * COMPILER / Generating Source Debug Attribute
857 * When generated, this attribute will enable the debugger to present the
858 * corresponding source code.
859 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.sourceFile"
860 * - possible values: { "generate", "do not generate" }
861 * - default: "generate"
863 * COMPILER / Preserving Unused Local Variables
864 * Unless requested to preserve unused local variables (i.e. never read), the
865 * compiler will optimize them out, potentially altering debugging
866 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.unusedLocal"
867 * - possible values: { "preserve", "optimize out" }
868 * - default: "preserve"
870 * COMPILER / Defining Target Java Platform
871 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
872 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
873 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.targetPlatform"
874 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
875 * - default: "1.1"
877 * COMPILER / Reporting Unreachable Code
878 * Unreachable code can optionally be reported as an error, warning or simply
879 * ignored. The bytecode generation will always optimized it out.
880 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unreachableCode"
881 * - possible values: { "error", "warning", "ignore" }
882 * - default: "error"
884 * COMPILER / Reporting Invalid Import
885 * An import statement that cannot be resolved might optionally be reported
886 * as an error, as a warning or ignored.
887 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.invalidImport"
888 * - possible values: { "error", "warning", "ignore" }
889 * - default: "error"
891 * COMPILER / Reporting Attempt to Override Package-Default Method
892 * A package default method is not visible in a different package, and thus
893 * cannot be overridden. When enabling this option, the compiler will signal
894 * such scenarii either as an error or a warning.
895 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
896 * - possible values: { "error", "warning", "ignore" }
897 * - default: "warning"
899 * COMPILER / Reporting Method With Constructor Name
900 * Naming a method with a constructor name is generally considered poor
901 * style programming. When enabling this option, the compiler will signal such
902 * scenarii either as an error or a warning.
903 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.methodWithConstructorName"
904 * - possible values: { "error", "warning", "ignore" }
905 * - default: "warning"
907 * COMPILER / Reporting Deprecation
908 * When enabled, the compiler will signal use of deprecated API either as an
909 * error or a warning.
910 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecation"
911 * - possible values: { "error", "warning", "ignore" }
912 * - default: "warning"
914 * COMPILER / Reporting Deprecation Inside Deprecated Code
915 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
916 * The severity of the problem is controlled with option "org.phpeclipse.phpdt.core.compiler.problem.deprecation".
917 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
918 * - possible values: { "enabled", "disabled" }
919 * - default: "disabled"
921 * COMPILER / Reporting Hidden Catch Block
922 * Locally to a try statement, some catch blocks may hide others , e.g.
923 * try { throw new java.io.CharConversionException();
924 * } catch (java.io.CharConversionException e) {
925 * } catch (java.io.IOException e) {}.
926 * When enabling this option, the compiler will issue an error or a warning for hidden
927 * catch blocks corresponding to checked exceptions
928 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.hiddenCatchBlock"
929 * - possible values: { "error", "warning", "ignore" }
930 * - default: "warning"
932 * COMPILER / Reporting Unused Local
933 * When enabled, the compiler will issue an error or a warning for unused local
934 * variables (i.e. variables never read from)
935 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedLocal"
936 * - possible values: { "error", "warning", "ignore" }
937 * - default: "ignore"
939 * COMPILER / Reporting Unused Parameter
940 * When enabled, the compiler will issue an error or a warning for unused method
941 * parameters (i.e. parameters never read from)
942 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedParameter"
943 * - possible values: { "error", "warning", "ignore" }
944 * - default: "ignore"
946 * COMPILER / Reporting Unused Import
947 * When enabled, the compiler will issue an error or a warning for unused import
949 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedImport"
950 * - possible values: { "error", "warning", "ignore" }
951 * - default: "warning"
953 * COMPILER / Reporting Synthetic Access Emulation
954 * When enabled, the compiler will issue an error or a warning whenever it emulates
955 * access to a non-accessible member of an enclosing type. Such access can have
956 * performance implications.
957 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.syntheticAccessEmulation"
958 * - possible values: { "error", "warning", "ignore" }
959 * - default: "ignore"
961 * COMPILER / Reporting Non-Externalized String Literal
962 * When enabled, the compiler will issue an error or a warning for non externalized
963 * String literal (i.e. non tagged with //$NON-NLS-<n>$).
964 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
965 * - possible values: { "error", "warning", "ignore" }
966 * - default: "ignore"
968 * COMPILER / Reporting Usage of 'assert' Identifier
969 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
970 * used as an identifier (reserved keyword in 1.4)
971 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.assertIdentifier"
972 * - possible values: { "error", "warning", "ignore" }
973 * - default: "ignore"
975 * COMPILER / Reporting Usage of expression receiver on static invocation/field access
976 * When enabled, the compiler will issue an error or a warning whenever a static field
977 * or method is accessed with an expression receiver.
978 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.staticAccessReceiver"
979 * - possible values: { "error", "warning", "ignore" }
980 * - default: "warning"
982 * COMPILER / Reporting Assignment with no effect
983 * When enabled, the compiler will issue an error or a warning whenever an assignment
984 * has no effect (e.g 'x = x').
985 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.noEffectAssignment"
986 * - possible values: { "error", "warning", "ignore" }
987 * - default: "warning"
989 * COMPILER / Setting Source Compatibility Mode
990 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
991 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
992 * level should be set to "1.4" and the compliance mode should be "1.4".
993 * - option id: "org.phpeclipse.phpdt.core.compiler.source"
994 * - possible values: { "1.3", "1.4" }
995 * - default: "1.3"
997 * COMPILER / Setting Compliance Level
998 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
999 * should not go beyond "1.3" level.
1000 * - option id: "org.phpeclipse.phpdt.core.compiler.compliance"
1001 * - possible values: { "1.3", "1.4" }
1002 * - default: "1.3"
1004 * COMPILER / Maximum number of problems reported per compilation unit
1005 * Specify the maximum number of problems reported on each compilation unit.
1006 * - option id: "org.phpeclipse.phpdt.core.compiler.maxProblemPerUnit"
1007 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
1008 * - default: "100"
1010 * COMPILER / Define the Automatic Task Tags
1011 * When the tag is non empty, the compiler will issue a task marker whenever it encounters
1012 * one of the corresponding tag inside any comment in Java source code.
1013 * Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed.
1014 * - option id: "org.phpeclipse.phpdt.core.compiler.taskTags"
1015 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card
1016 * - default: ""
1017 * COMPILER / Define the Automatic Task Priorities
1018 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
1019 * of the task markers issued by the compiler.
1020 * If the default is specified, the priority of each task marker is "NORMAL".
1021 * - option id: "org.phpeclipse.phpdt.core.compiler.taskPriorities"
1022 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
1023 * - default: ""
1025 * BUILDER / Specifying Filters for Resource Copying Control
1026 * Allow to specify some filters to control the resource copy process.
1027 * - option id: "org.phpeclipse.phpdt.core.builder.resourceCopyExclusionFilter"
1028 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
1029 * or the name of a folder which ends with '/'
1030 * - default: ""
1032 * BUILDER / Abort if Invalid Classpath
1033 * Allow to toggle the builder to abort if the classpath is invalid
1034 * - option id: "org.phpeclipse.phpdt.core.builder.invalidClasspath"
1035 * - possible values: { "abort", "ignore" }
1036 * - default: "ignore"
1038 * BUILDER / Cleaning Output Folder(s)
1039 * Indicate whether the JavaBuilder is allowed to clean the output folders
1040 * when performing full build operations.
1041 * - option id: "org.phpeclipse.phpdt.core.builder.cleanOutputFolder"
1042 * - possible values: { "clean", "ignore" }
1043 * - default: "clean"
1045 * JAVACORE / Computing Project Build Order
1046 * Indicate whether JavaCore should enforce the project build order to be based on
1047 * the classpath prerequisite chain. When requesting to compute, this takes over
1048 * the platform default order (based on project references).
1049 * - option id: "org.phpeclipse.phpdt.core.computeJavaBuildOrder"
1050 * - possible values: { "compute", "ignore" }
1051 * - default: "ignore"
1053 * JAVACORE / Specify Default Source Encoding Format
1054 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
1055 * to 'ResourcesPlugin.getEncoding()'.
1056 * - option id: "org.phpeclipse.phpdt.core.encoding"
1057 * - possible values: { any of the supported encoding name}.
1058 * - default: <platform default>
1060 * JAVACORE / Reporting Incomplete Classpath
1061 * An entry on the classpath doesn't exist or is not visible (e.g. a referenced project is closed).
1062 * - option id: "org.phpeclipse.phpdt.core.incompleteClasspath"
1063 * - possible values: { "error", "warning"}
1064 * - default: "error"
1066 * JAVACORE / Reporting Classpath Cycle
1067 * A project is involved in a cycle.
1068 * - option id: "org.phpeclipse.phpdt.core.circularClasspath"
1069 * - possible values: { "error", "warning" }
1070 * - default: "error"
1072 * FORMATTER / Inserting New Line Before Opening Brace
1073 * When Insert, a new line is inserted before an opening brace, otherwise nothing
1075 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.openingBrace"
1076 * - possible values: { "insert", "do not insert" }
1077 * - default: "do not insert"
1079 * FORMATTER / Inserting New Line Inside Control Statement
1080 * When Insert, a new line is inserted between } and following else, catch, finally
1081 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.controlStatement"
1082 * - possible values: { "insert", "do not insert" }
1083 * - default: "do not insert"
1085 * FORMATTER / Clearing Blank Lines
1086 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
1087 * and all others removed.
1088 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.clearAll"
1089 * - possible values: { "clear all", "preserve one" }
1090 * - default: "preserve one"
1092 * FORMATTER / Inserting New Line Between Else/If
1093 * When Insert, a blank line is inserted between an else and an if when they are
1094 * contiguous. When choosing to not insert, else-if will be kept on the same
1095 * line when possible.
1096 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.elseIf"
1097 * - possible values: { "insert", "do not insert" }
1098 * - default: "do not insert"
1100 * FORMATTER / Inserting New Line In Empty Block
1101 * When insert, a line break is inserted between contiguous { and }, if } is not followed
1103 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.emptyBlock"
1104 * - possible values: { "insert", "do not insert" }
1105 * - default: "insert"
1107 * FORMATTER / Splitting Lines Exceeding Length
1108 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
1109 * disable line splitting
1110 * - option id: "org.phpeclipse.phpdt.core.formatter.lineSplit"
1111 * - possible values: "<n>", where n is zero or a positive integer
1112 * - default: "80"
1114 * FORMATTER / Compacting Assignment
1115 * Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space
1116 * is inserted before the assignment operator
1117 * - option id: "org.phpeclipse.phpdt.core.formatter.style.assignment"
1118 * - possible values: { "compact", "normal" }
1119 * - default: "normal"
1121 * FORMATTER / Defining Indentation Character
1122 * Either choose to indent with tab characters or spaces
1123 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.char"
1124 * - possible values: { "tab", "space" }
1125 * - default: "tab"
1127 * FORMATTER / Defining Space Indentation Length
1128 * When using spaces, set the amount of space characters to use for each
1130 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.size"
1131 * - possible values: "<n>", where n is a positive integer
1132 * - default: "4"
1134 * CODEASSIST / Activate Visibility Sensitive Completion
1135 * When active, completion doesn't show that you can not see
1136 * (e.g. you can not see private methods of a super class).
1137 * - option id: "org.phpeclipse.phpdt.core.codeComplete.visibilityCheck"
1138 * - possible values: { "enabled", "disabled" }
1139 * - default: "disabled"
1141 * CODEASSIST / Automatic Qualification of Implicit Members
1142 * When active, completion automatically qualifies completion on implicit
1143 * field references and message expressions.
1144 * - option id: "org.phpeclipse.phpdt.core.codeComplete.forceImplicitQualification"
1145 * - possible values: { "enabled", "disabled" }
1146 * - default: "disabled"
1148 * CODEASSIST / Define the Prefixes for Field Name
1149 * When the prefixes is non empty, completion for field name will begin with
1150 * one of the proposed prefixes.
1151 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldPrefixes"
1152 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1153 * - default: ""
1155 * CODEASSIST / Define the Prefixes for Static Field Name
1156 * When the prefixes is non empty, completion for static field name will begin with
1157 * one of the proposed prefixes.
1158 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldPrefixes"
1159 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1160 * - default: ""
1162 * CODEASSIST / Define the Prefixes for Local Variable Name
1163 * When the prefixes is non empty, completion for local variable name will begin with
1164 * one of the proposed prefixes.
1165 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localPrefixes"
1166 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1167 * - default: ""
1169 * CODEASSIST / Define the Prefixes for Argument Name
1170 * When the prefixes is non empty, completion for argument name will begin with
1171 * one of the proposed prefixes.
1172 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentPrefixes"
1173 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1174 * - default: ""
1176 * CODEASSIST / Define the Suffixes for Field Name
1177 * When the suffixes is non empty, completion for field name will end with
1178 * one of the proposed suffixes.
1179 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldSuffixes"
1180 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1181 * - default: ""
1183 * CODEASSIST / Define the Suffixes for Static Field Name
1184 * When the suffixes is non empty, completion for static field name will end with
1185 * one of the proposed suffixes.
1186 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldSuffixes"
1187 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1188 * - default: ""
1190 * CODEASSIST / Define the Suffixes for Local Variable Name
1191 * When the suffixes is non empty, completion for local variable name will end with
1192 * one of the proposed suffixes.
1193 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localSuffixes"
1194 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1195 * - default: ""
1197 * CODEASSIST / Define the Suffixes for Argument Name
1198 * When the suffixes is non empty, completion for argument name will end with
1199 * one of the proposed suffixes.
1200 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentSuffixes"
1201 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
1202 * - default: ""
1205 * @return a mutable table containing the default settings of all known options
1218 // public static Hashtable getDefaultOptions() {
1220 // Hashtable defaultOptions = new Hashtable(10);
1222 // // see #initializeDefaultPluginPreferences() for changing default
1224 // Preferences preferences = getPlugin().getPluginPreferences();
1225 // HashSet optionNames = OptionNames;
1227 // // get preferences set to their default
1228 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1229 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1230 // String propertyName = defaultPropertyNames[i];
1231 // if (optionNames.contains(propertyName)) {
1232 // defaultOptions.put(propertyName,
1233 // preferences.getDefaultString(propertyName));
1236 // // get preferences not set to their default
1237 // String[] propertyNames = preferences.propertyNames();
1238 // for (int i = 0; i < propertyNames.length; i++) {
1239 // String propertyName = propertyNames[i];
1240 // if (optionNames.contains(propertyName)) {
1241 // defaultOptions.put(propertyName,
1242 // preferences.getDefaultString(propertyName));
1245 // // get encoding through resource plugin
1246 // defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1248 // return defaultOptions;
1251 * Helper method for returning one option value only. Equivalent to
1252 * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
1253 * may answer <code>null</code> if this option does not exist.
1255 * For a complete description of the configurable options, see
1256 * <code>getDefaultOptions</code>.
1260 * the name of an option
1261 * @return the String value of a given option
1262 * @see JavaCore#getDefaultOptions
1265 // public static String getOption(String optionName) {
1267 // if (CORE_ENCODING.equals(optionName)) {
1268 // return ResourcesPlugin.getEncoding();
1270 // if (OptionNames.contains(optionName)) {
1271 // Preferences preferences = getPlugin().getPluginPreferences();
1272 // return preferences.getString(optionName).trim();
1277 * Returns the table of the current options. Initially, all options have
1278 * their default values, and this method returns a table that includes all
1281 * For a complete description of the configurable options, see
1282 * <code>getDefaultOptions</code>.
1285 * @return table of current settings of all options (key type:
1286 * <code>String</code>; value type: <code>String</code>)
1287 * @see JavaCore#getDefaultOptions
1289 // public static Hashtable getOptions() {
1291 // Hashtable options = new Hashtable(10);
1293 // // see #initializeDefaultPluginPreferences() for changing default
1295 // Plugin plugin = getPlugin();
1296 // if (plugin != null) {
1297 // Preferences preferences = getPlugin().getPluginPreferences();
1298 // HashSet optionNames = OptionNames;
1300 // // get preferences set to their default
1301 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1302 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1303 // String propertyName = defaultPropertyNames[i];
1304 // if (optionNames.contains(propertyName)) {
1305 // options.put(propertyName, preferences.getDefaultString(propertyName));
1308 // // get preferences not set to their default
1309 // String[] propertyNames = preferences.propertyNames();
1310 // for (int i = 0; i < propertyNames.length; i++) {
1311 // String propertyName = propertyNames[i];
1312 // if (optionNames.contains(propertyName)) {
1313 // options.put(propertyName, preferences.getString(propertyName).trim());
1316 // // get encoding through resource plugin
1317 // options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1322 * Sets the current table of options. All and only the options explicitly
1323 * included in the given table are remembered; all previous option settings
1324 * are forgotten, including ones not explicitly mentioned.
1326 * For a complete description of the configurable options, see
1327 * <code>getDefaultOptions</code>.
1331 * the new options (key type: <code>String</code>; value type:
1332 * <code>String</code>), or <code>null</code> to reset all
1333 * options to their default values
1334 * @see JavaCore#getDefaultOptions
1336 // public static void setOptions(Hashtable newOptions) {
1338 // // see #initializeDefaultPluginPreferences() for changing default
1340 // Preferences preferences = getPlugin().getPluginPreferences();
1342 // if (newOptions == null) {
1343 // newOptions = getDefaultOptions();
1345 // Enumeration keys = newOptions.keys();
1346 // while (keys.hasMoreElements()) {
1347 // String key = (String) keys.nextElement();
1348 // if (!OptionNames.contains(key))
1349 // continue; // unrecognized option
1350 // if (key.equals(CORE_ENCODING))
1351 // continue; // skipped, contributed by resource prefs
1352 // String value = (String) newOptions.get(key);
1353 // preferences.setValue(key, value);
1356 // // persist options
1357 // getPlugin().savePluginPreferences();
1359 public static IProject[] getPHPProjects() {
1360 List phpProjectsList = new ArrayList();
1361 IProject[] workspaceProjects = PHPeclipsePlugin.getWorkspace()
1362 .getRoot().getProjects();
1364 for (int i = 0; i < workspaceProjects.length; i++) {
1365 IProject iProject = workspaceProjects[i];
1366 if (isPHPProject(iProject))
1367 phpProjectsList.add(iProject);
1370 IProject[] phpProjects = new IProject[phpProjectsList.size()];
1371 return (IProject[]) phpProjectsList.toArray(phpProjects);
1374 // public static PHPProject getPHPProject(String name) {
1375 // IProject aProject =
1376 // PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
1377 // if (isPHPProject(aProject)) {
1378 // PHPProject thePHPProject = new PHPProject();
1379 // thePHPProject.setProject(aProject);
1380 // return thePHPProject;
1385 public static boolean isPHPProject(IProject aProject) {
1387 return aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID);
1388 } catch (CoreException e) {
1394 // public static PHPFile create(IFile aFile) {
1395 // if (PHPFile.EXTENSION.equalsIgnoreCase(aFile.getFileExtension()))
1396 // return new PHPFile(aFile);
1397 // if (PHPFile.EXTENSION1.equalsIgnoreCase(aFile.getFileExtension()))
1398 // return new PHPFile(aFile);
1399 // if (PHPFile.EXTENSION2.equalsIgnoreCase(aFile.getFileExtension()))
1400 // return new PHPFile(aFile);
1401 // if (PHPFile.EXTENSION3.equalsIgnoreCase(aFile.getFileExtension()))
1402 // return new PHPFile(aFile);
1403 // if (PHPFile.EXTENSION4.equalsIgnoreCase(aFile.getFileExtension()))
1404 // return new PHPFile(aFile);
1405 // if (PHPFile.EXTENSION5.equalsIgnoreCase(aFile.getFileExtension()))
1406 // return new PHPFile(aFile);
1411 // public static PHPProject create(IProject aProject) {
1414 // if (aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1415 // PHPProject project = new PHPProject();
1416 // project.setProject(aProject);
1419 // } catch (CoreException e) {
1420 // System.err.println("Exception occurred in PHPCore#create(IProject): " +
1427 public static void addPHPNature(IProject project, IProgressMonitor monitor)
1428 throws CoreException {
1429 if (!project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1430 IProjectDescription description = project.getDescription();
1431 String[] prevNatures = description.getNatureIds();
1432 String[] newNatures = new String[prevNatures.length + 1];
1433 System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
1434 newNatures[prevNatures.length] = PHPeclipsePlugin.PHP_NATURE_ID;
1435 description.setNatureIds(newNatures);
1436 project.setDescription(description, monitor);
1441 * Returns the single instance of the PHP core plug-in runtime class.
1443 * @return the single instance of the PHP core plug-in runtime class
1445 public static Plugin getPlugin() {
1446 return PHPeclipsePlugin.getDefault();
1450 * Runs the given action as an atomic Java model operation.
1452 * After running a method that modifies java elements, registered listeners
1453 * receive after-the-fact notification of what just transpired, in the form
1454 * of a element changed event. This method allows clients to call a number
1455 * of methods that modify java elements and only have element changed event
1456 * notifications reported at the end of the entire batch.
1459 * If this method is called outside the dynamic scope of another such call,
1460 * this method runs the action and then reports a single element changed
1461 * event describing the net effect of all changes done to java elements by
1465 * If this method is called in the dynamic scope of another such call, this
1466 * method simply runs the action.
1470 * the action to perform
1472 * a progress monitor, or <code>null</code> if progress
1473 * reporting and cancellation are not desired
1474 * @exception CoreException
1475 * if the operation failed.
1478 // public static void run(IWorkspaceRunnable action, IProgressMonitor
1479 // monitor) throws CoreException {
1480 // run(action, ResourcesPlugin.getWorkspace().getRoot(), monitor);
1483 * Runs the given action as an atomic Java model operation.
1485 * After running a method that modifies java elements, registered listeners
1486 * receive after-the-fact notification of what just transpired, in the form
1487 * of a element changed event. This method allows clients to call a number
1488 * of methods that modify java elements and only have element changed event
1489 * notifications reported at the end of the entire batch.
1492 * If this method is called outside the dynamic scope of another such call,
1493 * this method runs the action and then reports a single element changed
1494 * event describing the net effect of all changes done to java elements by
1498 * If this method is called in the dynamic scope of another such call, this
1499 * method simply runs the action.
1502 * The supplied scheduling rule is used to determine whether this operation
1503 * can be run simultaneously with workspace changes in other threads. See
1504 * <code>IWorkspace.run(...)</code> for more details.
1508 * the action to perform
1510 * the scheduling rule to use when running this operation, or
1511 * <code>null</code> if there are no scheduling restrictions
1512 * for this operation.
1514 * a progress monitor, or <code>null</code> if progress
1515 * reporting and cancellation are not desired
1516 * @exception CoreException
1517 * if the operation failed.
1520 // public static void run(IWorkspaceRunnable action, ISchedulingRule rule,
1521 // IProgressMonitor monitor) throws CoreException {
1522 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
1523 // if (workspace.isTreeLocked()) {
1524 // new BatchOperation(action).run(monitor);
1526 // // use IWorkspace.run(...) to ensure that a build will be done in
1528 // workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE,
1533 * Adds the given listener for changes to Java elements. Has no effect if an
1534 * identical listener is already registered.
1536 * This listener will only be notified during the POST_CHANGE resource
1537 * change notification and any reconcile operation (POST_RECONCILE). For
1538 * finer control of the notification, use
1539 * <code>addElementChangedListener(IElementChangedListener,int)</code>,
1540 * which allows to specify a different eventMask.
1542 * @see ElementChangedEvent
1546 public static void addElementChangedListener(
1547 IElementChangedListener listener) {
1548 addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE
1549 | ElementChangedEvent.POST_RECONCILE);
1553 * Adds the given listener for changes to Java elements. Has no effect if an
1554 * identical listener is already registered. After completion of this
1555 * method, the given listener will be registered for exactly the specified
1556 * events. If they were previously registered for other events, they will be
1559 * Once registered, a listener starts receiving notification of changes to
1560 * java elements in the model. The listener continues to receive
1561 * notifications until it is replaced or removed.
1564 * Listeners can listen for several types of event as defined in
1565 * <code>ElementChangeEvent</code>. Clients are free to register for any
1566 * number of event types however if they register for more than one, it is
1567 * their responsibility to ensure they correctly handle the case where the
1568 * same java element change shows up in multiple notifications. Clients are
1569 * guaranteed to receive only the events for which they are registered.
1575 * the bit-wise OR of all event types of interest to the listener
1576 * @see IElementChangedListener
1577 * @see ElementChangedEvent
1578 * @see #removeElementChangedListener(IElementChangedListener)
1581 public static void addElementChangedListener(
1582 IElementChangedListener listener, int eventMask) {
1583 JavaModelManager.getJavaModelManager().addElementChangedListener(
1584 listener, eventMask);
1588 * Configures the given marker attribute map for the given Java element.
1589 * Used for markers, which denote a Java element rather than a resource.
1592 * the mutable marker attribute map (key type:
1593 * <code>String</code>, value type: <code>String</code>)
1595 * the Java element for which the marker needs to be configured
1597 public static void addJavaElementMarkerAttributes(Map attributes,
1598 IJavaElement element) {
1599 // if (element instanceof IMember)
1600 // element = ((IMember) element).getClassFile();
1601 if (attributes != null && element != null)
1602 attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier());
1606 * Adds the given listener for POST_CHANGE resource change events to the
1607 * Java core. The listener is guarantied to be notified of the POST_CHANGE
1608 * resource change event before the Java core starts processing the resource
1609 * change event itself.
1611 * Has no effect if an identical listener is already registered.
1616 * @see #removePreProcessingResourceChangedListener(IResourceChangeListener)
1619 public static void addPreProcessingResourceChangedListener(
1620 IResourceChangeListener listener) {
1621 JavaModelManager.getJavaModelManager().deltaState
1622 .addPreResourceChangedListener(listener);
1626 * Configures the given marker for the given Java element. Used for markers,
1627 * which denote a Java element rather than a resource.
1630 * the marker to be configured
1632 * the Java element for which the marker needs to be configured
1633 * @exception CoreException
1634 * if the <code>IMarker.setAttribute</code> on the marker
1637 public void configureJavaElementMarker(IMarker marker, IJavaElement element)
1638 throws CoreException {
1639 // if (element instanceof IMember)
1640 // element = ((IMember) element).getClassFile();
1641 if (marker != null && element != null)
1642 marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier());
1646 * Returns the Java model element corresponding to the given handle
1647 * identifier generated by <code>IJavaElement.getHandleIdentifier()</code>,
1648 * or <code>null</code> if unable to create the associated element.
1650 public static IJavaElement create(String handleIdentifier) {
1651 if (handleIdentifier == null) {
1655 return JavaModelManager.getJavaModelManager().getHandleFromMemento(
1657 } catch (JavaModelException e) {
1663 * Returns the Java model element corresponding to the given handle
1664 * identifier generated by <code>IJavaElement.getHandleIdentifier()</code>,
1665 * or <code>null</code> if unable to create the associated element. If the
1666 * returned Java element is an <code>ICompilationUnit</code>, its owner
1667 * is the given owner if such a working copy exists, otherwise the
1668 * compilation unit is a primary compilation unit.
1670 * @param handleIdentifier
1671 * the given handle identifier
1673 * the owner of the returned compilation unit, ignored if the
1674 * returned element is not a compilation unit
1675 * @return the Java element corresponding to the handle identifier
1678 public static IJavaElement create(String handleIdentifier,
1679 WorkingCopyOwner owner) {
1680 if (handleIdentifier == null) {
1683 MementoTokenizer memento = new MementoTokenizer(handleIdentifier);
1684 JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel();
1685 return model.getHandleFromMemento(memento, owner);
1689 * Returns the Java element corresponding to the given file, or
1690 * <code>null</code> if unable to associate the given file with a Java
1694 * The file must be one of:
1696 * <li>a <code>.java</code> file - the element returned is the
1697 * corresponding <code>ICompilationUnit</code></li>
1698 * <li>a <code>.class</code> file - the element returned is the
1699 * corresponding <code>IClassFile</code></li>
1700 * <li>a <code>.jar</code> file - the element returned is the
1701 * corresponding <code>IPackageFragmentRoot</code></li>
1704 * Creating a Java element has the side effect of creating and opening all
1705 * of the element's parents if they are not yet open.
1709 * @return the Java element corresponding to the given file, or
1710 * <code>null</code> if unable to associate the given file with a
1713 public static IJavaElement create(IFile file) {
1714 return JavaModelManager.create(file, null);
1718 * Returns the package fragment or package fragment root corresponding to
1719 * the given folder, or <code>null</code> if unable to associate the given
1720 * folder with a Java element.
1722 * Note that a package fragment root is returned rather than a default
1725 * Creating a Java element has the side effect of creating and opening all
1726 * of the element's parents if they are not yet open.
1730 * @return the package fragment or package fragment root corresponding to
1731 * the given folder, or <code>null</code> if unable to associate
1732 * the given folder with a Java element
1734 public static IJavaElement create(IFolder folder) {
1735 return JavaModelManager.create(folder, null);
1739 * Returns the Java project corresponding to the given project.
1741 * Creating a Java Project has the side effect of creating and opening all
1742 * of the project's parents if they are not yet open.
1744 * Note that no check is done at this time on the existence or the java
1745 * nature of this project.
1749 * @return the Java project corresponding to the given project, null if the
1750 * given project is null
1752 public static IJavaProject create(IProject project) {
1753 if (project == null) {
1756 JavaModel javaModel = JavaModelManager.getJavaModelManager()
1758 return javaModel.getJavaProject(project);
1762 * Returns the Java element corresponding to the given resource, or
1763 * <code>null</code> if unable to associate the given resource with a Java
1766 * The resource must be one of:
1768 * <li>a project - the element returned is the corresponding
1769 * <code>IJavaProject</code></li>
1770 * <li>a <code>.java</code> file - the element returned is the
1771 * corresponding <code>ICompilationUnit</code></li>
1772 * <li>a <code>.class</code> file - the element returned is the
1773 * corresponding <code>IClassFile</code></li>
1774 * <li>a <code>.jar</code> file - the element returned is the
1775 * corresponding <code>IPackageFragmentRoot</code></li>
1776 * <li>a folder - the element returned is the corresponding
1777 * <code>IPackageFragmentRoot</code> or <code>IPackageFragment</code>
1779 * <li>the workspace root resource - the element returned is the
1780 * <code>IJavaModel</code></li>
1783 * Creating a Java element has the side effect of creating and opening all
1784 * of the element's parents if they are not yet open.
1787 * the given resource
1788 * @return the Java element corresponding to the given resource, or
1789 * <code>null</code> if unable to associate the given resource
1790 * with a Java element
1792 public static IJavaElement create(IResource resource) {
1793 return JavaModelManager.create(resource, null);
1797 * Returns the Java model.
1801 * @return the Java model, or <code>null</code> if the root is null
1803 public static IJavaModel create(IWorkspaceRoot root) {
1807 return JavaModelManager.getJavaModelManager().getJavaModel();
1811 * Creates and returns a class file element for the given
1812 * <code>.class</code> file. Returns <code>null</code> if unable to
1813 * recognize the class file.
1816 * the given <code>.class</code> file
1817 * @return a class file element for the given <code>.class</code> file, or
1818 * <code>null</code> if unable to recognize the class file
1820 // public static IClassFile createClassFileFrom(IFile file) {
1821 // return JavaModelManager.createClassFileFrom(file, null);
1824 * Creates and returns a compilation unit element for the given
1825 * <code>.java</code> file. Returns <code>null</code> if unable to
1826 * recognize the compilation unit.
1829 * the given <code>.java</code> file
1830 * @return a compilation unit element for the given <code>.java</code>
1831 * file, or <code>null</code> if unable to recognize the
1834 public static ICompilationUnit createCompilationUnitFrom(IFile file) {
1835 return JavaModelManager.createCompilationUnitFrom(file, null);
1839 * Creates and returns a handle for the given JAR file. The Java model
1840 * associated with the JAR's project may be created as a side effect.
1843 * the given JAR file
1844 * @return a handle for the given JAR file, or <code>null</code> if unable
1845 * to create a JAR package fragment root. (for example, if the JAR
1846 * file represents a non-Java resource)
1848 // public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile
1850 // return JavaModelManager.createJarPackageFragmentRootFrom(file, null);
1853 * Answers the project specific value for a given classpath container. In
1854 * case this container path could not be resolved, then will answer
1855 * <code>null</code>. Both the container path and the project context are
1856 * supposed to be non-null.
1858 * The containerPath is a formed by a first ID segment followed with extra
1859 * segments, which can be used as additional hints for resolution. If no
1860 * container was ever recorded for this container path onto this project
1861 * (using <code>setClasspathContainer</code>, then a
1862 * <code>ClasspathContainerInitializer</code> will be activated if any was
1863 * registered for this container ID onto the extension point
1864 * "net.sourceforge.phpdt.core.classpathContainerInitializer".
1866 * There is no assumption that the returned container must answer the exact
1867 * same containerPath when requested
1868 * <code>IClasspathContainer#getPath</code>. Indeed, the containerPath is
1869 * just an indication for resolving it to an actual container object.
1871 * Classpath container values are persisted locally to the workspace, but
1872 * are not preserved from a session to another. It is thus highly
1873 * recommended to register a <code>ClasspathContainerInitializer</code>
1874 * for each referenced container (through the extension point
1875 * "net.sourceforge.phpdt.core.ClasspathContainerInitializer").
1878 * @param containerPath
1879 * the name of the container, which needs to be resolved
1881 * a specific project in which the container is being resolved
1882 * @return the corresponding classpath container or <code>null</code> if
1883 * unable to find one.
1885 * @exception JavaModelException
1886 * if an exception occurred while resolving the container, or
1887 * if the resolved container contains illegal entries
1888 * (contains CPE_CONTAINER entries or null entries).
1890 * @see ClasspathContainerInitializer
1891 * @see IClasspathContainer
1892 * @see #setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[],
1896 // public static IClasspathContainer getClasspathContainer(final IPath
1897 // containerPath, final IJavaProject project) throws JavaModelException {
1899 // IClasspathContainer container = JavaModelManager.containerGet(project,
1901 // if (container == JavaModelManager.ContainerInitializationInProgress)
1902 // return null; // break cycle
1904 // if (container == null){
1905 // final ClasspathContainerInitializer initializer =
1906 // JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
1907 // if (initializer != null){
1908 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1909 // System.out.println("CPContainer INIT - triggering initialization of:
1910 // ["+project.getElementName()+"] " + containerPath + " using initializer:
1911 // "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
1912 // new Exception("FAKE exception for dumping current CPContainer
1913 // (["+project.getElementName()+"] "+ containerPath+ ")INIT invocation stack
1914 // trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
1916 // JavaModelManager.containerPut(project, containerPath,
1917 // JavaModelManager.ContainerInitializationInProgress); // avoid
1918 // initialization cycles
1919 // boolean ok = false;
1921 // // wrap initializer call with Safe runnable in case initializer would be
1922 // causing some grief
1923 // Platform.run(new ISafeRunnable() {
1924 // public void handleException(Throwable exception) {
1925 // ProjectPrefUtil.log(exception, "Exception occurred in classpath container
1926 // initializer: "+initializer); //$NON-NLS-1$
1928 // public void run() throws Exception {
1929 // initializer.initialize(containerPath, project);
1933 // // retrieve value (if initialization was successful)
1934 // container = JavaModelManager.containerGet(project, containerPath);
1935 // if (container == JavaModelManager.ContainerInitializationInProgress)
1936 // return null; // break cycle
1939 // if (!ok) JavaModelManager.containerPut(project, containerPath, null); //
1942 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1943 // System.out.print("CPContainer INIT - after resolution:
1944 // ["+project.getElementName()+"] " + containerPath + " --> ");
1945 // //$NON-NLS-2$//$NON-NLS-1$//$NON-NLS-3$
1946 // if (container != null){
1947 // System.out.print("container: "+container.getDescription()+" {");
1948 // //$NON-NLS-2$//$NON-NLS-1$
1949 // IClasspathEntry[] entries = container.getClasspathEntries();
1950 // if (entries != null){
1951 // for (int i = 0; i < entries.length; i++){
1952 // if (i > 0) System.out.println(", ");//$NON-NLS-1$
1953 // System.out.println(entries[i]);
1956 // System.out.println("}");//$NON-NLS-1$
1958 // System.out.println("{unbound}");//$NON-NLS-1$
1962 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1963 // System.out.println("CPContainer INIT - no initializer found for:
1964 // "+project.getElementName()+"] " + containerPath); //$NON-NLS-1$
1969 // return container;
1972 * Helper method finding the classpath container initializer registered for
1973 * a given classpath container ID or <code>null</code> if none was found
1974 * while iterating over the contributions to extension point to the
1976 * "net.sourceforge.phpdt.core.classpathContainerInitializer".
1978 * A containerID is the first segment of any container path, used to
1979 * identify the registered container initializer.
1983 * a containerID identifying a registered initializer
1984 * @return ClasspathContainerInitializer - the registered classpath
1985 * container initializer or <code>null</code> if none was found.
1988 // public static ClasspathContainerInitializer
1989 // getClasspathContainerInitializer(String containerID){
1991 // Plugin jdtCorePlugin = JavaCore.getPlugin();
1992 // if (jdtCorePlugin == null) return null;
1994 // IExtensionPoint extension =
1995 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID);
1996 // if (extension != null) {
1997 // IExtension[] extensions = extension.getExtensions();
1998 // for(int i = 0; i < extensions.length; i++){
1999 // IConfigurationElement [] configElements =
2000 // extensions[i].getConfigurationElements();
2001 // for(int j = 0; j < configElements.length; j++){
2002 // String initializerID = configElements[j].getAttribute("id");
2004 // if (initializerID != null && initializerID.equals(containerID)){
2005 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
2006 // System.out.println("CPContainer INIT - found initializer: "+containerID
2008 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
2011 // Object execExt = configElements[j].createExecutableExtension("class");
2013 // if (execExt instanceof ClasspathContainerInitializer){
2014 // return (ClasspathContainerInitializer)execExt;
2016 // } catch(CoreException e) {
2025 * Returns the path held in the given classpath variable. Returns <node>null
2026 * </code> if unable to bind.
2028 * Classpath variable values are persisted locally to the workspace, and are
2029 * preserved from session to session.
2031 * Note that classpath variables can be contributed registered initializers
2032 * for, using the extension point
2033 * "net.sourceforge.phpdt.core.classpathVariableInitializer". If an
2034 * initializer is registered for a variable, its persisted value will be
2035 * ignored: its initializer will thus get the opportunity to rebind the
2036 * variable differently on each session.
2038 * @param variableName
2039 * the name of the classpath variable
2040 * @return the path, or <code>null</code> if none
2041 * @see #setClasspathVariable
2043 public static IPath getClasspathVariable(final String variableName) {
2045 IPath variablePath = JavaModelManager.variableGet(variableName);
2046 if (variablePath == JavaModelManager.VariableInitializationInProgress)
2047 return null; // break cycle
2049 if (variablePath != null) {
2050 return variablePath;
2053 // even if persisted value exists, initializer is given priority, only
2054 // if no initializer is found the persisted value is reused
2055 // final ClasspathVariableInitializer initializer =
2056 // PHPCore.getClasspathVariableInitializer(variableName);
2057 // if (initializer != null){
2058 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2059 // System.out.println("CPVariable INIT - triggering initialization of: "
2060 // + variableName+ " using initializer: "+ initializer); //$NON-NLS-1$
2062 // new Exception("FAKE exception for dumping current CPVariable
2063 // ("+variableName+ ")INIT invocation stack trace").printStackTrace();
2064 // //$NON-NLS-1$//$NON-NLS-2$
2066 // JavaModelManager.variablePut(variableName,
2067 // JavaModelManager.VariableInitializationInProgress); // avoid
2068 // initialization cycles
2069 // boolean ok = false;
2071 // // wrap initializer call with Safe runnable in case initializer would
2072 // be causing some grief
2073 // Platform.run(new ISafeRunnable() {
2074 // public void handleException(Throwable exception) {
2075 // ProjectPrefUtil.log(exception, "Exception occurred in classpath
2077 // initializer: "+initializer+" while initializing variable:
2078 // "+variableName); //$NON-NLS-1$ //$NON-NLS-2$
2080 // public void run() throws Exception {
2081 // initializer.initialize(variableName);
2084 // variablePath = (IPath) JavaModelManager.variableGet(variableName); //
2085 // initializer should have performed side-effect
2086 // if (variablePath ==
2087 // JavaModelManager.VariableInitializationInProgress) return null; //
2088 // break cycle (initializer did not init or reentering call)
2089 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2090 // System.out.println("CPVariable INIT - after initialization: " +
2091 // variableName + " --> " + variablePath); //$NON-NLS-2$//$NON-NLS-1$
2095 // if (!ok) JavaModelManager.variablePut(variableName, null); // flush
2099 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2100 // System.out.println("CPVariable INIT - no initializer found for: " +
2101 // variableName); //$NON-NLS-1$
2104 return variablePath;
2108 * Helper method finding the classpath variable initializer registered for a
2109 * given classpath variable name or <code>null</code> if none was found
2110 * while iterating over the contributions to extension point to the
2112 * "net.sourceforge.phpdt.core.classpathVariableInitializer".
2117 * @return ClasspathVariableInitializer - the registered classpath variable
2118 * initializer or <code>null</code> if none was found.
2121 public static ClasspathVariableInitializer getClasspathVariableInitializer(
2124 Plugin jdtCorePlugin = JavaCore.getPlugin();
2125 if (jdtCorePlugin == null)
2128 // IExtensionPoint extension =
2129 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID);
2130 // if (extension != null) {
2131 // IExtension[] extensions = extension.getExtensions();
2132 // for(int i = 0; i < extensions.length; i++){
2133 // IConfigurationElement [] configElements =
2134 // extensions[i].getConfigurationElements();
2135 // for(int j = 0; j < configElements.length; j++){
2137 // String varAttribute = configElements[j].getAttribute("variable");
2139 // if (variable.equals(varAttribute)) {
2140 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
2141 // System.out.println("CPVariable INIT - found initializer: "+variable+"
2143 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
2146 // configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
2147 // if (execExt instanceof ClasspathVariableInitializer){
2148 // return (ClasspathVariableInitializer)execExt;
2151 // } catch(CoreException e){
2160 * Returns the names of all known classpath variables.
2162 * Classpath variable values are persisted locally to the workspace, and are
2163 * preserved from session to session.
2166 * @return the list of classpath variable names
2167 * @see #setClasspathVariable
2169 // public static String[] getClasspathVariableNames() {
2170 // return JavaModelManager.variableNames();
2173 * Returns a table of all known configurable options with their default
2174 * values. These options allow to configure the behaviour of the underlying
2175 * components. The client may safely use the result as a template that they
2176 * can modify and then pass to <code>setOptions</code>.
2178 * Helper constants have been defined on JavaCore for each of the option ID
2179 * and their possible constant values.
2181 * Note: more options might be added in further releases.
2185 * RECOGNIZED OPTIONS:
2186 * COMPILER / Generating Local Variable Debug Attribute
2187 * When generated, this attribute will enable local variable names
2188 * to be displayed in debugger, only in place where variables are
2189 * definitely assigned (.class file is then bigger)
2190 * - option id: "net.sourceforge.phpdt.core.compiler.debug.localVariable"
2191 * - possible values: { "generate", "do not generate" }
2192 * - default: "generate"
2194 * COMPILER / Generating Line Number Debug Attribute
2195 * When generated, this attribute will enable source code highlighting in debugger
2196 * (.class file is then bigger).
2197 * - option id: "net.sourceforge.phpdt.core.compiler.debug.lineNumber"
2198 * - possible values: { "generate", "do not generate" }
2199 * - default: "generate"
2201 * COMPILER / Generating Source Debug Attribute
2202 * When generated, this attribute will enable the debugger to present the
2203 * corresponding source code.
2204 * - option id: "net.sourceforge.phpdt.core.compiler.debug.sourceFile"
2205 * - possible values: { "generate", "do not generate" }
2206 * - default: "generate"
2208 * COMPILER / Preserving Unused Local Variables
2209 * Unless requested to preserve unused local variables (that is, never read), the
2210 * compiler will optimize them out, potentially altering debugging
2211 * - option id: "net.sourceforge.phpdt.core.compiler.codegen.unusedLocal"
2212 * - possible values: { "preserve", "optimize out" }
2213 * - default: "preserve"
2215 * COMPILER / Defining Target Java Platform
2216 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
2217 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
2218 * - option id: "net.sourceforge.phpdt.core.compiler.codegen.targetPlatform"
2219 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
2220 * - default: "1.1"
2222 * COMPILER / Reporting Unreachable Code
2223 * Unreachable code can optionally be reported as an error, warning or simply
2224 * ignored. The bytecode generation will always optimized it out.
2225 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unreachableCode"
2226 * - possible values: { "error", "warning", "ignore" }
2227 * - default: "error"
2229 * COMPILER / Reporting Invalid Import
2230 * An import statement that cannot be resolved might optionally be reported
2231 * as an error, as a warning or ignored.
2232 * - option id: "net.sourceforge.phpdt.core.compiler.problem.invalidImport"
2233 * - possible values: { "error", "warning", "ignore" }
2234 * - default: "error"
2236 * COMPILER / Reporting Attempt to Override Package-Default Method
2237 * A package default method is not visible in a different package, and thus
2238 * cannot be overridden. When enabling this option, the compiler will signal
2239 * such scenarii either as an error or a warning.
2240 * - option id: "net.sourceforge.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
2241 * - possible values: { "error", "warning", "ignore" }
2242 * - default: "warning"
2244 * COMPILER / Reporting Method With Constructor Name
2245 * Naming a method with a constructor name is generally considered poor
2246 * style programming. When enabling this option, the compiler will signal such
2247 * scenarii either as an error or a warning.
2248 * - option id: "net.sourceforge.phpdt.core.compiler.problem.methodWithConstructorName"
2249 * - possible values: { "error", "warning", "ignore" }
2250 * - default: "warning"
2252 * COMPILER / Reporting Deprecation
2253 * When enabled, the compiler will signal use of deprecated API either as an
2254 * error or a warning.
2255 * - option id: "net.sourceforge.phpdt.core.compiler.problem.deprecation"
2256 * - possible values: { "error", "warning", "ignore" }
2257 * - default: "warning"
2259 * COMPILER / Reporting Deprecation Inside Deprecated Code
2260 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
2261 * The severity of the problem is controlled with option "net.sourceforge.phpdt.core.compiler.problem.deprecation".
2262 * - option id: "net.sourceforge.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
2263 * - possible values: { "enabled", "disabled" }
2264 * - default: "disabled"
2266 * COMPILER / Reporting Hidden Catch Block
2267 * Locally to a try statement, some catch blocks may hide others . For example,
2268 * try { throw new java.io.CharConversionException();
2269 * } catch (java.io.CharConversionException e) {
2270 * } catch (java.io.IOException e) {}.
2271 * When enabling this option, the compiler will issue an error or a warning for hidden
2272 * catch blocks corresponding to checked exceptions
2273 * - option id: "net.sourceforge.phpdt.core.compiler.problem.hiddenCatchBlock"
2274 * - possible values: { "error", "warning", "ignore" }
2275 * - default: "warning"
2277 * COMPILER / Reporting Unused Local
2278 * When enabled, the compiler will issue an error or a warning for unused local
2279 * variables (that is, variables never read from)
2280 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedLocal"
2281 * - possible values: { "error", "warning", "ignore" }
2282 * - default: "ignore"
2284 * COMPILER / Reporting Unused Parameter
2285 * When enabled, the compiler will issue an error or a warning for unused method
2286 * parameters (that is, parameters never read from)
2287 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedParameter"
2288 * - possible values: { "error", "warning", "ignore" }
2289 * - default: "ignore"
2291 * COMPILER / Reporting Unused Parameter if Implementing Abstract Method
2292 * When enabled, the compiler will signal unused parameters in abstract method implementations.
2293 * The severity of the problem is controlled with option "net.sourceforge.phpdt.core.compiler.problem.unusedParameter".
2294 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"
2295 * - possible values: { "enabled", "disabled" }
2296 * - default: "disabled"
2298 * COMPILER / Reporting Unused Parameter if Overriding Concrete Method
2299 * When enabled, the compiler will signal unused parameters in methods overriding concrete ones.
2300 * The severity of the problem is controlled with option "net.sourceforge.phpdt.core.compiler.problem.unusedParameter".
2301 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"
2302 * - possible values: { "enabled", "disabled" }
2303 * - default: "disabled"
2305 * COMPILER / Reporting Unused Import
2306 * When enabled, the compiler will issue an error or a warning for unused import
2308 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedImport"
2309 * - possible values: { "error", "warning", "ignore" }
2310 * - default: "warning"
2312 * COMPILER / Reporting Unused Private Members
2313 * When enabled, the compiler will issue an error or a warning whenever a private
2314 * method or field is declared but never used within the same unit.
2315 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedPrivateMember"
2316 * - possible values: { "error", "warning", "ignore" }
2317 * - default: "ignore"
2319 * COMPILER / Reporting Synthetic Access Emulation
2320 * When enabled, the compiler will issue an error or a warning whenever it emulates
2321 * access to a non-accessible member of an enclosing type. Such access can have
2322 * performance implications.
2323 * - option id: "net.sourceforge.phpdt.core.compiler.problem.syntheticAccessEmulation"
2324 * - possible values: { "error", "warning", "ignore" }
2325 * - default: "ignore"
2327 * COMPILER / Reporting Non-Externalized String Literal
2328 * When enabled, the compiler will issue an error or a warning for non externalized
2329 * String literal (that is, not tagged with //$NON-NLS-<n>$).
2330 * - option id: "net.sourceforge.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
2331 * - possible values: { "error", "warning", "ignore" }
2332 * - default: "ignore"
2334 * COMPILER / Reporting Usage of 'assert' Identifier
2335 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
2336 * used as an identifier (reserved keyword in 1.4)
2337 * - option id: "net.sourceforge.phpdt.core.compiler.problem.assertIdentifier"
2338 * - possible values: { "error", "warning", "ignore" }
2339 * - default: "ignore"
2341 * COMPILER / Reporting Non-Static Reference to a Static Member
2342 * When enabled, the compiler will issue an error or a warning whenever a static field
2343 * or method is accessed with an expression receiver. A reference to a static member should
2344 * be qualified with a type name.
2345 * - option id: "net.sourceforge.phpdt.core.compiler.problem.staticAccessReceiver"
2346 * - possible values: { "error", "warning", "ignore" }
2347 * - default: "warning"
2349 * COMPILER / Reporting Assignment with no Effect
2350 * When enabled, the compiler will issue an error or a warning whenever an assignment
2351 * has no effect (e.g 'x = x').
2352 * - option id: "net.sourceforge.phpdt.core.compiler.problem.noEffectAssignment"
2353 * - possible values: { "error", "warning", "ignore" }
2354 * - default: "warning"
2356 * COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods
2357 * When enabled, the compiler will issue an error or a warning whenever an interface
2358 * defines a method incompatible with a non-inherited Object method. Until this conflict
2359 * is resolved, such an interface cannot be implemented, For example,
2363 * - option id: "net.sourceforge.phpdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"
2364 * - possible values: { "error", "warning", "ignore" }
2365 * - default: "warning"
2367 * COMPILER / Reporting Usage of char[] Expressions in String Concatenations
2368 * When enabled, the compiler will issue an error or a warning whenever a char[] expression
2369 * is used in String concatenations (for example, "hello" + new char[]{'w','o','r','l','d'}).
2370 * - option id: "net.sourceforge.phpdt.core.compiler.problem.noImplicitStringConversion"
2371 * - possible values: { "error", "warning", "ignore" }
2372 * - default: "warning"
2374 * COMPILER / Setting Source Compatibility Mode
2375 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
2376 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
2377 * level should be set to "1.4" and the compliance mode should be "1.4".
2378 * - option id: "net.sourceforge.phpdt.core.compiler.source"
2379 * - possible values: { "1.3", "1.4" }
2380 * - default: "1.3"
2382 * COMPILER / Setting Compliance Level
2383 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
2384 * should not go beyond "1.3" level.
2385 * - option id: "net.sourceforge.phpdt.core.compiler.compliance"
2386 * - possible values: { "1.3", "1.4" }
2387 * - default: "1.3"
2389 * COMPILER / Maximum number of problems reported per compilation unit
2390 * Specify the maximum number of problems reported on each compilation unit.
2391 * - option id: "net.sourceforge.phpdt.core.compiler.maxProblemPerUnit"
2392 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
2393 * - default: "100"
2395 * COMPILER / Define the Automatic Task Tags
2396 * When the tag list is not empty, the compiler will issue a task marker whenever it encounters
2397 * one of the corresponding tag inside any comment in Java source code.
2398 * Generated task messages will include the tag, and range until the next line separator or comment ending.
2399 * Note that tasks messages are trimmed.
2400 * - option id: "net.sourceforge.phpdt.core.compiler.taskTags"
2401 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card or leading/trailing spaces
2402 * - default: ""
2404 * COMPILER / Define the Automatic Task Priorities
2405 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
2406 * of the task markers issued by the compiler.
2407 * If the default is specified, the priority of each task marker is "NORMAL".
2408 * - option id: "net.sourceforge.phpdt.core.compiler.taskPriorities"
2409 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
2410 * - default: ""
2412 * BUILDER / Specifying Filters for Resource Copying Control
2413 * Allow to specify some filters to control the resource copy process.
2414 * - option id: "net.sourceforge.phpdt.core.builder.resourceCopyExclusionFilter"
2415 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
2416 * or the name of a folder which ends with '/'
2417 * - default: ""
2419 * BUILDER / Abort if Invalid Classpath
2420 * Allow to toggle the builder to abort if the classpath is invalid
2421 * - option id: "net.sourceforge.phpdt.core.builder.invalidClasspath"
2422 * - possible values: { "abort", "ignore" }
2423 * - default: "abort"
2425 * BUILDER / Cleaning Output Folder(s)
2426 * Indicate whether the JavaBuilder is allowed to clean the output folders
2427 * when performing full build operations.
2428 * - option id: "net.sourceforge.phpdt.core.builder.cleanOutputFolder"
2429 * - possible values: { "clean", "ignore" }
2430 * - default: "clean"
2432 * BUILDER / Reporting Duplicate Resources
2433 * Indicate the severity of the problem reported when more than one occurrence
2434 * of a resource is to be copied into the output location.
2435 * - option id: "net.sourceforge.phpdt.core.builder.duplicateResourceTask"
2436 * - possible values: { "error", "warning" }
2437 * - default: "warning"
2439 * JAVACORE / Computing Project Build Order
2440 * Indicate whether JavaCore should enforce the project build order to be based on
2441 * the classpath prerequisite chain. When requesting to compute, this takes over
2442 * the platform default order (based on project references).
2443 * - option id: "net.sourceforge.phpdt.core.computeJavaBuildOrder"
2444 * - possible values: { "compute", "ignore" }
2445 * - default: "ignore"
2447 * JAVACORE / Specify Default Source Encoding Format
2448 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
2449 * to 'ResourcesPlugin.getEncoding()'.
2450 * - option id: "net.sourceforge.phpdt.core.encoding"
2451 * - possible values: { any of the supported encoding name}.
2452 * - default: <platform default>
2454 * JAVACORE / Reporting Incomplete Classpath
2455 * Indicate the severity of the problem reported when an entry on the classpath does not exist,
2456 * is not legite or is not visible (for example, a referenced project is closed).
2457 * - option id: "net.sourceforge.phpdt.core.incompleteClasspath"
2458 * - possible values: { "error", "warning"}
2459 * - default: "error"
2461 * JAVACORE / Reporting Classpath Cycle
2462 * Indicate the severity of the problem reported when a project is involved in a cycle.
2463 * - option id: "net.sourceforge.phpdt.core.circularClasspath"
2464 * - possible values: { "error", "warning" }
2465 * - default: "error"
2467 * JAVACORE / Enabling Usage of Classpath Exclusion Patterns
2468 * When disabled, no entry on a project classpath can be associated with
2469 * an exclusion pattern.
2470 * - option id: "net.sourceforge.phpdt.core.classpath.exclusionPatterns"
2471 * - possible values: { "enabled", "disabled" }
2472 * - default: "enabled"
2474 * JAVACORE / Enabling Usage of Classpath Multiple Output Locations
2475 * When disabled, no entry on a project classpath can be associated with
2476 * a specific output location, preventing thus usage of multiple output locations.
2477 * - option id: "net.sourceforge.phpdt.core.classpath.multipleOutputLocations"
2478 * - possible values: { "enabled", "disabled" }
2479 * - default: "enabled"
2481 * FORMATTER / Inserting New Line Before Opening Brace
2482 * When Insert, a new line is inserted before an opening brace, otherwise nothing
2484 * - option id: "net.sourceforge.phpdt.core.formatter.newline.openingBrace"
2485 * - possible values: { "insert", "do not insert" }
2486 * - default: "do not insert"
2488 * FORMATTER / Inserting New Line Inside Control Statement
2489 * When Insert, a new line is inserted between } and following else, catch, finally
2490 * - option id: "net.sourceforge.phpdt.core.formatter.newline.controlStatement"
2491 * - possible values: { "insert", "do not insert" }
2492 * - default: "do not insert"
2494 * FORMATTER / Clearing Blank Lines
2495 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
2496 * and all others removed.
2497 * - option id: "net.sourceforge.phpdt.core.formatter.newline.clearAll"
2498 * - possible values: { "clear all", "preserve one" }
2499 * - default: "preserve one"
2501 * FORMATTER / Inserting New Line Between Else/If
2502 * When Insert, a blank line is inserted between an else and an if when they are
2503 * contiguous. When choosing to not insert, else-if will be kept on the same
2504 * line when possible.
2505 * - option id: "net.sourceforge.phpdt.core.formatter.newline.elseIf"
2506 * - possible values: { "insert", "do not insert" }
2507 * - default: "do not insert"
2509 * FORMATTER / Inserting New Line In Empty Block
2510 * When insert, a line break is inserted between contiguous { and }, if } is not followed
2512 * - option id: "net.sourceforge.phpdt.core.formatter.newline.emptyBlock"
2513 * - possible values: { "insert", "do not insert" }
2514 * - default: "insert"
2516 * FORMATTER / Splitting Lines Exceeding Length
2517 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
2518 * disable line splitting
2519 * - option id: "net.sourceforge.phpdt.core.formatter.lineSplit"
2520 * - possible values: "<n>", where n is zero or a positive integer
2521 * - default: "80"
2523 * FORMATTER / Compacting Assignment
2524 * Assignments can be formatted asymmetrically, for example 'int x= 2;', when Normal, a space
2525 * is inserted before the assignment operator
2526 * - option id: "net.sourceforge.phpdt.core.formatter.style.assignment"
2527 * - possible values: { "compact", "normal" }
2528 * - default: "normal"
2530 * FORMATTER / Defining Indentation Character
2531 * Either choose to indent with tab characters or spaces
2532 * - option id: "net.sourceforge.phpdt.core.formatter.tabulation.char"
2533 * - possible values: { "tab", "space" }
2534 * - default: "tab"
2536 * FORMATTER / Defining Space Indentation Length
2537 * When using spaces, set the amount of space characters to use for each
2539 * - option id: "net.sourceforge.phpdt.core.formatter.tabulation.size"
2540 * - possible values: "<n>", where n is a positive integer
2541 * - default: "4"
2543 * FORMATTER / Inserting space in cast expression
2544 * When Insert, a space is added between the type and the expression in a cast expression.
2545 * - option id: "net.sourceforge.phpdt.core.formatter.space.castexpression"
2546 * - possible values: { "insert", "do not insert" }
2547 * - default: "insert"
2549 * CODEASSIST / Activate Visibility Sensitive Completion
2550 * When active, completion doesn't show that you can not see
2551 * (for example, you can not see private methods of a super class).
2552 * - option id: "net.sourceforge.phpdt.core.codeComplete.visibilityCheck"
2553 * - possible values: { "enabled", "disabled" }
2554 * - default: "disabled"
2556 * CODEASSIST / Automatic Qualification of Implicit Members
2557 * When active, completion automatically qualifies completion on implicit
2558 * field references and message expressions.
2559 * - option id: "net.sourceforge.phpdt.core.codeComplete.forceImplicitQualification"
2560 * - possible values: { "enabled", "disabled" }
2561 * - default: "disabled"
2563 * CODEASSIST / Define the Prefixes for Field Name
2564 * When the prefixes is non empty, completion for field name will begin with
2565 * one of the proposed prefixes.
2566 * - option id: "net.sourceforge.phpdt.core.codeComplete.fieldPrefixes"
2567 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2568 * - default: ""
2570 * CODEASSIST / Define the Prefixes for Static Field Name
2571 * When the prefixes is non empty, completion for static field name will begin with
2572 * one of the proposed prefixes.
2573 * - option id: "net.sourceforge.phpdt.core.codeComplete.staticFieldPrefixes"
2574 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2575 * - default: ""
2577 * CODEASSIST / Define the Prefixes for Local Variable Name
2578 * When the prefixes is non empty, completion for local variable name will begin with
2579 * one of the proposed prefixes.
2580 * - option id: "net.sourceforge.phpdt.core.codeComplete.localPrefixes"
2581 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2582 * - default: ""
2584 * CODEASSIST / Define the Prefixes for Argument Name
2585 * When the prefixes is non empty, completion for argument name will begin with
2586 * one of the proposed prefixes.
2587 * - option id: "net.sourceforge.phpdt.core.codeComplete.argumentPrefixes"
2588 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2589 * - default: ""
2591 * CODEASSIST / Define the Suffixes for Field Name
2592 * When the suffixes is non empty, completion for field name will end with
2593 * one of the proposed suffixes.
2594 * - option id: "net.sourceforge.phpdt.core.codeComplete.fieldSuffixes"
2595 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2596 * - default: ""
2598 * CODEASSIST / Define the Suffixes for Static Field Name
2599 * When the suffixes is non empty, completion for static field name will end with
2600 * one of the proposed suffixes.
2601 * - option id: "net.sourceforge.phpdt.core.codeComplete.staticFieldSuffixes"
2602 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2603 * - default: ""
2605 * CODEASSIST / Define the Suffixes for Local Variable Name
2606 * When the suffixes is non empty, completion for local variable name will end with
2607 * one of the proposed suffixes.
2608 * - option id: "net.sourceforge.phpdt.core.codeComplete.localSuffixes"
2609 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2610 * - default: ""
2612 * CODEASSIST / Define the Suffixes for Argument Name
2613 * When the suffixes is non empty, completion for argument name will end with
2614 * one of the proposed suffixes.
2615 * - option id: "net.sourceforge.phpdt.core.codeComplete.argumentSuffixes"
2616 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
2617 * - default: ""
2620 * @return a mutable table containing the default settings of all known options
2633 public static Hashtable getDefaultOptions() {
2635 Hashtable defaultOptions = new Hashtable(10);
2637 // see #initializeDefaultPluginPreferences() for changing default
2639 Preferences preferences = getPlugin().getPluginPreferences();
2640 HashSet optionNames = JavaModelManager.OptionNames;
2642 // get preferences set to their default
2643 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2644 for (int i = 0; i < defaultPropertyNames.length; i++) {
2645 String propertyName = defaultPropertyNames[i];
2646 if (optionNames.contains(propertyName)) {
2647 defaultOptions.put(propertyName, preferences
2648 .getDefaultString(propertyName));
2651 // get preferences not set to their default
2652 String[] propertyNames = preferences.propertyNames();
2653 for (int i = 0; i < propertyNames.length; i++) {
2654 String propertyName = propertyNames[i];
2655 if (optionNames.contains(propertyName)) {
2656 defaultOptions.put(propertyName, preferences
2657 .getDefaultString(propertyName));
2660 // get encoding through resource plugin
2661 defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2663 return defaultOptions;
2667 * Returns the single instance of the Java core plug-in runtime class.
2668 * Equivalent to <code>(JavaCore) getPlugin()</code>.
2670 * @return the single instance of the Java core plug-in runtime class
2672 public static PHPeclipsePlugin getJavaCore() {
2673 return (PHPeclipsePlugin) getPlugin();
2677 * Helper method for returning one option value only. Equivalent to
2678 * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
2679 * may answer <code>null</code> if this option does not exist.
2681 * For a complete description of the configurable options, see
2682 * <code>getDefaultOptions</code>.
2686 * the name of an option
2687 * @return the String value of a given option
2688 * @see JavaCore#getDefaultOptions
2691 public static String getOption(String optionName) {
2693 if (CORE_ENCODING.equals(optionName)) {
2694 return ResourcesPlugin.getEncoding();
2696 if (JavaModelManager.OptionNames.contains(optionName)) {
2697 Preferences preferences = getPlugin().getPluginPreferences();
2698 return preferences.getString(optionName).trim();
2704 * Returns the table of the current options. Initially, all options have
2705 * their default values, and this method returns a table that includes all
2708 * For a complete description of the configurable options, see
2709 * <code>getDefaultOptions</code>.
2712 * @return table of current settings of all options (key type:
2713 * <code>String</code>; value type: <code>String</code>)
2714 * @see JavaCore#getDefaultOptions
2716 public static Hashtable getOptions() {
2718 Hashtable options = new Hashtable(10);
2720 // see #initializeDefaultPluginPreferences() for changing default
2722 Plugin plugin = getPlugin();
2723 if (plugin != null) {
2724 Preferences preferences = getPlugin().getPluginPreferences();
2725 HashSet optionNames = JavaModelManager.OptionNames;
2727 // get preferences set to their default
2728 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2729 for (int i = 0; i < defaultPropertyNames.length; i++) {
2730 String propertyName = defaultPropertyNames[i];
2731 if (optionNames.contains(propertyName)) {
2732 options.put(propertyName, preferences
2733 .getDefaultString(propertyName));
2736 // get preferences not set to their default
2737 String[] propertyNames = preferences.propertyNames();
2738 for (int i = 0; i < propertyNames.length; i++) {
2739 String propertyName = propertyNames[i];
2740 if (optionNames.contains(propertyName)) {
2741 options.put(propertyName, preferences.getString(
2742 propertyName).trim());
2745 // get encoding through resource plugin
2746 options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2752 * This is a helper method, which returns the resolved classpath entry
2753 * denoted by a given entry (if it is a variable entry). It is obtained by
2754 * resolving the variable reference in the first segment. Returns <node>null
2755 * </code> if unable to resolve using the following algorithm:
2757 * <li>if variable segment cannot be resolved, returns <code>null</code>
2759 * <li>finds a project, JAR or binary folder in the workspace at the
2760 * resolved path location</li>
2761 * <li>if none finds an external JAR file or folder outside the workspace
2762 * at the resolved path location</li>
2763 * <li>if none returns <code>null</code></li>
2766 * Variable source attachment path and root path are also resolved and
2767 * recorded in the resulting classpath entry.
2769 * NOTE: This helper method does not handle classpath containers, for which
2770 * should rather be used <code>JavaCore#getClasspathContainer(IPath,
2771 * IJavaProject)</code>.
2775 * the given variable entry
2776 * @return the resolved library or project classpath entry, or <code>null
2777 * </code> if the given variable entry could not be resolved to a
2778 * valid classpath entry
2780 public static IClasspathEntry getResolvedClasspathEntry(
2781 IClasspathEntry entry) {
2783 if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
2786 IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
2787 IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath());
2788 if (resolvedPath == null)
2791 Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false);
2795 // inside the workspace
2796 if (target instanceof IResource) {
2797 IResource resolvedResource = (IResource) target;
2798 if (resolvedResource != null) {
2799 switch (resolvedResource.getType()) {
2801 case IResource.PROJECT:
2803 return JavaCore.newProjectEntry(resolvedPath, entry
2806 case IResource.FILE:
2808 // (ProjectPrefUtil.isArchiveFileName(resolvedResource.getName()))
2810 // // internal binary archive
2811 // return JavaCore.newLibraryEntry(
2813 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2814 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2815 // entry.isExported());
2819 case IResource.FOLDER:
2820 // internal binary folder
2821 // return JavaCore.newLibraryEntry(
2823 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2824 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2825 // entry.isExported());
2830 // outside the workspace
2831 if (target instanceof File) {
2832 File externalFile = (File) target;
2833 if (externalFile.isFile()) {
2834 String fileName = externalFile.getName().toLowerCase();
2835 // if (fileName.endsWith(".jar" //$NON-NLS-1$
2836 // ) || fileName.endsWith(".zip" //$NON-NLS-1$
2837 // )) { // external binary archive
2838 // return JavaCore.newLibraryEntry(
2840 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2841 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2842 // entry.isExported());
2844 } else { // external binary folder
2845 if (resolvedPath.isAbsolute()) {
2846 // return JavaCore.newLibraryEntry(
2848 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2849 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2850 // entry.isExported());
2858 * Resolve a variable path (helper method).
2860 * @param variablePath
2861 * the given variable path
2862 * @return the resolved variable path or <code>null</code> if none
2864 public static IPath getResolvedVariablePath(IPath variablePath) {
2866 if (variablePath == null)
2868 int count = variablePath.segmentCount();
2873 String variableName = variablePath.segment(0);
2874 IPath resolvedPath = JavaCore.getClasspathVariable(variableName);
2875 if (resolvedPath == null)
2878 // append path suffix
2880 resolvedPath = resolvedPath.append(variablePath
2881 .removeFirstSegments(1));
2883 return resolvedPath;
2887 * Answers the shared working copies currently registered for this buffer
2888 * factory. Working copies can be shared by several clients using the same
2889 * buffer factory,see <code>IWorkingCopy.getSharedWorkingCopy</code>.
2892 * the given buffer factory
2893 * @return the list of shared working copies for a given buffer factory
2897 public static IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory) {
2899 // if factory is null, default factory must be used
2900 if (factory == null)
2901 factory = BufferManager.getDefaultBufferManager()
2902 .getDefaultBufferFactory();
2903 Map sharedWorkingCopies = JavaModelManager.getJavaModelManager().sharedWorkingCopies;
2905 Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
2906 if (perFactoryWorkingCopies == null)
2907 return JavaModelManager.NoWorkingCopy;
2908 Collection copies = perFactoryWorkingCopies.values();
2909 IWorkingCopy[] result = new IWorkingCopy[copies.size()];
2910 copies.toArray(result);
2915 * Initializes the default preferences settings for this plug-in.
2917 public static void initializeDefaultPluginPreferences() {
2919 Preferences preferences = PHPeclipsePlugin.getDefault()
2920 .getPluginPreferences();
2921 HashSet optionNames = JavaModelManager.OptionNames;
2923 // Compiler settings
2924 preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
2925 optionNames.add(COMPILER_LOCAL_VARIABLE_ATTR);
2927 preferences.setDefault(COMPILER_LINE_NUMBER_ATTR, GENERATE);
2928 optionNames.add(COMPILER_LINE_NUMBER_ATTR);
2930 preferences.setDefault(COMPILER_SOURCE_FILE_ATTR, GENERATE);
2931 optionNames.add(COMPILER_SOURCE_FILE_ATTR);
2933 preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE);
2934 optionNames.add(COMPILER_CODEGEN_UNUSED_LOCAL);
2936 preferences.setDefault(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1);
2937 optionNames.add(COMPILER_CODEGEN_TARGET_PLATFORM);
2939 preferences.setDefault(COMPILER_PB_PHP_VAR_DEPRECATED, IGNORE);
2940 optionNames.add(COMPILER_PB_PHP_VAR_DEPRECATED);
2941 preferences.setDefault(COMPILER_PB_PHP_KEYWORD, WARNING);
2942 optionNames.add(COMPILER_PB_PHP_KEYWORD);
2943 preferences.setDefault(COMPILER_PB_PHP_UPPERCASE_IDENTIFIER, IGNORE);
2944 optionNames.add(COMPILER_PB_PHP_UPPERCASE_IDENTIFIER);
2945 preferences.setDefault(COMPILER_PB_PHP_FILE_NOT_EXIST, WARNING);
2946 optionNames.add(COMPILER_PB_PHP_FILE_NOT_EXIST);
2947 preferences.setDefault(COMPILER_PB_UNREACHABLE_CODE, WARNING);
2948 optionNames.add(COMPILER_PB_UNREACHABLE_CODE);
2949 preferences.setDefault(COMPILER_PB_UNINITIALIZED_LOCAL_VARIABLE,
2951 optionNames.add(COMPILER_PB_UNINITIALIZED_LOCAL_VARIABLE);
2953 preferences.setDefault(COMPILER_PB_INVALID_IMPORT, ERROR);
2954 optionNames.add(COMPILER_PB_INVALID_IMPORT);
2956 preferences.setDefault(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD,
2958 optionNames.add(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD);
2960 preferences.setDefault(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME,
2962 optionNames.add(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME);
2964 preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING);
2965 optionNames.add(COMPILER_PB_DEPRECATION);
2967 preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE,
2969 optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE);
2971 preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING);
2972 optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK);
2974 preferences.setDefault(COMPILER_PB_UNUSED_LOCAL, IGNORE);
2975 optionNames.add(COMPILER_PB_UNUSED_LOCAL);
2977 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE);
2978 optionNames.add(COMPILER_PB_UNUSED_PARAMETER);
2980 preferences.setDefault(
2981 COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT,
2984 .add(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT);
2988 COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE,
2990 optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE);
2992 preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING);
2993 optionNames.add(COMPILER_PB_UNUSED_IMPORT);
2995 preferences.setDefault(COMPILER_PB_UNUSED_PRIVATE_MEMBER, IGNORE);
2996 optionNames.add(COMPILER_PB_UNUSED_PRIVATE_MEMBER);
2998 preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE);
2999 optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION);
3001 preferences.setDefault(COMPILER_PB_NON_NLS_STRING_LITERAL, IGNORE);
3002 optionNames.add(COMPILER_PB_NON_NLS_STRING_LITERAL);
3004 preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE);
3005 optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER);
3007 preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING);
3008 optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER);
3010 preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING);
3011 optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT);
3013 preferences.setDefault(
3014 COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD,
3017 .add(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD);
3019 preferences.setDefault(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION,
3021 optionNames.add(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION);
3023 preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAG); //$NON-NLS-1$
3024 optionNames.add(COMPILER_TASK_TAGS);
3026 preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITY); //$NON-NLS-1$
3027 optionNames.add(COMPILER_TASK_PRIORITIES);
3029 preferences.setDefault(COMPILER_SOURCE, VERSION_1_3);
3030 optionNames.add(COMPILER_SOURCE);
3032 preferences.setDefault(COMPILER_COMPLIANCE, VERSION_1_3);
3033 optionNames.add(COMPILER_COMPLIANCE);
3035 preferences.setDefault(COMPILER_PB_MAX_PER_UNIT, "100"); //$NON-NLS-1$
3036 optionNames.add(COMPILER_PB_MAX_PER_UNIT);
3039 preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
3040 optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
3042 preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT);
3043 optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH);
3045 preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING);
3046 optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE);
3048 preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN);
3049 optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER);
3051 // JavaCore settings
3052 preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE);
3053 optionNames.add(CORE_JAVA_BUILD_ORDER);
3055 preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR);
3056 optionNames.add(CORE_CIRCULAR_CLASSPATH);
3058 preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR);
3059 optionNames.add(CORE_INCOMPLETE_CLASSPATH);
3061 preferences.setDefault(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS,
3063 optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS);
3065 preferences.setDefault(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS,
3067 optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS);
3069 // encoding setting comes from resource plug-in
3070 optionNames.add(CORE_ENCODING);
3072 // Formatter settings
3073 preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT);
3074 optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE);
3076 preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT);
3077 optionNames.add(FORMATTER_NEWLINE_CONTROL);
3079 preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE);
3080 optionNames.add(FORMATTER_CLEAR_BLANK_LINES);
3082 preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT);
3083 optionNames.add(FORMATTER_NEWLINE_ELSE_IF);
3085 preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT);
3086 optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK);
3088 preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$
3089 optionNames.add(FORMATTER_LINE_SPLIT);
3091 preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL);
3092 optionNames.add(FORMATTER_COMPACT_ASSIGNMENT);
3094 preferences.setDefault(FORMATTER_TAB_CHAR, TAB);
3095 optionNames.add(FORMATTER_TAB_CHAR);
3097 preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$
3098 optionNames.add(FORMATTER_TAB_SIZE);
3100 preferences.setDefault(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$
3101 optionNames.add(FORMATTER_SPACE_CASTEXPRESSION);
3103 // CodeAssist settings
3104 preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$
3105 optionNames.add(CODEASSIST_VISIBILITY_CHECK);
3107 preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$
3108 optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION);
3110 preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
3111 optionNames.add(CODEASSIST_FIELD_PREFIXES);
3113 preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
3114 optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES);
3116 preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
3117 optionNames.add(CODEASSIST_LOCAL_PREFIXES);
3119 preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
3120 optionNames.add(CODEASSIST_ARGUMENT_PREFIXES);
3122 preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3123 optionNames.add(CODEASSIST_FIELD_SUFFIXES);
3125 preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3126 optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES);
3128 preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
3129 optionNames.add(CODEASSIST_LOCAL_SUFFIXES);
3131 preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
3132 optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES);
3136 * Returns whether the given marker references the given Java element. Used
3137 * for markers, which denote a Java element rather than a resource.
3143 * @return <code>true</code> if the marker references the element, false
3145 * @exception CoreException
3146 * if the <code>IMarker.getAttribute</code> on the marker
3149 public static boolean isReferencedBy(IJavaElement element, IMarker marker)
3150 throws CoreException {
3152 // only match units or classfiles
3153 if (element instanceof IMember) {
3154 IMember member = (IMember) element;
3155 if (member.isBinary()) {
3156 element = null; // member.getClassFile();
3158 element = member.getCompilationUnit();
3161 if (element == null)
3166 String markerHandleId = (String) marker.getAttribute(ATT_HANDLE_ID);
3167 if (markerHandleId == null)
3170 IJavaElement markerElement = JavaCore.create(markerHandleId);
3172 if (element.equals(markerElement))
3173 return true; // external elements may still be equal with
3177 // cycle through enclosing types in case marker is associated with a
3178 // classfile (15568)
3179 // if (markerElement instanceof IClassFile){
3180 // IType enclosingType =
3181 // ((IClassFile)markerElement).getType().getDeclaringType();
3182 // if (enclosingType != null){
3183 // markerElement = enclosingType.getClassFile(); // retry with immediate
3184 // enclosing classfile
3194 * Returns whether the given marker delta references the given Java element.
3195 * Used for markers deltas, which denote a Java element rather than a
3200 * @param markerDelta
3202 * @return <code>true</code> if the marker delta references the element
3203 * @exception CoreException
3204 * if the <code>IMarkerDelta.getAttribute</code> on the
3205 * marker delta fails
3207 public static boolean isReferencedBy(IJavaElement element,
3208 IMarkerDelta markerDelta) throws CoreException {
3210 // only match units or classfiles
3211 if (element instanceof IMember) {
3212 IMember member = (IMember) element;
3213 if (member.isBinary()) {
3214 element = null; // member.getClassFile();
3216 element = member.getCompilationUnit();
3219 if (element == null)
3221 if (markerDelta == null)
3224 String markerDeltarHandleId = (String) markerDelta
3225 .getAttribute(ATT_HANDLE_ID);
3226 if (markerDeltarHandleId == null)
3229 IJavaElement markerElement = JavaCore.create(markerDeltarHandleId);
3231 if (element.equals(markerElement))
3232 return true; // external elements may still be equal with
3236 // cycle through enclosing types in case marker is associated with a
3237 // classfile (15568)
3238 // if (markerElement instanceof IClassFile){
3239 // IType enclosingType =
3240 // ((IClassFile)markerElement).getType().getDeclaringType();
3241 // if (enclosingType != null){
3242 // markerElement = enclosingType.getClassFile(); // retry with immediate
3243 // enclosing classfile
3253 * Creates and returns a new classpath entry of kind
3254 * <code>CPE_CONTAINER</code> for the given path. The path of the
3255 * container will be used during resolution so as to map this container
3256 * entry to a set of other classpath entries the container is acting for.
3258 * A container entry allows to express indirect references to a set of
3259 * libraries, projects and variable entries, which can be interpreted
3260 * differently for each Java project where it is used. A classpath container
3261 * entry can be resolved using
3262 * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3263 * <code>JavaCore.classpathContainerChanged</code>
3265 * A container is exclusively resolved by a
3266 * <code>ClasspathContainerInitializer</code> registered onto the
3268 * "net.sourceforge.phpdt.core.classpathContainerInitializer".
3270 * A container path must be formed of at least one segment, where:
3272 * <li>the first segment is a unique ID identifying the target container,
3273 * there must be a container initializer registered onto this ID through the
3275 * "net.sourceforge.phpdt.core.classpathContainerInitializer". </li>
3276 * <li>the remaining segments will be passed onto the initializer, and can
3277 * be used as additional hints during the initialization phase.</li>
3280 * Example of an ClasspathContainerInitializer for a classpath container
3281 * denoting a default JDK container:
3283 * containerEntry = JavaCore.newContainerEntry(new
3284 * Path("MyProvidedJDK/default"));
3287 * point="net.sourceforge.phpdt.core.classpathContainerInitializer">
3288 * <containerInitializer id="MyProvidedJDK"
3289 * class="com.example.MyInitializer"/>
3291 * Note that this operation does not attempt to validate classpath
3292 * containers or access the resources at the given paths.
3294 * The resulting entry is not exported to dependent projects. This method is
3295 * equivalent to <code>newContainerEntry(-,false)</code>.
3298 * @param containerPath
3299 * the path identifying the container, it must be formed of two
3301 * @return a new container classpath entry
3303 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3304 * @see JavaCore#newContainerEntry(IPath, boolean)
3307 public static IClasspathEntry newContainerEntry(IPath containerPath) {
3309 return newContainerEntry(containerPath, false);
3313 * Creates and returns a new classpath entry of kind
3314 * <code>CPE_CONTAINER</code> for the given path. The path of the
3315 * container will be used during resolution so as to map this container
3316 * entry to a set of other classpath entries the container is acting for.
3318 * A container entry allows to express indirect references to a set of
3319 * libraries, projects and variable entries, which can be interpreted
3320 * differently for each Java project where it is used. A classpath container
3321 * entry can be resolved using
3322 * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3323 * <code>JavaCore.classpathContainerChanged</code>
3325 * A container is exclusively resolved by a
3326 * <code>ClasspathContainerInitializer</code> registered onto the
3328 * "net.sourceforge.phpdt.core.classpathContainerInitializer".
3330 * A container path must be formed of at least one segment, where:
3332 * <li>the first segment is a unique ID identifying the target container,
3333 * there must be a container initializer registered onto this ID through the
3335 * "net.sourceforge.phpdt.core.classpathContainerInitializer". </li>
3336 * <li>the remaining segments will be passed onto the initializer, and can
3337 * be used as additional hints during the initialization phase.</li>
3340 * Example of an ClasspathContainerInitializer for a classpath container
3341 * denoting a default JDK container:
3343 * containerEntry = JavaCore.newContainerEntry(new
3344 * Path("MyProvidedJDK/default"));
3347 * point="net.sourceforge.phpdt.core.classpathContainerInitializer">
3348 * <containerInitializer id="MyProvidedJDK"
3349 * class="com.example.MyInitializer"/>
3351 * Note that this operation does not attempt to validate classpath
3352 * containers or access the resources at the given paths.
3355 * @param containerPath
3356 * the path identifying the container, it must be formed of at
3357 * least one segment (ID+hints)
3359 * a boolean indicating whether this entry is contributed to
3360 * dependent projects in addition to the output location
3361 * @return a new container classpath entry
3363 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3364 * @see JavaCore#setClasspathContainer(IPath, IJavaProject[],
3365 * IClasspathContainer[], IProgressMonitor)
3366 * @see JavaCore#newContainerEntry(IPath, boolean)
3370 public static IClasspathEntry newContainerEntry(IPath containerPath,
3371 boolean isExported) {
3373 if (containerPath == null)
3374 Assert.isTrue(false, "Container path cannot be null"); //$NON-NLS-1$
3375 if (containerPath.segmentCount() < 1) {
3379 "Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$
3381 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3382 IClasspathEntry.CPE_CONTAINER, containerPath,
3383 ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, null, // source
3385 null, // source attachment root
3386 null, // specific output folder
3391 * Creates and returns a new non-exported classpath entry of kind
3392 * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3393 * absolute path. This specifies that all package fragments within the root
3394 * will have children of type <code>IClassFile</code>.
3396 * A library entry is used to denote a prerequisite JAR or root folder
3397 * containing binaries. The target JAR or folder can either be defined
3398 * internally to the workspace (absolute path relative to the workspace
3399 * root) or externally to the workspace (absolute path in the file system).
3401 * e.g. Here are some examples of binary path usage
3403 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3405 * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3407 * <li><code> "c:/classes/" </code>- reference to an external binary
3410 * Note that this operation does not attempt to validate or access the
3411 * resources at the given paths.
3413 * The resulting entry is not exported to dependent projects. This method is
3414 * equivalent to <code>newLibraryEntry(-,-,-,false)</code>.
3418 * the absolute path of the binary archive
3419 * @param sourceAttachmentPath
3420 * the absolute path of the corresponding source archive or
3421 * folder, or <code>null</code> if none
3422 * @param sourceAttachmentRootPath
3423 * the location of the root within the source archive or folder
3424 * or <code>null</code> if this location should be
3425 * automatically detected.
3426 * @return a new library classpath entry
3428 * @see #newLibraryEntry(IPath, IPath, IPath, boolean)
3430 // public static IClasspathEntry newLibraryEntry(
3432 // IPath sourceAttachmentPath,
3433 // IPath sourceAttachmentRootPath) {
3435 // return newLibraryEntry(path, sourceAttachmentPath,
3436 // sourceAttachmentRootPath, false);
3439 * Creates and returns a new classpath entry of kind
3440 * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3441 * absolute path. This specifies that all package fragments within the root
3442 * will have children of type <code>IClassFile</code>.
3444 * A library entry is used to denote a prerequisite JAR or root folder
3445 * containing binaries. The target JAR or folder can either be defined
3446 * internally to the workspace (absolute path relative to the workspace
3447 * root) or externally to the workspace (absolute path in the file system).
3449 * e.g. Here are some examples of binary path usage
3451 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3453 * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3455 * <li><code> "c:/classes/" </code>- reference to an external binary
3458 * Note that this operation does not attempt to validate or access the
3459 * resources at the given paths.
3463 * the absolute path of the binary archive
3464 * @param sourceAttachmentPath
3465 * the absolute path of the corresponding source archive or
3466 * folder, or <code>null</code> if none
3467 * @param sourceAttachmentRootPath
3468 * the location of the root within the source archive or folder
3469 * or <code>null</code> if this location should be
3470 * automatically detected.
3472 * indicates whether this entry is contributed to dependent
3473 * projects in addition to the output location
3474 * @return a new library classpath entry
3477 // public static IClasspathEntry newLibraryEntry(
3479 // IPath sourceAttachmentPath,
3480 // IPath sourceAttachmentRootPath,
3481 // boolean isExported) {
3483 // if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry
3484 // must be absolute"); //$NON-NLS-1$
3486 // return new ClasspathEntry(
3487 // IPackageFragmentRoot.K_BINARY,
3488 // IClasspathEntry.CPE_LIBRARY,
3489 // JavaProject.canonicalizedPath(path),
3490 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3491 // sourceAttachmentPath,
3492 // sourceAttachmentRootPath,
3493 // null, // specific output folder
3497 * Creates and returns a new non-exported classpath entry of kind
3498 * <code>CPE_PROJECT</code> for the project identified by the given
3501 * A project entry is used to denote a prerequisite project on a classpath.
3502 * The referenced project will be contributed as a whole, either as sources
3503 * (in the Java Model, it contributes all its package fragment roots) or as
3504 * binaries (when building, it contributes its whole output location).
3506 * A project reference allows to indirect through another project,
3507 * independently from its internal layout.
3509 * The prerequisite project is referred to using an absolute path relative
3510 * to the workspace root.
3512 * The resulting entry is not exported to dependent projects. This method is
3513 * equivalent to <code>newProjectEntry(_,false)</code>.
3517 * the absolute path of the binary archive
3518 * @return a new project classpath entry
3520 * @see JavaCore#newProjectEntry(IPath, boolean)
3522 public static IClasspathEntry newProjectEntry(IPath path) {
3523 return newProjectEntry(path, false);
3527 * Creates and returns a new classpath entry of kind
3528 * <code>CPE_PROJECT</code> for the project identified by the given
3531 * A project entry is used to denote a prerequisite project on a classpath.
3532 * The referenced project will be contributed as a whole, either as sources
3533 * (in the Java Model, it contributes all its package fragment roots) or as
3534 * binaries (when building, it contributes its whole output location).
3536 * A project reference allows to indirect through another project,
3537 * independently from its internal layout.
3539 * The prerequisite project is referred to using an absolute path relative
3540 * to the workspace root.
3544 * the absolute path of the prerequisite project
3546 * indicates whether this entry is contributed to dependent
3547 * projects in addition to the output location
3548 * @return a new project classpath entry
3551 public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) {
3553 if (!path.isAbsolute())
3554 Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3556 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3557 IClasspathEntry.CPE_PROJECT, path, ClasspathEntry.INCLUDE_ALL,
3558 ClasspathEntry.EXCLUDE_NONE, null, // source attachment
3559 null, // source attachment root
3560 null, // specific output folder
3565 * Returns a new empty region.
3567 * @return a new empty region
3569 public static IRegion newRegion() {
3570 return new Region();
3574 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3575 * for all files in the project's source folder identified by the given
3576 * absolute workspace-relative path.
3578 * The convenience method is fully equivalent to:
3581 * newSourceEntry(path, new IPath[] {}, new IPath[] {}, null);
3587 * the absolute workspace-relative path of a source folder
3588 * @return a new source classpath entry
3589 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath)
3591 public static IClasspathEntry newSourceEntry(IPath path) {
3593 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL,
3594 ClasspathEntry.EXCLUDE_NONE, null /* output location */);
3598 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3599 * for the project's source folder identified by the given absolute
3600 * workspace-relative path but excluding all source files with paths
3601 * matching any of the given patterns.
3603 * The convenience method is fully equivalent to:
3606 * newSourceEntry(path, new IPath[] {}, exclusionPatterns, null);
3612 * the absolute workspace-relative path of a source folder
3613 * @param exclusionPatterns
3614 * the possibly empty list of exclusion patterns represented as
3616 * @return a new source classpath entry
3617 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath)
3620 public static IClasspathEntry newSourceEntry(IPath path,
3621 IPath[] exclusionPatterns) {
3623 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL,
3624 exclusionPatterns, null /* output location */);
3628 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3629 * for the project's source folder identified by the given absolute
3630 * workspace-relative path but excluding all source files with paths
3631 * matching any of the given patterns, and associated with a specific output
3632 * location (that is, ".class" files are not going to the project default
3635 * The convenience method is fully equivalent to:
3638 * newSourceEntry(path, new IPath[] {}, exclusionPatterns, specificOutputLocation);
3644 * the absolute workspace-relative path of a source folder
3645 * @param exclusionPatterns
3646 * the possibly empty list of exclusion patterns represented as
3648 * @param specificOutputLocation
3649 * the specific output location for this source entry (<code>null</code>
3650 * if using project default ouput location)
3651 * @return a new source classpath entry
3652 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath)
3655 public static IClasspathEntry newSourceEntry(IPath path,
3656 IPath[] exclusionPatterns, IPath specificOutputLocation) {
3658 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL,
3659 exclusionPatterns, specificOutputLocation);
3663 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3664 * for the project's source folder identified by the given absolute
3665 * workspace-relative path using the given inclusion and exclusion patterns
3666 * to determine which source files are included, and the given output path
3667 * to control the output location of generated files.
3669 * The source folder is referred to using an absolute path relative to the
3670 * workspace root, e.g. <code>/Project/src</code>. A project's source
3671 * folders are located with that project. That is, a source classpath entry
3672 * specifying the path <code>/P1/src</code> is only usable for project
3676 * The inclusion patterns determines the initial set of source files that
3677 * are to be included; the exclusion patterns are then used to reduce this
3678 * set. When no inclusion patterns are specified, the initial file set
3679 * includes all relevent files in the resource tree rooted at the source
3680 * entry's path. On the other hand, specifying one or more inclusion
3681 * patterns means that all <b>and only</b> files matching at least one of
3682 * the specified patterns are to be included. If exclusion patterns are
3683 * specified, the initial set of files is then reduced by eliminating files
3684 * matched by at least one of the exclusion patterns. Inclusion and
3685 * exclusion patterns look like relative file paths with wildcards and are
3686 * interpreted relative to the source entry's path. File patterns are
3687 * case-sensitive can contain '**', '*' or '?' wildcards (see
3688 * {@link IClasspathEntry#getExclusionPatterns()} for the full description
3689 * of their syntax and semantics). The resulting set of files are included
3690 * in the corresponding package fragment root; all package fragments within
3691 * the root will have children of type <code>ICompilationUnit</code>.
3694 * For example, if the source folder path is <code>/Project/src</code>,
3695 * there are no inclusion filters, and the exclusion pattern is
3696 * <code>com/xyz/tests/**</code>, then source files like
3697 * <code>/Project/src/com/xyz/Foo.java</code> and
3698 * <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3699 * whereas <code>/Project/src/com/xyz/tests/T1.java</code> and
3700 * <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3704 * Additionally, a source entry can be associated with a specific output
3705 * location. By doing so, the Java builder will ensure that the generated
3706 * ".class" files will be issued inside this output location, as opposed to
3707 * be generated into the project default output location (when output
3708 * location is <code>null</code>). Note that multiple source entries may
3709 * target the same output location. The output location is referred to using
3710 * an absolute path relative to the workspace root, e.g.
3711 * <code>"/Project/bin"</code>, it must be located inside the same
3712 * project as the source folder.
3715 * Also note that all sources/binaries inside a project are contributed as a
3716 * whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
3717 * Particular source entries cannot be selectively exported.
3721 * the absolute workspace-relative path of a source folder
3722 * @param inclusionPatterns
3723 * the possibly empty list of inclusion patterns represented as
3725 * @param exclusionPatterns
3726 * the possibly empty list of exclusion patterns represented as
3728 * @param specificOutputLocation
3729 * the specific output location for this source entry (<code>null</code>
3730 * if using project default ouput location)
3731 * @return a new source classpath entry with the given exclusion patterns
3732 * @see IClasspathEntry#getInclusionPatterns()
3733 * @see IClasspathEntry#getExclusionPatterns()
3734 * @see IClasspathEntry#getOutputLocation()
3737 public static IClasspathEntry newSourceEntry(IPath path,
3738 IPath[] inclusionPatterns, IPath[] exclusionPatterns,
3739 IPath specificOutputLocation) {
3742 Assert.isTrue(false, "Source path cannot be null"); //$NON-NLS-1$
3743 if (!path.isAbsolute())
3744 Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3745 if (exclusionPatterns == null)
3746 Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$
3747 if (inclusionPatterns == null)
3748 Assert.isTrue(false, "Inclusion pattern set cannot be null"); //$NON-NLS-1$
3750 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3751 IClasspathEntry.CPE_SOURCE, path, inclusionPatterns,
3752 exclusionPatterns, null, // source attachment
3753 null, // source attachment root
3754 specificOutputLocation, // custom output location
3759 * Creates and returns a new non-exported classpath entry of kind
3760 * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3761 * path is the name of a classpath variable. The trailing segments of the
3762 * path will be appended to resolved variable path.
3764 * A variable entry allows to express indirect references on a classpath to
3765 * other projects or libraries, depending on what the classpath variable is
3768 * It is possible to register an automatic initializer (
3769 * <code>ClasspathVariableInitializer</code>), which will be invoked
3770 * through the extension point
3771 * "net.sourceforge.phpdt.core.classpathVariableInitializer". After
3772 * resolution, a classpath variable entry may either correspond to a project
3773 * or a library entry.</li>
3775 * e.g. Here are some examples of variable path usage
3777 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3778 * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3779 * library "c:\jars\jdtcore.jar"</li>
3780 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3781 * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3782 * "/Project_JDTCORE"</li>
3783 * <li>"PLUGINS/com.example/example.jar" where variable
3784 * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3785 * classpath entry is denoting the library
3786 * "c:/eclipse/plugins/com.example/example.jar"</li>
3788 * Note that this operation does not attempt to validate classpath variables
3789 * or access the resources at the given paths.
3791 * The resulting entry is not exported to dependent projects. This method is
3792 * equivalent to <code>newVariableEntry(-,-,-,false)</code>.
3795 * @param variablePath
3796 * the path of the binary archive; first segment is the name of a
3797 * classpath variable
3798 * @param variableSourceAttachmentPath
3799 * the path of the corresponding source archive, or
3800 * <code>null</code> if none; if present, the first segment is
3801 * the name of a classpath variable (not necessarily the same
3802 * variable as the one that begins <code>variablePath</code>)
3803 * @param sourceAttachmentRootPath
3804 * the location of the root within the source archive or
3805 * <code>null</code> if <code>archivePath</code> is also
3807 * @return a new library classpath entry
3809 * @see JavaCore#newVariableEntry(IPath, IPath, IPath, boolean)
3811 // public static IClasspathEntry newVariableEntry(
3812 // IPath variablePath,
3813 // IPath variableSourceAttachmentPath,
3814 // IPath sourceAttachmentRootPath) {
3816 // return newVariableEntry(variablePath, variableSourceAttachmentPath,
3817 // sourceAttachmentRootPath, false);
3820 * Creates and returns a new non-exported classpath entry of kind
3821 * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3822 * path is the name of a classpath variable. The trailing segments of the
3823 * path will be appended to resolved variable path.
3825 * A variable entry allows to express indirect references on a classpath to
3826 * other projects or libraries, depending on what the classpath variable is
3829 * It is possible to register an automatic initializer (
3830 * <code>ClasspathVariableInitializer</code>), which will be invoked
3831 * through the extension point
3832 * "net.sourceforge.phpdt.core.classpathVariableInitializer". After
3833 * resolution, a classpath variable entry may either correspond to a project
3834 * or a library entry.</li>
3836 * e.g. Here are some examples of variable path usage
3838 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3839 * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3840 * library "c:\jars\jdtcore.jar"</li>
3841 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3842 * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3843 * "/Project_JDTCORE"</li>
3844 * <li>"PLUGINS/com.example/example.jar" where variable
3845 * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3846 * classpath entry is denoting the library
3847 * "c:/eclipse/plugins/com.example/example.jar"</li>
3849 * Note that this operation does not attempt to validate classpath variables
3850 * or access the resources at the given paths.
3853 * @param variablePath
3854 * the path of the binary archive; first segment is the name of a
3855 * classpath variable
3856 * @param variableSourceAttachmentPath
3857 * the path of the corresponding source archive, or
3858 * <code>null</code> if none; if present, the first segment is
3859 * the name of a classpath variable (not necessarily the same
3860 * variable as the one that begins <code>variablePath</code>)
3861 * @param sourceAttachmentRootPath
3862 * the location of the root within the source archive or
3863 * <code>null</code> if <code>archivePath</code> is also
3866 * indicates whether this entry is contributed to dependent
3867 * projects in addition to the output location
3868 * @return a new variable classpath entry
3871 // public static IClasspathEntry newVariableEntry(
3872 // IPath variablePath,
3873 // IPath variableSourceAttachmentPath,
3874 // IPath variableSourceAttachmentRootPath,
3875 // boolean isExported) {
3877 // if (variablePath == null || variablePath.segmentCount() < 1) {
3880 // "Illegal classpath variable path: \'" +
3881 // variablePath.makeRelative().toString() + "\', must have at least one
3882 // segment"); //$NON-NLS-1$//$NON-NLS-2$
3885 // return new ClasspathEntry(
3886 // IPackageFragmentRoot.K_SOURCE,
3887 // IClasspathEntry.CPE_VARIABLE,
3889 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3890 // variableSourceAttachmentPath, // source attachment
3891 // variableSourceAttachmentRootPath, // source attachment root
3892 // null, // specific output folder
3896 * Removed the given classpath variable. Does nothing if no value was set
3897 * for this classpath variable.
3899 * This functionality cannot be used while the resource tree is locked.
3901 * Classpath variable values are persisted locally to the workspace, and are
3902 * preserved from session to session.
3905 * @param variableName
3906 * the name of the classpath variable
3907 * @see #setClasspathVariable
3909 * @deprecated - use version with extra IProgressMonitor
3911 // public static void removeClasspathVariable(String variableName) {
3912 // removeClasspathVariable(variableName, null);
3915 * Removed the given classpath variable. Does nothing if no value was set
3916 * for this classpath variable.
3918 * This functionality cannot be used while the resource tree is locked.
3920 * Classpath variable values are persisted locally to the workspace, and are
3921 * preserved from session to session.
3924 * @param variableName
3925 * the name of the classpath variable
3927 * the progress monitor to report progress
3928 * @see #setClasspathVariable
3930 // public static void removeClasspathVariable(
3931 // String variableName,
3932 // IProgressMonitor monitor) {
3935 // updateVariableValues(new String[]{ variableName}, new IPath[]{ null },
3937 // } catch (JavaModelException e) {
3941 * Removes the given element changed listener. Has no affect if an identical
3942 * listener is not registered.
3947 public static void removeElementChangedListener(
3948 IElementChangedListener listener) {
3949 JavaModelManager.getJavaModelManager().removeElementChangedListener(
3954 * Bind a container reference path to some actual containers (
3955 * <code>IClasspathContainer</code>). This API must be invoked whenever
3956 * changes in container need to be reflected onto the JavaModel. Containers
3957 * can have distinct values in different projects, therefore this API
3958 * considers a set of projects with their respective containers.
3960 * <code>containerPath</code> is the path under which these values can be
3961 * referenced through container classpath entries (
3962 * <code>IClasspathEntry#CPE_CONTAINER</code>). A container path is
3963 * formed by a first ID segment followed with extra segments, which can be
3964 * used as additional hints for the resolution. The container ID is used to
3965 * identify a <code>ClasspathContainerInitializer</code> registered on the
3967 * "net.sourceforge.phpdt.core.classpathContainerInitializer".
3969 * There is no assumption that each individual container value passed in
3970 * argument (<code>respectiveContainers</code>) must answer the exact
3971 * same path when requested <code>IClasspathContainer#getPath</code>.
3972 * Indeed, the containerPath is just an indication for resolving it to an
3973 * actual container object. It can be delegated to a
3974 * <code>ClasspathContainerInitializer</code>, which can be activated
3975 * through the extension point
3976 * "net.sourceforge.phpdt.core.ClasspathContainerInitializer").
3978 * In reaction to changing container values, the JavaModel will be updated
3979 * to reflect the new state of the updated container.
3981 * This functionality cannot be used while the resource tree is locked.
3983 * Classpath container values are persisted locally to the workspace, but
3984 * are not preserved from a session to another. It is thus highly
3985 * recommended to register a <code>ClasspathContainerInitializer</code>
3986 * for each referenced container (through the extension point
3987 * "net.sourceforge.phpdt.core.ClasspathContainerInitializer").
3989 * Note: setting a container to <code>null</code> will cause it to be
3990 * lazily resolved again whenever its value is required. In particular, this
3991 * will cause a registered initializer to be invoked again.
3994 * @param containerPath -
3995 * the name of the container reference, which is being updated
3996 * @param affectedProjects -
3997 * the set of projects for which this container is being bound
3998 * @param respectiveContainers -
3999 * the set of respective containers for the affected projects
4001 * a monitor to report progress
4003 * @see ClasspathContainerInitializer
4004 * @see #getClasspathContainer(IPath, IJavaProject)
4005 * @see IClasspathContainer
4008 // public static void setClasspathContainer(final IPath containerPath,
4009 // IJavaProject[] affectedProjects, IClasspathContainer[]
4010 // respectiveContainers, IProgressMonitor monitor) throws JavaModelException
4013 // if (affectedProjects.length != respectiveContainers.length)
4014 // Assert.isTrue(false, "Projects and containers collections should have the
4015 // same size"); //$NON-NLS-1$
4017 // if (monitor != null && monitor.isCanceled()) return;
4019 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4020 // System.out.println("CPContainer SET - setting container:
4021 // ["+containerPath+"] for projects: {" //$NON-NLS-1$ //$NON-NLS-2$
4022 // + (ProjectPrefUtil.toString(affectedProjects,
4023 // new ProjectPrefUtil.Displayable(){
4024 // public String displayString(Object o) { return ((IJavaProject)
4025 // o).getElementName(); }
4027 // + "} with values: " //$NON-NLS-1$
4028 // + (ProjectPrefUtil.toString(respectiveContainers,
4029 // new ProjectPrefUtil.Displayable(){
4030 // public String displayString(Object o) { return ((IClasspathContainer)
4031 // o).getDescription(); }
4036 // final int projectLength = affectedProjects.length;
4037 // final IJavaProject[] modifiedProjects;
4038 // System.arraycopy(affectedProjects, 0, modifiedProjects = new
4039 // IJavaProject[projectLength], 0, projectLength);
4040 // final IClasspathEntry[][] oldResolvedPaths = new
4041 // IClasspathEntry[projectLength][];
4043 // // filter out unmodified project containers
4044 // int remaining = 0;
4045 // for (int i = 0; i < projectLength; i++){
4047 // if (monitor != null && monitor.isCanceled()) return;
4049 // IJavaProject affectedProject = affectedProjects[i];
4050 // IClasspathContainer newContainer = respectiveContainers[i];
4051 // if (newContainer == null) newContainer =
4052 // JavaModelManager.ContainerInitializationInProgress; // 30920 - prevent
4054 // boolean found = false;
4055 // if (JavaProject.hasJavaNature(affectedProject.getProject())){
4056 // IClasspathEntry[] rawClasspath = affectedProject.getRawClasspath();
4057 // for (int j = 0, cpLength = rawClasspath.length; j <cpLength; j++) {
4058 // IClasspathEntry entry = rawClasspath[j];
4059 // if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER &&
4060 // entry.getPath().equals(containerPath)){
4067 // modifiedProjects[i] = null; // filter out this project - does not
4068 // reference the container path, or isnt't yet Java project
4069 // JavaModelManager.containerPut(affectedProject, containerPath,
4073 // IClasspathContainer oldContainer =
4074 // JavaModelManager.containerGet(affectedProject, containerPath);
4075 // if (oldContainer == JavaModelManager.ContainerInitializationInProgress) {
4076 // Map previousContainerValues =
4077 // (Map)JavaModelManager.PreviousSessionContainers.get(affectedProject);
4078 // if (previousContainerValues != null){
4079 // IClasspathContainer previousContainer =
4080 // (IClasspathContainer)previousContainerValues.get(containerPath);
4081 // if (previousContainer != null) {
4082 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4083 // System.out.println("CPContainer INIT - reentering access to project
4084 // container: ["+affectedProject.getElementName()+"] " + containerPath + "
4085 // during its initialization, will see previous value: "+
4086 // previousContainer.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
4089 // JavaModelManager.containerPut(affectedProject, containerPath,
4090 // previousContainer);
4092 // oldContainer = null; //33695 - cannot filter out restored container, must
4093 // update affected project to reset cached CP
4095 // oldContainer = null;
4098 // if (oldContainer != null &&
4099 // oldContainer.equals(respectiveContainers[i])){// TODO: could improve to
4100 // only compare entries
4101 // modifiedProjects[i] = null; // filter out this project - container did
4106 // oldResolvedPaths[i] = affectedProject.getResolvedClasspath(true);
4107 // JavaModelManager.containerPut(affectedProject, containerPath,
4111 // if (remaining == 0) return;
4113 // // trigger model refresh
4115 // JavaCore.run(new IWorkspaceRunnable() {
4116 // public void run(IProgressMonitor monitor) throws CoreException {
4117 // for(int i = 0; i < projectLength; i++){
4119 // if (monitor != null && monitor.isCanceled()) return;
4121 // JavaProject affectedProject = (JavaProject)modifiedProjects[i];
4122 // if (affectedProject == null) continue; // was filtered out
4124 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4125 // System.out.println("CPContainer SET - updating affected project:
4126 // ["+affectedProject.getElementName()+"] due to setting container: " +
4127 // containerPath); //$NON-NLS-1$ //$NON-NLS-2$
4130 // // force a refresh of the affected project (will compute deltas)
4131 // affectedProject.setRawClasspath(
4132 // affectedProject.getRawClasspath(),
4133 // SetClasspathOperation.ReuseOutputLocation,
4135 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can save resources
4136 // oldResolvedPaths[i],
4137 // false, // updating - no validation
4138 // false); // updating - no need to save
4143 // } catch(CoreException e) {
4144 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4145 // System.out.println("CPContainer SET - FAILED DUE TO EXCEPTION:
4146 // "+containerPath); //$NON-NLS-1$
4147 // e.printStackTrace();
4149 // if (e instanceof JavaModelException) {
4150 // throw (JavaModelException)e;
4152 // throw new JavaModelException(e);
4155 // for (int i = 0; i < projectLength; i++) {
4156 // if (respectiveContainers[i] == null) {
4157 // JavaModelManager.containerPut(affectedProjects[i], containerPath, null);
4158 // // reset init in progress marker
4165 * Sets the value of the given classpath variable. The path must have at
4166 * least one segment.
4168 * This functionality cannot be used while the resource tree is locked.
4170 * Classpath variable values are persisted locally to the workspace, and are
4171 * preserved from session to session.
4174 * @param variableName
4175 * the name of the classpath variable
4178 * @see #getClasspathVariable
4180 * @deprecated - use API with IProgressMonitor
4182 // public static void setClasspathVariable(String variableName, IPath path)
4183 // throws JavaModelException {
4185 // setClasspathVariable(variableName, path, null);
4188 * Sets the value of the given classpath variable. The path must not be
4191 * This functionality cannot be used while the resource tree is locked.
4193 * Classpath variable values are persisted locally to the workspace, and are
4194 * preserved from session to session.
4196 * Updating a variable with the same value has no effect.
4198 * @param variableName
4199 * the name of the classpath variable
4203 * a monitor to report progress
4204 * @see #getClasspathVariable
4206 // public static void setClasspathVariable(
4207 // String variableName,
4209 // IProgressMonitor monitor)
4210 // throws JavaModelException {
4212 // if (path == null) Assert.isTrue(false, "Variable path cannot be null");
4214 // setClasspathVariables(new String[]{variableName}, new IPath[]{ path },
4218 * Sets the values of all the given classpath variables at once. Null paths
4219 * can be used to request corresponding variable removal.
4221 * This functionality cannot be used while the resource tree is locked.
4223 * Classpath variable values are persisted locally to the workspace, and are
4224 * preserved from session to session.
4226 * Updating a variable with the same value has no effect.
4228 * @param variableNames
4229 * an array of names for the updated classpath variables
4231 * an array of path updates for the modified classpath variables
4232 * (null meaning that the corresponding value will be removed
4234 * a monitor to report progress
4235 * @see #getClasspathVariable
4238 // public static void setClasspathVariables(
4239 // String[] variableNames,
4241 // IProgressMonitor monitor)
4242 // throws JavaModelException {
4244 // if (variableNames.length != paths.length) Assert.isTrue(false, "Variable
4245 // names and paths collections should have the same size"); //$NON-NLS-1$
4246 // //TODO: should check that null cannot be used as variable paths
4247 // updateVariableValues(variableNames, paths, monitor);
4250 * (non-Javadoc) Method declared on IExecutableExtension. Record any
4251 * necessary initialization data from the plugin.
4253 public void setInitializationData(IConfigurationElement cfig,
4254 String propertyName, Object data) throws CoreException {
4258 * Sets the current table of options. All and only the options explicitly
4259 * included in the given table are remembered; all previous option settings
4260 * are forgotten, including ones not explicitly mentioned.
4262 * For a complete description of the configurable options, see
4263 * <code>getDefaultOptions</code>.
4267 * the new options (key type: <code>String</code>; value type:
4268 * <code>String</code>), or <code>null</code> to reset all
4269 * options to their default values
4270 * @see JavaCore#getDefaultOptions
4272 public static void setOptions(Hashtable newOptions) {
4274 // see #initializeDefaultPluginPreferences() for changing default
4276 Preferences preferences = getPlugin().getPluginPreferences();
4278 if (newOptions == null) {
4279 newOptions = JavaCore.getDefaultOptions();
4281 Enumeration keys = newOptions.keys();
4282 while (keys.hasMoreElements()) {
4283 String key = (String) keys.nextElement();
4284 if (!JavaModelManager.OptionNames.contains(key))
4285 continue; // unrecognized option
4286 if (key.equals(CORE_ENCODING))
4287 continue; // skipped, contributed by resource prefs
4288 String value = (String) newOptions.get(key);
4289 preferences.setValue(key, value);
4293 getPlugin().savePluginPreferences();
4297 * Shutdown the JavaCore plug-in.
4299 * De-registers the JavaModelManager as a resource changed listener and save
4303 * @see org.eclipse.core.runtime.Plugin#shutdown()
4305 // moved to PHPeclipsePlugin#shutdown()
4306 // public void shutdown() {
4308 // //savePluginPreferences();
4309 // getPlugin().savePluginPreferences();
4310 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4311 // workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaProcessor);
4312 // workspace.removeSaveParticipant(PHPeclipsePlugin.getDefault());
4314 // ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown();
4317 * Initiate the background indexing process. This should be deferred after
4318 * the plugin activation.
4320 // private void startIndexing() {
4322 // JavaModelManager.getJavaModelManager().getIndexManager().reset();
4325 * Startup of the JavaCore plug-in.
4327 * Registers the JavaModelManager as a resource changed listener and save
4328 * participant. Starts the background indexing, and restore saved classpath
4332 * @see org.eclipse.core.runtime.Plugin#startup()
4335 // moved to PHPeclipsePlugin#startup()
4336 // public void startup() {
4338 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
4340 // manager.configurePluginDebugOptions();
4342 // // request state folder creation (workaround 19885)
4343 // JavaCore.getPlugin().getStateLocation();
4345 // // retrieve variable values
4346 // JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4347 // JavaModelManager.PluginPreferencesListener());
4348 // // TODO : jsurfer temp-del
4349 // // manager.loadVariablesAndContainers();
4351 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4352 // workspace.addResourceChangeListener(
4353 // manager.deltaProcessor,
4354 // IResourceChangeEvent.PRE_AUTO_BUILD
4355 // | IResourceChangeEvent.POST_AUTO_BUILD
4356 // | IResourceChangeEvent.POST_CHANGE
4357 // | IResourceChangeEvent.PRE_DELETE
4358 // | IResourceChangeEvent.PRE_CLOSE);
4360 // // startIndexing();
4361 // workspace.addSaveParticipant(PHPeclipsePlugin.getDefault(), manager);
4363 // } catch (CoreException e) {
4364 // } catch (RuntimeException e) {
4365 // manager.shutdown();
4370 * Internal updating of a variable values (null path meaning removal),
4371 * allowing to change multiple variable values at once.
4373 // private static void updateVariableValues(
4374 // String[] variableNames,
4375 // IPath[] variablePaths,
4376 // IProgressMonitor monitor) throws JavaModelException {
4378 // if (monitor != null && monitor.isCanceled()) return;
4380 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4381 // System.out.println("CPVariable SET - setting variables: {" +
4382 // ProjectPrefUtil.toString(variableNames) //$NON-NLS-1$
4383 // + "} with values: " + ProjectPrefUtil.toString(variablePaths));
4387 // int varLength = variableNames.length;
4389 // // gather classpath information for updating
4390 // final HashMap affectedProjects = new HashMap(5);
4391 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
4392 // IJavaModel model = manager.getJavaModel();
4394 // // filter out unmodified variables
4395 // int discardCount = 0;
4396 // for (int i = 0; i < varLength; i++){
4397 // String variableName = variableNames[i];
4398 // IPath oldPath = (IPath)JavaModelManager.variableGet(variableName); // if
4399 // reentering will provide previous session value
4400 // if (oldPath == JavaModelManager.VariableInitializationInProgress){
4401 // IPath previousPath =
4402 // (IPath)JavaModelManager.PreviousSessionVariables.get(variableName);
4403 // if (previousPath != null){
4404 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4405 // System.out.println("CPVariable INIT - reentering access to variable: " +
4406 // variableName+ " during its initialization, will see previous value: "+
4407 // previousPath); //$NON-NLS-1$ //$NON-NLS-2$
4409 // JavaModelManager.variablePut(variableName, previousPath); // replace
4410 // value so reentering calls are seeing old value
4412 // oldPath = null; //33695 - cannot filter out restored variable, must
4413 // update affected project to reset cached CP
4415 // if (oldPath != null && oldPath.equals(variablePaths[i])){
4416 // variableNames[i] = null;
4420 // if (discardCount > 0){
4421 // if (discardCount == varLength) return;
4422 // int changedLength = varLength - discardCount;
4423 // String[] changedVariableNames = new String[changedLength];
4424 // IPath[] changedVariablePaths = new IPath[changedLength];
4425 // for (int i = 0, index = 0; i < varLength; i++){
4426 // if (variableNames[i] != null){
4427 // changedVariableNames[index] = variableNames[i];
4428 // changedVariablePaths[index] = variablePaths[i];
4432 // variableNames = changedVariableNames;
4433 // variablePaths = changedVariablePaths;
4434 // varLength = changedLength;
4437 // if (monitor != null && monitor.isCanceled()) return;
4439 // if (model != null) {
4440 // IJavaProject[] projects = model.getJavaProjects();
4441 // nextProject : for (int i = 0, projectLength = projects.length; i <
4442 // projectLength; i++){
4443 // IJavaProject project = projects[i];
4445 // // check to see if any of the modified variables is present on the
4447 // IClasspathEntry[] classpath = project.getRawClasspath();
4448 // for (int j = 0, cpLength = classpath.length; j < cpLength; j++){
4450 // IClasspathEntry entry = classpath[j];
4451 // for (int k = 0; k < varLength; k++){
4453 // String variableName = variableNames[k];
4454 // if (entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE){
4456 // if (variableName.equals(entry.getPath().segment(0))){
4457 // affectedProjects.put(project, project.getResolvedClasspath(true));
4458 // continue nextProject;
4460 // IPath sourcePath, sourceRootPath;
4461 // if (((sourcePath = entry.getSourceAttachmentPath()) != null &&
4462 // variableName.equals(sourcePath.segment(0)))
4463 // || ((sourceRootPath = entry.getSourceAttachmentRootPath()) != null &&
4464 // variableName.equals(sourceRootPath.segment(0)))) {
4466 // affectedProjects.put(project, project.getResolvedClasspath(true));
4467 // continue nextProject;
4474 // // update variables
4475 // for (int i = 0; i < varLength; i++){
4476 // JavaModelManager.variablePut(variableNames[i], variablePaths[i]);
4478 // final String[] dbgVariableNames = variableNames;
4480 // // update affected project classpaths
4481 // if (!affectedProjects.isEmpty()) {
4483 // JavaCore_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt.run(
4484 // new IWorkspaceRunnable() {
4485 // public void run(IProgressMonitor monitor) throws CoreException {
4486 // // propagate classpath change
4487 // Iterator projectsToUpdate = affectedProjects.keySet().iterator();
4488 // while (projectsToUpdate.hasNext()) {
4490 // if (monitor != null && monitor.isCanceled()) return;
4492 // JavaProject project = (JavaProject) projectsToUpdate.next();
4494 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4495 // System.out.println("CPVariable SET - updating affected project:
4496 // ["+project.getElementName()+"] due to setting variables: "+
4497 // ProjectPrefUtil.toString(dbgVariableNames)); //$NON-NLS-1$ //$NON-NLS-2$
4501 // .setRawClasspath(
4502 // project.getRawClasspath(),
4503 // SetClasspathOperation.ReuseOutputLocation,
4504 // null, // don't call beginTask on the monitor (see
4505 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=3717)
4506 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can change resources
4507 // (IClasspathEntry[]) affectedProjects.get(project),
4508 // false, // updating - no validation
4509 // false); // updating - no need to save
4514 // } catch (CoreException e) {
4515 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4516 // System.out.println("CPVariable SET - FAILED DUE TO EXCEPTION:
4517 // "+ProjectPrefUtil.toString(dbgVariableNames)); //$NON-NLS-1$
4518 // e.printStackTrace();
4520 // if (e instanceof JavaModelException) {
4521 // throw (JavaModelException)e;
4523 // throw new JavaModelException(e);
4529 * (non-Javadoc) Startup the JavaCore plug-in. <p> Registers the
4530 * JavaModelManager as a resource changed listener and save participant.
4531 * Starts the background indexing, and restore saved classpath variable
4532 * values. <p> @throws Exception
4534 * @see org.eclipse.core.runtime.Plugin#start(BundleContext)
4536 // public static void start(final Plugin plugin, BundleContext context)
4537 // throws Exception {
4538 // // super.start(context);
4540 // final JavaModelManager manager = JavaModelManager.getJavaModelManager();
4542 // manager.configurePluginDebugOptions();
4544 // // request state folder creation (workaround 19885)
4545 // JavaCore.getPlugin().getStateLocation();
4547 // // retrieve variable values
4548 // //JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4549 // JavaModelManager.PluginPreferencesListener());
4550 // // manager.loadVariablesAndContainers();
4552 // final IWorkspace workspace = ResourcesPlugin.getWorkspace();
4553 // workspace.addResourceChangeListener(
4554 // manager.deltaState,
4555 // IResourceChangeEvent.PRE_BUILD
4556 // | IResourceChangeEvent.POST_BUILD
4557 // | IResourceChangeEvent.POST_CHANGE
4558 // | IResourceChangeEvent.PRE_DELETE
4559 // | IResourceChangeEvent.PRE_CLOSE);
4561 // // startIndexing();
4563 // // process deltas since last activated in indexer thread so that indexes
4565 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658
4566 // Job processSavedState = new
4567 // Job(ProjectPrefUtil.bind("savedState.jobName")) {
4569 // protected IStatus run(IProgressMonitor monitor) {
4571 // // add save participant and process delta atomically
4572 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59937
4574 // new IWorkspaceRunnable() {
4575 // public void run(IProgressMonitor progress) throws CoreException {
4576 // // ISavedState savedState = workspace.addSaveParticipant(JavaCore.this,
4578 // ISavedState savedState = workspace.addSaveParticipant(plugin, manager);
4579 // if (savedState != null) {
4580 // // the event type coming from the saved state is always POST_AUTO_BUILD
4581 // // force it to be POST_CHANGE so that the delta processor can handle it
4582 // manager.deltaState.getDeltaProcessor().overridenEventType =
4583 // IResourceChangeEvent.POST_CHANGE;
4584 // savedState.processResourceChangeEvents(manager.deltaState);
4589 // } catch (CoreException e) {
4590 // return e.getStatus();
4592 // return Status.OK_STATUS;
4595 // processSavedState.setSystem(true);
4596 // processSavedState.setPriority(Job.SHORT); // process asap
4597 // processSavedState.schedule();
4598 // } catch (RuntimeException e) {
4599 // manager.shutdown();
4604 * (non-Javadoc) Shutdown the JavaCore plug-in. <p> De-registers the
4605 * JavaModelManager as a resource changed listener and save participant. <p>
4607 * @see org.eclipse.core.runtime.Plugin#stop(BundleContext)
4609 // public static void stop(Plugin plugin, BundleContext context)
4610 // throws Exception {
4612 // plugin.savePluginPreferences();
4613 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4614 // workspace.removeResourceChangeListener(JavaModelManager
4615 // .getJavaModelManager().deltaState);
4616 // workspace.removeSaveParticipant(plugin);
4618 // JavaModelManager.getJavaModelManager().shutdown();
4620 // // ensure we call super.stop as the last thing
4621 // // super.stop(context);