1 package net.sourceforge.phpdt.core;
4 import java.util.ArrayList;
5 import java.util.Collection;
6 import java.util.Enumeration;
7 import java.util.HashSet;
8 import java.util.Hashtable;
12 import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
13 import net.sourceforge.phpdt.internal.core.BufferManager;
14 import net.sourceforge.phpdt.internal.core.ClasspathEntry;
15 import net.sourceforge.phpdt.internal.core.JavaModel;
16 import net.sourceforge.phpdt.internal.core.JavaModelManager;
17 import net.sourceforge.phpdt.internal.core.Region;
18 import net.sourceforge.phpdt.internal.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.IResourceChangeListener;
29 import org.eclipse.core.resources.IWorkspaceRoot;
30 import org.eclipse.core.resources.ResourcesPlugin;
31 import org.eclipse.core.runtime.CoreException;
32 import org.eclipse.core.runtime.IConfigurationElement;
33 import org.eclipse.core.runtime.IPath;
34 import org.eclipse.core.runtime.IProgressMonitor;
35 import org.eclipse.core.runtime.Plugin;
36 import org.eclipse.core.runtime.Preferences;
38 public class JavaCore {
40 // public static HashSet OptionNames = new HashSet(20);
42 * The plug-in identifier of the Java core support (value
43 * <code>"net.sourceforge.phpeclipse"</code>)
45 // public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.core";
47 public static final String PLUGIN_ID = PHPeclipsePlugin.PLUGIN_ID;
50 * Possible configurable option ID.
52 * @see #getDefaultOptions
55 public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; //$NON-NLS-1$
58 * Possible configurable option ID.
60 * @see #getDefaultOptions
63 public static final String FORMATTER_NEWLINE_OPENING_BRACE = PLUGIN_ID
64 + ".formatter.newline.openingBrace"; //$NON-NLS-1$
67 * Possible configurable option ID.
69 * @see #getDefaultOptions
72 public static final String FORMATTER_NEWLINE_CONTROL = PLUGIN_ID
73 + ".formatter.newline.controlStatement"; //$NON-NLS-1$
76 * Possible configurable option ID.
78 * @see #getDefaultOptions
81 public static final String FORMATTER_NEWLINE_ELSE_IF = PLUGIN_ID
82 + ".formatter.newline.elseIf"; //$NON-NLS-1$
85 * Possible configurable option ID.
87 * @see #getDefaultOptions
90 public static final String FORMATTER_NEWLINE_EMPTY_BLOCK = PLUGIN_ID
91 + ".formatter.newline.emptyBlock"; //$NON-NLS-1$
94 * Possible configurable option ID.
96 * @see #getDefaultOptions
99 public static final String FORMATTER_CLEAR_BLANK_LINES = PLUGIN_ID
100 + ".formatter.newline.clearAll"; //$NON-NLS-1$
103 * Possible configurable option ID.
105 * @see #getDefaultOptions
108 public static final String FORMATTER_LINE_SPLIT = PLUGIN_ID
109 + ".formatter.lineSplit"; //$NON-NLS-1$
112 * Possible configurable option ID.
114 * @see #getDefaultOptions
117 public static final String FORMATTER_COMPACT_ASSIGNMENT = PLUGIN_ID
118 + ".formatter.style.assignment"; //$NON-NLS-1$
121 * Possible configurable option ID.
123 * @see #getDefaultOptions
126 public static final String FORMATTER_TAB_CHAR = PLUGIN_ID
127 + ".formatter.tabulation.char"; //$NON-NLS-1$
130 * Possible configurable option ID.
132 * @see #getDefaultOptions
135 public static final String FORMATTER_TAB_SIZE = PLUGIN_ID
136 + ".formatter.tabulation.size"; //$NON-NLS-1$
139 * Possible configurable option value.
141 * @see #getDefaultOptions
144 public static final String INSERT = "insert"; //$NON-NLS-1$
147 * Possible configurable option value.
149 * @see #getDefaultOptions
152 public static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$
155 * Possible configurable option value.
157 * @see #getDefaultOptions
160 public static final String PRESERVE_ONE = "preserve one"; //$NON-NLS-1$
163 * Possible configurable option value.
165 * @see #getDefaultOptions
168 public static final String CLEAR_ALL = "clear all"; //$NON-NLS-1$
171 * Possible configurable option value.
173 * @see #getDefaultOptions
176 public static final String NORMAL = "normal"; //$NON-NLS-1$
179 * Possible configurable option value.
181 * @see #getDefaultOptions
184 public static final String COMPACT = "compact"; //$NON-NLS-1$
187 * Possible configurable option value.
189 * @see #getDefaultOptions
192 public static final String TAB = "tab"; //$NON-NLS-1$
195 * Possible configurable option value.
197 * @see #getDefaultOptions
200 public static final String SPACE = "space"; //$NON-NLS-1$
203 * Possible configurable option value.
205 * @see #getDefaultOptions
208 public static final String ENABLED = "enabled"; //$NON-NLS-1$
211 * Possible configurable option value.
213 * @see #getDefaultOptions
216 public static final String DISABLED = "disabled"; //$NON-NLS-1$
219 * Possible configurable option value.
221 * @see #getDefaultOptions
224 public static final String CLEAN = "clean"; //$NON-NLS-1$
227 * Possible configurable option ID.
229 * @see #getDefaultOptions
232 public static final String COMPILER_TASK_TAGS = PLUGIN_ID
233 + ".compiler.taskTags"; //$NON-NLS-1$
236 * Name of the handle id attribute in a Java marker.
238 protected static final String ATT_HANDLE_ID = "net.sourceforge.phpdt.internal.core.JavaModelManager.handleId"; //$NON-NLS-1$
240 // *************** Possible IDs for configurable options.
241 // ********************
244 * Possible configurable option ID.
246 * @see #getDefaultOptions()
248 public static final String COMPILER_LOCAL_VARIABLE_ATTR = PLUGIN_ID
249 + ".compiler.debug.localVariable"; //$NON-NLS-1$
252 * Possible configurable option ID.
254 * @see #getDefaultOptions()
256 public static final String COMPILER_LINE_NUMBER_ATTR = PLUGIN_ID
257 + ".compiler.debug.lineNumber"; //$NON-NLS-1$
260 * Possible configurable option ID.
262 * @see #getDefaultOptions
264 public static final String COMPILER_SOURCE_FILE_ATTR = PLUGIN_ID
265 + ".compiler.debug.sourceFile"; //$NON-NLS-1$
268 * Possible configurable option ID.
270 * @see #getDefaultOptions
272 public static final String COMPILER_CODEGEN_UNUSED_LOCAL = PLUGIN_ID
273 + ".compiler.codegen.unusedLocal"; //$NON-NLS-1$
276 * Possible configurable option ID.
278 * @see #getDefaultOptions
280 public static final String COMPILER_CODEGEN_TARGET_PLATFORM = PLUGIN_ID
281 + ".compiler.codegen.targetPlatform"; //$NON-NLS-1$
284 * Possible configurable option ID.
286 * @see #getDefaultOptions
288 public static final String COMPILER_PB_PHP_VAR_DEPRECATED = CompilerOptions.OPTION_PHPVarDeprecatedWarning; //$NON-NLS-1$
290 public static final String COMPILER_PB_PHP_KEYWORD = CompilerOptions.OPTION_PHPBadStyleKeywordWarning; //$NON-NLS-1$
292 public static final String COMPILER_PB_PHP_UPPERCASE_IDENTIFIER = CompilerOptions.OPTION_PHPBadStyleUppercaseIdentifierWarning; //$NON-NLS-1$
294 public static final String COMPILER_PB_PHP_FILE_NOT_EXIST = CompilerOptions.OPTION_PHPIncludeNotExistWarning; //$NON-NLS-1$
297 * Possible configurable option ID.
299 * @see #getDefaultOptions
301 public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID
302 + ".compiler.problem.unreachableCode"; //$NON-NLS-1$
305 * Possible configurable option ID.
307 * @see #getDefaultOptions
309 public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID
310 + ".compiler.problem.invalidImport"; //$NON-NLS-1$
313 * Possible configurable option ID.
315 * @see #getDefaultOptions
317 public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID
318 + ".compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
321 * Possible configurable option ID.
323 * @see #getDefaultOptions
325 public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID
326 + ".compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
329 * Possible configurable option ID.
331 * @see #getDefaultOptions
333 public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID
334 + ".compiler.problem.deprecation"; //$NON-NLS-1$
337 * Possible configurable option ID.
339 * @see #getDefaultOptions
342 public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID
343 + ".compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
346 * Possible configurable option ID.
348 * @see #getDefaultOptions
350 public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID
351 + ".compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
354 * Possible configurable option ID.
356 * @see #getDefaultOptions
358 public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID
359 + ".compiler.problem.unusedLocal"; //$NON-NLS-1$
362 * Possible configurable option ID.
364 * @see #getDefaultOptions
366 public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID
367 + ".compiler.problem.unusedParameter"; //$NON-NLS-1$
370 * Possible configurable option ID.
372 * @see #getDefaultOptions
375 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID
376 + ".compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
379 * Possible configurable option ID.
381 * @see #getDefaultOptions
384 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID
385 + ".compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
388 * Possible configurable option ID.
390 * @see #getDefaultOptions
393 public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID
394 + ".compiler.problem.unusedImport"; //$NON-NLS-1$
397 * Possible configurable option ID.
399 * @see #getDefaultOptions
401 public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID
402 + ".compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
405 * Possible configurable option ID.
407 * @see #getDefaultOptions
410 public static final String COMPILER_PB_NON_NLS_STRING_LITERAL = PLUGIN_ID
411 + ".compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
414 * Possible configurable option ID.
416 * @see #getDefaultOptions
419 public static final String COMPILER_PB_ASSERT_IDENTIFIER = PLUGIN_ID
420 + ".compiler.problem.assertIdentifier"; //$NON-NLS-1$
423 * Possible configurable option ID.
425 * @see #getDefaultOptions
428 public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID
429 + ".compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
432 * Possible configurable option ID.
434 * @see #getDefaultOptions
437 public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID
438 + ".compiler.problem.noEffectAssignment"; //$NON-NLS-1$
441 * Possible configurable option ID.
443 * @see #getDefaultOptions
446 public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID
447 + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
450 * Possible configurable option ID.
452 * @see #getDefaultOptions
455 public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID
456 + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
459 * Possible configurable option ID.
461 * @see #getDefaultOptions
464 public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID
465 + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
468 * Possible configurable option ID.
470 * @see #getDefaultOptions
473 public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID
474 + ".compiler.maxProblemPerUnit"; //$NON-NLS-1$
477 * Possible configurable option ID.
479 * @see #getDefaultOptions
482 public static final String COMPILER_SOURCE = PLUGIN_ID + ".compiler.source"; //$NON-NLS-1$
485 * Possible configurable option ID.
487 * @see #getDefaultOptions
490 public static final String COMPILER_COMPLIANCE = PLUGIN_ID
491 + ".compiler.compliance"; //$NON-NLS-1$
494 * Possible configurable option ID.
496 * @see #getDefaultOptions
499 public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID
500 + ".compiler.taskPriorities"; //$NON-NLS-1$
503 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
505 * @see #getDefaultOptions
508 public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$
511 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
513 * @see #getDefaultOptions
516 public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$
519 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
521 * @see #getDefaultOptions
524 public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$
527 * Possible configurable option ID.
529 * @see #getDefaultOptions
531 public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID
532 + ".computeJavaBuildOrder"; //$NON-NLS-1$
535 * Possible configurable option ID.
537 * @see #getDefaultOptions
540 public static final String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER = PLUGIN_ID
541 + ".builder.resourceCopyExclusionFilter"; //$NON-NLS-1$
544 * Possible configurable option ID.
546 * @see #getDefaultOptions
549 public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID
550 + ".builder.duplicateResourceTask"; //$NON-NLS-1$
553 * Possible configurable option ID.
555 * @see #getDefaultOptions
558 public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID
559 + ".builder.cleanOutputFolder"; //$NON-NLS-1$
562 * Possible configurable option ID.
564 * @see #getDefaultOptions
567 public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID
568 + ".incompleteClasspath"; //$NON-NLS-1$
571 * Possible configurable option ID.
573 * @see #getDefaultOptions
576 public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID
577 + ".circularClasspath"; //$NON-NLS-1$
580 * Possible configurable option ID.
582 * @see #getDefaultOptions
585 public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID
586 + ".builder.invalidClasspath"; //$NON-NLS-1$
589 * Possible configurable option ID.
591 * @see #getDefaultOptions
594 public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID
595 + ".classpath.exclusionPatterns"; //$NON-NLS-1$
598 * Possible configurable option ID.
600 * @see #getDefaultOptions
603 public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID
604 + ".classpath.multipleOutputLocations"; //$NON-NLS-1$
611 public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$
614 * Default task priority
618 public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; //$NON-NLS-1$
621 * Possible configurable option ID
623 * @see #getDefaultOptions
626 public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID
627 + ".formatter.space.castexpression"; //$NON-NLS-1$
630 * Possible configurable option ID.
632 * @see #getDefaultOptions
635 public static final String CODEASSIST_VISIBILITY_CHECK = PLUGIN_ID
636 + ".codeComplete.visibilityCheck"; //$NON-NLS-1$
639 * Possible configurable option ID.
641 * @see #getDefaultOptions
644 public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID
645 + ".codeComplete.forceImplicitQualification"; //$NON-NLS-1$
648 * Possible configurable option ID.
650 * @see #getDefaultOptions
653 public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID
654 + ".codeComplete.fieldPrefixes"; //$NON-NLS-1$
657 * Possible configurable option ID.
659 * @see #getDefaultOptions
662 public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID
663 + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
666 * Possible configurable option ID.
668 * @see #getDefaultOptions
671 public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID
672 + ".codeComplete.localPrefixes"; //$NON-NLS-1$
675 * Possible configurable option ID.
677 * @see #getDefaultOptions
680 public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID
681 + ".codeComplete.argumentPrefixes"; //$NON-NLS-1$
684 * Possible configurable option ID.
686 * @see #getDefaultOptions
689 public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID
690 + ".codeComplete.fieldSuffixes"; //$NON-NLS-1$
693 * Possible configurable option ID.
695 * @see #getDefaultOptions
698 public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID
699 + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
702 * Possible configurable option ID.
704 * @see #getDefaultOptions
707 public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID
708 + ".codeComplete.localSuffixes"; //$NON-NLS-1$
711 * Possible configurable option ID.
713 * @see #getDefaultOptions
716 public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID
717 + ".codeComplete.argumentSuffixes"; //$NON-NLS-1$
719 // *************** Possible values for configurable options.
720 // ********************
723 * Possible configurable option value.
725 * @see #getDefaultOptions
727 public static final String GENERATE = "generate"; //$NON-NLS-1$
730 * Possible configurable option value.
732 * @see #getDefaultOptions
734 public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
737 * Possible configurable option value.
739 * @see #getDefaultOptions
741 public static final String PRESERVE = "preserve"; //$NON-NLS-1$
744 * Possible configurable option value.
746 * @see #getDefaultOptions
748 public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
751 * Possible configurable option value.
753 * @see #getDefaultOptions
755 public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$
758 * Possible configurable option value.
760 * @see #getDefaultOptions
762 public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$
765 * Possible configurable option value.
767 * @see #getDefaultOptions
770 public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
773 * Possible configurable option value.
775 * @see #getDefaultOptions
778 public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
781 * Possible configurable option value.
783 * @see #getDefaultOptions
786 public static final String ABORT = "abort"; //$NON-NLS-1$
789 * Possible configurable option value.
791 * @see #getDefaultOptions
793 public static final String ERROR = "error"; //$NON-NLS-1$
796 * Possible configurable option value.
798 * @see #getDefaultOptions
800 public static final String WARNING = "warning"; //$NON-NLS-1$
803 * Possible configurable option value.
805 * @see #getDefaultOptions
807 public static final String IGNORE = "ignore"; //$NON-NLS-1$
810 * Possible configurable option value.
812 * @see #getDefaultOptions
814 public static final String COMPUTE = "compute"; //$NON-NLS-1$
817 * Possible configurable option value.
819 * @see #getDefaultOptions
824 * Returns a table of all known configurable options with their default
825 * values. These options allow to configure the behaviour of the underlying
826 * components. The client may safely use the result as a template that they
827 * can modify and then pass to <code>setOptions</code>.
829 * Helper constants have been defined on JavaCore for each of the option ID
830 * and their possible constant values.
832 * Note: more options might be added in further releases.
836 * RECOGNIZED OPTIONS:
837 * COMPILER / Generating Local Variable Debug Attribute
838 * When generated, this attribute will enable local variable names
839 * to be displayed in debugger, only in place where variables are
840 * definitely assigned (.class file is then bigger)
841 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.localVariable"
842 * - possible values: { "generate", "do not generate" }
843 * - default: "generate"
845 * COMPILER / Generating Line Number Debug Attribute
846 * When generated, this attribute will enable source code highlighting in debugger
847 * (.class file is then bigger).
848 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.lineNumber"
849 * - possible values: { "generate", "do not generate" }
850 * - default: "generate"
852 * COMPILER / Generating Source Debug Attribute
853 * When generated, this attribute will enable the debugger to present the
854 * corresponding source code.
855 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.sourceFile"
856 * - possible values: { "generate", "do not generate" }
857 * - default: "generate"
859 * COMPILER / Preserving Unused Local Variables
860 * Unless requested to preserve unused local variables (i.e. never read), the
861 * compiler will optimize them out, potentially altering debugging
862 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.unusedLocal"
863 * - possible values: { "preserve", "optimize out" }
864 * - default: "preserve"
866 * COMPILER / Defining Target Java Platform
867 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
868 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
869 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.targetPlatform"
870 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
871 * - default: "1.1"
873 * COMPILER / Reporting Unreachable Code
874 * Unreachable code can optionally be reported as an error, warning or simply
875 * ignored. The bytecode generation will always optimized it out.
876 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unreachableCode"
877 * - possible values: { "error", "warning", "ignore" }
878 * - default: "error"
880 * COMPILER / Reporting Invalid Import
881 * An import statement that cannot be resolved might optionally be reported
882 * as an error, as a warning or ignored.
883 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.invalidImport"
884 * - possible values: { "error", "warning", "ignore" }
885 * - default: "error"
887 * COMPILER / Reporting Attempt to Override Package-Default Method
888 * A package default method is not visible in a different package, and thus
889 * cannot be overridden. When enabling this option, the compiler will signal
890 * such scenarii either as an error or a warning.
891 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
892 * - possible values: { "error", "warning", "ignore" }
893 * - default: "warning"
895 * COMPILER / Reporting Method With Constructor Name
896 * Naming a method with a constructor name is generally considered poor
897 * style programming. When enabling this option, the compiler will signal such
898 * scenarii either as an error or a warning.
899 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.methodWithConstructorName"
900 * - possible values: { "error", "warning", "ignore" }
901 * - default: "warning"
903 * COMPILER / Reporting Deprecation
904 * When enabled, the compiler will signal use of deprecated API either as an
905 * error or a warning.
906 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecation"
907 * - possible values: { "error", "warning", "ignore" }
908 * - default: "warning"
910 * COMPILER / Reporting Deprecation Inside Deprecated Code
911 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
912 * The severity of the problem is controlled with option "org.phpeclipse.phpdt.core.compiler.problem.deprecation".
913 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
914 * - possible values: { "enabled", "disabled" }
915 * - default: "disabled"
917 * COMPILER / Reporting Hidden Catch Block
918 * Locally to a try statement, some catch blocks may hide others , e.g.
919 * try { throw new java.io.CharConversionException();
920 * } catch (java.io.CharConversionException e) {
921 * } catch (java.io.IOException e) {}.
922 * When enabling this option, the compiler will issue an error or a warning for hidden
923 * catch blocks corresponding to checked exceptions
924 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.hiddenCatchBlock"
925 * - possible values: { "error", "warning", "ignore" }
926 * - default: "warning"
928 * COMPILER / Reporting Unused Local
929 * When enabled, the compiler will issue an error or a warning for unused local
930 * variables (i.e. variables never read from)
931 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedLocal"
932 * - possible values: { "error", "warning", "ignore" }
933 * - default: "ignore"
935 * COMPILER / Reporting Unused Parameter
936 * When enabled, the compiler will issue an error or a warning for unused method
937 * parameters (i.e. parameters never read from)
938 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedParameter"
939 * - possible values: { "error", "warning", "ignore" }
940 * - default: "ignore"
942 * COMPILER / Reporting Unused Import
943 * When enabled, the compiler will issue an error or a warning for unused import
945 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedImport"
946 * - possible values: { "error", "warning", "ignore" }
947 * - default: "warning"
949 * COMPILER / Reporting Synthetic Access Emulation
950 * When enabled, the compiler will issue an error or a warning whenever it emulates
951 * access to a non-accessible member of an enclosing type. Such access can have
952 * performance implications.
953 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.syntheticAccessEmulation"
954 * - possible values: { "error", "warning", "ignore" }
955 * - default: "ignore"
957 * COMPILER / Reporting Non-Externalized String Literal
958 * When enabled, the compiler will issue an error or a warning for non externalized
959 * String literal (i.e. non tagged with //$NON-NLS-<n>$).
960 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
961 * - possible values: { "error", "warning", "ignore" }
962 * - default: "ignore"
964 * COMPILER / Reporting Usage of 'assert' Identifier
965 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
966 * used as an identifier (reserved keyword in 1.4)
967 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.assertIdentifier"
968 * - possible values: { "error", "warning", "ignore" }
969 * - default: "ignore"
971 * COMPILER / Reporting Usage of expression receiver on static invocation/field access
972 * When enabled, the compiler will issue an error or a warning whenever a static field
973 * or method is accessed with an expression receiver.
974 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.staticAccessReceiver"
975 * - possible values: { "error", "warning", "ignore" }
976 * - default: "warning"
978 * COMPILER / Reporting Assignment with no effect
979 * When enabled, the compiler will issue an error or a warning whenever an assignment
980 * has no effect (e.g 'x = x').
981 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.noEffectAssignment"
982 * - possible values: { "error", "warning", "ignore" }
983 * - default: "warning"
985 * COMPILER / Setting Source Compatibility Mode
986 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
987 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
988 * level should be set to "1.4" and the compliance mode should be "1.4".
989 * - option id: "org.phpeclipse.phpdt.core.compiler.source"
990 * - possible values: { "1.3", "1.4" }
991 * - default: "1.3"
993 * COMPILER / Setting Compliance Level
994 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
995 * should not go beyond "1.3" level.
996 * - option id: "org.phpeclipse.phpdt.core.compiler.compliance"
997 * - possible values: { "1.3", "1.4" }
998 * - default: "1.3"
1000 * COMPILER / Maximum number of problems reported per compilation unit
1001 * Specify the maximum number of problems reported on each compilation unit.
1002 * - option id: "org.phpeclipse.phpdt.core.compiler.maxProblemPerUnit"
1003 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
1004 * - default: "100"
1006 * COMPILER / Define the Automatic Task Tags
1007 * When the tag is non empty, the compiler will issue a task marker whenever it encounters
1008 * one of the corresponding tag inside any comment in Java source code.
1009 * Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed.
1010 * - option id: "org.phpeclipse.phpdt.core.compiler.taskTags"
1011 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card
1012 * - default: ""
1013 * COMPILER / Define the Automatic Task Priorities
1014 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
1015 * of the task markers issued by the compiler.
1016 * If the default is specified, the priority of each task marker is "NORMAL".
1017 * - option id: "org.phpeclipse.phpdt.core.compiler.taskPriorities"
1018 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
1019 * - default: ""
1021 * BUILDER / Specifying Filters for Resource Copying Control
1022 * Allow to specify some filters to control the resource copy process.
1023 * - option id: "org.phpeclipse.phpdt.core.builder.resourceCopyExclusionFilter"
1024 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
1025 * or the name of a folder which ends with '/'
1026 * - default: ""
1028 * BUILDER / Abort if Invalid Classpath
1029 * Allow to toggle the builder to abort if the classpath is invalid
1030 * - option id: "org.phpeclipse.phpdt.core.builder.invalidClasspath"
1031 * - possible values: { "abort", "ignore" }
1032 * - default: "ignore"
1034 * BUILDER / Cleaning Output Folder(s)
1035 * Indicate whether the JavaBuilder is allowed to clean the output folders
1036 * when performing full build operations.
1037 * - option id: "org.phpeclipse.phpdt.core.builder.cleanOutputFolder"
1038 * - possible values: { "clean", "ignore" }
1039 * - default: "clean"
1041 * JAVACORE / Computing Project Build Order
1042 * Indicate whether JavaCore should enforce the project build order to be based on
1043 * the classpath prerequisite chain. When requesting to compute, this takes over
1044 * the platform default order (based on project references).
1045 * - option id: "org.phpeclipse.phpdt.core.computeJavaBuildOrder"
1046 * - possible values: { "compute", "ignore" }
1047 * - default: "ignore"
1049 * JAVACORE / Specify Default Source Encoding Format
1050 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
1051 * to 'ResourcesPlugin.getEncoding()'.
1052 * - option id: "org.phpeclipse.phpdt.core.encoding"
1053 * - possible values: { any of the supported encoding name}.
1054 * - default: <platform default>
1056 * JAVACORE / Reporting Incomplete Classpath
1057 * An entry on the classpath doesn't exist or is not visible (e.g. a referenced project is closed).
1058 * - option id: "org.phpeclipse.phpdt.core.incompleteClasspath"
1059 * - possible values: { "error", "warning"}
1060 * - default: "error"
1062 * JAVACORE / Reporting Classpath Cycle
1063 * A project is involved in a cycle.
1064 * - option id: "org.phpeclipse.phpdt.core.circularClasspath"
1065 * - possible values: { "error", "warning" }
1066 * - default: "error"
1068 * FORMATTER / Inserting New Line Before Opening Brace
1069 * When Insert, a new line is inserted before an opening brace, otherwise nothing
1071 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.openingBrace"
1072 * - possible values: { "insert", "do not insert" }
1073 * - default: "do not insert"
1075 * FORMATTER / Inserting New Line Inside Control Statement
1076 * When Insert, a new line is inserted between } and following else, catch, finally
1077 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.controlStatement"
1078 * - possible values: { "insert", "do not insert" }
1079 * - default: "do not insert"
1081 * FORMATTER / Clearing Blank Lines
1082 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
1083 * and all others removed.
1084 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.clearAll"
1085 * - possible values: { "clear all", "preserve one" }
1086 * - default: "preserve one"
1088 * FORMATTER / Inserting New Line Between Else/If
1089 * When Insert, a blank line is inserted between an else and an if when they are
1090 * contiguous. When choosing to not insert, else-if will be kept on the same
1091 * line when possible.
1092 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.elseIf"
1093 * - possible values: { "insert", "do not insert" }
1094 * - default: "do not insert"
1096 * FORMATTER / Inserting New Line In Empty Block
1097 * When insert, a line break is inserted between contiguous { and }, if } is not followed
1099 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.emptyBlock"
1100 * - possible values: { "insert", "do not insert" }
1101 * - default: "insert"
1103 * FORMATTER / Splitting Lines Exceeding Length
1104 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
1105 * disable line splitting
1106 * - option id: "org.phpeclipse.phpdt.core.formatter.lineSplit"
1107 * - possible values: "<n>", where n is zero or a positive integer
1108 * - default: "80"
1110 * FORMATTER / Compacting Assignment
1111 * Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space
1112 * is inserted before the assignment operator
1113 * - option id: "org.phpeclipse.phpdt.core.formatter.style.assignment"
1114 * - possible values: { "compact", "normal" }
1115 * - default: "normal"
1117 * FORMATTER / Defining Indentation Character
1118 * Either choose to indent with tab characters or spaces
1119 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.char"
1120 * - possible values: { "tab", "space" }
1121 * - default: "tab"
1123 * FORMATTER / Defining Space Indentation Length
1124 * When using spaces, set the amount of space characters to use for each
1126 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.size"
1127 * - possible values: "<n>", where n is a positive integer
1128 * - default: "4"
1130 * CODEASSIST / Activate Visibility Sensitive Completion
1131 * When active, completion doesn't show that you can not see
1132 * (e.g. you can not see private methods of a super class).
1133 * - option id: "org.phpeclipse.phpdt.core.codeComplete.visibilityCheck"
1134 * - possible values: { "enabled", "disabled" }
1135 * - default: "disabled"
1137 * CODEASSIST / Automatic Qualification of Implicit Members
1138 * When active, completion automatically qualifies completion on implicit
1139 * field references and message expressions.
1140 * - option id: "org.phpeclipse.phpdt.core.codeComplete.forceImplicitQualification"
1141 * - possible values: { "enabled", "disabled" }
1142 * - default: "disabled"
1144 * CODEASSIST / Define the Prefixes for Field Name
1145 * When the prefixes is non empty, completion for field name will begin with
1146 * one of the proposed prefixes.
1147 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldPrefixes"
1148 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1149 * - default: ""
1151 * CODEASSIST / Define the Prefixes for Static Field Name
1152 * When the prefixes is non empty, completion for static field name will begin with
1153 * one of the proposed prefixes.
1154 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldPrefixes"
1155 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1156 * - default: ""
1158 * CODEASSIST / Define the Prefixes for Local Variable Name
1159 * When the prefixes is non empty, completion for local variable name will begin with
1160 * one of the proposed prefixes.
1161 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localPrefixes"
1162 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1163 * - default: ""
1165 * CODEASSIST / Define the Prefixes for Argument Name
1166 * When the prefixes is non empty, completion for argument name will begin with
1167 * one of the proposed prefixes.
1168 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentPrefixes"
1169 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
1170 * - default: ""
1172 * CODEASSIST / Define the Suffixes for Field Name
1173 * When the suffixes is non empty, completion for field name will end with
1174 * one of the proposed suffixes.
1175 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldSuffixes"
1176 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1177 * - default: ""
1179 * CODEASSIST / Define the Suffixes for Static Field Name
1180 * When the suffixes is non empty, completion for static field name will end with
1181 * one of the proposed suffixes.
1182 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldSuffixes"
1183 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1184 * - default: ""
1186 * CODEASSIST / Define the Suffixes for Local Variable Name
1187 * When the suffixes is non empty, completion for local variable name will end with
1188 * one of the proposed suffixes.
1189 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localSuffixes"
1190 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
1191 * - default: ""
1193 * CODEASSIST / Define the Suffixes for Argument Name
1194 * When the suffixes is non empty, completion for argument name will end with
1195 * one of the proposed suffixes.
1196 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentSuffixes"
1197 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
1198 * - default: ""
1201 * @return a mutable table containing the default settings of all known options
1214 // public static Hashtable getDefaultOptions() {
1216 // Hashtable defaultOptions = new Hashtable(10);
1218 // // see #initializeDefaultPluginPreferences() for changing default
1220 // Preferences preferences = getPlugin().getPluginPreferences();
1221 // HashSet optionNames = OptionNames;
1223 // // get preferences set to their default
1224 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1225 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1226 // String propertyName = defaultPropertyNames[i];
1227 // if (optionNames.contains(propertyName)) {
1228 // defaultOptions.put(propertyName,
1229 // preferences.getDefaultString(propertyName));
1232 // // get preferences not set to their default
1233 // String[] propertyNames = preferences.propertyNames();
1234 // for (int i = 0; i < propertyNames.length; i++) {
1235 // String propertyName = propertyNames[i];
1236 // if (optionNames.contains(propertyName)) {
1237 // defaultOptions.put(propertyName,
1238 // preferences.getDefaultString(propertyName));
1241 // // get encoding through resource plugin
1242 // defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1244 // return defaultOptions;
1247 * Helper method for returning one option value only. Equivalent to
1248 * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
1249 * may answer <code>null</code> if this option does not exist.
1251 * For a complete description of the configurable options, see
1252 * <code>getDefaultOptions</code>.
1256 * the name of an option
1257 * @return the String value of a given option
1258 * @see JavaCore#getDefaultOptions
1261 // public static String getOption(String optionName) {
1263 // if (CORE_ENCODING.equals(optionName)) {
1264 // return ResourcesPlugin.getEncoding();
1266 // if (OptionNames.contains(optionName)) {
1267 // Preferences preferences = getPlugin().getPluginPreferences();
1268 // return preferences.getString(optionName).trim();
1273 * Returns the table of the current options. Initially, all options have
1274 * their default values, and this method returns a table that includes all
1277 * For a complete description of the configurable options, see
1278 * <code>getDefaultOptions</code>.
1281 * @return table of current settings of all options (key type:
1282 * <code>String</code>; value type: <code>String</code>)
1283 * @see JavaCore#getDefaultOptions
1285 // public static Hashtable getOptions() {
1287 // Hashtable options = new Hashtable(10);
1289 // // see #initializeDefaultPluginPreferences() for changing default
1291 // Plugin plugin = getPlugin();
1292 // if (plugin != null) {
1293 // Preferences preferences = getPlugin().getPluginPreferences();
1294 // HashSet optionNames = OptionNames;
1296 // // get preferences set to their default
1297 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1298 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1299 // String propertyName = defaultPropertyNames[i];
1300 // if (optionNames.contains(propertyName)) {
1301 // options.put(propertyName, preferences.getDefaultString(propertyName));
1304 // // get preferences not set to their default
1305 // String[] propertyNames = preferences.propertyNames();
1306 // for (int i = 0; i < propertyNames.length; i++) {
1307 // String propertyName = propertyNames[i];
1308 // if (optionNames.contains(propertyName)) {
1309 // options.put(propertyName, preferences.getString(propertyName).trim());
1312 // // get encoding through resource plugin
1313 // options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1318 * Sets the current table of options. All and only the options explicitly
1319 * included in the given table are remembered; all previous option settings
1320 * are forgotten, including ones not explicitly mentioned.
1322 * For a complete description of the configurable options, see
1323 * <code>getDefaultOptions</code>.
1327 * the new options (key type: <code>String</code>; value type:
1328 * <code>String</code>), or <code>null</code> to reset all
1329 * options to their default values
1330 * @see JavaCore#getDefaultOptions
1332 // public static void setOptions(Hashtable newOptions) {
1334 // // see #initializeDefaultPluginPreferences() for changing default
1336 // Preferences preferences = getPlugin().getPluginPreferences();
1338 // if (newOptions == null) {
1339 // newOptions = getDefaultOptions();
1341 // Enumeration keys = newOptions.keys();
1342 // while (keys.hasMoreElements()) {
1343 // String key = (String) keys.nextElement();
1344 // if (!OptionNames.contains(key))
1345 // continue; // unrecognized option
1346 // if (key.equals(CORE_ENCODING))
1347 // continue; // skipped, contributed by resource prefs
1348 // String value = (String) newOptions.get(key);
1349 // preferences.setValue(key, value);
1352 // // persist options
1353 // getPlugin().savePluginPreferences();
1355 public static IProject[] getPHPProjects() {
1356 List phpProjectsList = new ArrayList();
1357 IProject[] workspaceProjects = PHPeclipsePlugin.getWorkspace()
1358 .getRoot().getProjects();
1360 for (int i = 0; i < workspaceProjects.length; i++) {
1361 IProject iProject = workspaceProjects[i];
1362 if (isPHPProject(iProject))
1363 phpProjectsList.add(iProject);
1366 IProject[] phpProjects = new IProject[phpProjectsList.size()];
1367 return (IProject[]) phpProjectsList.toArray(phpProjects);
1370 // public static PHPProject getPHPProject(String name) {
1371 // IProject aProject =
1372 // PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
1373 // if (isPHPProject(aProject)) {
1374 // PHPProject thePHPProject = new PHPProject();
1375 // thePHPProject.setProject(aProject);
1376 // return thePHPProject;
1381 public static boolean isPHPProject(IProject aProject) {
1383 return aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID);
1384 } catch (CoreException e) {
1390 // public static PHPFile create(IFile aFile) {
1391 // if (PHPFile.EXTENSION.equalsIgnoreCase(aFile.getFileExtension()))
1392 // return new PHPFile(aFile);
1393 // if (PHPFile.EXTENSION1.equalsIgnoreCase(aFile.getFileExtension()))
1394 // return new PHPFile(aFile);
1395 // if (PHPFile.EXTENSION2.equalsIgnoreCase(aFile.getFileExtension()))
1396 // return new PHPFile(aFile);
1397 // if (PHPFile.EXTENSION3.equalsIgnoreCase(aFile.getFileExtension()))
1398 // return new PHPFile(aFile);
1399 // if (PHPFile.EXTENSION4.equalsIgnoreCase(aFile.getFileExtension()))
1400 // return new PHPFile(aFile);
1401 // if (PHPFile.EXTENSION5.equalsIgnoreCase(aFile.getFileExtension()))
1402 // return new PHPFile(aFile);
1407 // public static PHPProject create(IProject aProject) {
1410 // if (aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1411 // PHPProject project = new PHPProject();
1412 // project.setProject(aProject);
1415 // } catch (CoreException e) {
1416 // System.err.println("Exception occurred in PHPCore#create(IProject): " +
1423 public static void addPHPNature(IProject project, IProgressMonitor monitor)
1424 throws CoreException {
1425 if (!project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1426 IProjectDescription description = project.getDescription();
1427 String[] prevNatures = description.getNatureIds();
1428 String[] newNatures = new String[prevNatures.length + 1];
1429 System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
1430 newNatures[prevNatures.length] = PHPeclipsePlugin.PHP_NATURE_ID;
1431 description.setNatureIds(newNatures);
1432 project.setDescription(description, monitor);
1437 * Returns the single instance of the PHP core plug-in runtime class.
1439 * @return the single instance of the PHP core plug-in runtime class
1441 public static Plugin getPlugin() {
1442 return PHPeclipsePlugin.getDefault();
1446 * Runs the given action as an atomic Java model operation.
1448 * After running a method that modifies java elements, registered listeners
1449 * receive after-the-fact notification of what just transpired, in the form
1450 * of a element changed event. This method allows clients to call a number
1451 * of methods that modify java elements and only have element changed event
1452 * notifications reported at the end of the entire batch.
1455 * If this method is called outside the dynamic scope of another such call,
1456 * this method runs the action and then reports a single element changed
1457 * event describing the net effect of all changes done to java elements by
1461 * If this method is called in the dynamic scope of another such call, this
1462 * method simply runs the action.
1466 * the action to perform
1468 * a progress monitor, or <code>null</code> if progress
1469 * reporting and cancellation are not desired
1470 * @exception CoreException
1471 * if the operation failed.
1474 // public static void run(IWorkspaceRunnable action, IProgressMonitor
1475 // monitor) throws CoreException {
1476 // run(action, ResourcesPlugin.getWorkspace().getRoot(), monitor);
1479 * Runs the given action as an atomic Java model operation.
1481 * After running a method that modifies java elements, registered listeners
1482 * receive after-the-fact notification of what just transpired, in the form
1483 * of a element changed event. This method allows clients to call a number
1484 * of methods that modify java elements and only have element changed event
1485 * notifications reported at the end of the entire batch.
1488 * If this method is called outside the dynamic scope of another such call,
1489 * this method runs the action and then reports a single element changed
1490 * event describing the net effect of all changes done to java elements by
1494 * If this method is called in the dynamic scope of another such call, this
1495 * method simply runs the action.
1498 * The supplied scheduling rule is used to determine whether this operation
1499 * can be run simultaneously with workspace changes in other threads. See
1500 * <code>IWorkspace.run(...)</code> for more details.
1504 * the action to perform
1506 * the scheduling rule to use when running this operation, or
1507 * <code>null</code> if there are no scheduling restrictions
1508 * for this operation.
1510 * a progress monitor, or <code>null</code> if progress
1511 * reporting and cancellation are not desired
1512 * @exception CoreException
1513 * if the operation failed.
1516 // public static void run(IWorkspaceRunnable action, ISchedulingRule rule,
1517 // IProgressMonitor monitor) throws CoreException {
1518 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
1519 // if (workspace.isTreeLocked()) {
1520 // new BatchOperation(action).run(monitor);
1522 // // use IWorkspace.run(...) to ensure that a build will be done in
1524 // workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE,
1530 * Adds the given listener for changes to Java elements. Has no effect if an
1531 * identical listener is already registered.
1533 * This listener will only be notified during the POST_CHANGE resource
1534 * change notification and any reconcile operation (POST_RECONCILE). For
1535 * finer control of the notification, use
1536 * <code>addElementChangedListener(IElementChangedListener,int)</code>,
1537 * which allows to specify a different eventMask.
1539 * @see ElementChangedEvent
1543 public static void addElementChangedListener(
1544 IElementChangedListener listener) {
1545 addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE
1546 | ElementChangedEvent.POST_RECONCILE);
1550 * Adds the given listener for changes to Java elements. Has no effect if an
1551 * identical listener is already registered. After completion of this
1552 * method, the given listener will be registered for exactly the specified
1553 * events. If they were previously registered for other events, they will be
1556 * Once registered, a listener starts receiving notification of changes to
1557 * java elements in the model. The listener continues to receive
1558 * notifications until it is replaced or removed.
1561 * Listeners can listen for several types of event as defined in
1562 * <code>ElementChangeEvent</code>. Clients are free to register for any
1563 * number of event types however if they register for more than one, it is
1564 * their responsibility to ensure they correctly handle the case where the
1565 * same java element change shows up in multiple notifications. Clients are
1566 * guaranteed to receive only the events for which they are registered.
1572 * the bit-wise OR of all event types of interest to the listener
1573 * @see IElementChangedListener
1574 * @see ElementChangedEvent
1575 * @see #removeElementChangedListener(IElementChangedListener)
1578 public static void addElementChangedListener(
1579 IElementChangedListener listener, int eventMask) {
1580 JavaModelManager.getJavaModelManager().addElementChangedListener(
1581 listener, eventMask);
1585 * Configures the given marker attribute map for the given Java element.
1586 * Used for markers, which denote a Java element rather than a resource.
1589 * the mutable marker attribute map (key type:
1590 * <code>String</code>, value type: <code>String</code>)
1592 * the Java element for which the marker needs to be configured
1594 public static void addJavaElementMarkerAttributes(Map attributes,
1595 IJavaElement element) {
1596 // if (element instanceof IMember)
1597 // element = ((IMember) element).getClassFile();
1598 if (attributes != null && element != null)
1599 attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier());
1603 * Adds the given listener for POST_CHANGE resource change events to the Java core.
1604 * The listener is guarantied to be notified of the POST_CHANGE resource change event before
1605 * the Java core starts processing the resource change event itself.
1607 * Has no effect if an identical listener is already registered.
1610 * @param listener the listener
1611 * @see #removePreProcessingResourceChangedListener(IResourceChangeListener)
1614 public static void addPreProcessingResourceChangedListener(IResourceChangeListener listener) {
1615 JavaModelManager.getJavaModelManager().deltaState.addPreResourceChangedListener(listener);
1618 * Configures the given marker for the given Java element. Used for markers,
1619 * which denote a Java element rather than a resource.
1622 * the marker to be configured
1624 * the Java element for which the marker needs to be configured
1625 * @exception CoreException
1626 * if the <code>IMarker.setAttribute</code> on the marker
1629 public void configureJavaElementMarker(IMarker marker, IJavaElement element)
1630 throws CoreException {
1631 // if (element instanceof IMember)
1632 // element = ((IMember) element).getClassFile();
1633 if (marker != null && element != null)
1634 marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier());
1638 * Returns the Java model element corresponding to the given handle
1639 * identifier generated by <code>IJavaElement.getHandleIdentifier()</code>,
1640 * or <code>null</code> if unable to create the associated element.
1642 public static IJavaElement create(String handleIdentifier) {
1643 if (handleIdentifier == null) {
1647 return JavaModelManager.getJavaModelManager().getHandleFromMemento(
1649 } catch (JavaModelException e) {
1655 * Returns the Java element corresponding to the given file, or
1656 * <code>null</code> if unable to associate the given file with a Java
1660 * The file must be one of:
1662 * <li>a <code>.java</code> file - the element returned is the
1663 * corresponding <code>ICompilationUnit</code></li>
1664 * <li>a <code>.class</code> file - the element returned is the
1665 * corresponding <code>IClassFile</code></li>
1666 * <li>a <code>.jar</code> file - the element returned is the
1667 * corresponding <code>IPackageFragmentRoot</code></li>
1670 * Creating a Java element has the side effect of creating and opening all
1671 * of the element's parents if they are not yet open.
1675 * @return the Java element corresponding to the given file, or
1676 * <code>null</code> if unable to associate the given file with a
1679 public static IJavaElement create(IFile file) {
1680 return JavaModelManager.create(file, null);
1684 * Returns the package fragment or package fragment root corresponding to
1685 * the given folder, or <code>null</code> if unable to associate the given
1686 * folder with a Java element.
1688 * Note that a package fragment root is returned rather than a default
1691 * Creating a Java element has the side effect of creating and opening all
1692 * of the element's parents if they are not yet open.
1696 * @return the package fragment or package fragment root corresponding to
1697 * the given folder, or <code>null</code> if unable to associate
1698 * the given folder with a Java element
1700 public static IJavaElement create(IFolder folder) {
1701 return JavaModelManager.create(folder, null);
1705 * Returns the Java project corresponding to the given project.
1707 * Creating a Java Project has the side effect of creating and opening all
1708 * of the project's parents if they are not yet open.
1710 * Note that no check is done at this time on the existence or the java
1711 * nature of this project.
1715 * @return the Java project corresponding to the given project, null if the
1716 * given project is null
1718 public static IJavaProject create(IProject project) {
1719 if (project == null) {
1722 JavaModel javaModel = JavaModelManager.getJavaModelManager()
1724 return javaModel.getJavaProject(project);
1728 * Returns the Java element corresponding to the given resource, or
1729 * <code>null</code> if unable to associate the given resource with a Java
1732 * The resource must be one of:
1734 * <li>a project - the element returned is the corresponding
1735 * <code>IJavaProject</code></li>
1736 * <li>a <code>.java</code> file - the element returned is the
1737 * corresponding <code>ICompilationUnit</code></li>
1738 * <li>a <code>.class</code> file - the element returned is the
1739 * corresponding <code>IClassFile</code></li>
1740 * <li>a <code>.jar</code> file - the element returned is the
1741 * corresponding <code>IPackageFragmentRoot</code></li>
1742 * <li>a folder - the element returned is the corresponding
1743 * <code>IPackageFragmentRoot</code> or <code>IPackageFragment</code>
1745 * <li>the workspace root resource - the element returned is the
1746 * <code>IJavaModel</code></li>
1749 * Creating a Java element has the side effect of creating and opening all
1750 * of the element's parents if they are not yet open.
1753 * the given resource
1754 * @return the Java element corresponding to the given resource, or
1755 * <code>null</code> if unable to associate the given resource
1756 * with a Java element
1758 public static IJavaElement create(IResource resource) {
1759 return JavaModelManager.create(resource, null);
1763 * Returns the Java model.
1767 * @return the Java model, or <code>null</code> if the root is null
1769 public static IJavaModel create(IWorkspaceRoot root) {
1773 return JavaModelManager.getJavaModelManager().getJavaModel();
1777 * Creates and returns a class file element for the given
1778 * <code>.class</code> file. Returns <code>null</code> if unable to
1779 * recognize the class file.
1782 * the given <code>.class</code> file
1783 * @return a class file element for the given <code>.class</code> file, or
1784 * <code>null</code> if unable to recognize the class file
1786 //public static IClassFile createClassFileFrom(IFile file) {
1787 // return JavaModelManager.createClassFileFrom(file, null);
1790 * Creates and returns a compilation unit element for the given
1791 * <code>.java</code> file. Returns <code>null</code> if unable to
1792 * recognize the compilation unit.
1795 * the given <code>.java</code> file
1796 * @return a compilation unit element for the given <code>.java</code>
1797 * file, or <code>null</code> if unable to recognize the
1800 public static ICompilationUnit createCompilationUnitFrom(IFile file) {
1801 return JavaModelManager.createCompilationUnitFrom(file, null);
1805 * Creates and returns a handle for the given JAR file. The Java model
1806 * associated with the JAR's project may be created as a side effect.
1809 * the given JAR file
1810 * @return a handle for the given JAR file, or <code>null</code> if unable
1811 * to create a JAR package fragment root. (for example, if the JAR
1812 * file represents a non-Java resource)
1814 //public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile
1816 // return JavaModelManager.createJarPackageFragmentRootFrom(file, null);
1819 * Answers the project specific value for a given classpath container. In
1820 * case this container path could not be resolved, then will answer
1821 * <code>null</code>. Both the container path and the project context are
1822 * supposed to be non-null.
1824 * The containerPath is a formed by a first ID segment followed with extra
1825 * segments, which can be used as additional hints for resolution. If no
1826 * container was ever recorded for this container path onto this project
1827 * (using <code>setClasspathContainer</code>, then a
1828 * <code>ClasspathContainerInitializer</code> will be activated if any was
1829 * registered for this container ID onto the extension point
1830 * "org.eclipse.jdt.core.classpathContainerInitializer".
1832 * There is no assumption that the returned container must answer the exact
1833 * same containerPath when requested
1834 * <code>IClasspathContainer#getPath</code>. Indeed, the containerPath is
1835 * just an indication for resolving it to an actual container object.
1837 * Classpath container values are persisted locally to the workspace, but
1838 * are not preserved from a session to another. It is thus highly
1839 * recommended to register a <code>ClasspathContainerInitializer</code>
1840 * for each referenced container (through the extension point
1841 * "org.eclipse.jdt.core.ClasspathContainerInitializer").
1844 * @param containerPath
1845 * the name of the container, which needs to be resolved
1847 * a specific project in which the container is being resolved
1848 * @return the corresponding classpath container or <code>null</code> if
1849 * unable to find one.
1851 * @exception JavaModelException
1852 * if an exception occurred while resolving the container, or
1853 * if the resolved container contains illegal entries
1854 * (contains CPE_CONTAINER entries or null entries).
1856 * @see ClasspathContainerInitializer
1857 * @see IClasspathContainer
1858 * @see #setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[],
1862 //public static IClasspathContainer getClasspathContainer(final IPath
1863 // containerPath, final IJavaProject project) throws JavaModelException {
1865 // IClasspathContainer container = JavaModelManager.containerGet(project,
1867 // if (container == JavaModelManager.ContainerInitializationInProgress)
1868 // return null; // break cycle
1870 // if (container == null){
1871 // final ClasspathContainerInitializer initializer =
1872 // JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
1873 // if (initializer != null){
1874 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1875 // System.out.println("CPContainer INIT - triggering initialization of:
1876 // ["+project.getElementName()+"] " + containerPath + " using initializer:
1877 // "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
1878 // new Exception("FAKE exception for dumping current CPContainer
1879 // (["+project.getElementName()+"] "+ containerPath+ ")INIT invocation stack
1880 // trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
1882 // JavaModelManager.containerPut(project, containerPath,
1883 // JavaModelManager.ContainerInitializationInProgress); // avoid
1884 // initialization cycles
1885 // boolean ok = false;
1887 // // wrap initializer call with Safe runnable in case initializer would be
1888 // causing some grief
1889 // Platform.run(new ISafeRunnable() {
1890 // public void handleException(Throwable exception) {
1891 // ProjectPrefUtil.log(exception, "Exception occurred in classpath container
1892 // initializer: "+initializer); //$NON-NLS-1$
1894 // public void run() throws Exception {
1895 // initializer.initialize(containerPath, project);
1899 // // retrieve value (if initialization was successful)
1900 // container = JavaModelManager.containerGet(project, containerPath);
1901 // if (container == JavaModelManager.ContainerInitializationInProgress)
1902 // return null; // break cycle
1905 // if (!ok) JavaModelManager.containerPut(project, containerPath, null); //
1908 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1909 // System.out.print("CPContainer INIT - after resolution:
1910 // ["+project.getElementName()+"] " + containerPath + " --> ");
1911 // //$NON-NLS-2$//$NON-NLS-1$//$NON-NLS-3$
1912 // if (container != null){
1913 // System.out.print("container: "+container.getDescription()+" {");
1914 // //$NON-NLS-2$//$NON-NLS-1$
1915 // IClasspathEntry[] entries = container.getClasspathEntries();
1916 // if (entries != null){
1917 // for (int i = 0; i < entries.length; i++){
1918 // if (i > 0) System.out.println(", ");//$NON-NLS-1$
1919 // System.out.println(entries[i]);
1922 // System.out.println("}");//$NON-NLS-1$
1924 // System.out.println("{unbound}");//$NON-NLS-1$
1928 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1929 // System.out.println("CPContainer INIT - no initializer found for:
1930 // "+project.getElementName()+"] " + containerPath); //$NON-NLS-1$
1935 // return container;
1938 * Helper method finding the classpath container initializer registered for
1939 * a given classpath container ID or <code>null</code> if none was found
1940 * while iterating over the contributions to extension point to the
1941 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
1943 * A containerID is the first segment of any container path, used to
1944 * identify the registered container initializer.
1948 * a containerID identifying a registered initializer
1949 * @return ClasspathContainerInitializer - the registered classpath
1950 * container initializer or <code>null</code> if none was found.
1953 //public static ClasspathContainerInitializer
1954 // getClasspathContainerInitializer(String containerID){
1956 // Plugin jdtCorePlugin = JavaCore.getPlugin();
1957 // if (jdtCorePlugin == null) return null;
1959 // IExtensionPoint extension =
1960 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID);
1961 // if (extension != null) {
1962 // IExtension[] extensions = extension.getExtensions();
1963 // for(int i = 0; i < extensions.length; i++){
1964 // IConfigurationElement [] configElements =
1965 // extensions[i].getConfigurationElements();
1966 // for(int j = 0; j < configElements.length; j++){
1967 // String initializerID = configElements[j].getAttribute("id");
1969 // if (initializerID != null && initializerID.equals(containerID)){
1970 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
1971 // System.out.println("CPContainer INIT - found initializer: "+containerID
1973 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
1976 // Object execExt = configElements[j].createExecutableExtension("class");
1978 // if (execExt instanceof ClasspathContainerInitializer){
1979 // return (ClasspathContainerInitializer)execExt;
1981 // } catch(CoreException e) {
1990 * Returns the path held in the given classpath variable. Returns <node>null
1991 * </code> if unable to bind.
1993 * Classpath variable values are persisted locally to the workspace, and are
1994 * preserved from session to session.
1996 * Note that classpath variables can be contributed registered initializers
1997 * for, using the extension point
1998 * "org.eclipse.jdt.core.classpathVariableInitializer". If an initializer is
1999 * registered for a variable, its persisted value will be ignored: its
2000 * initializer will thus get the opportunity to rebind the variable
2001 * differently on each session.
2003 * @param variableName
2004 * the name of the classpath variable
2005 * @return the path, or <code>null</code> if none
2006 * @see #setClasspathVariable
2008 public static IPath getClasspathVariable(final String variableName) {
2010 IPath variablePath = JavaModelManager.variableGet(variableName);
2011 if (variablePath == JavaModelManager.VariableInitializationInProgress)
2012 return null; // break cycle
2014 if (variablePath != null) {
2015 return variablePath;
2018 // even if persisted value exists, initializer is given priority, only
2019 // if no initializer is found the persisted value is reused
2020 // final ClasspathVariableInitializer initializer =
2021 // PHPCore.getClasspathVariableInitializer(variableName);
2022 // if (initializer != null){
2023 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2024 // System.out.println("CPVariable INIT - triggering initialization of: "
2025 // + variableName+ " using initializer: "+ initializer); //$NON-NLS-1$
2027 // new Exception("FAKE exception for dumping current CPVariable
2028 // ("+variableName+ ")INIT invocation stack trace").printStackTrace();
2029 // //$NON-NLS-1$//$NON-NLS-2$
2031 // JavaModelManager.variablePut(variableName,
2032 // JavaModelManager.VariableInitializationInProgress); // avoid
2033 // initialization cycles
2034 // boolean ok = false;
2036 // // wrap initializer call with Safe runnable in case initializer would
2037 // be causing some grief
2038 // Platform.run(new ISafeRunnable() {
2039 // public void handleException(Throwable exception) {
2040 // ProjectPrefUtil.log(exception, "Exception occurred in classpath variable
2041 // initializer: "+initializer+" while initializing variable:
2042 // "+variableName); //$NON-NLS-1$ //$NON-NLS-2$
2044 // public void run() throws Exception {
2045 // initializer.initialize(variableName);
2048 // variablePath = (IPath) JavaModelManager.variableGet(variableName); //
2049 // initializer should have performed side-effect
2050 // if (variablePath ==
2051 // JavaModelManager.VariableInitializationInProgress) return null; //
2052 // break cycle (initializer did not init or reentering call)
2053 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2054 // System.out.println("CPVariable INIT - after initialization: " +
2055 // variableName + " --> " + variablePath); //$NON-NLS-2$//$NON-NLS-1$
2059 // if (!ok) JavaModelManager.variablePut(variableName, null); // flush
2063 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
2064 // System.out.println("CPVariable INIT - no initializer found for: " +
2065 // variableName); //$NON-NLS-1$
2068 return variablePath;
2072 * Helper method finding the classpath variable initializer registered for a
2073 * given classpath variable name or <code>null</code> if none was found
2074 * while iterating over the contributions to extension point to the
2075 * extension point "org.eclipse.jdt.core.classpathVariableInitializer".
2080 * @return ClasspathVariableInitializer - the registered classpath variable
2081 * initializer or <code>null</code> if none was found.
2084 public static ClasspathVariableInitializer getClasspathVariableInitializer(
2087 Plugin jdtCorePlugin = JavaCore.getPlugin();
2088 if (jdtCorePlugin == null)
2091 // IExtensionPoint extension =
2092 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID);
2093 // if (extension != null) {
2094 // IExtension[] extensions = extension.getExtensions();
2095 // for(int i = 0; i < extensions.length; i++){
2096 // IConfigurationElement [] configElements =
2097 // extensions[i].getConfigurationElements();
2098 // for(int j = 0; j < configElements.length; j++){
2100 // String varAttribute = configElements[j].getAttribute("variable");
2102 // if (variable.equals(varAttribute)) {
2103 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
2104 // System.out.println("CPVariable INIT - found initializer: "+variable+"
2106 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
2109 // configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
2110 // if (execExt instanceof ClasspathVariableInitializer){
2111 // return (ClasspathVariableInitializer)execExt;
2114 // } catch(CoreException e){
2123 * Returns the names of all known classpath variables.
2125 * Classpath variable values are persisted locally to the workspace, and are
2126 * preserved from session to session.
2129 * @return the list of classpath variable names
2130 * @see #setClasspathVariable
2132 //public static String[] getClasspathVariableNames() {
2133 // return JavaModelManager.variableNames();
2136 * Returns a table of all known configurable options with their default
2137 * values. These options allow to configure the behaviour of the underlying
2138 * components. The client may safely use the result as a template that they
2139 * can modify and then pass to <code>setOptions</code>.
2141 * Helper constants have been defined on JavaCore for each of the option ID
2142 * and their possible constant values.
2144 * Note: more options might be added in further releases.
2148 * RECOGNIZED OPTIONS:
2149 * COMPILER / Generating Local Variable Debug Attribute
2150 * When generated, this attribute will enable local variable names
2151 * to be displayed in debugger, only in place where variables are
2152 * definitely assigned (.class file is then bigger)
2153 * - option id: "org.eclipse.jdt.core.compiler.debug.localVariable"
2154 * - possible values: { "generate", "do not generate" }
2155 * - default: "generate"
2157 * COMPILER / Generating Line Number Debug Attribute
2158 * When generated, this attribute will enable source code highlighting in debugger
2159 * (.class file is then bigger).
2160 * - option id: "org.eclipse.jdt.core.compiler.debug.lineNumber"
2161 * - possible values: { "generate", "do not generate" }
2162 * - default: "generate"
2164 * COMPILER / Generating Source Debug Attribute
2165 * When generated, this attribute will enable the debugger to present the
2166 * corresponding source code.
2167 * - option id: "org.eclipse.jdt.core.compiler.debug.sourceFile"
2168 * - possible values: { "generate", "do not generate" }
2169 * - default: "generate"
2171 * COMPILER / Preserving Unused Local Variables
2172 * Unless requested to preserve unused local variables (that is, never read), the
2173 * compiler will optimize them out, potentially altering debugging
2174 * - option id: "org.eclipse.jdt.core.compiler.codegen.unusedLocal"
2175 * - possible values: { "preserve", "optimize out" }
2176 * - default: "preserve"
2178 * COMPILER / Defining Target Java Platform
2179 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
2180 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
2181 * - option id: "org.eclipse.jdt.core.compiler.codegen.targetPlatform"
2182 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
2183 * - default: "1.1"
2185 * COMPILER / Reporting Unreachable Code
2186 * Unreachable code can optionally be reported as an error, warning or simply
2187 * ignored. The bytecode generation will always optimized it out.
2188 * - option id: "org.eclipse.jdt.core.compiler.problem.unreachableCode"
2189 * - possible values: { "error", "warning", "ignore" }
2190 * - default: "error"
2192 * COMPILER / Reporting Invalid Import
2193 * An import statement that cannot be resolved might optionally be reported
2194 * as an error, as a warning or ignored.
2195 * - option id: "org.eclipse.jdt.core.compiler.problem.invalidImport"
2196 * - possible values: { "error", "warning", "ignore" }
2197 * - default: "error"
2199 * COMPILER / Reporting Attempt to Override Package-Default Method
2200 * A package default method is not visible in a different package, and thus
2201 * cannot be overridden. When enabling this option, the compiler will signal
2202 * such scenarii either as an error or a warning.
2203 * - option id: "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"
2204 * - possible values: { "error", "warning", "ignore" }
2205 * - default: "warning"
2207 * COMPILER / Reporting Method With Constructor Name
2208 * Naming a method with a constructor name is generally considered poor
2209 * style programming. When enabling this option, the compiler will signal such
2210 * scenarii either as an error or a warning.
2211 * - option id: "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"
2212 * - possible values: { "error", "warning", "ignore" }
2213 * - default: "warning"
2215 * COMPILER / Reporting Deprecation
2216 * When enabled, the compiler will signal use of deprecated API either as an
2217 * error or a warning.
2218 * - option id: "org.eclipse.jdt.core.compiler.problem.deprecation"
2219 * - possible values: { "error", "warning", "ignore" }
2220 * - default: "warning"
2222 * COMPILER / Reporting Deprecation Inside Deprecated Code
2223 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
2224 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.deprecation".
2225 * - option id: "org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode"
2226 * - possible values: { "enabled", "disabled" }
2227 * - default: "disabled"
2229 * COMPILER / Reporting Hidden Catch Block
2230 * Locally to a try statement, some catch blocks may hide others . For example,
2231 * try { throw new java.io.CharConversionException();
2232 * } catch (java.io.CharConversionException e) {
2233 * } catch (java.io.IOException e) {}.
2234 * When enabling this option, the compiler will issue an error or a warning for hidden
2235 * catch blocks corresponding to checked exceptions
2236 * - option id: "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"
2237 * - possible values: { "error", "warning", "ignore" }
2238 * - default: "warning"
2240 * COMPILER / Reporting Unused Local
2241 * When enabled, the compiler will issue an error or a warning for unused local
2242 * variables (that is, variables never read from)
2243 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedLocal"
2244 * - possible values: { "error", "warning", "ignore" }
2245 * - default: "ignore"
2247 * COMPILER / Reporting Unused Parameter
2248 * When enabled, the compiler will issue an error or a warning for unused method
2249 * parameters (that is, parameters never read from)
2250 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameter"
2251 * - possible values: { "error", "warning", "ignore" }
2252 * - default: "ignore"
2254 * COMPILER / Reporting Unused Parameter if Implementing Abstract Method
2255 * When enabled, the compiler will signal unused parameters in abstract method implementations.
2256 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
2257 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"
2258 * - possible values: { "enabled", "disabled" }
2259 * - default: "disabled"
2261 * COMPILER / Reporting Unused Parameter if Overriding Concrete Method
2262 * When enabled, the compiler will signal unused parameters in methods overriding concrete ones.
2263 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
2264 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"
2265 * - possible values: { "enabled", "disabled" }
2266 * - default: "disabled"
2268 * COMPILER / Reporting Unused Import
2269 * When enabled, the compiler will issue an error or a warning for unused import
2271 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedImport"
2272 * - possible values: { "error", "warning", "ignore" }
2273 * - default: "warning"
2275 * COMPILER / Reporting Unused Private Members
2276 * When enabled, the compiler will issue an error or a warning whenever a private
2277 * method or field is declared but never used within the same unit.
2278 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"
2279 * - possible values: { "error", "warning", "ignore" }
2280 * - default: "ignore"
2282 * COMPILER / Reporting Synthetic Access Emulation
2283 * When enabled, the compiler will issue an error or a warning whenever it emulates
2284 * access to a non-accessible member of an enclosing type. Such access can have
2285 * performance implications.
2286 * - option id: "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"
2287 * - possible values: { "error", "warning", "ignore" }
2288 * - default: "ignore"
2290 * COMPILER / Reporting Non-Externalized String Literal
2291 * When enabled, the compiler will issue an error or a warning for non externalized
2292 * String literal (that is, not tagged with //$NON-NLS-<n>$).
2293 * - option id: "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"
2294 * - possible values: { "error", "warning", "ignore" }
2295 * - default: "ignore"
2297 * COMPILER / Reporting Usage of 'assert' Identifier
2298 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
2299 * used as an identifier (reserved keyword in 1.4)
2300 * - option id: "org.eclipse.jdt.core.compiler.problem.assertIdentifier"
2301 * - possible values: { "error", "warning", "ignore" }
2302 * - default: "ignore"
2304 * COMPILER / Reporting Non-Static Reference to a Static Member
2305 * When enabled, the compiler will issue an error or a warning whenever a static field
2306 * or method is accessed with an expression receiver. A reference to a static member should
2307 * be qualified with a type name.
2308 * - option id: "org.eclipse.jdt.core.compiler.problem.staticAccessReceiver"
2309 * - possible values: { "error", "warning", "ignore" }
2310 * - default: "warning"
2312 * COMPILER / Reporting Assignment with no Effect
2313 * When enabled, the compiler will issue an error or a warning whenever an assignment
2314 * has no effect (e.g 'x = x').
2315 * - option id: "org.eclipse.jdt.core.compiler.problem.noEffectAssignment"
2316 * - possible values: { "error", "warning", "ignore" }
2317 * - default: "warning"
2319 * COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods
2320 * When enabled, the compiler will issue an error or a warning whenever an interface
2321 * defines a method incompatible with a non-inherited Object method. Until this conflict
2322 * is resolved, such an interface cannot be implemented, For example,
2326 * - option id: "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"
2327 * - possible values: { "error", "warning", "ignore" }
2328 * - default: "warning"
2330 * COMPILER / Reporting Usage of char[] Expressions in String Concatenations
2331 * When enabled, the compiler will issue an error or a warning whenever a char[] expression
2332 * is used in String concatenations (for example, "hello" + new char[]{'w','o','r','l','d'}).
2333 * - option id: "org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion"
2334 * - possible values: { "error", "warning", "ignore" }
2335 * - default: "warning"
2337 * COMPILER / Setting Source Compatibility Mode
2338 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
2339 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
2340 * level should be set to "1.4" and the compliance mode should be "1.4".
2341 * - option id: "org.eclipse.jdt.core.compiler.source"
2342 * - possible values: { "1.3", "1.4" }
2343 * - default: "1.3"
2345 * COMPILER / Setting Compliance Level
2346 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
2347 * should not go beyond "1.3" level.
2348 * - option id: "org.eclipse.jdt.core.compiler.compliance"
2349 * - possible values: { "1.3", "1.4" }
2350 * - default: "1.3"
2352 * COMPILER / Maximum number of problems reported per compilation unit
2353 * Specify the maximum number of problems reported on each compilation unit.
2354 * - option id: "org.eclipse.jdt.core.compiler.maxProblemPerUnit"
2355 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
2356 * - default: "100"
2358 * COMPILER / Define the Automatic Task Tags
2359 * When the tag list is not empty, the compiler will issue a task marker whenever it encounters
2360 * one of the corresponding tag inside any comment in Java source code.
2361 * Generated task messages will include the tag, and range until the next line separator or comment ending.
2362 * Note that tasks messages are trimmed.
2363 * - option id: "org.eclipse.jdt.core.compiler.taskTags"
2364 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card or leading/trailing spaces
2365 * - default: ""
2367 * COMPILER / Define the Automatic Task Priorities
2368 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
2369 * of the task markers issued by the compiler.
2370 * If the default is specified, the priority of each task marker is "NORMAL".
2371 * - option id: "org.eclipse.jdt.core.compiler.taskPriorities"
2372 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
2373 * - default: ""
2375 * BUILDER / Specifying Filters for Resource Copying Control
2376 * Allow to specify some filters to control the resource copy process.
2377 * - option id: "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
2378 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
2379 * or the name of a folder which ends with '/'
2380 * - default: ""
2382 * BUILDER / Abort if Invalid Classpath
2383 * Allow to toggle the builder to abort if the classpath is invalid
2384 * - option id: "org.eclipse.jdt.core.builder.invalidClasspath"
2385 * - possible values: { "abort", "ignore" }
2386 * - default: "abort"
2388 * BUILDER / Cleaning Output Folder(s)
2389 * Indicate whether the JavaBuilder is allowed to clean the output folders
2390 * when performing full build operations.
2391 * - option id: "org.eclipse.jdt.core.builder.cleanOutputFolder"
2392 * - possible values: { "clean", "ignore" }
2393 * - default: "clean"
2395 * BUILDER / Reporting Duplicate Resources
2396 * Indicate the severity of the problem reported when more than one occurrence
2397 * of a resource is to be copied into the output location.
2398 * - option id: "org.eclipse.jdt.core.builder.duplicateResourceTask"
2399 * - possible values: { "error", "warning" }
2400 * - default: "warning"
2402 * JAVACORE / Computing Project Build Order
2403 * Indicate whether JavaCore should enforce the project build order to be based on
2404 * the classpath prerequisite chain. When requesting to compute, this takes over
2405 * the platform default order (based on project references).
2406 * - option id: "org.eclipse.jdt.core.computeJavaBuildOrder"
2407 * - possible values: { "compute", "ignore" }
2408 * - default: "ignore"
2410 * JAVACORE / Specify Default Source Encoding Format
2411 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
2412 * to 'ResourcesPlugin.getEncoding()'.
2413 * - option id: "org.eclipse.jdt.core.encoding"
2414 * - possible values: { any of the supported encoding name}.
2415 * - default: <platform default>
2417 * JAVACORE / Reporting Incomplete Classpath
2418 * Indicate the severity of the problem reported when an entry on the classpath does not exist,
2419 * is not legite or is not visible (for example, a referenced project is closed).
2420 * - option id: "org.eclipse.jdt.core.incompleteClasspath"
2421 * - possible values: { "error", "warning"}
2422 * - default: "error"
2424 * JAVACORE / Reporting Classpath Cycle
2425 * Indicate the severity of the problem reported when a project is involved in a cycle.
2426 * - option id: "org.eclipse.jdt.core.circularClasspath"
2427 * - possible values: { "error", "warning" }
2428 * - default: "error"
2430 * JAVACORE / Enabling Usage of Classpath Exclusion Patterns
2431 * When disabled, no entry on a project classpath can be associated with
2432 * an exclusion pattern.
2433 * - option id: "org.eclipse.jdt.core.classpath.exclusionPatterns"
2434 * - possible values: { "enabled", "disabled" }
2435 * - default: "enabled"
2437 * JAVACORE / Enabling Usage of Classpath Multiple Output Locations
2438 * When disabled, no entry on a project classpath can be associated with
2439 * a specific output location, preventing thus usage of multiple output locations.
2440 * - option id: "org.eclipse.jdt.core.classpath.multipleOutputLocations"
2441 * - possible values: { "enabled", "disabled" }
2442 * - default: "enabled"
2444 * FORMATTER / Inserting New Line Before Opening Brace
2445 * When Insert, a new line is inserted before an opening brace, otherwise nothing
2447 * - option id: "org.eclipse.jdt.core.formatter.newline.openingBrace"
2448 * - possible values: { "insert", "do not insert" }
2449 * - default: "do not insert"
2451 * FORMATTER / Inserting New Line Inside Control Statement
2452 * When Insert, a new line is inserted between } and following else, catch, finally
2453 * - option id: "org.eclipse.jdt.core.formatter.newline.controlStatement"
2454 * - possible values: { "insert", "do not insert" }
2455 * - default: "do not insert"
2457 * FORMATTER / Clearing Blank Lines
2458 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
2459 * and all others removed.
2460 * - option id: "org.eclipse.jdt.core.formatter.newline.clearAll"
2461 * - possible values: { "clear all", "preserve one" }
2462 * - default: "preserve one"
2464 * FORMATTER / Inserting New Line Between Else/If
2465 * When Insert, a blank line is inserted between an else and an if when they are
2466 * contiguous. When choosing to not insert, else-if will be kept on the same
2467 * line when possible.
2468 * - option id: "org.eclipse.jdt.core.formatter.newline.elseIf"
2469 * - possible values: { "insert", "do not insert" }
2470 * - default: "do not insert"
2472 * FORMATTER / Inserting New Line In Empty Block
2473 * When insert, a line break is inserted between contiguous { and }, if } is not followed
2475 * - option id: "org.eclipse.jdt.core.formatter.newline.emptyBlock"
2476 * - possible values: { "insert", "do not insert" }
2477 * - default: "insert"
2479 * FORMATTER / Splitting Lines Exceeding Length
2480 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
2481 * disable line splitting
2482 * - option id: "org.eclipse.jdt.core.formatter.lineSplit"
2483 * - possible values: "<n>", where n is zero or a positive integer
2484 * - default: "80"
2486 * FORMATTER / Compacting Assignment
2487 * Assignments can be formatted asymmetrically, for example 'int x= 2;', when Normal, a space
2488 * is inserted before the assignment operator
2489 * - option id: "org.eclipse.jdt.core.formatter.style.assignment"
2490 * - possible values: { "compact", "normal" }
2491 * - default: "normal"
2493 * FORMATTER / Defining Indentation Character
2494 * Either choose to indent with tab characters or spaces
2495 * - option id: "org.eclipse.jdt.core.formatter.tabulation.char"
2496 * - possible values: { "tab", "space" }
2497 * - default: "tab"
2499 * FORMATTER / Defining Space Indentation Length
2500 * When using spaces, set the amount of space characters to use for each
2502 * - option id: "org.eclipse.jdt.core.formatter.tabulation.size"
2503 * - possible values: "<n>", where n is a positive integer
2504 * - default: "4"
2506 * FORMATTER / Inserting space in cast expression
2507 * When Insert, a space is added between the type and the expression in a cast expression.
2508 * - option id: "org.eclipse.jdt.core.formatter.space.castexpression"
2509 * - possible values: { "insert", "do not insert" }
2510 * - default: "insert"
2512 * CODEASSIST / Activate Visibility Sensitive Completion
2513 * When active, completion doesn't show that you can not see
2514 * (for example, you can not see private methods of a super class).
2515 * - option id: "org.eclipse.jdt.core.codeComplete.visibilityCheck"
2516 * - possible values: { "enabled", "disabled" }
2517 * - default: "disabled"
2519 * CODEASSIST / Automatic Qualification of Implicit Members
2520 * When active, completion automatically qualifies completion on implicit
2521 * field references and message expressions.
2522 * - option id: "org.eclipse.jdt.core.codeComplete.forceImplicitQualification"
2523 * - possible values: { "enabled", "disabled" }
2524 * - default: "disabled"
2526 * CODEASSIST / Define the Prefixes for Field Name
2527 * When the prefixes is non empty, completion for field name will begin with
2528 * one of the proposed prefixes.
2529 * - option id: "org.eclipse.jdt.core.codeComplete.fieldPrefixes"
2530 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2531 * - default: ""
2533 * CODEASSIST / Define the Prefixes for Static Field Name
2534 * When the prefixes is non empty, completion for static field name will begin with
2535 * one of the proposed prefixes.
2536 * - option id: "org.eclipse.jdt.core.codeComplete.staticFieldPrefixes"
2537 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2538 * - default: ""
2540 * CODEASSIST / Define the Prefixes for Local Variable Name
2541 * When the prefixes is non empty, completion for local variable name will begin with
2542 * one of the proposed prefixes.
2543 * - option id: "org.eclipse.jdt.core.codeComplete.localPrefixes"
2544 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2545 * - default: ""
2547 * CODEASSIST / Define the Prefixes for Argument Name
2548 * When the prefixes is non empty, completion for argument name will begin with
2549 * one of the proposed prefixes.
2550 * - option id: "org.eclipse.jdt.core.codeComplete.argumentPrefixes"
2551 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2552 * - default: ""
2554 * CODEASSIST / Define the Suffixes for Field Name
2555 * When the suffixes is non empty, completion for field name will end with
2556 * one of the proposed suffixes.
2557 * - option id: "org.eclipse.jdt.core.codeComplete.fieldSuffixes"
2558 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2559 * - default: ""
2561 * CODEASSIST / Define the Suffixes for Static Field Name
2562 * When the suffixes is non empty, completion for static field name will end with
2563 * one of the proposed suffixes.
2564 * - option id: "org.eclipse.jdt.core.codeComplete.staticFieldSuffixes"
2565 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2566 * - default: ""
2568 * CODEASSIST / Define the Suffixes for Local Variable Name
2569 * When the suffixes is non empty, completion for local variable name will end with
2570 * one of the proposed suffixes.
2571 * - option id: "org.eclipse.jdt.core.codeComplete.localSuffixes"
2572 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2573 * - default: ""
2575 * CODEASSIST / Define the Suffixes for Argument Name
2576 * When the suffixes is non empty, completion for argument name will end with
2577 * one of the proposed suffixes.
2578 * - option id: "org.eclipse.jdt.core.codeComplete.argumentSuffixes"
2579 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
2580 * - default: ""
2583 * @return a mutable table containing the default settings of all known options
2596 public static Hashtable getDefaultOptions() {
2598 Hashtable defaultOptions = new Hashtable(10);
2600 // see #initializeDefaultPluginPreferences() for changing default
2602 Preferences preferences = getPlugin().getPluginPreferences();
2603 HashSet optionNames = JavaModelManager.OptionNames;
2605 // get preferences set to their default
2606 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2607 for (int i = 0; i < defaultPropertyNames.length; i++) {
2608 String propertyName = defaultPropertyNames[i];
2609 if (optionNames.contains(propertyName)) {
2610 defaultOptions.put(propertyName, preferences
2611 .getDefaultString(propertyName));
2614 // get preferences not set to their default
2615 String[] propertyNames = preferences.propertyNames();
2616 for (int i = 0; i < propertyNames.length; i++) {
2617 String propertyName = propertyNames[i];
2618 if (optionNames.contains(propertyName)) {
2619 defaultOptions.put(propertyName, preferences
2620 .getDefaultString(propertyName));
2623 // get encoding through resource plugin
2624 defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2626 return defaultOptions;
2630 * Returns the single instance of the Java core plug-in runtime class.
2631 * Equivalent to <code>(JavaCore) getPlugin()</code>.
2633 * @return the single instance of the Java core plug-in runtime class
2635 public static PHPeclipsePlugin getJavaCore() {
2636 return (PHPeclipsePlugin) getPlugin();
2640 * Helper method for returning one option value only. Equivalent to
2641 * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
2642 * may answer <code>null</code> if this option does not exist.
2644 * For a complete description of the configurable options, see
2645 * <code>getDefaultOptions</code>.
2649 * the name of an option
2650 * @return the String value of a given option
2651 * @see JavaCore#getDefaultOptions
2654 public static String getOption(String optionName) {
2656 if (CORE_ENCODING.equals(optionName)) {
2657 return ResourcesPlugin.getEncoding();
2659 if (JavaModelManager.OptionNames.contains(optionName)) {
2660 Preferences preferences = getPlugin().getPluginPreferences();
2661 return preferences.getString(optionName).trim();
2667 * Returns the table of the current options. Initially, all options have
2668 * their default values, and this method returns a table that includes all
2671 * For a complete description of the configurable options, see
2672 * <code>getDefaultOptions</code>.
2675 * @return table of current settings of all options (key type:
2676 * <code>String</code>; value type: <code>String</code>)
2677 * @see JavaCore#getDefaultOptions
2679 public static Hashtable getOptions() {
2681 Hashtable options = new Hashtable(10);
2683 // see #initializeDefaultPluginPreferences() for changing default
2685 Plugin plugin = getPlugin();
2686 if (plugin != null) {
2687 Preferences preferences = getPlugin().getPluginPreferences();
2688 HashSet optionNames = JavaModelManager.OptionNames;
2690 // get preferences set to their default
2691 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2692 for (int i = 0; i < defaultPropertyNames.length; i++) {
2693 String propertyName = defaultPropertyNames[i];
2694 if (optionNames.contains(propertyName)) {
2695 options.put(propertyName, preferences
2696 .getDefaultString(propertyName));
2699 // get preferences not set to their default
2700 String[] propertyNames = preferences.propertyNames();
2701 for (int i = 0; i < propertyNames.length; i++) {
2702 String propertyName = propertyNames[i];
2703 if (optionNames.contains(propertyName)) {
2704 options.put(propertyName, preferences.getString(
2705 propertyName).trim());
2708 // get encoding through resource plugin
2709 options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2715 * This is a helper method, which returns the resolved classpath entry
2716 * denoted by a given entry (if it is a variable entry). It is obtained by
2717 * resolving the variable reference in the first segment. Returns <node>null
2718 * </code> if unable to resolve using the following algorithm:
2720 * <li>if variable segment cannot be resolved, returns <code>null</code>
2722 * <li>finds a project, JAR or binary folder in the workspace at the
2723 * resolved path location</li>
2724 * <li>if none finds an external JAR file or folder outside the workspace
2725 * at the resolved path location</li>
2726 * <li>if none returns <code>null</code></li>
2729 * Variable source attachment path and root path are also resolved and
2730 * recorded in the resulting classpath entry.
2732 * NOTE: This helper method does not handle classpath containers, for which
2733 * should rather be used <code>JavaCore#getClasspathContainer(IPath,
2734 * IJavaProject)</code>.
2738 * the given variable entry
2739 * @return the resolved library or project classpath entry, or <code>null
2740 * </code> if the given variable entry could not be resolved to a
2741 * valid classpath entry
2743 public static IClasspathEntry getResolvedClasspathEntry(
2744 IClasspathEntry entry) {
2746 if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
2749 IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
2750 IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath());
2751 if (resolvedPath == null)
2754 Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false);
2758 // inside the workspace
2759 if (target instanceof IResource) {
2760 IResource resolvedResource = (IResource) target;
2761 if (resolvedResource != null) {
2762 switch (resolvedResource.getType()) {
2764 case IResource.PROJECT:
2766 return JavaCore.newProjectEntry(resolvedPath, entry
2769 case IResource.FILE:
2770 // if (ProjectPrefUtil.isArchiveFileName(resolvedResource.getName())) {
2771 // // internal binary archive
2772 // return JavaCore.newLibraryEntry(
2774 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2775 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2776 // entry.isExported());
2780 case IResource.FOLDER:
2781 // internal binary folder
2782 // return JavaCore.newLibraryEntry(
2784 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2785 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2786 // entry.isExported());
2791 // outside the workspace
2792 if (target instanceof File) {
2793 File externalFile = (File) target;
2794 if (externalFile.isFile()) {
2795 String fileName = externalFile.getName().toLowerCase();
2796 // if (fileName.endsWith(".jar" //$NON-NLS-1$
2797 // ) || fileName.endsWith(".zip" //$NON-NLS-1$
2798 // )) { // external binary archive
2799 // return JavaCore.newLibraryEntry(
2801 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2802 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2803 // entry.isExported());
2805 } else { // external binary folder
2806 if (resolvedPath.isAbsolute()) {
2807 // return JavaCore.newLibraryEntry(
2809 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2810 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2811 // entry.isExported());
2819 * Resolve a variable path (helper method).
2821 * @param variablePath
2822 * the given variable path
2823 * @return the resolved variable path or <code>null</code> if none
2825 public static IPath getResolvedVariablePath(IPath variablePath) {
2827 if (variablePath == null)
2829 int count = variablePath.segmentCount();
2834 String variableName = variablePath.segment(0);
2835 IPath resolvedPath = JavaCore.getClasspathVariable(variableName);
2836 if (resolvedPath == null)
2839 // append path suffix
2841 resolvedPath = resolvedPath.append(variablePath
2842 .removeFirstSegments(1));
2844 return resolvedPath;
2848 * Answers the shared working copies currently registered for this buffer
2849 * factory. Working copies can be shared by several clients using the same
2850 * buffer factory,see <code>IWorkingCopy.getSharedWorkingCopy</code>.
2853 * the given buffer factory
2854 * @return the list of shared working copies for a given buffer factory
2858 public static IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory) {
2860 // if factory is null, default factory must be used
2861 if (factory == null)
2862 factory = BufferManager.getDefaultBufferManager()
2863 .getDefaultBufferFactory();
2864 Map sharedWorkingCopies = JavaModelManager.getJavaModelManager().sharedWorkingCopies;
2866 Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
2867 if (perFactoryWorkingCopies == null)
2868 return JavaModelManager.NoWorkingCopy;
2869 Collection copies = perFactoryWorkingCopies.values();
2870 IWorkingCopy[] result = new IWorkingCopy[copies.size()];
2871 copies.toArray(result);
2876 * Initializes the default preferences settings for this plug-in.
2878 public static void initializeDefaultPluginPreferences() {
2880 Preferences preferences = PHPeclipsePlugin.getDefault()
2881 .getPluginPreferences();
2882 HashSet optionNames = JavaModelManager.OptionNames;
2884 // Compiler settings
2885 preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
2886 optionNames.add(COMPILER_LOCAL_VARIABLE_ATTR);
2888 preferences.setDefault(COMPILER_LINE_NUMBER_ATTR, GENERATE);
2889 optionNames.add(COMPILER_LINE_NUMBER_ATTR);
2891 preferences.setDefault(COMPILER_SOURCE_FILE_ATTR, GENERATE);
2892 optionNames.add(COMPILER_SOURCE_FILE_ATTR);
2894 preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE);
2895 optionNames.add(COMPILER_CODEGEN_UNUSED_LOCAL);
2897 preferences.setDefault(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1);
2898 optionNames.add(COMPILER_CODEGEN_TARGET_PLATFORM);
2900 preferences.setDefault(COMPILER_PB_PHP_VAR_DEPRECATED, WARNING);
2901 optionNames.add(COMPILER_PB_PHP_VAR_DEPRECATED);
2902 preferences.setDefault(COMPILER_PB_PHP_KEYWORD, WARNING);
2903 optionNames.add(COMPILER_PB_PHP_KEYWORD);
2904 preferences.setDefault(COMPILER_PB_PHP_UPPERCASE_IDENTIFIER, IGNORE);
2905 optionNames.add(COMPILER_PB_PHP_UPPERCASE_IDENTIFIER);
2906 preferences.setDefault(COMPILER_PB_PHP_FILE_NOT_EXIST, WARNING);
2907 optionNames.add(COMPILER_PB_PHP_FILE_NOT_EXIST);
2909 preferences.setDefault(COMPILER_PB_UNREACHABLE_CODE, ERROR);
2910 optionNames.add(COMPILER_PB_UNREACHABLE_CODE);
2912 preferences.setDefault(COMPILER_PB_INVALID_IMPORT, ERROR);
2913 optionNames.add(COMPILER_PB_INVALID_IMPORT);
2915 preferences.setDefault(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD,
2917 optionNames.add(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD);
2919 preferences.setDefault(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME,
2921 optionNames.add(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME);
2923 preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING);
2924 optionNames.add(COMPILER_PB_DEPRECATION);
2926 preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE,
2928 optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE);
2930 preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING);
2931 optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK);
2933 preferences.setDefault(COMPILER_PB_UNUSED_LOCAL, IGNORE);
2934 optionNames.add(COMPILER_PB_UNUSED_LOCAL);
2936 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE);
2937 optionNames.add(COMPILER_PB_UNUSED_PARAMETER);
2939 preferences.setDefault(
2940 COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT,
2943 .add(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT);
2947 COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE,
2949 optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE);
2951 preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING);
2952 optionNames.add(COMPILER_PB_UNUSED_IMPORT);
2954 preferences.setDefault(COMPILER_PB_UNUSED_PRIVATE_MEMBER, IGNORE);
2955 optionNames.add(COMPILER_PB_UNUSED_PRIVATE_MEMBER);
2957 preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE);
2958 optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION);
2960 preferences.setDefault(COMPILER_PB_NON_NLS_STRING_LITERAL, IGNORE);
2961 optionNames.add(COMPILER_PB_NON_NLS_STRING_LITERAL);
2963 preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE);
2964 optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER);
2966 preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING);
2967 optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER);
2969 preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING);
2970 optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT);
2972 preferences.setDefault(
2973 COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD,
2976 .add(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD);
2978 preferences.setDefault(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION,
2980 optionNames.add(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION);
2982 preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAG); //$NON-NLS-1$
2983 optionNames.add(COMPILER_TASK_TAGS);
2985 preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITY); //$NON-NLS-1$
2986 optionNames.add(COMPILER_TASK_PRIORITIES);
2988 preferences.setDefault(COMPILER_SOURCE, VERSION_1_3);
2989 optionNames.add(COMPILER_SOURCE);
2991 preferences.setDefault(COMPILER_COMPLIANCE, VERSION_1_3);
2992 optionNames.add(COMPILER_COMPLIANCE);
2994 preferences.setDefault(COMPILER_PB_MAX_PER_UNIT, "100"); //$NON-NLS-1$
2995 optionNames.add(COMPILER_PB_MAX_PER_UNIT);
2998 preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
2999 optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
3001 preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT);
3002 optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH);
3004 preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING);
3005 optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE);
3007 preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN);
3008 optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER);
3010 // JavaCore settings
3011 preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE);
3012 optionNames.add(CORE_JAVA_BUILD_ORDER);
3014 preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR);
3015 optionNames.add(CORE_CIRCULAR_CLASSPATH);
3017 preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR);
3018 optionNames.add(CORE_INCOMPLETE_CLASSPATH);
3020 preferences.setDefault(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS,
3022 optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS);
3024 preferences.setDefault(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS,
3026 optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS);
3028 // encoding setting comes from resource plug-in
3029 optionNames.add(CORE_ENCODING);
3031 // Formatter settings
3032 preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT);
3033 optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE);
3035 preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT);
3036 optionNames.add(FORMATTER_NEWLINE_CONTROL);
3038 preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE);
3039 optionNames.add(FORMATTER_CLEAR_BLANK_LINES);
3041 preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT);
3042 optionNames.add(FORMATTER_NEWLINE_ELSE_IF);
3044 preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT);
3045 optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK);
3047 preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$
3048 optionNames.add(FORMATTER_LINE_SPLIT);
3050 preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL);
3051 optionNames.add(FORMATTER_COMPACT_ASSIGNMENT);
3053 preferences.setDefault(FORMATTER_TAB_CHAR, TAB);
3054 optionNames.add(FORMATTER_TAB_CHAR);
3056 preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$
3057 optionNames.add(FORMATTER_TAB_SIZE);
3059 preferences.setDefault(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$
3060 optionNames.add(FORMATTER_SPACE_CASTEXPRESSION);
3062 // CodeAssist settings
3063 preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$
3064 optionNames.add(CODEASSIST_VISIBILITY_CHECK);
3066 preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$
3067 optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION);
3069 preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
3070 optionNames.add(CODEASSIST_FIELD_PREFIXES);
3072 preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
3073 optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES);
3075 preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
3076 optionNames.add(CODEASSIST_LOCAL_PREFIXES);
3078 preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
3079 optionNames.add(CODEASSIST_ARGUMENT_PREFIXES);
3081 preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3082 optionNames.add(CODEASSIST_FIELD_SUFFIXES);
3084 preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3085 optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES);
3087 preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
3088 optionNames.add(CODEASSIST_LOCAL_SUFFIXES);
3090 preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
3091 optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES);
3095 * Returns whether the given marker references the given Java element. Used
3096 * for markers, which denote a Java element rather than a resource.
3102 * @return <code>true</code> if the marker references the element, false
3104 * @exception CoreException
3105 * if the <code>IMarker.getAttribute</code> on the marker
3108 public static boolean isReferencedBy(IJavaElement element, IMarker marker)
3109 throws CoreException {
3111 // only match units or classfiles
3112 if (element instanceof IMember) {
3113 IMember member = (IMember) element;
3114 if (member.isBinary()) {
3115 element = null; //member.getClassFile();
3117 element = member.getCompilationUnit();
3120 if (element == null)
3125 String markerHandleId = (String) marker.getAttribute(ATT_HANDLE_ID);
3126 if (markerHandleId == null)
3129 IJavaElement markerElement = JavaCore.create(markerHandleId);
3131 if (element.equals(markerElement))
3132 return true; // external elements may still be equal with different
3135 // cycle through enclosing types in case marker is associated with a
3136 // classfile (15568)
3137 // if (markerElement instanceof IClassFile){
3138 // IType enclosingType =
3139 // ((IClassFile)markerElement).getType().getDeclaringType();
3140 // if (enclosingType != null){
3141 // markerElement = enclosingType.getClassFile(); // retry with immediate
3142 // enclosing classfile
3152 * Returns whether the given marker delta references the given Java element.
3153 * Used for markers deltas, which denote a Java element rather than a
3158 * @param markerDelta
3160 * @return <code>true</code> if the marker delta references the element
3161 * @exception CoreException
3162 * if the <code>IMarkerDelta.getAttribute</code> on the
3163 * marker delta fails
3165 public static boolean isReferencedBy(IJavaElement element,
3166 IMarkerDelta markerDelta) throws CoreException {
3168 // only match units or classfiles
3169 if (element instanceof IMember) {
3170 IMember member = (IMember) element;
3171 if (member.isBinary()) {
3172 element = null; //member.getClassFile();
3174 element = member.getCompilationUnit();
3177 if (element == null)
3179 if (markerDelta == null)
3182 String markerDeltarHandleId = (String) markerDelta
3183 .getAttribute(ATT_HANDLE_ID);
3184 if (markerDeltarHandleId == null)
3187 IJavaElement markerElement = JavaCore.create(markerDeltarHandleId);
3189 if (element.equals(markerElement))
3190 return true; // external elements may still be equal with different
3193 // cycle through enclosing types in case marker is associated with a
3194 // classfile (15568)
3195 // if (markerElement instanceof IClassFile){
3196 // IType enclosingType =
3197 // ((IClassFile)markerElement).getType().getDeclaringType();
3198 // if (enclosingType != null){
3199 // markerElement = enclosingType.getClassFile(); // retry with immediate
3200 // enclosing classfile
3210 * Creates and returns a new classpath entry of kind
3211 * <code>CPE_CONTAINER</code> for the given path. The path of the
3212 * container will be used during resolution so as to map this container
3213 * entry to a set of other classpath entries the container is acting for.
3215 * A container entry allows to express indirect references to a set of
3216 * libraries, projects and variable entries, which can be interpreted
3217 * differently for each Java project where it is used. A classpath container
3218 * entry can be resolved using
3219 * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3220 * <code>JavaCore.classpathContainerChanged</code>
3222 * A container is exclusively resolved by a
3223 * <code>ClasspathContainerInitializer</code> registered onto the
3224 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3226 * A container path must be formed of at least one segment, where:
3228 * <li>the first segment is a unique ID identifying the target container,
3229 * there must be a container initializer registered onto this ID through the
3230 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3232 * <li>the remaining segments will be passed onto the initializer, and can
3233 * be used as additional hints during the initialization phase.</li>
3236 * Example of an ClasspathContainerInitializer for a classpath container
3237 * denoting a default JDK container:
3239 * containerEntry = JavaCore.newContainerEntry(new
3240 * Path("MyProvidedJDK/default"));
3242 * <extension point="org.eclipse.jdt.core.classpathContainerInitializer">
3243 * <containerInitializer id="MyProvidedJDK"
3244 * class="com.example.MyInitializer"/>
3246 * Note that this operation does not attempt to validate classpath
3247 * containers or access the resources at the given paths.
3249 * The resulting entry is not exported to dependent projects. This method is
3250 * equivalent to <code>newContainerEntry(-,false)</code>.
3253 * @param containerPath
3254 * the path identifying the container, it must be formed of two
3256 * @return a new container classpath entry
3258 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3259 * @see JavaCore#newContainerEntry(IPath, boolean)
3262 public static IClasspathEntry newContainerEntry(IPath containerPath) {
3264 return newContainerEntry(containerPath, false);
3268 * Creates and returns a new classpath entry of kind
3269 * <code>CPE_CONTAINER</code> for the given path. The path of the
3270 * container will be used during resolution so as to map this container
3271 * entry to a set of other classpath entries the container is acting for.
3273 * A container entry allows to express indirect references to a set of
3274 * libraries, projects and variable entries, which can be interpreted
3275 * differently for each Java project where it is used. A classpath container
3276 * entry can be resolved using
3277 * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3278 * <code>JavaCore.classpathContainerChanged</code>
3280 * A container is exclusively resolved by a
3281 * <code>ClasspathContainerInitializer</code> registered onto the
3282 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3284 * A container path must be formed of at least one segment, where:
3286 * <li>the first segment is a unique ID identifying the target container,
3287 * there must be a container initializer registered onto this ID through the
3288 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3290 * <li>the remaining segments will be passed onto the initializer, and can
3291 * be used as additional hints during the initialization phase.</li>
3294 * Example of an ClasspathContainerInitializer for a classpath container
3295 * denoting a default JDK container:
3297 * containerEntry = JavaCore.newContainerEntry(new
3298 * Path("MyProvidedJDK/default"));
3300 * <extension point="org.eclipse.jdt.core.classpathContainerInitializer">
3301 * <containerInitializer id="MyProvidedJDK"
3302 * class="com.example.MyInitializer"/>
3304 * Note that this operation does not attempt to validate classpath
3305 * containers or access the resources at the given paths.
3308 * @param containerPath
3309 * the path identifying the container, it must be formed of at
3310 * least one segment (ID+hints)
3312 * a boolean indicating whether this entry is contributed to
3313 * dependent projects in addition to the output location
3314 * @return a new container classpath entry
3316 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3317 * @see JavaCore#setClasspathContainer(IPath, IJavaProject[],
3318 * IClasspathContainer[], IProgressMonitor)
3319 * @see JavaCore#newContainerEntry(IPath, boolean)
3322 public static IClasspathEntry newContainerEntry(IPath containerPath,
3323 boolean isExported) {
3325 if (containerPath == null || containerPath.segmentCount() < 1) {
3329 "Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$
3331 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3332 IClasspathEntry.CPE_CONTAINER, containerPath,
3333 ClasspathEntry.NO_EXCLUSION_PATTERNS, null, // source attachment
3334 null, // source attachment root
3335 null, // specific output folder
3340 * Creates and returns a new non-exported classpath entry of kind
3341 * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3342 * absolute path. This specifies that all package fragments within the root
3343 * will have children of type <code>IClassFile</code>.
3345 * A library entry is used to denote a prerequisite JAR or root folder
3346 * containing binaries. The target JAR or folder can either be defined
3347 * internally to the workspace (absolute path relative to the workspace
3348 * root) or externally to the workspace (absolute path in the file system).
3350 * e.g. Here are some examples of binary path usage
3352 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3354 * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3356 * <li><code> "c:/classes/" </code>- reference to an external binary
3359 * Note that this operation does not attempt to validate or access the
3360 * resources at the given paths.
3362 * The resulting entry is not exported to dependent projects. This method is
3363 * equivalent to <code>newLibraryEntry(-,-,-,false)</code>.
3367 * the absolute path of the binary archive
3368 * @param sourceAttachmentPath
3369 * the absolute path of the corresponding source archive or
3370 * folder, or <code>null</code> if none
3371 * @param sourceAttachmentRootPath
3372 * the location of the root within the source archive or folder
3373 * or <code>null</code> if this location should be
3374 * automatically detected.
3375 * @return a new library classpath entry
3377 * @see #newLibraryEntry(IPath, IPath, IPath, boolean)
3379 //public static IClasspathEntry newLibraryEntry(
3381 // IPath sourceAttachmentPath,
3382 // IPath sourceAttachmentRootPath) {
3384 // return newLibraryEntry(path, sourceAttachmentPath,
3385 // sourceAttachmentRootPath, false);
3388 * Creates and returns a new classpath entry of kind
3389 * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3390 * absolute path. This specifies that all package fragments within the root
3391 * will have children of type <code>IClassFile</code>.
3393 * A library entry is used to denote a prerequisite JAR or root folder
3394 * containing binaries. The target JAR or folder can either be defined
3395 * internally to the workspace (absolute path relative to the workspace
3396 * root) or externally to the workspace (absolute path in the file system).
3398 * e.g. Here are some examples of binary path usage
3400 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3402 * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3404 * <li><code> "c:/classes/" </code>- reference to an external binary
3407 * Note that this operation does not attempt to validate or access the
3408 * resources at the given paths.
3412 * the absolute path of the binary archive
3413 * @param sourceAttachmentPath
3414 * the absolute path of the corresponding source archive or
3415 * folder, or <code>null</code> if none
3416 * @param sourceAttachmentRootPath
3417 * the location of the root within the source archive or folder
3418 * or <code>null</code> if this location should be
3419 * automatically detected.
3421 * indicates whether this entry is contributed to dependent
3422 * projects in addition to the output location
3423 * @return a new library classpath entry
3426 //public static IClasspathEntry newLibraryEntry(
3428 // IPath sourceAttachmentPath,
3429 // IPath sourceAttachmentRootPath,
3430 // boolean isExported) {
3432 // if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry
3433 // must be absolute"); //$NON-NLS-1$
3435 // return new ClasspathEntry(
3436 // IPackageFragmentRoot.K_BINARY,
3437 // IClasspathEntry.CPE_LIBRARY,
3438 // JavaProject.canonicalizedPath(path),
3439 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3440 // sourceAttachmentPath,
3441 // sourceAttachmentRootPath,
3442 // null, // specific output folder
3446 * Creates and returns a new non-exported classpath entry of kind
3447 * <code>CPE_PROJECT</code> for the project identified by the given
3450 * A project entry is used to denote a prerequisite project on a classpath.
3451 * The referenced project will be contributed as a whole, either as sources
3452 * (in the Java Model, it contributes all its package fragment roots) or as
3453 * binaries (when building, it contributes its whole output location).
3455 * A project reference allows to indirect through another project,
3456 * independently from its internal layout.
3458 * The prerequisite project is referred to using an absolute path relative
3459 * to the workspace root.
3461 * The resulting entry is not exported to dependent projects. This method is
3462 * equivalent to <code>newProjectEntry(_,false)</code>.
3466 * the absolute path of the binary archive
3467 * @return a new project classpath entry
3469 * @see JavaCore#newProjectEntry(IPath, boolean)
3471 public static IClasspathEntry newProjectEntry(IPath path) {
3472 return newProjectEntry(path, false);
3476 * Creates and returns a new classpath entry of kind
3477 * <code>CPE_PROJECT</code> for the project identified by the given
3480 * A project entry is used to denote a prerequisite project on a classpath.
3481 * The referenced project will be contributed as a whole, either as sources
3482 * (in the Java Model, it contributes all its package fragment roots) or as
3483 * binaries (when building, it contributes its whole output location).
3485 * A project reference allows to indirect through another project,
3486 * independently from its internal layout.
3488 * The prerequisite project is referred to using an absolute path relative
3489 * to the workspace root.
3493 * the absolute path of the prerequisite project
3495 * indicates whether this entry is contributed to dependent
3496 * projects in addition to the output location
3497 * @return a new project classpath entry
3500 public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) {
3502 if (!path.isAbsolute())
3503 Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3505 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3506 IClasspathEntry.CPE_PROJECT, path,
3507 ClasspathEntry.NO_EXCLUSION_PATTERNS, null, // source attachment
3508 null, // source attachment root
3509 null, // specific output folder
3514 * Returns a new empty region.
3516 * @return a new empty region
3518 public static IRegion newRegion() {
3519 return new Region();
3523 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3524 * for the project's source folder identified by the given absolute
3525 * workspace-relative path. This specifies that all package fragments within
3526 * the root will have children of type <code>ICompilationUnit</code>.
3528 * The source folder is referred to using an absolute path relative to the
3529 * workspace root, e.g. <code>/Project/src</code>. A project's source
3530 * folders are located with that project. That is, a source classpath entry
3531 * specifying the path <code>/P1/src</code> is only usable for project
3535 * The source classpath entry created by this method includes all source
3536 * files below the given workspace-relative path. To selectively exclude
3537 * some of these source files, use the factory method
3538 * <code>JavaCore.newSourceEntry(IPath,IPath[])</code> instead.
3541 * Note that all sources/binaries inside a project are contributed as a
3542 * whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
3543 * Particular source entries cannot be selectively exported.
3547 * the absolute workspace-relative path of a source folder
3548 * @return a new source classpath entry with not exclusion patterns
3550 * @see #newSourceEntry(org.eclipse.core.runtime.IPath,org.eclipse.core.runtime.IPath[])
3552 public static IClasspathEntry newSourceEntry(IPath path) {
3554 return newSourceEntry(path, ClasspathEntry.NO_EXCLUSION_PATTERNS, null /*
3561 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3562 * for the project's source folder identified by the given absolute
3563 * workspace-relative path but excluding all source files with paths
3564 * matching any of the given patterns. This specifies that all package
3565 * fragments within the root will have children of type
3566 * <code>ICompilationUnit</code>.
3568 * The source folder is referred to using an absolute path relative to the
3569 * workspace root, e.g. <code>/Project/src</code>. A project's source
3570 * folders are located with that project. That is, a source classpath entry
3571 * specifying the path <code>/P1/src</code> is only usable for project
3575 * The source classpath entry created by this method includes all source
3576 * files below the given workspace-relative path except for those matched by
3577 * one (or more) of the given exclusion patterns. Each exclusion pattern is
3578 * represented by a relative path, which is interpreted as relative to the
3579 * source folder. For example, if the source folder path is
3580 * <code>/Project/src</code> and the exclusion pattern is
3581 * <code>com/xyz/tests/**</code>, then source files like
3582 * <code>/Project/src/com/xyz/Foo.java</code> and
3583 * <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3584 * whereas <code>/Project/src/com/xyz/tests/T1.java</code> and
3585 * <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3586 * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
3587 * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code> for
3588 * the full description of the syntax and semantics of exclusion patterns.
3590 * If the empty list of exclusion patterns is specified, the source folder
3591 * will automatically include all resources located inside the source
3592 * folder. In that case, the result is entirely equivalent to using the
3593 * factory method <code>JavaCore.newSourceEntry(IPath)</code>.
3596 * Note that all sources/binaries inside a project are contributed as a
3597 * whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
3598 * Particular source entries cannot be selectively exported.
3602 * the absolute workspace-relative path of a source folder
3603 * @param exclusionPatterns
3604 * the possibly empty list of exclusion patterns represented as
3606 * @return a new source classpath entry with the given exclusion patterns
3607 * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
3608 * @see IClasspathEntry#getExclusionPatterns
3612 public static IClasspathEntry newSourceEntry(IPath path,
3613 IPath[] exclusionPatterns) {
3615 return newSourceEntry(path, exclusionPatterns, null /* output location */);
3619 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3620 * for the project's source folder identified by the given absolute
3621 * workspace-relative path but excluding all source files with paths
3622 * matching any of the given patterns, and associated with a specific output
3623 * location (that is, ".class" files are not going to the project default
3624 * output location). All package fragments within the root will have
3625 * children of type <code>ICompilationUnit</code>.
3627 * The source folder is referred to using an absolute path relative to the
3628 * workspace root, e.g. <code>/Project/src</code>. A project's source
3629 * folders are located with that project. That is, a source classpath entry
3630 * specifying the path <code>/P1/src</code> is only usable for project
3634 * The source classpath entry created by this method includes all source
3635 * files below the given workspace-relative path except for those matched by
3636 * one (or more) of the given exclusion patterns. Each exclusion pattern is
3637 * represented by a relative path, which is interpreted as relative to the
3638 * source folder. For example, if the source folder path is
3639 * <code>/Project/src</code> and the exclusion pattern is
3640 * <code>com/xyz/tests/**</code>, then source files like
3641 * <code>/Project/src/com/xyz/Foo.java</code> and
3642 * <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3643 * whereas <code>/Project/src/com/xyz/tests/T1.java</code> and
3644 * <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3645 * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
3646 * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code> for
3647 * the full description of the syntax and semantics of exclusion patterns.
3649 * If the empty list of exclusion patterns is specified, the source folder
3650 * will automatically include all resources located inside the source
3651 * folder. In that case, the result is entirely equivalent to using the
3652 * factory method <code>JavaCore.newSourceEntry(IPath)</code>.
3655 * Additionally, a source entry can be associated with a specific output
3656 * location. By doing so, the Java builder will ensure that the generated
3657 * ".class" files will be issued inside this output location, as opposed to
3658 * be generated into the project default output location (when output
3659 * location is <code>null</code>). Note that multiple source entries may
3660 * target the same output location. The output location is referred to using
3661 * an absolute path relative to the workspace root, e.g.
3662 * <code>"/Project/bin"</code>, it must be located inside the same
3663 * project as the source folder.
3666 * Also note that all sources/binaries inside a project are contributed as a
3667 * whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
3668 * Particular source entries cannot be selectively exported.
3672 * the absolute workspace-relative path of a source folder
3673 * @param exclusionPatterns
3674 * the possibly empty list of exclusion patterns represented as
3676 * @param outputLocation
3677 * the specific output location for this source entry (
3678 * <code>null</code> if using project default ouput location)
3679 * @return a new source classpath entry with the given exclusion patterns
3680 * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
3681 * @see IClasspathEntry#getExclusionPatterns
3682 * @see IClasspathEntry#getOutputLocation()
3686 public static IClasspathEntry newSourceEntry(IPath path,
3687 IPath[] exclusionPatterns, IPath specificOutputLocation) {
3689 if (!path.isAbsolute())
3690 Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3691 if (exclusionPatterns == null)
3692 Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$
3694 return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3695 IClasspathEntry.CPE_SOURCE, path, exclusionPatterns, null, // source
3697 null, // source attachment root
3698 specificOutputLocation, // custom output location
3703 * Creates and returns a new non-exported classpath entry of kind
3704 * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3705 * path is the name of a classpath variable. The trailing segments of the
3706 * path will be appended to resolved variable path.
3708 * A variable entry allows to express indirect references on a classpath to
3709 * other projects or libraries, depending on what the classpath variable is
3712 * It is possible to register an automatic initializer (
3713 * <code>ClasspathVariableInitializer</code>), which will be invoked
3714 * through the extension point
3715 * "org.eclipse.jdt.core.classpathVariableInitializer". After resolution, a
3716 * classpath variable entry may either correspond to a project or a library
3719 * e.g. Here are some examples of variable path usage
3721 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3722 * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3723 * library "c:\jars\jdtcore.jar"</li>
3724 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3725 * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3726 * "/Project_JDTCORE"</li>
3727 * <li>"PLUGINS/com.example/example.jar" where variable
3728 * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3729 * classpath entry is denoting the library
3730 * "c:/eclipse/plugins/com.example/example.jar"</li>
3732 * Note that this operation does not attempt to validate classpath variables
3733 * or access the resources at the given paths.
3735 * The resulting entry is not exported to dependent projects. This method is
3736 * equivalent to <code>newVariableEntry(-,-,-,false)</code>.
3739 * @param variablePath
3740 * the path of the binary archive; first segment is the name of a
3741 * classpath variable
3742 * @param variableSourceAttachmentPath
3743 * the path of the corresponding source archive, or
3744 * <code>null</code> if none; if present, the first segment is
3745 * the name of a classpath variable (not necessarily the same
3746 * variable as the one that begins <code>variablePath</code>)
3747 * @param sourceAttachmentRootPath
3748 * the location of the root within the source archive or
3749 * <code>null</code> if <code>archivePath</code> is also
3751 * @return a new library classpath entry
3753 * @see JavaCore#newVariableEntry(IPath, IPath, IPath, boolean)
3755 //public static IClasspathEntry newVariableEntry(
3756 // IPath variablePath,
3757 // IPath variableSourceAttachmentPath,
3758 // IPath sourceAttachmentRootPath) {
3760 // return newVariableEntry(variablePath, variableSourceAttachmentPath,
3761 // sourceAttachmentRootPath, false);
3764 * Creates and returns a new non-exported classpath entry of kind
3765 * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3766 * path is the name of a classpath variable. The trailing segments of the
3767 * path will be appended to resolved variable path.
3769 * A variable entry allows to express indirect references on a classpath to
3770 * other projects or libraries, depending on what the classpath variable is
3773 * It is possible to register an automatic initializer (
3774 * <code>ClasspathVariableInitializer</code>), which will be invoked
3775 * through the extension point
3776 * "org.eclipse.jdt.core.classpathVariableInitializer". After resolution, a
3777 * classpath variable entry may either correspond to a project or a library
3780 * e.g. Here are some examples of variable path usage
3782 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3783 * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3784 * library "c:\jars\jdtcore.jar"</li>
3785 * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3786 * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3787 * "/Project_JDTCORE"</li>
3788 * <li>"PLUGINS/com.example/example.jar" where variable
3789 * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3790 * classpath entry is denoting the library
3791 * "c:/eclipse/plugins/com.example/example.jar"</li>
3793 * Note that this operation does not attempt to validate classpath variables
3794 * or access the resources at the given paths.
3797 * @param variablePath
3798 * the path of the binary archive; first segment is the name of a
3799 * classpath variable
3800 * @param variableSourceAttachmentPath
3801 * the path of the corresponding source archive, or
3802 * <code>null</code> if none; if present, the first segment is
3803 * the name of a classpath variable (not necessarily the same
3804 * variable as the one that begins <code>variablePath</code>)
3805 * @param sourceAttachmentRootPath
3806 * the location of the root within the source archive or
3807 * <code>null</code> if <code>archivePath</code> is also
3810 * indicates whether this entry is contributed to dependent
3811 * projects in addition to the output location
3812 * @return a new variable classpath entry
3815 //public static IClasspathEntry newVariableEntry(
3816 // IPath variablePath,
3817 // IPath variableSourceAttachmentPath,
3818 // IPath variableSourceAttachmentRootPath,
3819 // boolean isExported) {
3821 // if (variablePath == null || variablePath.segmentCount() < 1) {
3824 // "Illegal classpath variable path: \'" +
3825 // variablePath.makeRelative().toString() + "\', must have at least one
3826 // segment"); //$NON-NLS-1$//$NON-NLS-2$
3829 // return new ClasspathEntry(
3830 // IPackageFragmentRoot.K_SOURCE,
3831 // IClasspathEntry.CPE_VARIABLE,
3833 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3834 // variableSourceAttachmentPath, // source attachment
3835 // variableSourceAttachmentRootPath, // source attachment root
3836 // null, // specific output folder
3840 * Removed the given classpath variable. Does nothing if no value was set
3841 * for this classpath variable.
3843 * This functionality cannot be used while the resource tree is locked.
3845 * Classpath variable values are persisted locally to the workspace, and are
3846 * preserved from session to session.
3849 * @param variableName
3850 * the name of the classpath variable
3851 * @see #setClasspathVariable
3853 * @deprecated - use version with extra IProgressMonitor
3855 //public static void removeClasspathVariable(String variableName) {
3856 // removeClasspathVariable(variableName, null);
3859 * Removed the given classpath variable. Does nothing if no value was set
3860 * for this classpath variable.
3862 * This functionality cannot be used while the resource tree is locked.
3864 * Classpath variable values are persisted locally to the workspace, and are
3865 * preserved from session to session.
3868 * @param variableName
3869 * the name of the classpath variable
3871 * the progress monitor to report progress
3872 * @see #setClasspathVariable
3874 //public static void removeClasspathVariable(
3875 // String variableName,
3876 // IProgressMonitor monitor) {
3879 // updateVariableValues(new String[]{ variableName}, new IPath[]{ null },
3881 // } catch (JavaModelException e) {
3885 * Removes the given element changed listener. Has no affect if an identical
3886 * listener is not registered.
3891 public static void removeElementChangedListener(
3892 IElementChangedListener listener) {
3893 JavaModelManager.getJavaModelManager().removeElementChangedListener(
3898 * Bind a container reference path to some actual containers (
3899 * <code>IClasspathContainer</code>). This API must be invoked whenever
3900 * changes in container need to be reflected onto the JavaModel. Containers
3901 * can have distinct values in different projects, therefore this API
3902 * considers a set of projects with their respective containers.
3904 * <code>containerPath</code> is the path under which these values can be
3905 * referenced through container classpath entries (
3906 * <code>IClasspathEntry#CPE_CONTAINER</code>). A container path is
3907 * formed by a first ID segment followed with extra segments, which can be
3908 * used as additional hints for the resolution. The container ID is used to
3909 * identify a <code>ClasspathContainerInitializer</code> registered on the
3910 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3912 * There is no assumption that each individual container value passed in
3913 * argument (<code>respectiveContainers</code>) must answer the exact
3914 * same path when requested <code>IClasspathContainer#getPath</code>.
3915 * Indeed, the containerPath is just an indication for resolving it to an
3916 * actual container object. It can be delegated to a
3917 * <code>ClasspathContainerInitializer</code>, which can be activated
3918 * through the extension point
3919 * "org.eclipse.jdt.core.ClasspathContainerInitializer").
3921 * In reaction to changing container values, the JavaModel will be updated
3922 * to reflect the new state of the updated container.
3924 * This functionality cannot be used while the resource tree is locked.
3926 * Classpath container values are persisted locally to the workspace, but
3927 * are not preserved from a session to another. It is thus highly
3928 * recommended to register a <code>ClasspathContainerInitializer</code>
3929 * for each referenced container (through the extension point
3930 * "org.eclipse.jdt.core.ClasspathContainerInitializer").
3932 * Note: setting a container to <code>null</code> will cause it to be
3933 * lazily resolved again whenever its value is required. In particular, this
3934 * will cause a registered initializer to be invoked again.
3937 * @param containerPath -
3938 * the name of the container reference, which is being updated
3939 * @param affectedProjects -
3940 * the set of projects for which this container is being bound
3941 * @param respectiveContainers -
3942 * the set of respective containers for the affected projects
3944 * a monitor to report progress
3946 * @see ClasspathContainerInitializer
3947 * @see #getClasspathContainer(IPath, IJavaProject)
3948 * @see IClasspathContainer
3951 //public static void setClasspathContainer(final IPath containerPath,
3952 // IJavaProject[] affectedProjects, IClasspathContainer[]
3953 // respectiveContainers, IProgressMonitor monitor) throws JavaModelException
3956 // if (affectedProjects.length != respectiveContainers.length)
3957 // Assert.isTrue(false, "Projects and containers collections should have the
3958 // same size"); //$NON-NLS-1$
3960 // if (monitor != null && monitor.isCanceled()) return;
3962 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3963 // System.out.println("CPContainer SET - setting container:
3964 // ["+containerPath+"] for projects: {" //$NON-NLS-1$ //$NON-NLS-2$
3965 // + (ProjectPrefUtil.toString(affectedProjects,
3966 // new ProjectPrefUtil.Displayable(){
3967 // public String displayString(Object o) { return ((IJavaProject)
3968 // o).getElementName(); }
3970 // + "} with values: " //$NON-NLS-1$
3971 // + (ProjectPrefUtil.toString(respectiveContainers,
3972 // new ProjectPrefUtil.Displayable(){
3973 // public String displayString(Object o) { return ((IClasspathContainer)
3974 // o).getDescription(); }
3979 // final int projectLength = affectedProjects.length;
3980 // final IJavaProject[] modifiedProjects;
3981 // System.arraycopy(affectedProjects, 0, modifiedProjects = new
3982 // IJavaProject[projectLength], 0, projectLength);
3983 // final IClasspathEntry[][] oldResolvedPaths = new
3984 // IClasspathEntry[projectLength][];
3986 // // filter out unmodified project containers
3987 // int remaining = 0;
3988 // for (int i = 0; i < projectLength; i++){
3990 // if (monitor != null && monitor.isCanceled()) return;
3992 // IJavaProject affectedProject = affectedProjects[i];
3993 // IClasspathContainer newContainer = respectiveContainers[i];
3994 // if (newContainer == null) newContainer =
3995 // JavaModelManager.ContainerInitializationInProgress; // 30920 - prevent
3997 // boolean found = false;
3998 // if (JavaProject.hasJavaNature(affectedProject.getProject())){
3999 // IClasspathEntry[] rawClasspath = affectedProject.getRawClasspath();
4000 // for (int j = 0, cpLength = rawClasspath.length; j <cpLength; j++) {
4001 // IClasspathEntry entry = rawClasspath[j];
4002 // if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER &&
4003 // entry.getPath().equals(containerPath)){
4010 // modifiedProjects[i] = null; // filter out this project - does not
4011 // reference the container path, or isnt't yet Java project
4012 // JavaModelManager.containerPut(affectedProject, containerPath,
4016 // IClasspathContainer oldContainer =
4017 // JavaModelManager.containerGet(affectedProject, containerPath);
4018 // if (oldContainer == JavaModelManager.ContainerInitializationInProgress) {
4019 // Map previousContainerValues =
4020 // (Map)JavaModelManager.PreviousSessionContainers.get(affectedProject);
4021 // if (previousContainerValues != null){
4022 // IClasspathContainer previousContainer =
4023 // (IClasspathContainer)previousContainerValues.get(containerPath);
4024 // if (previousContainer != null) {
4025 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4026 // System.out.println("CPContainer INIT - reentering access to project
4027 // container: ["+affectedProject.getElementName()+"] " + containerPath + "
4028 // during its initialization, will see previous value: "+
4029 // previousContainer.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
4032 // JavaModelManager.containerPut(affectedProject, containerPath,
4033 // previousContainer);
4035 // oldContainer = null; //33695 - cannot filter out restored container, must
4036 // update affected project to reset cached CP
4038 // oldContainer = null;
4041 // if (oldContainer != null &&
4042 // oldContainer.equals(respectiveContainers[i])){// TODO: could improve to
4043 // only compare entries
4044 // modifiedProjects[i] = null; // filter out this project - container did
4049 // oldResolvedPaths[i] = affectedProject.getResolvedClasspath(true);
4050 // JavaModelManager.containerPut(affectedProject, containerPath,
4054 // if (remaining == 0) return;
4056 // // trigger model refresh
4058 // JavaCore.run(new IWorkspaceRunnable() {
4059 // public void run(IProgressMonitor monitor) throws CoreException {
4060 // for(int i = 0; i < projectLength; i++){
4062 // if (monitor != null && monitor.isCanceled()) return;
4064 // JavaProject affectedProject = (JavaProject)modifiedProjects[i];
4065 // if (affectedProject == null) continue; // was filtered out
4067 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4068 // System.out.println("CPContainer SET - updating affected project:
4069 // ["+affectedProject.getElementName()+"] due to setting container: " +
4070 // containerPath); //$NON-NLS-1$ //$NON-NLS-2$
4073 // // force a refresh of the affected project (will compute deltas)
4074 // affectedProject.setRawClasspath(
4075 // affectedProject.getRawClasspath(),
4076 // SetClasspathOperation.ReuseOutputLocation,
4078 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can save resources
4079 // oldResolvedPaths[i],
4080 // false, // updating - no validation
4081 // false); // updating - no need to save
4086 // } catch(CoreException e) {
4087 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4088 // System.out.println("CPContainer SET - FAILED DUE TO EXCEPTION:
4089 // "+containerPath); //$NON-NLS-1$
4090 // e.printStackTrace();
4092 // if (e instanceof JavaModelException) {
4093 // throw (JavaModelException)e;
4095 // throw new JavaModelException(e);
4098 // for (int i = 0; i < projectLength; i++) {
4099 // if (respectiveContainers[i] == null) {
4100 // JavaModelManager.containerPut(affectedProjects[i], containerPath, null);
4101 // // reset init in progress marker
4108 * Sets the value of the given classpath variable. The path must have at
4109 * least one segment.
4111 * This functionality cannot be used while the resource tree is locked.
4113 * Classpath variable values are persisted locally to the workspace, and are
4114 * preserved from session to session.
4117 * @param variableName
4118 * the name of the classpath variable
4121 * @see #getClasspathVariable
4123 * @deprecated - use API with IProgressMonitor
4125 //public static void setClasspathVariable(String variableName, IPath path)
4126 // throws JavaModelException {
4128 // setClasspathVariable(variableName, path, null);
4131 * Sets the value of the given classpath variable. The path must not be
4134 * This functionality cannot be used while the resource tree is locked.
4136 * Classpath variable values are persisted locally to the workspace, and are
4137 * preserved from session to session.
4139 * Updating a variable with the same value has no effect.
4141 * @param variableName
4142 * the name of the classpath variable
4146 * a monitor to report progress
4147 * @see #getClasspathVariable
4149 //public static void setClasspathVariable(
4150 // String variableName,
4152 // IProgressMonitor monitor)
4153 // throws JavaModelException {
4155 // if (path == null) Assert.isTrue(false, "Variable path cannot be null");
4157 // setClasspathVariables(new String[]{variableName}, new IPath[]{ path },
4161 * Sets the values of all the given classpath variables at once. Null paths
4162 * can be used to request corresponding variable removal.
4164 * This functionality cannot be used while the resource tree is locked.
4166 * Classpath variable values are persisted locally to the workspace, and are
4167 * preserved from session to session.
4169 * Updating a variable with the same value has no effect.
4171 * @param variableNames
4172 * an array of names for the updated classpath variables
4174 * an array of path updates for the modified classpath variables
4175 * (null meaning that the corresponding value will be removed
4177 * a monitor to report progress
4178 * @see #getClasspathVariable
4181 //public static void setClasspathVariables(
4182 // String[] variableNames,
4184 // IProgressMonitor monitor)
4185 // throws JavaModelException {
4187 // if (variableNames.length != paths.length) Assert.isTrue(false, "Variable
4188 // names and paths collections should have the same size"); //$NON-NLS-1$
4189 // //TODO: should check that null cannot be used as variable paths
4190 // updateVariableValues(variableNames, paths, monitor);
4193 * (non-Javadoc) Method declared on IExecutableExtension. Record any
4194 * necessary initialization data from the plugin.
4196 public void setInitializationData(IConfigurationElement cfig,
4197 String propertyName, Object data) throws CoreException {
4201 * Sets the current table of options. All and only the options explicitly
4202 * included in the given table are remembered; all previous option settings
4203 * are forgotten, including ones not explicitly mentioned.
4205 * For a complete description of the configurable options, see
4206 * <code>getDefaultOptions</code>.
4210 * the new options (key type: <code>String</code>; value type:
4211 * <code>String</code>), or <code>null</code> to reset all
4212 * options to their default values
4213 * @see JavaCore#getDefaultOptions
4215 public static void setOptions(Hashtable newOptions) {
4217 // see #initializeDefaultPluginPreferences() for changing default
4219 Preferences preferences = getPlugin().getPluginPreferences();
4221 if (newOptions == null) {
4222 newOptions = JavaCore.getDefaultOptions();
4224 Enumeration keys = newOptions.keys();
4225 while (keys.hasMoreElements()) {
4226 String key = (String) keys.nextElement();
4227 if (!JavaModelManager.OptionNames.contains(key))
4228 continue; // unrecognized option
4229 if (key.equals(CORE_ENCODING))
4230 continue; // skipped, contributed by resource prefs
4231 String value = (String) newOptions.get(key);
4232 preferences.setValue(key, value);
4236 getPlugin().savePluginPreferences();
4240 * Shutdown the JavaCore plug-in.
4242 * De-registers the JavaModelManager as a resource changed listener and save
4246 * @see org.eclipse.core.runtime.Plugin#shutdown()
4248 // moved to PHPeclipsePlugin#shutdown()
4249 //public void shutdown() {
4251 // //savePluginPreferences();
4252 // getPlugin().savePluginPreferences();
4253 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4254 // workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaProcessor);
4255 // workspace.removeSaveParticipant(PHPeclipsePlugin.getDefault());
4257 // ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown();
4260 * Initiate the background indexing process. This should be deferred after
4261 * the plugin activation.
4263 //private void startIndexing() {
4265 // JavaModelManager.getJavaModelManager().getIndexManager().reset();
4268 * Startup of the JavaCore plug-in.
4270 * Registers the JavaModelManager as a resource changed listener and save
4271 * participant. Starts the background indexing, and restore saved classpath
4275 * @see org.eclipse.core.runtime.Plugin#startup()
4278 // moved to PHPeclipsePlugin#startup()
4279 //public void startup() {
4281 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
4283 // manager.configurePluginDebugOptions();
4285 // // request state folder creation (workaround 19885)
4286 // JavaCore.getPlugin().getStateLocation();
4288 // // retrieve variable values
4289 // JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4290 // JavaModelManager.PluginPreferencesListener());
4291 //// TODO : jsurfer temp-del
4292 //// manager.loadVariablesAndContainers();
4294 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4295 // workspace.addResourceChangeListener(
4296 // manager.deltaProcessor,
4297 // IResourceChangeEvent.PRE_AUTO_BUILD
4298 // | IResourceChangeEvent.POST_AUTO_BUILD
4299 // | IResourceChangeEvent.POST_CHANGE
4300 // | IResourceChangeEvent.PRE_DELETE
4301 // | IResourceChangeEvent.PRE_CLOSE);
4303 //// startIndexing();
4304 // workspace.addSaveParticipant(PHPeclipsePlugin.getDefault(), manager);
4306 // } catch (CoreException e) {
4307 // } catch (RuntimeException e) {
4308 // manager.shutdown();
4313 * Internal updating of a variable values (null path meaning removal),
4314 * allowing to change multiple variable values at once.
4316 //private static void updateVariableValues(
4317 // String[] variableNames,
4318 // IPath[] variablePaths,
4319 // IProgressMonitor monitor) throws JavaModelException {
4321 // if (monitor != null && monitor.isCanceled()) return;
4323 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4324 // System.out.println("CPVariable SET - setting variables: {" +
4325 // ProjectPrefUtil.toString(variableNames) //$NON-NLS-1$
4326 // + "} with values: " + ProjectPrefUtil.toString(variablePaths)); //$NON-NLS-1$
4329 // int varLength = variableNames.length;
4331 // // gather classpath information for updating
4332 // final HashMap affectedProjects = new HashMap(5);
4333 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
4334 // IJavaModel model = manager.getJavaModel();
4336 // // filter out unmodified variables
4337 // int discardCount = 0;
4338 // for (int i = 0; i < varLength; i++){
4339 // String variableName = variableNames[i];
4340 // IPath oldPath = (IPath)JavaModelManager.variableGet(variableName); // if
4341 // reentering will provide previous session value
4342 // if (oldPath == JavaModelManager.VariableInitializationInProgress){
4343 // IPath previousPath =
4344 // (IPath)JavaModelManager.PreviousSessionVariables.get(variableName);
4345 // if (previousPath != null){
4346 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4347 // System.out.println("CPVariable INIT - reentering access to variable: " +
4348 // variableName+ " during its initialization, will see previous value: "+
4349 // previousPath); //$NON-NLS-1$ //$NON-NLS-2$
4351 // JavaModelManager.variablePut(variableName, previousPath); // replace
4352 // value so reentering calls are seeing old value
4354 // oldPath = null; //33695 - cannot filter out restored variable, must
4355 // update affected project to reset cached CP
4357 // if (oldPath != null && oldPath.equals(variablePaths[i])){
4358 // variableNames[i] = null;
4362 // if (discardCount > 0){
4363 // if (discardCount == varLength) return;
4364 // int changedLength = varLength - discardCount;
4365 // String[] changedVariableNames = new String[changedLength];
4366 // IPath[] changedVariablePaths = new IPath[changedLength];
4367 // for (int i = 0, index = 0; i < varLength; i++){
4368 // if (variableNames[i] != null){
4369 // changedVariableNames[index] = variableNames[i];
4370 // changedVariablePaths[index] = variablePaths[i];
4374 // variableNames = changedVariableNames;
4375 // variablePaths = changedVariablePaths;
4376 // varLength = changedLength;
4379 // if (monitor != null && monitor.isCanceled()) return;
4381 // if (model != null) {
4382 // IJavaProject[] projects = model.getJavaProjects();
4383 // nextProject : for (int i = 0, projectLength = projects.length; i <
4384 // projectLength; i++){
4385 // IJavaProject project = projects[i];
4387 // // check to see if any of the modified variables is present on the
4389 // IClasspathEntry[] classpath = project.getRawClasspath();
4390 // for (int j = 0, cpLength = classpath.length; j < cpLength; j++){
4392 // IClasspathEntry entry = classpath[j];
4393 // for (int k = 0; k < varLength; k++){
4395 // String variableName = variableNames[k];
4396 // if (entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE){
4398 // if (variableName.equals(entry.getPath().segment(0))){
4399 // affectedProjects.put(project, project.getResolvedClasspath(true));
4400 // continue nextProject;
4402 // IPath sourcePath, sourceRootPath;
4403 // if (((sourcePath = entry.getSourceAttachmentPath()) != null &&
4404 // variableName.equals(sourcePath.segment(0)))
4405 // || ((sourceRootPath = entry.getSourceAttachmentRootPath()) != null &&
4406 // variableName.equals(sourceRootPath.segment(0)))) {
4408 // affectedProjects.put(project, project.getResolvedClasspath(true));
4409 // continue nextProject;
4416 // // update variables
4417 // for (int i = 0; i < varLength; i++){
4418 // JavaModelManager.variablePut(variableNames[i], variablePaths[i]);
4420 // final String[] dbgVariableNames = variableNames;
4422 // // update affected project classpaths
4423 // if (!affectedProjects.isEmpty()) {
4425 // JavaCore_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt.run(
4426 // new IWorkspaceRunnable() {
4427 // public void run(IProgressMonitor monitor) throws CoreException {
4428 // // propagate classpath change
4429 // Iterator projectsToUpdate = affectedProjects.keySet().iterator();
4430 // while (projectsToUpdate.hasNext()) {
4432 // if (monitor != null && monitor.isCanceled()) return;
4434 // JavaProject project = (JavaProject) projectsToUpdate.next();
4436 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4437 // System.out.println("CPVariable SET - updating affected project:
4438 // ["+project.getElementName()+"] due to setting variables: "+
4439 // ProjectPrefUtil.toString(dbgVariableNames)); //$NON-NLS-1$ //$NON-NLS-2$
4443 // .setRawClasspath(
4444 // project.getRawClasspath(),
4445 // SetClasspathOperation.ReuseOutputLocation,
4446 // null, // don't call beginTask on the monitor (see
4447 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=3717)
4448 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can change resources
4449 // (IClasspathEntry[]) affectedProjects.get(project),
4450 // false, // updating - no validation
4451 // false); // updating - no need to save
4456 // } catch (CoreException e) {
4457 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
4458 // System.out.println("CPVariable SET - FAILED DUE TO EXCEPTION:
4459 // "+ProjectPrefUtil.toString(dbgVariableNames)); //$NON-NLS-1$
4460 // e.printStackTrace();
4462 // if (e instanceof JavaModelException) {
4463 // throw (JavaModelException)e;
4465 // throw new JavaModelException(e);
4471 * (non-Javadoc) Startup the JavaCore plug-in. <p> Registers the
4472 * JavaModelManager as a resource changed listener and save participant.
4473 * Starts the background indexing, and restore saved classpath variable
4474 * values. <p> @throws Exception
4476 * @see org.eclipse.core.runtime.Plugin#start(BundleContext)
4478 //public static void start(final Plugin plugin, BundleContext context)
4479 // throws Exception {
4480 //// super.start(context);
4482 // final JavaModelManager manager = JavaModelManager.getJavaModelManager();
4484 // manager.configurePluginDebugOptions();
4486 // // request state folder creation (workaround 19885)
4487 // JavaCore.getPlugin().getStateLocation();
4489 // // retrieve variable values
4490 // //JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4491 // JavaModelManager.PluginPreferencesListener());
4492 //// manager.loadVariablesAndContainers();
4494 // final IWorkspace workspace = ResourcesPlugin.getWorkspace();
4495 // workspace.addResourceChangeListener(
4496 // manager.deltaState,
4497 // IResourceChangeEvent.PRE_BUILD
4498 // | IResourceChangeEvent.POST_BUILD
4499 // | IResourceChangeEvent.POST_CHANGE
4500 // | IResourceChangeEvent.PRE_DELETE
4501 // | IResourceChangeEvent.PRE_CLOSE);
4503 //// startIndexing();
4505 // // process deltas since last activated in indexer thread so that indexes
4507 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658
4508 // Job processSavedState = new Job(ProjectPrefUtil.bind("savedState.jobName")) {
4510 // protected IStatus run(IProgressMonitor monitor) {
4512 // // add save participant and process delta atomically
4513 // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59937
4515 // new IWorkspaceRunnable() {
4516 // public void run(IProgressMonitor progress) throws CoreException {
4517 //// ISavedState savedState = workspace.addSaveParticipant(JavaCore.this,
4519 // ISavedState savedState = workspace.addSaveParticipant(plugin, manager);
4520 // if (savedState != null) {
4521 // // the event type coming from the saved state is always POST_AUTO_BUILD
4522 // // force it to be POST_CHANGE so that the delta processor can handle it
4523 // manager.deltaState.getDeltaProcessor().overridenEventType =
4524 // IResourceChangeEvent.POST_CHANGE;
4525 // savedState.processResourceChangeEvents(manager.deltaState);
4530 // } catch (CoreException e) {
4531 // return e.getStatus();
4533 // return Status.OK_STATUS;
4536 // processSavedState.setSystem(true);
4537 // processSavedState.setPriority(Job.SHORT); // process asap
4538 // processSavedState.schedule();
4539 // } catch (RuntimeException e) {
4540 // manager.shutdown();
4545 * (non-Javadoc) Shutdown the JavaCore plug-in. <p> De-registers the
4546 * JavaModelManager as a resource changed listener and save participant. <p>
4548 * @see org.eclipse.core.runtime.Plugin#stop(BundleContext)
4550 // public static void stop(Plugin plugin, BundleContext context)
4551 // throws Exception {
4553 // plugin.savePluginPreferences();
4554 // IWorkspace workspace = ResourcesPlugin.getWorkspace();
4555 // workspace.removeResourceChangeListener(JavaModelManager
4556 // .getJavaModelManager().deltaState);
4557 // workspace.removeSaveParticipant(plugin);
4559 // JavaModelManager.getJavaModelManager().shutdown();
4561 // // ensure we call super.stop as the last thing
4562 // // super.stop(context);