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$
298 * Possible configurable option ID.
300 * @see #getDefaultOptions
302 public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID
303 + ".compiler.problem.unreachableCode"; //$NON-NLS-1$
306 * Possible configurable option ID.
308 * @see #getDefaultOptions
310 public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID
311 + ".compiler.problem.invalidImport"; //$NON-NLS-1$
314 * Possible configurable option ID.
316 * @see #getDefaultOptions
318 public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID
319 + ".compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
322 * Possible configurable option ID.
324 * @see #getDefaultOptions
326 public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID
327 + ".compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
330 * Possible configurable option ID.
332 * @see #getDefaultOptions
334 public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID
335 + ".compiler.problem.deprecation"; //$NON-NLS-1$
338 * Possible configurable option ID.
340 * @see #getDefaultOptions
343 public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID
344 + ".compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
347 * Possible configurable option ID.
349 * @see #getDefaultOptions
351 public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID
352 + ".compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
355 * Possible configurable option ID.
357 * @see #getDefaultOptions
359 public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID
360 + ".compiler.problem.unusedLocal"; //$NON-NLS-1$
363 * Possible configurable option ID.
365 * @see #getDefaultOptions
367 public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID
368 + ".compiler.problem.unusedParameter"; //$NON-NLS-1$
371 * Possible configurable option ID.
373 * @see #getDefaultOptions
376 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID
377 + ".compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
380 * Possible configurable option ID.
382 * @see #getDefaultOptions
385 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID
386 + ".compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
389 * Possible configurable option ID.
391 * @see #getDefaultOptions
394 public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID
395 + ".compiler.problem.unusedImport"; //$NON-NLS-1$
398 * Possible configurable option ID.
400 * @see #getDefaultOptions
402 public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID
403 + ".compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
406 * Possible configurable option ID.
408 * @see #getDefaultOptions
411 public static final String COMPILER_PB_NON_NLS_STRING_LITERAL = PLUGIN_ID
412 + ".compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
415 * Possible configurable option ID.
417 * @see #getDefaultOptions
420 public static final String COMPILER_PB_ASSERT_IDENTIFIER = PLUGIN_ID
421 + ".compiler.problem.assertIdentifier"; //$NON-NLS-1$
424 * Possible configurable option ID.
426 * @see #getDefaultOptions
429 public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID
430 + ".compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
433 * Possible configurable option ID.
435 * @see #getDefaultOptions
438 public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID
439 + ".compiler.problem.noEffectAssignment"; //$NON-NLS-1$
442 * Possible configurable option ID.
444 * @see #getDefaultOptions
447 public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID
448 + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
451 * Possible configurable option ID.
453 * @see #getDefaultOptions
456 public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID
457 + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
460 * Possible configurable option ID.
462 * @see #getDefaultOptions
465 public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID
466 + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
469 * Possible configurable option ID.
471 * @see #getDefaultOptions
474 public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID
475 + ".compiler.maxProblemPerUnit"; //$NON-NLS-1$
478 * Possible configurable option ID.
480 * @see #getDefaultOptions
483 public static final String COMPILER_SOURCE = PLUGIN_ID + ".compiler.source"; //$NON-NLS-1$
486 * Possible configurable option ID.
488 * @see #getDefaultOptions
491 public static final String COMPILER_COMPLIANCE = PLUGIN_ID
492 + ".compiler.compliance"; //$NON-NLS-1$
495 * Possible configurable option ID.
497 * @see #getDefaultOptions
500 public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID
501 + ".compiler.taskPriorities"; //$NON-NLS-1$
504 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
506 * @see #getDefaultOptions
509 public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$
512 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
514 * @see #getDefaultOptions
517 public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$
520 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
522 * @see #getDefaultOptions
525 public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$
528 * Possible configurable option ID.
530 * @see #getDefaultOptions
532 public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID
533 + ".computeJavaBuildOrder"; //$NON-NLS-1$
536 * Possible configurable option ID.
538 * @see #getDefaultOptions
541 public static final String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER = PLUGIN_ID
542 + ".builder.resourceCopyExclusionFilter"; //$NON-NLS-1$
545 * Possible configurable option ID.
547 * @see #getDefaultOptions
550 public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID
551 + ".builder.duplicateResourceTask"; //$NON-NLS-1$
554 * Possible configurable option ID.
556 * @see #getDefaultOptions
559 public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID
560 + ".builder.cleanOutputFolder"; //$NON-NLS-1$
563 * Possible configurable option ID.
565 * @see #getDefaultOptions
568 public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID
569 + ".incompleteClasspath"; //$NON-NLS-1$
572 * Possible configurable option ID.
574 * @see #getDefaultOptions
577 public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID
578 + ".circularClasspath"; //$NON-NLS-1$
581 * Possible configurable option ID.
583 * @see #getDefaultOptions
586 public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID
587 + ".builder.invalidClasspath"; //$NON-NLS-1$
590 * Possible configurable option ID.
592 * @see #getDefaultOptions
595 public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID
596 + ".classpath.exclusionPatterns"; //$NON-NLS-1$
599 * Possible configurable option ID.
601 * @see #getDefaultOptions
604 public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID
605 + ".classpath.multipleOutputLocations"; //$NON-NLS-1$
612 public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$
615 * Default task priority
619 public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; //$NON-NLS-1$
622 * Possible configurable option ID
624 * @see #getDefaultOptions
627 public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID
628 + ".formatter.space.castexpression"; //$NON-NLS-1$
631 * Possible configurable option ID.
633 * @see #getDefaultOptions
636 public static final String CODEASSIST_VISIBILITY_CHECK = PLUGIN_ID
637 + ".codeComplete.visibilityCheck"; //$NON-NLS-1$
640 * Possible configurable option ID.
642 * @see #getDefaultOptions
645 public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID
646 + ".codeComplete.forceImplicitQualification"; //$NON-NLS-1$
649 * Possible configurable option ID.
651 * @see #getDefaultOptions
654 public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID
655 + ".codeComplete.fieldPrefixes"; //$NON-NLS-1$
658 * Possible configurable option ID.
660 * @see #getDefaultOptions
663 public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID
664 + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
667 * Possible configurable option ID.
669 * @see #getDefaultOptions
672 public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID
673 + ".codeComplete.localPrefixes"; //$NON-NLS-1$
676 * Possible configurable option ID.
678 * @see #getDefaultOptions
681 public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID
682 + ".codeComplete.argumentPrefixes"; //$NON-NLS-1$
685 * Possible configurable option ID.
687 * @see #getDefaultOptions
690 public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID
691 + ".codeComplete.fieldSuffixes"; //$NON-NLS-1$
694 * Possible configurable option ID.
696 * @see #getDefaultOptions
699 public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID
700 + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
703 * Possible configurable option ID.
705 * @see #getDefaultOptions
708 public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID
709 + ".codeComplete.localSuffixes"; //$NON-NLS-1$
712 * Possible configurable option ID.
714 * @see #getDefaultOptions
717 public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID
718 + ".codeComplete.argumentSuffixes"; //$NON-NLS-1$
720 // *************** Possible values for configurable options.
721 // ********************
724 * Possible configurable option value.
726 * @see #getDefaultOptions
728 public static final String GENERATE = "generate"; //$NON-NLS-1$
731 * Possible configurable option value.
733 * @see #getDefaultOptions
735 public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
738 * Possible configurable option value.
740 * @see #getDefaultOptions
742 public static final String PRESERVE = "preserve"; //$NON-NLS-1$
745 * Possible configurable option value.
747 * @see #getDefaultOptions
749 public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
752 * Possible configurable option value.
754 * @see #getDefaultOptions
756 public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$
759 * Possible configurable option value.
761 * @see #getDefaultOptions
763 public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$
766 * Possible configurable option value.
768 * @see #getDefaultOptions
771 public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
774 * Possible configurable option value.
776 * @see #getDefaultOptions
779 public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
782 * Possible configurable option value.
784 * @see #getDefaultOptions
787 public static final String ABORT = "abort"; //$NON-NLS-1$
790 * Possible configurable option value.
792 * @see #getDefaultOptions
794 public static final String ERROR = "error"; //$NON-NLS-1$
797 * Possible configurable option value.
799 * @see #getDefaultOptions
801 public static final String WARNING = "warning"; //$NON-NLS-1$
804 * Possible configurable option value.
806 * @see #getDefaultOptions
808 public static final String IGNORE = "ignore"; //$NON-NLS-1$
811 * Possible configurable option value.
813 * @see #getDefaultOptions
815 public static final String COMPUTE = "compute"; //$NON-NLS-1$
818 * Possible configurable option value.
820 * @see #getDefaultOptions
825 * Returns a table of all known configurable options with their default
826 * values. These options allow to configure the behaviour of the underlying
827 * components. The client may safely use the result as a template that they
828 * can modify and then pass to <code>setOptions</code>.
830 * Helper constants have been defined on JavaCore for each of the option ID
831 * and their possible constant values.
833 * Note: more options might be added in further releases.
837 * RECOGNIZED OPTIONS:
838 * COMPILER / Generating Local Variable Debug Attribute
839 * When generated, this attribute will enable local variable names
840 * to be displayed in debugger, only in place where variables are
841 * definitely assigned (.class file is then bigger)
842 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.localVariable"
843 * - possible values: { "generate", "do not generate" }
844 * - default: "generate"
846 * COMPILER / Generating Line Number Debug Attribute
847 * When generated, this attribute will enable source code highlighting in debugger
848 * (.class file is then bigger).
849 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.lineNumber"
850 * - possible values: { "generate", "do not generate" }
851 * - default: "generate"
853 * COMPILER / Generating Source Debug Attribute
854 * When generated, this attribute will enable the debugger to present the
855 * corresponding source code.
856 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.sourceFile"
857 * - possible values: { "generate", "do not generate" }
858 * - default: "generate"
860 * COMPILER / Preserving Unused Local Variables
861 * Unless requested to preserve unused local variables (i.e. never read), the
862 * compiler will optimize them out, potentially altering debugging
863 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.unusedLocal"
864 * - possible values: { "preserve", "optimize out" }
865 * - default: "preserve"
867 * COMPILER / Defining Target Java Platform
868 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
869 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
870 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.targetPlatform"
871 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
872 * - default: "1.1"
874 * COMPILER / Reporting Unreachable Code
875 * Unreachable code can optionally be reported as an error, warning or simply
876 * ignored. The bytecode generation will always optimized it out.
877 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unreachableCode"
878 * - possible values: { "error", "warning", "ignore" }
879 * - default: "error"
881 * COMPILER / Reporting Invalid Import
882 * An import statement that cannot be resolved might optionally be reported
883 * as an error, as a warning or ignored.
884 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.invalidImport"
885 * - possible values: { "error", "warning", "ignore" }
886 * - default: "error"
888 * COMPILER / Reporting Attempt to Override Package-Default Method
889 * A package default method is not visible in a different package, and thus
890 * cannot be overridden. When enabling this option, the compiler will signal
891 * such scenarii either as an error or a warning.
892 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
893 * - possible values: { "error", "warning", "ignore" }
894 * - default: "warning"
896 * COMPILER / Reporting Method With Constructor Name
897 * Naming a method with a constructor name is generally considered poor
898 * style programming. When enabling this option, the compiler will signal such
899 * scenarii either as an error or a warning.
900 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.methodWithConstructorName"
901 * - possible values: { "error", "warning", "ignore" }
902 * - default: "warning"
904 * COMPILER / Reporting Deprecation
905 * When enabled, the compiler will signal use of deprecated API either as an
906 * error or a warning.
907 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecation"
908 * - possible values: { "error", "warning", "ignore" }
909 * - default: "warning"
911 * COMPILER / Reporting Deprecation Inside Deprecated Code
912 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
913 * The severity of the problem is controlled with option "org.phpeclipse.phpdt.core.compiler.problem.deprecation".
914 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
915 * - possible values: { "enabled", "disabled" }
916 * - default: "disabled"
918 * COMPILER / Reporting Hidden Catch Block
919 * Locally to a try statement, some catch blocks may hide others , e.g.
920 * try { throw new java.io.CharConversionException();
921 * } catch (java.io.CharConversionException e) {
922 * } catch (java.io.IOException e) {}.
923 * When enabling this option, the compiler will issue an error or a warning for hidden
924 * catch blocks corresponding to checked exceptions
925 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.hiddenCatchBlock"
926 * - possible values: { "error", "warning", "ignore" }
927 * - default: "warning"
929 * COMPILER / Reporting Unused Local
930 * When enabled, the compiler will issue an error or a warning for unused local
931 * variables (i.e. variables never read from)
932 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedLocal"
933 * - possible values: { "error", "warning", "ignore" }
934 * - default: "ignore"
936 * COMPILER / Reporting Unused Parameter
937 * When enabled, the compiler will issue an error or a warning for unused method
938 * parameters (i.e. parameters never read from)
939 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedParameter"
940 * - possible values: { "error", "warning", "ignore" }
941 * - default: "ignore"
943 * COMPILER / Reporting Unused Import
944 * When enabled, the compiler will issue an error or a warning for unused import
946 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedImport"
947 * - possible values: { "error", "warning", "ignore" }
948 * - default: "warning"
950 * COMPILER / Reporting Synthetic Access Emulation
951 * When enabled, the compiler will issue an error or a warning whenever it emulates
952 * access to a non-accessible member of an enclosing type. Such access can have
953 * performance implications.
954 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.syntheticAccessEmulation"
955 * - possible values: { "error", "warning", "ignore" }
956 * - default: "ignore"
958 * COMPILER / Reporting Non-Externalized String Literal
959 * When enabled, the compiler will issue an error or a warning for non externalized
960 * String literal (i.e. non tagged with //$NON-NLS-<n>$).
961 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
962 * - possible values: { "error", "warning", "ignore" }
963 * - default: "ignore"
965 * COMPILER / Reporting Usage of 'assert' Identifier
966 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
967 * used as an identifier (reserved keyword in 1.4)
968 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.assertIdentifier"
969 * - possible values: { "error", "warning", "ignore" }
970 * - default: "ignore"
972 * COMPILER / Reporting Usage of expression receiver on static invocation/field access
973 * When enabled, the compiler will issue an error or a warning whenever a static field
974 * or method is accessed with an expression receiver.
975 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.staticAccessReceiver"
976 * - possible values: { "error", "warning", "ignore" }
977 * - default: "warning"
979 * COMPILER / Reporting Assignment with no effect
980 * When enabled, the compiler will issue an error or a warning whenever an assignment
981 * has no effect (e.g 'x = x').
982 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.noEffectAssignment"
983 * - possible values: { "error", "warning", "ignore" }
984 * - default: "warning"
986 * COMPILER / Setting Source Compatibility Mode
987 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
988 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
989 * level should be set to "1.4" and the compliance mode should be "1.4".
990 * - option id: "org.phpeclipse.phpdt.core.compiler.source"
991 * - possible values: { "1.3", "1.4" }
992 * - default: "1.3"
994 * COMPILER / Setting Compliance Level
995 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
996 * should not go beyond "1.3" level.
997 * - option id: "org.phpeclipse.phpdt.core.compiler.compliance"
998 * - possible values: { "1.3", "1.4" }
999 * - default: "1.3"
1001 * COMPILER / Maximum number of problems reported per compilation unit
1002 * Specify the maximum number of problems reported on each compilation unit.
1003 * - option id: "org.phpeclipse.phpdt.core.compiler.maxProblemPerUnit"
1004 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
1005 * - default: "100"
1007 * COMPILER / Define the Automatic Task Tags
1008 * When the tag is non empty, the compiler will issue a task marker whenever it encounters
1009 * one of the corresponding tag inside any comment in Java source code.
1010 * Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed.
1011 * - option id: "org.phpeclipse.phpdt.core.compiler.taskTags"
1012 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card
1013 * - default: ""
1014 * COMPILER / Define the Automatic Task Priorities
1015 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
1016 * of the task markers issued by the compiler.
1017 * If the default is specified, the priority of each task marker is "NORMAL".
1018 * - option id: "org.phpeclipse.phpdt.core.compiler.taskPriorities"
1019 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
1020 * - default: ""
1022 * BUILDER / Specifying Filters for Resource Copying Control
1023 * Allow to specify some filters to control the resource copy process.
1024 * - option id: "org.phpeclipse.phpdt.core.builder.resourceCopyExclusionFilter"
1025 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
1026 * or the name of a folder which ends with '/'
1027 * - default: ""
1029 * BUILDER / Abort if Invalid Classpath
1030 * Allow to toggle the builder to abort if the classpath is invalid
1031 * - option id: "org.phpeclipse.phpdt.core.builder.invalidClasspath"
1032 * - possible values: { "abort", "ignore" }
1033 * - default: "ignore"
1035 * BUILDER / Cleaning Output Folder(s)
1036 * Indicate whether the JavaBuilder is allowed to clean the output folders
1037 * when performing full build operations.
1038 * - option id: "org.phpeclipse.phpdt.core.builder.cleanOutputFolder"
1039 * - possible values: { "clean", "ignore" }
1040 * - default: "clean"
1042 * JAVACORE / Computing Project Build Order
1043 * Indicate whether JavaCore should enforce the project build order to be based on
1044 * the classpath prerequisite chain. When requesting to compute, this takes over
1045 * the platform default order (based on project references).
1046 * - option id: "org.phpeclipse.phpdt.core.computeJavaBuildOrder"
1047 * - possible values: { "compute", "ignore" }
1048 * - default: "ignore"
1050 * JAVACORE / Specify Default Source Encoding Format
1051 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
1052 * to 'ResourcesPlugin.getEncoding()'.
1053 * - option id: "org.phpeclipse.phpdt.core.encoding"
1054 * - possible values: { any of the supported encoding name}.
1055 * - default: <platform default>
1057 * JAVACORE / Reporting Incomplete Classpath
1058 * An entry on the classpath doesn't exist or is not visible (e.g. a referenced project is closed).
1059 * - option id: "org.phpeclipse.phpdt.core.incompleteClasspath"
1060 * - possible values: { "error", "warning"}
1061 * - default: "error"
1063 * JAVACORE / Reporting Classpath Cycle
1064 * A project is involved in a cycle.
1065 * - option id: "org.phpeclipse.phpdt.core.circularClasspath"
1066 * - possible values: { "error", "warning" }
1067 * - default: "error"
1069 * FORMATTER / Inserting New Line Before Opening Brace
1070 * When Insert, a new line is inserted before an opening brace, otherwise nothing
1072 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.openingBrace"
1073 * - possible values: { "insert", "do not insert" }
1074 * - default: "do not insert"
1076 * FORMATTER / Inserting New Line Inside Control Statement
1077 * When Insert, a new line is inserted between } and following else, catch, finally
1078 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.controlStatement"
1079 * - possible values: { "insert", "do not insert" }
1080 * - default: "do not insert"
1082 * FORMATTER / Clearing Blank Lines
1083 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
1084 * and all others removed.
1085 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.clearAll"
1086 * - possible values: { "clear all", "preserve one" }
1087 * - default: "preserve one"
1089 * FORMATTER / Inserting New Line Between Else/If
1090 * When Insert, a blank line is inserted between an else and an if when they are
1091 * contiguous. When choosing to not insert, else-if will be kept on the same
1092 * line when possible.
1093 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.elseIf"
1094 * - possible values: { "insert", "do not insert" }
1095 * - default: "do not insert"
1097 * FORMATTER / Inserting New Line In Empty Block
1098 * When insert, a line break is inserted between contiguous { and }, if } is not followed
1100 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.emptyBlock"
1101 * - possible values: { "insert", "do not insert" }
1102 * - default: "insert"
1104 * FORMATTER / Splitting Lines Exceeding Length
1105 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
1106 * disable line splitting
1107 * - option id: "org.phpeclipse.phpdt.core.formatter.lineSplit"
1108 * - possible values: "<n>", where n is zero or a positive integer
1109 * - default: "80"
1111 * FORMATTER / Compacting Assignment
1112 * Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space
1113 * is inserted before the assignment operator
1114 * - option id: "org.phpeclipse.phpdt.core.formatter.style.assignment"
1115 * - possible values: { "compact", "normal" }
1116 * - default: "normal"
1118 * FORMATTER / Defining Indentation Character
1119 * Either choose to indent with tab characters or spaces
1120 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.char"
1121 * - possible values: { "tab", "space" }
1122 * - default: "tab"
1124 * FORMATTER / Defining Space Indentation Length
1125 * When using spaces, set the amount of space characters to use for each
1127 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.size"
1128 * - possible values: "<n>", where n is a positive integer
1129 * - default: "4"
1131 * CODEASSIST / Activate Visibility Sensitive Completion
1132 * When active, completion doesn't show that you can not see
1133 * (e.g. you can not see private methods of a super class).
1134 * - option id: "org.phpeclipse.phpdt.core.codeComplete.visibilityCheck"
1135 * - possible values: { "enabled", "disabled" }
1136 * - default: "disabled"
1138 * CODEASSIST / Automatic Qualification of Implicit Members
1139 * When active, completion automatically qualifies completion on implicit
1140 * field references and message expressions.
1141 * - option id: "org.phpeclipse.phpdt.core.codeComplete.forceImplicitQualification"
1142 * - possible values: { "enabled", "disabled" }
1143 * - default: "disabled"
1145 * CODEASSIST / Define the Prefixes for Field Name
1146 * When the prefixes is non empty, completion for field name will begin with
1147 * one of the proposed prefixes.
1148 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldPrefixes"
1149 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1150 * - default: ""
1152 * CODEASSIST / Define the Prefixes for Static Field Name
1153 * When the prefixes is non empty, completion for static field name will begin with
1154 * one of the proposed prefixes.
1155 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldPrefixes"
1156 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1157 * - default: ""
1159 * CODEASSIST / Define the Prefixes for Local Variable Name
1160 * When the prefixes is non empty, completion for local variable name will begin with
1161 * one of the proposed prefixes.
1162 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localPrefixes"
1163 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1164 * - default: ""
1166 * CODEASSIST / Define the Prefixes for Argument Name
1167 * When the prefixes is non empty, completion for argument name will begin with
1168 * one of the proposed prefixes.
1169 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentPrefixes"
1170 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1171 * - default: ""
1173 * CODEASSIST / Define the Suffixes for Field Name
1174 * When the suffixes is non empty, completion for field name will end with
1175 * one of the proposed suffixes.
1176 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldSuffixes"
1177 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1178 * - default: ""
1180 * CODEASSIST / Define the Suffixes for Static Field Name
1181 * When the suffixes is non empty, completion for static field name will end with
1182 * one of the proposed suffixes.
1183 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldSuffixes"
1184 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1185 * - default: ""
1187 * CODEASSIST / Define the Suffixes for Local Variable Name
1188 * When the suffixes is non empty, completion for local variable name will end with
1189 * one of the proposed suffixes.
1190 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localSuffixes"
1191 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1192 * - default: ""
1194 * CODEASSIST / Define the Suffixes for Argument Name
1195 * When the suffixes is non empty, completion for argument name will end with
1196 * one of the proposed suffixes.
1197 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentSuffixes"
1198 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
1199 * - default: ""
1202 * @return a mutable table containing the default settings of all known options
1215 // public static Hashtable getDefaultOptions() {
1217 // Hashtable defaultOptions = new Hashtable(10);
1219 // // see #initializeDefaultPluginPreferences() for changing default
1221 // Preferences preferences = getPlugin().getPluginPreferences();
1222 // HashSet optionNames = OptionNames;
1224 // // get preferences set to their default
1225 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1226 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1227 // String propertyName = defaultPropertyNames[i];
1228 // if (optionNames.contains(propertyName)) {
1229 // defaultOptions.put(propertyName,
1230 // preferences.getDefaultString(propertyName));
1233 // // get preferences not set to their default
1234 // String[] propertyNames = preferences.propertyNames();
1235 // for (int i = 0; i < propertyNames.length; i++) {
1236 // String propertyName = propertyNames[i];
1237 // if (optionNames.contains(propertyName)) {
1238 // defaultOptions.put(propertyName,
1239 // preferences.getDefaultString(propertyName));
1242 // // get encoding through resource plugin
1243 // defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1245 // return defaultOptions;
1248 * Helper method for returning one option value only. Equivalent to
1249 * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
1250 * may answer <code>null</code> if this option does not exist.
1252 * For a complete description of the configurable options, see
1253 * <code>getDefaultOptions</code>.
1257 * the name of an option
1258 * @return the String value of a given option
1259 * @see JavaCore#getDefaultOptions
1262 // public static String getOption(String optionName) {
1264 // if (CORE_ENCODING.equals(optionName)) {
1265 // return ResourcesPlugin.getEncoding();
1267 // if (OptionNames.contains(optionName)) {
1268 // Preferences preferences = getPlugin().getPluginPreferences();
1269 // return preferences.getString(optionName).trim();
1274 * Returns the table of the current options. Initially, all options have
1275 * their default values, and this method returns a table that includes all
1278 * For a complete description of the configurable options, see
1279 * <code>getDefaultOptions</code>.
1282 * @return table of current settings of all options (key type:
1283 * <code>String</code>; value type: <code>String</code>)
1284 * @see JavaCore#getDefaultOptions
1286 // public static Hashtable getOptions() {
1288 // Hashtable options = new Hashtable(10);
1290 // // see #initializeDefaultPluginPreferences() for changing default
1292 // Plugin plugin = getPlugin();
1293 // if (plugin != null) {
1294 // Preferences preferences = getPlugin().getPluginPreferences();
1295 // HashSet optionNames = OptionNames;
1297 // // get preferences set to their default
1298 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1299 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1300 // String propertyName = defaultPropertyNames[i];
1301 // if (optionNames.contains(propertyName)) {
1302 // options.put(propertyName, preferences.getDefaultString(propertyName));
1305 // // get preferences not set to their default
1306 // String[] propertyNames = preferences.propertyNames();
1307 // for (int i = 0; i < propertyNames.length; i++) {
1308 // String propertyName = propertyNames[i];
1309 // if (optionNames.contains(propertyName)) {
1310 // options.put(propertyName, preferences.getString(propertyName).trim());
1313 // // get encoding through resource plugin
1314 // options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1319 * Sets the current table of options. All and only the options explicitly
1320 * included in the given table are remembered; all previous option settings
1321 * are forgotten, including ones not explicitly mentioned.
1323 * For a complete description of the configurable options, see
1324 * <code>getDefaultOptions</code>.
1328 * the new options (key type: <code>String</code>; value type:
1329 * <code>String</code>), or <code>null</code> to reset all
1330 * options to their default values
1331 * @see JavaCore#getDefaultOptions
1333 // public static void setOptions(Hashtable newOptions) {
1335 // // see #initializeDefaultPluginPreferences() for changing default
1337 // Preferences preferences = getPlugin().getPluginPreferences();
1339 // if (newOptions == null) {
1340 // newOptions = getDefaultOptions();
1342 // Enumeration keys = newOptions.keys();
1343 // while (keys.hasMoreElements()) {
1344 // String key = (String) keys.nextElement();
1345 // if (!OptionNames.contains(key))
1346 // continue; // unrecognized option
1347 // if (key.equals(CORE_ENCODING))
1348 // continue; // skipped, contributed by resource prefs
1349 // String value = (String) newOptions.get(key);
1350 // preferences.setValue(key, value);
1353 // // persist options
1354 // getPlugin().savePluginPreferences();
1356 public static IProject[] getPHPProjects() {
1357 List phpProjectsList = new ArrayList();
1358 IProject[] workspaceProjects = PHPeclipsePlugin.getWorkspace()
1359 .getRoot().getProjects();
1361 for (int i = 0; i < workspaceProjects.length; i++) {
1362 IProject iProject = workspaceProjects[i];
1363 if (isPHPProject(iProject))
1364 phpProjectsList.add(iProject);
1367 IProject[] phpProjects = new IProject[phpProjectsList.size()];
1368 return (IProject[]) phpProjectsList.toArray(phpProjects);
1371 // public static PHPProject getPHPProject(String name) {
1372 // IProject aProject =
1373 // PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
1374 // if (isPHPProject(aProject)) {
1375 // PHPProject thePHPProject = new PHPProject();
1376 // thePHPProject.setProject(aProject);
1377 // return thePHPProject;
1382 public static boolean isPHPProject(IProject aProject) {
1384 return aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID);
1385 } catch (CoreException e) {
1391 // public static PHPFile create(IFile aFile) {
1392 // if (PHPFile.EXTENSION.equalsIgnoreCase(aFile.getFileExtension()))
1393 // return new PHPFile(aFile);
1394 // if (PHPFile.EXTENSION1.equalsIgnoreCase(aFile.getFileExtension()))
1395 // return new PHPFile(aFile);
1396 // if (PHPFile.EXTENSION2.equalsIgnoreCase(aFile.getFileExtension()))
1397 // return new PHPFile(aFile);
1398 // if (PHPFile.EXTENSION3.equalsIgnoreCase(aFile.getFileExtension()))
1399 // return new PHPFile(aFile);
1400 // if (PHPFile.EXTENSION4.equalsIgnoreCase(aFile.getFileExtension()))
1401 // return new PHPFile(aFile);
1402 // if (PHPFile.EXTENSION5.equalsIgnoreCase(aFile.getFileExtension()))
1403 // return new PHPFile(aFile);
1408 // public static PHPProject create(IProject aProject) {
1411 // if (aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1412 // PHPProject project = new PHPProject();
1413 // project.setProject(aProject);
1416 // } catch (CoreException e) {
1417 // System.err.println("Exception occurred in PHPCore#create(IProject): " +
1424 public static void addPHPNature(IProject project, IProgressMonitor monitor)
1425 throws CoreException {
1426 if (!project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1427 IProjectDescription description = project.getDescription();
1428 String[] prevNatures = description.getNatureIds();
1429 String[] newNatures = new String[prevNatures.length + 1];
1430 System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
1431 newNatures[prevNatures.length] = PHPeclipsePlugin.PHP_NATURE_ID;
1432 description.setNatureIds(newNatures);
1433 project.setDescription(description, monitor);
1438 * Returns the single instance of the PHP core plug-in runtime class.
1440 * @return the single instance of the PHP core plug-in runtime class
1442 public static Plugin getPlugin() {
1443 return PHPeclipsePlugin.getDefault();
1447 * Runs the given action as an atomic Java model operation.
1449 * After running a method that modifies java elements, registered listeners
1450 * receive after-the-fact notification of what just transpired, in the form
1451 * of a element changed event. This method allows clients to call a number
1452 * of methods that modify java elements and only have element changed event
1453 * notifications reported at the end of the entire batch.
1456 * If this method is called outside the dynamic scope of another such call,
1457 * this method runs the action and then reports a single element changed
1458 * event describing the net effect of all changes done to java elements by
1462 * If this method is called in the dynamic scope of another such call, this
1463 * method simply runs the action.
1467 * the action to perform
1469 * a progress monitor, or <code>null</code> if progress
1470 * reporting and cancellation are not desired
1471 * @exception CoreException
1472 * if the operation failed.
1475 // public static void run(IWorkspaceRunnable action, IProgressMonitor
1476 // monitor) throws CoreException {
1477 // run(action, ResourcesPlugin.getWorkspace().getRoot(), monitor);
1480 * Runs the given action as an atomic Java model operation.
1482 * After running a method that modifies java elements, registered listeners
1483 * receive after-the-fact notification of what just transpired, in the form
1484 * of a element changed event. This method allows clients to call a number
1485 * of methods that modify java elements and only have element changed event
1486 * notifications reported at the end of the entire batch.
1489 * If this method is called outside the dynamic scope of another such call,
1490 * this method runs the action and then reports a single element changed
1491 * event describing the net effect of all changes done to java elements by
1495 * If this method is called in the dynamic scope of another such call, this
1496 * method simply runs the action.
1499 * The supplied scheduling rule is used to determine whether this operation
1500 * can be run simultaneously with workspace changes in other threads. See
1501 * <code>IWorkspace.run(...)</code> for more details.
1505 * the action to perform
1507 * the scheduling rule to use when running this operation, or
1508 * <code>null</code> if there are no scheduling restrictions
1509 * for this operation.
1511 * a progress monitor, or <code>null</code> if progress
1512 * reporting and cancellation are not desired
1513 * @exception CoreException
1514 * if the operation failed.
1517 // public static void run(IWorkspaceRunnable action, ISchedulingRule rule,
1518 // IProgressMonitor monitor) throws CoreException {
1519 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
1520 // if (workspace.isTreeLocked()) {
1521 // new BatchOperation(action).run(monitor);
1523 // // use IWorkspace.run(...) to ensure that a build will be done in
1525 // workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE,
1531 * Adds the given listener for changes to Java elements. Has no effect if an
1532 * identical listener is already registered.
1534 * This listener will only be notified during the POST_CHANGE resource
1535 * change notification and any reconcile operation (POST_RECONCILE). For
1536 * finer control of the notification, use
1537 * <code>addElementChangedListener(IElementChangedListener,int)</code>,
1538 * which allows to specify a different eventMask.
1540 * @see ElementChangedEvent
1544 public static void addElementChangedListener(
1545 IElementChangedListener listener) {
1546 addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE
1547 | ElementChangedEvent.POST_RECONCILE);
1551 * Adds the given listener for changes to Java elements. Has no effect if an
1552 * identical listener is already registered. After completion of this
1553 * method, the given listener will be registered for exactly the specified
1554 * events. If they were previously registered for other events, they will be
1557 * Once registered, a listener starts receiving notification of changes to
1558 * java elements in the model. The listener continues to receive
1559 * notifications until it is replaced or removed.
1562 * Listeners can listen for several types of event as defined in
1563 * <code>ElementChangeEvent</code>. Clients are free to register for any
1564 * number of event types however if they register for more than one, it is
1565 * their responsibility to ensure they correctly handle the case where the
1566 * same java element change shows up in multiple notifications. Clients are
1567 * guaranteed to receive only the events for which they are registered.
1573 * the bit-wise OR of all event types of interest to the listener
1574 * @see IElementChangedListener
1575 * @see ElementChangedEvent
1576 * @see #removeElementChangedListener(IElementChangedListener)
1579 public static void addElementChangedListener(
1580 IElementChangedListener listener, int eventMask) {
1581 JavaModelManager.getJavaModelManager().addElementChangedListener(
1582 listener, eventMask);
1586 * Configures the given marker attribute map for the given Java element.
1587 * Used for markers, which denote a Java element rather than a resource.
1590 * the mutable marker attribute map (key type:
1591 * <code>String</code>, value type: <code>String</code>)
1593 * the Java element for which the marker needs to be configured
1595 public static void addJavaElementMarkerAttributes(Map attributes,
1596 IJavaElement element) {
1597 // if (element instanceof IMember)
1598 // element = ((IMember) element).getClassFile();
1599 if (attributes != null && element != null)
1600 attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier());
1604 * Adds the given listener for POST_CHANGE resource change events to the Java core.
1605 * The listener is guarantied to be notified of the POST_CHANGE resource change event before
1606 * the Java core starts processing the resource change event itself.
1608 * Has no effect if an identical listener is already registered.
1611 * @param listener the listener
1612 * @see #removePreProcessingResourceChangedListener(IResourceChangeListener)
1615 public static void addPreProcessingResourceChangedListener(IResourceChangeListener listener) {
1616 JavaModelManager.getJavaModelManager().deltaState.addPreResourceChangedListener(listener);
1619 * Configures the given marker for the given Java element. Used for markers,
1620 * which denote a Java element rather than a resource.
1623 * the marker to be configured
1625 * the Java element for which the marker needs to be configured
1626 * @exception CoreException
1627 * if the <code>IMarker.setAttribute</code> on the marker
1630 public void configureJavaElementMarker(IMarker marker, IJavaElement element)
1631 throws CoreException {
1632 // if (element instanceof IMember)
1633 // element = ((IMember) element).getClassFile();
1634 if (marker != null && element != null)
1635 marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier());
1639 * Returns the Java model element corresponding to the given handle
1640 * identifier generated by <code>IJavaElement.getHandleIdentifier()</code>,
1641 * or <code>null</code> if unable to create the associated element.
1643 public static IJavaElement create(String handleIdentifier) {
1644 if (handleIdentifier == null) {
1648 return JavaModelManager.getJavaModelManager().getHandleFromMemento(
1650 } catch (JavaModelException e) {
1656 * Returns the Java model element corresponding to the given handle identifier
1657 * generated by <code>IJavaElement.getHandleIdentifier()</code>, or
1658 * <code>null</code> if unable to create the associated element.
1659 * If the returned Java element is an <code>ICompilationUnit</code>, its owner
1660 * is the given owner if such a working copy exists, otherwise the compilation unit
1661 * is a primary compilation unit.
1663 * @param handleIdentifier the given handle identifier
1664 * @param owner the owner of the returned compilation unit, ignored if the returned
1665 * element is not a compilation unit
1666 * @return the Java element corresponding to the handle identifier
1669 public static IJavaElement create(String handleIdentifier, WorkingCopyOwner owner) {
1670 if (handleIdentifier == null) {
1673 MementoTokenizer memento = new MementoTokenizer(handleIdentifier);
1674 JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel();
1675 return model.getHandleFromMemento(memento, owner);
1679 * Returns the Java element corresponding to the given file, or
1680 * <code>null</code> if unable to associate the given file with a Java
1684 * The file must be one of:
1686 * <li>a <code>.java</code> file - the element returned is the
1687 * corresponding <code>ICompilationUnit</code></li>
1688 * <li>a <code>.class</code> file - the element returned is the
1689 * corresponding <code>IClassFile</code></li>
1690 * <li>a <code>.jar</code> file - the element returned is the
1691 * corresponding <code>IPackageFragmentRoot</code></li>
1694 * Creating a Java element has the side effect of creating and opening all
1695 * of the element's parents if they are not yet open.
1699 * @return the Java element corresponding to the given file, or
1700 * <code>null</code> if unable to associate the given file with a
1703 public static IJavaElement create(IFile file) {
1704 return JavaModelManager.create(file, null);
1708 * Returns the package fragment or package fragment root corresponding to
1709 * the given folder, or <code>null</code> if unable to associate the given
1710 * folder with a Java element.
1712 * Note that a package fragment root is returned rather than a default
1715 * Creating a Java element has the side effect of creating and opening all
1716 * of the element's parents if they are not yet open.
1720 * @return the package fragment or package fragment root corresponding to
1721 * the given folder, or <code>null</code> if unable to associate
1722 * the given folder with a Java element
1724 public static IJavaElement create(IFolder folder) {
1725 return JavaModelManager.create(folder, null);
1729 * Returns the Java project corresponding to the given project.
1731 * Creating a Java Project has the side effect of creating and opening all
1732 * of the project's parents if they are not yet open.
1734 * Note that no check is done at this time on the existence or the java
1735 * nature of this project.
1739 * @return the Java project corresponding to the given project, null if the
1740 * given project is null
1742 public static IJavaProject create(IProject project) {
1743 if (project == null) {
1746 JavaModel javaModel = JavaModelManager.getJavaModelManager()
1748 return javaModel.getJavaProject(project);
1752 * Returns the Java element corresponding to the given resource, or
1753 * <code>null</code> if unable to associate the given resource with a Java
1756 * The resource must be one of:
1758 * <li>a project - the element returned is the corresponding
1759 * <code>IJavaProject</code></li>
1760 * <li>a <code>.java</code> file - the element returned is the
1761 * corresponding <code>ICompilationUnit</code></li>
1762 * <li>a <code>.class</code> file - the element returned is the
1763 * corresponding <code>IClassFile</code></li>
1764 * <li>a <code>.jar</code> file - the element returned is the
1765 * corresponding <code>IPackageFragmentRoot</code></li>
1766 * <li>a folder - the element returned is the corresponding
1767 * <code>IPackageFragmentRoot</code> or <code>IPackageFragment</code>
1769 * <li>the workspace root resource - the element returned is the
1770 * <code>IJavaModel</code></li>
1773 * Creating a Java element has the side effect of creating and opening all
1774 * of the element's parents if they are not yet open.
1777 * the given resource
1778 * @return the Java element corresponding to the given resource, or
1779 * <code>null</code> if unable to associate the given resource
1780 * with a Java element
1782 public static IJavaElement create(IResource resource) {
1783 return JavaModelManager.create(resource, null);
1787 * Returns the Java model.
1791 * @return the Java model, or <code>null</code> if the root is null
1793 public static IJavaModel create(IWorkspaceRoot root) {
1797 return JavaModelManager.getJavaModelManager().getJavaModel();
1801 * Creates and returns a class file element for the given
1802 * <code>.class</code> file. Returns <code>null</code> if unable to
1803 * recognize the class file.
1806 * the given <code>.class</code> file
1807 * @return a class file element for the given <code>.class</code> file, or
1808 * <code>null</code> if unable to recognize the class file
1810 //public static IClassFile createClassFileFrom(IFile file) {
1811 // return JavaModelManager.createClassFileFrom(file, null);
1814 * Creates and returns a compilation unit element for the given
1815 * <code>.java</code> file. Returns <code>null</code> if unable to
1816 * recognize the compilation unit.
1819 * the given <code>.java</code> file
1820 * @return a compilation unit element for the given <code>.java</code>
1821 * file, or <code>null</code> if unable to recognize the
1824 public static ICompilationUnit createCompilationUnitFrom(IFile file) {
1825 return JavaModelManager.createCompilationUnitFrom(file, null);
1829 * Creates and returns a handle for the given JAR file. The Java model
1830 * associated with the JAR's project may be created as a side effect.
1833 * the given JAR file
1834 * @return a handle for the given JAR file, or <code>null</code> if unable
1835 * to create a JAR package fragment root. (for example, if the JAR
1836 * file represents a non-Java resource)
1838 //public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile
1840 // return JavaModelManager.createJarPackageFragmentRootFrom(file, null);
1843 * Answers the project specific value for a given classpath container. In
1844 * case this container path could not be resolved, then will answer
1845 * <code>null</code>. Both the container path and the project context are
1846 * supposed to be non-null.
1848 * The containerPath is a formed by a first ID segment followed with extra
1849 * segments, which can be used as additional hints for resolution. If no
1850 * container was ever recorded for this container path onto this project
1851 * (using <code>setClasspathContainer</code>, then a
1852 * <code>ClasspathContainerInitializer</code> will be activated if any was
1853 * registered for this container ID onto the extension point
1854 * "net.sourceforge.phpdt.core.classpathContainerInitializer".
1856 * There is no assumption that the returned container must answer the exact
1857 * same containerPath when requested
1858 * <code>IClasspathContainer#getPath</code>. Indeed, the containerPath is
1859 * just an indication for resolving it to an actual container object.
1861 * Classpath container values are persisted locally to the workspace, but
1862 * are not preserved from a session to another. It is thus highly
1863 * recommended to register a <code>ClasspathContainerInitializer</code>
1864 * for each referenced container (through the extension point
1865 * "net.sourceforge.phpdt.core.ClasspathContainerInitializer").
1868 * @param containerPath
1869 * the name of the container, which needs to be resolved
1871 * a specific project in which the container is being resolved
1872 * @return the corresponding classpath container or <code>null</code> if
1873 * unable to find one.
1875 * @exception JavaModelException
1876 * if an exception occurred while resolving the container, or
1877 * if the resolved container contains illegal entries
1878 * (contains CPE_CONTAINER entries or null entries).
1880 * @see ClasspathContainerInitializer
1881 * @see IClasspathContainer
1882 * @see #setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[],
1886 //public static IClasspathContainer getClasspathContainer(final IPath
1887 // containerPath, final IJavaProject project) throws JavaModelException {
1889 // IClasspathContainer container = JavaModelManager.containerGet(project,
1891 // if (container == JavaModelManager.ContainerInitializationInProgress)
1892 // return null; // break cycle
1894 // if (container == null){
1895 // final ClasspathContainerInitializer initializer =
1896 // JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
1897 // if (initializer != null){
1898 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1899 // System.out.println("CPContainer INIT - triggering initialization of:
1900 // ["+project.getElementName()+"] " + containerPath + " using initializer:
1901 // "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
1902 // new Exception("FAKE exception for dumping current CPContainer
1903 // (["+project.getElementName()+"] "+ containerPath+ ")INIT invocation stack
1904 // trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
1906 // JavaModelManager.containerPut(project, containerPath,
1907 // JavaModelManager.ContainerInitializationInProgress); // avoid
1908 // initialization cycles
1909 // boolean ok = false;
1911 // // wrap initializer call with Safe runnable in case initializer would be
1912 // causing some grief
1913 // Platform.run(new ISafeRunnable() {
1914 // public void handleException(Throwable exception) {
1915 // ProjectPrefUtil.log(exception, "Exception occurred in classpath container
1916 // initializer: "+initializer); //$NON-NLS-1$
1918 // public void run() throws Exception {
1919 // initializer.initialize(containerPath, project);
1923 // // retrieve value (if initialization was successful)
1924 // container = JavaModelManager.containerGet(project, containerPath);
1925 // if (container == JavaModelManager.ContainerInitializationInProgress)
1926 // return null; // break cycle
1929 // if (!ok) JavaModelManager.containerPut(project, containerPath, null); //
1932 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1933 // System.out.print("CPContainer INIT - after resolution:
1934 // ["+project.getElementName()+"] " + containerPath + " --> ");
1935 // //$NON-NLS-2$//$NON-NLS-1$//$NON-NLS-3$
1936 // if (container != null){
1937 // System.out.print("container: "+container.getDescription()+" {");
1938 // //$NON-NLS-2$//$NON-NLS-1$
1939 // IClasspathEntry[] entries = container.getClasspathEntries();
1940 // if (entries != null){
1941 // for (int i = 0; i < entries.length; i++){
1942 // if (i > 0) System.out.println(", ");//$NON-NLS-1$
1943 // System.out.println(entries[i]);
1946 // System.out.println("}");//$NON-NLS-1$
1948 // System.out.println("{unbound}");//$NON-NLS-1$
1952 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1953 // System.out.println("CPContainer INIT - no initializer found for:
1954 // "+project.getElementName()+"] " + containerPath); //$NON-NLS-1$
1959 // return container;
1962 * Helper method finding the classpath container initializer registered for
1963 * a given classpath container ID or <code>null</code> if none was found
1964 * while iterating over the contributions to extension point to the
1965 * extension point "net.sourceforge.phpdt.core.classpathContainerInitializer".
1967 * A containerID is the first segment of any container path, used to
1968 * identify the registered container initializer.
1972 * a containerID identifying a registered initializer
1973 * @return ClasspathContainerInitializer - the registered classpath
1974 * container initializer or <code>null</code> if none was found.
1977 //public static ClasspathContainerInitializer
1978 // getClasspathContainerInitializer(String containerID){
1980 // Plugin jdtCorePlugin = JavaCore.getPlugin();
1981 // if (jdtCorePlugin == null) return null;
1983 // IExtensionPoint extension =
1984 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID);
1985 // if (extension != null) {
1986 // IExtension[] extensions = extension.getExtensions();
1987 // for(int i = 0; i < extensions.length; i++){
1988 // IConfigurationElement [] configElements =
1989 // extensions[i].getConfigurationElements();
1990 // for(int j = 0; j < configElements.length; j++){
1991 // String initializerID = configElements[j].getAttribute("id");
1993 // if (initializerID != null && initializerID.equals(containerID)){
1994 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
1995 // System.out.println("CPContainer INIT - found initializer: "+containerID
1997 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
2000 // Object execExt = configElements[j].createExecutableExtension("class");
2002 // if (execExt instanceof ClasspathContainerInitializer){
2003 // return (ClasspathContainerInitializer)execExt;
2005 // } catch(CoreException e) {
2014 * Returns the path held in the given classpath variable. Returns <node>null
2015 * </code> if unable to bind.
2017 * Classpath variable values are persisted locally to the workspace, and are
2018 * preserved from session to session.
2020 * Note that classpath variables can be contributed registered initializers
2021 * for, using the extension point
2022 * "net.sourceforge.phpdt.core.classpathVariableInitializer". If an initializer is
2023 * registered for a variable, its persisted value will be ignored: its
2024 * initializer will thus get the opportunity to rebind the variable
2025 * differently on each session.
2027 * @param variableName
2028 * the name of the classpath variable
2029 * @return the path, or <code>null</code> if none
2030 * @see #setClasspathVariable
2032 public static IPath getClasspathVariable(final String variableName) {
2034 IPath variablePath = JavaModelManager.variableGet(variableName);
2035 if (variablePath == JavaModelManager.VariableInitializationInProgress)
2036 return null; // break cycle
2038 if (variablePath != null) {
2039 return variablePath;
2042 // even if persisted value exists, initializer is given priority, only
2043 // if no initializer is found the persisted value is reused
2044 // final ClasspathVariableInitializer initializer =
2045 // PHPCore.getClasspathVariableInitializer(variableName);
2046 // if (initializer != null){
2047 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2048 // System.out.println("CPVariable INIT - triggering initialization of: "
2049 // + variableName+ " using initializer: "+ initializer); //$NON-NLS-1$
2051 // new Exception("FAKE exception for dumping current CPVariable
2052 // ("+variableName+ ")INIT invocation stack trace").printStackTrace();
2053 // //$NON-NLS-1$//$NON-NLS-2$
2055 // JavaModelManager.variablePut(variableName,
2056 // JavaModelManager.VariableInitializationInProgress); // avoid
2057 // initialization cycles
2058 // boolean ok = false;
2060 // // wrap initializer call with Safe runnable in case initializer would
2061 // be causing some grief
2062 // Platform.run(new ISafeRunnable() {
2063 // public void handleException(Throwable exception) {
2064 // ProjectPrefUtil.log(exception, "Exception occurred in classpath variable
2065 // initializer: "+initializer+" while initializing variable:
2066 // "+variableName); //$NON-NLS-1$ //$NON-NLS-2$
2068 // public void run() throws Exception {
2069 // initializer.initialize(variableName);
2072 // variablePath = (IPath) JavaModelManager.variableGet(variableName); //
2073 // initializer should have performed side-effect
2074 // if (variablePath ==
2075 // JavaModelManager.VariableInitializationInProgress) return null; //
2076 // break cycle (initializer did not init or reentering call)
2077 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2078 // System.out.println("CPVariable INIT - after initialization: " +
2079 // variableName + " --> " + variablePath); //$NON-NLS-2$//$NON-NLS-1$
2083 // if (!ok) JavaModelManager.variablePut(variableName, null); // flush
2087 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2088 // System.out.println("CPVariable INIT - no initializer found for: " +
2089 // variableName); //$NON-NLS-1$
2092 return variablePath;
2096 * Helper method finding the classpath variable initializer registered for a
2097 * given classpath variable name or <code>null</code> if none was found
2098 * while iterating over the contributions to extension point to the
2099 * extension point "net.sourceforge.phpdt.core.classpathVariableInitializer".
2104 * @return ClasspathVariableInitializer - the registered classpath variable
2105 * initializer or <code>null</code> if none was found.
2108 public static ClasspathVariableInitializer getClasspathVariableInitializer(
2111 Plugin jdtCorePlugin = JavaCore.getPlugin();
2112 if (jdtCorePlugin == null)
2115 // IExtensionPoint extension =
2116 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID);
2117 // if (extension != null) {
2118 // IExtension[] extensions = extension.getExtensions();
2119 // for(int i = 0; i < extensions.length; i++){
2120 // IConfigurationElement [] configElements =
2121 // extensions[i].getConfigurationElements();
2122 // for(int j = 0; j < configElements.length; j++){
2124 // String varAttribute = configElements[j].getAttribute("variable");
2126 // if (variable.equals(varAttribute)) {
2127 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
2128 // System.out.println("CPVariable INIT - found initializer: "+variable+"
2130 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
2133 // configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
2134 // if (execExt instanceof ClasspathVariableInitializer){
2135 // return (ClasspathVariableInitializer)execExt;
2138 // } catch(CoreException e){
2147 * Returns the names of all known classpath variables.
2149 * Classpath variable values are persisted locally to the workspace, and are
2150 * preserved from session to session.
2153 * @return the list of classpath variable names
2154 * @see #setClasspathVariable
2156 //public static String[] getClasspathVariableNames() {
2157 // return JavaModelManager.variableNames();
2160 * Returns a table of all known configurable options with their default
2161 * values. These options allow to configure the behaviour of the underlying
2162 * components. The client may safely use the result as a template that they
2163 * can modify and then pass to <code>setOptions</code>.
2165 * Helper constants have been defined on JavaCore for each of the option ID
2166 * and their possible constant values.
2168 * Note: more options might be added in further releases.
2172 * RECOGNIZED OPTIONS:
2173 * COMPILER / Generating Local Variable Debug Attribute
2174 * When generated, this attribute will enable local variable names
2175 * to be displayed in debugger, only in place where variables are
2176 * definitely assigned (.class file is then bigger)
2177 * - option id: "net.sourceforge.phpdt.core.compiler.debug.localVariable"
2178 * - possible values: { "generate", "do not generate" }
2179 * - default: "generate"
2181 * COMPILER / Generating Line Number Debug Attribute
2182 * When generated, this attribute will enable source code highlighting in debugger
2183 * (.class file is then bigger).
2184 * - option id: "net.sourceforge.phpdt.core.compiler.debug.lineNumber"
2185 * - possible values: { "generate", "do not generate" }
2186 * - default: "generate"
2188 * COMPILER / Generating Source Debug Attribute
2189 * When generated, this attribute will enable the debugger to present the
2190 * corresponding source code.
2191 * - option id: "net.sourceforge.phpdt.core.compiler.debug.sourceFile"
2192 * - possible values: { "generate", "do not generate" }
2193 * - default: "generate"
2195 * COMPILER / Preserving Unused Local Variables
2196 * Unless requested to preserve unused local variables (that is, never read), the
2197 * compiler will optimize them out, potentially altering debugging
2198 * - option id: "net.sourceforge.phpdt.core.compiler.codegen.unusedLocal"
2199 * - possible values: { "preserve", "optimize out" }
2200 * - default: "preserve"
2202 * COMPILER / Defining Target Java Platform
2203 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
2204 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
2205 * - option id: "net.sourceforge.phpdt.core.compiler.codegen.targetPlatform"
2206 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
2207 * - default: "1.1"
2209 * COMPILER / Reporting Unreachable Code
2210 * Unreachable code can optionally be reported as an error, warning or simply
2211 * ignored. The bytecode generation will always optimized it out.
2212 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unreachableCode"
2213 * - possible values: { "error", "warning", "ignore" }
2214 * - default: "error"
2216 * COMPILER / Reporting Invalid Import
2217 * An import statement that cannot be resolved might optionally be reported
2218 * as an error, as a warning or ignored.
2219 * - option id: "net.sourceforge.phpdt.core.compiler.problem.invalidImport"
2220 * - possible values: { "error", "warning", "ignore" }
2221 * - default: "error"
2223 * COMPILER / Reporting Attempt to Override Package-Default Method
2224 * A package default method is not visible in a different package, and thus
2225 * cannot be overridden. When enabling this option, the compiler will signal
2226 * such scenarii either as an error or a warning.
2227 * - option id: "net.sourceforge.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
2228 * - possible values: { "error", "warning", "ignore" }
2229 * - default: "warning"
2231 * COMPILER / Reporting Method With Constructor Name
2232 * Naming a method with a constructor name is generally considered poor
2233 * style programming. When enabling this option, the compiler will signal such
2234 * scenarii either as an error or a warning.
2235 * - option id: "net.sourceforge.phpdt.core.compiler.problem.methodWithConstructorName"
2236 * - possible values: { "error", "warning", "ignore" }
2237 * - default: "warning"
2239 * COMPILER / Reporting Deprecation
2240 * When enabled, the compiler will signal use of deprecated API either as an
2241 * error or a warning.
2242 * - option id: "net.sourceforge.phpdt.core.compiler.problem.deprecation"
2243 * - possible values: { "error", "warning", "ignore" }
2244 * - default: "warning"
2246 * COMPILER / Reporting Deprecation Inside Deprecated Code
2247 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
2248 * The severity of the problem is controlled with option "net.sourceforge.phpdt.core.compiler.problem.deprecation".
2249 * - option id: "net.sourceforge.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
2250 * - possible values: { "enabled", "disabled" }
2251 * - default: "disabled"
2253 * COMPILER / Reporting Hidden Catch Block
2254 * Locally to a try statement, some catch blocks may hide others . For example,
2255 * try { throw new java.io.CharConversionException();
2256 * } catch (java.io.CharConversionException e) {
2257 * } catch (java.io.IOException e) {}.
2258 * When enabling this option, the compiler will issue an error or a warning for hidden
2259 * catch blocks corresponding to checked exceptions
2260 * - option id: "net.sourceforge.phpdt.core.compiler.problem.hiddenCatchBlock"
2261 * - possible values: { "error", "warning", "ignore" }
2262 * - default: "warning"
2264 * COMPILER / Reporting Unused Local
2265 * When enabled, the compiler will issue an error or a warning for unused local
2266 * variables (that is, variables never read from)
2267 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedLocal"
2268 * - possible values: { "error", "warning", "ignore" }
2269 * - default: "ignore"
2271 * COMPILER / Reporting Unused Parameter
2272 * When enabled, the compiler will issue an error or a warning for unused method
2273 * parameters (that is, parameters never read from)
2274 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedParameter"
2275 * - possible values: { "error", "warning", "ignore" }
2276 * - default: "ignore"
2278 * COMPILER / Reporting Unused Parameter if Implementing Abstract Method
2279 * When enabled, the compiler will signal unused parameters in abstract method implementations.
2280 * The severity of the problem is controlled with option "net.sourceforge.phpdt.core.compiler.problem.unusedParameter".
2281 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"
2282 * - possible values: { "enabled", "disabled" }
2283 * - default: "disabled"
2285 * COMPILER / Reporting Unused Parameter if Overriding Concrete Method
2286 * When enabled, the compiler will signal unused parameters in methods overriding concrete ones.
2287 * The severity of the problem is controlled with option "net.sourceforge.phpdt.core.compiler.problem.unusedParameter".
2288 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"
2289 * - possible values: { "enabled", "disabled" }
2290 * - default: "disabled"
2292 * COMPILER / Reporting Unused Import
2293 * When enabled, the compiler will issue an error or a warning for unused import
2295 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedImport"
2296 * - possible values: { "error", "warning", "ignore" }
2297 * - default: "warning"
2299 * COMPILER / Reporting Unused Private Members
2300 * When enabled, the compiler will issue an error or a warning whenever a private
2301 * method or field is declared but never used within the same unit.
2302 * - option id: "net.sourceforge.phpdt.core.compiler.problem.unusedPrivateMember"
2303 * - possible values: { "error", "warning", "ignore" }
2304 * - default: "ignore"
2306 * COMPILER / Reporting Synthetic Access Emulation
2307 * When enabled, the compiler will issue an error or a warning whenever it emulates
2308 * access to a non-accessible member of an enclosing type. Such access can have
2309 * performance implications.
2310 * - option id: "net.sourceforge.phpdt.core.compiler.problem.syntheticAccessEmulation"
2311 * - possible values: { "error", "warning", "ignore" }
2312 * - default: "ignore"
2314 * COMPILER / Reporting Non-Externalized String Literal
2315 * When enabled, the compiler will issue an error or a warning for non externalized
2316 * String literal (that is, not tagged with //$NON-NLS-<n>$).
2317 * - option id: "net.sourceforge.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
2318 * - possible values: { "error", "warning", "ignore" }
2319 * - default: "ignore"
2321 * COMPILER / Reporting Usage of 'assert' Identifier
2322 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
2323 * used as an identifier (reserved keyword in 1.4)
2324 * - option id: "net.sourceforge.phpdt.core.compiler.problem.assertIdentifier"
2325 * - possible values: { "error", "warning", "ignore" }
2326 * - default: "ignore"
2328 * COMPILER / Reporting Non-Static Reference to a Static Member
2329 * When enabled, the compiler will issue an error or a warning whenever a static field
2330 * or method is accessed with an expression receiver. A reference to a static member should
2331 * be qualified with a type name.
2332 * - option id: "net.sourceforge.phpdt.core.compiler.problem.staticAccessReceiver"
2333 * - possible values: { "error", "warning", "ignore" }
2334 * - default: "warning"
2336 * COMPILER / Reporting Assignment with no Effect
2337 * When enabled, the compiler will issue an error or a warning whenever an assignment
2338 * has no effect (e.g 'x = x').
2339 * - option id: "net.sourceforge.phpdt.core.compiler.problem.noEffectAssignment"
2340 * - possible values: { "error", "warning", "ignore" }
2341 * - default: "warning"
2343 * COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods
2344 * When enabled, the compiler will issue an error or a warning whenever an interface
2345 * defines a method incompatible with a non-inherited Object method. Until this conflict
2346 * is resolved, such an interface cannot be implemented, For example,
2350 * - option id: "net.sourceforge.phpdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"
2351 * - possible values: { "error", "warning", "ignore" }
2352 * - default: "warning"
2354 * COMPILER / Reporting Usage of char[] Expressions in String Concatenations
2355 * When enabled, the compiler will issue an error or a warning whenever a char[] expression
2356 * is used in String concatenations (for example, "hello" + new char[]{'w','o','r','l','d'}).
2357 * - option id: "net.sourceforge.phpdt.core.compiler.problem.noImplicitStringConversion"
2358 * - possible values: { "error", "warning", "ignore" }
2359 * - default: "warning"
2361 * COMPILER / Setting Source Compatibility Mode
2362 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
2363 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
2364 * level should be set to "1.4" and the compliance mode should be "1.4".
2365 * - option id: "net.sourceforge.phpdt.core.compiler.source"
2366 * - possible values: { "1.3", "1.4" }
2367 * - default: "1.3"
2369 * COMPILER / Setting Compliance Level
2370 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
2371 * should not go beyond "1.3" level.
2372 * - option id: "net.sourceforge.phpdt.core.compiler.compliance"
2373 * - possible values: { "1.3", "1.4" }
2374 * - default: "1.3"
2376 * COMPILER / Maximum number of problems reported per compilation unit
2377 * Specify the maximum number of problems reported on each compilation unit.
2378 * - option id: "net.sourceforge.phpdt.core.compiler.maxProblemPerUnit"
2379 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
2380 * - default: "100"
2382 * COMPILER / Define the Automatic Task Tags
2383 * When the tag list is not empty, the compiler will issue a task marker whenever it encounters
2384 * one of the corresponding tag inside any comment in Java source code.
2385 * Generated task messages will include the tag, and range until the next line separator or comment ending.
2386 * Note that tasks messages are trimmed.
2387 * - option id: "net.sourceforge.phpdt.core.compiler.taskTags"
2388 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card or leading/trailing spaces
2389 * - default: ""
2391 * COMPILER / Define the Automatic Task Priorities
2392 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
2393 * of the task markers issued by the compiler.
2394 * If the default is specified, the priority of each task marker is "NORMAL".
2395 * - option id: "net.sourceforge.phpdt.core.compiler.taskPriorities"
2396 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
2397 * - default: ""
2399 * BUILDER / Specifying Filters for Resource Copying Control
2400 * Allow to specify some filters to control the resource copy process.
2401 * - option id: "net.sourceforge.phpdt.core.builder.resourceCopyExclusionFilter"
2402 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
2403 * or the name of a folder which ends with '/'
2404 * - default: ""
2406 * BUILDER / Abort if Invalid Classpath
2407 * Allow to toggle the builder to abort if the classpath is invalid
2408 * - option id: "net.sourceforge.phpdt.core.builder.invalidClasspath"
2409 * - possible values: { "abort", "ignore" }
2410 * - default: "abort"
2412 * BUILDER / Cleaning Output Folder(s)
2413 * Indicate whether the JavaBuilder is allowed to clean the output folders
2414 * when performing full build operations.
2415 * - option id: "net.sourceforge.phpdt.core.builder.cleanOutputFolder"
2416 * - possible values: { "clean", "ignore" }
2417 * - default: "clean"
2419 * BUILDER / Reporting Duplicate Resources
2420 * Indicate the severity of the problem reported when more than one occurrence
2421 * of a resource is to be copied into the output location.
2422 * - option id: "net.sourceforge.phpdt.core.builder.duplicateResourceTask"
2423 * - possible values: { "error", "warning" }
2424 * - default: "warning"
2426 * JAVACORE / Computing Project Build Order
2427 * Indicate whether JavaCore should enforce the project build order to be based on
2428 * the classpath prerequisite chain. When requesting to compute, this takes over
2429 * the platform default order (based on project references).
2430 * - option id: "net.sourceforge.phpdt.core.computeJavaBuildOrder"
2431 * - possible values: { "compute", "ignore" }
2432 * - default: "ignore"
2434 * JAVACORE / Specify Default Source Encoding Format
2435 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
2436 * to 'ResourcesPlugin.getEncoding()'.
2437 * - option id: "net.sourceforge.phpdt.core.encoding"
2438 * - possible values: { any of the supported encoding name}.
2439 * - default: <platform default>
2441 * JAVACORE / Reporting Incomplete Classpath
2442 * Indicate the severity of the problem reported when an entry on the classpath does not exist,
2443 * is not legite or is not visible (for example, a referenced project is closed).
2444 * - option id: "net.sourceforge.phpdt.core.incompleteClasspath"
2445 * - possible values: { "error", "warning"}
2446 * - default: "error"
2448 * JAVACORE / Reporting Classpath Cycle
2449 * Indicate the severity of the problem reported when a project is involved in a cycle.
2450 * - option id: "net.sourceforge.phpdt.core.circularClasspath"
2451 * - possible values: { "error", "warning" }
2452 * - default: "error"
2454 * JAVACORE / Enabling Usage of Classpath Exclusion Patterns
2455 * When disabled, no entry on a project classpath can be associated with
2456 * an exclusion pattern.
2457 * - option id: "net.sourceforge.phpdt.core.classpath.exclusionPatterns"
2458 * - possible values: { "enabled", "disabled" }
2459 * - default: "enabled"
2461 * JAVACORE / Enabling Usage of Classpath Multiple Output Locations
2462 * When disabled, no entry on a project classpath can be associated with
2463 * a specific output location, preventing thus usage of multiple output locations.
2464 * - option id: "net.sourceforge.phpdt.core.classpath.multipleOutputLocations"
2465 * - possible values: { "enabled", "disabled" }
2466 * - default: "enabled"
2468 * FORMATTER / Inserting New Line Before Opening Brace
2469 * When Insert, a new line is inserted before an opening brace, otherwise nothing
2471 * - option id: "net.sourceforge.phpdt.core.formatter.newline.openingBrace"
2472 * - possible values: { "insert", "do not insert" }
2473 * - default: "do not insert"
2475 * FORMATTER / Inserting New Line Inside Control Statement
2476 * When Insert, a new line is inserted between } and following else, catch, finally
2477 * - option id: "net.sourceforge.phpdt.core.formatter.newline.controlStatement"
2478 * - possible values: { "insert", "do not insert" }
2479 * - default: "do not insert"
2481 * FORMATTER / Clearing Blank Lines
2482 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
2483 * and all others removed.
2484 * - option id: "net.sourceforge.phpdt.core.formatter.newline.clearAll"
2485 * - possible values: { "clear all", "preserve one" }
2486 * - default: "preserve one"
2488 * FORMATTER / Inserting New Line Between Else/If
2489 * When Insert, a blank line is inserted between an else and an if when they are
2490 * contiguous. When choosing to not insert, else-if will be kept on the same
2491 * line when possible.
2492 * - option id: "net.sourceforge.phpdt.core.formatter.newline.elseIf"
2493 * - possible values: { "insert", "do not insert" }
2494 * - default: "do not insert"
2496 * FORMATTER / Inserting New Line In Empty Block
2497 * When insert, a line break is inserted between contiguous { and }, if } is not followed
2499 * - option id: "net.sourceforge.phpdt.core.formatter.newline.emptyBlock"
2500 * - possible values: { "insert", "do not insert" }
2501 * - default: "insert"
2503 * FORMATTER / Splitting Lines Exceeding Length
2504 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
2505 * disable line splitting
2506 * - option id: "net.sourceforge.phpdt.core.formatter.lineSplit"
2507 * - possible values: "<n>", where n is zero or a positive integer
2508 * - default: "80"
2510 * FORMATTER / Compacting Assignment
2511 * Assignments can be formatted asymmetrically, for example 'int x= 2;', when Normal, a space
2512 * is inserted before the assignment operator
2513 * - option id: "net.sourceforge.phpdt.core.formatter.style.assignment"
2514 * - possible values: { "compact", "normal" }
2515 * - default: "normal"
2517 * FORMATTER / Defining Indentation Character
2518 * Either choose to indent with tab characters or spaces
2519 * - option id: "net.sourceforge.phpdt.core.formatter.tabulation.char"
2520 * - possible values: { "tab", "space" }
2521 * - default: "tab"
2523 * FORMATTER / Defining Space Indentation Length
2524 * When using spaces, set the amount of space characters to use for each
2526 * - option id: "net.sourceforge.phpdt.core.formatter.tabulation.size"
2527 * - possible values: "<n>", where n is a positive integer
2528 * - default: "4"
2530 * FORMATTER / Inserting space in cast expression
2531 * When Insert, a space is added between the type and the expression in a cast expression.
2532 * - option id: "net.sourceforge.phpdt.core.formatter.space.castexpression"
2533 * - possible values: { "insert", "do not insert" }
2534 * - default: "insert"
2536 * CODEASSIST / Activate Visibility Sensitive Completion
2537 * When active, completion doesn't show that you can not see
2538 * (for example, you can not see private methods of a super class).
2539 * - option id: "net.sourceforge.phpdt.core.codeComplete.visibilityCheck"
2540 * - possible values: { "enabled", "disabled" }
2541 * - default: "disabled"
2543 * CODEASSIST / Automatic Qualification of Implicit Members
2544 * When active, completion automatically qualifies completion on implicit
2545 * field references and message expressions.
2546 * - option id: "net.sourceforge.phpdt.core.codeComplete.forceImplicitQualification"
2547 * - possible values: { "enabled", "disabled" }
2548 * - default: "disabled"
2550 * CODEASSIST / Define the Prefixes for Field Name
2551 * When the prefixes is non empty, completion for field name will begin with
2552 * one of the proposed prefixes.
2553 * - option id: "net.sourceforge.phpdt.core.codeComplete.fieldPrefixes"
2554 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2555 * - default: ""
2557 * CODEASSIST / Define the Prefixes for Static Field Name
2558 * When the prefixes is non empty, completion for static field name will begin with
2559 * one of the proposed prefixes.
2560 * - option id: "net.sourceforge.phpdt.core.codeComplete.staticFieldPrefixes"
2561 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2562 * - default: ""
2564 * CODEASSIST / Define the Prefixes for Local Variable Name
2565 * When the prefixes is non empty, completion for local variable name will begin with
2566 * one of the proposed prefixes.
2567 * - option id: "net.sourceforge.phpdt.core.codeComplete.localPrefixes"
2568 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2569 * - default: ""
2571 * CODEASSIST / Define the Prefixes for Argument Name
2572 * When the prefixes is non empty, completion for argument name will begin with
2573 * one of the proposed prefixes.
2574 * - option id: "net.sourceforge.phpdt.core.codeComplete.argumentPrefixes"
2575 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2576 * - default: ""
2578 * CODEASSIST / Define the Suffixes for Field Name
2579 * When the suffixes is non empty, completion for field name will end with
2580 * one of the proposed suffixes.
2581 * - option id: "net.sourceforge.phpdt.core.codeComplete.fieldSuffixes"
2582 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2583 * - default: ""
2585 * CODEASSIST / Define the Suffixes for Static Field Name
2586 * When the suffixes is non empty, completion for static field name will end with
2587 * one of the proposed suffixes.
2588 * - option id: "net.sourceforge.phpdt.core.codeComplete.staticFieldSuffixes"
2589 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2590 * - default: ""
2592 * CODEASSIST / Define the Suffixes for Local Variable Name
2593 * When the suffixes is non empty, completion for local variable name will end with
2594 * one of the proposed suffixes.
2595 * - option id: "net.sourceforge.phpdt.core.codeComplete.localSuffixes"
2596 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2597 * - default: ""
2599 * CODEASSIST / Define the Suffixes for Argument Name
2600 * When the suffixes is non empty, completion for argument name will end with
2601 * one of the proposed suffixes.
2602 * - option id: "net.sourceforge.phpdt.core.codeComplete.argumentSuffixes"
2603 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
2604 * - default: ""
2607 * @return a mutable table containing the default settings of all known options
2620 public static Hashtable getDefaultOptions() {
2622 Hashtable defaultOptions = new Hashtable(10);
2624 // see #initializeDefaultPluginPreferences() for changing default
2626 Preferences preferences = getPlugin().getPluginPreferences();
2627 HashSet optionNames = JavaModelManager.OptionNames;
2629 // get preferences set to their default
2630 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2631 for (int i = 0; i < defaultPropertyNames.length; i++) {
2632 String propertyName = defaultPropertyNames[i];
2633 if (optionNames.contains(propertyName)) {
2634 defaultOptions.put(propertyName, preferences
2635 .getDefaultString(propertyName));
2638 // get preferences not set to their default
2639 String[] propertyNames = preferences.propertyNames();
2640 for (int i = 0; i < propertyNames.length; i++) {
2641 String propertyName = propertyNames[i];
2642 if (optionNames.contains(propertyName)) {
2643 defaultOptions.put(propertyName, preferences
2644 .getDefaultString(propertyName));
2647 // get encoding through resource plugin
2648 defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2650 return defaultOptions;
2654 * Returns the single instance of the Java core plug-in runtime class.
2655 * Equivalent to <code>(JavaCore) getPlugin()</code>.
2657 * @return the single instance of the Java core plug-in runtime class
2659 public static PHPeclipsePlugin getJavaCore() {
2660 return (PHPeclipsePlugin) getPlugin();
2664 * Helper method for returning one option value only. Equivalent to
2665 * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
2666 * may answer <code>null</code> if this option does not exist.
2668 * For a complete description of the configurable options, see
2669 * <code>getDefaultOptions</code>.
2673 * the name of an option
2674 * @return the String value of a given option
2675 * @see JavaCore#getDefaultOptions
2678 public static String getOption(String optionName) {
2680 if (CORE_ENCODING.equals(optionName)) {
2681 return ResourcesPlugin.getEncoding();
2683 if (JavaModelManager.OptionNames.contains(optionName)) {
2684 Preferences preferences = getPlugin().getPluginPreferences();
2685 return preferences.getString(optionName).trim();
2691 * Returns the table of the current options. Initially, all options have
2692 * their default values, and this method returns a table that includes all
2695 * For a complete description of the configurable options, see
2696 * <code>getDefaultOptions</code>.
2699 * @return table of current settings of all options (key type:
2700 * <code>String</code>; value type: <code>String</code>)
2701 * @see JavaCore#getDefaultOptions
2703 public static Hashtable getOptions() {
2705 Hashtable options = new Hashtable(10);
2707 // see #initializeDefaultPluginPreferences() for changing default
2709 Plugin plugin = getPlugin();
2710 if (plugin != null) {
2711 Preferences preferences = getPlugin().getPluginPreferences();
2712 HashSet optionNames = JavaModelManager.OptionNames;
2714 // get preferences set to their default
2715 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2716 for (int i = 0; i < defaultPropertyNames.length; i++) {
2717 String propertyName = defaultPropertyNames[i];
2718 if (optionNames.contains(propertyName)) {
2719 options.put(propertyName, preferences
2720 .getDefaultString(propertyName));
2723 // get preferences not set to their default
2724 String[] propertyNames = preferences.propertyNames();
2725 for (int i = 0; i < propertyNames.length; i++) {
2726 String propertyName = propertyNames[i];
2727 if (optionNames.contains(propertyName)) {
2728 options.put(propertyName, preferences.getString(
2729 propertyName).trim());
2732 // get encoding through resource plugin
2733 options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2739 * This is a helper method, which returns the resolved classpath entry
2740 * denoted by a given entry (if it is a variable entry). It is obtained by
2741 * resolving the variable reference in the first segment. Returns <node>null
2742 * </code> if unable to resolve using the following algorithm:
2744 * <li>if variable segment cannot be resolved, returns <code>null</code>
2746 * <li>finds a project, JAR or binary folder in the workspace at the
2747 * resolved path location</li>
2748 * <li>if none finds an external JAR file or folder outside the workspace
2749 * at the resolved path location</li>
2750 * <li>if none returns <code>null</code></li>
2753 * Variable source attachment path and root path are also resolved and
2754 * recorded in the resulting classpath entry.
2756 * NOTE: This helper method does not handle classpath containers, for which
2757 * should rather be used <code>JavaCore#getClasspathContainer(IPath,
2758 * IJavaProject)</code>.
2762 * the given variable entry
2763 * @return the resolved library or project classpath entry, or <code>null
2764 * </code> if the given variable entry could not be resolved to a
2765 * valid classpath entry
2767 public static IClasspathEntry getResolvedClasspathEntry(
2768 IClasspathEntry entry) {
2770 if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
2773 IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
2774 IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath());
2775 if (resolvedPath == null)
2778 Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false);
2782 // inside the workspace
2783 if (target instanceof IResource) {
2784 IResource resolvedResource = (IResource) target;
2785 if (resolvedResource != null) {
2786 switch (resolvedResource.getType()) {
2788 case IResource.PROJECT:
2790 return JavaCore.newProjectEntry(resolvedPath, entry
2793 case IResource.FILE:
2794 // if (ProjectPrefUtil.isArchiveFileName(resolvedResource.getName())) {
2795 // // internal binary archive
2796 // return JavaCore.newLibraryEntry(
2798 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2799 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2800 // entry.isExported());
2804 case IResource.FOLDER:
2805 // internal binary folder
2806 // return JavaCore.newLibraryEntry(
2808 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2809 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2810 // entry.isExported());
2815 // outside the workspace
2816 if (target instanceof File) {
2817 File externalFile = (File) target;
2818 if (externalFile.isFile()) {
2819 String fileName = externalFile.getName().toLowerCase();
2820 // if (fileName.endsWith(".jar" //$NON-NLS-1$
2821 // ) || fileName.endsWith(".zip" //$NON-NLS-1$
2822 // )) { // external binary archive
2823 // return JavaCore.newLibraryEntry(
2825 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2826 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2827 // entry.isExported());
2829 } else { // external binary folder
2830 if (resolvedPath.isAbsolute()) {
2831 // return JavaCore.newLibraryEntry(
2833 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2834 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2835 // entry.isExported());
2843 * Resolve a variable path (helper method).
2845 * @param variablePath
2846 * the given variable path
2847 * @return the resolved variable path or <code>null</code> if none
2849 public static IPath getResolvedVariablePath(IPath variablePath) {
2851 if (variablePath == null)
2853 int count = variablePath.segmentCount();
2858 String variableName = variablePath.segment(0);
2859 IPath resolvedPath = JavaCore.getClasspathVariable(variableName);
2860 if (resolvedPath == null)
2863 // append path suffix
2865 resolvedPath = resolvedPath.append(variablePath
2866 .removeFirstSegments(1));
2868 return resolvedPath;
2872 * Answers the shared working copies currently registered for this buffer
2873 * factory. Working copies can be shared by several clients using the same
2874 * buffer factory,see <code>IWorkingCopy.getSharedWorkingCopy</code>.
2877 * the given buffer factory
2878 * @return the list of shared working copies for a given buffer factory
2882 public static IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory) {
2884 // if factory is null, default factory must be used
2885 if (factory == null)
2886 factory = BufferManager.getDefaultBufferManager()
2887 .getDefaultBufferFactory();
2888 Map sharedWorkingCopies = JavaModelManager.getJavaModelManager().sharedWorkingCopies;
2890 Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
2891 if (perFactoryWorkingCopies == null)
2892 return JavaModelManager.NoWorkingCopy;
2893 Collection copies = perFactoryWorkingCopies.values();
2894 IWorkingCopy[] result = new IWorkingCopy[copies.size()];
2895 copies.toArray(result);
2900 * Initializes the default preferences settings for this plug-in.
2902 public static void initializeDefaultPluginPreferences() {
2904 Preferences preferences = PHPeclipsePlugin.getDefault()
2905 .getPluginPreferences();
2906 HashSet optionNames = JavaModelManager.OptionNames;
2908 // Compiler settings
2909 preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
2910 optionNames.add(COMPILER_LOCAL_VARIABLE_ATTR);
2912 preferences.setDefault(COMPILER_LINE_NUMBER_ATTR, GENERATE);
2913 optionNames.add(COMPILER_LINE_NUMBER_ATTR);
2915 preferences.setDefault(COMPILER_SOURCE_FILE_ATTR, GENERATE);
2916 optionNames.add(COMPILER_SOURCE_FILE_ATTR);
2918 preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE);
2919 optionNames.add(COMPILER_CODEGEN_UNUSED_LOCAL);
2921 preferences.setDefault(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1);
2922 optionNames.add(COMPILER_CODEGEN_TARGET_PLATFORM);
2924 preferences.setDefault(COMPILER_PB_PHP_VAR_DEPRECATED, WARNING);
2925 optionNames.add(COMPILER_PB_PHP_VAR_DEPRECATED);
2926 preferences.setDefault(COMPILER_PB_PHP_KEYWORD, WARNING);
2927 optionNames.add(COMPILER_PB_PHP_KEYWORD);
2928 preferences.setDefault(COMPILER_PB_PHP_UPPERCASE_IDENTIFIER, IGNORE);
2929 optionNames.add(COMPILER_PB_PHP_UPPERCASE_IDENTIFIER);
2930 preferences.setDefault(COMPILER_PB_PHP_FILE_NOT_EXIST, WARNING);
2931 optionNames.add(COMPILER_PB_PHP_FILE_NOT_EXIST);
2933 preferences.setDefault(COMPILER_PB_UNREACHABLE_CODE, ERROR);
2934 optionNames.add(COMPILER_PB_UNREACHABLE_CODE);
2936 preferences.setDefault(COMPILER_PB_INVALID_IMPORT, ERROR);
2937 optionNames.add(COMPILER_PB_INVALID_IMPORT);
2939 preferences.setDefault(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD,
2941 optionNames.add(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD);
2943 preferences.setDefault(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME,
2945 optionNames.add(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME);
2947 preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING);
2948 optionNames.add(COMPILER_PB_DEPRECATION);
2950 preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE,
2952 optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE);
2954 preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING);
2955 optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK);
2957 preferences.setDefault(COMPILER_PB_UNUSED_LOCAL, IGNORE);
2958 optionNames.add(COMPILER_PB_UNUSED_LOCAL);
2960 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE);
2961 optionNames.add(COMPILER_PB_UNUSED_PARAMETER);
2963 preferences.setDefault(
2964 COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT,
2967 .add(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT);
2971 COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE,
2973 optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE);
2975 preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING);
2976 optionNames.add(COMPILER_PB_UNUSED_IMPORT);
2978 preferences.setDefault(COMPILER_PB_UNUSED_PRIVATE_MEMBER, IGNORE);
2979 optionNames.add(COMPILER_PB_UNUSED_PRIVATE_MEMBER);
2981 preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE);
2982 optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION);
2984 preferences.setDefault(COMPILER_PB_NON_NLS_STRING_LITERAL, IGNORE);
2985 optionNames.add(COMPILER_PB_NON_NLS_STRING_LITERAL);
2987 preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE);
2988 optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER);
2990 preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING);
2991 optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER);
2993 preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING);
2994 optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT);
2996 preferences.setDefault(
2997 COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD,
3000 .add(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD);
3002 preferences.setDefault(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION,
3004 optionNames.add(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION);
3006 preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAG); //$NON-NLS-1$
3007 optionNames.add(COMPILER_TASK_TAGS);
3009 preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITY); //$NON-NLS-1$
3010 optionNames.add(COMPILER_TASK_PRIORITIES);
3012 preferences.setDefault(COMPILER_SOURCE, VERSION_1_3);
3013 optionNames.add(COMPILER_SOURCE);
3015 preferences.setDefault(COMPILER_COMPLIANCE, VERSION_1_3);
3016 optionNames.add(COMPILER_COMPLIANCE);
3018 preferences.setDefault(COMPILER_PB_MAX_PER_UNIT, "100"); //$NON-NLS-1$
3019 optionNames.add(COMPILER_PB_MAX_PER_UNIT);
3022 preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
3023 optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
3025 preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT);
3026 optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH);
3028 preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING);
3029 optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE);
3031 preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN);
3032 optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER);
3034 // JavaCore settings
3035 preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE);
3036 optionNames.add(CORE_JAVA_BUILD_ORDER);
3038 preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR);
3039 optionNames.add(CORE_CIRCULAR_CLASSPATH);
3041 preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR);
3042 optionNames.add(CORE_INCOMPLETE_CLASSPATH);
3044 preferences.setDefault(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS,
3046 optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS);
3048 preferences.setDefault(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS,
3050 optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS);
3052 // encoding setting comes from resource plug-in
3053 optionNames.add(CORE_ENCODING);
3055 // Formatter settings
3056 preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT);
3057 optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE);
3059 preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT);
3060 optionNames.add(FORMATTER_NEWLINE_CONTROL);
3062 preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE);
3063 optionNames.add(FORMATTER_CLEAR_BLANK_LINES);
3065 preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT);
3066 optionNames.add(FORMATTER_NEWLINE_ELSE_IF);
3068 preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT);
3069 optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK);
3071 preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$
3072 optionNames.add(FORMATTER_LINE_SPLIT);
3074 preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL);
3075 optionNames.add(FORMATTER_COMPACT_ASSIGNMENT);
3077 preferences.setDefault(FORMATTER_TAB_CHAR, TAB);
3078 optionNames.add(FORMATTER_TAB_CHAR);
3080 preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$
3081 optionNames.add(FORMATTER_TAB_SIZE);
3083 preferences.setDefault(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$
3084 optionNames.add(FORMATTER_SPACE_CASTEXPRESSION);
3086 // CodeAssist settings
3087 preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$
3088 optionNames.add(CODEASSIST_VISIBILITY_CHECK);
3090 preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$
3091 optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION);
3093 preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
3094 optionNames.add(CODEASSIST_FIELD_PREFIXES);
3096 preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
3097 optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES);
3099 preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
3100 optionNames.add(CODEASSIST_LOCAL_PREFIXES);
3102 preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
3103 optionNames.add(CODEASSIST_ARGUMENT_PREFIXES);
3105 preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3106 optionNames.add(CODEASSIST_FIELD_SUFFIXES);
3108 preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3109 optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES);
3111 preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
3112 optionNames.add(CODEASSIST_LOCAL_SUFFIXES);
3114 preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
3115 optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES);
3119 * Returns whether the given marker references the given Java element. Used
3120 * for markers, which denote a Java element rather than a resource.
3126 * @return <code>true</code> if the marker references the element, false
3128 * @exception CoreException
3129 * if the <code>IMarker.getAttribute</code> on the marker
3132 public static boolean isReferencedBy(IJavaElement element, IMarker marker)
3133 throws CoreException {
3135 // only match units or classfiles
3136 if (element instanceof IMember) {
3137 IMember member = (IMember) element;
3138 if (member.isBinary()) {
3139 element = null; //member.getClassFile();
3141 element = member.getCompilationUnit();
3144 if (element == null)
3149 String markerHandleId = (String) marker.getAttribute(ATT_HANDLE_ID);
3150 if (markerHandleId == null)
3153 IJavaElement markerElement = JavaCore.create(markerHandleId);
3155 if (element.equals(markerElement))
3156 return true; // external elements may still be equal with different
3159 // cycle through enclosing types in case marker is associated with a
3160 // classfile (15568)
3161 // if (markerElement instanceof IClassFile){
3162 // IType enclosingType =
3163 // ((IClassFile)markerElement).getType().getDeclaringType();
3164 // if (enclosingType != null){
3165 // markerElement = enclosingType.getClassFile(); // retry with immediate
3166 // enclosing classfile
3176 * Returns whether the given marker delta references the given Java element.
3177 * Used for markers deltas, which denote a Java element rather than a
3182 * @param markerDelta
3184 * @return <code>true</code> if the marker delta references the element
3185 * @exception CoreException
3186 * if the <code>IMarkerDelta.getAttribute</code> on the
3187 * marker delta fails
3189 public static boolean isReferencedBy(IJavaElement element,
3190 IMarkerDelta markerDelta) throws CoreException {
3192 // only match units or classfiles
3193 if (element instanceof IMember) {
3194 IMember member = (IMember) element;
3195 if (member.isBinary()) {
3196 element = null; //member.getClassFile();
3198 element = member.getCompilationUnit();
3201 if (element == null)
3203 if (markerDelta == null)
3206 String markerDeltarHandleId = (String) markerDelta
3207 .getAttribute(ATT_HANDLE_ID);
3208 if (markerDeltarHandleId == null)
3211 IJavaElement markerElement = JavaCore.create(markerDeltarHandleId);
3213 if (element.equals(markerElement))
3214 return true; // external elements may still be equal with different
3217 // cycle through enclosing types in case marker is associated with a
3218 // classfile (15568)
3219 // if (markerElement instanceof IClassFile){
3220 // IType enclosingType =
3221 // ((IClassFile)markerElement).getType().getDeclaringType();
3222 // if (enclosingType != null){
3223 // markerElement = enclosingType.getClassFile(); // retry with immediate
3224 // enclosing classfile
3234 * Creates and returns a new classpath entry of kind
3235 * <code>CPE_CONTAINER</code> for the given path. The path of the
3236 * container will be used during resolution so as to map this container
3237 * entry to a set of other classpath entries the container is acting for.
3239 * A container entry allows to express indirect references to a set of
3240 * libraries, projects and variable entries, which can be interpreted
3241 * differently for each Java project where it is used. A classpath container
3242 * entry can be resolved using
3243 * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3244 * <code>JavaCore.classpathContainerChanged</code>
3246 * A container is exclusively resolved by a
3247 * <code>ClasspathContainerInitializer</code> registered onto the
3248 * extension point "net.sourceforge.phpdt.core.classpathContainerInitializer".
3250 * A container path must be formed of at least one segment, where:
3252 * <li>the first segment is a unique ID identifying the target container,
3253 * there must be a container initializer registered onto this ID through the
3254 * extension point "net.sourceforge.phpdt.core.classpathContainerInitializer".
3256 * <li>the remaining segments will be passed onto the initializer, and can
3257 * be used as additional hints during the initialization phase.</li>
3260 * Example of an ClasspathContainerInitializer for a classpath container
3261 * denoting a default JDK container:
3263 * containerEntry = JavaCore.newContainerEntry(new
3264 * Path("MyProvidedJDK/default"));
3266 * <extension point="net.sourceforge.phpdt.core.classpathContainerInitializer">
3267 * <containerInitializer id="MyProvidedJDK"
3268 * class="com.example.MyInitializer"/>
3270 * Note that this operation does not attempt to validate classpath
3271 * containers or access the resources at the given paths.
3273 * The resulting entry is not exported to dependent projects. This method is
3274 * equivalent to <code>newContainerEntry(-,false)</code>.
3277 * @param containerPath
3278 * the path identifying the container, it must be formed of two
3280 * @return a new container classpath entry
3282 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3283 * @see JavaCore#newContainerEntry(IPath, boolean)
3286 public static IClasspathEntry newContainerEntry(IPath containerPath) {
3288 return newContainerEntry(containerPath, false);
3292 * Creates and returns a new classpath entry of kind
3293 * <code>CPE_CONTAINER</code> for the given path. The path of the
3294 * container will be used during resolution so as to map this container
3295 * entry to a set of other classpath entries the container is acting for.
3297 * A container entry allows to express indirect references to a set of
3298 * libraries, projects and variable entries, which can be interpreted
3299 * differently for each Java project where it is used. A classpath container
3300 * entry can be resolved using
3301 * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3302 * <code>JavaCore.classpathContainerChanged</code>
3304 * A container is exclusively resolved by a
3305 * <code>ClasspathContainerInitializer</code> registered onto the
3306 * extension point "net.sourceforge.phpdt.core.classpathContainerInitializer".
3308 * A container path must be formed of at least one segment, where:
3310 * <li>the first segment is a unique ID identifying the target container,
3311 * there must be a container initializer registered onto this ID through the
3312 * extension point "net.sourceforge.phpdt.core.classpathContainerInitializer".
3314 * <li>the remaining segments will be passed onto the initializer, and can
3315 * be used as additional hints during the initialization phase.</li>
3318 * Example of an ClasspathContainerInitializer for a classpath container
3319 * denoting a default JDK container:
3321 * containerEntry = JavaCore.newContainerEntry(new
3322 * Path("MyProvidedJDK/default"));
3324 * <extension point="net.sourceforge.phpdt.core.classpathContainerInitializer">
3325 * <containerInitializer id="MyProvidedJDK"
3326 * class="com.example.MyInitializer"/>
3328 * Note that this operation does not attempt to validate classpath
3329 * containers or access the resources at the given paths.
3332 * @param containerPath
3333 * the path identifying the container, it must be formed of at
3334 * least one segment (ID+hints)
3336 * a boolean indicating whether this entry is contributed to
3337 * dependent projects in addition to the output location
3338 * @return a new container classpath entry
3340 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3341 * @see JavaCore#setClasspathContainer(IPath, IJavaProject[],
3342 * IClasspathContainer[], IProgressMonitor)
3343 * @see JavaCore#newContainerEntry(IPath, boolean)
3347 public static IClasspathEntry newContainerEntry(IPath containerPath, boolean isExported) {
3349 if (containerPath == null) Assert.isTrue(false, "Container path cannot be null"); //$NON-NLS-1$
3350 if (containerPath.segmentCount() < 1) {
3353 "Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$
3355 return new ClasspathEntry(
3356 IPackageFragmentRoot.K_SOURCE,
3357 IClasspathEntry.CPE_CONTAINER,
3359 ClasspathEntry.INCLUDE_ALL,
3360 ClasspathEntry.EXCLUDE_NONE,
3361 null, // source attachment
3362 null, // source attachment root
3363 null, // specific output folder
3368 * Creates and returns a new non-exported classpath entry of kind
3369 * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3370 * absolute path. This specifies that all package fragments within the root
3371 * will have children of type <code>IClassFile</code>.
3373 * A library entry is used to denote a prerequisite JAR or root folder
3374 * containing binaries. The target JAR or folder can either be defined
3375 * internally to the workspace (absolute path relative to the workspace
3376 * root) or externally to the workspace (absolute path in the file system).
3378 * e.g. Here are some examples of binary path usage
3380 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3382 * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3384 * <li><code> "c:/classes/" </code>- reference to an external binary
3387 * Note that this operation does not attempt to validate or access the
3388 * resources at the given paths.
3390 * The resulting entry is not exported to dependent projects. This method is
3391 * equivalent to <code>newLibraryEntry(-,-,-,false)</code>.
3395 * the absolute path of the binary archive
3396 * @param sourceAttachmentPath
3397 * the absolute path of the corresponding source archive or
3398 * folder, or <code>null</code> if none
3399 * @param sourceAttachmentRootPath
3400 * the location of the root within the source archive or folder
3401 * or <code>null</code> if this location should be
3402 * automatically detected.
3403 * @return a new library classpath entry
3405 * @see #newLibraryEntry(IPath, IPath, IPath, boolean)
3407 //public static IClasspathEntry newLibraryEntry(
3409 // IPath sourceAttachmentPath,
3410 // IPath sourceAttachmentRootPath) {
3412 // return newLibraryEntry(path, sourceAttachmentPath,
3413 // sourceAttachmentRootPath, false);
3416 * Creates and returns a new classpath entry of kind
3417 * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3418 * absolute path. This specifies that all package fragments within the root
3419 * will have children of type <code>IClassFile</code>.
3421 * A library entry is used to denote a prerequisite JAR or root folder
3422 * containing binaries. The target JAR or folder can either be defined
3423 * internally to the workspace (absolute path relative to the workspace
3424 * root) or externally to the workspace (absolute path in the file system).
3426 * e.g. Here are some examples of binary path usage
3428 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3430 * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3432 * <li><code> "c:/classes/" </code>- reference to an external binary
3435 * Note that this operation does not attempt to validate or access the
3436 * resources at the given paths.
3440 * the absolute path of the binary archive
3441 * @param sourceAttachmentPath
3442 * the absolute path of the corresponding source archive or
3443 * folder, or <code>null</code> if none
3444 * @param sourceAttachmentRootPath
3445 * the location of the root within the source archive or folder
3446 * or <code>null</code> if this location should be
3447 * automatically detected.
3449 * indicates whether this entry is contributed to dependent
3450 * projects in addition to the output location
3451 * @return a new library classpath entry
3454 //public static IClasspathEntry newLibraryEntry(
3456 // IPath sourceAttachmentPath,
3457 // IPath sourceAttachmentRootPath,
3458 // boolean isExported) {
3460 // if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry
3461 // must be absolute"); //$NON-NLS-1$
3463 // return new ClasspathEntry(
3464 // IPackageFragmentRoot.K_BINARY,
3465 // IClasspathEntry.CPE_LIBRARY,
3466 // JavaProject.canonicalizedPath(path),
3467 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3468 // sourceAttachmentPath,
3469 // sourceAttachmentRootPath,
3470 // null, // specific output folder
3474 * Creates and returns a new non-exported classpath entry of kind
3475 * <code>CPE_PROJECT</code> for the project identified by the given
3478 * A project entry is used to denote a prerequisite project on a classpath.
3479 * The referenced project will be contributed as a whole, either as sources
3480 * (in the Java Model, it contributes all its package fragment roots) or as
3481 * binaries (when building, it contributes its whole output location).
3483 * A project reference allows to indirect through another project,
3484 * independently from its internal layout.
3486 * The prerequisite project is referred to using an absolute path relative
3487 * to the workspace root.
3489 * The resulting entry is not exported to dependent projects. This method is
3490 * equivalent to <code>newProjectEntry(_,false)</code>.
3494 * the absolute path of the binary archive
3495 * @return a new project classpath entry
3497 * @see JavaCore#newProjectEntry(IPath, boolean)
3499 public static IClasspathEntry newProjectEntry(IPath path) {
3500 return newProjectEntry(path, false);
3504 * Creates and returns a new classpath entry of kind
3505 * <code>CPE_PROJECT</code> for the project identified by the given
3508 * A project entry is used to denote a prerequisite project on a classpath.
3509 * The referenced project will be contributed as a whole, either as sources
3510 * (in the Java Model, it contributes all its package fragment roots) or as
3511 * binaries (when building, it contributes its whole output location).
3513 * A project reference allows to indirect through another project,
3514 * independently from its internal layout.
3516 * The prerequisite project is referred to using an absolute path relative
3517 * to the workspace root.
3521 * the absolute path of the prerequisite project
3523 * indicates whether this entry is contributed to dependent
3524 * projects in addition to the output location
3525 * @return a new project classpath entry
3528 public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) {
3530 if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3532 return new ClasspathEntry(
3533 IPackageFragmentRoot.K_SOURCE,
3534 IClasspathEntry.CPE_PROJECT,
3536 ClasspathEntry.INCLUDE_ALL,
3537 ClasspathEntry.EXCLUDE_NONE,
3538 null, // source attachment
3539 null, // source attachment root
3540 null, // specific output folder
3546 * Returns a new empty region.
3548 * @return a new empty region
3550 public static IRegion newRegion() {
3551 return new Region();
3555 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3556 * for all files in the project's source folder identified by the given
3557 * absolute workspace-relative path.
3559 * The convenience method is fully equivalent to:
3561 * newSourceEntry(path, new IPath[] {}, new IPath[] {}, null);
3565 * @param path the absolute workspace-relative path of a source folder
3566 * @return a new source classpath entry
3567 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath)
3569 public static IClasspathEntry newSourceEntry(IPath path) {
3571 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, null /*output location*/);
3575 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3576 * for the project's source folder identified by the given absolute
3577 * workspace-relative path but excluding all source files with paths
3578 * matching any of the given patterns.
3580 * The convenience method is fully equivalent to:
3582 * newSourceEntry(path, new IPath[] {}, exclusionPatterns, null);
3586 * @param path the absolute workspace-relative path of a source folder
3587 * @param exclusionPatterns the possibly empty list of exclusion patterns
3588 * represented as relative paths
3589 * @return a new source classpath entry
3590 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath)
3593 public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns) {
3595 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL, exclusionPatterns, null /*output location*/);
3599 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3600 * for the project's source folder identified by the given absolute
3601 * workspace-relative path but excluding all source files with paths
3602 * matching any of the given patterns, and associated with a specific output location
3603 * (that is, ".class" files are not going to the project default output location).
3605 * The convenience method is fully equivalent to:
3607 * newSourceEntry(path, new IPath[] {}, exclusionPatterns, specificOutputLocation);
3611 * @param path the absolute workspace-relative path of a source folder
3612 * @param exclusionPatterns the possibly empty list of exclusion patterns
3613 * represented as relative paths
3614 * @param specificOutputLocation the specific output location for this source entry (<code>null</code> if using project default ouput location)
3615 * @return a new source classpath entry
3616 * @see #newSourceEntry(IPath, IPath[], IPath[], IPath)
3619 public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns, IPath specificOutputLocation) {
3621 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL, exclusionPatterns, specificOutputLocation);
3625 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3626 * for the project's source folder identified by the given absolute
3627 * workspace-relative path using the given inclusion and exclusion patterns
3628 * to determine which source files are included, and the given output path
3629 * to control the output location of generated files.
3631 * The source folder is referred to using an absolute path relative to the
3632 * workspace root, e.g. <code>/Project/src</code>. A project's source
3633 * folders are located with that project. That is, a source classpath
3634 * entry specifying the path <code>/P1/src</code> is only usable for
3635 * project <code>P1</code>.
3638 * The inclusion patterns determines the initial set of source files that
3639 * are to be included; the exclusion patterns are then used to reduce this
3640 * set. When no inclusion patterns are specified, the initial file set
3641 * includes all relevent files in the resource tree rooted at the source
3642 * entry's path. On the other hand, specifying one or more inclusion
3643 * patterns means that all <b>and only</b> files matching at least one of
3644 * the specified patterns are to be included. If exclusion patterns are
3645 * specified, the initial set of files is then reduced by eliminating files
3646 * matched by at least one of the exclusion patterns. Inclusion and
3647 * exclusion patterns look like relative file paths with wildcards and are
3648 * interpreted relative to the source entry's path. File patterns are
3649 * case-sensitive can contain '**', '*' or '?' wildcards (see
3650 * {@link IClasspathEntry#getExclusionPatterns()} for the full description
3651 * of their syntax and semantics). The resulting set of files are included
3652 * in the corresponding package fragment root; all package fragments within
3653 * the root will have children of type <code>ICompilationUnit</code>.
3656 * For example, if the source folder path is
3657 * <code>/Project/src</code>, there are no inclusion filters, and the
3658 * exclusion pattern is
3659 * <code>com/xyz/tests/**</code>, then source files
3660 * like <code>/Project/src/com/xyz/Foo.java</code>
3661 * and <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3662 * whereas <code>/Project/src/com/xyz/tests/T1.java</code>
3663 * and <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3667 * Additionally, a source entry can be associated with a specific output location.
3668 * By doing so, the Java builder will ensure that the generated ".class" files will
3669 * be issued inside this output location, as opposed to be generated into the
3670 * project default output location (when output location is <code>null</code>).
3671 * Note that multiple source entries may target the same output location.
3672 * The output location is referred to using an absolute path relative to the
3673 * workspace root, e.g. <code>"/Project/bin"</code>, it must be located inside
3674 * the same project as the source folder.
3677 * Also note that all sources/binaries inside a project are contributed as
3678 * a whole through a project entry
3679 * (see <code>JavaCore.newProjectEntry</code>). Particular source entries
3680 * cannot be selectively exported.
3683 * @param path the absolute workspace-relative path of a source folder
3684 * @param inclusionPatterns the possibly empty list of inclusion patterns
3685 * represented as relative paths
3686 * @param exclusionPatterns the possibly empty list of exclusion patterns
3687 * represented as relative paths
3688 * @param specificOutputLocation the specific output location for this source entry (<code>null</code> if using project default ouput location)
3689 * @return a new source classpath entry with the given exclusion patterns
3690 * @see IClasspathEntry#getInclusionPatterns()
3691 * @see IClasspathEntry#getExclusionPatterns()
3692 * @see IClasspathEntry#getOutputLocation()
3695 public static IClasspathEntry newSourceEntry(IPath path, IPath[] inclusionPatterns, IPath[] exclusionPatterns, IPath specificOutputLocation) {
3697 if (path == null) Assert.isTrue(false, "Source path cannot be null"); //$NON-NLS-1$
3698 if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3699 if (exclusionPatterns == null) Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$
3700 if (inclusionPatterns == null) Assert.isTrue(false, "Inclusion pattern set cannot be null"); //$NON-NLS-1$
3702 return new ClasspathEntry(
3703 IPackageFragmentRoot.K_SOURCE,
3704 IClasspathEntry.CPE_SOURCE,
3708 null, // source attachment
3709 null, // source attachment root
3710 specificOutputLocation, // custom output location
3715 * Creates and returns a new non-exported classpath entry of kind
3716 * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3717 * path is the name of a classpath variable. The trailing segments of the
3718 * path will be appended to resolved variable path.
3720 * A variable entry allows to express indirect references on a classpath to
3721 * other projects or libraries, depending on what the classpath variable is
3724 * It is possible to register an automatic initializer (
3725 * <code>ClasspathVariableInitializer</code>), which will be invoked
3726 * through the extension point
3727 * "net.sourceforge.phpdt.core.classpathVariableInitializer". After resolution, a
3728 * classpath variable entry may either correspond to a project or a library
3731 * e.g. Here are some examples of variable path usage
3733 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3734 * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3735 * library "c:\jars\jdtcore.jar"</li>
3736 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3737 * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3738 * "/Project_JDTCORE"</li>
3739 * <li>"PLUGINS/com.example/example.jar" where variable
3740 * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3741 * classpath entry is denoting the library
3742 * "c:/eclipse/plugins/com.example/example.jar"</li>
3744 * Note that this operation does not attempt to validate classpath variables
3745 * or access the resources at the given paths.
3747 * The resulting entry is not exported to dependent projects. This method is
3748 * equivalent to <code>newVariableEntry(-,-,-,false)</code>.
3751 * @param variablePath
3752 * the path of the binary archive; first segment is the name of a
3753 * classpath variable
3754 * @param variableSourceAttachmentPath
3755 * the path of the corresponding source archive, or
3756 * <code>null</code> if none; if present, the first segment is
3757 * the name of a classpath variable (not necessarily the same
3758 * variable as the one that begins <code>variablePath</code>)
3759 * @param sourceAttachmentRootPath
3760 * the location of the root within the source archive or
3761 * <code>null</code> if <code>archivePath</code> is also
3763 * @return a new library classpath entry
3765 * @see JavaCore#newVariableEntry(IPath, IPath, IPath, boolean)
3767 //public static IClasspathEntry newVariableEntry(
3768 // IPath variablePath,
3769 // IPath variableSourceAttachmentPath,
3770 // IPath sourceAttachmentRootPath) {
3772 // return newVariableEntry(variablePath, variableSourceAttachmentPath,
3773 // sourceAttachmentRootPath, false);
3776 * Creates and returns a new non-exported classpath entry of kind
3777 * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3778 * path is the name of a classpath variable. The trailing segments of the
3779 * path will be appended to resolved variable path.
3781 * A variable entry allows to express indirect references on a classpath to
3782 * other projects or libraries, depending on what the classpath variable is
3785 * It is possible to register an automatic initializer (
3786 * <code>ClasspathVariableInitializer</code>), which will be invoked
3787 * through the extension point
3788 * "net.sourceforge.phpdt.core.classpathVariableInitializer". After resolution, a
3789 * classpath variable entry may either correspond to a project or a library
3792 * e.g. Here are some examples of variable path usage
3794 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3795 * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3796 * library "c:\jars\jdtcore.jar"</li>
3797 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3798 * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3799 * "/Project_JDTCORE"</li>
3800 * <li>"PLUGINS/com.example/example.jar" where variable
3801 * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3802 * classpath entry is denoting the library
3803 * "c:/eclipse/plugins/com.example/example.jar"</li>
3805 * Note that this operation does not attempt to validate classpath variables
3806 * or access the resources at the given paths.
3809 * @param variablePath
3810 * the path of the binary archive; first segment is the name of a
3811 * classpath variable
3812 * @param variableSourceAttachmentPath
3813 * the path of the corresponding source archive, or
3814 * <code>null</code> if none; if present, the first segment is
3815 * the name of a classpath variable (not necessarily the same
3816 * variable as the one that begins <code>variablePath</code>)
3817 * @param sourceAttachmentRootPath
3818 * the location of the root within the source archive or
3819 * <code>null</code> if <code>archivePath</code> is also
3822 * indicates whether this entry is contributed to dependent
3823 * projects in addition to the output location
3824 * @return a new variable classpath entry
3827 //public static IClasspathEntry newVariableEntry(
3828 // IPath variablePath,
3829 // IPath variableSourceAttachmentPath,
3830 // IPath variableSourceAttachmentRootPath,
3831 // boolean isExported) {
3833 // if (variablePath == null || variablePath.segmentCount() < 1) {
3836 // "Illegal classpath variable path: \'" +
3837 // variablePath.makeRelative().toString() + "\', must have at least one
3838 // segment"); //$NON-NLS-1$//$NON-NLS-2$
3841 // return new ClasspathEntry(
3842 // IPackageFragmentRoot.K_SOURCE,
3843 // IClasspathEntry.CPE_VARIABLE,
3845 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3846 // variableSourceAttachmentPath, // source attachment
3847 // variableSourceAttachmentRootPath, // source attachment root
3848 // null, // specific output folder
3852 * Removed the given classpath variable. Does nothing if no value was set
3853 * for this classpath variable.
3855 * This functionality cannot be used while the resource tree is locked.
3857 * Classpath variable values are persisted locally to the workspace, and are
3858 * preserved from session to session.
3861 * @param variableName
3862 * the name of the classpath variable
3863 * @see #setClasspathVariable
3865 * @deprecated - use version with extra IProgressMonitor
3867 //public static void removeClasspathVariable(String variableName) {
3868 // removeClasspathVariable(variableName, null);
3871 * Removed the given classpath variable. Does nothing if no value was set
3872 * for this classpath variable.
3874 * This functionality cannot be used while the resource tree is locked.
3876 * Classpath variable values are persisted locally to the workspace, and are
3877 * preserved from session to session.
3880 * @param variableName
3881 * the name of the classpath variable
3883 * the progress monitor to report progress
3884 * @see #setClasspathVariable
3886 //public static void removeClasspathVariable(
3887 // String variableName,
3888 // IProgressMonitor monitor) {
3891 // updateVariableValues(new String[]{ variableName}, new IPath[]{ null },
3893 // } catch (JavaModelException e) {
3897 * Removes the given element changed listener. Has no affect if an identical
3898 * listener is not registered.
3903 public static void removeElementChangedListener(
3904 IElementChangedListener listener) {
3905 JavaModelManager.getJavaModelManager().removeElementChangedListener(
3910 * Bind a container reference path to some actual containers (
3911 * <code>IClasspathContainer</code>). This API must be invoked whenever
3912 * changes in container need to be reflected onto the JavaModel. Containers
3913 * can have distinct values in different projects, therefore this API
3914 * considers a set of projects with their respective containers.
3916 * <code>containerPath</code> is the path under which these values can be
3917 * referenced through container classpath entries (
3918 * <code>IClasspathEntry#CPE_CONTAINER</code>). A container path is
3919 * formed by a first ID segment followed with extra segments, which can be
3920 * used as additional hints for the resolution. The container ID is used to
3921 * identify a <code>ClasspathContainerInitializer</code> registered on the
3922 * extension point "net.sourceforge.phpdt.core.classpathContainerInitializer".
3924 * There is no assumption that each individual container value passed in
3925 * argument (<code>respectiveContainers</code>) must answer the exact
3926 * same path when requested <code>IClasspathContainer#getPath</code>.
3927 * Indeed, the containerPath is just an indication for resolving it to an
3928 * actual container object. It can be delegated to a
3929 * <code>ClasspathContainerInitializer</code>, which can be activated
3930 * through the extension point
3931 * "net.sourceforge.phpdt.core.ClasspathContainerInitializer").
3933 * In reaction to changing container values, the JavaModel will be updated
3934 * to reflect the new state of the updated container.
3936 * This functionality cannot be used while the resource tree is locked.
3938 * Classpath container values are persisted locally to the workspace, but
3939 * are not preserved from a session to another. It is thus highly
3940 * recommended to register a <code>ClasspathContainerInitializer</code>
3941 * for each referenced container (through the extension point
3942 * "net.sourceforge.phpdt.core.ClasspathContainerInitializer").
3944 * Note: setting a container to <code>null</code> will cause it to be
3945 * lazily resolved again whenever its value is required. In particular, this
3946 * will cause a registered initializer to be invoked again.
3949 * @param containerPath -
3950 * the name of the container reference, which is being updated
3951 * @param affectedProjects -
3952 * the set of projects for which this container is being bound
3953 * @param respectiveContainers -
3954 * the set of respective containers for the affected projects
3956 * a monitor to report progress
3958 * @see ClasspathContainerInitializer
3959 * @see #getClasspathContainer(IPath, IJavaProject)
3960 * @see IClasspathContainer
3963 //public static void setClasspathContainer(final IPath containerPath,
3964 // IJavaProject[] affectedProjects, IClasspathContainer[]
3965 // respectiveContainers, IProgressMonitor monitor) throws JavaModelException
3968 // if (affectedProjects.length != respectiveContainers.length)
3969 // Assert.isTrue(false, "Projects and containers collections should have the
3970 // same size"); //$NON-NLS-1$
3972 // if (monitor != null && monitor.isCanceled()) return;
3974 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3975 // System.out.println("CPContainer SET - setting container:
3976 // ["+containerPath+"] for projects: {" //$NON-NLS-1$ //$NON-NLS-2$
3977 // + (ProjectPrefUtil.toString(affectedProjects,
3978 // new ProjectPrefUtil.Displayable(){
3979 // public String displayString(Object o) { return ((IJavaProject)
3980 // o).getElementName(); }
3982 // + "} with values: " //$NON-NLS-1$
3983 // + (ProjectPrefUtil.toString(respectiveContainers,
3984 // new ProjectPrefUtil.Displayable(){
3985 // public String displayString(Object o) { return ((IClasspathContainer)
3986 // o).getDescription(); }
3991 // final int projectLength = affectedProjects.length;
3992 // final IJavaProject[] modifiedProjects;
3993 // System.arraycopy(affectedProjects, 0, modifiedProjects = new
3994 // IJavaProject[projectLength], 0, projectLength);
3995 // final IClasspathEntry[][] oldResolvedPaths = new
3996 // IClasspathEntry[projectLength][];
3998 // // filter out unmodified project containers
3999 // int remaining = 0;
4000 // for (int i = 0; i < projectLength; i++){
4002 // if (monitor != null && monitor.isCanceled()) return;
4004 // IJavaProject affectedProject = affectedProjects[i];
4005 // IClasspathContainer newContainer = respectiveContainers[i];
4006 // if (newContainer == null) newContainer =
4007 // JavaModelManager.ContainerInitializationInProgress; // 30920 - prevent
4009 // boolean found = false;
4010 // if (JavaProject.hasJavaNature(affectedProject.getProject())){
4011 // IClasspathEntry[] rawClasspath = affectedProject.getRawClasspath();
4012 // for (int j = 0, cpLength = rawClasspath.length; j <cpLength; j++) {
4013 // IClasspathEntry entry = rawClasspath[j];
4014 // if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER &&
4015 // entry.getPath().equals(containerPath)){
4022 // modifiedProjects[i] = null; // filter out this project - does not
4023 // reference the container path, or isnt't yet Java project
4024 // JavaModelManager.containerPut(affectedProject, containerPath,
4028 // IClasspathContainer oldContainer =
4029 // JavaModelManager.containerGet(affectedProject, containerPath);
4030 // if (oldContainer == JavaModelManager.ContainerInitializationInProgress) {
4031 // Map previousContainerValues =
4032 // (Map)JavaModelManager.PreviousSessionContainers.get(affectedProject);
4033 // if (previousContainerValues != null){
4034 // IClasspathContainer previousContainer =
4035 // (IClasspathContainer)previousContainerValues.get(containerPath);
4036 // if (previousContainer != null) {
4037 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4038 // System.out.println("CPContainer INIT - reentering access to project
4039 // container: ["+affectedProject.getElementName()+"] " + containerPath + "
4040 // during its initialization, will see previous value: "+
4041 // previousContainer.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
4044 // JavaModelManager.containerPut(affectedProject, containerPath,
4045 // previousContainer);
4047 // oldContainer = null; //33695 - cannot filter out restored container, must
4048 // update affected project to reset cached CP
4050 // oldContainer = null;
4053 // if (oldContainer != null &&
4054 // oldContainer.equals(respectiveContainers[i])){// TODO: could improve to
4055 // only compare entries
4056 // modifiedProjects[i] = null; // filter out this project - container did
4061 // oldResolvedPaths[i] = affectedProject.getResolvedClasspath(true);
4062 // JavaModelManager.containerPut(affectedProject, containerPath,
4066 // if (remaining == 0) return;
4068 // // trigger model refresh
4070 // JavaCore.run(new IWorkspaceRunnable() {
4071 // public void run(IProgressMonitor monitor) throws CoreException {
4072 // for(int i = 0; i < projectLength; i++){
4074 // if (monitor != null && monitor.isCanceled()) return;
4076 // JavaProject affectedProject = (JavaProject)modifiedProjects[i];
4077 // if (affectedProject == null) continue; // was filtered out
4079 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4080 // System.out.println("CPContainer SET - updating affected project:
4081 // ["+affectedProject.getElementName()+"] due to setting container: " +
4082 // containerPath); //$NON-NLS-1$ //$NON-NLS-2$
4085 // // force a refresh of the affected project (will compute deltas)
4086 // affectedProject.setRawClasspath(
4087 // affectedProject.getRawClasspath(),
4088 // SetClasspathOperation.ReuseOutputLocation,
4090 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can save resources
4091 // oldResolvedPaths[i],
4092 // false, // updating - no validation
4093 // false); // updating - no need to save
4098 // } catch(CoreException e) {
4099 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4100 // System.out.println("CPContainer SET - FAILED DUE TO EXCEPTION:
4101 // "+containerPath); //$NON-NLS-1$
4102 // e.printStackTrace();
4104 // if (e instanceof JavaModelException) {
4105 // throw (JavaModelException)e;
4107 // throw new JavaModelException(e);
4110 // for (int i = 0; i < projectLength; i++) {
4111 // if (respectiveContainers[i] == null) {
4112 // JavaModelManager.containerPut(affectedProjects[i], containerPath, null);
4113 // // reset init in progress marker
4120 * Sets the value of the given classpath variable. The path must have at
4121 * least one segment.
4123 * This functionality cannot be used while the resource tree is locked.
4125 * Classpath variable values are persisted locally to the workspace, and are
4126 * preserved from session to session.
4129 * @param variableName
4130 * the name of the classpath variable
4133 * @see #getClasspathVariable
4135 * @deprecated - use API with IProgressMonitor
4137 //public static void setClasspathVariable(String variableName, IPath path)
4138 // throws JavaModelException {
4140 // setClasspathVariable(variableName, path, null);
4143 * Sets the value of the given classpath variable. The path must not be
4146 * This functionality cannot be used while the resource tree is locked.
4148 * Classpath variable values are persisted locally to the workspace, and are
4149 * preserved from session to session.
4151 * Updating a variable with the same value has no effect.
4153 * @param variableName
4154 * the name of the classpath variable
4158 * a monitor to report progress
4159 * @see #getClasspathVariable
4161 //public static void setClasspathVariable(
4162 // String variableName,
4164 // IProgressMonitor monitor)
4165 // throws JavaModelException {
4167 // if (path == null) Assert.isTrue(false, "Variable path cannot be null");
4169 // setClasspathVariables(new String[]{variableName}, new IPath[]{ path },
4173 * Sets the values of all the given classpath variables at once. Null paths
4174 * can be used to request corresponding variable removal.
4176 * This functionality cannot be used while the resource tree is locked.
4178 * Classpath variable values are persisted locally to the workspace, and are
4179 * preserved from session to session.
4181 * Updating a variable with the same value has no effect.
4183 * @param variableNames
4184 * an array of names for the updated classpath variables
4186 * an array of path updates for the modified classpath variables
4187 * (null meaning that the corresponding value will be removed
4189 * a monitor to report progress
4190 * @see #getClasspathVariable
4193 //public static void setClasspathVariables(
4194 // String[] variableNames,
4196 // IProgressMonitor monitor)
4197 // throws JavaModelException {
4199 // if (variableNames.length != paths.length) Assert.isTrue(false, "Variable
4200 // names and paths collections should have the same size"); //$NON-NLS-1$
4201 // //TODO: should check that null cannot be used as variable paths
4202 // updateVariableValues(variableNames, paths, monitor);
4205 * (non-Javadoc) Method declared on IExecutableExtension. Record any
4206 * necessary initialization data from the plugin.
4208 public void setInitializationData(IConfigurationElement cfig,
4209 String propertyName, Object data) throws CoreException {
4213 * Sets the current table of options. All and only the options explicitly
4214 * included in the given table are remembered; all previous option settings
4215 * are forgotten, including ones not explicitly mentioned.
4217 * For a complete description of the configurable options, see
4218 * <code>getDefaultOptions</code>.
4222 * the new options (key type: <code>String</code>; value type:
4223 * <code>String</code>), or <code>null</code> to reset all
4224 * options to their default values
4225 * @see JavaCore#getDefaultOptions
4227 public static void setOptions(Hashtable newOptions) {
4229 // see #initializeDefaultPluginPreferences() for changing default
4231 Preferences preferences = getPlugin().getPluginPreferences();
4233 if (newOptions == null) {
4234 newOptions = JavaCore.getDefaultOptions();
4236 Enumeration keys = newOptions.keys();
4237 while (keys.hasMoreElements()) {
4238 String key = (String) keys.nextElement();
4239 if (!JavaModelManager.OptionNames.contains(key))
4240 continue; // unrecognized option
4241 if (key.equals(CORE_ENCODING))
4242 continue; // skipped, contributed by resource prefs
4243 String value = (String) newOptions.get(key);
4244 preferences.setValue(key, value);
4248 getPlugin().savePluginPreferences();
4252 * Shutdown the JavaCore plug-in.
4254 * De-registers the JavaModelManager as a resource changed listener and save
4258 * @see org.eclipse.core.runtime.Plugin#shutdown()
4260 // moved to PHPeclipsePlugin#shutdown()
4261 //public void shutdown() {
4263 // //savePluginPreferences();
4264 // getPlugin().savePluginPreferences();
4265 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4266 // workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaProcessor);
4267 // workspace.removeSaveParticipant(PHPeclipsePlugin.getDefault());
4269 // ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown();
4272 * Initiate the background indexing process. This should be deferred after
4273 * the plugin activation.
4275 //private void startIndexing() {
4277 // JavaModelManager.getJavaModelManager().getIndexManager().reset();
4280 * Startup of the JavaCore plug-in.
4282 * Registers the JavaModelManager as a resource changed listener and save
4283 * participant. Starts the background indexing, and restore saved classpath
4287 * @see org.eclipse.core.runtime.Plugin#startup()
4290 // moved to PHPeclipsePlugin#startup()
4291 //public void startup() {
4293 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
4295 // manager.configurePluginDebugOptions();
4297 // // request state folder creation (workaround 19885)
4298 // JavaCore.getPlugin().getStateLocation();
4300 // // retrieve variable values
4301 // JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4302 // JavaModelManager.PluginPreferencesListener());
4303 //// TODO : jsurfer temp-del
4304 //// manager.loadVariablesAndContainers();
4306 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4307 // workspace.addResourceChangeListener(
4308 // manager.deltaProcessor,
4309 // IResourceChangeEvent.PRE_AUTO_BUILD
4310 // | IResourceChangeEvent.POST_AUTO_BUILD
4311 // | IResourceChangeEvent.POST_CHANGE
4312 // | IResourceChangeEvent.PRE_DELETE
4313 // | IResourceChangeEvent.PRE_CLOSE);
4315 //// startIndexing();
4316 // workspace.addSaveParticipant(PHPeclipsePlugin.getDefault(), manager);
4318 // } catch (CoreException e) {
4319 // } catch (RuntimeException e) {
4320 // manager.shutdown();
4325 * Internal updating of a variable values (null path meaning removal),
4326 * allowing to change multiple variable values at once.
4328 //private static void updateVariableValues(
4329 // String[] variableNames,
4330 // IPath[] variablePaths,
4331 // IProgressMonitor monitor) throws JavaModelException {
4333 // if (monitor != null && monitor.isCanceled()) return;
4335 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4336 // System.out.println("CPVariable SET - setting variables: {" +
4337 // ProjectPrefUtil.toString(variableNames) //$NON-NLS-1$
4338 // + "} with values: " + ProjectPrefUtil.toString(variablePaths)); //$NON-NLS-1$
4341 // int varLength = variableNames.length;
4343 // // gather classpath information for updating
4344 // final HashMap affectedProjects = new HashMap(5);
4345 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
4346 // IJavaModel model = manager.getJavaModel();
4348 // // filter out unmodified variables
4349 // int discardCount = 0;
4350 // for (int i = 0; i < varLength; i++){
4351 // String variableName = variableNames[i];
4352 // IPath oldPath = (IPath)JavaModelManager.variableGet(variableName); // if
4353 // reentering will provide previous session value
4354 // if (oldPath == JavaModelManager.VariableInitializationInProgress){
4355 // IPath previousPath =
4356 // (IPath)JavaModelManager.PreviousSessionVariables.get(variableName);
4357 // if (previousPath != null){
4358 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4359 // System.out.println("CPVariable INIT - reentering access to variable: " +
4360 // variableName+ " during its initialization, will see previous value: "+
4361 // previousPath); //$NON-NLS-1$ //$NON-NLS-2$
4363 // JavaModelManager.variablePut(variableName, previousPath); // replace
4364 // value so reentering calls are seeing old value
4366 // oldPath = null; //33695 - cannot filter out restored variable, must
4367 // update affected project to reset cached CP
4369 // if (oldPath != null && oldPath.equals(variablePaths[i])){
4370 // variableNames[i] = null;
4374 // if (discardCount > 0){
4375 // if (discardCount == varLength) return;
4376 // int changedLength = varLength - discardCount;
4377 // String[] changedVariableNames = new String[changedLength];
4378 // IPath[] changedVariablePaths = new IPath[changedLength];
4379 // for (int i = 0, index = 0; i < varLength; i++){
4380 // if (variableNames[i] != null){
4381 // changedVariableNames[index] = variableNames[i];
4382 // changedVariablePaths[index] = variablePaths[i];
4386 // variableNames = changedVariableNames;
4387 // variablePaths = changedVariablePaths;
4388 // varLength = changedLength;
4391 // if (monitor != null && monitor.isCanceled()) return;
4393 // if (model != null) {
4394 // IJavaProject[] projects = model.getJavaProjects();
4395 // nextProject : for (int i = 0, projectLength = projects.length; i <
4396 // projectLength; i++){
4397 // IJavaProject project = projects[i];
4399 // // check to see if any of the modified variables is present on the
4401 // IClasspathEntry[] classpath = project.getRawClasspath();
4402 // for (int j = 0, cpLength = classpath.length; j < cpLength; j++){
4404 // IClasspathEntry entry = classpath[j];
4405 // for (int k = 0; k < varLength; k++){
4407 // String variableName = variableNames[k];
4408 // if (entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE){
4410 // if (variableName.equals(entry.getPath().segment(0))){
4411 // affectedProjects.put(project, project.getResolvedClasspath(true));
4412 // continue nextProject;
4414 // IPath sourcePath, sourceRootPath;
4415 // if (((sourcePath = entry.getSourceAttachmentPath()) != null &&
4416 // variableName.equals(sourcePath.segment(0)))
4417 // || ((sourceRootPath = entry.getSourceAttachmentRootPath()) != null &&
4418 // variableName.equals(sourceRootPath.segment(0)))) {
4420 // affectedProjects.put(project, project.getResolvedClasspath(true));
4421 // continue nextProject;
4428 // // update variables
4429 // for (int i = 0; i < varLength; i++){
4430 // JavaModelManager.variablePut(variableNames[i], variablePaths[i]);
4432 // final String[] dbgVariableNames = variableNames;
4434 // // update affected project classpaths
4435 // if (!affectedProjects.isEmpty()) {
4437 // JavaCore_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt.run(
4438 // new IWorkspaceRunnable() {
4439 // public void run(IProgressMonitor monitor) throws CoreException {
4440 // // propagate classpath change
4441 // Iterator projectsToUpdate = affectedProjects.keySet().iterator();
4442 // while (projectsToUpdate.hasNext()) {
4444 // if (monitor != null && monitor.isCanceled()) return;
4446 // JavaProject project = (JavaProject) projectsToUpdate.next();
4448 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4449 // System.out.println("CPVariable SET - updating affected project:
4450 // ["+project.getElementName()+"] due to setting variables: "+
4451 // ProjectPrefUtil.toString(dbgVariableNames)); //$NON-NLS-1$ //$NON-NLS-2$
4455 // .setRawClasspath(
4456 // project.getRawClasspath(),
4457 // SetClasspathOperation.ReuseOutputLocation,
4458 // null, // don't call beginTask on the monitor (see
4459 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=3717)
4460 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can change resources
4461 // (IClasspathEntry[]) affectedProjects.get(project),
4462 // false, // updating - no validation
4463 // false); // updating - no need to save
4468 // } catch (CoreException e) {
4469 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4470 // System.out.println("CPVariable SET - FAILED DUE TO EXCEPTION:
4471 // "+ProjectPrefUtil.toString(dbgVariableNames)); //$NON-NLS-1$
4472 // e.printStackTrace();
4474 // if (e instanceof JavaModelException) {
4475 // throw (JavaModelException)e;
4477 // throw new JavaModelException(e);
4483 * (non-Javadoc) Startup the JavaCore plug-in. <p> Registers the
4484 * JavaModelManager as a resource changed listener and save participant.
4485 * Starts the background indexing, and restore saved classpath variable
4486 * values. <p> @throws Exception
4488 * @see org.eclipse.core.runtime.Plugin#start(BundleContext)
4490 //public static void start(final Plugin plugin, BundleContext context)
4491 // throws Exception {
4492 //// super.start(context);
4494 // final JavaModelManager manager = JavaModelManager.getJavaModelManager();
4496 // manager.configurePluginDebugOptions();
4498 // // request state folder creation (workaround 19885)
4499 // JavaCore.getPlugin().getStateLocation();
4501 // // retrieve variable values
4502 // //JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4503 // JavaModelManager.PluginPreferencesListener());
4504 //// manager.loadVariablesAndContainers();
4506 // final IWorkspace workspace = ResourcesPlugin.getWorkspace();
4507 // workspace.addResourceChangeListener(
4508 // manager.deltaState,
4509 // IResourceChangeEvent.PRE_BUILD
4510 // | IResourceChangeEvent.POST_BUILD
4511 // | IResourceChangeEvent.POST_CHANGE
4512 // | IResourceChangeEvent.PRE_DELETE
4513 // | IResourceChangeEvent.PRE_CLOSE);
4515 //// startIndexing();
4517 // // process deltas since last activated in indexer thread so that indexes
4519 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658
4520 // Job processSavedState = new Job(ProjectPrefUtil.bind("savedState.jobName")) {
4522 // protected IStatus run(IProgressMonitor monitor) {
4524 // // add save participant and process delta atomically
4525 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59937
4527 // new IWorkspaceRunnable() {
4528 // public void run(IProgressMonitor progress) throws CoreException {
4529 //// ISavedState savedState = workspace.addSaveParticipant(JavaCore.this,
4531 // ISavedState savedState = workspace.addSaveParticipant(plugin, manager);
4532 // if (savedState != null) {
4533 // // the event type coming from the saved state is always POST_AUTO_BUILD
4534 // // force it to be POST_CHANGE so that the delta processor can handle it
4535 // manager.deltaState.getDeltaProcessor().overridenEventType =
4536 // IResourceChangeEvent.POST_CHANGE;
4537 // savedState.processResourceChangeEvents(manager.deltaState);
4542 // } catch (CoreException e) {
4543 // return e.getStatus();
4545 // return Status.OK_STATUS;
4548 // processSavedState.setSystem(true);
4549 // processSavedState.setPriority(Job.SHORT); // process asap
4550 // processSavedState.schedule();
4551 // } catch (RuntimeException e) {
4552 // manager.shutdown();
4557 * (non-Javadoc) Shutdown the JavaCore plug-in. <p> De-registers the
4558 * JavaModelManager as a resource changed listener and save participant. <p>
4560 * @see org.eclipse.core.runtime.Plugin#stop(BundleContext)
4562 // public static void stop(Plugin plugin, BundleContext context)
4563 // throws Exception {
4565 // plugin.savePluginPreferences();
4566 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4567 // workspace.removeResourceChangeListener(JavaModelManager
4568 // .getJavaModelManager().deltaState);
4569 // workspace.removeSaveParticipant(plugin);
4571 // JavaModelManager.getJavaModelManager().shutdown();
4573 // // ensure we call super.stop as the last thing
4574 // // super.stop(context);