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$
310 * Possible configurable option ID.
312 * @see #getDefaultOptions
314 public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID
315 + ".compiler.problem.invalidImport"; //$NON-NLS-1$
318 * Possible configurable option ID.
320 * @see #getDefaultOptions
322 public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID
323 + ".compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
326 * Possible configurable option ID.
328 * @see #getDefaultOptions
330 public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID
331 + ".compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
334 * Possible configurable option ID.
336 * @see #getDefaultOptions
338 public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID
339 + ".compiler.problem.deprecation"; //$NON-NLS-1$
342 * Possible configurable option ID.
344 * @see #getDefaultOptions
347 public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID
348 + ".compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
351 * Possible configurable option ID.
353 * @see #getDefaultOptions
355 public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID
356 + ".compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
359 * Possible configurable option ID.
361 * @see #getDefaultOptions
363 public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID
364 + ".compiler.problem.unusedLocal"; //$NON-NLS-1$
367 * Possible configurable option ID.
369 * @see #getDefaultOptions
371 public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID
372 + ".compiler.problem.unusedParameter"; //$NON-NLS-1$
375 * Possible configurable option ID.
377 * @see #getDefaultOptions
380 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID
381 + ".compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
384 * Possible configurable option ID.
386 * @see #getDefaultOptions
389 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID
390 + ".compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
393 * Possible configurable option ID.
395 * @see #getDefaultOptions
398 public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID
399 + ".compiler.problem.unusedImport"; //$NON-NLS-1$
402 * Possible configurable option ID.
404 * @see #getDefaultOptions
406 public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID
407 + ".compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
410 * Possible configurable option ID.
412 * @see #getDefaultOptions
415 public static final String COMPILER_PB_NON_NLS_STRING_LITERAL = PLUGIN_ID
416 + ".compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
419 * Possible configurable option ID.
421 * @see #getDefaultOptions
424 public static final String COMPILER_PB_ASSERT_IDENTIFIER = PLUGIN_ID
425 + ".compiler.problem.assertIdentifier"; //$NON-NLS-1$
428 * Possible configurable option ID.
430 * @see #getDefaultOptions
433 public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID
434 + ".compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
437 * Possible configurable option ID.
439 * @see #getDefaultOptions
442 public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID
443 + ".compiler.problem.noEffectAssignment"; //$NON-NLS-1$
446 * Possible configurable option ID.
448 * @see #getDefaultOptions
451 public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID
452 + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
455 * Possible configurable option ID.
457 * @see #getDefaultOptions
460 public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID
461 + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
464 * Possible configurable option ID.
466 * @see #getDefaultOptions
469 public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID
470 + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
473 * Possible configurable option ID.
475 * @see #getDefaultOptions
478 public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID
479 + ".compiler.maxProblemPerUnit"; //$NON-NLS-1$
482 * Possible configurable option ID.
484 * @see #getDefaultOptions
487 public static final String COMPILER_SOURCE = PLUGIN_ID + ".compiler.source"; //$NON-NLS-1$
490 * Possible configurable option ID.
492 * @see #getDefaultOptions
495 public static final String COMPILER_COMPLIANCE = PLUGIN_ID
496 + ".compiler.compliance"; //$NON-NLS-1$
499 * Possible configurable option ID.
501 * @see #getDefaultOptions
504 public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID
505 + ".compiler.taskPriorities"; //$NON-NLS-1$
508 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
510 * @see #getDefaultOptions
513 public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$
516 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
518 * @see #getDefaultOptions
521 public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$
524 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
526 * @see #getDefaultOptions
529 public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$
532 * Possible configurable option ID.
534 * @see #getDefaultOptions
536 public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID
537 + ".computeJavaBuildOrder"; //$NON-NLS-1$
540 * Possible configurable option ID.
542 * @see #getDefaultOptions
545 public static final String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER = PLUGIN_ID
546 + ".builder.resourceCopyExclusionFilter"; //$NON-NLS-1$
549 * Possible configurable option ID.
551 * @see #getDefaultOptions
554 public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID
555 + ".builder.duplicateResourceTask"; //$NON-NLS-1$
558 * Possible configurable option ID.
560 * @see #getDefaultOptions
563 public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID
564 + ".builder.cleanOutputFolder"; //$NON-NLS-1$
567 * Possible configurable option ID.
569 * @see #getDefaultOptions
572 public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID
573 + ".incompleteClasspath"; //$NON-NLS-1$
576 * Possible configurable option ID.
578 * @see #getDefaultOptions
581 public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID
582 + ".circularClasspath"; //$NON-NLS-1$
585 * Possible configurable option ID.
587 * @see #getDefaultOptions
590 public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID
591 + ".builder.invalidClasspath"; //$NON-NLS-1$
594 * Possible configurable option ID.
596 * @see #getDefaultOptions
599 public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID
600 + ".classpath.exclusionPatterns"; //$NON-NLS-1$
603 * Possible configurable option ID.
605 * @see #getDefaultOptions
608 public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID
609 + ".classpath.multipleOutputLocations"; //$NON-NLS-1$
616 public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$
619 * Default task priority
623 public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; //$NON-NLS-1$
626 * Possible configurable option ID
628 * @see #getDefaultOptions
631 public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID
632 + ".formatter.space.castexpression"; //$NON-NLS-1$
635 * Possible configurable option ID.
637 * @see #getDefaultOptions
640 public static final String CODEASSIST_VISIBILITY_CHECK = PLUGIN_ID
641 + ".codeComplete.visibilityCheck"; //$NON-NLS-1$
644 * Possible configurable option ID.
646 * @see #getDefaultOptions
649 public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID
650 + ".codeComplete.forceImplicitQualification"; //$NON-NLS-1$
653 * Possible configurable option ID.
655 * @see #getDefaultOptions
658 public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID
659 + ".codeComplete.fieldPrefixes"; //$NON-NLS-1$
662 * Possible configurable option ID.
664 * @see #getDefaultOptions
667 public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID
668 + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
671 * Possible configurable option ID.
673 * @see #getDefaultOptions
676 public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID
677 + ".codeComplete.localPrefixes"; //$NON-NLS-1$
680 * Possible configurable option ID.
682 * @see #getDefaultOptions
685 public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID
686 + ".codeComplete.argumentPrefixes"; //$NON-NLS-1$
689 * Possible configurable option ID.
691 * @see #getDefaultOptions
694 public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID
695 + ".codeComplete.fieldSuffixes"; //$NON-NLS-1$
698 * Possible configurable option ID.
700 * @see #getDefaultOptions
703 public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID
704 + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
707 * Possible configurable option ID.
709 * @see #getDefaultOptions
712 public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID
713 + ".codeComplete.localSuffixes"; //$NON-NLS-1$
716 * Possible configurable option ID.
718 * @see #getDefaultOptions
721 public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID
722 + ".codeComplete.argumentSuffixes"; //$NON-NLS-1$
724 // *************** Possible values for configurable options.
725 // ********************
728 * Possible configurable option value.
730 * @see #getDefaultOptions
732 public static final String GENERATE = "generate"; //$NON-NLS-1$
735 * Possible configurable option value.
737 * @see #getDefaultOptions
739 public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
742 * Possible configurable option value.
744 * @see #getDefaultOptions
746 public static final String PRESERVE = "preserve"; //$NON-NLS-1$
749 * Possible configurable option value.
751 * @see #getDefaultOptions
753 public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
756 * Possible configurable option value.
758 * @see #getDefaultOptions
760 public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$
763 * Possible configurable option value.
765 * @see #getDefaultOptions
767 public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$
770 * Possible configurable option value.
772 * @see #getDefaultOptions
775 public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
778 * Possible configurable option value.
780 * @see #getDefaultOptions
783 public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
786 * Possible configurable option value.
788 * @see #getDefaultOptions
791 public static final String ABORT = "abort"; //$NON-NLS-1$
794 * Possible configurable option value.
796 * @see #getDefaultOptions
798 public static final String ERROR = "error"; //$NON-NLS-1$
801 * Possible configurable option value.
803 * @see #getDefaultOptions
805 public static final String WARNING = "warning"; //$NON-NLS-1$
808 * Possible configurable option value.
810 * @see #getDefaultOptions
812 public static final String IGNORE = "ignore"; //$NON-NLS-1$
815 * Possible configurable option value.
817 * @see #getDefaultOptions
819 public static final String COMPUTE = "compute"; //$NON-NLS-1$
822 * Possible configurable option value.
824 * @see #getDefaultOptions
829 * Returns a table of all known configurable options with their default
830 * values. These options allow to configure the behaviour of the underlying
831 * components. The client may safely use the result as a template that they
832 * can modify and then pass to <code>setOptions</code>.
834 * Helper constants have been defined on JavaCore for each of the option ID
835 * and their possible constant values.
837 * Note: more options might be added in further releases.
841 * RECOGNIZED OPTIONS:
842 * COMPILER / Generating Local Variable Debug Attribute
843 * When generated, this attribute will enable local variable names
844 * to be displayed in debugger, only in place where variables are
845 * definitely assigned (.class file is then bigger)
846 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.localVariable"
847 * - possible values: { "generate", "do not generate" }
848 * - default: "generate"
850 * COMPILER / Generating Line Number Debug Attribute
851 * When generated, this attribute will enable source code highlighting in debugger
852 * (.class file is then bigger).
853 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.lineNumber"
854 * - possible values: { "generate", "do not generate" }
855 * - default: "generate"
857 * COMPILER / Generating Source Debug Attribute
858 * When generated, this attribute will enable the debugger to present the
859 * corresponding source code.
860 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.sourceFile"
861 * - possible values: { "generate", "do not generate" }
862 * - default: "generate"
864 * COMPILER / Preserving Unused Local Variables
865 * Unless requested to preserve unused local variables (i.e. never read), the
866 * compiler will optimize them out, potentially altering debugging
867 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.unusedLocal"
868 * - possible values: { "preserve", "optimize out" }
869 * - default: "preserve"
871 * COMPILER / Defining Target Java Platform
872 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
873 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
874 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.targetPlatform"
875 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
876 * - default: "1.1"
878 * COMPILER / Reporting Unreachable Code
879 * Unreachable code can optionally be reported as an error, warning or simply
880 * ignored. The bytecode generation will always optimized it out.
881 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unreachableCode"
882 * - possible values: { "error", "warning", "ignore" }
883 * - default: "error"
885 * COMPILER / Reporting Invalid Import
886 * An import statement that cannot be resolved might optionally be reported
887 * as an error, as a warning or ignored.
888 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.invalidImport"
889 * - possible values: { "error", "warning", "ignore" }
890 * - default: "error"
892 * COMPILER / Reporting Attempt to Override Package-Default Method
893 * A package default method is not visible in a different package, and thus
894 * cannot be overridden. When enabling this option, the compiler will signal
895 * such scenarii either as an error or a warning.
896 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
897 * - possible values: { "error", "warning", "ignore" }
898 * - default: "warning"
900 * COMPILER / Reporting Method With Constructor Name
901 * Naming a method with a constructor name is generally considered poor
902 * style programming. When enabling this option, the compiler will signal such
903 * scenarii either as an error or a warning.
904 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.methodWithConstructorName"
905 * - possible values: { "error", "warning", "ignore" }
906 * - default: "warning"
908 * COMPILER / Reporting Deprecation
909 * When enabled, the compiler will signal use of deprecated API either as an
910 * error or a warning.
911 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecation"
912 * - possible values: { "error", "warning", "ignore" }
913 * - default: "warning"
915 * COMPILER / Reporting Deprecation Inside Deprecated Code
916 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
917 * The severity of the problem is controlled with option "org.phpeclipse.phpdt.core.compiler.problem.deprecation".
918 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
919 * - possible values: { "enabled", "disabled" }
920 * - default: "disabled"
922 * COMPILER / Reporting Hidden Catch Block
923 * Locally to a try statement, some catch blocks may hide others , e.g.
924 * try { throw new java.io.CharConversionException();
925 * } catch (java.io.CharConversionException e) {
926 * } catch (java.io.IOException e) {}.
927 * When enabling this option, the compiler will issue an error or a warning for hidden
928 * catch blocks corresponding to checked exceptions
929 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.hiddenCatchBlock"
930 * - possible values: { "error", "warning", "ignore" }
931 * - default: "warning"
933 * COMPILER / Reporting Unused Local
934 * When enabled, the compiler will issue an error or a warning for unused local
935 * variables (i.e. variables never read from)
936 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedLocal"
937 * - possible values: { "error", "warning", "ignore" }
938 * - default: "ignore"
940 * COMPILER / Reporting Unused Parameter
941 * When enabled, the compiler will issue an error or a warning for unused method
942 * parameters (i.e. parameters never read from)
943 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedParameter"
944 * - possible values: { "error", "warning", "ignore" }
945 * - default: "ignore"
947 * COMPILER / Reporting Unused Import
948 * When enabled, the compiler will issue an error or a warning for unused import
950 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedImport"
951 * - possible values: { "error", "warning", "ignore" }
952 * - default: "warning"
954 * COMPILER / Reporting Synthetic Access Emulation
955 * When enabled, the compiler will issue an error or a warning whenever it emulates
956 * access to a non-accessible member of an enclosing type. Such access can have
957 * performance implications.
958 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.syntheticAccessEmulation"
959 * - possible values: { "error", "warning", "ignore" }
960 * - default: "ignore"
962 * COMPILER / Reporting Non-Externalized String Literal
963 * When enabled, the compiler will issue an error or a warning for non externalized
964 * String literal (i.e. non tagged with //$NON-NLS-<n>$).
965 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
966 * - possible values: { "error", "warning", "ignore" }
967 * - default: "ignore"
969 * COMPILER / Reporting Usage of 'assert' Identifier
970 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
971 * used as an identifier (reserved keyword in 1.4)
972 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.assertIdentifier"
973 * - possible values: { "error", "warning", "ignore" }
974 * - default: "ignore"
976 * COMPILER / Reporting Usage of expression receiver on static invocation/field access
977 * When enabled, the compiler will issue an error or a warning whenever a static field
978 * or method is accessed with an expression receiver.
979 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.staticAccessReceiver"
980 * - possible values: { "error", "warning", "ignore" }
981 * - default: "warning"
983 * COMPILER / Reporting Assignment with no effect
984 * When enabled, the compiler will issue an error or a warning whenever an assignment
985 * has no effect (e.g 'x = x').
986 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.noEffectAssignment"
987 * - possible values: { "error", "warning", "ignore" }
988 * - default: "warning"
990 * COMPILER / Setting Source Compatibility Mode
991 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
992 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
993 * level should be set to "1.4" and the compliance mode should be "1.4".
994 * - option id: "org.phpeclipse.phpdt.core.compiler.source"
995 * - possible values: { "1.3", "1.4" }
996 * - default: "1.3"
998 * COMPILER / Setting Compliance Level
999 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
1000 * should not go beyond "1.3" level.
1001 * - option id: "org.phpeclipse.phpdt.core.compiler.compliance"
1002 * - possible values: { "1.3", "1.4" }
1003 * - default: "1.3"
1005 * COMPILER / Maximum number of problems reported per compilation unit
1006 * Specify the maximum number of problems reported on each compilation unit.
1007 * - option id: "org.phpeclipse.phpdt.core.compiler.maxProblemPerUnit"
1008 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
1009 * - default: "100"
1011 * COMPILER / Define the Automatic Task Tags
1012 * When the tag is non empty, the compiler will issue a task marker whenever it encounters
1013 * one of the corresponding tag inside any comment in Java source code.
1014 * Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed.
1015 * - option id: "org.phpeclipse.phpdt.core.compiler.taskTags"
1016 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card
1017 * - default: ""
1018 * COMPILER / Define the Automatic Task Priorities
1019 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
1020 * of the task markers issued by the compiler.
1021 * If the default is specified, the priority of each task marker is "NORMAL".
1022 * - option id: "org.phpeclipse.phpdt.core.compiler.taskPriorities"
1023 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
1024 * - default: ""
1026 * BUILDER / Specifying Filters for Resource Copying Control
1027 * Allow to specify some filters to control the resource copy process.
1028 * - option id: "org.phpeclipse.phpdt.core.builder.resourceCopyExclusionFilter"
1029 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
1030 * or the name of a folder which ends with '/'
1031 * - default: ""
1033 * BUILDER / Abort if Invalid Classpath
1034 * Allow to toggle the builder to abort if the classpath is invalid
1035 * - option id: "org.phpeclipse.phpdt.core.builder.invalidClasspath"
1036 * - possible values: { "abort", "ignore" }
1037 * - default: "ignore"
1039 * BUILDER / Cleaning Output Folder(s)
1040 * Indicate whether the JavaBuilder is allowed to clean the output folders
1041 * when performing full build operations.
1042 * - option id: "org.phpeclipse.phpdt.core.builder.cleanOutputFolder"
1043 * - possible values: { "clean", "ignore" }
1044 * - default: "clean"
1046 * JAVACORE / Computing Project Build Order
1047 * Indicate whether JavaCore should enforce the project build order to be based on
1048 * the classpath prerequisite chain. When requesting to compute, this takes over
1049 * the platform default order (based on project references).
1050 * - option id: "org.phpeclipse.phpdt.core.computeJavaBuildOrder"
1051 * - possible values: { "compute", "ignore" }
1052 * - default: "ignore"
1054 * JAVACORE / Specify Default Source Encoding Format
1055 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
1056 * to 'ResourcesPlugin.getEncoding()'.
1057 * - option id: "org.phpeclipse.phpdt.core.encoding"
1058 * - possible values: { any of the supported encoding name}.
1059 * - default: <platform default>
1061 * JAVACORE / Reporting Incomplete Classpath
1062 * An entry on the classpath doesn't exist or is not visible (e.g. a referenced project is closed).
1063 * - option id: "org.phpeclipse.phpdt.core.incompleteClasspath"
1064 * - possible values: { "error", "warning"}
1065 * - default: "error"
1067 * JAVACORE / Reporting Classpath Cycle
1068 * A project is involved in a cycle.
1069 * - option id: "org.phpeclipse.phpdt.core.circularClasspath"
1070 * - possible values: { "error", "warning" }
1071 * - default: "error"
1073 * FORMATTER / Inserting New Line Before Opening Brace
1074 * When Insert, a new line is inserted before an opening brace, otherwise nothing
1076 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.openingBrace"
1077 * - possible values: { "insert", "do not insert" }
1078 * - default: "do not insert"
1080 * FORMATTER / Inserting New Line Inside Control Statement
1081 * When Insert, a new line is inserted between } and following else, catch, finally
1082 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.controlStatement"
1083 * - possible values: { "insert", "do not insert" }
1084 * - default: "do not insert"
1086 * FORMATTER / Clearing Blank Lines
1087 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
1088 * and all others removed.
1089 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.clearAll"
1090 * - possible values: { "clear all", "preserve one" }
1091 * - default: "preserve one"
1093 * FORMATTER / Inserting New Line Between Else/If
1094 * When Insert, a blank line is inserted between an else and an if when they are
1095 * contiguous. When choosing to not insert, else-if will be kept on the same
1096 * line when possible.
1097 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.elseIf"
1098 * - possible values: { "insert", "do not insert" }
1099 * - default: "do not insert"
1101 * FORMATTER / Inserting New Line In Empty Block
1102 * When insert, a line break is inserted between contiguous { and }, if } is not followed
1104 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.emptyBlock"
1105 * - possible values: { "insert", "do not insert" }
1106 * - default: "insert"
1108 * FORMATTER / Splitting Lines Exceeding Length
1109 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
1110 * disable line splitting
1111 * - option id: "org.phpeclipse.phpdt.core.formatter.lineSplit"
1112 * - possible values: "<n>", where n is zero or a positive integer
1113 * - default: "80"
1115 * FORMATTER / Compacting Assignment
1116 * Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space
1117 * is inserted before the assignment operator
1118 * - option id: "org.phpeclipse.phpdt.core.formatter.style.assignment"
1119 * - possible values: { "compact", "normal" }
1120 * - default: "normal"
1122 * FORMATTER / Defining Indentation Character
1123 * Either choose to indent with tab characters or spaces
1124 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.char"
1125 * - possible values: { "tab", "space" }
1126 * - default: "tab"
1128 * FORMATTER / Defining Space Indentation Length
1129 * When using spaces, set the amount of space characters to use for each
1131 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.size"
1132 * - possible values: "<n>", where n is a positive integer
1133 * - default: "4"
1135 * CODEASSIST / Activate Visibility Sensitive Completion
1136 * When active, completion doesn't show that you can not see
1137 * (e.g. you can not see private methods of a super class).
1138 * - option id: "org.phpeclipse.phpdt.core.codeComplete.visibilityCheck"
1139 * - possible values: { "enabled", "disabled" }
1140 * - default: "disabled"
1142 * CODEASSIST / Automatic Qualification of Implicit Members
1143 * When active, completion automatically qualifies completion on implicit
1144 * field references and message expressions.
1145 * - option id: "org.phpeclipse.phpdt.core.codeComplete.forceImplicitQualification"
1146 * - possible values: { "enabled", "disabled" }
1147 * - default: "disabled"
1149 * CODEASSIST / Define the Prefixes for Field Name
1150 * When the prefixes is non empty, completion for field name will begin with
1151 * one of the proposed prefixes.
1152 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldPrefixes"
1153 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1154 * - default: ""
1156 * CODEASSIST / Define the Prefixes for Static Field Name
1157 * When the prefixes is non empty, completion for static field name will begin with
1158 * one of the proposed prefixes.
1159 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldPrefixes"
1160 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1161 * - default: ""
1163 * CODEASSIST / Define the Prefixes for Local Variable Name
1164 * When the prefixes is non empty, completion for local variable name will begin with
1165 * one of the proposed prefixes.
1166 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localPrefixes"
1167 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1168 * - default: ""
1170 * CODEASSIST / Define the Prefixes for Argument Name
1171 * When the prefixes is non empty, completion for argument name will begin with
1172 * one of the proposed prefixes.
1173 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentPrefixes"
1174 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1175 * - default: ""
1177 * CODEASSIST / Define the Suffixes for Field Name
1178 * When the suffixes is non empty, completion for field name will end with
1179 * one of the proposed suffixes.
1180 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldSuffixes"
1181 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1182 * - default: ""
1184 * CODEASSIST / Define the Suffixes for Static Field Name
1185 * When the suffixes is non empty, completion for static field name will end with
1186 * one of the proposed suffixes.
1187 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldSuffixes"
1188 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1189 * - default: ""
1191 * CODEASSIST / Define the Suffixes for Local Variable Name
1192 * When the suffixes is non empty, completion for local variable name will end with
1193 * one of the proposed suffixes.
1194 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localSuffixes"
1195 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1196 * - default: ""
1198 * CODEASSIST / Define the Suffixes for Argument Name
1199 * When the suffixes is non empty, completion for argument name will end with
1200 * one of the proposed suffixes.
1201 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentSuffixes"
1202 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
1203 * - default: ""
1206 * @return a mutable table containing the default settings of all known options
1219 // public static Hashtable getDefaultOptions() {
1221 // Hashtable defaultOptions = new Hashtable(10);
1223 // // see #initializeDefaultPluginPreferences() for changing default
1225 // Preferences preferences = getPlugin().getPluginPreferences();
1226 // HashSet optionNames = OptionNames;
1228 // // get preferences set to their default
1229 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1230 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1231 // String propertyName = defaultPropertyNames[i];
1232 // if (optionNames.contains(propertyName)) {
1233 // defaultOptions.put(propertyName,
1234 // preferences.getDefaultString(propertyName));
1237 // // get preferences not set to their default
1238 // String[] propertyNames = preferences.propertyNames();
1239 // for (int i = 0; i < propertyNames.length; i++) {
1240 // String propertyName = propertyNames[i];
1241 // if (optionNames.contains(propertyName)) {
1242 // defaultOptions.put(propertyName,
1243 // preferences.getDefaultString(propertyName));
1246 // // get encoding through resource plugin
1247 // defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1249 // return defaultOptions;
1252 * Helper method for returning one option value only. Equivalent to
1253 * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
1254 * may answer <code>null</code> if this option does not exist.
1256 * For a complete description of the configurable options, see
1257 * <code>getDefaultOptions</code>.
1261 * the name of an option
1262 * @return the String value of a given option
1263 * @see JavaCore#getDefaultOptions
1266 // public static String getOption(String optionName) {
1268 // if (CORE_ENCODING.equals(optionName)) {
1269 // return ResourcesPlugin.getEncoding();
1271 // if (OptionNames.contains(optionName)) {
1272 // Preferences preferences = getPlugin().getPluginPreferences();
1273 // return preferences.getString(optionName).trim();
1278 * Returns the table of the current options. Initially, all options have
1279 * their default values, and this method returns a table that includes all
1282 * For a complete description of the configurable options, see
1283 * <code>getDefaultOptions</code>.
1286 * @return table of current settings of all options (key type:
1287 * <code>String</code>; value type: <code>String</code>)
1288 * @see JavaCore#getDefaultOptions
1290 // public static Hashtable getOptions() {
1292 // Hashtable options = new Hashtable(10);
1294 // // see #initializeDefaultPluginPreferences() for changing default
1296 // Plugin plugin = getPlugin();
1297 // if (plugin != null) {
1298 // Preferences preferences = getPlugin().getPluginPreferences();
1299 // HashSet optionNames = OptionNames;
1301 // // get preferences set to their default
1302 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1303 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1304 // String propertyName = defaultPropertyNames[i];
1305 // if (optionNames.contains(propertyName)) {
1306 // options.put(propertyName, preferences.getDefaultString(propertyName));
1309 // // get preferences not set to their default
1310 // String[] propertyNames = preferences.propertyNames();
1311 // for (int i = 0; i < propertyNames.length; i++) {
1312 // String propertyName = propertyNames[i];
1313 // if (optionNames.contains(propertyName)) {
1314 // options.put(propertyName, preferences.getString(propertyName).trim());
1317 // // get encoding through resource plugin
1318 // options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1323 * Sets the current table of options. All and only the options explicitly
1324 * included in the given table are remembered; all previous option settings
1325 * are forgotten, including ones not explicitly mentioned.
1327 * For a complete description of the configurable options, see
1328 * <code>getDefaultOptions</code>.
1332 * the new options (key type: <code>String</code>; value type:
1333 * <code>String</code>), or <code>null</code> to reset all
1334 * options to their default values
1335 * @see JavaCore#getDefaultOptions
1337 // public static void setOptions(Hashtable newOptions) {
1339 // // see #initializeDefaultPluginPreferences() for changing default
1341 // Preferences preferences = getPlugin().getPluginPreferences();
1343 // if (newOptions == null) {
1344 // newOptions = getDefaultOptions();
1346 // Enumeration keys = newOptions.keys();
1347 // while (keys.hasMoreElements()) {
1348 // String key = (String) keys.nextElement();
1349 // if (!OptionNames.contains(key))
1350 // continue; // unrecognized option
1351 // if (key.equals(CORE_ENCODING))
1352 // continue; // skipped, contributed by resource prefs
1353 // String value = (String) newOptions.get(key);
1354 // preferences.setValue(key, value);
1357 // // persist options
1358 // getPlugin().savePluginPreferences();
1360 public static IProject[] getPHPProjects() {
1361 List phpProjectsList = new ArrayList();
1362 IProject[] workspaceProjects = PHPeclipsePlugin.getWorkspace()
1363 .getRoot().getProjects();
1365 for (int i = 0; i < workspaceProjects.length; i++) {
1366 IProject iProject = workspaceProjects[i];
1367 if (isPHPProject(iProject))
1368 phpProjectsList.add(iProject);
1371 IProject[] phpProjects = new IProject[phpProjectsList.size()];
1372 return (IProject[]) phpProjectsList.toArray(phpProjects);
1375 // public static PHPProject getPHPProject(String name) {
1376 // IProject aProject =
1377 // PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
1378 // if (isPHPProject(aProject)) {
1379 // PHPProject thePHPProject = new PHPProject();
1380 // thePHPProject.setProject(aProject);
1381 // return thePHPProject;
1386 public static boolean isPHPProject(IProject aProject) {
1388 return aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID);
1389 } catch (CoreException e) {
1395 // public static PHPFile create(IFile aFile) {
1396 // if (PHPFile.EXTENSION.equalsIgnoreCase(aFile.getFileExtension()))
1397 // return new PHPFile(aFile);
1398 // if (PHPFile.EXTENSION1.equalsIgnoreCase(aFile.getFileExtension()))
1399 // return new PHPFile(aFile);
1400 // if (PHPFile.EXTENSION2.equalsIgnoreCase(aFile.getFileExtension()))
1401 // return new PHPFile(aFile);
1402 // if (PHPFile.EXTENSION3.equalsIgnoreCase(aFile.getFileExtension()))
1403 // return new PHPFile(aFile);
1404 // if (PHPFile.EXTENSION4.equalsIgnoreCase(aFile.getFileExtension()))
1405 // return new PHPFile(aFile);
1406 // if (PHPFile.EXTENSION5.equalsIgnoreCase(aFile.getFileExtension()))
1407 // return new PHPFile(aFile);
1412 // public static PHPProject create(IProject aProject) {
1415 // if (aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1416 // PHPProject project = new PHPProject();
1417 // project.setProject(aProject);
1420 // } catch (CoreException e) {
1421 // System.err.println("Exception occurred in PHPCore#create(IProject): " +
1428 public static void addPHPNature(IProject project, IProgressMonitor monitor)
1429 throws CoreException {
1430 if (!project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1431 IProjectDescription description = project.getDescription();
1432 String[] prevNatures = description.getNatureIds();
1433 String[] newNatures = new String[prevNatures.length + 1];
1434 System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
1435 newNatures[prevNatures.length] = PHPeclipsePlugin.PHP_NATURE_ID;
1436 description.setNatureIds(newNatures);
1437 project.setDescription(description, monitor);
1442 * Returns the single instance of the PHP core plug-in runtime class.
1444 * @return the single instance of the PHP core plug-in runtime class
1446 public static Plugin getPlugin() {
1447 return PHPeclipsePlugin.getDefault();
1451 * Runs the given action as an atomic Java model operation.
1453 * After running a method that modifies java elements, registered listeners
1454 * receive after-the-fact notification of what just transpired, in the form
1455 * of a element changed event. This method allows clients to call a number
1456 * of methods that modify java elements and only have element changed event
1457 * notifications reported at the end of the entire batch.
1460 * If this method is called outside the dynamic scope of another such call,
1461 * this method runs the action and then reports a single element changed
1462 * event describing the net effect of all changes done to java elements by
1466 * If this method is called in the dynamic scope of another such call, this
1467 * method simply runs the action.
1471 * the action to perform
1473 * a progress monitor, or <code>null</code> if progress
1474 * reporting and cancellation are not desired
1475 * @exception CoreException
1476 * if the operation failed.
1479 // public static void run(IWorkspaceRunnable action, IProgressMonitor
1480 // monitor) throws CoreException {
1481 // run(action, ResourcesPlugin.getWorkspace().getRoot(), monitor);
1484 * Runs the given action as an atomic Java model operation.
1486 * After running a method that modifies java elements, registered listeners
1487 * receive after-the-fact notification of what just transpired, in the form
1488 * of a element changed event. This method allows clients to call a number
1489 * of methods that modify java elements and only have element changed event
1490 * notifications reported at the end of the entire batch.
1493 * If this method is called outside the dynamic scope of another such call,
1494 * this method runs the action and then reports a single element changed
1495 * event describing the net effect of all changes done to java elements by
1499 * If this method is called in the dynamic scope of another such call, this
1500 * method simply runs the action.
1503 * The supplied scheduling rule is used to determine whether this operation
1504 * can be run simultaneously with workspace changes in other threads. See
1505 * <code>IWorkspace.run(...)</code> for more details.
1509 * the action to perform
1511 * the scheduling rule to use when running this operation, or
1512 * <code>null</code> if there are no scheduling restrictions
1513 * for this operation.
1515 * a progress monitor, or <code>null</code> if progress
1516 * reporting and cancellation are not desired
1517 * @exception CoreException
1518 * if the operation failed.
1521 // public static void run(IWorkspaceRunnable action, ISchedulingRule rule,
1522 // IProgressMonitor monitor) throws CoreException {
1523 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
1524 // if (workspace.isTreeLocked()) {
1525 // new BatchOperation(action).run(monitor);
1527 // // use IWorkspace.run(...) to ensure that a build will be done in
1529 // workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE,
1535 * Adds the given listener for changes to Java elements. Has no effect if an
1536 * identical listener is already registered.
1538 * This listener will only be notified during the POST_CHANGE resource
1539 * change notification and any reconcile operation (POST_RECONCILE). For
1540 * finer control of the notification, use
1541 * <code>addElementChangedListener(IElementChangedListener,int)</code>,
1542 * which allows to specify a different eventMask.
1544 * @see ElementChangedEvent
1548 public static void addElementChangedListener(
1549 IElementChangedListener listener) {
1550 addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE
1551 | ElementChangedEvent.POST_RECONCILE);
1555 * Adds the given listener for changes to Java elements. Has no effect if an
1556 * identical listener is already registered. After completion of this
1557 * method, the given listener will be registered for exactly the specified
1558 * events. If they were previously registered for other events, they will be
1561 * Once registered, a listener starts receiving notification of changes to
1562 * java elements in the model. The listener continues to receive
1563 * notifications until it is replaced or removed.
1566 * Listeners can listen for several types of event as defined in
1567 * <code>ElementChangeEvent</code>. Clients are free to register for any
1568 * number of event types however if they register for more than one, it is
1569 * their responsibility to ensure they correctly handle the case where the
1570 * same java element change shows up in multiple notifications. Clients are
1571 * guaranteed to receive only the events for which they are registered.
1577 * the bit-wise OR of all event types of interest to the listener
1578 * @see IElementChangedListener
1579 * @see ElementChangedEvent
1580 * @see #removeElementChangedListener(IElementChangedListener)
1583 public static void addElementChangedListener(
1584 IElementChangedListener listener, int eventMask) {
1585 JavaModelManager.getJavaModelManager().addElementChangedListener(
1586 listener, eventMask);
1590 * Configures the given marker attribute map for the given Java element.
1591 * Used for markers, which denote a Java element rather than a resource.
1594 * the mutable marker attribute map (key type:
1595 * <code>String</code>, value type: <code>String</code>)
1597 * the Java element for which the marker needs to be configured
1599 public static void addJavaElementMarkerAttributes(Map attributes,
1600 IJavaElement element) {
1601 // if (element instanceof IMember)
1602 // element = ((IMember) element).getClassFile();
1603 if (attributes != null && element != null)
1604 attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier());
1608 * Adds the given listener for POST_CHANGE resource change events to the Java core.
1609 * The listener is guarantied to be notified of the POST_CHANGE resource change event before
1610 * the Java core starts processing the resource change event itself.
1612 * Has no effect if an identical listener is already registered.
1615 * @param listener the listener
1616 * @see #removePreProcessingResourceChangedListener(IResourceChangeListener)
1619 public static void addPreProcessingResourceChangedListener(IResourceChangeListener listener) {
1620 JavaModelManager.getJavaModelManager().deltaState.addPreResourceChangedListener(listener);
1623 * Configures the given marker for the given Java element. Used for markers,
1624 * which denote a Java element rather than a resource.
1627 * the marker to be configured
1629 * the Java element for which the marker needs to be configured
1630 * @exception CoreException
1631 * if the <code>IMarker.setAttribute</code> on the marker
1634 public void configureJavaElementMarker(IMarker marker, IJavaElement element)
1635 throws CoreException {
1636 // if (element instanceof IMember)
1637 // element = ((IMember) element).getClassFile();
1638 if (marker != null && element != null)
1639 marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier());
1643 * Returns the Java model element corresponding to the given handle
1644 * identifier generated by <code>IJavaElement.getHandleIdentifier()</code>,
1645 * or <code>null</code> if unable to create the associated element.
1647 public static IJavaElement create(String handleIdentifier) {
1648 if (handleIdentifier == null) {
1652 return JavaModelManager.getJavaModelManager().getHandleFromMemento(
1654 } catch (JavaModelException e) {
1660 * Returns the Java model element corresponding to the given handle identifier
1661 * generated by <code>IJavaElement.getHandleIdentifier()</code>, or
1662 * <code>null</code> if unable to create the associated element.
1663 * If the returned Java element is an <code>ICompilationUnit</code>, its owner
1664 * is the given owner if such a working copy exists, otherwise the compilation unit
1665 * is a primary compilation unit.
1667 * @param handleIdentifier the given handle identifier
1668 * @param owner the owner of the returned compilation unit, ignored if the returned
1669 * element is not a compilation unit
1670 * @return the Java element corresponding to the handle identifier
1673 public static IJavaElement create(String handleIdentifier, WorkingCopyOwner owner) {
1674 if (handleIdentifier == null) {
1677 MementoTokenizer memento = new MementoTokenizer(handleIdentifier);
1678 JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel();
1679 return model.getHandleFromMemento(memento, owner);
1683 * Returns the Java element corresponding to the given file, or
1684 * <code>null</code> if unable to associate the given file with a Java
1688 * The file must be one of:
1690 * <li>a <code>.java</code> file - the element returned is the
1691 * corresponding <code>ICompilationUnit</code></li>
1692 * <li>a <code>.class</code> file - the element returned is the
1693 * corresponding <code>IClassFile</code></li>
1694 * <li>a <code>.jar</code> file - the element returned is the
1695 * corresponding <code>IPackageFragmentRoot</code></li>
1698 * Creating a Java element has the side effect of creating and opening all
1699 * of the element's parents if they are not yet open.
1703 * @return the Java element corresponding to the given file, or
1704 * <code>null</code> if unable to associate the given file with a
1707 public static IJavaElement create(IFile file) {
1708 return JavaModelManager.create(file, null);
1712 * Returns the package fragment or package fragment root corresponding to
1713 * the given folder, or <code>null</code> if unable to associate the given
1714 * folder with a Java element.
1716 * Note that a package fragment root is returned rather than a default
1719 * Creating a Java element has the side effect of creating and opening all
1720 * of the element's parents if they are not yet open.
1724 * @return the package fragment or package fragment root corresponding to
1725 * the given folder, or <code>null</code> if unable to associate
1726 * the given folder with a Java element
1728 public static IJavaElement create(IFolder folder) {
1729 return JavaModelManager.create(folder, null);
1733 * Returns the Java project corresponding to the given project.
1735 * Creating a Java Project has the side effect of creating and opening all
1736 * of the project's parents if they are not yet open.
1738 * Note that no check is done at this time on the existence or the java
1739 * nature of this project.
1743 * @return the Java project corresponding to the given project, null if the
1744 * given project is null
1746 public static IJavaProject create(IProject project) {
1747 if (project == null) {
1750 JavaModel javaModel = JavaModelManager.getJavaModelManager()
1752 return javaModel.getJavaProject(project);
1756 * Returns the Java element corresponding to the given resource, or
1757 * <code>null</code> if unable to associate the given resource with a Java
1760 * The resource must be one of:
1762 * <li>a project - the element returned is the corresponding
1763 * <code>IJavaProject</code></li>
1764 * <li>a <code>.java</code> file - the element returned is the
1765 * corresponding <code>ICompilationUnit</code></li>
1766 * <li>a <code>.class</code> file - the element returned is the
1767 * corresponding <code>IClassFile</code></li>
1768 * <li>a <code>.jar</code> file - the element returned is the
1769 * corresponding <code>IPackageFragmentRoot</code></li>
1770 * <li>a folder - the element returned is the corresponding
1771 * <code>IPackageFragmentRoot</code> or <code>IPackageFragment</code>
1773 * <li>the workspace root resource - the element returned is the
1774 * <code>IJavaModel</code></li>
1777 * Creating a Java element has the side effect of creating and opening all
1778 * of the element's parents if they are not yet open.
1781 * the given resource
1782 * @return the Java element corresponding to the given resource, or
1783 * <code>null</code> if unable to associate the given resource
1784 * with a Java element
1786 public static IJavaElement create(IResource resource) {
1787 return JavaModelManager.create(resource, null);
1791 * Returns the Java model.
1795 * @return the Java model, or <code>null</code> if the root is null
1797 public static IJavaModel create(IWorkspaceRoot root) {
1801 return JavaModelManager.getJavaModelManager().getJavaModel();
1805 * Creates and returns a class file element for the given
1806 * <code>.class</code> file. Returns <code>null</code> if unable to
1807 * recognize the class file.
1810 * the given <code>.class</code> file
1811 * @return a class file element for the given <code>.class</code> file, or
1812 * <code>null</code> if unable to recognize the class file
1814 //public static IClassFile createClassFileFrom(IFile file) {
1815 // return JavaModelManager.createClassFileFrom(file, null);
1818 * Creates and returns a compilation unit element for the given
1819 * <code>.java</code> file. Returns <code>null</code> if unable to
1820 * recognize the compilation unit.
1823 * the given <code>.java</code> file
1824 * @return a compilation unit element for the given <code>.java</code>
1825 * file, or <code>null</code> if unable to recognize the
1828 public static ICompilationUnit createCompilationUnitFrom(IFile file) {
1829 return JavaModelManager.createCompilationUnitFrom(file, null);
1833 * Creates and returns a handle for the given JAR file. The Java model
1834 * associated with the JAR's project may be created as a side effect.
1837 * the given JAR file
1838 * @return a handle for the given JAR file, or <code>null</code> if unable
1839 * to create a JAR package fragment root. (for example, if the JAR
1840 * file represents a non-Java resource)
1842 //public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile
1844 // return JavaModelManager.createJarPackageFragmentRootFrom(file, null);
1847 * Answers the project specific value for a given classpath container. In
1848 * case this container path could not be resolved, then will answer
1849 * <code>null</code>. Both the container path and the project context are
1850 * supposed to be non-null.
1852 * The containerPath is a formed by a first ID segment followed with extra
1853 * segments, which can be used as additional hints for resolution. If no
1854 * container was ever recorded for this container path onto this project
1855 * (using <code>setClasspathContainer</code>, then a
1856 * <code>ClasspathContainerInitializer</code> will be activated if any was
1857 * registered for this container ID onto the extension point
1858 * "net.sourceforge.phpdt.core.classpathContainerInitializer".
1860 * There is no assumption that the returned container must answer the exact
1861 * same containerPath when requested
1862 * <code>IClasspathContainer#getPath</code>. Indeed, the containerPath is
1863 * just an indication for resolving it to an actual container object.
1865 * Classpath container values are persisted locally to the workspace, but
1866 * are not preserved from a session to another. It is thus highly
1867 * recommended to register a <code>ClasspathContainerInitializer</code>
1868 * for each referenced container (through the extension point
1869 * "net.sourceforge.phpdt.core.ClasspathContainerInitializer").
1872 * @param containerPath
1873 * the name of the container, which needs to be resolved
1875 * a specific project in which the container is being resolved
1876 * @return the corresponding classpath container or <code>null</code> if
1877 * unable to find one.
1879 * @exception JavaModelException
1880 * if an exception occurred while resolving the container, or
1881 * if the resolved container contains illegal entries
1882 * (contains CPE_CONTAINER entries or null entries).
1884 * @see ClasspathContainerInitializer
1885 * @see IClasspathContainer
1886 * @see #setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[],
1890 //public static IClasspathContainer getClasspathContainer(final IPath
1891 // containerPath, final IJavaProject project) throws JavaModelException {
1893 // IClasspathContainer container = JavaModelManager.containerGet(project,
1895 // if (container == JavaModelManager.ContainerInitializationInProgress)
1896 // return null; // break cycle
1898 // if (container == null){
1899 // final ClasspathContainerInitializer initializer =
1900 // JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
1901 // if (initializer != null){
1902 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1903 // System.out.println("CPContainer INIT - triggering initialization of:
1904 // ["+project.getElementName()+"] " + containerPath + " using initializer:
1905 // "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
1906 // new Exception("FAKE exception for dumping current CPContainer
1907 // (["+project.getElementName()+"] "+ containerPath+ ")INIT invocation stack
1908 // trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
1910 // JavaModelManager.containerPut(project, containerPath,
1911 // JavaModelManager.ContainerInitializationInProgress); // avoid
1912 // initialization cycles
1913 // boolean ok = false;
1915 // // wrap initializer call with Safe runnable in case initializer would be
1916 // causing some grief
1917 // Platform.run(new ISafeRunnable() {
1918 // public void handleException(Throwable exception) {
1919 // ProjectPrefUtil.log(exception, "Exception occurred in classpath container
1920 // initializer: "+initializer); //$NON-NLS-1$
1922 // public void run() throws Exception {
1923 // initializer.initialize(containerPath, project);
1927 // // retrieve value (if initialization was successful)
1928 // container = JavaModelManager.containerGet(project, containerPath);
1929 // if (container == JavaModelManager.ContainerInitializationInProgress)
1930 // return null; // break cycle
1933 // if (!ok) JavaModelManager.containerPut(project, containerPath, null); //
1936 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1937 // System.out.print("CPContainer INIT - after resolution:
1938 // ["+project.getElementName()+"] " + containerPath + " --> ");
1939 // //$NON-NLS-2$//$NON-NLS-1$//$NON-NLS-3$
1940 // if (container != null){
1941 // System.out.print("container: "+container.getDescription()+" {");
1942 // //$NON-NLS-2$//$NON-NLS-1$
1943 // IClasspathEntry[] entries = container.getClasspathEntries();
1944 // if (entries != null){
1945 // for (int i = 0; i < entries.length; i++){
1946 // if (i > 0) System.out.println(", ");//$NON-NLS-1$
1947 // System.out.println(entries[i]);
1950 // System.out.println("}");//$NON-NLS-1$
1952 // System.out.println("{unbound}");//$NON-NLS-1$
1956 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1957 // System.out.println("CPContainer INIT - no initializer found for:
1958 // "+project.getElementName()+"] " + containerPath); //$NON-NLS-1$
1963 // return container;
1966 * Helper method finding the classpath container initializer registered for
1967 * a given classpath container ID or <code>null</code> if none was found
1968 * while iterating over the contributions to extension point to the
1969 * extension point "net.sourceforge.phpdt.core.classpathContainerInitializer".
1971 * A containerID is the first segment of any container path, used to
1972 * identify the registered container initializer.
1976 * a containerID identifying a registered initializer
1977 * @return ClasspathContainerInitializer - the registered classpath
1978 * container initializer or <code>null</code> if none was found.
1981 //public static ClasspathContainerInitializer
1982 // getClasspathContainerInitializer(String containerID){
1984 // Plugin jdtCorePlugin = JavaCore.getPlugin();
1985 // if (jdtCorePlugin == null) return null;
1987 // IExtensionPoint extension =
1988 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID);
1989 // if (extension != null) {
1990 // IExtension[] extensions = extension.getExtensions();
1991 // for(int i = 0; i < extensions.length; i++){
1992 // IConfigurationElement [] configElements =
1993 // extensions[i].getConfigurationElements();
1994 // for(int j = 0; j < configElements.length; j++){
1995 // String initializerID = configElements[j].getAttribute("id");
1997 // if (initializerID != null && initializerID.equals(containerID)){
1998 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
1999 // System.out.println("CPContainer INIT - found initializer: "+containerID
2001 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
2004 // Object execExt = configElements[j].createExecutableExtension("class");
2006 // if (execExt instanceof ClasspathContainerInitializer){
2007 // return (ClasspathContainerInitializer)execExt;
2009 // } catch(CoreException e) {
2018 * Returns the path held in the given classpath variable. Returns <node>null
2019 * </code> if unable to bind.
2021 * Classpath variable values are persisted locally to the workspace, and are
2022 * preserved from session to session.
2024 * Note that classpath variables can be contributed registered initializers
2025 * for, using the extension point
2026 * "net.sourceforge.phpdt.core.classpathVariableInitializer". If an initializer is
2027 * registered for a variable, its persisted value will be ignored: its
2028 * initializer will thus get the opportunity to rebind the variable
2029 * differently on each session.
2031 * @param variableName
2032 * the name of the classpath variable
2033 * @return the path, or <code>null</code> if none
2034 * @see #setClasspathVariable
2036 public static IPath getClasspathVariable(final String variableName) {
2038 IPath variablePath = JavaModelManager.variableGet(variableName);
2039 if (variablePath == JavaModelManager.VariableInitializationInProgress)
2040 return null; // break cycle
2042 if (variablePath != null) {
2043 return variablePath;
2046 // even if persisted value exists, initializer is given priority, only
2047 // if no initializer is found the persisted value is reused
2048 // final ClasspathVariableInitializer initializer =
2049 // PHPCore.getClasspathVariableInitializer(variableName);
2050 // if (initializer != null){
2051 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2052 // System.out.println("CPVariable INIT - triggering initialization of: "
2053 // + variableName+ " using initializer: "+ initializer); //$NON-NLS-1$
2055 // new Exception("FAKE exception for dumping current CPVariable
2056 // ("+variableName+ ")INIT invocation stack trace").printStackTrace();
2057 // //$NON-NLS-1$//$NON-NLS-2$
2059 // JavaModelManager.variablePut(variableName,
2060 // JavaModelManager.VariableInitializationInProgress); // avoid
2061 // initialization cycles
2062 // boolean ok = false;
2064 // // wrap initializer call with Safe runnable in case initializer would
2065 // be causing some grief
2066 // Platform.run(new ISafeRunnable() {
2067 // public void handleException(Throwable exception) {
2068 // ProjectPrefUtil.log(exception, "Exception occurred in classpath variable
2069 // initializer: "+initializer+" while initializing variable:
2070 // "+variableName); //$NON-NLS-1$ //$NON-NLS-2$
2072 // public void run() throws Exception {
2073 // initializer.initialize(variableName);
2076 // variablePath = (IPath) JavaModelManager.variableGet(variableName); //
2077 // initializer should have performed side-effect
2078 // if (variablePath ==
2079 // JavaModelManager.VariableInitializationInProgress) return null; //
2080 // break cycle (initializer did not init or reentering call)
2081 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2082 // System.out.println("CPVariable INIT - after initialization: " +
2083 // variableName + " --> " + variablePath); //$NON-NLS-2$//$NON-NLS-1$
2087 // if (!ok) JavaModelManager.variablePut(variableName, null); // flush
2091 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2092 // System.out.println("CPVariable INIT - no initializer found for: " +
2093 // variableName); //$NON-NLS-1$
2096 return variablePath;
2100 * Helper method finding the classpath variable initializer registered for a
2101 * given classpath variable name or <code>null</code> if none was found
2102 * while iterating over the contributions to extension point to the
2103 * extension point "net.sourceforge.phpdt.core.classpathVariableInitializer".
2108 * @return ClasspathVariableInitializer - the registered classpath variable
2109 * initializer or <code>null</code> if none was found.
2112 public static ClasspathVariableInitializer getClasspathVariableInitializer(
2115 Plugin jdtCorePlugin = JavaCore.getPlugin();
2116 if (jdtCorePlugin == null)
2119 // IExtensionPoint extension =
2120 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID);
2121 // if (extension != null) {
2122 // IExtension[] extensions = extension.getExtensions();
2123 // for(int i = 0; i < extensions.length; i++){
2124 // IConfigurationElement [] configElements =
2125 // extensions[i].getConfigurationElements();
2126 // for(int j = 0; j < configElements.length; j++){
2128 // String varAttribute = configElements[j].getAttribute("variable");
2130 // if (variable.equals(varAttribute)) {
2131 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
2132 // System.out.println("CPVariable INIT - found initializer: "+variable+"
2134 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
2137 // configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
2138 // if (execExt instanceof ClasspathVariableInitializer){
2139 // return (ClasspathVariableInitializer)execExt;
2142 // } catch(CoreException e){
2151 * Returns the names of all known classpath variables.
2153 * Classpath variable values are persisted locally to the workspace, and are
2154 * preserved from session to session.
2157 * @return the list of classpath variable names
2158 * @see #setClasspathVariable
2160 //public static String[] getClasspathVariableNames() {
2161 // return JavaModelManager.variableNames();
2164 * Returns a table of all known configurable options with their default
2165 * values. These options allow to configure the behaviour of the underlying
2166 * components. The client may safely use the result as a template that they
2167 * can modify and then pass to <code>setOptions</code>.
2169 * Helper constants have been defined on JavaCore for each of the option ID
2170 * and their possible constant values.
2172 * Note: more options might be added in further releases.
2176 * RECOGNIZED OPTIONS:
2177 * COMPILER / Generating Local Variable Debug Attribute
2178 * When generated, this attribute will enable local variable names
2179 * to be displayed in debugger, only in place where variables are
2180 * definitely assigned (.class file is then bigger)
2181 * - option id: "net.sourceforge.phpdt.core.compiler.debug.localVariable"
2182 * - possible values: { "generate", "do not generate" }
2183 * - default: "generate"
2185 * COMPILER / Generating Line Number Debug Attribute
2186 * When generated, this attribute will enable source code highlighting in debugger
2187 * (.class file is then bigger).
2188 * - option id: "net.sourceforge.phpdt.core.compiler.debug.lineNumber"
2189 * - possible values: { "generate", "do not generate" }
2190 * - default: "generate"
2192 * COMPILER / Generating Source Debug Attribute
2193 * When generated, this attribute will enable the debugger to present the
2194 * corresponding source code.
2195 * - option id: "net.sourceforge.phpdt.core.compiler.debug.sourceFile"
2196 * - possible values: { "generate", "do not generate" }
2197 * - default: "generate"
2199 * COMPILER / Preserving Unused Local Variables
2200 * Unless requested to preserve unused local variables (that is, never read), the
2201 * compiler will optimize them out, potentially altering debugging
2202 * - option id: "net.sourceforge.phpdt.core.compiler.codegen.unusedLocal"
2203 * - possible values: { "preserve", "optimize out" }
2204 * - default: "preserve"
2206 * COMPILER / Defining Target Java Platform
2207 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
2208 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
2209 * - option id: "net.sourceforge.phpdt.core.compiler.codegen.targetPlatform"
2210 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
2211 * - default: "1.1"
2213 * COMPILER / Reporting Unreachable Code
2214 * Unreachable code can optionally be reported as an error, warning or simply
2215 * ignored. The bytecode generation will always optimized it out.
2216 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unreachableCode"
2217 * - possible values: { "error", "warning", "ignore" }
2218 * - default: "error"
2220 * COMPILER / Reporting Invalid Import
2221 * An import statement that cannot be resolved might optionally be reported
2222 * as an error, as a warning or ignored.
2223 * - option id: "net.sourceforge.phpdt.core.compiler.problem.invalidImport"
2224 * - possible values: { "error", "warning", "ignore" }
2225 * - default: "error"
2227 * COMPILER / Reporting Attempt to Override Package-Default Method
2228 * A package default method is not visible in a different package, and thus
2229 * cannot be overridden. When enabling this option, the compiler will signal
2230 * such scenarii either as an error or a warning.
2231 * - option id: "net.sourceforge.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
2232 * - possible values: { "error", "warning", "ignore" }
2233 * - default: "warning"
2235 * COMPILER / Reporting Method With Constructor Name
2236 * Naming a method with a constructor name is generally considered poor
2237 * style programming. When enabling this option, the compiler will signal such
2238 * scenarii either as an error or a warning.
2239 * - option id: "net.sourceforge.phpdt.core.compiler.problem.methodWithConstructorName"
2240 * - possible values: { "error", "warning", "ignore" }
2241 * - default: "warning"
2243 * COMPILER / Reporting Deprecation
2244 * When enabled, the compiler will signal use of deprecated API either as an
2245 * error or a warning.
2246 * - option id: "net.sourceforge.phpdt.core.compiler.problem.deprecation"
2247 * - possible values: { "error", "warning", "ignore" }
2248 * - default: "warning"
2250 * COMPILER / Reporting Deprecation Inside Deprecated Code
2251 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
2252 * The severity of the problem is controlled with option "net.sourceforge.phpdt.core.compiler.problem.deprecation".
2253 * - option id: "net.sourceforge.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
2254 * - possible values: { "enabled", "disabled" }
2255 * - default: "disabled"
2257 * COMPILER / Reporting Hidden Catch Block
2258 * Locally to a try statement, some catch blocks may hide others . For example,
2259 * try { throw new java.io.CharConversionException();
2260 * } catch (java.io.CharConversionException e) {
2261 * } catch (java.io.IOException e) {}.
2262 * When enabling this option, the compiler will issue an error or a warning for hidden
2263 * catch blocks corresponding to checked exceptions
2264 * - option id: "net.sourceforge.phpdt.core.compiler.problem.hiddenCatchBlock"
2265 * - possible values: { "error", "warning", "ignore" }
2266 * - default: "warning"
2268 * COMPILER / Reporting Unused Local
2269 * When enabled, the compiler will issue an error or a warning for unused local
2270 * variables (that is, variables never read from)
2271 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedLocal"
2272 * - possible values: { "error", "warning", "ignore" }
2273 * - default: "ignore"
2275 * COMPILER / Reporting Unused Parameter
2276 * When enabled, the compiler will issue an error or a warning for unused method
2277 * parameters (that is, parameters never read from)
2278 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedParameter"
2279 * - possible values: { "error", "warning", "ignore" }
2280 * - default: "ignore"
2282 * COMPILER / Reporting Unused Parameter if Implementing Abstract Method
2283 * When enabled, the compiler will signal unused parameters in abstract method implementations.
2284 * The severity of the problem is controlled with option "net.sourceforge.phpdt.core.compiler.problem.unusedParameter".
2285 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"
2286 * - possible values: { "enabled", "disabled" }
2287 * - default: "disabled"
2289 * COMPILER / Reporting Unused Parameter if Overriding Concrete Method
2290 * When enabled, the compiler will signal unused parameters in methods overriding concrete ones.
2291 * The severity of the problem is controlled with option "net.sourceforge.phpdt.core.compiler.problem.unusedParameter".
2292 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"
2293 * - possible values: { "enabled", "disabled" }
2294 * - default: "disabled"
2296 * COMPILER / Reporting Unused Import
2297 * When enabled, the compiler will issue an error or a warning for unused import
2299 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedImport"
2300 * - possible values: { "error", "warning", "ignore" }
2301 * - default: "warning"
2303 * COMPILER / Reporting Unused Private Members
2304 * When enabled, the compiler will issue an error or a warning whenever a private
2305 * method or field is declared but never used within the same unit.
2306 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedPrivateMember"
2307 * - possible values: { "error", "warning", "ignore" }
2308 * - default: "ignore"
2310 * COMPILER / Reporting Synthetic Access Emulation
2311 * When enabled, the compiler will issue an error or a warning whenever it emulates
2312 * access to a non-accessible member of an enclosing type. Such access can have
2313 * performance implications.
2314 * - option id: "net.sourceforge.phpdt.core.compiler.problem.syntheticAccessEmulation"
2315 * - possible values: { "error", "warning", "ignore" }
2316 * - default: "ignore"
2318 * COMPILER / Reporting Non-Externalized String Literal
2319 * When enabled, the compiler will issue an error or a warning for non externalized
2320 * String literal (that is, not tagged with //$NON-NLS-<n>$).
2321 * - option id: "net.sourceforge.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
2322 * - possible values: { "error", "warning", "ignore" }
2323 * - default: "ignore"
2325 * COMPILER / Reporting Usage of 'assert' Identifier
2326 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
2327 * used as an identifier (reserved keyword in 1.4)
2328 * - option id: "net.sourceforge.phpdt.core.compiler.problem.assertIdentifier"
2329 * - possible values: { "error", "warning", "ignore" }
2330 * - default: "ignore"
2332 * COMPILER / Reporting Non-Static Reference to a Static Member
2333 * When enabled, the compiler will issue an error or a warning whenever a static field
2334 * or method is accessed with an expression receiver. A reference to a static member should
2335 * be qualified with a type name.
2336 * - option id: "net.sourceforge.phpdt.core.compiler.problem.staticAccessReceiver"
2337 * - possible values: { "error", "warning", "ignore" }
2338 * - default: "warning"
2340 * COMPILER / Reporting Assignment with no Effect
2341 * When enabled, the compiler will issue an error or a warning whenever an assignment
2342 * has no effect (e.g 'x = x').
2343 * - option id: "net.sourceforge.phpdt.core.compiler.problem.noEffectAssignment"
2344 * - possible values: { "error", "warning", "ignore" }
2345 * - default: "warning"
2347 * COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods
2348 * When enabled, the compiler will issue an error or a warning whenever an interface
2349 * defines a method incompatible with a non-inherited Object method. Until this conflict
2350 * is resolved, such an interface cannot be implemented, For example,
2354 * - option id: "net.sourceforge.phpdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"
2355 * - possible values: { "error", "warning", "ignore" }
2356 * - default: "warning"
2358 * COMPILER / Reporting Usage of char[] Expressions in String Concatenations
2359 * When enabled, the compiler will issue an error or a warning whenever a char[] expression
2360 * is used in String concatenations (for example, "hello" + new char[]{'w','o','r','l','d'}).
2361 * - option id: "net.sourceforge.phpdt.core.compiler.problem.noImplicitStringConversion"
2362 * - possible values: { "error", "warning", "ignore" }
2363 * - default: "warning"
2365 * COMPILER / Setting Source Compatibility Mode
2366 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
2367 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
2368 * level should be set to "1.4" and the compliance mode should be "1.4".
2369 * - option id: "net.sourceforge.phpdt.core.compiler.source"
2370 * - possible values: { "1.3", "1.4" }
2371 * - default: "1.3"
2373 * COMPILER / Setting Compliance Level
2374 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
2375 * should not go beyond "1.3" level.
2376 * - option id: "net.sourceforge.phpdt.core.compiler.compliance"
2377 * - possible values: { "1.3", "1.4" }
2378 * - default: "1.3"
2380 * COMPILER / Maximum number of problems reported per compilation unit
2381 * Specify the maximum number of problems reported on each compilation unit.
2382 * - option id: "net.sourceforge.phpdt.core.compiler.maxProblemPerUnit"
2383 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
2384 * - default: "100"
2386 * COMPILER / Define the Automatic Task Tags
2387 * When the tag list is not empty, the compiler will issue a task marker whenever it encounters
2388 * one of the corresponding tag inside any comment in Java source code.
2389 * Generated task messages will include the tag, and range until the next line separator or comment ending.
2390 * Note that tasks messages are trimmed.
2391 * - option id: "net.sourceforge.phpdt.core.compiler.taskTags"
2392 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card or leading/trailing spaces
2393 * - default: ""
2395 * COMPILER / Define the Automatic Task Priorities
2396 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
2397 * of the task markers issued by the compiler.
2398 * If the default is specified, the priority of each task marker is "NORMAL".
2399 * - option id: "net.sourceforge.phpdt.core.compiler.taskPriorities"
2400 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
2401 * - default: ""
2403 * BUILDER / Specifying Filters for Resource Copying Control
2404 * Allow to specify some filters to control the resource copy process.
2405 * - option id: "net.sourceforge.phpdt.core.builder.resourceCopyExclusionFilter"
2406 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
2407 * or the name of a folder which ends with '/'
2408 * - default: ""
2410 * BUILDER / Abort if Invalid Classpath
2411 * Allow to toggle the builder to abort if the classpath is invalid
2412 * - option id: "net.sourceforge.phpdt.core.builder.invalidClasspath"
2413 * - possible values: { "abort", "ignore" }
2414 * - default: "abort"
2416 * BUILDER / Cleaning Output Folder(s)
2417 * Indicate whether the JavaBuilder is allowed to clean the output folders
2418 * when performing full build operations.
2419 * - option id: "net.sourceforge.phpdt.core.builder.cleanOutputFolder"
2420 * - possible values: { "clean", "ignore" }
2421 * - default: "clean"
2423 * BUILDER / Reporting Duplicate Resources
2424 * Indicate the severity of the problem reported when more than one occurrence
2425 * of a resource is to be copied into the output location.
2426 * - option id: "net.sourceforge.phpdt.core.builder.duplicateResourceTask"
2427 * - possible values: { "error", "warning" }
2428 * - default: "warning"
2430 * JAVACORE / Computing Project Build Order
2431 * Indicate whether JavaCore should enforce the project build order to be based on
2432 * the classpath prerequisite chain. When requesting to compute, this takes over
2433 * the platform default order (based on project references).
2434 * - option id: "net.sourceforge.phpdt.core.computeJavaBuildOrder"
2435 * - possible values: { "compute", "ignore" }
2436 * - default: "ignore"
2438 * JAVACORE / Specify Default Source Encoding Format
2439 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
2440 * to 'ResourcesPlugin.getEncoding()'.
2441 * - option id: "net.sourceforge.phpdt.core.encoding"
2442 * - possible values: { any of the supported encoding name}.
2443 * - default: <platform default>
2445 * JAVACORE / Reporting Incomplete Classpath
2446 * Indicate the severity of the problem reported when an entry on the classpath does not exist,
2447 * is not legite or is not visible (for example, a referenced project is closed).
2448 * - option id: "net.sourceforge.phpdt.core.incompleteClasspath"
2449 * - possible values: { "error", "warning"}
2450 * - default: "error"
2452 * JAVACORE / Reporting Classpath Cycle
2453 * Indicate the severity of the problem reported when a project is involved in a cycle.
2454 * - option id: "net.sourceforge.phpdt.core.circularClasspath"
2455 * - possible values: { "error", "warning" }
2456 * - default: "error"
2458 * JAVACORE / Enabling Usage of Classpath Exclusion Patterns
2459 * When disabled, no entry on a project classpath can be associated with
2460 * an exclusion pattern.
2461 * - option id: "net.sourceforge.phpdt.core.classpath.exclusionPatterns"
2462 * - possible values: { "enabled", "disabled" }
2463 * - default: "enabled"
2465 * JAVACORE / Enabling Usage of Classpath Multiple Output Locations
2466 * When disabled, no entry on a project classpath can be associated with
2467 * a specific output location, preventing thus usage of multiple output locations.
2468 * - option id: "net.sourceforge.phpdt.core.classpath.multipleOutputLocations"
2469 * - possible values: { "enabled", "disabled" }
2470 * - default: "enabled"
2472 * FORMATTER / Inserting New Line Before Opening Brace
2473 * When Insert, a new line is inserted before an opening brace, otherwise nothing
2475 * - option id: "net.sourceforge.phpdt.core.formatter.newline.openingBrace"
2476 * - possible values: { "insert", "do not insert" }
2477 * - default: "do not insert"
2479 * FORMATTER / Inserting New Line Inside Control Statement
2480 * When Insert, a new line is inserted between } and following else, catch, finally
2481 * - option id: "net.sourceforge.phpdt.core.formatter.newline.controlStatement"
2482 * - possible values: { "insert", "do not insert" }
2483 * - default: "do not insert"
2485 * FORMATTER / Clearing Blank Lines
2486 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
2487 * and all others removed.
2488 * - option id: "net.sourceforge.phpdt.core.formatter.newline.clearAll"
2489 * - possible values: { "clear all", "preserve one" }
2490 * - default: "preserve one"
2492 * FORMATTER / Inserting New Line Between Else/If
2493 * When Insert, a blank line is inserted between an else and an if when they are
2494 * contiguous. When choosing to not insert, else-if will be kept on the same
2495 * line when possible.
2496 * - option id: "net.sourceforge.phpdt.core.formatter.newline.elseIf"
2497 * - possible values: { "insert", "do not insert" }
2498 * - default: "do not insert"
2500 * FORMATTER / Inserting New Line In Empty Block
2501 * When insert, a line break is inserted between contiguous { and }, if } is not followed
2503 * - option id: "net.sourceforge.phpdt.core.formatter.newline.emptyBlock"
2504 * - possible values: { "insert", "do not insert" }
2505 * - default: "insert"
2507 * FORMATTER / Splitting Lines Exceeding Length
2508 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
2509 * disable line splitting
2510 * - option id: "net.sourceforge.phpdt.core.formatter.lineSplit"
2511 * - possible values: "<n>", where n is zero or a positive integer
2512 * - default: "80"
2514 * FORMATTER / Compacting Assignment
2515 * Assignments can be formatted asymmetrically, for example 'int x= 2;', when Normal, a space
2516 * is inserted before the assignment operator
2517 * - option id: "net.sourceforge.phpdt.core.formatter.style.assignment"
2518 * - possible values: { "compact", "normal" }
2519 * - default: "normal"
2521 * FORMATTER / Defining Indentation Character
2522 * Either choose to indent with tab characters or spaces
2523 * - option id: "net.sourceforge.phpdt.core.formatter.tabulation.char"
2524 * - possible values: { "tab", "space" }
2525 * - default: "tab"
2527 * FORMATTER / Defining Space Indentation Length
2528 * When using spaces, set the amount of space characters to use for each
2530 * - option id: "net.sourceforge.phpdt.core.formatter.tabulation.size"
2531 * - possible values: "<n>", where n is a positive integer
2532 * - default: "4"
2534 * FORMATTER / Inserting space in cast expression
2535 * When Insert, a space is added between the type and the expression in a cast expression.
2536 * - option id: "net.sourceforge.phpdt.core.formatter.space.castexpression"
2537 * - possible values: { "insert", "do not insert" }
2538 * - default: "insert"
2540 * CODEASSIST / Activate Visibility Sensitive Completion
2541 * When active, completion doesn't show that you can not see
2542 * (for example, you can not see private methods of a super class).
2543 * - option id: "net.sourceforge.phpdt.core.codeComplete.visibilityCheck"
2544 * - possible values: { "enabled", "disabled" }
2545 * - default: "disabled"
2547 * CODEASSIST / Automatic Qualification of Implicit Members
2548 * When active, completion automatically qualifies completion on implicit
2549 * field references and message expressions.
2550 * - option id: "net.sourceforge.phpdt.core.codeComplete.forceImplicitQualification"
2551 * - possible values: { "enabled", "disabled" }
2552 * - default: "disabled"
2554 * CODEASSIST / Define the Prefixes for Field Name
2555 * When the prefixes is non empty, completion for field name will begin with
2556 * one of the proposed prefixes.
2557 * - option id: "net.sourceforge.phpdt.core.codeComplete.fieldPrefixes"
2558 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2559 * - default: ""
2561 * CODEASSIST / Define the Prefixes for Static Field Name
2562 * When the prefixes is non empty, completion for static field name will begin with
2563 * one of the proposed prefixes.
2564 * - option id: "net.sourceforge.phpdt.core.codeComplete.staticFieldPrefixes"
2565 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2566 * - default: ""
2568 * CODEASSIST / Define the Prefixes for Local Variable Name
2569 * When the prefixes is non empty, completion for local variable name will begin with
2570 * one of the proposed prefixes.
2571 * - option id: "net.sourceforge.phpdt.core.codeComplete.localPrefixes"
2572 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2573 * - default: ""
2575 * CODEASSIST / Define the Prefixes for Argument Name
2576 * When the prefixes is non empty, completion for argument name will begin with
2577 * one of the proposed prefixes.
2578 * - option id: "net.sourceforge.phpdt.core.codeComplete.argumentPrefixes"
2579 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2580 * - default: ""
2582 * CODEASSIST / Define the Suffixes for Field Name
2583 * When the suffixes is non empty, completion for field name will end with
2584 * one of the proposed suffixes.
2585 * - option id: "net.sourceforge.phpdt.core.codeComplete.fieldSuffixes"
2586 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2587 * - default: ""
2589 * CODEASSIST / Define the Suffixes for Static Field Name
2590 * When the suffixes is non empty, completion for static field name will end with
2591 * one of the proposed suffixes.
2592 * - option id: "net.sourceforge.phpdt.core.codeComplete.staticFieldSuffixes"
2593 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2594 * - default: ""
2596 * CODEASSIST / Define the Suffixes for Local Variable Name
2597 * When the suffixes is non empty, completion for local variable name will end with
2598 * one of the proposed suffixes.
2599 * - option id: "net.sourceforge.phpdt.core.codeComplete.localSuffixes"
2600 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2601 * - default: ""
2603 * CODEASSIST / Define the Suffixes for Argument Name
2604 * When the suffixes is non empty, completion for argument name will end with
2605 * one of the proposed suffixes.
2606 * - option id: "net.sourceforge.phpdt.core.codeComplete.argumentSuffixes"
2607 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
2608 * - default: ""
2611 * @return a mutable table containing the default settings of all known options
2624 public static Hashtable getDefaultOptions() {
2626 Hashtable defaultOptions = new Hashtable(10);
2628 // see #initializeDefaultPluginPreferences() for changing default
2630 Preferences preferences = getPlugin().getPluginPreferences();
2631 HashSet optionNames = JavaModelManager.OptionNames;
2633 // get preferences set to their default
2634 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2635 for (int i = 0; i < defaultPropertyNames.length; i++) {
2636 String propertyName = defaultPropertyNames[i];
2637 if (optionNames.contains(propertyName)) {
2638 defaultOptions.put(propertyName, preferences
2639 .getDefaultString(propertyName));
2642 // get preferences not set to their default
2643 String[] propertyNames = preferences.propertyNames();
2644 for (int i = 0; i < propertyNames.length; i++) {
2645 String propertyName = propertyNames[i];
2646 if (optionNames.contains(propertyName)) {
2647 defaultOptions.put(propertyName, preferences
2648 .getDefaultString(propertyName));
2651 // get encoding through resource plugin
2652 defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2654 return defaultOptions;
2658 * Returns the single instance of the Java core plug-in runtime class.
2659 * Equivalent to <code>(JavaCore) getPlugin()</code>.
2661 * @return the single instance of the Java core plug-in runtime class
2663 public static PHPeclipsePlugin getJavaCore() {
2664 return (PHPeclipsePlugin) getPlugin();
2668 * Helper method for returning one option value only. Equivalent to
2669 * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
2670 * may answer <code>null</code> if this option does not exist.
2672 * For a complete description of the configurable options, see
2673 * <code>getDefaultOptions</code>.
2677 * the name of an option
2678 * @return the String value of a given option
2679 * @see JavaCore#getDefaultOptions
2682 public static String getOption(String optionName) {
2684 if (CORE_ENCODING.equals(optionName)) {
2685 return ResourcesPlugin.getEncoding();
2687 if (JavaModelManager.OptionNames.contains(optionName)) {
2688 Preferences preferences = getPlugin().getPluginPreferences();
2689 return preferences.getString(optionName).trim();
2695 * Returns the table of the current options. Initially, all options have
2696 * their default values, and this method returns a table that includes all
2699 * For a complete description of the configurable options, see
2700 * <code>getDefaultOptions</code>.
2703 * @return table of current settings of all options (key type:
2704 * <code>String</code>; value type: <code>String</code>)
2705 * @see JavaCore#getDefaultOptions
2707 public static Hashtable getOptions() {
2709 Hashtable options = new Hashtable(10);
2711 // see #initializeDefaultPluginPreferences() for changing default
2713 Plugin plugin = getPlugin();
2714 if (plugin != null) {
2715 Preferences preferences = getPlugin().getPluginPreferences();
2716 HashSet optionNames = JavaModelManager.OptionNames;
2718 // get preferences set to their default
2719 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2720 for (int i = 0; i < defaultPropertyNames.length; i++) {
2721 String propertyName = defaultPropertyNames[i];
2722 if (optionNames.contains(propertyName)) {
2723 options.put(propertyName, preferences
2724 .getDefaultString(propertyName));
2727 // get preferences not set to their default
2728 String[] propertyNames = preferences.propertyNames();
2729 for (int i = 0; i < propertyNames.length; i++) {
2730 String propertyName = propertyNames[i];
2731 if (optionNames.contains(propertyName)) {
2732 options.put(propertyName, preferences.getString(
2733 propertyName).trim());
2736 // get encoding through resource plugin
2737 options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2743 * This is a helper method, which returns the resolved classpath entry
2744 * denoted by a given entry (if it is a variable entry). It is obtained by
2745 * resolving the variable reference in the first segment. Returns <node>null
2746 * </code> if unable to resolve using the following algorithm:
2748 * <li>if variable segment cannot be resolved, returns <code>null</code>
2750 * <li>finds a project, JAR or binary folder in the workspace at the
2751 * resolved path location</li>
2752 * <li>if none finds an external JAR file or folder outside the workspace
2753 * at the resolved path location</li>
2754 * <li>if none returns <code>null</code></li>
2757 * Variable source attachment path and root path are also resolved and
2758 * recorded in the resulting classpath entry.
2760 * NOTE: This helper method does not handle classpath containers, for which
2761 * should rather be used <code>JavaCore#getClasspathContainer(IPath,
2762 * IJavaProject)</code>.
2766 * the given variable entry
2767 * @return the resolved library or project classpath entry, or <code>null
2768 * </code> if the given variable entry could not be resolved to a
2769 * valid classpath entry
2771 public static IClasspathEntry getResolvedClasspathEntry(
2772 IClasspathEntry entry) {
2774 if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
2777 IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
2778 IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath());
2779 if (resolvedPath == null)
2782 Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false);
2786 // inside the workspace
2787 if (target instanceof IResource) {
2788 IResource resolvedResource = (IResource) target;
2789 if (resolvedResource != null) {
2790 switch (resolvedResource.getType()) {
2792 case IResource.PROJECT:
2794 return JavaCore.newProjectEntry(resolvedPath, entry
2797 case IResource.FILE:
2798 // if (ProjectPrefUtil.isArchiveFileName(resolvedResource.getName())) {
2799 // // internal binary archive
2800 // return JavaCore.newLibraryEntry(
2802 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2803 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2804 // entry.isExported());
2808 case IResource.FOLDER:
2809 // internal binary folder
2810 // return JavaCore.newLibraryEntry(
2812 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2813 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2814 // entry.isExported());
2819 // outside the workspace
2820 if (target instanceof File) {
2821 File externalFile = (File) target;
2822 if (externalFile.isFile()) {
2823 String fileName = externalFile.getName().toLowerCase();
2824 // if (fileName.endsWith(".jar" //$NON-NLS-1$
2825 // ) || fileName.endsWith(".zip" //$NON-NLS-1$
2826 // )) { // external binary archive
2827 // return JavaCore.newLibraryEntry(
2829 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2830 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2831 // entry.isExported());
2833 } else { // external binary folder
2834 if (resolvedPath.isAbsolute()) {
2835 // return JavaCore.newLibraryEntry(
2837 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2838 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2839 // entry.isExported());
2847 * Resolve a variable path (helper method).
2849 * @param variablePath
2850 * the given variable path
2851 * @return the resolved variable path or <code>null</code> if none
2853 public static IPath getResolvedVariablePath(IPath variablePath) {
2855 if (variablePath == null)
2857 int count = variablePath.segmentCount();
2862 String variableName = variablePath.segment(0);
2863 IPath resolvedPath = JavaCore.getClasspathVariable(variableName);
2864 if (resolvedPath == null)
2867 // append path suffix
2869 resolvedPath = resolvedPath.append(variablePath
2870 .removeFirstSegments(1));
2872 return resolvedPath;
2876 * Answers the shared working copies currently registered for this buffer
2877 * factory. Working copies can be shared by several clients using the same
2878 * buffer factory,see <code>IWorkingCopy.getSharedWorkingCopy</code>.
2881 * the given buffer factory
2882 * @return the list of shared working copies for a given buffer factory
2886 public static IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory) {
2888 // if factory is null, default factory must be used
2889 if (factory == null)
2890 factory = BufferManager.getDefaultBufferManager()
2891 .getDefaultBufferFactory();
2892 Map sharedWorkingCopies = JavaModelManager.getJavaModelManager().sharedWorkingCopies;
2894 Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
2895 if (perFactoryWorkingCopies == null)
2896 return JavaModelManager.NoWorkingCopy;
2897 Collection copies = perFactoryWorkingCopies.values();
2898 IWorkingCopy[] result = new IWorkingCopy[copies.size()];
2899 copies.toArray(result);
2904 * Initializes the default preferences settings for this plug-in.
2906 public static void initializeDefaultPluginPreferences() {
2908 Preferences preferences = PHPeclipsePlugin.getDefault()
2909 .getPluginPreferences();
2910 HashSet optionNames = JavaModelManager.OptionNames;
2912 // Compiler settings
2913 preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
2914 optionNames.add(COMPILER_LOCAL_VARIABLE_ATTR);
2916 preferences.setDefault(COMPILER_LINE_NUMBER_ATTR, GENERATE);
2917 optionNames.add(COMPILER_LINE_NUMBER_ATTR);
2919 preferences.setDefault(COMPILER_SOURCE_FILE_ATTR, GENERATE);
2920 optionNames.add(COMPILER_SOURCE_FILE_ATTR);
2922 preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE);
2923 optionNames.add(COMPILER_CODEGEN_UNUSED_LOCAL);
2925 preferences.setDefault(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1);
2926 optionNames.add(COMPILER_CODEGEN_TARGET_PLATFORM);
2928 preferences.setDefault(COMPILER_PB_PHP_VAR_DEPRECATED, WARNING);
2929 optionNames.add(COMPILER_PB_PHP_VAR_DEPRECATED);
2930 preferences.setDefault(COMPILER_PB_PHP_KEYWORD, WARNING);
2931 optionNames.add(COMPILER_PB_PHP_KEYWORD);
2932 preferences.setDefault(COMPILER_PB_PHP_UPPERCASE_IDENTIFIER, IGNORE);
2933 optionNames.add(COMPILER_PB_PHP_UPPERCASE_IDENTIFIER);
2934 preferences.setDefault(COMPILER_PB_PHP_FILE_NOT_EXIST, WARNING);
2935 optionNames.add(COMPILER_PB_PHP_FILE_NOT_EXIST);
2936 preferences.setDefault(COMPILER_PB_UNREACHABLE_CODE, WARNING);
2937 optionNames.add(COMPILER_PB_UNREACHABLE_CODE);
2938 preferences.setDefault(COMPILER_PB_UNINITIALIZED_LOCAL_VARIABLE, WARNING);
2939 optionNames.add(COMPILER_PB_UNINITIALIZED_LOCAL_VARIABLE);
2941 preferences.setDefault(COMPILER_PB_INVALID_IMPORT, ERROR);
2942 optionNames.add(COMPILER_PB_INVALID_IMPORT);
2944 preferences.setDefault(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD,
2946 optionNames.add(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD);
2948 preferences.setDefault(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME,
2950 optionNames.add(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME);
2952 preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING);
2953 optionNames.add(COMPILER_PB_DEPRECATION);
2955 preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE,
2957 optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE);
2959 preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING);
2960 optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK);
2962 preferences.setDefault(COMPILER_PB_UNUSED_LOCAL, IGNORE);
2963 optionNames.add(COMPILER_PB_UNUSED_LOCAL);
2965 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE);
2966 optionNames.add(COMPILER_PB_UNUSED_PARAMETER);
2968 preferences.setDefault(
2969 COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT,
2972 .add(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT);
2976 COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE,
2978 optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE);
2980 preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING);
2981 optionNames.add(COMPILER_PB_UNUSED_IMPORT);
2983 preferences.setDefault(COMPILER_PB_UNUSED_PRIVATE_MEMBER, IGNORE);
2984 optionNames.add(COMPILER_PB_UNUSED_PRIVATE_MEMBER);
2986 preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE);
2987 optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION);
2989 preferences.setDefault(COMPILER_PB_NON_NLS_STRING_LITERAL, IGNORE);
2990 optionNames.add(COMPILER_PB_NON_NLS_STRING_LITERAL);
2992 preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE);
2993 optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER);
2995 preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING);
2996 optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER);
2998 preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING);
2999 optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT);
3001 preferences.setDefault(
3002 COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD,
3005 .add(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD);
3007 preferences.setDefault(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION,
3009 optionNames.add(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION);
3011 preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAG); //$NON-NLS-1$
3012 optionNames.add(COMPILER_TASK_TAGS);
3014 preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITY); //$NON-NLS-1$
3015 optionNames.add(COMPILER_TASK_PRIORITIES);
3017 preferences.setDefault(COMPILER_SOURCE, VERSION_1_3);
3018 optionNames.add(COMPILER_SOURCE);
3020 preferences.setDefault(COMPILER_COMPLIANCE, VERSION_1_3);
3021 optionNames.add(COMPILER_COMPLIANCE);
3023 preferences.setDefault(COMPILER_PB_MAX_PER_UNIT, "100"); //$NON-NLS-1$
3024 optionNames.add(COMPILER_PB_MAX_PER_UNIT);
3027 preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
3028 optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
3030 preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT);
3031 optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH);
3033 preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING);
3034 optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE);
3036 preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN);
3037 optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER);
3039 // JavaCore settings
3040 preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE);
3041 optionNames.add(CORE_JAVA_BUILD_ORDER);
3043 preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR);
3044 optionNames.add(CORE_CIRCULAR_CLASSPATH);
3046 preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR);
3047 optionNames.add(CORE_INCOMPLETE_CLASSPATH);
3049 preferences.setDefault(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS,
3051 optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS);
3053 preferences.setDefault(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS,
3055 optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS);
3057 // encoding setting comes from resource plug-in
3058 optionNames.add(CORE_ENCODING);
3060 // Formatter settings
3061 preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT);
3062 optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE);
3064 preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT);
3065 optionNames.add(FORMATTER_NEWLINE_CONTROL);
3067 preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE);
3068 optionNames.add(FORMATTER_CLEAR_BLANK_LINES);
3070 preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT);
3071 optionNames.add(FORMATTER_NEWLINE_ELSE_IF);
3073 preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT);
3074 optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK);
3076 preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$
3077 optionNames.add(FORMATTER_LINE_SPLIT);
3079 preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL);
3080 optionNames.add(FORMATTER_COMPACT_ASSIGNMENT);
3082 preferences.setDefault(FORMATTER_TAB_CHAR, TAB);
3083 optionNames.add(FORMATTER_TAB_CHAR);
3085 preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$
3086 optionNames.add(FORMATTER_TAB_SIZE);
3088 preferences.setDefault(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$
3089 optionNames.add(FORMATTER_SPACE_CASTEXPRESSION);
3091 // CodeAssist settings
3092 preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$
3093 optionNames.add(CODEASSIST_VISIBILITY_CHECK);
3095 preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$
3096 optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION);
3098 preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
3099 optionNames.add(CODEASSIST_FIELD_PREFIXES);
3101 preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
3102 optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES);
3104 preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
3105 optionNames.add(CODEASSIST_LOCAL_PREFIXES);
3107 preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
3108 optionNames.add(CODEASSIST_ARGUMENT_PREFIXES);
3110 preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3111 optionNames.add(CODEASSIST_FIELD_SUFFIXES);
3113 preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3114 optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES);
3116 preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
3117 optionNames.add(CODEASSIST_LOCAL_SUFFIXES);
3119 preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
3120 optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES);
3124 * Returns whether the given marker references the given Java element. Used
3125 * for markers, which denote a Java element rather than a resource.
3131 * @return <code>true</code> if the marker references the element, false
3133 * @exception CoreException
3134 * if the <code>IMarker.getAttribute</code> on the marker
3137 public static boolean isReferencedBy(IJavaElement element, IMarker marker)
3138 throws CoreException {
3140 // only match units or classfiles
3141 if (element instanceof IMember) {
3142 IMember member = (IMember) element;
3143 if (member.isBinary()) {
3144 element = null; //member.getClassFile();
3146 element = member.getCompilationUnit();
3149 if (element == null)
3154 String markerHandleId = (String) marker.getAttribute(ATT_HANDLE_ID);
3155 if (markerHandleId == null)
3158 IJavaElement markerElement = JavaCore.create(markerHandleId);
3160 if (element.equals(markerElement))
3161 return true; // external elements may still be equal with different
3164 // cycle through enclosing types in case marker is associated with a
3165 // classfile (15568)
3166 // if (markerElement instanceof IClassFile){
3167 // IType enclosingType =
3168 // ((IClassFile)markerElement).getType().getDeclaringType();
3169 // if (enclosingType != null){
3170 // markerElement = enclosingType.getClassFile(); // retry with immediate
3171 // enclosing classfile
3181 * Returns whether the given marker delta references the given Java element.
3182 * Used for markers deltas, which denote a Java element rather than a
3187 * @param markerDelta
3189 * @return <code>true</code> if the marker delta references the element
3190 * @exception CoreException
3191 * if the <code>IMarkerDelta.getAttribute</code> on the
3192 * marker delta fails
3194 public static boolean isReferencedBy(IJavaElement element,
3195 IMarkerDelta markerDelta) throws CoreException {
3197 // only match units or classfiles
3198 if (element instanceof IMember) {
3199 IMember member = (IMember) element;
3200 if (member.isBinary()) {
3201 element = null; //member.getClassFile();
3203 element = member.getCompilationUnit();
3206 if (element == null)
3208 if (markerDelta == null)
3211 String markerDeltarHandleId = (String) markerDelta
3212 .getAttribute(ATT_HANDLE_ID);
3213 if (markerDeltarHandleId == null)
3216 IJavaElement markerElement = JavaCore.create(markerDeltarHandleId);
3218 if (element.equals(markerElement))
3219 return true; // external elements may still be equal with different
3222 // cycle through enclosing types in case marker is associated with a
3223 // classfile (15568)
3224 // if (markerElement instanceof IClassFile){
3225 // IType enclosingType =
3226 // ((IClassFile)markerElement).getType().getDeclaringType();
3227 // if (enclosingType != null){
3228 // markerElement = enclosingType.getClassFile(); // retry with immediate
3229 // enclosing classfile
3239 * Creates and returns a new classpath entry of kind
3240 * <code>CPE_CONTAINER</code> for the given path. The path of the
3241 * container will be used during resolution so as to map this container
3242 * entry to a set of other classpath entries the container is acting for.
3244 * A container entry allows to express indirect references to a set of
3245 * libraries, projects and variable entries, which can be interpreted
3246 * differently for each Java project where it is used. A classpath container
3247 * entry can be resolved using
3248 * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3249 * <code>JavaCore.classpathContainerChanged</code>
3251 * A container is exclusively resolved by a
3252 * <code>ClasspathContainerInitializer</code> registered onto the
3253 * extension point "net.sourceforge.phpdt.core.classpathContainerInitializer".
3255 * A container path must be formed of at least one segment, where:
3257 * <li>the first segment is a unique ID identifying the target container,
3258 * there must be a container initializer registered onto this ID through the
3259 * extension point "net.sourceforge.phpdt.core.classpathContainerInitializer".
3261 * <li>the remaining segments will be passed onto the initializer, and can
3262 * be used as additional hints during the initialization phase.</li>
3265 * Example of an ClasspathContainerInitializer for a classpath container
3266 * denoting a default JDK container:
3268 * containerEntry = JavaCore.newContainerEntry(new
3269 * Path("MyProvidedJDK/default"));
3271 * <extension point="net.sourceforge.phpdt.core.classpathContainerInitializer">
3272 * <containerInitializer id="MyProvidedJDK"
3273 * class="com.example.MyInitializer"/>
3275 * Note that this operation does not attempt to validate classpath
3276 * containers or access the resources at the given paths.
3278 * The resulting entry is not exported to dependent projects. This method is
3279 * equivalent to <code>newContainerEntry(-,false)</code>.
3282 * @param containerPath
3283 * the path identifying the container, it must be formed of two
3285 * @return a new container classpath entry
3287 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3288 * @see JavaCore#newContainerEntry(IPath, boolean)
3291 public static IClasspathEntry newContainerEntry(IPath containerPath) {
3293 return newContainerEntry(containerPath, false);
3297 * Creates and returns a new classpath entry of kind
3298 * <code>CPE_CONTAINER</code> for the given path. The path of the
3299 * container will be used during resolution so as to map this container
3300 * entry to a set of other classpath entries the container is acting for.
3302 * A container entry allows to express indirect references to a set of
3303 * libraries, projects and variable entries, which can be interpreted
3304 * differently for each Java project where it is used. A classpath container
3305 * entry can be resolved using
3306 * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3307 * <code>JavaCore.classpathContainerChanged</code>
3309 * A container is exclusively resolved by a
3310 * <code>ClasspathContainerInitializer</code> registered onto the
3311 * extension point "net.sourceforge.phpdt.core.classpathContainerInitializer".
3313 * A container path must be formed of at least one segment, where:
3315 * <li>the first segment is a unique ID identifying the target container,
3316 * there must be a container initializer registered onto this ID through the
3317 * extension point "net.sourceforge.phpdt.core.classpathContainerInitializer".
3319 * <li>the remaining segments will be passed onto the initializer, and can
3320 * be used as additional hints during the initialization phase.</li>
3323 * Example of an ClasspathContainerInitializer for a classpath container
3324 * denoting a default JDK container:
3326 * containerEntry = JavaCore.newContainerEntry(new
3327 * Path("MyProvidedJDK/default"));
3329 * <extension point="net.sourceforge.phpdt.core.classpathContainerInitializer">
3330 * <containerInitializer id="MyProvidedJDK"
3331 * class="com.example.MyInitializer"/>
3333 * Note that this operation does not attempt to validate classpath
3334 * containers or access the resources at the given paths.
3337 * @param containerPath
3338 * the path identifying the container, it must be formed of at
3339 * least one segment (ID+hints)
3341 * a boolean indicating whether this entry is contributed to
3342 * dependent projects in addition to the output location
3343 * @return a new container classpath entry
3345 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3346 * @see JavaCore#setClasspathContainer(IPath, IJavaProject[],
3347 * IClasspathContainer[], IProgressMonitor)
3348 * @see JavaCore#newContainerEntry(IPath, boolean)
3352 public static IClasspathEntry newContainerEntry(IPath containerPath, boolean isExported) {
3354 if (containerPath == null) Assert.isTrue(false, "Container path cannot be null"); //$NON-NLS-1$
3355 if (containerPath.segmentCount() < 1) {
3358 "Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$
3360 return new ClasspathEntry(
3361 IPackageFragmentRoot.K_SOURCE,
3362 IClasspathEntry.CPE_CONTAINER,
3364 ClasspathEntry.INCLUDE_ALL,
3365 ClasspathEntry.EXCLUDE_NONE,
3366 null, // source attachment
3367 null, // source attachment root
3368 null, // specific output folder
3373 * Creates and returns a new non-exported classpath entry of kind
3374 * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3375 * absolute path. This specifies that all package fragments within the root
3376 * will have children of type <code>IClassFile</code>.
3378 * A library entry is used to denote a prerequisite JAR or root folder
3379 * containing binaries. The target JAR or folder can either be defined
3380 * internally to the workspace (absolute path relative to the workspace
3381 * root) or externally to the workspace (absolute path in the file system).
3383 * e.g. Here are some examples of binary path usage
3385 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3387 * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3389 * <li><code> "c:/classes/" </code>- reference to an external binary
3392 * Note that this operation does not attempt to validate or access the
3393 * resources at the given paths.
3395 * The resulting entry is not exported to dependent projects. This method is
3396 * equivalent to <code>newLibraryEntry(-,-,-,false)</code>.
3400 * the absolute path of the binary archive
3401 * @param sourceAttachmentPath
3402 * the absolute path of the corresponding source archive or
3403 * folder, or <code>null</code> if none
3404 * @param sourceAttachmentRootPath
3405 * the location of the root within the source archive or folder
3406 * or <code>null</code> if this location should be
3407 * automatically detected.
3408 * @return a new library classpath entry
3410 * @see #newLibraryEntry(IPath, IPath, IPath, boolean)
3412 //public static IClasspathEntry newLibraryEntry(
3414 // IPath sourceAttachmentPath,
3415 // IPath sourceAttachmentRootPath) {
3417 // return newLibraryEntry(path, sourceAttachmentPath,
3418 // sourceAttachmentRootPath, false);
3421 * Creates and returns a new classpath entry of kind
3422 * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3423 * absolute path. This specifies that all package fragments within the root
3424 * will have children of type <code>IClassFile</code>.
3426 * A library entry is used to denote a prerequisite JAR or root folder
3427 * containing binaries. The target JAR or folder can either be defined
3428 * internally to the workspace (absolute path relative to the workspace
3429 * root) or externally to the workspace (absolute path in the file system).
3431 * e.g. Here are some examples of binary path usage
3433 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3435 * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3437 * <li><code> "c:/classes/" </code>- reference to an external binary
3440 * Note that this operation does not attempt to validate or access the
3441 * resources at the given paths.
3445 * the absolute path of the binary archive
3446 * @param sourceAttachmentPath
3447 * the absolute path of the corresponding source archive or
3448 * folder, or <code>null</code> if none
3449 * @param sourceAttachmentRootPath
3450 * the location of the root within the source archive or folder
3451 * or <code>null</code> if this location should be
3452 * automatically detected.
3454 * indicates whether this entry is contributed to dependent
3455 * projects in addition to the output location
3456 * @return a new library classpath entry
3459 //public static IClasspathEntry newLibraryEntry(
3461 // IPath sourceAttachmentPath,
3462 // IPath sourceAttachmentRootPath,
3463 // boolean isExported) {
3465 // if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry
3466 // must be absolute"); //$NON-NLS-1$
3468 // return new ClasspathEntry(
3469 // IPackageFragmentRoot.K_BINARY,
3470 // IClasspathEntry.CPE_LIBRARY,
3471 // JavaProject.canonicalizedPath(path),
3472 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3473 // sourceAttachmentPath,
3474 // sourceAttachmentRootPath,
3475 // null, // specific output folder
3479 * Creates and returns a new non-exported classpath entry of kind
3480 * <code>CPE_PROJECT</code> for the project identified by the given
3483 * A project entry is used to denote a prerequisite project on a classpath.
3484 * The referenced project will be contributed as a whole, either as sources
3485 * (in the Java Model, it contributes all its package fragment roots) or as
3486 * binaries (when building, it contributes its whole output location).
3488 * A project reference allows to indirect through another project,
3489 * independently from its internal layout.
3491 * The prerequisite project is referred to using an absolute path relative
3492 * to the workspace root.
3494 * The resulting entry is not exported to dependent projects. This method is
3495 * equivalent to <code>newProjectEntry(_,false)</code>.
3499 * the absolute path of the binary archive
3500 * @return a new project classpath entry
3502 * @see JavaCore#newProjectEntry(IPath, boolean)
3504 public static IClasspathEntry newProjectEntry(IPath path) {
3505 return newProjectEntry(path, false);
3509 * Creates and returns a new classpath entry of kind
3510 * <code>CPE_PROJECT</code> for the project identified by the given
3513 * A project entry is used to denote a prerequisite project on a classpath.
3514 * The referenced project will be contributed as a whole, either as sources
3515 * (in the Java Model, it contributes all its package fragment roots) or as
3516 * binaries (when building, it contributes its whole output location).
3518 * A project reference allows to indirect through another project,
3519 * independently from its internal layout.
3521 * The prerequisite project is referred to using an absolute path relative
3522 * to the workspace root.
3526 * the absolute path of the prerequisite project
3528 * indicates whether this entry is contributed to dependent
3529 * projects in addition to the output location
3530 * @return a new project classpath entry
3533 public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) {
3535 if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3537 return new ClasspathEntry(
3538 IPackageFragmentRoot.K_SOURCE,
3539 IClasspathEntry.CPE_PROJECT,
3541 ClasspathEntry.INCLUDE_ALL,
3542 ClasspathEntry.EXCLUDE_NONE,
3543 null, // source attachment
3544 null, // source attachment root
3545 null, // specific output folder
3551 * Returns a new empty region.
3553 * @return a new empty region
3555 public static IRegion newRegion() {
3556 return new Region();
3560 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3561 * for all files in the project's source folder identified by the given
3562 * absolute workspace-relative path.
3564 * The convenience method is fully equivalent to:
3566 * newSourceEntry(path, new IPath[] {}, new IPath[] {}, null);
3570 * @param path the absolute workspace-relative path of a source folder
3571 * @return a new source classpath entry
3572 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath)
3574 public static IClasspathEntry newSourceEntry(IPath path) {
3576 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, null /*output location*/);
3580 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3581 * for the project's source folder identified by the given absolute
3582 * workspace-relative path but excluding all source files with paths
3583 * matching any of the given patterns.
3585 * The convenience method is fully equivalent to:
3587 * newSourceEntry(path, new IPath[] {}, exclusionPatterns, null);
3591 * @param path the absolute workspace-relative path of a source folder
3592 * @param exclusionPatterns the possibly empty list of exclusion patterns
3593 * represented as relative paths
3594 * @return a new source classpath entry
3595 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath)
3598 public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns) {
3600 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL, exclusionPatterns, null /*output location*/);
3604 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3605 * for the project's source folder identified by the given absolute
3606 * workspace-relative path but excluding all source files with paths
3607 * matching any of the given patterns, and associated with a specific output location
3608 * (that is, ".class" files are not going to the project default output location).
3610 * The convenience method is fully equivalent to:
3612 * newSourceEntry(path, new IPath[] {}, exclusionPatterns, specificOutputLocation);
3616 * @param path the absolute workspace-relative path of a source folder
3617 * @param exclusionPatterns the possibly empty list of exclusion patterns
3618 * represented as relative paths
3619 * @param specificOutputLocation the specific output location for this source entry (<code>null</code> if using project default ouput location)
3620 * @return a new source classpath entry
3621 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath)
3624 public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns, IPath specificOutputLocation) {
3626 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL, exclusionPatterns, specificOutputLocation);
3630 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3631 * for the project's source folder identified by the given absolute
3632 * workspace-relative path using the given inclusion and exclusion patterns
3633 * to determine which source files are included, and the given output path
3634 * to control the output location of generated files.
3636 * The source folder is referred to using an absolute path relative to the
3637 * workspace root, e.g. <code>/Project/src</code>. A project's source
3638 * folders are located with that project. That is, a source classpath
3639 * entry specifying the path <code>/P1/src</code> is only usable for
3640 * project <code>P1</code>.
3643 * The inclusion patterns determines the initial set of source files that
3644 * are to be included; the exclusion patterns are then used to reduce this
3645 * set. When no inclusion patterns are specified, the initial file set
3646 * includes all relevent files in the resource tree rooted at the source
3647 * entry's path. On the other hand, specifying one or more inclusion
3648 * patterns means that all <b>and only</b> files matching at least one of
3649 * the specified patterns are to be included. If exclusion patterns are
3650 * specified, the initial set of files is then reduced by eliminating files
3651 * matched by at least one of the exclusion patterns. Inclusion and
3652 * exclusion patterns look like relative file paths with wildcards and are
3653 * interpreted relative to the source entry's path. File patterns are
3654 * case-sensitive can contain '**', '*' or '?' wildcards (see
3655 * {@link IClasspathEntry#getExclusionPatterns()} for the full description
3656 * of their syntax and semantics). The resulting set of files are included
3657 * in the corresponding package fragment root; all package fragments within
3658 * the root will have children of type <code>ICompilationUnit</code>.
3661 * For example, if the source folder path is
3662 * <code>/Project/src</code>, there are no inclusion filters, and the
3663 * exclusion pattern is
3664 * <code>com/xyz/tests/**</code>, then source files
3665 * like <code>/Project/src/com/xyz/Foo.java</code>
3666 * and <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3667 * whereas <code>/Project/src/com/xyz/tests/T1.java</code>
3668 * and <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3672 * Additionally, a source entry can be associated with a specific output location.
3673 * By doing so, the Java builder will ensure that the generated ".class" files will
3674 * be issued inside this output location, as opposed to be generated into the
3675 * project default output location (when output location is <code>null</code>).
3676 * Note that multiple source entries may target the same output location.
3677 * The output location is referred to using an absolute path relative to the
3678 * workspace root, e.g. <code>"/Project/bin"</code>, it must be located inside
3679 * the same project as the source folder.
3682 * Also note that all sources/binaries inside a project are contributed as
3683 * a whole through a project entry
3684 * (see <code>JavaCore.newProjectEntry</code>). Particular source entries
3685 * cannot be selectively exported.
3688 * @param path the absolute workspace-relative path of a source folder
3689 * @param inclusionPatterns the possibly empty list of inclusion patterns
3690 * represented as relative paths
3691 * @param exclusionPatterns the possibly empty list of exclusion patterns
3692 * represented as relative paths
3693 * @param specificOutputLocation the specific output location for this source entry (<code>null</code> if using project default ouput location)
3694 * @return a new source classpath entry with the given exclusion patterns
3695 * @see IClasspathEntry#getInclusionPatterns()
3696 * @see IClasspathEntry#getExclusionPatterns()
3697 * @see IClasspathEntry#getOutputLocation()
3700 public static IClasspathEntry newSourceEntry(IPath path, IPath[] inclusionPatterns, IPath[] exclusionPatterns, IPath specificOutputLocation) {
3702 if (path == null) Assert.isTrue(false, "Source path cannot be null"); //$NON-NLS-1$
3703 if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3704 if (exclusionPatterns == null) Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$
3705 if (inclusionPatterns == null) Assert.isTrue(false, "Inclusion pattern set cannot be null"); //$NON-NLS-1$
3707 return new ClasspathEntry(
3708 IPackageFragmentRoot.K_SOURCE,
3709 IClasspathEntry.CPE_SOURCE,
3713 null, // source attachment
3714 null, // source attachment root
3715 specificOutputLocation, // custom output location
3720 * Creates and returns a new non-exported classpath entry of kind
3721 * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3722 * path is the name of a classpath variable. The trailing segments of the
3723 * path will be appended to resolved variable path.
3725 * A variable entry allows to express indirect references on a classpath to
3726 * other projects or libraries, depending on what the classpath variable is
3729 * It is possible to register an automatic initializer (
3730 * <code>ClasspathVariableInitializer</code>), which will be invoked
3731 * through the extension point
3732 * "net.sourceforge.phpdt.core.classpathVariableInitializer". After resolution, a
3733 * classpath variable entry may either correspond to a project or a library
3736 * e.g. Here are some examples of variable path usage
3738 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3739 * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3740 * library "c:\jars\jdtcore.jar"</li>
3741 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3742 * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3743 * "/Project_JDTCORE"</li>
3744 * <li>"PLUGINS/com.example/example.jar" where variable
3745 * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3746 * classpath entry is denoting the library
3747 * "c:/eclipse/plugins/com.example/example.jar"</li>
3749 * Note that this operation does not attempt to validate classpath variables
3750 * or access the resources at the given paths.
3752 * The resulting entry is not exported to dependent projects. This method is
3753 * equivalent to <code>newVariableEntry(-,-,-,false)</code>.
3756 * @param variablePath
3757 * the path of the binary archive; first segment is the name of a
3758 * classpath variable
3759 * @param variableSourceAttachmentPath
3760 * the path of the corresponding source archive, or
3761 * <code>null</code> if none; if present, the first segment is
3762 * the name of a classpath variable (not necessarily the same
3763 * variable as the one that begins <code>variablePath</code>)
3764 * @param sourceAttachmentRootPath
3765 * the location of the root within the source archive or
3766 * <code>null</code> if <code>archivePath</code> is also
3768 * @return a new library classpath entry
3770 * @see JavaCore#newVariableEntry(IPath, IPath, IPath, boolean)
3772 //public static IClasspathEntry newVariableEntry(
3773 // IPath variablePath,
3774 // IPath variableSourceAttachmentPath,
3775 // IPath sourceAttachmentRootPath) {
3777 // return newVariableEntry(variablePath, variableSourceAttachmentPath,
3778 // sourceAttachmentRootPath, false);
3781 * Creates and returns a new non-exported classpath entry of kind
3782 * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3783 * path is the name of a classpath variable. The trailing segments of the
3784 * path will be appended to resolved variable path.
3786 * A variable entry allows to express indirect references on a classpath to
3787 * other projects or libraries, depending on what the classpath variable is
3790 * It is possible to register an automatic initializer (
3791 * <code>ClasspathVariableInitializer</code>), which will be invoked
3792 * through the extension point
3793 * "net.sourceforge.phpdt.core.classpathVariableInitializer". After resolution, a
3794 * classpath variable entry may either correspond to a project or a library
3797 * e.g. Here are some examples of variable path usage
3799 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3800 * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3801 * library "c:\jars\jdtcore.jar"</li>
3802 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3803 * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3804 * "/Project_JDTCORE"</li>
3805 * <li>"PLUGINS/com.example/example.jar" where variable
3806 * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3807 * classpath entry is denoting the library
3808 * "c:/eclipse/plugins/com.example/example.jar"</li>
3810 * Note that this operation does not attempt to validate classpath variables
3811 * or access the resources at the given paths.
3814 * @param variablePath
3815 * the path of the binary archive; first segment is the name of a
3816 * classpath variable
3817 * @param variableSourceAttachmentPath
3818 * the path of the corresponding source archive, or
3819 * <code>null</code> if none; if present, the first segment is
3820 * the name of a classpath variable (not necessarily the same
3821 * variable as the one that begins <code>variablePath</code>)
3822 * @param sourceAttachmentRootPath
3823 * the location of the root within the source archive or
3824 * <code>null</code> if <code>archivePath</code> is also
3827 * indicates whether this entry is contributed to dependent
3828 * projects in addition to the output location
3829 * @return a new variable classpath entry
3832 //public static IClasspathEntry newVariableEntry(
3833 // IPath variablePath,
3834 // IPath variableSourceAttachmentPath,
3835 // IPath variableSourceAttachmentRootPath,
3836 // boolean isExported) {
3838 // if (variablePath == null || variablePath.segmentCount() < 1) {
3841 // "Illegal classpath variable path: \'" +
3842 // variablePath.makeRelative().toString() + "\', must have at least one
3843 // segment"); //$NON-NLS-1$//$NON-NLS-2$
3846 // return new ClasspathEntry(
3847 // IPackageFragmentRoot.K_SOURCE,
3848 // IClasspathEntry.CPE_VARIABLE,
3850 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3851 // variableSourceAttachmentPath, // source attachment
3852 // variableSourceAttachmentRootPath, // source attachment root
3853 // null, // specific output folder
3857 * Removed the given classpath variable. Does nothing if no value was set
3858 * for this classpath variable.
3860 * This functionality cannot be used while the resource tree is locked.
3862 * Classpath variable values are persisted locally to the workspace, and are
3863 * preserved from session to session.
3866 * @param variableName
3867 * the name of the classpath variable
3868 * @see #setClasspathVariable
3870 * @deprecated - use version with extra IProgressMonitor
3872 //public static void removeClasspathVariable(String variableName) {
3873 // removeClasspathVariable(variableName, null);
3876 * Removed the given classpath variable. Does nothing if no value was set
3877 * for this classpath variable.
3879 * This functionality cannot be used while the resource tree is locked.
3881 * Classpath variable values are persisted locally to the workspace, and are
3882 * preserved from session to session.
3885 * @param variableName
3886 * the name of the classpath variable
3888 * the progress monitor to report progress
3889 * @see #setClasspathVariable
3891 //public static void removeClasspathVariable(
3892 // String variableName,
3893 // IProgressMonitor monitor) {
3896 // updateVariableValues(new String[]{ variableName}, new IPath[]{ null },
3898 // } catch (JavaModelException e) {
3902 * Removes the given element changed listener. Has no affect if an identical
3903 * listener is not registered.
3908 public static void removeElementChangedListener(
3909 IElementChangedListener listener) {
3910 JavaModelManager.getJavaModelManager().removeElementChangedListener(
3915 * Bind a container reference path to some actual containers (
3916 * <code>IClasspathContainer</code>). This API must be invoked whenever
3917 * changes in container need to be reflected onto the JavaModel. Containers
3918 * can have distinct values in different projects, therefore this API
3919 * considers a set of projects with their respective containers.
3921 * <code>containerPath</code> is the path under which these values can be
3922 * referenced through container classpath entries (
3923 * <code>IClasspathEntry#CPE_CONTAINER</code>). A container path is
3924 * formed by a first ID segment followed with extra segments, which can be
3925 * used as additional hints for the resolution. The container ID is used to
3926 * identify a <code>ClasspathContainerInitializer</code> registered on the
3927 * extension point "net.sourceforge.phpdt.core.classpathContainerInitializer".
3929 * There is no assumption that each individual container value passed in
3930 * argument (<code>respectiveContainers</code>) must answer the exact
3931 * same path when requested <code>IClasspathContainer#getPath</code>.
3932 * Indeed, the containerPath is just an indication for resolving it to an
3933 * actual container object. It can be delegated to a
3934 * <code>ClasspathContainerInitializer</code>, which can be activated
3935 * through the extension point
3936 * "net.sourceforge.phpdt.core.ClasspathContainerInitializer").
3938 * In reaction to changing container values, the JavaModel will be updated
3939 * to reflect the new state of the updated container.
3941 * This functionality cannot be used while the resource tree is locked.
3943 * Classpath container values are persisted locally to the workspace, but
3944 * are not preserved from a session to another. It is thus highly
3945 * recommended to register a <code>ClasspathContainerInitializer</code>
3946 * for each referenced container (through the extension point
3947 * "net.sourceforge.phpdt.core.ClasspathContainerInitializer").
3949 * Note: setting a container to <code>null</code> will cause it to be
3950 * lazily resolved again whenever its value is required. In particular, this
3951 * will cause a registered initializer to be invoked again.
3954 * @param containerPath -
3955 * the name of the container reference, which is being updated
3956 * @param affectedProjects -
3957 * the set of projects for which this container is being bound
3958 * @param respectiveContainers -
3959 * the set of respective containers for the affected projects
3961 * a monitor to report progress
3963 * @see ClasspathContainerInitializer
3964 * @see #getClasspathContainer(IPath, IJavaProject)
3965 * @see IClasspathContainer
3968 //public static void setClasspathContainer(final IPath containerPath,
3969 // IJavaProject[] affectedProjects, IClasspathContainer[]
3970 // respectiveContainers, IProgressMonitor monitor) throws JavaModelException
3973 // if (affectedProjects.length != respectiveContainers.length)
3974 // Assert.isTrue(false, "Projects and containers collections should have the
3975 // same size"); //$NON-NLS-1$
3977 // if (monitor != null && monitor.isCanceled()) return;
3979 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3980 // System.out.println("CPContainer SET - setting container:
3981 // ["+containerPath+"] for projects: {" //$NON-NLS-1$ //$NON-NLS-2$
3982 // + (ProjectPrefUtil.toString(affectedProjects,
3983 // new ProjectPrefUtil.Displayable(){
3984 // public String displayString(Object o) { return ((IJavaProject)
3985 // o).getElementName(); }
3987 // + "} with values: " //$NON-NLS-1$
3988 // + (ProjectPrefUtil.toString(respectiveContainers,
3989 // new ProjectPrefUtil.Displayable(){
3990 // public String displayString(Object o) { return ((IClasspathContainer)
3991 // o).getDescription(); }
3996 // final int projectLength = affectedProjects.length;
3997 // final IJavaProject[] modifiedProjects;
3998 // System.arraycopy(affectedProjects, 0, modifiedProjects = new
3999 // IJavaProject[projectLength], 0, projectLength);
4000 // final IClasspathEntry[][] oldResolvedPaths = new
4001 // IClasspathEntry[projectLength][];
4003 // // filter out unmodified project containers
4004 // int remaining = 0;
4005 // for (int i = 0; i < projectLength; i++){
4007 // if (monitor != null && monitor.isCanceled()) return;
4009 // IJavaProject affectedProject = affectedProjects[i];
4010 // IClasspathContainer newContainer = respectiveContainers[i];
4011 // if (newContainer == null) newContainer =
4012 // JavaModelManager.ContainerInitializationInProgress; // 30920 - prevent
4014 // boolean found = false;
4015 // if (JavaProject.hasJavaNature(affectedProject.getProject())){
4016 // IClasspathEntry[] rawClasspath = affectedProject.getRawClasspath();
4017 // for (int j = 0, cpLength = rawClasspath.length; j <cpLength; j++) {
4018 // IClasspathEntry entry = rawClasspath[j];
4019 // if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER &&
4020 // entry.getPath().equals(containerPath)){
4027 // modifiedProjects[i] = null; // filter out this project - does not
4028 // reference the container path, or isnt't yet Java project
4029 // JavaModelManager.containerPut(affectedProject, containerPath,
4033 // IClasspathContainer oldContainer =
4034 // JavaModelManager.containerGet(affectedProject, containerPath);
4035 // if (oldContainer == JavaModelManager.ContainerInitializationInProgress) {
4036 // Map previousContainerValues =
4037 // (Map)JavaModelManager.PreviousSessionContainers.get(affectedProject);
4038 // if (previousContainerValues != null){
4039 // IClasspathContainer previousContainer =
4040 // (IClasspathContainer)previousContainerValues.get(containerPath);
4041 // if (previousContainer != null) {
4042 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4043 // System.out.println("CPContainer INIT - reentering access to project
4044 // container: ["+affectedProject.getElementName()+"] " + containerPath + "
4045 // during its initialization, will see previous value: "+
4046 // previousContainer.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
4049 // JavaModelManager.containerPut(affectedProject, containerPath,
4050 // previousContainer);
4052 // oldContainer = null; //33695 - cannot filter out restored container, must
4053 // update affected project to reset cached CP
4055 // oldContainer = null;
4058 // if (oldContainer != null &&
4059 // oldContainer.equals(respectiveContainers[i])){// TODO: could improve to
4060 // only compare entries
4061 // modifiedProjects[i] = null; // filter out this project - container did
4066 // oldResolvedPaths[i] = affectedProject.getResolvedClasspath(true);
4067 // JavaModelManager.containerPut(affectedProject, containerPath,
4071 // if (remaining == 0) return;
4073 // // trigger model refresh
4075 // JavaCore.run(new IWorkspaceRunnable() {
4076 // public void run(IProgressMonitor monitor) throws CoreException {
4077 // for(int i = 0; i < projectLength; i++){
4079 // if (monitor != null && monitor.isCanceled()) return;
4081 // JavaProject affectedProject = (JavaProject)modifiedProjects[i];
4082 // if (affectedProject == null) continue; // was filtered out
4084 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4085 // System.out.println("CPContainer SET - updating affected project:
4086 // ["+affectedProject.getElementName()+"] due to setting container: " +
4087 // containerPath); //$NON-NLS-1$ //$NON-NLS-2$
4090 // // force a refresh of the affected project (will compute deltas)
4091 // affectedProject.setRawClasspath(
4092 // affectedProject.getRawClasspath(),
4093 // SetClasspathOperation.ReuseOutputLocation,
4095 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can save resources
4096 // oldResolvedPaths[i],
4097 // false, // updating - no validation
4098 // false); // updating - no need to save
4103 // } catch(CoreException e) {
4104 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4105 // System.out.println("CPContainer SET - FAILED DUE TO EXCEPTION:
4106 // "+containerPath); //$NON-NLS-1$
4107 // e.printStackTrace();
4109 // if (e instanceof JavaModelException) {
4110 // throw (JavaModelException)e;
4112 // throw new JavaModelException(e);
4115 // for (int i = 0; i < projectLength; i++) {
4116 // if (respectiveContainers[i] == null) {
4117 // JavaModelManager.containerPut(affectedProjects[i], containerPath, null);
4118 // // reset init in progress marker
4125 * Sets the value of the given classpath variable. The path must have at
4126 * least one segment.
4128 * This functionality cannot be used while the resource tree is locked.
4130 * Classpath variable values are persisted locally to the workspace, and are
4131 * preserved from session to session.
4134 * @param variableName
4135 * the name of the classpath variable
4138 * @see #getClasspathVariable
4140 * @deprecated - use API with IProgressMonitor
4142 //public static void setClasspathVariable(String variableName, IPath path)
4143 // throws JavaModelException {
4145 // setClasspathVariable(variableName, path, null);
4148 * Sets the value of the given classpath variable. The path must not be
4151 * This functionality cannot be used while the resource tree is locked.
4153 * Classpath variable values are persisted locally to the workspace, and are
4154 * preserved from session to session.
4156 * Updating a variable with the same value has no effect.
4158 * @param variableName
4159 * the name of the classpath variable
4163 * a monitor to report progress
4164 * @see #getClasspathVariable
4166 //public static void setClasspathVariable(
4167 // String variableName,
4169 // IProgressMonitor monitor)
4170 // throws JavaModelException {
4172 // if (path == null) Assert.isTrue(false, "Variable path cannot be null");
4174 // setClasspathVariables(new String[]{variableName}, new IPath[]{ path },
4178 * Sets the values of all the given classpath variables at once. Null paths
4179 * can be used to request corresponding variable removal.
4181 * This functionality cannot be used while the resource tree is locked.
4183 * Classpath variable values are persisted locally to the workspace, and are
4184 * preserved from session to session.
4186 * Updating a variable with the same value has no effect.
4188 * @param variableNames
4189 * an array of names for the updated classpath variables
4191 * an array of path updates for the modified classpath variables
4192 * (null meaning that the corresponding value will be removed
4194 * a monitor to report progress
4195 * @see #getClasspathVariable
4198 //public static void setClasspathVariables(
4199 // String[] variableNames,
4201 // IProgressMonitor monitor)
4202 // throws JavaModelException {
4204 // if (variableNames.length != paths.length) Assert.isTrue(false, "Variable
4205 // names and paths collections should have the same size"); //$NON-NLS-1$
4206 // //TODO: should check that null cannot be used as variable paths
4207 // updateVariableValues(variableNames, paths, monitor);
4210 * (non-Javadoc) Method declared on IExecutableExtension. Record any
4211 * necessary initialization data from the plugin.
4213 public void setInitializationData(IConfigurationElement cfig,
4214 String propertyName, Object data) throws CoreException {
4218 * Sets the current table of options. All and only the options explicitly
4219 * included in the given table are remembered; all previous option settings
4220 * are forgotten, including ones not explicitly mentioned.
4222 * For a complete description of the configurable options, see
4223 * <code>getDefaultOptions</code>.
4227 * the new options (key type: <code>String</code>; value type:
4228 * <code>String</code>), or <code>null</code> to reset all
4229 * options to their default values
4230 * @see JavaCore#getDefaultOptions
4232 public static void setOptions(Hashtable newOptions) {
4234 // see #initializeDefaultPluginPreferences() for changing default
4236 Preferences preferences = getPlugin().getPluginPreferences();
4238 if (newOptions == null) {
4239 newOptions = JavaCore.getDefaultOptions();
4241 Enumeration keys = newOptions.keys();
4242 while (keys.hasMoreElements()) {
4243 String key = (String) keys.nextElement();
4244 if (!JavaModelManager.OptionNames.contains(key))
4245 continue; // unrecognized option
4246 if (key.equals(CORE_ENCODING))
4247 continue; // skipped, contributed by resource prefs
4248 String value = (String) newOptions.get(key);
4249 preferences.setValue(key, value);
4253 getPlugin().savePluginPreferences();
4257 * Shutdown the JavaCore plug-in.
4259 * De-registers the JavaModelManager as a resource changed listener and save
4263 * @see org.eclipse.core.runtime.Plugin#shutdown()
4265 // moved to PHPeclipsePlugin#shutdown()
4266 //public void shutdown() {
4268 // //savePluginPreferences();
4269 // getPlugin().savePluginPreferences();
4270 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4271 // workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaProcessor);
4272 // workspace.removeSaveParticipant(PHPeclipsePlugin.getDefault());
4274 // ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown();
4277 * Initiate the background indexing process. This should be deferred after
4278 * the plugin activation.
4280 //private void startIndexing() {
4282 // JavaModelManager.getJavaModelManager().getIndexManager().reset();
4285 * Startup of the JavaCore plug-in.
4287 * Registers the JavaModelManager as a resource changed listener and save
4288 * participant. Starts the background indexing, and restore saved classpath
4292 * @see org.eclipse.core.runtime.Plugin#startup()
4295 // moved to PHPeclipsePlugin#startup()
4296 //public void startup() {
4298 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
4300 // manager.configurePluginDebugOptions();
4302 // // request state folder creation (workaround 19885)
4303 // JavaCore.getPlugin().getStateLocation();
4305 // // retrieve variable values
4306 // JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4307 // JavaModelManager.PluginPreferencesListener());
4308 //// TODO : jsurfer temp-del
4309 //// manager.loadVariablesAndContainers();
4311 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4312 // workspace.addResourceChangeListener(
4313 // manager.deltaProcessor,
4314 // IResourceChangeEvent.PRE_AUTO_BUILD
4315 // | IResourceChangeEvent.POST_AUTO_BUILD
4316 // | IResourceChangeEvent.POST_CHANGE
4317 // | IResourceChangeEvent.PRE_DELETE
4318 // | IResourceChangeEvent.PRE_CLOSE);
4320 //// startIndexing();
4321 // workspace.addSaveParticipant(PHPeclipsePlugin.getDefault(), manager);
4323 // } catch (CoreException e) {
4324 // } catch (RuntimeException e) {
4325 // manager.shutdown();
4330 * Internal updating of a variable values (null path meaning removal),
4331 * allowing to change multiple variable values at once.
4333 //private static void updateVariableValues(
4334 // String[] variableNames,
4335 // IPath[] variablePaths,
4336 // IProgressMonitor monitor) throws JavaModelException {
4338 // if (monitor != null && monitor.isCanceled()) return;
4340 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4341 // System.out.println("CPVariable SET - setting variables: {" +
4342 // ProjectPrefUtil.toString(variableNames) //$NON-NLS-1$
4343 // + "} with values: " + ProjectPrefUtil.toString(variablePaths)); //$NON-NLS-1$
4346 // int varLength = variableNames.length;
4348 // // gather classpath information for updating
4349 // final HashMap affectedProjects = new HashMap(5);
4350 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
4351 // IJavaModel model = manager.getJavaModel();
4353 // // filter out unmodified variables
4354 // int discardCount = 0;
4355 // for (int i = 0; i < varLength; i++){
4356 // String variableName = variableNames[i];
4357 // IPath oldPath = (IPath)JavaModelManager.variableGet(variableName); // if
4358 // reentering will provide previous session value
4359 // if (oldPath == JavaModelManager.VariableInitializationInProgress){
4360 // IPath previousPath =
4361 // (IPath)JavaModelManager.PreviousSessionVariables.get(variableName);
4362 // if (previousPath != null){
4363 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4364 // System.out.println("CPVariable INIT - reentering access to variable: " +
4365 // variableName+ " during its initialization, will see previous value: "+
4366 // previousPath); //$NON-NLS-1$ //$NON-NLS-2$
4368 // JavaModelManager.variablePut(variableName, previousPath); // replace
4369 // value so reentering calls are seeing old value
4371 // oldPath = null; //33695 - cannot filter out restored variable, must
4372 // update affected project to reset cached CP
4374 // if (oldPath != null && oldPath.equals(variablePaths[i])){
4375 // variableNames[i] = null;
4379 // if (discardCount > 0){
4380 // if (discardCount == varLength) return;
4381 // int changedLength = varLength - discardCount;
4382 // String[] changedVariableNames = new String[changedLength];
4383 // IPath[] changedVariablePaths = new IPath[changedLength];
4384 // for (int i = 0, index = 0; i < varLength; i++){
4385 // if (variableNames[i] != null){
4386 // changedVariableNames[index] = variableNames[i];
4387 // changedVariablePaths[index] = variablePaths[i];
4391 // variableNames = changedVariableNames;
4392 // variablePaths = changedVariablePaths;
4393 // varLength = changedLength;
4396 // if (monitor != null && monitor.isCanceled()) return;
4398 // if (model != null) {
4399 // IJavaProject[] projects = model.getJavaProjects();
4400 // nextProject : for (int i = 0, projectLength = projects.length; i <
4401 // projectLength; i++){
4402 // IJavaProject project = projects[i];
4404 // // check to see if any of the modified variables is present on the
4406 // IClasspathEntry[] classpath = project.getRawClasspath();
4407 // for (int j = 0, cpLength = classpath.length; j < cpLength; j++){
4409 // IClasspathEntry entry = classpath[j];
4410 // for (int k = 0; k < varLength; k++){
4412 // String variableName = variableNames[k];
4413 // if (entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE){
4415 // if (variableName.equals(entry.getPath().segment(0))){
4416 // affectedProjects.put(project, project.getResolvedClasspath(true));
4417 // continue nextProject;
4419 // IPath sourcePath, sourceRootPath;
4420 // if (((sourcePath = entry.getSourceAttachmentPath()) != null &&
4421 // variableName.equals(sourcePath.segment(0)))
4422 // || ((sourceRootPath = entry.getSourceAttachmentRootPath()) != null &&
4423 // variableName.equals(sourceRootPath.segment(0)))) {
4425 // affectedProjects.put(project, project.getResolvedClasspath(true));
4426 // continue nextProject;
4433 // // update variables
4434 // for (int i = 0; i < varLength; i++){
4435 // JavaModelManager.variablePut(variableNames[i], variablePaths[i]);
4437 // final String[] dbgVariableNames = variableNames;
4439 // // update affected project classpaths
4440 // if (!affectedProjects.isEmpty()) {
4442 // JavaCore_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt.run(
4443 // new IWorkspaceRunnable() {
4444 // public void run(IProgressMonitor monitor) throws CoreException {
4445 // // propagate classpath change
4446 // Iterator projectsToUpdate = affectedProjects.keySet().iterator();
4447 // while (projectsToUpdate.hasNext()) {
4449 // if (monitor != null && monitor.isCanceled()) return;
4451 // JavaProject project = (JavaProject) projectsToUpdate.next();
4453 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4454 // System.out.println("CPVariable SET - updating affected project:
4455 // ["+project.getElementName()+"] due to setting variables: "+
4456 // ProjectPrefUtil.toString(dbgVariableNames)); //$NON-NLS-1$ //$NON-NLS-2$
4460 // .setRawClasspath(
4461 // project.getRawClasspath(),
4462 // SetClasspathOperation.ReuseOutputLocation,
4463 // null, // don't call beginTask on the monitor (see
4464 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=3717)
4465 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can change resources
4466 // (IClasspathEntry[]) affectedProjects.get(project),
4467 // false, // updating - no validation
4468 // false); // updating - no need to save
4473 // } catch (CoreException e) {
4474 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4475 // System.out.println("CPVariable SET - FAILED DUE TO EXCEPTION:
4476 // "+ProjectPrefUtil.toString(dbgVariableNames)); //$NON-NLS-1$
4477 // e.printStackTrace();
4479 // if (e instanceof JavaModelException) {
4480 // throw (JavaModelException)e;
4482 // throw new JavaModelException(e);
4488 * (non-Javadoc) Startup the JavaCore plug-in. <p> Registers the
4489 * JavaModelManager as a resource changed listener and save participant.
4490 * Starts the background indexing, and restore saved classpath variable
4491 * values. <p> @throws Exception
4493 * @see org.eclipse.core.runtime.Plugin#start(BundleContext)
4495 //public static void start(final Plugin plugin, BundleContext context)
4496 // throws Exception {
4497 //// super.start(context);
4499 // final JavaModelManager manager = JavaModelManager.getJavaModelManager();
4501 // manager.configurePluginDebugOptions();
4503 // // request state folder creation (workaround 19885)
4504 // JavaCore.getPlugin().getStateLocation();
4506 // // retrieve variable values
4507 // //JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4508 // JavaModelManager.PluginPreferencesListener());
4509 //// manager.loadVariablesAndContainers();
4511 // final IWorkspace workspace = ResourcesPlugin.getWorkspace();
4512 // workspace.addResourceChangeListener(
4513 // manager.deltaState,
4514 // IResourceChangeEvent.PRE_BUILD
4515 // | IResourceChangeEvent.POST_BUILD
4516 // | IResourceChangeEvent.POST_CHANGE
4517 // | IResourceChangeEvent.PRE_DELETE
4518 // | IResourceChangeEvent.PRE_CLOSE);
4520 //// startIndexing();
4522 // // process deltas since last activated in indexer thread so that indexes
4524 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658
4525 // Job processSavedState = new Job(ProjectPrefUtil.bind("savedState.jobName")) {
4527 // protected IStatus run(IProgressMonitor monitor) {
4529 // // add save participant and process delta atomically
4530 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59937
4532 // new IWorkspaceRunnable() {
4533 // public void run(IProgressMonitor progress) throws CoreException {
4534 //// ISavedState savedState = workspace.addSaveParticipant(JavaCore.this,
4536 // ISavedState savedState = workspace.addSaveParticipant(plugin, manager);
4537 // if (savedState != null) {
4538 // // the event type coming from the saved state is always POST_AUTO_BUILD
4539 // // force it to be POST_CHANGE so that the delta processor can handle it
4540 // manager.deltaState.getDeltaProcessor().overridenEventType =
4541 // IResourceChangeEvent.POST_CHANGE;
4542 // savedState.processResourceChangeEvents(manager.deltaState);
4547 // } catch (CoreException e) {
4548 // return e.getStatus();
4550 // return Status.OK_STATUS;
4553 // processSavedState.setSystem(true);
4554 // processSavedState.setPriority(Job.SHORT); // process asap
4555 // processSavedState.schedule();
4556 // } catch (RuntimeException e) {
4557 // manager.shutdown();
4562 * (non-Javadoc) Shutdown the JavaCore plug-in. <p> De-registers the
4563 * JavaModelManager as a resource changed listener and save participant. <p>
4565 * @see org.eclipse.core.runtime.Plugin#stop(BundleContext)
4567 // public static void stop(Plugin plugin, BundleContext context)
4568 // throws Exception {
4570 // plugin.savePluginPreferences();
4571 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4572 // workspace.removeResourceChangeListener(JavaModelManager
4573 // .getJavaModelManager().deltaState);
4574 // workspace.removeSaveParticipant(plugin);
4576 // JavaModelManager.getJavaModelManager().shutdown();
4578 // // ensure we call super.stop as the last thing
4579 // // super.stop(context);