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.core.BatchOperation;
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.corext.Assert;
19 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
21 import org.eclipse.core.resources.IFile;
22 import org.eclipse.core.resources.IFolder;
23 import org.eclipse.core.resources.IMarker;
24 import org.eclipse.core.resources.IMarkerDelta;
25 import org.eclipse.core.resources.IProject;
26 import org.eclipse.core.resources.IProjectDescription;
27 import org.eclipse.core.resources.IResource;
28 import org.eclipse.core.resources.IResourceChangeEvent;
29 import org.eclipse.core.resources.ISavedState;
30 import org.eclipse.core.resources.IWorkspace;
31 import org.eclipse.core.resources.IWorkspaceRoot;
32 import org.eclipse.core.resources.IWorkspaceRunnable;
33 import org.eclipse.core.resources.ResourcesPlugin;
34 import org.eclipse.core.runtime.CoreException;
35 import org.eclipse.core.runtime.IConfigurationElement;
36 import org.eclipse.core.runtime.IPath;
37 import org.eclipse.core.runtime.IProgressMonitor;
38 import org.eclipse.core.runtime.IStatus;
39 import org.eclipse.core.runtime.Plugin;
40 import org.eclipse.core.runtime.Preferences;
41 import org.eclipse.core.runtime.Status;
42 import org.eclipse.core.runtime.jobs.ISchedulingRule;
43 import org.eclipse.core.runtime.jobs.Job;
44 import net.sourceforge.phpdt.internal.core.util.Util;
45 import org.osgi.framework.BundleContext;
47 public class JavaCore {
49 // public static HashSet OptionNames = new HashSet(20);
51 * The plug-in identifier of the Java core support (value
52 * <code>"net.sourceforge.phpeclipse"</code>)
54 // public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.core";
56 public static final String PLUGIN_ID = PHPeclipsePlugin.PLUGIN_ID;
59 * Possible configurable option ID.
61 * @see #getDefaultOptions
64 public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; //$NON-NLS-1$
67 * Possible configurable option ID.
69 * @see #getDefaultOptions
72 public static final String FORMATTER_NEWLINE_OPENING_BRACE = PLUGIN_ID
73 + ".formatter.newline.openingBrace"; //$NON-NLS-1$
76 * Possible configurable option ID.
78 * @see #getDefaultOptions
81 public static final String FORMATTER_NEWLINE_CONTROL = PLUGIN_ID
82 + ".formatter.newline.controlStatement"; //$NON-NLS-1$
85 * Possible configurable option ID.
87 * @see #getDefaultOptions
90 public static final String FORMATTER_NEWLINE_ELSE_IF = PLUGIN_ID
91 + ".formatter.newline.elseIf"; //$NON-NLS-1$
94 * Possible configurable option ID.
96 * @see #getDefaultOptions
99 public static final String FORMATTER_NEWLINE_EMPTY_BLOCK = PLUGIN_ID
100 + ".formatter.newline.emptyBlock"; //$NON-NLS-1$
103 * Possible configurable option ID.
105 * @see #getDefaultOptions
108 public static final String FORMATTER_CLEAR_BLANK_LINES = PLUGIN_ID
109 + ".formatter.newline.clearAll"; //$NON-NLS-1$
112 * Possible configurable option ID.
114 * @see #getDefaultOptions
117 public static final String FORMATTER_LINE_SPLIT = PLUGIN_ID
118 + ".formatter.lineSplit"; //$NON-NLS-1$
121 * Possible configurable option ID.
123 * @see #getDefaultOptions
126 public static final String FORMATTER_COMPACT_ASSIGNMENT = PLUGIN_ID
127 + ".formatter.style.assignment"; //$NON-NLS-1$
130 * Possible configurable option ID.
132 * @see #getDefaultOptions
135 public static final String FORMATTER_TAB_CHAR = PLUGIN_ID
136 + ".formatter.tabulation.char"; //$NON-NLS-1$
139 * Possible configurable option ID.
141 * @see #getDefaultOptions
144 public static final String FORMATTER_TAB_SIZE = PLUGIN_ID
145 + ".formatter.tabulation.size"; //$NON-NLS-1$
148 * Possible configurable option value.
150 * @see #getDefaultOptions
153 public static final String INSERT = "insert"; //$NON-NLS-1$
156 * Possible configurable option value.
158 * @see #getDefaultOptions
161 public static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$
164 * Possible configurable option value.
166 * @see #getDefaultOptions
169 public static final String PRESERVE_ONE = "preserve one"; //$NON-NLS-1$
172 * Possible configurable option value.
174 * @see #getDefaultOptions
177 public static final String CLEAR_ALL = "clear all"; //$NON-NLS-1$
180 * Possible configurable option value.
182 * @see #getDefaultOptions
185 public static final String NORMAL = "normal"; //$NON-NLS-1$
188 * Possible configurable option value.
190 * @see #getDefaultOptions
193 public static final String COMPACT = "compact"; //$NON-NLS-1$
196 * Possible configurable option value.
198 * @see #getDefaultOptions
201 public static final String TAB = "tab"; //$NON-NLS-1$
204 * Possible configurable option value.
206 * @see #getDefaultOptions
209 public static final String SPACE = "space"; //$NON-NLS-1$
212 * Possible configurable option value.
214 * @see #getDefaultOptions
217 public static final String ENABLED = "enabled"; //$NON-NLS-1$
220 * Possible configurable option value.
222 * @see #getDefaultOptions
225 public static final String DISABLED = "disabled"; //$NON-NLS-1$
228 * Possible configurable option value.
230 * @see #getDefaultOptions
233 public static final String CLEAN = "clean"; //$NON-NLS-1$
236 * Possible configurable option ID.
238 * @see #getDefaultOptions
241 public static final String COMPILER_TASK_TAGS = PLUGIN_ID
242 + ".compiler.taskTags"; //$NON-NLS-1$
245 * Name of the handle id attribute in a Java marker.
247 protected static final String ATT_HANDLE_ID = "net.sourceforge.phpdt.internal.core.JavaModelManager.handleId"; //$NON-NLS-1$
249 // *************** Possible IDs for configurable options.
250 // ********************
253 * Possible configurable option ID.
255 * @see #getDefaultOptions()
257 public static final String COMPILER_LOCAL_VARIABLE_ATTR = PLUGIN_ID
258 + ".compiler.debug.localVariable"; //$NON-NLS-1$
261 * Possible configurable option ID.
263 * @see #getDefaultOptions()
265 public static final String COMPILER_LINE_NUMBER_ATTR = PLUGIN_ID
266 + ".compiler.debug.lineNumber"; //$NON-NLS-1$
269 * Possible configurable option ID.
271 * @see #getDefaultOptions
273 public static final String COMPILER_SOURCE_FILE_ATTR = PLUGIN_ID
274 + ".compiler.debug.sourceFile"; //$NON-NLS-1$
277 * Possible configurable option ID.
279 * @see #getDefaultOptions
281 public static final String COMPILER_CODEGEN_UNUSED_LOCAL = PLUGIN_ID
282 + ".compiler.codegen.unusedLocal"; //$NON-NLS-1$
285 * Possible configurable option ID.
287 * @see #getDefaultOptions
289 public static final String COMPILER_CODEGEN_TARGET_PLATFORM = PLUGIN_ID
290 + ".compiler.codegen.targetPlatform"; //$NON-NLS-1$
293 * Possible configurable option ID.
295 * @see #getDefaultOptions
297 public static final String COMPILER_PB_PHP_VAR_DEPRECATED = PLUGIN_ID
298 + ".compiler.problem.phpVarDeprecatedWarning"; //$NON-NLS-1$
300 public static final String COMPILER_PB_PHP_KEYWORD = PLUGIN_ID
301 + ".compiler.problem.phpBadStyleKeywordWarning"; //$NON-NLS-1$
303 public static final String COMPILER_PB_PHP_UPPERCASE_IDENTIFIER = PLUGIN_ID
304 + ".compiler.problem.phpBadStyleUppercaseIdentifierWarning"; //$NON-NLS-1$
307 * Possible configurable option ID.
309 * @see #getDefaultOptions
311 public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID
312 + ".compiler.problem.unreachableCode"; //$NON-NLS-1$
315 * Possible configurable option ID.
317 * @see #getDefaultOptions
319 public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID
320 + ".compiler.problem.invalidImport"; //$NON-NLS-1$
323 * Possible configurable option ID.
325 * @see #getDefaultOptions
327 public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID
328 + ".compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
331 * Possible configurable option ID.
333 * @see #getDefaultOptions
335 public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID
336 + ".compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
339 * Possible configurable option ID.
341 * @see #getDefaultOptions
343 public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID
344 + ".compiler.problem.deprecation"; //$NON-NLS-1$
347 * Possible configurable option ID.
349 * @see #getDefaultOptions
352 public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID
353 + ".compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
356 * Possible configurable option ID.
358 * @see #getDefaultOptions
360 public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID
361 + ".compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
364 * Possible configurable option ID.
366 * @see #getDefaultOptions
368 public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID
369 + ".compiler.problem.unusedLocal"; //$NON-NLS-1$
372 * Possible configurable option ID.
374 * @see #getDefaultOptions
376 public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID
377 + ".compiler.problem.unusedParameter"; //$NON-NLS-1$
380 * Possible configurable option ID.
382 * @see #getDefaultOptions
385 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID
386 + ".compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
389 * Possible configurable option ID.
391 * @see #getDefaultOptions
394 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID
395 + ".compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
398 * Possible configurable option ID.
400 * @see #getDefaultOptions
403 public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID
404 + ".compiler.problem.unusedImport"; //$NON-NLS-1$
407 * Possible configurable option ID.
409 * @see #getDefaultOptions
411 public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID
412 + ".compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
415 * Possible configurable option ID.
417 * @see #getDefaultOptions
420 public static final String COMPILER_PB_NON_NLS_STRING_LITERAL = PLUGIN_ID
421 + ".compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
424 * Possible configurable option ID.
426 * @see #getDefaultOptions
429 public static final String COMPILER_PB_ASSERT_IDENTIFIER = PLUGIN_ID
430 + ".compiler.problem.assertIdentifier"; //$NON-NLS-1$
433 * Possible configurable option ID.
435 * @see #getDefaultOptions
438 public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID
439 + ".compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
442 * Possible configurable option ID.
444 * @see #getDefaultOptions
447 public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID
448 + ".compiler.problem.noEffectAssignment"; //$NON-NLS-1$
451 * Possible configurable option ID.
453 * @see #getDefaultOptions
456 public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID
457 + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
460 * Possible configurable option ID.
462 * @see #getDefaultOptions
465 public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID
466 + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
469 * Possible configurable option ID.
471 * @see #getDefaultOptions
474 public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID
475 + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
478 * Possible configurable option ID.
480 * @see #getDefaultOptions
483 public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID
484 + ".compiler.maxProblemPerUnit"; //$NON-NLS-1$
487 * Possible configurable option ID.
489 * @see #getDefaultOptions
492 public static final String COMPILER_SOURCE = PLUGIN_ID + ".compiler.source"; //$NON-NLS-1$
495 * Possible configurable option ID.
497 * @see #getDefaultOptions
500 public static final String COMPILER_COMPLIANCE = PLUGIN_ID
501 + ".compiler.compliance"; //$NON-NLS-1$
504 * Possible configurable option ID.
506 * @see #getDefaultOptions
509 public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID
510 + ".compiler.taskPriorities"; //$NON-NLS-1$
513 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
515 * @see #getDefaultOptions
518 public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$
521 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
523 * @see #getDefaultOptions
526 public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$
529 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
531 * @see #getDefaultOptions
534 public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$
537 * Possible configurable option ID.
539 * @see #getDefaultOptions
541 public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID
542 + ".computeJavaBuildOrder"; //$NON-NLS-1$
545 * Possible configurable option ID.
547 * @see #getDefaultOptions
550 public static final String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER = PLUGIN_ID
551 + ".builder.resourceCopyExclusionFilter"; //$NON-NLS-1$
554 * Possible configurable option ID.
556 * @see #getDefaultOptions
559 public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID
560 + ".builder.duplicateResourceTask"; //$NON-NLS-1$
563 * Possible configurable option ID.
565 * @see #getDefaultOptions
568 public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID
569 + ".builder.cleanOutputFolder"; //$NON-NLS-1$
572 * Possible configurable option ID.
574 * @see #getDefaultOptions
577 public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID
578 + ".incompleteClasspath"; //$NON-NLS-1$
581 * Possible configurable option ID.
583 * @see #getDefaultOptions
586 public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID
587 + ".circularClasspath"; //$NON-NLS-1$
590 * Possible configurable option ID.
592 * @see #getDefaultOptions
595 public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID
596 + ".builder.invalidClasspath"; //$NON-NLS-1$
599 * Possible configurable option ID.
601 * @see #getDefaultOptions
604 public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID
605 + ".classpath.exclusionPatterns"; //$NON-NLS-1$
608 * Possible configurable option ID.
610 * @see #getDefaultOptions
613 public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID
614 + ".classpath.multipleOutputLocations"; //$NON-NLS-1$
621 public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$
624 * Default task priority
628 public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; //$NON-NLS-1$
631 * Possible configurable option ID
633 * @see #getDefaultOptions
636 public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID
637 + ".formatter.space.castexpression"; //$NON-NLS-1$
640 * Possible configurable option ID.
642 * @see #getDefaultOptions
645 public static final String CODEASSIST_VISIBILITY_CHECK = PLUGIN_ID
646 + ".codeComplete.visibilityCheck"; //$NON-NLS-1$
649 * Possible configurable option ID.
651 * @see #getDefaultOptions
654 public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID
655 + ".codeComplete.forceImplicitQualification"; //$NON-NLS-1$
658 * Possible configurable option ID.
660 * @see #getDefaultOptions
663 public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID
664 + ".codeComplete.fieldPrefixes"; //$NON-NLS-1$
667 * Possible configurable option ID.
669 * @see #getDefaultOptions
672 public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID
673 + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
676 * Possible configurable option ID.
678 * @see #getDefaultOptions
681 public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID
682 + ".codeComplete.localPrefixes"; //$NON-NLS-1$
685 * Possible configurable option ID.
687 * @see #getDefaultOptions
690 public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID
691 + ".codeComplete.argumentPrefixes"; //$NON-NLS-1$
694 * Possible configurable option ID.
696 * @see #getDefaultOptions
699 public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID
700 + ".codeComplete.fieldSuffixes"; //$NON-NLS-1$
703 * Possible configurable option ID.
705 * @see #getDefaultOptions
708 public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID
709 + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
712 * Possible configurable option ID.
714 * @see #getDefaultOptions
717 public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID
718 + ".codeComplete.localSuffixes"; //$NON-NLS-1$
721 * Possible configurable option ID.
723 * @see #getDefaultOptions
726 public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID
727 + ".codeComplete.argumentSuffixes"; //$NON-NLS-1$
729 // *************** Possible values for configurable options.
730 // ********************
733 * Possible configurable option value.
735 * @see #getDefaultOptions
737 public static final String GENERATE = "generate"; //$NON-NLS-1$
740 * Possible configurable option value.
742 * @see #getDefaultOptions
744 public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
747 * Possible configurable option value.
749 * @see #getDefaultOptions
751 public static final String PRESERVE = "preserve"; //$NON-NLS-1$
754 * Possible configurable option value.
756 * @see #getDefaultOptions
758 public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
761 * Possible configurable option value.
763 * @see #getDefaultOptions
765 public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$
768 * Possible configurable option value.
770 * @see #getDefaultOptions
772 public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$
775 * Possible configurable option value.
777 * @see #getDefaultOptions
780 public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
783 * Possible configurable option value.
785 * @see #getDefaultOptions
788 public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
791 * Possible configurable option value.
793 * @see #getDefaultOptions
796 public static final String ABORT = "abort"; //$NON-NLS-1$
799 * Possible configurable option value.
801 * @see #getDefaultOptions
803 public static final String ERROR = "error"; //$NON-NLS-1$
806 * Possible configurable option value.
808 * @see #getDefaultOptions
810 public static final String WARNING = "warning"; //$NON-NLS-1$
813 * Possible configurable option value.
815 * @see #getDefaultOptions
817 public static final String IGNORE = "ignore"; //$NON-NLS-1$
820 * Possible configurable option value.
822 * @see #getDefaultOptions
824 public static final String COMPUTE = "compute"; //$NON-NLS-1$
827 * Possible configurable option value.
829 * @see #getDefaultOptions
834 * Returns a table of all known configurable options with their default
835 * values. These options allow to configure the behaviour of the underlying
836 * components. The client may safely use the result as a template that they
837 * can modify and then pass to <code>setOptions</code>.
839 * Helper constants have been defined on JavaCore for each of the option ID
840 * and their possible constant values.
842 * Note: more options might be added in further releases.
846 * RECOGNIZED OPTIONS:
847 * COMPILER / Generating Local Variable Debug Attribute
848 * When generated, this attribute will enable local variable names
849 * to be displayed in debugger, only in place where variables are
850 * definitely assigned (.class file is then bigger)
851 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.localVariable"
852 * - possible values: { "generate", "do not generate" }
853 * - default: "generate"
855 * COMPILER / Generating Line Number Debug Attribute
856 * When generated, this attribute will enable source code highlighting in debugger
857 * (.class file is then bigger).
858 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.lineNumber"
859 * - possible values: { "generate", "do not generate" }
860 * - default: "generate"
862 * COMPILER / Generating Source Debug Attribute
863 * When generated, this attribute will enable the debugger to present the
864 * corresponding source code.
865 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.sourceFile"
866 * - possible values: { "generate", "do not generate" }
867 * - default: "generate"
869 * COMPILER / Preserving Unused Local Variables
870 * Unless requested to preserve unused local variables (i.e. never read), the
871 * compiler will optimize them out, potentially altering debugging
872 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.unusedLocal"
873 * - possible values: { "preserve", "optimize out" }
874 * - default: "preserve"
876 * COMPILER / Defining Target Java Platform
877 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
878 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
879 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.targetPlatform"
880 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
881 * - default: "1.1"
883 * COMPILER / Reporting Unreachable Code
884 * Unreachable code can optionally be reported as an error, warning or simply
885 * ignored. The bytecode generation will always optimized it out.
886 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unreachableCode"
887 * - possible values: { "error", "warning", "ignore" }
888 * - default: "error"
890 * COMPILER / Reporting Invalid Import
891 * An import statement that cannot be resolved might optionally be reported
892 * as an error, as a warning or ignored.
893 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.invalidImport"
894 * - possible values: { "error", "warning", "ignore" }
895 * - default: "error"
897 * COMPILER / Reporting Attempt to Override Package-Default Method
898 * A package default method is not visible in a different package, and thus
899 * cannot be overridden. When enabling this option, the compiler will signal
900 * such scenarii either as an error or a warning.
901 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
902 * - possible values: { "error", "warning", "ignore" }
903 * - default: "warning"
905 * COMPILER / Reporting Method With Constructor Name
906 * Naming a method with a constructor name is generally considered poor
907 * style programming. When enabling this option, the compiler will signal such
908 * scenarii either as an error or a warning.
909 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.methodWithConstructorName"
910 * - possible values: { "error", "warning", "ignore" }
911 * - default: "warning"
913 * COMPILER / Reporting Deprecation
914 * When enabled, the compiler will signal use of deprecated API either as an
915 * error or a warning.
916 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecation"
917 * - possible values: { "error", "warning", "ignore" }
918 * - default: "warning"
920 * COMPILER / Reporting Deprecation Inside Deprecated Code
921 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
922 * The severity of the problem is controlled with option "org.phpeclipse.phpdt.core.compiler.problem.deprecation".
923 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
924 * - possible values: { "enabled", "disabled" }
925 * - default: "disabled"
927 * COMPILER / Reporting Hidden Catch Block
928 * Locally to a try statement, some catch blocks may hide others , e.g.
929 * try { throw new java.io.CharConversionException();
930 * } catch (java.io.CharConversionException e) {
931 * } catch (java.io.IOException e) {}.
932 * When enabling this option, the compiler will issue an error or a warning for hidden
933 * catch blocks corresponding to checked exceptions
934 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.hiddenCatchBlock"
935 * - possible values: { "error", "warning", "ignore" }
936 * - default: "warning"
938 * COMPILER / Reporting Unused Local
939 * When enabled, the compiler will issue an error or a warning for unused local
940 * variables (i.e. variables never read from)
941 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedLocal"
942 * - possible values: { "error", "warning", "ignore" }
943 * - default: "ignore"
945 * COMPILER / Reporting Unused Parameter
946 * When enabled, the compiler will issue an error or a warning for unused method
947 * parameters (i.e. parameters never read from)
948 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedParameter"
949 * - possible values: { "error", "warning", "ignore" }
950 * - default: "ignore"
952 * COMPILER / Reporting Unused Import
953 * When enabled, the compiler will issue an error or a warning for unused import
955 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedImport"
956 * - possible values: { "error", "warning", "ignore" }
957 * - default: "warning"
959 * COMPILER / Reporting Synthetic Access Emulation
960 * When enabled, the compiler will issue an error or a warning whenever it emulates
961 * access to a non-accessible member of an enclosing type. Such access can have
962 * performance implications.
963 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.syntheticAccessEmulation"
964 * - possible values: { "error", "warning", "ignore" }
965 * - default: "ignore"
967 * COMPILER / Reporting Non-Externalized String Literal
968 * When enabled, the compiler will issue an error or a warning for non externalized
969 * String literal (i.e. non tagged with //$NON-NLS-<n>$).
970 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
971 * - possible values: { "error", "warning", "ignore" }
972 * - default: "ignore"
974 * COMPILER / Reporting Usage of 'assert' Identifier
975 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
976 * used as an identifier (reserved keyword in 1.4)
977 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.assertIdentifier"
978 * - possible values: { "error", "warning", "ignore" }
979 * - default: "ignore"
981 * COMPILER / Reporting Usage of expression receiver on static invocation/field access
982 * When enabled, the compiler will issue an error or a warning whenever a static field
983 * or method is accessed with an expression receiver.
984 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.staticAccessReceiver"
985 * - possible values: { "error", "warning", "ignore" }
986 * - default: "warning"
988 * COMPILER / Reporting Assignment with no effect
989 * When enabled, the compiler will issue an error or a warning whenever an assignment
990 * has no effect (e.g 'x = x').
991 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.noEffectAssignment"
992 * - possible values: { "error", "warning", "ignore" }
993 * - default: "warning"
995 * COMPILER / Setting Source Compatibility Mode
996 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
997 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
998 * level should be set to "1.4" and the compliance mode should be "1.4".
999 * - option id: "org.phpeclipse.phpdt.core.compiler.source"
1000 * - possible values: { "1.3", "1.4" }
1001 * - default: "1.3"
1003 * COMPILER / Setting Compliance Level
1004 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
1005 * should not go beyond "1.3" level.
1006 * - option id: "org.phpeclipse.phpdt.core.compiler.compliance"
1007 * - possible values: { "1.3", "1.4" }
1008 * - default: "1.3"
1010 * COMPILER / Maximum number of problems reported per compilation unit
1011 * Specify the maximum number of problems reported on each compilation unit.
1012 * - option id: "org.phpeclipse.phpdt.core.compiler.maxProblemPerUnit"
1013 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
1014 * - default: "100"
1016 * COMPILER / Define the Automatic Task Tags
1017 * When the tag is non empty, the compiler will issue a task marker whenever it encounters
1018 * one of the corresponding tag inside any comment in Java source code.
1019 * Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed.
1020 * - option id: "org.phpeclipse.phpdt.core.compiler.taskTags"
1021 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card
1022 * - default: ""
1023 * COMPILER / Define the Automatic Task Priorities
1024 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
1025 * of the task markers issued by the compiler.
1026 * If the default is specified, the priority of each task marker is "NORMAL".
1027 * - option id: "org.phpeclipse.phpdt.core.compiler.taskPriorities"
1028 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
1029 * - default: ""
1031 * BUILDER / Specifying Filters for Resource Copying Control
1032 * Allow to specify some filters to control the resource copy process.
1033 * - option id: "org.phpeclipse.phpdt.core.builder.resourceCopyExclusionFilter"
1034 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
1035 * or the name of a folder which ends with '/'
1036 * - default: ""
1038 * BUILDER / Abort if Invalid Classpath
1039 * Allow to toggle the builder to abort if the classpath is invalid
1040 * - option id: "org.phpeclipse.phpdt.core.builder.invalidClasspath"
1041 * - possible values: { "abort", "ignore" }
1042 * - default: "ignore"
1044 * BUILDER / Cleaning Output Folder(s)
1045 * Indicate whether the JavaBuilder is allowed to clean the output folders
1046 * when performing full build operations.
1047 * - option id: "org.phpeclipse.phpdt.core.builder.cleanOutputFolder"
1048 * - possible values: { "clean", "ignore" }
1049 * - default: "clean"
1051 * JAVACORE / Computing Project Build Order
1052 * Indicate whether JavaCore should enforce the project build order to be based on
1053 * the classpath prerequisite chain. When requesting to compute, this takes over
1054 * the platform default order (based on project references).
1055 * - option id: "org.phpeclipse.phpdt.core.computeJavaBuildOrder"
1056 * - possible values: { "compute", "ignore" }
1057 * - default: "ignore"
1059 * JAVACORE / Specify Default Source Encoding Format
1060 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
1061 * to 'ResourcesPlugin.getEncoding()'.
1062 * - option id: "org.phpeclipse.phpdt.core.encoding"
1063 * - possible values: { any of the supported encoding name}.
1064 * - default: <platform default>
1066 * JAVACORE / Reporting Incomplete Classpath
1067 * An entry on the classpath doesn't exist or is not visible (e.g. a referenced project is closed).
1068 * - option id: "org.phpeclipse.phpdt.core.incompleteClasspath"
1069 * - possible values: { "error", "warning"}
1070 * - default: "error"
1072 * JAVACORE / Reporting Classpath Cycle
1073 * A project is involved in a cycle.
1074 * - option id: "org.phpeclipse.phpdt.core.circularClasspath"
1075 * - possible values: { "error", "warning" }
1076 * - default: "error"
1078 * FORMATTER / Inserting New Line Before Opening Brace
1079 * When Insert, a new line is inserted before an opening brace, otherwise nothing
1081 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.openingBrace"
1082 * - possible values: { "insert", "do not insert" }
1083 * - default: "do not insert"
1085 * FORMATTER / Inserting New Line Inside Control Statement
1086 * When Insert, a new line is inserted between } and following else, catch, finally
1087 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.controlStatement"
1088 * - possible values: { "insert", "do not insert" }
1089 * - default: "do not insert"
1091 * FORMATTER / Clearing Blank Lines
1092 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
1093 * and all others removed.
1094 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.clearAll"
1095 * - possible values: { "clear all", "preserve one" }
1096 * - default: "preserve one"
1098 * FORMATTER / Inserting New Line Between Else/If
1099 * When Insert, a blank line is inserted between an else and an if when they are
1100 * contiguous. When choosing to not insert, else-if will be kept on the same
1101 * line when possible.
1102 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.elseIf"
1103 * - possible values: { "insert", "do not insert" }
1104 * - default: "do not insert"
1106 * FORMATTER / Inserting New Line In Empty Block
1107 * When insert, a line break is inserted between contiguous { and }, if } is not followed
1109 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.emptyBlock"
1110 * - possible values: { "insert", "do not insert" }
1111 * - default: "insert"
1113 * FORMATTER / Splitting Lines Exceeding Length
1114 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
1115 * disable line splitting
1116 * - option id: "org.phpeclipse.phpdt.core.formatter.lineSplit"
1117 * - possible values: "<n>", where n is zero or a positive integer
1118 * - default: "80"
1120 * FORMATTER / Compacting Assignment
1121 * Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space
1122 * is inserted before the assignment operator
1123 * - option id: "org.phpeclipse.phpdt.core.formatter.style.assignment"
1124 * - possible values: { "compact", "normal" }
1125 * - default: "normal"
1127 * FORMATTER / Defining Indentation Character
1128 * Either choose to indent with tab characters or spaces
1129 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.char"
1130 * - possible values: { "tab", "space" }
1131 * - default: "tab"
1133 * FORMATTER / Defining Space Indentation Length
1134 * When using spaces, set the amount of space characters to use for each
1136 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.size"
1137 * - possible values: "<n>", where n is a positive integer
1138 * - default: "4"
1140 * CODEASSIST / Activate Visibility Sensitive Completion
1141 * When active, completion doesn't show that you can not see
1142 * (e.g. you can not see private methods of a super class).
1143 * - option id: "org.phpeclipse.phpdt.core.codeComplete.visibilityCheck"
1144 * - possible values: { "enabled", "disabled" }
1145 * - default: "disabled"
1147 * CODEASSIST / Automatic Qualification of Implicit Members
1148 * When active, completion automatically qualifies completion on implicit
1149 * field references and message expressions.
1150 * - option id: "org.phpeclipse.phpdt.core.codeComplete.forceImplicitQualification"
1151 * - possible values: { "enabled", "disabled" }
1152 * - default: "disabled"
1154 * CODEASSIST / Define the Prefixes for Field Name
1155 * When the prefixes is non empty, completion for field name will begin with
1156 * one of the proposed prefixes.
1157 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldPrefixes"
1158 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1159 * - default: ""
1161 * CODEASSIST / Define the Prefixes for Static Field Name
1162 * When the prefixes is non empty, completion for static field name will begin with
1163 * one of the proposed prefixes.
1164 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldPrefixes"
1165 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1166 * - default: ""
1168 * CODEASSIST / Define the Prefixes for Local Variable Name
1169 * When the prefixes is non empty, completion for local variable name will begin with
1170 * one of the proposed prefixes.
1171 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localPrefixes"
1172 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1173 * - default: ""
1175 * CODEASSIST / Define the Prefixes for Argument Name
1176 * When the prefixes is non empty, completion for argument name will begin with
1177 * one of the proposed prefixes.
1178 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentPrefixes"
1179 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1180 * - default: ""
1182 * CODEASSIST / Define the Suffixes for Field Name
1183 * When the suffixes is non empty, completion for field name will end with
1184 * one of the proposed suffixes.
1185 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldSuffixes"
1186 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1187 * - default: ""
1189 * CODEASSIST / Define the Suffixes for Static Field Name
1190 * When the suffixes is non empty, completion for static field name will end with
1191 * one of the proposed suffixes.
1192 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldSuffixes"
1193 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1194 * - default: ""
1196 * CODEASSIST / Define the Suffixes for Local Variable Name
1197 * When the suffixes is non empty, completion for local variable name will end with
1198 * one of the proposed suffixes.
1199 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localSuffixes"
1200 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1201 * - default: ""
1203 * CODEASSIST / Define the Suffixes for Argument Name
1204 * When the suffixes is non empty, completion for argument name will end with
1205 * one of the proposed suffixes.
1206 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentSuffixes"
1207 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
1208 * - default: ""
1211 * @return a mutable table containing the default settings of all known options
1224 // public static Hashtable getDefaultOptions() {
1226 // Hashtable defaultOptions = new Hashtable(10);
1228 // // see #initializeDefaultPluginPreferences() for changing default
1230 // Preferences preferences = getPlugin().getPluginPreferences();
1231 // HashSet optionNames = OptionNames;
1233 // // get preferences set to their default
1234 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1235 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1236 // String propertyName = defaultPropertyNames[i];
1237 // if (optionNames.contains(propertyName)) {
1238 // defaultOptions.put(propertyName,
1239 // preferences.getDefaultString(propertyName));
1242 // // get preferences not set to their default
1243 // String[] propertyNames = preferences.propertyNames();
1244 // for (int i = 0; i < propertyNames.length; i++) {
1245 // String propertyName = propertyNames[i];
1246 // if (optionNames.contains(propertyName)) {
1247 // defaultOptions.put(propertyName,
1248 // preferences.getDefaultString(propertyName));
1251 // // get encoding through resource plugin
1252 // defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1254 // return defaultOptions;
1257 * Helper method for returning one option value only. Equivalent to
1258 * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
1259 * may answer <code>null</code> if this option does not exist.
1261 * For a complete description of the configurable options, see
1262 * <code>getDefaultOptions</code>.
1266 * the name of an option
1267 * @return the String value of a given option
1268 * @see JavaCore#getDefaultOptions
1271 // public static String getOption(String optionName) {
1273 // if (CORE_ENCODING.equals(optionName)) {
1274 // return ResourcesPlugin.getEncoding();
1276 // if (OptionNames.contains(optionName)) {
1277 // Preferences preferences = getPlugin().getPluginPreferences();
1278 // return preferences.getString(optionName).trim();
1283 * Returns the table of the current options. Initially, all options have
1284 * their default values, and this method returns a table that includes all
1287 * For a complete description of the configurable options, see
1288 * <code>getDefaultOptions</code>.
1291 * @return table of current settings of all options (key type:
1292 * <code>String</code>; value type: <code>String</code>)
1293 * @see JavaCore#getDefaultOptions
1295 // public static Hashtable getOptions() {
1297 // Hashtable options = new Hashtable(10);
1299 // // see #initializeDefaultPluginPreferences() for changing default
1301 // Plugin plugin = getPlugin();
1302 // if (plugin != null) {
1303 // Preferences preferences = getPlugin().getPluginPreferences();
1304 // HashSet optionNames = OptionNames;
1306 // // get preferences set to their default
1307 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1308 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1309 // String propertyName = defaultPropertyNames[i];
1310 // if (optionNames.contains(propertyName)) {
1311 // options.put(propertyName, preferences.getDefaultString(propertyName));
1314 // // get preferences not set to their default
1315 // String[] propertyNames = preferences.propertyNames();
1316 // for (int i = 0; i < propertyNames.length; i++) {
1317 // String propertyName = propertyNames[i];
1318 // if (optionNames.contains(propertyName)) {
1319 // options.put(propertyName, preferences.getString(propertyName).trim());
1322 // // get encoding through resource plugin
1323 // options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1328 * Sets the current table of options. All and only the options explicitly
1329 * included in the given table are remembered; all previous option settings
1330 * are forgotten, including ones not explicitly mentioned.
1332 * For a complete description of the configurable options, see
1333 * <code>getDefaultOptions</code>.
1337 * the new options (key type: <code>String</code>; value type:
1338 * <code>String</code>), or <code>null</code> to reset all
1339 * options to their default values
1340 * @see JavaCore#getDefaultOptions
1342 // public static void setOptions(Hashtable newOptions) {
1344 // // see #initializeDefaultPluginPreferences() for changing default
1346 // Preferences preferences = getPlugin().getPluginPreferences();
1348 // if (newOptions == null) {
1349 // newOptions = getDefaultOptions();
1351 // Enumeration keys = newOptions.keys();
1352 // while (keys.hasMoreElements()) {
1353 // String key = (String) keys.nextElement();
1354 // if (!OptionNames.contains(key))
1355 // continue; // unrecognized option
1356 // if (key.equals(CORE_ENCODING))
1357 // continue; // skipped, contributed by resource prefs
1358 // String value = (String) newOptions.get(key);
1359 // preferences.setValue(key, value);
1362 // // persist options
1363 // getPlugin().savePluginPreferences();
1365 public static IProject[] getPHPProjects() {
1366 List phpProjectsList = new ArrayList();
1367 IProject[] workspaceProjects = PHPeclipsePlugin.getWorkspace()
1368 .getRoot().getProjects();
1370 for (int i = 0; i < workspaceProjects.length; i++) {
1371 IProject iProject = workspaceProjects[i];
1372 if (isPHPProject(iProject))
1373 phpProjectsList.add(iProject);
1376 IProject[] phpProjects = new IProject[phpProjectsList.size()];
1377 return (IProject[]) phpProjectsList.toArray(phpProjects);
1380 // public static PHPProject getPHPProject(String name) {
1381 // IProject aProject =
1382 // PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
1383 // if (isPHPProject(aProject)) {
1384 // PHPProject thePHPProject = new PHPProject();
1385 // thePHPProject.setProject(aProject);
1386 // return thePHPProject;
1391 public static boolean isPHPProject(IProject aProject) {
1393 return aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID);
1394 } catch (CoreException e) {
1400 // public static PHPFile create(IFile aFile) {
1401 // if (PHPFile.EXTENSION.equalsIgnoreCase(aFile.getFileExtension()))
1402 // return new PHPFile(aFile);
1403 // if (PHPFile.EXTENSION1.equalsIgnoreCase(aFile.getFileExtension()))
1404 // return new PHPFile(aFile);
1405 // if (PHPFile.EXTENSION2.equalsIgnoreCase(aFile.getFileExtension()))
1406 // return new PHPFile(aFile);
1407 // if (PHPFile.EXTENSION3.equalsIgnoreCase(aFile.getFileExtension()))
1408 // return new PHPFile(aFile);
1409 // if (PHPFile.EXTENSION4.equalsIgnoreCase(aFile.getFileExtension()))
1410 // return new PHPFile(aFile);
1411 // if (PHPFile.EXTENSION5.equalsIgnoreCase(aFile.getFileExtension()))
1412 // return new PHPFile(aFile);
1417 // public static PHPProject create(IProject aProject) {
1420 // if (aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1421 // PHPProject project = new PHPProject();
1422 // project.setProject(aProject);
1425 // } catch (CoreException e) {
1426 // System.err.println("Exception occurred in PHPCore#create(IProject): " +
1433 public static void addPHPNature(IProject project, IProgressMonitor monitor)
1434 throws CoreException {
1435 if (!project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1436 IProjectDescription description = project.getDescription();
1437 String[] prevNatures = description.getNatureIds();
1438 String[] newNatures = new String[prevNatures.length + 1];
1439 System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
1440 newNatures[prevNatures.length] = PHPeclipsePlugin.PHP_NATURE_ID;
1441 description.setNatureIds(newNatures);
1442 project.setDescription(description, monitor);
1447 * Returns the single instance of the PHP core plug-in runtime class.
1449 * @return the single instance of the PHP core plug-in runtime class
1451 public static Plugin getPlugin() {
1452 return PHPeclipsePlugin.getDefault();
1456 * Runs the given action as an atomic Java model operation.
1458 * After running a method that modifies java elements, registered listeners
1459 * receive after-the-fact notification of what just transpired, in the form
1460 * of a element changed event. This method allows clients to call a number
1461 * of methods that modify java elements and only have element changed event
1462 * notifications reported at the end of the entire batch.
1465 * If this method is called outside the dynamic scope of another such call,
1466 * this method runs the action and then reports a single element changed
1467 * event describing the net effect of all changes done to java elements by
1471 * If this method is called in the dynamic scope of another such call, this
1472 * method simply runs the action.
1476 * the action to perform
1478 * a progress monitor, or <code>null</code> if progress
1479 * reporting and cancellation are not desired
1480 * @exception CoreException
1481 * if the operation failed.
1484 // public static void run(IWorkspaceRunnable action, IProgressMonitor
1485 // monitor) throws CoreException {
1486 // run(action, ResourcesPlugin.getWorkspace().getRoot(), monitor);
1489 * Runs the given action as an atomic Java model operation.
1491 * After running a method that modifies java elements, registered listeners
1492 * receive after-the-fact notification of what just transpired, in the form
1493 * of a element changed event. This method allows clients to call a number
1494 * of methods that modify java elements and only have element changed event
1495 * notifications reported at the end of the entire batch.
1498 * If this method is called outside the dynamic scope of another such call,
1499 * this method runs the action and then reports a single element changed
1500 * event describing the net effect of all changes done to java elements by
1504 * If this method is called in the dynamic scope of another such call, this
1505 * method simply runs the action.
1508 * The supplied scheduling rule is used to determine whether this operation
1509 * can be run simultaneously with workspace changes in other threads. See
1510 * <code>IWorkspace.run(...)</code> for more details.
1514 * the action to perform
1516 * the scheduling rule to use when running this operation, or
1517 * <code>null</code> if there are no scheduling restrictions
1518 * for this operation.
1520 * a progress monitor, or <code>null</code> if progress
1521 * reporting and cancellation are not desired
1522 * @exception CoreException
1523 * if the operation failed.
1526 // public static void run(IWorkspaceRunnable action, ISchedulingRule rule,
1527 // IProgressMonitor monitor) throws CoreException {
1528 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
1529 // if (workspace.isTreeLocked()) {
1530 // new BatchOperation(action).run(monitor);
1532 // // use IWorkspace.run(...) to ensure that a build will be done in
1534 // workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE,
1540 * Adds the given listener for changes to Java elements. Has no effect if an
1541 * identical listener is already registered.
1543 * This listener will only be notified during the POST_CHANGE resource
1544 * change notification and any reconcile operation (POST_RECONCILE). For
1545 * finer control of the notification, use
1546 * <code>addElementChangedListener(IElementChangedListener,int)</code>,
1547 * which allows to specify a different eventMask.
1549 * @see ElementChangedEvent
1553 public static void addElementChangedListener(
1554 IElementChangedListener listener) {
1555 addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE
1556 | ElementChangedEvent.POST_RECONCILE);
1560 * Adds the given listener for changes to Java elements. Has no effect if an
1561 * identical listener is already registered. After completion of this
1562 * method, the given listener will be registered for exactly the specified
1563 * events. If they were previously registered for other events, they will be
1566 * Once registered, a listener starts receiving notification of changes to
1567 * java elements in the model. The listener continues to receive
1568 * notifications until it is replaced or removed.
1571 * Listeners can listen for several types of event as defined in
1572 * <code>ElementChangeEvent</code>. Clients are free to register for any
1573 * number of event types however if they register for more than one, it is
1574 * their responsibility to ensure they correctly handle the case where the
1575 * same java element change shows up in multiple notifications. Clients are
1576 * guaranteed to receive only the events for which they are registered.
1582 * the bit-wise OR of all event types of interest to the listener
1583 * @see IElementChangedListener
1584 * @see ElementChangedEvent
1585 * @see #removeElementChangedListener(IElementChangedListener)
1588 public static void addElementChangedListener(
1589 IElementChangedListener listener, int eventMask) {
1590 JavaModelManager.getJavaModelManager().addElementChangedListener(
1591 listener, eventMask);
1595 * Configures the given marker attribute map for the given Java element.
1596 * Used for markers, which denote a Java element rather than a resource.
1599 * the mutable marker attribute map (key type:
1600 * <code>String</code>, value type: <code>String</code>)
1602 * the Java element for which the marker needs to be configured
1604 public static void addJavaElementMarkerAttributes(Map attributes,
1605 IJavaElement element) {
1606 // if (element instanceof IMember)
1607 // element = ((IMember) element).getClassFile();
1608 if (attributes != null && element != null)
1609 attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier());
1613 * Configures the given marker for the given Java element. Used for markers,
1614 * which denote a Java element rather than a resource.
1617 * the marker to be configured
1619 * the Java element for which the marker needs to be configured
1620 * @exception CoreException
1621 * if the <code>IMarker.setAttribute</code> on the marker
1624 public void configureJavaElementMarker(IMarker marker, IJavaElement element)
1625 throws CoreException {
1626 // if (element instanceof IMember)
1627 // element = ((IMember) element).getClassFile();
1628 if (marker != null && element != null)
1629 marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier());
1633 * Returns the Java model element corresponding to the given handle
1634 * identifier generated by <code>IJavaElement.getHandleIdentifier()</code>,
1635 * or <code>null</code> if unable to create the associated element.
1637 public static IJavaElement create(String handleIdentifier) {
1638 if (handleIdentifier == null) {
1642 return JavaModelManager.getJavaModelManager().getHandleFromMemento(
1644 } catch (JavaModelException e) {
1650 * Returns the Java element corresponding to the given file, or
1651 * <code>null</code> if unable to associate the given file with a Java
1655 * The file must be one of:
1657 * <li>a <code>.java</code> file - the element returned is the
1658 * corresponding <code>ICompilationUnit</code></li>
1659 * <li>a <code>.class</code> file - the element returned is the
1660 * corresponding <code>IClassFile</code></li>
1661 * <li>a <code>.jar</code> file - the element returned is the
1662 * corresponding <code>IPackageFragmentRoot</code></li>
1665 * Creating a Java element has the side effect of creating and opening all
1666 * of the element's parents if they are not yet open.
1670 * @return the Java element corresponding to the given file, or
1671 * <code>null</code> if unable to associate the given file with a
1674 public static IJavaElement create(IFile file) {
1675 return JavaModelManager.create(file, null);
1679 * Returns the package fragment or package fragment root corresponding to
1680 * the given folder, or <code>null</code> if unable to associate the given
1681 * folder with a Java element.
1683 * Note that a package fragment root is returned rather than a default
1686 * Creating a Java element has the side effect of creating and opening all
1687 * of the element's parents if they are not yet open.
1691 * @return the package fragment or package fragment root corresponding to
1692 * the given folder, or <code>null</code> if unable to associate
1693 * the given folder with a Java element
1695 public static IJavaElement create(IFolder folder) {
1696 return JavaModelManager.create(folder, null);
1700 * Returns the Java project corresponding to the given project.
1702 * Creating a Java Project has the side effect of creating and opening all
1703 * of the project's parents if they are not yet open.
1705 * Note that no check is done at this time on the existence or the java
1706 * nature of this project.
1710 * @return the Java project corresponding to the given project, null if the
1711 * given project is null
1713 public static IJavaProject create(IProject project) {
1714 if (project == null) {
1717 JavaModel javaModel = JavaModelManager.getJavaModelManager()
1719 return javaModel.getJavaProject(project);
1723 * Returns the Java element corresponding to the given resource, or
1724 * <code>null</code> if unable to associate the given resource with a Java
1727 * The resource must be one of:
1729 * <li>a project - the element returned is the corresponding
1730 * <code>IJavaProject</code></li>
1731 * <li>a <code>.java</code> file - the element returned is the
1732 * corresponding <code>ICompilationUnit</code></li>
1733 * <li>a <code>.class</code> file - the element returned is the
1734 * corresponding <code>IClassFile</code></li>
1735 * <li>a <code>.jar</code> file - the element returned is the
1736 * corresponding <code>IPackageFragmentRoot</code></li>
1737 * <li>a folder - the element returned is the corresponding
1738 * <code>IPackageFragmentRoot</code> or <code>IPackageFragment</code>
1740 * <li>the workspace root resource - the element returned is the
1741 * <code>IJavaModel</code></li>
1744 * Creating a Java element has the side effect of creating and opening all
1745 * of the element's parents if they are not yet open.
1748 * the given resource
1749 * @return the Java element corresponding to the given resource, or
1750 * <code>null</code> if unable to associate the given resource
1751 * with a Java element
1753 public static IJavaElement create(IResource resource) {
1754 return JavaModelManager.create(resource, null);
1758 * Returns the Java model.
1762 * @return the Java model, or <code>null</code> if the root is null
1764 public static IJavaModel create(IWorkspaceRoot root) {
1768 return JavaModelManager.getJavaModelManager().getJavaModel();
1772 * Creates and returns a class file element for the given
1773 * <code>.class</code> file. Returns <code>null</code> if unable to
1774 * recognize the class file.
1777 * the given <code>.class</code> file
1778 * @return a class file element for the given <code>.class</code> file, or
1779 * <code>null</code> if unable to recognize the class file
1781 //public static IClassFile createClassFileFrom(IFile file) {
1782 // return JavaModelManager.createClassFileFrom(file, null);
1785 * Creates and returns a compilation unit element for the given
1786 * <code>.java</code> file. Returns <code>null</code> if unable to
1787 * recognize the compilation unit.
1790 * the given <code>.java</code> file
1791 * @return a compilation unit element for the given <code>.java</code>
1792 * file, or <code>null</code> if unable to recognize the
1795 public static ICompilationUnit createCompilationUnitFrom(IFile file) {
1796 return JavaModelManager.createCompilationUnitFrom(file, null);
1800 * Creates and returns a handle for the given JAR file. The Java model
1801 * associated with the JAR's project may be created as a side effect.
1804 * the given JAR file
1805 * @return a handle for the given JAR file, or <code>null</code> if unable
1806 * to create a JAR package fragment root. (for example, if the JAR
1807 * file represents a non-Java resource)
1809 //public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile
1811 // return JavaModelManager.createJarPackageFragmentRootFrom(file, null);
1814 * Answers the project specific value for a given classpath container. In
1815 * case this container path could not be resolved, then will answer
1816 * <code>null</code>. Both the container path and the project context are
1817 * supposed to be non-null.
1819 * The containerPath is a formed by a first ID segment followed with extra
1820 * segments, which can be used as additional hints for resolution. If no
1821 * container was ever recorded for this container path onto this project
1822 * (using <code>setClasspathContainer</code>, then a
1823 * <code>ClasspathContainerInitializer</code> will be activated if any was
1824 * registered for this container ID onto the extension point
1825 * "org.eclipse.jdt.core.classpathContainerInitializer".
1827 * There is no assumption that the returned container must answer the exact
1828 * same containerPath when requested
1829 * <code>IClasspathContainer#getPath</code>. Indeed, the containerPath is
1830 * just an indication for resolving it to an actual container object.
1832 * Classpath container values are persisted locally to the workspace, but
1833 * are not preserved from a session to another. It is thus highly
1834 * recommended to register a <code>ClasspathContainerInitializer</code>
1835 * for each referenced container (through the extension point
1836 * "org.eclipse.jdt.core.ClasspathContainerInitializer").
1839 * @param containerPath
1840 * the name of the container, which needs to be resolved
1842 * a specific project in which the container is being resolved
1843 * @return the corresponding classpath container or <code>null</code> if
1844 * unable to find one.
1846 * @exception JavaModelException
1847 * if an exception occurred while resolving the container, or
1848 * if the resolved container contains illegal entries
1849 * (contains CPE_CONTAINER entries or null entries).
1851 * @see ClasspathContainerInitializer
1852 * @see IClasspathContainer
1853 * @see #setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[],
1857 //public static IClasspathContainer getClasspathContainer(final IPath
1858 // containerPath, final IJavaProject project) throws JavaModelException {
1860 // IClasspathContainer container = JavaModelManager.containerGet(project,
1862 // if (container == JavaModelManager.ContainerInitializationInProgress)
1863 // return null; // break cycle
1865 // if (container == null){
1866 // final ClasspathContainerInitializer initializer =
1867 // JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
1868 // if (initializer != null){
1869 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1870 // System.out.println("CPContainer INIT - triggering initialization of:
1871 // ["+project.getElementName()+"] " + containerPath + " using initializer:
1872 // "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
1873 // new Exception("FAKE exception for dumping current CPContainer
1874 // (["+project.getElementName()+"] "+ containerPath+ ")INIT invocation stack
1875 // trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
1877 // JavaModelManager.containerPut(project, containerPath,
1878 // JavaModelManager.ContainerInitializationInProgress); // avoid
1879 // initialization cycles
1880 // boolean ok = false;
1882 // // wrap initializer call with Safe runnable in case initializer would be
1883 // causing some grief
1884 // Platform.run(new ISafeRunnable() {
1885 // public void handleException(Throwable exception) {
1886 // Util.log(exception, "Exception occurred in classpath container
1887 // initializer: "+initializer); //$NON-NLS-1$
1889 // public void run() throws Exception {
1890 // initializer.initialize(containerPath, project);
1894 // // retrieve value (if initialization was successful)
1895 // container = JavaModelManager.containerGet(project, containerPath);
1896 // if (container == JavaModelManager.ContainerInitializationInProgress)
1897 // return null; // break cycle
1900 // if (!ok) JavaModelManager.containerPut(project, containerPath, null); //
1903 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1904 // System.out.print("CPContainer INIT - after resolution:
1905 // ["+project.getElementName()+"] " + containerPath + " --> ");
1906 // //$NON-NLS-2$//$NON-NLS-1$//$NON-NLS-3$
1907 // if (container != null){
1908 // System.out.print("container: "+container.getDescription()+" {");
1909 // //$NON-NLS-2$//$NON-NLS-1$
1910 // IClasspathEntry[] entries = container.getClasspathEntries();
1911 // if (entries != null){
1912 // for (int i = 0; i < entries.length; i++){
1913 // if (i > 0) System.out.println(", ");//$NON-NLS-1$
1914 // System.out.println(entries[i]);
1917 // System.out.println("}");//$NON-NLS-1$
1919 // System.out.println("{unbound}");//$NON-NLS-1$
1923 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1924 // System.out.println("CPContainer INIT - no initializer found for:
1925 // "+project.getElementName()+"] " + containerPath); //$NON-NLS-1$
1930 // return container;
1933 * Helper method finding the classpath container initializer registered for
1934 * a given classpath container ID or <code>null</code> if none was found
1935 * while iterating over the contributions to extension point to the
1936 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
1938 * A containerID is the first segment of any container path, used to
1939 * identify the registered container initializer.
1943 * a containerID identifying a registered initializer
1944 * @return ClasspathContainerInitializer - the registered classpath
1945 * container initializer or <code>null</code> if none was found.
1948 //public static ClasspathContainerInitializer
1949 // getClasspathContainerInitializer(String containerID){
1951 // Plugin jdtCorePlugin = JavaCore.getPlugin();
1952 // if (jdtCorePlugin == null) return null;
1954 // IExtensionPoint extension =
1955 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID);
1956 // if (extension != null) {
1957 // IExtension[] extensions = extension.getExtensions();
1958 // for(int i = 0; i < extensions.length; i++){
1959 // IConfigurationElement [] configElements =
1960 // extensions[i].getConfigurationElements();
1961 // for(int j = 0; j < configElements.length; j++){
1962 // String initializerID = configElements[j].getAttribute("id");
1964 // if (initializerID != null && initializerID.equals(containerID)){
1965 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
1966 // System.out.println("CPContainer INIT - found initializer: "+containerID
1968 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
1971 // Object execExt = configElements[j].createExecutableExtension("class");
1973 // if (execExt instanceof ClasspathContainerInitializer){
1974 // return (ClasspathContainerInitializer)execExt;
1976 // } catch(CoreException e) {
1985 * Returns the path held in the given classpath variable. Returns <node>null
1986 * </code> if unable to bind.
1988 * Classpath variable values are persisted locally to the workspace, and are
1989 * preserved from session to session.
1991 * Note that classpath variables can be contributed registered initializers
1992 * for, using the extension point
1993 * "org.eclipse.jdt.core.classpathVariableInitializer". If an initializer is
1994 * registered for a variable, its persisted value will be ignored: its
1995 * initializer will thus get the opportunity to rebind the variable
1996 * differently on each session.
1998 * @param variableName
1999 * the name of the classpath variable
2000 * @return the path, or <code>null</code> if none
2001 * @see #setClasspathVariable
2003 public static IPath getClasspathVariable(final String variableName) {
2005 IPath variablePath = JavaModelManager.variableGet(variableName);
2006 if (variablePath == JavaModelManager.VariableInitializationInProgress)
2007 return null; // break cycle
2009 if (variablePath != null) {
2010 return variablePath;
2013 // even if persisted value exists, initializer is given priority, only
2014 // if no initializer is found the persisted value is reused
2015 // final ClasspathVariableInitializer initializer =
2016 // PHPCore.getClasspathVariableInitializer(variableName);
2017 // if (initializer != null){
2018 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2019 // System.out.println("CPVariable INIT - triggering initialization of: "
2020 // + variableName+ " using initializer: "+ initializer); //$NON-NLS-1$
2022 // new Exception("FAKE exception for dumping current CPVariable
2023 // ("+variableName+ ")INIT invocation stack trace").printStackTrace();
2024 // //$NON-NLS-1$//$NON-NLS-2$
2026 // JavaModelManager.variablePut(variableName,
2027 // JavaModelManager.VariableInitializationInProgress); // avoid
2028 // initialization cycles
2029 // boolean ok = false;
2031 // // wrap initializer call with Safe runnable in case initializer would
2032 // be causing some grief
2033 // Platform.run(new ISafeRunnable() {
2034 // public void handleException(Throwable exception) {
2035 // Util.log(exception, "Exception occurred in classpath variable
2036 // initializer: "+initializer+" while initializing variable:
2037 // "+variableName); //$NON-NLS-1$ //$NON-NLS-2$
2039 // public void run() throws Exception {
2040 // initializer.initialize(variableName);
2043 // variablePath = (IPath) JavaModelManager.variableGet(variableName); //
2044 // initializer should have performed side-effect
2045 // if (variablePath ==
2046 // JavaModelManager.VariableInitializationInProgress) return null; //
2047 // break cycle (initializer did not init or reentering call)
2048 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2049 // System.out.println("CPVariable INIT - after initialization: " +
2050 // variableName + " --> " + variablePath); //$NON-NLS-2$//$NON-NLS-1$
2054 // if (!ok) JavaModelManager.variablePut(variableName, null); // flush
2058 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2059 // System.out.println("CPVariable INIT - no initializer found for: " +
2060 // variableName); //$NON-NLS-1$
2063 return variablePath;
2067 * Helper method finding the classpath variable initializer registered for a
2068 * given classpath variable name or <code>null</code> if none was found
2069 * while iterating over the contributions to extension point to the
2070 * extension point "org.eclipse.jdt.core.classpathVariableInitializer".
2075 * @return ClasspathVariableInitializer - the registered classpath variable
2076 * initializer or <code>null</code> if none was found.
2079 public static ClasspathVariableInitializer getClasspathVariableInitializer(
2082 Plugin jdtCorePlugin = JavaCore.getPlugin();
2083 if (jdtCorePlugin == null)
2086 // IExtensionPoint extension =
2087 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID);
2088 // if (extension != null) {
2089 // IExtension[] extensions = extension.getExtensions();
2090 // for(int i = 0; i < extensions.length; i++){
2091 // IConfigurationElement [] configElements =
2092 // extensions[i].getConfigurationElements();
2093 // for(int j = 0; j < configElements.length; j++){
2095 // String varAttribute = configElements[j].getAttribute("variable");
2097 // if (variable.equals(varAttribute)) {
2098 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
2099 // System.out.println("CPVariable INIT - found initializer: "+variable+"
2101 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
2104 // configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
2105 // if (execExt instanceof ClasspathVariableInitializer){
2106 // return (ClasspathVariableInitializer)execExt;
2109 // } catch(CoreException e){
2118 * Returns the names of all known classpath variables.
2120 * Classpath variable values are persisted locally to the workspace, and are
2121 * preserved from session to session.
2124 * @return the list of classpath variable names
2125 * @see #setClasspathVariable
2127 //public static String[] getClasspathVariableNames() {
2128 // return JavaModelManager.variableNames();
2131 * Returns a table of all known configurable options with their default
2132 * values. These options allow to configure the behaviour of the underlying
2133 * components. The client may safely use the result as a template that they
2134 * can modify and then pass to <code>setOptions</code>.
2136 * Helper constants have been defined on JavaCore for each of the option ID
2137 * and their possible constant values.
2139 * Note: more options might be added in further releases.
2143 * RECOGNIZED OPTIONS:
2144 * COMPILER / Generating Local Variable Debug Attribute
2145 * When generated, this attribute will enable local variable names
2146 * to be displayed in debugger, only in place where variables are
2147 * definitely assigned (.class file is then bigger)
2148 * - option id: "org.eclipse.jdt.core.compiler.debug.localVariable"
2149 * - possible values: { "generate", "do not generate" }
2150 * - default: "generate"
2152 * COMPILER / Generating Line Number Debug Attribute
2153 * When generated, this attribute will enable source code highlighting in debugger
2154 * (.class file is then bigger).
2155 * - option id: "org.eclipse.jdt.core.compiler.debug.lineNumber"
2156 * - possible values: { "generate", "do not generate" }
2157 * - default: "generate"
2159 * COMPILER / Generating Source Debug Attribute
2160 * When generated, this attribute will enable the debugger to present the
2161 * corresponding source code.
2162 * - option id: "org.eclipse.jdt.core.compiler.debug.sourceFile"
2163 * - possible values: { "generate", "do not generate" }
2164 * - default: "generate"
2166 * COMPILER / Preserving Unused Local Variables
2167 * Unless requested to preserve unused local variables (that is, never read), the
2168 * compiler will optimize them out, potentially altering debugging
2169 * - option id: "org.eclipse.jdt.core.compiler.codegen.unusedLocal"
2170 * - possible values: { "preserve", "optimize out" }
2171 * - default: "preserve"
2173 * COMPILER / Defining Target Java Platform
2174 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
2175 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
2176 * - option id: "org.eclipse.jdt.core.compiler.codegen.targetPlatform"
2177 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
2178 * - default: "1.1"
2180 * COMPILER / Reporting Unreachable Code
2181 * Unreachable code can optionally be reported as an error, warning or simply
2182 * ignored. The bytecode generation will always optimized it out.
2183 * - option id: "org.eclipse.jdt.core.compiler.problem.unreachableCode"
2184 * - possible values: { "error", "warning", "ignore" }
2185 * - default: "error"
2187 * COMPILER / Reporting Invalid Import
2188 * An import statement that cannot be resolved might optionally be reported
2189 * as an error, as a warning or ignored.
2190 * - option id: "org.eclipse.jdt.core.compiler.problem.invalidImport"
2191 * - possible values: { "error", "warning", "ignore" }
2192 * - default: "error"
2194 * COMPILER / Reporting Attempt to Override Package-Default Method
2195 * A package default method is not visible in a different package, and thus
2196 * cannot be overridden. When enabling this option, the compiler will signal
2197 * such scenarii either as an error or a warning.
2198 * - option id: "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"
2199 * - possible values: { "error", "warning", "ignore" }
2200 * - default: "warning"
2202 * COMPILER / Reporting Method With Constructor Name
2203 * Naming a method with a constructor name is generally considered poor
2204 * style programming. When enabling this option, the compiler will signal such
2205 * scenarii either as an error or a warning.
2206 * - option id: "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"
2207 * - possible values: { "error", "warning", "ignore" }
2208 * - default: "warning"
2210 * COMPILER / Reporting Deprecation
2211 * When enabled, the compiler will signal use of deprecated API either as an
2212 * error or a warning.
2213 * - option id: "org.eclipse.jdt.core.compiler.problem.deprecation"
2214 * - possible values: { "error", "warning", "ignore" }
2215 * - default: "warning"
2217 * COMPILER / Reporting Deprecation Inside Deprecated Code
2218 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
2219 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.deprecation".
2220 * - option id: "org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode"
2221 * - possible values: { "enabled", "disabled" }
2222 * - default: "disabled"
2224 * COMPILER / Reporting Hidden Catch Block
2225 * Locally to a try statement, some catch blocks may hide others . For example,
2226 * try { throw new java.io.CharConversionException();
2227 * } catch (java.io.CharConversionException e) {
2228 * } catch (java.io.IOException e) {}.
2229 * When enabling this option, the compiler will issue an error or a warning for hidden
2230 * catch blocks corresponding to checked exceptions
2231 * - option id: "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"
2232 * - possible values: { "error", "warning", "ignore" }
2233 * - default: "warning"
2235 * COMPILER / Reporting Unused Local
2236 * When enabled, the compiler will issue an error or a warning for unused local
2237 * variables (that is, variables never read from)
2238 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedLocal"
2239 * - possible values: { "error", "warning", "ignore" }
2240 * - default: "ignore"
2242 * COMPILER / Reporting Unused Parameter
2243 * When enabled, the compiler will issue an error or a warning for unused method
2244 * parameters (that is, parameters never read from)
2245 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameter"
2246 * - possible values: { "error", "warning", "ignore" }
2247 * - default: "ignore"
2249 * COMPILER / Reporting Unused Parameter if Implementing Abstract Method
2250 * When enabled, the compiler will signal unused parameters in abstract method implementations.
2251 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
2252 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"
2253 * - possible values: { "enabled", "disabled" }
2254 * - default: "disabled"
2256 * COMPILER / Reporting Unused Parameter if Overriding Concrete Method
2257 * When enabled, the compiler will signal unused parameters in methods overriding concrete ones.
2258 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
2259 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"
2260 * - possible values: { "enabled", "disabled" }
2261 * - default: "disabled"
2263 * COMPILER / Reporting Unused Import
2264 * When enabled, the compiler will issue an error or a warning for unused import
2266 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedImport"
2267 * - possible values: { "error", "warning", "ignore" }
2268 * - default: "warning"
2270 * COMPILER / Reporting Unused Private Members
2271 * When enabled, the compiler will issue an error or a warning whenever a private
2272 * method or field is declared but never used within the same unit.
2273 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"
2274 * - possible values: { "error", "warning", "ignore" }
2275 * - default: "ignore"
2277 * COMPILER / Reporting Synthetic Access Emulation
2278 * When enabled, the compiler will issue an error or a warning whenever it emulates
2279 * access to a non-accessible member of an enclosing type. Such access can have
2280 * performance implications.
2281 * - option id: "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"
2282 * - possible values: { "error", "warning", "ignore" }
2283 * - default: "ignore"
2285 * COMPILER / Reporting Non-Externalized String Literal
2286 * When enabled, the compiler will issue an error or a warning for non externalized
2287 * String literal (that is, not tagged with //$NON-NLS-<n>$).
2288 * - option id: "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"
2289 * - possible values: { "error", "warning", "ignore" }
2290 * - default: "ignore"
2292 * COMPILER / Reporting Usage of 'assert' Identifier
2293 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
2294 * used as an identifier (reserved keyword in 1.4)
2295 * - option id: "org.eclipse.jdt.core.compiler.problem.assertIdentifier"
2296 * - possible values: { "error", "warning", "ignore" }
2297 * - default: "ignore"
2299 * COMPILER / Reporting Non-Static Reference to a Static Member
2300 * When enabled, the compiler will issue an error or a warning whenever a static field
2301 * or method is accessed with an expression receiver. A reference to a static member should
2302 * be qualified with a type name.
2303 * - option id: "org.eclipse.jdt.core.compiler.problem.staticAccessReceiver"
2304 * - possible values: { "error", "warning", "ignore" }
2305 * - default: "warning"
2307 * COMPILER / Reporting Assignment with no Effect
2308 * When enabled, the compiler will issue an error or a warning whenever an assignment
2309 * has no effect (e.g 'x = x').
2310 * - option id: "org.eclipse.jdt.core.compiler.problem.noEffectAssignment"
2311 * - possible values: { "error", "warning", "ignore" }
2312 * - default: "warning"
2314 * COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods
2315 * When enabled, the compiler will issue an error or a warning whenever an interface
2316 * defines a method incompatible with a non-inherited Object method. Until this conflict
2317 * is resolved, such an interface cannot be implemented, For example,
2321 * - option id: "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"
2322 * - possible values: { "error", "warning", "ignore" }
2323 * - default: "warning"
2325 * COMPILER / Reporting Usage of char[] Expressions in String Concatenations
2326 * When enabled, the compiler will issue an error or a warning whenever a char[] expression
2327 * is used in String concatenations (for example, "hello" + new char[]{'w','o','r','l','d'}).
2328 * - option id: "org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion"
2329 * - possible values: { "error", "warning", "ignore" }
2330 * - default: "warning"
2332 * COMPILER / Setting Source Compatibility Mode
2333 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
2334 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
2335 * level should be set to "1.4" and the compliance mode should be "1.4".
2336 * - option id: "org.eclipse.jdt.core.compiler.source"
2337 * - possible values: { "1.3", "1.4" }
2338 * - default: "1.3"
2340 * COMPILER / Setting Compliance Level
2341 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
2342 * should not go beyond "1.3" level.
2343 * - option id: "org.eclipse.jdt.core.compiler.compliance"
2344 * - possible values: { "1.3", "1.4" }
2345 * - default: "1.3"
2347 * COMPILER / Maximum number of problems reported per compilation unit
2348 * Specify the maximum number of problems reported on each compilation unit.
2349 * - option id: "org.eclipse.jdt.core.compiler.maxProblemPerUnit"
2350 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
2351 * - default: "100"
2353 * COMPILER / Define the Automatic Task Tags
2354 * When the tag list is not empty, the compiler will issue a task marker whenever it encounters
2355 * one of the corresponding tag inside any comment in Java source code.
2356 * Generated task messages will include the tag, and range until the next line separator or comment ending.
2357 * Note that tasks messages are trimmed.
2358 * - option id: "org.eclipse.jdt.core.compiler.taskTags"
2359 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card or leading/trailing spaces
2360 * - default: ""
2362 * COMPILER / Define the Automatic Task Priorities
2363 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
2364 * of the task markers issued by the compiler.
2365 * If the default is specified, the priority of each task marker is "NORMAL".
2366 * - option id: "org.eclipse.jdt.core.compiler.taskPriorities"
2367 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
2368 * - default: ""
2370 * BUILDER / Specifying Filters for Resource Copying Control
2371 * Allow to specify some filters to control the resource copy process.
2372 * - option id: "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
2373 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
2374 * or the name of a folder which ends with '/'
2375 * - default: ""
2377 * BUILDER / Abort if Invalid Classpath
2378 * Allow to toggle the builder to abort if the classpath is invalid
2379 * - option id: "org.eclipse.jdt.core.builder.invalidClasspath"
2380 * - possible values: { "abort", "ignore" }
2381 * - default: "abort"
2383 * BUILDER / Cleaning Output Folder(s)
2384 * Indicate whether the JavaBuilder is allowed to clean the output folders
2385 * when performing full build operations.
2386 * - option id: "org.eclipse.jdt.core.builder.cleanOutputFolder"
2387 * - possible values: { "clean", "ignore" }
2388 * - default: "clean"
2390 * BUILDER / Reporting Duplicate Resources
2391 * Indicate the severity of the problem reported when more than one occurrence
2392 * of a resource is to be copied into the output location.
2393 * - option id: "org.eclipse.jdt.core.builder.duplicateResourceTask"
2394 * - possible values: { "error", "warning" }
2395 * - default: "warning"
2397 * JAVACORE / Computing Project Build Order
2398 * Indicate whether JavaCore should enforce the project build order to be based on
2399 * the classpath prerequisite chain. When requesting to compute, this takes over
2400 * the platform default order (based on project references).
2401 * - option id: "org.eclipse.jdt.core.computeJavaBuildOrder"
2402 * - possible values: { "compute", "ignore" }
2403 * - default: "ignore"
2405 * JAVACORE / Specify Default Source Encoding Format
2406 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
2407 * to 'ResourcesPlugin.getEncoding()'.
2408 * - option id: "org.eclipse.jdt.core.encoding"
2409 * - possible values: { any of the supported encoding name}.
2410 * - default: <platform default>
2412 * JAVACORE / Reporting Incomplete Classpath
2413 * Indicate the severity of the problem reported when an entry on the classpath does not exist,
2414 * is not legite or is not visible (for example, a referenced project is closed).
2415 * - option id: "org.eclipse.jdt.core.incompleteClasspath"
2416 * - possible values: { "error", "warning"}
2417 * - default: "error"
2419 * JAVACORE / Reporting Classpath Cycle
2420 * Indicate the severity of the problem reported when a project is involved in a cycle.
2421 * - option id: "org.eclipse.jdt.core.circularClasspath"
2422 * - possible values: { "error", "warning" }
2423 * - default: "error"
2425 * JAVACORE / Enabling Usage of Classpath Exclusion Patterns
2426 * When disabled, no entry on a project classpath can be associated with
2427 * an exclusion pattern.
2428 * - option id: "org.eclipse.jdt.core.classpath.exclusionPatterns"
2429 * - possible values: { "enabled", "disabled" }
2430 * - default: "enabled"
2432 * JAVACORE / Enabling Usage of Classpath Multiple Output Locations
2433 * When disabled, no entry on a project classpath can be associated with
2434 * a specific output location, preventing thus usage of multiple output locations.
2435 * - option id: "org.eclipse.jdt.core.classpath.multipleOutputLocations"
2436 * - possible values: { "enabled", "disabled" }
2437 * - default: "enabled"
2439 * FORMATTER / Inserting New Line Before Opening Brace
2440 * When Insert, a new line is inserted before an opening brace, otherwise nothing
2442 * - option id: "org.eclipse.jdt.core.formatter.newline.openingBrace"
2443 * - possible values: { "insert", "do not insert" }
2444 * - default: "do not insert"
2446 * FORMATTER / Inserting New Line Inside Control Statement
2447 * When Insert, a new line is inserted between } and following else, catch, finally
2448 * - option id: "org.eclipse.jdt.core.formatter.newline.controlStatement"
2449 * - possible values: { "insert", "do not insert" }
2450 * - default: "do not insert"
2452 * FORMATTER / Clearing Blank Lines
2453 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
2454 * and all others removed.
2455 * - option id: "org.eclipse.jdt.core.formatter.newline.clearAll"
2456 * - possible values: { "clear all", "preserve one" }
2457 * - default: "preserve one"
2459 * FORMATTER / Inserting New Line Between Else/If
2460 * When Insert, a blank line is inserted between an else and an if when they are
2461 * contiguous. When choosing to not insert, else-if will be kept on the same
2462 * line when possible.
2463 * - option id: "org.eclipse.jdt.core.formatter.newline.elseIf"
2464 * - possible values: { "insert", "do not insert" }
2465 * - default: "do not insert"
2467 * FORMATTER / Inserting New Line In Empty Block
2468 * When insert, a line break is inserted between contiguous { and }, if } is not followed
2470 * - option id: "org.eclipse.jdt.core.formatter.newline.emptyBlock"
2471 * - possible values: { "insert", "do not insert" }
2472 * - default: "insert"
2474 * FORMATTER / Splitting Lines Exceeding Length
2475 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
2476 * disable line splitting
2477 * - option id: "org.eclipse.jdt.core.formatter.lineSplit"
2478 * - possible values: "<n>", where n is zero or a positive integer
2479 * - default: "80"
2481 * FORMATTER / Compacting Assignment
2482 * Assignments can be formatted asymmetrically, for example 'int x= 2;', when Normal, a space
2483 * is inserted before the assignment operator
2484 * - option id: "org.eclipse.jdt.core.formatter.style.assignment"
2485 * - possible values: { "compact", "normal" }
2486 * - default: "normal"
2488 * FORMATTER / Defining Indentation Character
2489 * Either choose to indent with tab characters or spaces
2490 * - option id: "org.eclipse.jdt.core.formatter.tabulation.char"
2491 * - possible values: { "tab", "space" }
2492 * - default: "tab"
2494 * FORMATTER / Defining Space Indentation Length
2495 * When using spaces, set the amount of space characters to use for each
2497 * - option id: "org.eclipse.jdt.core.formatter.tabulation.size"
2498 * - possible values: "<n>", where n is a positive integer
2499 * - default: "4"
2501 * FORMATTER / Inserting space in cast expression
2502 * When Insert, a space is added between the type and the expression in a cast expression.
2503 * - option id: "org.eclipse.jdt.core.formatter.space.castexpression"
2504 * - possible values: { "insert", "do not insert" }
2505 * - default: "insert"
2507 * CODEASSIST / Activate Visibility Sensitive Completion
2508 * When active, completion doesn't show that you can not see
2509 * (for example, you can not see private methods of a super class).
2510 * - option id: "org.eclipse.jdt.core.codeComplete.visibilityCheck"
2511 * - possible values: { "enabled", "disabled" }
2512 * - default: "disabled"
2514 * CODEASSIST / Automatic Qualification of Implicit Members
2515 * When active, completion automatically qualifies completion on implicit
2516 * field references and message expressions.
2517 * - option id: "org.eclipse.jdt.core.codeComplete.forceImplicitQualification"
2518 * - possible values: { "enabled", "disabled" }
2519 * - default: "disabled"
2521 * CODEASSIST / Define the Prefixes for Field Name
2522 * When the prefixes is non empty, completion for field name will begin with
2523 * one of the proposed prefixes.
2524 * - option id: "org.eclipse.jdt.core.codeComplete.fieldPrefixes"
2525 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2526 * - default: ""
2528 * CODEASSIST / Define the Prefixes for Static Field Name
2529 * When the prefixes is non empty, completion for static field name will begin with
2530 * one of the proposed prefixes.
2531 * - option id: "org.eclipse.jdt.core.codeComplete.staticFieldPrefixes"
2532 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2533 * - default: ""
2535 * CODEASSIST / Define the Prefixes for Local Variable Name
2536 * When the prefixes is non empty, completion for local variable name will begin with
2537 * one of the proposed prefixes.
2538 * - option id: "org.eclipse.jdt.core.codeComplete.localPrefixes"
2539 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2540 * - default: ""
2542 * CODEASSIST / Define the Prefixes for Argument Name
2543 * When the prefixes is non empty, completion for argument name will begin with
2544 * one of the proposed prefixes.
2545 * - option id: "org.eclipse.jdt.core.codeComplete.argumentPrefixes"
2546 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2547 * - default: ""
2549 * CODEASSIST / Define the Suffixes for Field Name
2550 * When the suffixes is non empty, completion for field name will end with
2551 * one of the proposed suffixes.
2552 * - option id: "org.eclipse.jdt.core.codeComplete.fieldSuffixes"
2553 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2554 * - default: ""
2556 * CODEASSIST / Define the Suffixes for Static Field Name
2557 * When the suffixes is non empty, completion for static field name will end with
2558 * one of the proposed suffixes.
2559 * - option id: "org.eclipse.jdt.core.codeComplete.staticFieldSuffixes"
2560 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2561 * - default: ""
2563 * CODEASSIST / Define the Suffixes for Local Variable Name
2564 * When the suffixes is non empty, completion for local variable name will end with
2565 * one of the proposed suffixes.
2566 * - option id: "org.eclipse.jdt.core.codeComplete.localSuffixes"
2567 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2568 * - default: ""
2570 * CODEASSIST / Define the Suffixes for Argument Name
2571 * When the suffixes is non empty, completion for argument name will end with
2572 * one of the proposed suffixes.
2573 * - option id: "org.eclipse.jdt.core.codeComplete.argumentSuffixes"
2574 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
2575 * - default: ""
2578 * @return a mutable table containing the default settings of all known options
2591 public static Hashtable getDefaultOptions() {
2593 Hashtable defaultOptions = new Hashtable(10);
2595 // see #initializeDefaultPluginPreferences() for changing default
2597 Preferences preferences = getPlugin().getPluginPreferences();
2598 HashSet optionNames = JavaModelManager.OptionNames;
2600 // get preferences set to their default
2601 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2602 for (int i = 0; i < defaultPropertyNames.length; i++) {
2603 String propertyName = defaultPropertyNames[i];
2604 if (optionNames.contains(propertyName)) {
2605 defaultOptions.put(propertyName, preferences
2606 .getDefaultString(propertyName));
2609 // get preferences not set to their default
2610 String[] propertyNames = preferences.propertyNames();
2611 for (int i = 0; i < propertyNames.length; i++) {
2612 String propertyName = propertyNames[i];
2613 if (optionNames.contains(propertyName)) {
2614 defaultOptions.put(propertyName, preferences
2615 .getDefaultString(propertyName));
2618 // get encoding through resource plugin
2619 defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2621 return defaultOptions;
2625 * Returns the single instance of the Java core plug-in runtime class.
2626 * Equivalent to <code>(JavaCore) getPlugin()</code>.
2628 * @return the single instance of the Java core plug-in runtime class
2630 public static PHPeclipsePlugin getJavaCore() {
2631 return (PHPeclipsePlugin) getPlugin();
2635 * Helper method for returning one option value only. Equivalent to
2636 * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
2637 * may answer <code>null</code> if this option does not exist.
2639 * For a complete description of the configurable options, see
2640 * <code>getDefaultOptions</code>.
2644 * the name of an option
2645 * @return the String value of a given option
2646 * @see JavaCore#getDefaultOptions
2649 public static String getOption(String optionName) {
2651 if (CORE_ENCODING.equals(optionName)) {
2652 return ResourcesPlugin.getEncoding();
2654 if (JavaModelManager.OptionNames.contains(optionName)) {
2655 Preferences preferences = getPlugin().getPluginPreferences();
2656 return preferences.getString(optionName).trim();
2662 * Returns the table of the current options. Initially, all options have
2663 * their default values, and this method returns a table that includes all
2666 * For a complete description of the configurable options, see
2667 * <code>getDefaultOptions</code>.
2670 * @return table of current settings of all options (key type:
2671 * <code>String</code>; value type: <code>String</code>)
2672 * @see JavaCore#getDefaultOptions
2674 public static Hashtable getOptions() {
2676 Hashtable options = new Hashtable(10);
2678 // see #initializeDefaultPluginPreferences() for changing default
2680 Plugin plugin = getPlugin();
2681 if (plugin != null) {
2682 Preferences preferences = getPlugin().getPluginPreferences();
2683 HashSet optionNames = JavaModelManager.OptionNames;
2685 // get preferences set to their default
2686 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2687 for (int i = 0; i < defaultPropertyNames.length; i++) {
2688 String propertyName = defaultPropertyNames[i];
2689 if (optionNames.contains(propertyName)) {
2690 options.put(propertyName, preferences
2691 .getDefaultString(propertyName));
2694 // get preferences not set to their default
2695 String[] propertyNames = preferences.propertyNames();
2696 for (int i = 0; i < propertyNames.length; i++) {
2697 String propertyName = propertyNames[i];
2698 if (optionNames.contains(propertyName)) {
2699 options.put(propertyName, preferences.getString(
2700 propertyName).trim());
2703 // get encoding through resource plugin
2704 options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2710 * This is a helper method, which returns the resolved classpath entry
2711 * denoted by a given entry (if it is a variable entry). It is obtained by
2712 * resolving the variable reference in the first segment. Returns <node>null
2713 * </code> if unable to resolve using the following algorithm:
2715 * <li>if variable segment cannot be resolved, returns <code>null</code>
2717 * <li>finds a project, JAR or binary folder in the workspace at the
2718 * resolved path location</li>
2719 * <li>if none finds an external JAR file or folder outside the workspace
2720 * at the resolved path location</li>
2721 * <li>if none returns <code>null</code></li>
2724 * Variable source attachment path and root path are also resolved and
2725 * recorded in the resulting classpath entry.
2727 * NOTE: This helper method does not handle classpath containers, for which
2728 * should rather be used <code>JavaCore#getClasspathContainer(IPath,
2729 * IJavaProject)</code>.
2733 * the given variable entry
2734 * @return the resolved library or project classpath entry, or <code>null
2735 * </code> if the given variable entry could not be resolved to a
2736 * valid classpath entry
2738 public static IClasspathEntry getResolvedClasspathEntry(
2739 IClasspathEntry entry) {
2741 if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
2744 IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
2745 IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath());
2746 if (resolvedPath == null)
2749 Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false);
2753 // inside the workspace
2754 if (target instanceof IResource) {
2755 IResource resolvedResource = (IResource) target;
2756 if (resolvedResource != null) {
2757 switch (resolvedResource.getType()) {
2759 case IResource.PROJECT:
2761 return JavaCore.newProjectEntry(resolvedPath, entry
2764 case IResource.FILE:
2765 // if (Util.isArchiveFileName(resolvedResource.getName())) {
2766 // // internal binary archive
2767 // return JavaCore.newLibraryEntry(
2769 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2770 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2771 // entry.isExported());
2775 case IResource.FOLDER:
2776 // internal binary folder
2777 // return JavaCore.newLibraryEntry(
2779 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2780 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2781 // entry.isExported());
2786 // outside the workspace
2787 if (target instanceof File) {
2788 File externalFile = (File) target;
2789 if (externalFile.isFile()) {
2790 String fileName = externalFile.getName().toLowerCase();
2791 // if (fileName.endsWith(".jar" //$NON-NLS-1$
2792 // ) || fileName.endsWith(".zip" //$NON-NLS-1$
2793 // )) { // external binary archive
2794 // return JavaCore.newLibraryEntry(
2796 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2797 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2798 // entry.isExported());
2800 } else { // external binary folder
2801 if (resolvedPath.isAbsolute()) {
2802 // return JavaCore.newLibraryEntry(
2804 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2805 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2806 // entry.isExported());
2814 * Resolve a variable path (helper method).
2816 * @param variablePath
2817 * the given variable path
2818 * @return the resolved variable path or <code>null</code> if none
2820 public static IPath getResolvedVariablePath(IPath variablePath) {
2822 if (variablePath == null)
2824 int count = variablePath.segmentCount();
2829 String variableName = variablePath.segment(0);
2830 IPath resolvedPath = JavaCore.getClasspathVariable(variableName);
2831 if (resolvedPath == null)
2834 // append path suffix
2836 resolvedPath = resolvedPath.append(variablePath
2837 .removeFirstSegments(1));
2839 return resolvedPath;
2843 * Answers the shared working copies currently registered for this buffer
2844 * factory. Working copies can be shared by several clients using the same
2845 * buffer factory,see <code>IWorkingCopy.getSharedWorkingCopy</code>.
2848 * the given buffer factory
2849 * @return the list of shared working copies for a given buffer factory
2853 public static IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory) {
2855 // if factory is null, default factory must be used
2856 if (factory == null)
2857 factory = BufferManager.getDefaultBufferManager()
2858 .getDefaultBufferFactory();
2859 Map sharedWorkingCopies = JavaModelManager.getJavaModelManager().sharedWorkingCopies;
2861 Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
2862 if (perFactoryWorkingCopies == null)
2863 return JavaModelManager.NoWorkingCopy;
2864 Collection copies = perFactoryWorkingCopies.values();
2865 IWorkingCopy[] result = new IWorkingCopy[copies.size()];
2866 copies.toArray(result);
2871 * Initializes the default preferences settings for this plug-in.
2873 public static void initializeDefaultPluginPreferences() {
2875 Preferences preferences = PHPeclipsePlugin.getDefault()
2876 .getPluginPreferences();
2877 HashSet optionNames = JavaModelManager.OptionNames;
2879 // Compiler settings
2880 preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
2881 optionNames.add(COMPILER_LOCAL_VARIABLE_ATTR);
2883 preferences.setDefault(COMPILER_LINE_NUMBER_ATTR, GENERATE);
2884 optionNames.add(COMPILER_LINE_NUMBER_ATTR);
2886 preferences.setDefault(COMPILER_SOURCE_FILE_ATTR, GENERATE);
2887 optionNames.add(COMPILER_SOURCE_FILE_ATTR);
2889 preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE);
2890 optionNames.add(COMPILER_CODEGEN_UNUSED_LOCAL);
2892 preferences.setDefault(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1);
2893 optionNames.add(COMPILER_CODEGEN_TARGET_PLATFORM);
2895 preferences.setDefault(COMPILER_PB_PHP_VAR_DEPRECATED, WARNING);
2896 optionNames.add(COMPILER_PB_PHP_VAR_DEPRECATED);
2897 preferences.setDefault(COMPILER_PB_PHP_KEYWORD, WARNING);
2898 optionNames.add(COMPILER_PB_PHP_KEYWORD);
2899 preferences.setDefault(COMPILER_PB_PHP_UPPERCASE_IDENTIFIER, IGNORE);
2900 optionNames.add(COMPILER_PB_PHP_UPPERCASE_IDENTIFIER);
2902 preferences.setDefault(COMPILER_PB_UNREACHABLE_CODE, ERROR);
2903 optionNames.add(COMPILER_PB_UNREACHABLE_CODE);
2905 preferences.setDefault(COMPILER_PB_INVALID_IMPORT, ERROR);
2906 optionNames.add(COMPILER_PB_INVALID_IMPORT);
2908 preferences.setDefault(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD,
2910 optionNames.add(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD);
2912 preferences.setDefault(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME,
2914 optionNames.add(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME);
2916 preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING);
2917 optionNames.add(COMPILER_PB_DEPRECATION);
2919 preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE,
2921 optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE);
2923 preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING);
2924 optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK);
2926 preferences.setDefault(COMPILER_PB_UNUSED_LOCAL, IGNORE);
2927 optionNames.add(COMPILER_PB_UNUSED_LOCAL);
2929 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE);
2930 optionNames.add(COMPILER_PB_UNUSED_PARAMETER);
2932 preferences.setDefault(
2933 COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT,
2936 .add(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT);
2940 COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE,
2942 optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE);
2944 preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING);
2945 optionNames.add(COMPILER_PB_UNUSED_IMPORT);
2947 preferences.setDefault(COMPILER_PB_UNUSED_PRIVATE_MEMBER, IGNORE);
2948 optionNames.add(COMPILER_PB_UNUSED_PRIVATE_MEMBER);
2950 preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE);
2951 optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION);
2953 preferences.setDefault(COMPILER_PB_NON_NLS_STRING_LITERAL, IGNORE);
2954 optionNames.add(COMPILER_PB_NON_NLS_STRING_LITERAL);
2956 preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE);
2957 optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER);
2959 preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING);
2960 optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER);
2962 preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING);
2963 optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT);
2965 preferences.setDefault(
2966 COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD,
2969 .add(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD);
2971 preferences.setDefault(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION,
2973 optionNames.add(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION);
2975 preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAG); //$NON-NLS-1$
2976 optionNames.add(COMPILER_TASK_TAGS);
2978 preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITY); //$NON-NLS-1$
2979 optionNames.add(COMPILER_TASK_PRIORITIES);
2981 preferences.setDefault(COMPILER_SOURCE, VERSION_1_3);
2982 optionNames.add(COMPILER_SOURCE);
2984 preferences.setDefault(COMPILER_COMPLIANCE, VERSION_1_3);
2985 optionNames.add(COMPILER_COMPLIANCE);
2987 preferences.setDefault(COMPILER_PB_MAX_PER_UNIT, "100"); //$NON-NLS-1$
2988 optionNames.add(COMPILER_PB_MAX_PER_UNIT);
2991 preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
2992 optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
2994 preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT);
2995 optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH);
2997 preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING);
2998 optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE);
3000 preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN);
3001 optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER);
3003 // JavaCore settings
3004 preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE);
3005 optionNames.add(CORE_JAVA_BUILD_ORDER);
3007 preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR);
3008 optionNames.add(CORE_CIRCULAR_CLASSPATH);
3010 preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR);
3011 optionNames.add(CORE_INCOMPLETE_CLASSPATH);
3013 preferences.setDefault(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS,
3015 optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS);
3017 preferences.setDefault(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS,
3019 optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS);
3021 // encoding setting comes from resource plug-in
3022 optionNames.add(CORE_ENCODING);
3024 // Formatter settings
3025 preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT);
3026 optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE);
3028 preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT);
3029 optionNames.add(FORMATTER_NEWLINE_CONTROL);
3031 preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE);
3032 optionNames.add(FORMATTER_CLEAR_BLANK_LINES);
3034 preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT);
3035 optionNames.add(FORMATTER_NEWLINE_ELSE_IF);
3037 preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT);
3038 optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK);
3040 preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$
3041 optionNames.add(FORMATTER_LINE_SPLIT);
3043 preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL);
3044 optionNames.add(FORMATTER_COMPACT_ASSIGNMENT);
3046 preferences.setDefault(FORMATTER_TAB_CHAR, TAB);
3047 optionNames.add(FORMATTER_TAB_CHAR);
3049 preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$
3050 optionNames.add(FORMATTER_TAB_SIZE);
3052 preferences.setDefault(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$
3053 optionNames.add(FORMATTER_SPACE_CASTEXPRESSION);
3055 // CodeAssist settings
3056 preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$
3057 optionNames.add(CODEASSIST_VISIBILITY_CHECK);
3059 preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$
3060 optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION);
3062 preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
3063 optionNames.add(CODEASSIST_FIELD_PREFIXES);
3065 preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
3066 optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES);
3068 preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
3069 optionNames.add(CODEASSIST_LOCAL_PREFIXES);
3071 preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
3072 optionNames.add(CODEASSIST_ARGUMENT_PREFIXES);
3074 preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3075 optionNames.add(CODEASSIST_FIELD_SUFFIXES);
3077 preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3078 optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES);
3080 preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
3081 optionNames.add(CODEASSIST_LOCAL_SUFFIXES);
3083 preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
3084 optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES);
3088 * Returns whether the given marker references the given Java element. Used
3089 * for markers, which denote a Java element rather than a resource.
3095 * @return <code>true</code> if the marker references the element, false
3097 * @exception CoreException
3098 * if the <code>IMarker.getAttribute</code> on the marker
3101 public static boolean isReferencedBy(IJavaElement element, IMarker marker)
3102 throws CoreException {
3104 // only match units or classfiles
3105 if (element instanceof IMember) {
3106 IMember member = (IMember) element;
3107 if (member.isBinary()) {
3108 element = null; //member.getClassFile();
3110 element = member.getCompilationUnit();
3113 if (element == null)
3118 String markerHandleId = (String) marker.getAttribute(ATT_HANDLE_ID);
3119 if (markerHandleId == null)
3122 IJavaElement markerElement = JavaCore.create(markerHandleId);
3124 if (element.equals(markerElement))
3125 return true; // external elements may still be equal with different
3128 // cycle through enclosing types in case marker is associated with a
3129 // classfile (15568)
3130 // if (markerElement instanceof IClassFile){
3131 // IType enclosingType =
3132 // ((IClassFile)markerElement).getType().getDeclaringType();
3133 // if (enclosingType != null){
3134 // markerElement = enclosingType.getClassFile(); // retry with immediate
3135 // enclosing classfile
3145 * Returns whether the given marker delta references the given Java element.
3146 * Used for markers deltas, which denote a Java element rather than a
3151 * @param markerDelta
3153 * @return <code>true</code> if the marker delta references the element
3154 * @exception CoreException
3155 * if the <code>IMarkerDelta.getAttribute</code> on the
3156 * marker delta fails
3158 public static boolean isReferencedBy(IJavaElement element,
3159 IMarkerDelta markerDelta) throws CoreException {
3161 // only match units or classfiles
3162 if (element instanceof IMember) {
3163 IMember member = (IMember) element;
3164 if (member.isBinary()) {
3165 element = null; //member.getClassFile();
3167 element = member.getCompilationUnit();
3170 if (element == null)
3172 if (markerDelta == null)
3175 String markerDeltarHandleId = (String) markerDelta
3176 .getAttribute(ATT_HANDLE_ID);
3177 if (markerDeltarHandleId == null)
3180 IJavaElement markerElement = JavaCore.create(markerDeltarHandleId);
3182 if (element.equals(markerElement))
3183 return true; // external elements may still be equal with different
3186 // cycle through enclosing types in case marker is associated with a
3187 // classfile (15568)
3188 // if (markerElement instanceof IClassFile){
3189 // IType enclosingType =
3190 // ((IClassFile)markerElement).getType().getDeclaringType();
3191 // if (enclosingType != null){
3192 // markerElement = enclosingType.getClassFile(); // retry with immediate
3193 // enclosing classfile
3203 * Creates and returns a new classpath entry of kind
3204 * <code>CPE_CONTAINER</code> for the given path. The path of the
3205 * container will be used during resolution so as to map this container
3206 * entry to a set of other classpath entries the container is acting for.
3208 * A container entry allows to express indirect references to a set of
3209 * libraries, projects and variable entries, which can be interpreted
3210 * differently for each Java project where it is used. A classpath container
3211 * entry can be resolved using
3212 * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3213 * <code>JavaCore.classpathContainerChanged</code>
3215 * A container is exclusively resolved by a
3216 * <code>ClasspathContainerInitializer</code> registered onto the
3217 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3219 * A container path must be formed of at least one segment, where:
3221 * <li>the first segment is a unique ID identifying the target container,
3222 * there must be a container initializer registered onto this ID through the
3223 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3225 * <li>the remaining segments will be passed onto the initializer, and can
3226 * be used as additional hints during the initialization phase.</li>
3229 * Example of an ClasspathContainerInitializer for a classpath container
3230 * denoting a default JDK container:
3232 * containerEntry = JavaCore.newContainerEntry(new
3233 * Path("MyProvidedJDK/default"));
3235 * <extension point="org.eclipse.jdt.core.classpathContainerInitializer">
3236 * <containerInitializer id="MyProvidedJDK"
3237 * class="com.example.MyInitializer"/>
3239 * Note that this operation does not attempt to validate classpath
3240 * containers or access the resources at the given paths.
3242 * The resulting entry is not exported to dependent projects. This method is
3243 * equivalent to <code>newContainerEntry(-,false)</code>.
3246 * @param containerPath
3247 * the path identifying the container, it must be formed of two
3249 * @return a new container classpath entry
3251 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3252 * @see JavaCore#newContainerEntry(IPath, boolean)
3255 public static IClasspathEntry newContainerEntry(IPath containerPath) {
3257 return newContainerEntry(containerPath, false);
3261 * Creates and returns a new classpath entry of kind
3262 * <code>CPE_CONTAINER</code> for the given path. The path of the
3263 * container will be used during resolution so as to map this container
3264 * entry to a set of other classpath entries the container is acting for.
3266 * A container entry allows to express indirect references to a set of
3267 * libraries, projects and variable entries, which can be interpreted
3268 * differently for each Java project where it is used. A classpath container
3269 * entry can be resolved using
3270 * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3271 * <code>JavaCore.classpathContainerChanged</code>
3273 * A container is exclusively resolved by a
3274 * <code>ClasspathContainerInitializer</code> registered onto the
3275 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3277 * A container path must be formed of at least one segment, where:
3279 * <li>the first segment is a unique ID identifying the target container,
3280 * there must be a container initializer registered onto this ID through the
3281 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3283 * <li>the remaining segments will be passed onto the initializer, and can
3284 * be used as additional hints during the initialization phase.</li>
3287 * Example of an ClasspathContainerInitializer for a classpath container
3288 * denoting a default JDK container:
3290 * containerEntry = JavaCore.newContainerEntry(new
3291 * Path("MyProvidedJDK/default"));
3293 * <extension point="org.eclipse.jdt.core.classpathContainerInitializer">
3294 * <containerInitializer id="MyProvidedJDK"
3295 * class="com.example.MyInitializer"/>
3297 * Note that this operation does not attempt to validate classpath
3298 * containers or access the resources at the given paths.
3301 * @param containerPath
3302 * the path identifying the container, it must be formed of at
3303 * least one segment (ID+hints)
3305 * a boolean indicating whether this entry is contributed to
3306 * dependent projects in addition to the output location
3307 * @return a new container classpath entry
3309 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3310 * @see JavaCore#setClasspathContainer(IPath, IJavaProject[],
3311 * IClasspathContainer[], IProgressMonitor)
3312 * @see JavaCore#newContainerEntry(IPath, boolean)
3315 public static IClasspathEntry newContainerEntry(IPath containerPath,
3316 boolean isExported) {
3318 if (containerPath == null || containerPath.segmentCount() < 1) {
3322 "Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$
3324 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3325 IClasspathEntry.CPE_CONTAINER, containerPath,
3326 ClasspathEntry.NO_EXCLUSION_PATTERNS, null, // source attachment
3327 null, // source attachment root
3328 null, // specific output folder
3333 * Creates and returns a new non-exported classpath entry of kind
3334 * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3335 * absolute path. This specifies that all package fragments within the root
3336 * will have children of type <code>IClassFile</code>.
3338 * A library entry is used to denote a prerequisite JAR or root folder
3339 * containing binaries. The target JAR or folder can either be defined
3340 * internally to the workspace (absolute path relative to the workspace
3341 * root) or externally to the workspace (absolute path in the file system).
3343 * e.g. Here are some examples of binary path usage
3345 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3347 * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3349 * <li><code> "c:/classes/" </code>- reference to an external binary
3352 * Note that this operation does not attempt to validate or access the
3353 * resources at the given paths.
3355 * The resulting entry is not exported to dependent projects. This method is
3356 * equivalent to <code>newLibraryEntry(-,-,-,false)</code>.
3360 * the absolute path of the binary archive
3361 * @param sourceAttachmentPath
3362 * the absolute path of the corresponding source archive or
3363 * folder, or <code>null</code> if none
3364 * @param sourceAttachmentRootPath
3365 * the location of the root within the source archive or folder
3366 * or <code>null</code> if this location should be
3367 * automatically detected.
3368 * @return a new library classpath entry
3370 * @see #newLibraryEntry(IPath, IPath, IPath, boolean)
3372 //public static IClasspathEntry newLibraryEntry(
3374 // IPath sourceAttachmentPath,
3375 // IPath sourceAttachmentRootPath) {
3377 // return newLibraryEntry(path, sourceAttachmentPath,
3378 // sourceAttachmentRootPath, false);
3381 * Creates and returns a new classpath entry of kind
3382 * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3383 * absolute path. This specifies that all package fragments within the root
3384 * will have children of type <code>IClassFile</code>.
3386 * A library entry is used to denote a prerequisite JAR or root folder
3387 * containing binaries. The target JAR or folder can either be defined
3388 * internally to the workspace (absolute path relative to the workspace
3389 * root) or externally to the workspace (absolute path in the file system).
3391 * e.g. Here are some examples of binary path usage
3393 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3395 * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3397 * <li><code> "c:/classes/" </code>- reference to an external binary
3400 * Note that this operation does not attempt to validate or access the
3401 * resources at the given paths.
3405 * the absolute path of the binary archive
3406 * @param sourceAttachmentPath
3407 * the absolute path of the corresponding source archive or
3408 * folder, or <code>null</code> if none
3409 * @param sourceAttachmentRootPath
3410 * the location of the root within the source archive or folder
3411 * or <code>null</code> if this location should be
3412 * automatically detected.
3414 * indicates whether this entry is contributed to dependent
3415 * projects in addition to the output location
3416 * @return a new library classpath entry
3419 //public static IClasspathEntry newLibraryEntry(
3421 // IPath sourceAttachmentPath,
3422 // IPath sourceAttachmentRootPath,
3423 // boolean isExported) {
3425 // if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry
3426 // must be absolute"); //$NON-NLS-1$
3428 // return new ClasspathEntry(
3429 // IPackageFragmentRoot.K_BINARY,
3430 // IClasspathEntry.CPE_LIBRARY,
3431 // JavaProject.canonicalizedPath(path),
3432 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3433 // sourceAttachmentPath,
3434 // sourceAttachmentRootPath,
3435 // null, // specific output folder
3439 * Creates and returns a new non-exported classpath entry of kind
3440 * <code>CPE_PROJECT</code> for the project identified by the given
3443 * A project entry is used to denote a prerequisite project on a classpath.
3444 * The referenced project will be contributed as a whole, either as sources
3445 * (in the Java Model, it contributes all its package fragment roots) or as
3446 * binaries (when building, it contributes its whole output location).
3448 * A project reference allows to indirect through another project,
3449 * independently from its internal layout.
3451 * The prerequisite project is referred to using an absolute path relative
3452 * to the workspace root.
3454 * The resulting entry is not exported to dependent projects. This method is
3455 * equivalent to <code>newProjectEntry(_,false)</code>.
3459 * the absolute path of the binary archive
3460 * @return a new project classpath entry
3462 * @see JavaCore#newProjectEntry(IPath, boolean)
3464 public static IClasspathEntry newProjectEntry(IPath path) {
3465 return newProjectEntry(path, false);
3469 * Creates and returns a new classpath entry of kind
3470 * <code>CPE_PROJECT</code> for the project identified by the given
3473 * A project entry is used to denote a prerequisite project on a classpath.
3474 * The referenced project will be contributed as a whole, either as sources
3475 * (in the Java Model, it contributes all its package fragment roots) or as
3476 * binaries (when building, it contributes its whole output location).
3478 * A project reference allows to indirect through another project,
3479 * independently from its internal layout.
3481 * The prerequisite project is referred to using an absolute path relative
3482 * to the workspace root.
3486 * the absolute path of the prerequisite project
3488 * indicates whether this entry is contributed to dependent
3489 * projects in addition to the output location
3490 * @return a new project classpath entry
3493 public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) {
3495 if (!path.isAbsolute())
3496 Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3498 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3499 IClasspathEntry.CPE_PROJECT, path,
3500 ClasspathEntry.NO_EXCLUSION_PATTERNS, null, // source attachment
3501 null, // source attachment root
3502 null, // specific output folder
3507 * Returns a new empty region.
3509 * @return a new empty region
3511 public static IRegion newRegion() {
3512 return new Region();
3516 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3517 * for the project's source folder identified by the given absolute
3518 * workspace-relative path. This specifies that all package fragments within
3519 * the root will have children of type <code>ICompilationUnit</code>.
3521 * The source folder is referred to using an absolute path relative to the
3522 * workspace root, e.g. <code>/Project/src</code>. A project's source
3523 * folders are located with that project. That is, a source classpath entry
3524 * specifying the path <code>/P1/src</code> is only usable for project
3528 * The source classpath entry created by this method includes all source
3529 * files below the given workspace-relative path. To selectively exclude
3530 * some of these source files, use the factory method
3531 * <code>JavaCore.newSourceEntry(IPath,IPath[])</code> instead.
3534 * Note that all sources/binaries inside a project are contributed as a
3535 * whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
3536 * Particular source entries cannot be selectively exported.
3540 * the absolute workspace-relative path of a source folder
3541 * @return a new source classpath entry with not exclusion patterns
3543 * @see #newSourceEntry(org.eclipse.core.runtime.IPath,org.eclipse.core.runtime.IPath[])
3545 public static IClasspathEntry newSourceEntry(IPath path) {
3547 return newSourceEntry(path, ClasspathEntry.NO_EXCLUSION_PATTERNS, null /*
3554 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3555 * for the project's source folder identified by the given absolute
3556 * workspace-relative path but excluding all source files with paths
3557 * matching any of the given patterns. This specifies that all package
3558 * fragments within the root will have children of type
3559 * <code>ICompilationUnit</code>.
3561 * The source folder is referred to using an absolute path relative to the
3562 * workspace root, e.g. <code>/Project/src</code>. A project's source
3563 * folders are located with that project. That is, a source classpath entry
3564 * specifying the path <code>/P1/src</code> is only usable for project
3568 * The source classpath entry created by this method includes all source
3569 * files below the given workspace-relative path except for those matched by
3570 * one (or more) of the given exclusion patterns. Each exclusion pattern is
3571 * represented by a relative path, which is interpreted as relative to the
3572 * source folder. For example, if the source folder path is
3573 * <code>/Project/src</code> and the exclusion pattern is
3574 * <code>com/xyz/tests/**</code>, then source files like
3575 * <code>/Project/src/com/xyz/Foo.java</code> and
3576 * <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3577 * whereas <code>/Project/src/com/xyz/tests/T1.java</code> and
3578 * <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3579 * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
3580 * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code> for
3581 * the full description of the syntax and semantics of exclusion patterns.
3583 * If the empty list of exclusion patterns is specified, the source folder
3584 * will automatically include all resources located inside the source
3585 * folder. In that case, the result is entirely equivalent to using the
3586 * factory method <code>JavaCore.newSourceEntry(IPath)</code>.
3589 * Note that all sources/binaries inside a project are contributed as a
3590 * whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
3591 * Particular source entries cannot be selectively exported.
3595 * the absolute workspace-relative path of a source folder
3596 * @param exclusionPatterns
3597 * the possibly empty list of exclusion patterns represented as
3599 * @return a new source classpath entry with the given exclusion patterns
3600 * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
3601 * @see IClasspathEntry#getExclusionPatterns
3605 public static IClasspathEntry newSourceEntry(IPath path,
3606 IPath[] exclusionPatterns) {
3608 return newSourceEntry(path, exclusionPatterns, null /* output location */);
3612 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3613 * for the project's source folder identified by the given absolute
3614 * workspace-relative path but excluding all source files with paths
3615 * matching any of the given patterns, and associated with a specific output
3616 * location (that is, ".class" files are not going to the project default
3617 * output location). All package fragments within the root will have
3618 * children of type <code>ICompilationUnit</code>.
3620 * The source folder is referred to using an absolute path relative to the
3621 * workspace root, e.g. <code>/Project/src</code>. A project's source
3622 * folders are located with that project. That is, a source classpath entry
3623 * specifying the path <code>/P1/src</code> is only usable for project
3627 * The source classpath entry created by this method includes all source
3628 * files below the given workspace-relative path except for those matched by
3629 * one (or more) of the given exclusion patterns. Each exclusion pattern is
3630 * represented by a relative path, which is interpreted as relative to the
3631 * source folder. For example, if the source folder path is
3632 * <code>/Project/src</code> and the exclusion pattern is
3633 * <code>com/xyz/tests/**</code>, then source files like
3634 * <code>/Project/src/com/xyz/Foo.java</code> and
3635 * <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3636 * whereas <code>/Project/src/com/xyz/tests/T1.java</code> and
3637 * <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3638 * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
3639 * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code> for
3640 * the full description of the syntax and semantics of exclusion patterns.
3642 * If the empty list of exclusion patterns is specified, the source folder
3643 * will automatically include all resources located inside the source
3644 * folder. In that case, the result is entirely equivalent to using the
3645 * factory method <code>JavaCore.newSourceEntry(IPath)</code>.
3648 * Additionally, a source entry can be associated with a specific output
3649 * location. By doing so, the Java builder will ensure that the generated
3650 * ".class" files will be issued inside this output location, as opposed to
3651 * be generated into the project default output location (when output
3652 * location is <code>null</code>). Note that multiple source entries may
3653 * target the same output location. The output location is referred to using
3654 * an absolute path relative to the workspace root, e.g.
3655 * <code>"/Project/bin"</code>, it must be located inside the same
3656 * project as the source folder.
3659 * Also note that all sources/binaries inside a project are contributed as a
3660 * whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
3661 * Particular source entries cannot be selectively exported.
3665 * the absolute workspace-relative path of a source folder
3666 * @param exclusionPatterns
3667 * the possibly empty list of exclusion patterns represented as
3669 * @param outputLocation
3670 * the specific output location for this source entry (
3671 * <code>null</code> if using project default ouput location)
3672 * @return a new source classpath entry with the given exclusion patterns
3673 * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
3674 * @see IClasspathEntry#getExclusionPatterns
3675 * @see IClasspathEntry#getOutputLocation()
3679 public static IClasspathEntry newSourceEntry(IPath path,
3680 IPath[] exclusionPatterns, IPath specificOutputLocation) {
3682 if (!path.isAbsolute())
3683 Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3684 if (exclusionPatterns == null)
3685 Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$
3687 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3688 IClasspathEntry.CPE_SOURCE, path, exclusionPatterns, null, // source
3690 null, // source attachment root
3691 specificOutputLocation, // custom output location
3696 * Creates and returns a new non-exported classpath entry of kind
3697 * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3698 * path is the name of a classpath variable. The trailing segments of the
3699 * path will be appended to resolved variable path.
3701 * A variable entry allows to express indirect references on a classpath to
3702 * other projects or libraries, depending on what the classpath variable is
3705 * It is possible to register an automatic initializer (
3706 * <code>ClasspathVariableInitializer</code>), which will be invoked
3707 * through the extension point
3708 * "org.eclipse.jdt.core.classpathVariableInitializer". After resolution, a
3709 * classpath variable entry may either correspond to a project or a library
3712 * e.g. Here are some examples of variable path usage
3714 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3715 * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3716 * library "c:\jars\jdtcore.jar"</li>
3717 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3718 * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3719 * "/Project_JDTCORE"</li>
3720 * <li>"PLUGINS/com.example/example.jar" where variable
3721 * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3722 * classpath entry is denoting the library
3723 * "c:/eclipse/plugins/com.example/example.jar"</li>
3725 * Note that this operation does not attempt to validate classpath variables
3726 * or access the resources at the given paths.
3728 * The resulting entry is not exported to dependent projects. This method is
3729 * equivalent to <code>newVariableEntry(-,-,-,false)</code>.
3732 * @param variablePath
3733 * the path of the binary archive; first segment is the name of a
3734 * classpath variable
3735 * @param variableSourceAttachmentPath
3736 * the path of the corresponding source archive, or
3737 * <code>null</code> if none; if present, the first segment is
3738 * the name of a classpath variable (not necessarily the same
3739 * variable as the one that begins <code>variablePath</code>)
3740 * @param sourceAttachmentRootPath
3741 * the location of the root within the source archive or
3742 * <code>null</code> if <code>archivePath</code> is also
3744 * @return a new library classpath entry
3746 * @see JavaCore#newVariableEntry(IPath, IPath, IPath, boolean)
3748 //public static IClasspathEntry newVariableEntry(
3749 // IPath variablePath,
3750 // IPath variableSourceAttachmentPath,
3751 // IPath sourceAttachmentRootPath) {
3753 // return newVariableEntry(variablePath, variableSourceAttachmentPath,
3754 // sourceAttachmentRootPath, false);
3757 * Creates and returns a new non-exported classpath entry of kind
3758 * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3759 * path is the name of a classpath variable. The trailing segments of the
3760 * path will be appended to resolved variable path.
3762 * A variable entry allows to express indirect references on a classpath to
3763 * other projects or libraries, depending on what the classpath variable is
3766 * It is possible to register an automatic initializer (
3767 * <code>ClasspathVariableInitializer</code>), which will be invoked
3768 * through the extension point
3769 * "org.eclipse.jdt.core.classpathVariableInitializer". After resolution, a
3770 * classpath variable entry may either correspond to a project or a library
3773 * e.g. Here are some examples of variable path usage
3775 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3776 * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3777 * library "c:\jars\jdtcore.jar"</li>
3778 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3779 * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3780 * "/Project_JDTCORE"</li>
3781 * <li>"PLUGINS/com.example/example.jar" where variable
3782 * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3783 * classpath entry is denoting the library
3784 * "c:/eclipse/plugins/com.example/example.jar"</li>
3786 * Note that this operation does not attempt to validate classpath variables
3787 * or access the resources at the given paths.
3790 * @param variablePath
3791 * the path of the binary archive; first segment is the name of a
3792 * classpath variable
3793 * @param variableSourceAttachmentPath
3794 * the path of the corresponding source archive, or
3795 * <code>null</code> if none; if present, the first segment is
3796 * the name of a classpath variable (not necessarily the same
3797 * variable as the one that begins <code>variablePath</code>)
3798 * @param sourceAttachmentRootPath
3799 * the location of the root within the source archive or
3800 * <code>null</code> if <code>archivePath</code> is also
3803 * indicates whether this entry is contributed to dependent
3804 * projects in addition to the output location
3805 * @return a new variable classpath entry
3808 //public static IClasspathEntry newVariableEntry(
3809 // IPath variablePath,
3810 // IPath variableSourceAttachmentPath,
3811 // IPath variableSourceAttachmentRootPath,
3812 // boolean isExported) {
3814 // if (variablePath == null || variablePath.segmentCount() < 1) {
3817 // "Illegal classpath variable path: \'" +
3818 // variablePath.makeRelative().toString() + "\', must have at least one
3819 // segment"); //$NON-NLS-1$//$NON-NLS-2$
3822 // return new ClasspathEntry(
3823 // IPackageFragmentRoot.K_SOURCE,
3824 // IClasspathEntry.CPE_VARIABLE,
3826 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3827 // variableSourceAttachmentPath, // source attachment
3828 // variableSourceAttachmentRootPath, // source attachment root
3829 // null, // specific output folder
3833 * Removed the given classpath variable. Does nothing if no value was set
3834 * for this classpath variable.
3836 * This functionality cannot be used while the resource tree is locked.
3838 * Classpath variable values are persisted locally to the workspace, and are
3839 * preserved from session to session.
3842 * @param variableName
3843 * the name of the classpath variable
3844 * @see #setClasspathVariable
3846 * @deprecated - use version with extra IProgressMonitor
3848 //public static void removeClasspathVariable(String variableName) {
3849 // removeClasspathVariable(variableName, null);
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
3864 * the progress monitor to report progress
3865 * @see #setClasspathVariable
3867 //public static void removeClasspathVariable(
3868 // String variableName,
3869 // IProgressMonitor monitor) {
3872 // updateVariableValues(new String[]{ variableName}, new IPath[]{ null },
3874 // } catch (JavaModelException e) {
3878 * Removes the given element changed listener. Has no affect if an identical
3879 * listener is not registered.
3884 public static void removeElementChangedListener(
3885 IElementChangedListener listener) {
3886 JavaModelManager.getJavaModelManager().removeElementChangedListener(
3891 * Bind a container reference path to some actual containers (
3892 * <code>IClasspathContainer</code>). This API must be invoked whenever
3893 * changes in container need to be reflected onto the JavaModel. Containers
3894 * can have distinct values in different projects, therefore this API
3895 * considers a set of projects with their respective containers.
3897 * <code>containerPath</code> is the path under which these values can be
3898 * referenced through container classpath entries (
3899 * <code>IClasspathEntry#CPE_CONTAINER</code>). A container path is
3900 * formed by a first ID segment followed with extra segments, which can be
3901 * used as additional hints for the resolution. The container ID is used to
3902 * identify a <code>ClasspathContainerInitializer</code> registered on the
3903 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3905 * There is no assumption that each individual container value passed in
3906 * argument (<code>respectiveContainers</code>) must answer the exact
3907 * same path when requested <code>IClasspathContainer#getPath</code>.
3908 * Indeed, the containerPath is just an indication for resolving it to an
3909 * actual container object. It can be delegated to a
3910 * <code>ClasspathContainerInitializer</code>, which can be activated
3911 * through the extension point
3912 * "org.eclipse.jdt.core.ClasspathContainerInitializer").
3914 * In reaction to changing container values, the JavaModel will be updated
3915 * to reflect the new state of the updated container.
3917 * This functionality cannot be used while the resource tree is locked.
3919 * Classpath container values are persisted locally to the workspace, but
3920 * are not preserved from a session to another. It is thus highly
3921 * recommended to register a <code>ClasspathContainerInitializer</code>
3922 * for each referenced container (through the extension point
3923 * "org.eclipse.jdt.core.ClasspathContainerInitializer").
3925 * Note: setting a container to <code>null</code> will cause it to be
3926 * lazily resolved again whenever its value is required. In particular, this
3927 * will cause a registered initializer to be invoked again.
3930 * @param containerPath -
3931 * the name of the container reference, which is being updated
3932 * @param affectedProjects -
3933 * the set of projects for which this container is being bound
3934 * @param respectiveContainers -
3935 * the set of respective containers for the affected projects
3937 * a monitor to report progress
3939 * @see ClasspathContainerInitializer
3940 * @see #getClasspathContainer(IPath, IJavaProject)
3941 * @see IClasspathContainer
3944 //public static void setClasspathContainer(final IPath containerPath,
3945 // IJavaProject[] affectedProjects, IClasspathContainer[]
3946 // respectiveContainers, IProgressMonitor monitor) throws JavaModelException
3949 // if (affectedProjects.length != respectiveContainers.length)
3950 // Assert.isTrue(false, "Projects and containers collections should have the
3951 // same size"); //$NON-NLS-1$
3953 // if (monitor != null && monitor.isCanceled()) return;
3955 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3956 // System.out.println("CPContainer SET - setting container:
3957 // ["+containerPath+"] for projects: {" //$NON-NLS-1$ //$NON-NLS-2$
3958 // + (Util.toString(affectedProjects,
3959 // new Util.Displayable(){
3960 // public String displayString(Object o) { return ((IJavaProject)
3961 // o).getElementName(); }
3963 // + "} with values: " //$NON-NLS-1$
3964 // + (Util.toString(respectiveContainers,
3965 // new Util.Displayable(){
3966 // public String displayString(Object o) { return ((IClasspathContainer)
3967 // o).getDescription(); }
3972 // final int projectLength = affectedProjects.length;
3973 // final IJavaProject[] modifiedProjects;
3974 // System.arraycopy(affectedProjects, 0, modifiedProjects = new
3975 // IJavaProject[projectLength], 0, projectLength);
3976 // final IClasspathEntry[][] oldResolvedPaths = new
3977 // IClasspathEntry[projectLength][];
3979 // // filter out unmodified project containers
3980 // int remaining = 0;
3981 // for (int i = 0; i < projectLength; i++){
3983 // if (monitor != null && monitor.isCanceled()) return;
3985 // IJavaProject affectedProject = affectedProjects[i];
3986 // IClasspathContainer newContainer = respectiveContainers[i];
3987 // if (newContainer == null) newContainer =
3988 // JavaModelManager.ContainerInitializationInProgress; // 30920 - prevent
3990 // boolean found = false;
3991 // if (JavaProject.hasJavaNature(affectedProject.getProject())){
3992 // IClasspathEntry[] rawClasspath = affectedProject.getRawClasspath();
3993 // for (int j = 0, cpLength = rawClasspath.length; j <cpLength; j++) {
3994 // IClasspathEntry entry = rawClasspath[j];
3995 // if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER &&
3996 // entry.getPath().equals(containerPath)){
4003 // modifiedProjects[i] = null; // filter out this project - does not
4004 // reference the container path, or isnt't yet Java project
4005 // JavaModelManager.containerPut(affectedProject, containerPath,
4009 // IClasspathContainer oldContainer =
4010 // JavaModelManager.containerGet(affectedProject, containerPath);
4011 // if (oldContainer == JavaModelManager.ContainerInitializationInProgress) {
4012 // Map previousContainerValues =
4013 // (Map)JavaModelManager.PreviousSessionContainers.get(affectedProject);
4014 // if (previousContainerValues != null){
4015 // IClasspathContainer previousContainer =
4016 // (IClasspathContainer)previousContainerValues.get(containerPath);
4017 // if (previousContainer != null) {
4018 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4019 // System.out.println("CPContainer INIT - reentering access to project
4020 // container: ["+affectedProject.getElementName()+"] " + containerPath + "
4021 // during its initialization, will see previous value: "+
4022 // previousContainer.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
4025 // JavaModelManager.containerPut(affectedProject, containerPath,
4026 // previousContainer);
4028 // oldContainer = null; //33695 - cannot filter out restored container, must
4029 // update affected project to reset cached CP
4031 // oldContainer = null;
4034 // if (oldContainer != null &&
4035 // oldContainer.equals(respectiveContainers[i])){// TODO: could improve to
4036 // only compare entries
4037 // modifiedProjects[i] = null; // filter out this project - container did
4042 // oldResolvedPaths[i] = affectedProject.getResolvedClasspath(true);
4043 // JavaModelManager.containerPut(affectedProject, containerPath,
4047 // if (remaining == 0) return;
4049 // // trigger model refresh
4051 // JavaCore.run(new IWorkspaceRunnable() {
4052 // public void run(IProgressMonitor monitor) throws CoreException {
4053 // for(int i = 0; i < projectLength; i++){
4055 // if (monitor != null && monitor.isCanceled()) return;
4057 // JavaProject affectedProject = (JavaProject)modifiedProjects[i];
4058 // if (affectedProject == null) continue; // was filtered out
4060 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4061 // System.out.println("CPContainer SET - updating affected project:
4062 // ["+affectedProject.getElementName()+"] due to setting container: " +
4063 // containerPath); //$NON-NLS-1$ //$NON-NLS-2$
4066 // // force a refresh of the affected project (will compute deltas)
4067 // affectedProject.setRawClasspath(
4068 // affectedProject.getRawClasspath(),
4069 // SetClasspathOperation.ReuseOutputLocation,
4071 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can save resources
4072 // oldResolvedPaths[i],
4073 // false, // updating - no validation
4074 // false); // updating - no need to save
4079 // } catch(CoreException e) {
4080 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4081 // System.out.println("CPContainer SET - FAILED DUE TO EXCEPTION:
4082 // "+containerPath); //$NON-NLS-1$
4083 // e.printStackTrace();
4085 // if (e instanceof JavaModelException) {
4086 // throw (JavaModelException)e;
4088 // throw new JavaModelException(e);
4091 // for (int i = 0; i < projectLength; i++) {
4092 // if (respectiveContainers[i] == null) {
4093 // JavaModelManager.containerPut(affectedProjects[i], containerPath, null);
4094 // // reset init in progress marker
4101 * Sets the value of the given classpath variable. The path must have at
4102 * least one segment.
4104 * This functionality cannot be used while the resource tree is locked.
4106 * Classpath variable values are persisted locally to the workspace, and are
4107 * preserved from session to session.
4110 * @param variableName
4111 * the name of the classpath variable
4114 * @see #getClasspathVariable
4116 * @deprecated - use API with IProgressMonitor
4118 //public static void setClasspathVariable(String variableName, IPath path)
4119 // throws JavaModelException {
4121 // setClasspathVariable(variableName, path, null);
4124 * Sets the value of the given classpath variable. The path must not be
4127 * This functionality cannot be used while the resource tree is locked.
4129 * Classpath variable values are persisted locally to the workspace, and are
4130 * preserved from session to session.
4132 * Updating a variable with the same value has no effect.
4134 * @param variableName
4135 * the name of the classpath variable
4139 * a monitor to report progress
4140 * @see #getClasspathVariable
4142 //public static void setClasspathVariable(
4143 // String variableName,
4145 // IProgressMonitor monitor)
4146 // throws JavaModelException {
4148 // if (path == null) Assert.isTrue(false, "Variable path cannot be null");
4150 // setClasspathVariables(new String[]{variableName}, new IPath[]{ path },
4154 * Sets the values of all the given classpath variables at once. Null paths
4155 * can be used to request corresponding variable removal.
4157 * This functionality cannot be used while the resource tree is locked.
4159 * Classpath variable values are persisted locally to the workspace, and are
4160 * preserved from session to session.
4162 * Updating a variable with the same value has no effect.
4164 * @param variableNames
4165 * an array of names for the updated classpath variables
4167 * an array of path updates for the modified classpath variables
4168 * (null meaning that the corresponding value will be removed
4170 * a monitor to report progress
4171 * @see #getClasspathVariable
4174 //public static void setClasspathVariables(
4175 // String[] variableNames,
4177 // IProgressMonitor monitor)
4178 // throws JavaModelException {
4180 // if (variableNames.length != paths.length) Assert.isTrue(false, "Variable
4181 // names and paths collections should have the same size"); //$NON-NLS-1$
4182 // //TODO: should check that null cannot be used as variable paths
4183 // updateVariableValues(variableNames, paths, monitor);
4186 * (non-Javadoc) Method declared on IExecutableExtension. Record any
4187 * necessary initialization data from the plugin.
4189 public void setInitializationData(IConfigurationElement cfig,
4190 String propertyName, Object data) throws CoreException {
4194 * Sets the current table of options. All and only the options explicitly
4195 * included in the given table are remembered; all previous option settings
4196 * are forgotten, including ones not explicitly mentioned.
4198 * For a complete description of the configurable options, see
4199 * <code>getDefaultOptions</code>.
4203 * the new options (key type: <code>String</code>; value type:
4204 * <code>String</code>), or <code>null</code> to reset all
4205 * options to their default values
4206 * @see JavaCore#getDefaultOptions
4208 public static void setOptions(Hashtable newOptions) {
4210 // see #initializeDefaultPluginPreferences() for changing default
4212 Preferences preferences = getPlugin().getPluginPreferences();
4214 if (newOptions == null) {
4215 newOptions = JavaCore.getDefaultOptions();
4217 Enumeration keys = newOptions.keys();
4218 while (keys.hasMoreElements()) {
4219 String key = (String) keys.nextElement();
4220 if (!JavaModelManager.OptionNames.contains(key))
4221 continue; // unrecognized option
4222 if (key.equals(CORE_ENCODING))
4223 continue; // skipped, contributed by resource prefs
4224 String value = (String) newOptions.get(key);
4225 preferences.setValue(key, value);
4229 getPlugin().savePluginPreferences();
4233 * Shutdown the JavaCore plug-in.
4235 * De-registers the JavaModelManager as a resource changed listener and save
4239 * @see org.eclipse.core.runtime.Plugin#shutdown()
4241 // moved to PHPeclipsePlugin#shutdown()
4242 //public void shutdown() {
4244 // //savePluginPreferences();
4245 // getPlugin().savePluginPreferences();
4246 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4247 // workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaProcessor);
4248 // workspace.removeSaveParticipant(PHPeclipsePlugin.getDefault());
4250 // ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown();
4253 * Initiate the background indexing process. This should be deferred after
4254 * the plugin activation.
4256 //private void startIndexing() {
4258 // JavaModelManager.getJavaModelManager().getIndexManager().reset();
4261 * Startup of the JavaCore plug-in.
4263 * Registers the JavaModelManager as a resource changed listener and save
4264 * participant. Starts the background indexing, and restore saved classpath
4268 * @see org.eclipse.core.runtime.Plugin#startup()
4271 // moved to PHPeclipsePlugin#startup()
4272 //public void startup() {
4274 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
4276 // manager.configurePluginDebugOptions();
4278 // // request state folder creation (workaround 19885)
4279 // JavaCore.getPlugin().getStateLocation();
4281 // // retrieve variable values
4282 // JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4283 // JavaModelManager.PluginPreferencesListener());
4284 //// TODO : jsurfer temp-del
4285 //// manager.loadVariablesAndContainers();
4287 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4288 // workspace.addResourceChangeListener(
4289 // manager.deltaProcessor,
4290 // IResourceChangeEvent.PRE_AUTO_BUILD
4291 // | IResourceChangeEvent.POST_AUTO_BUILD
4292 // | IResourceChangeEvent.POST_CHANGE
4293 // | IResourceChangeEvent.PRE_DELETE
4294 // | IResourceChangeEvent.PRE_CLOSE);
4296 //// startIndexing();
4297 // workspace.addSaveParticipant(PHPeclipsePlugin.getDefault(), manager);
4299 // } catch (CoreException e) {
4300 // } catch (RuntimeException e) {
4301 // manager.shutdown();
4306 * Internal updating of a variable values (null path meaning removal),
4307 * allowing to change multiple variable values at once.
4309 //private static void updateVariableValues(
4310 // String[] variableNames,
4311 // IPath[] variablePaths,
4312 // IProgressMonitor monitor) throws JavaModelException {
4314 // if (monitor != null && monitor.isCanceled()) return;
4316 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4317 // System.out.println("CPVariable SET - setting variables: {" +
4318 // Util.toString(variableNames) //$NON-NLS-1$
4319 // + "} with values: " + Util.toString(variablePaths)); //$NON-NLS-1$
4322 // int varLength = variableNames.length;
4324 // // gather classpath information for updating
4325 // final HashMap affectedProjects = new HashMap(5);
4326 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
4327 // IJavaModel model = manager.getJavaModel();
4329 // // filter out unmodified variables
4330 // int discardCount = 0;
4331 // for (int i = 0; i < varLength; i++){
4332 // String variableName = variableNames[i];
4333 // IPath oldPath = (IPath)JavaModelManager.variableGet(variableName); // if
4334 // reentering will provide previous session value
4335 // if (oldPath == JavaModelManager.VariableInitializationInProgress){
4336 // IPath previousPath =
4337 // (IPath)JavaModelManager.PreviousSessionVariables.get(variableName);
4338 // if (previousPath != null){
4339 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4340 // System.out.println("CPVariable INIT - reentering access to variable: " +
4341 // variableName+ " during its initialization, will see previous value: "+
4342 // previousPath); //$NON-NLS-1$ //$NON-NLS-2$
4344 // JavaModelManager.variablePut(variableName, previousPath); // replace
4345 // value so reentering calls are seeing old value
4347 // oldPath = null; //33695 - cannot filter out restored variable, must
4348 // update affected project to reset cached CP
4350 // if (oldPath != null && oldPath.equals(variablePaths[i])){
4351 // variableNames[i] = null;
4355 // if (discardCount > 0){
4356 // if (discardCount == varLength) return;
4357 // int changedLength = varLength - discardCount;
4358 // String[] changedVariableNames = new String[changedLength];
4359 // IPath[] changedVariablePaths = new IPath[changedLength];
4360 // for (int i = 0, index = 0; i < varLength; i++){
4361 // if (variableNames[i] != null){
4362 // changedVariableNames[index] = variableNames[i];
4363 // changedVariablePaths[index] = variablePaths[i];
4367 // variableNames = changedVariableNames;
4368 // variablePaths = changedVariablePaths;
4369 // varLength = changedLength;
4372 // if (monitor != null && monitor.isCanceled()) return;
4374 // if (model != null) {
4375 // IJavaProject[] projects = model.getJavaProjects();
4376 // nextProject : for (int i = 0, projectLength = projects.length; i <
4377 // projectLength; i++){
4378 // IJavaProject project = projects[i];
4380 // // check to see if any of the modified variables is present on the
4382 // IClasspathEntry[] classpath = project.getRawClasspath();
4383 // for (int j = 0, cpLength = classpath.length; j < cpLength; j++){
4385 // IClasspathEntry entry = classpath[j];
4386 // for (int k = 0; k < varLength; k++){
4388 // String variableName = variableNames[k];
4389 // if (entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE){
4391 // if (variableName.equals(entry.getPath().segment(0))){
4392 // affectedProjects.put(project, project.getResolvedClasspath(true));
4393 // continue nextProject;
4395 // IPath sourcePath, sourceRootPath;
4396 // if (((sourcePath = entry.getSourceAttachmentPath()) != null &&
4397 // variableName.equals(sourcePath.segment(0)))
4398 // || ((sourceRootPath = entry.getSourceAttachmentRootPath()) != null &&
4399 // variableName.equals(sourceRootPath.segment(0)))) {
4401 // affectedProjects.put(project, project.getResolvedClasspath(true));
4402 // continue nextProject;
4409 // // update variables
4410 // for (int i = 0; i < varLength; i++){
4411 // JavaModelManager.variablePut(variableNames[i], variablePaths[i]);
4413 // final String[] dbgVariableNames = variableNames;
4415 // // update affected project classpaths
4416 // if (!affectedProjects.isEmpty()) {
4418 // JavaCore_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt.run(
4419 // new IWorkspaceRunnable() {
4420 // public void run(IProgressMonitor monitor) throws CoreException {
4421 // // propagate classpath change
4422 // Iterator projectsToUpdate = affectedProjects.keySet().iterator();
4423 // while (projectsToUpdate.hasNext()) {
4425 // if (monitor != null && monitor.isCanceled()) return;
4427 // JavaProject project = (JavaProject) projectsToUpdate.next();
4429 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4430 // System.out.println("CPVariable SET - updating affected project:
4431 // ["+project.getElementName()+"] due to setting variables: "+
4432 // Util.toString(dbgVariableNames)); //$NON-NLS-1$ //$NON-NLS-2$
4436 // .setRawClasspath(
4437 // project.getRawClasspath(),
4438 // SetClasspathOperation.ReuseOutputLocation,
4439 // null, // don't call beginTask on the monitor (see
4440 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=3717)
4441 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can change resources
4442 // (IClasspathEntry[]) affectedProjects.get(project),
4443 // false, // updating - no validation
4444 // false); // updating - no need to save
4449 // } catch (CoreException e) {
4450 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4451 // System.out.println("CPVariable SET - FAILED DUE TO EXCEPTION:
4452 // "+Util.toString(dbgVariableNames)); //$NON-NLS-1$
4453 // e.printStackTrace();
4455 // if (e instanceof JavaModelException) {
4456 // throw (JavaModelException)e;
4458 // throw new JavaModelException(e);
4464 * (non-Javadoc) Startup the JavaCore plug-in. <p> Registers the
4465 * JavaModelManager as a resource changed listener and save participant.
4466 * Starts the background indexing, and restore saved classpath variable
4467 * values. <p> @throws Exception
4469 * @see org.eclipse.core.runtime.Plugin#start(BundleContext)
4471 //public static void start(final Plugin plugin, BundleContext context)
4472 // throws Exception {
4473 //// super.start(context);
4475 // final JavaModelManager manager = JavaModelManager.getJavaModelManager();
4477 // manager.configurePluginDebugOptions();
4479 // // request state folder creation (workaround 19885)
4480 // JavaCore.getPlugin().getStateLocation();
4482 // // retrieve variable values
4483 // //JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4484 // JavaModelManager.PluginPreferencesListener());
4485 //// manager.loadVariablesAndContainers();
4487 // final IWorkspace workspace = ResourcesPlugin.getWorkspace();
4488 // workspace.addResourceChangeListener(
4489 // manager.deltaState,
4490 // IResourceChangeEvent.PRE_BUILD
4491 // | IResourceChangeEvent.POST_BUILD
4492 // | IResourceChangeEvent.POST_CHANGE
4493 // | IResourceChangeEvent.PRE_DELETE
4494 // | IResourceChangeEvent.PRE_CLOSE);
4496 //// startIndexing();
4498 // // process deltas since last activated in indexer thread so that indexes
4500 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658
4501 // Job processSavedState = new Job(Util.bind("savedState.jobName")) {
4503 // protected IStatus run(IProgressMonitor monitor) {
4505 // // add save participant and process delta atomically
4506 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59937
4508 // new IWorkspaceRunnable() {
4509 // public void run(IProgressMonitor progress) throws CoreException {
4510 //// ISavedState savedState = workspace.addSaveParticipant(JavaCore.this,
4512 // ISavedState savedState = workspace.addSaveParticipant(plugin, manager);
4513 // if (savedState != null) {
4514 // // the event type coming from the saved state is always POST_AUTO_BUILD
4515 // // force it to be POST_CHANGE so that the delta processor can handle it
4516 // manager.deltaState.getDeltaProcessor().overridenEventType =
4517 // IResourceChangeEvent.POST_CHANGE;
4518 // savedState.processResourceChangeEvents(manager.deltaState);
4523 // } catch (CoreException e) {
4524 // return e.getStatus();
4526 // return Status.OK_STATUS;
4529 // processSavedState.setSystem(true);
4530 // processSavedState.setPriority(Job.SHORT); // process asap
4531 // processSavedState.schedule();
4532 // } catch (RuntimeException e) {
4533 // manager.shutdown();
4538 * (non-Javadoc) Shutdown the JavaCore plug-in. <p> De-registers the
4539 * JavaModelManager as a resource changed listener and save participant. <p>
4541 * @see org.eclipse.core.runtime.Plugin#stop(BundleContext)
4543 // public static void stop(Plugin plugin, BundleContext context)
4544 // throws Exception {
4546 // plugin.savePluginPreferences();
4547 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4548 // workspace.removeResourceChangeListener(JavaModelManager
4549 // .getJavaModelManager().deltaState);
4550 // workspace.removeSaveParticipant(plugin);
4552 // JavaModelManager.getJavaModelManager().shutdown();
4554 // // ensure we call super.stop as the last thing
4555 // // super.stop(context);