1 package net.sourceforge.phpeclipse;
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.core.ClasspathVariableInitializer;
13 import net.sourceforge.phpdt.core.ElementChangedEvent;
14 import net.sourceforge.phpdt.core.IBufferFactory;
15 import net.sourceforge.phpdt.core.IClasspathEntry;
16 import net.sourceforge.phpdt.core.ICompilationUnit;
17 import net.sourceforge.phpdt.core.IElementChangedListener;
18 import net.sourceforge.phpdt.core.IJavaElement;
19 import net.sourceforge.phpdt.core.IJavaModel;
20 import net.sourceforge.phpdt.core.IJavaProject;
21 import net.sourceforge.phpdt.core.IMember;
22 import net.sourceforge.phpdt.core.IPackageFragmentRoot;
23 import net.sourceforge.phpdt.core.IRegion;
24 import net.sourceforge.phpdt.core.IWorkingCopy;
25 import net.sourceforge.phpdt.core.JavaModelException;
26 import net.sourceforge.phpdt.internal.core.BatchOperation;
27 import net.sourceforge.phpdt.internal.core.BufferManager;
28 import net.sourceforge.phpdt.internal.core.ClasspathEntry;
29 import net.sourceforge.phpdt.internal.core.JavaModel;
30 import net.sourceforge.phpdt.internal.core.JavaModelManager;
31 import net.sourceforge.phpdt.internal.core.Region;
32 import net.sourceforge.phpdt.internal.corext.Assert;
34 import org.eclipse.core.resources.IFile;
35 import org.eclipse.core.resources.IFolder;
36 import org.eclipse.core.resources.IMarker;
37 import org.eclipse.core.resources.IMarkerDelta;
38 import org.eclipse.core.resources.IProject;
39 import org.eclipse.core.resources.IProjectDescription;
40 import org.eclipse.core.resources.IResource;
41 import org.eclipse.core.resources.IResourceChangeEvent;
42 import org.eclipse.core.resources.IWorkspace;
43 import org.eclipse.core.resources.IWorkspaceRoot;
44 import org.eclipse.core.resources.IWorkspaceRunnable;
45 import org.eclipse.core.resources.ResourcesPlugin;
46 import org.eclipse.core.runtime.CoreException;
47 import org.eclipse.core.runtime.IConfigurationElement;
48 import org.eclipse.core.runtime.IPath;
49 import org.eclipse.core.runtime.IProgressMonitor;
50 import org.eclipse.core.runtime.Plugin;
51 import org.eclipse.core.runtime.Preferences;
53 public class PHPCore {
55 // public static HashSet OptionNames = new HashSet(20);
57 * The plug-in identifier of the Java core support
58 * (value <code>"org.phpeclipse.phpdt.core"</code>).
60 // public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.core"; //$NON-NLS-1$
61 public static final String PLUGIN_ID = PHPeclipsePlugin.PLUGIN_ID;
63 * Possible configurable option ID.
64 * @see #getDefaultOptions
67 public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; //$NON-NLS-1$
70 * Possible configurable option ID.
71 * @see #getDefaultOptions
74 public static final String FORMATTER_NEWLINE_OPENING_BRACE = PLUGIN_ID + ".formatter.newline.openingBrace"; //$NON-NLS-1$
76 * Possible configurable option ID.
77 * @see #getDefaultOptions
80 public static final String FORMATTER_NEWLINE_CONTROL = PLUGIN_ID + ".formatter.newline.controlStatement"; //$NON-NLS-1$
82 * Possible configurable option ID.
83 * @see #getDefaultOptions
86 public static final String FORMATTER_NEWLINE_ELSE_IF = PLUGIN_ID + ".formatter.newline.elseIf"; //$NON-NLS-1$
88 * Possible configurable option ID.
89 * @see #getDefaultOptions
92 public static final String FORMATTER_NEWLINE_EMPTY_BLOCK = PLUGIN_ID + ".formatter.newline.emptyBlock"; //$NON-NLS-1$
94 * Possible configurable option ID.
95 * @see #getDefaultOptions
98 public static final String FORMATTER_CLEAR_BLANK_LINES = PLUGIN_ID + ".formatter.newline.clearAll"; //$NON-NLS-1$
100 * Possible configurable option ID.
101 * @see #getDefaultOptions
104 public static final String FORMATTER_LINE_SPLIT = PLUGIN_ID + ".formatter.lineSplit"; //$NON-NLS-1$
106 * Possible configurable option ID.
107 * @see #getDefaultOptions
110 public static final String FORMATTER_COMPACT_ASSIGNMENT = PLUGIN_ID + ".formatter.style.assignment"; //$NON-NLS-1$
112 * Possible configurable option ID.
113 * @see #getDefaultOptions
116 public static final String FORMATTER_TAB_CHAR = PLUGIN_ID + ".formatter.tabulation.char"; //$NON-NLS-1$
118 * Possible configurable option ID.
119 * @see #getDefaultOptions
122 public static final String FORMATTER_TAB_SIZE = PLUGIN_ID + ".formatter.tabulation.size"; //$NON-NLS-1$
124 * Possible configurable option value.
125 * @see #getDefaultOptions
128 public static final String INSERT = "insert"; //$NON-NLS-1$
130 * Possible configurable option value.
131 * @see #getDefaultOptions
134 public static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$
137 * Possible configurable option value.
138 * @see #getDefaultOptions
141 public static final String PRESERVE_ONE = "preserve one"; //$NON-NLS-1$
143 * Possible configurable option value.
144 * @see #getDefaultOptions
147 public static final String CLEAR_ALL = "clear all"; //$NON-NLS-1$
149 * Possible configurable option value.
150 * @see #getDefaultOptions
153 public static final String NORMAL = "normal"; //$NON-NLS-1$
155 * Possible configurable option value.
156 * @see #getDefaultOptions
159 public static final String COMPACT = "compact"; //$NON-NLS-1$
161 * Possible configurable option value.
162 * @see #getDefaultOptions
165 public static final String TAB = "tab"; //$NON-NLS-1$
167 * Possible configurable option value.
168 * @see #getDefaultOptions
171 public static final String SPACE = "space"; //$NON-NLS-1$
173 * Possible configurable option value.
174 * @see #getDefaultOptions
177 public static final String ENABLED = "enabled"; //$NON-NLS-1$
179 * Possible configurable option value.
180 * @see #getDefaultOptions
183 public static final String DISABLED = "disabled"; //$NON-NLS-1$
185 * Possible configurable option value.
186 * @see #getDefaultOptions
189 public static final String CLEAN = "clean"; //$NON-NLS-1$
192 * Possible configurable option ID.
193 * @see #getDefaultOptions
196 public static final String COMPILER_TASK_TAGS = PLUGIN_ID + ".compiler.taskTags"; //$NON-NLS-1$
199 * Name of the handle id attribute in a Java marker.
201 protected static final String ATT_HANDLE_ID =
202 "net.sourceforge.phpdt.internal.core.JavaModelManager.handleId" ; //$NON-NLS-1$
204 // *************** Possible IDs for configurable options. ********************
207 * Possible configurable option ID.
208 * @see #getDefaultOptions()
210 public static final String COMPILER_LOCAL_VARIABLE_ATTR = PLUGIN_ID + ".compiler.debug.localVariable"; //$NON-NLS-1$
212 * Possible configurable option ID.
213 * @see #getDefaultOptions()
215 public static final String COMPILER_LINE_NUMBER_ATTR = PLUGIN_ID + ".compiler.debug.lineNumber"; //$NON-NLS-1$
217 * Possible configurable option ID.
218 * @see #getDefaultOptions
220 public static final String COMPILER_SOURCE_FILE_ATTR = PLUGIN_ID + ".compiler.debug.sourceFile"; //$NON-NLS-1$
222 * Possible configurable option ID.
223 * @see #getDefaultOptions
225 public static final String COMPILER_CODEGEN_UNUSED_LOCAL = PLUGIN_ID + ".compiler.codegen.unusedLocal"; //$NON-NLS-1$
227 * Possible configurable option ID.
228 * @see #getDefaultOptions
230 public static final String COMPILER_CODEGEN_TARGET_PLATFORM = PLUGIN_ID + ".compiler.codegen.targetPlatform"; //$NON-NLS-1$
232 * Possible configurable option ID.
233 * @see #getDefaultOptions
235 public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID + ".compiler.problem.unreachableCode"; //$NON-NLS-1$
237 * Possible configurable option ID.
238 * @see #getDefaultOptions
240 public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID + ".compiler.problem.invalidImport"; //$NON-NLS-1$
242 * Possible configurable option ID.
243 * @see #getDefaultOptions
245 public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID + ".compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
247 * Possible configurable option ID.
248 * @see #getDefaultOptions
250 public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID + ".compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
252 * Possible configurable option ID.
253 * @see #getDefaultOptions
255 public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID + ".compiler.problem.deprecation"; //$NON-NLS-1$
257 * Possible configurable option ID.
258 * @see #getDefaultOptions
261 public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID + ".compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
263 * Possible configurable option ID.
264 * @see #getDefaultOptions
266 public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID + ".compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
268 * Possible configurable option ID.
269 * @see #getDefaultOptions
271 public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID + ".compiler.problem.unusedLocal"; //$NON-NLS-1$
273 * Possible configurable option ID.
274 * @see #getDefaultOptions
276 public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID + ".compiler.problem.unusedParameter"; //$NON-NLS-1$
278 * Possible configurable option ID.
279 * @see #getDefaultOptions
282 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID + ".compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
284 * Possible configurable option ID.
285 * @see #getDefaultOptions
288 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID + ".compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
290 * Possible configurable option ID.
291 * @see #getDefaultOptions
294 public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID + ".compiler.problem.unusedImport"; //$NON-NLS-1$
296 * Possible configurable option ID.
297 * @see #getDefaultOptions
299 public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID + ".compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
301 * Possible configurable option ID.
302 * @see #getDefaultOptions
305 public static final String COMPILER_PB_NON_NLS_STRING_LITERAL = PLUGIN_ID + ".compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
307 * Possible configurable option ID.
308 * @see #getDefaultOptions
311 public static final String COMPILER_PB_ASSERT_IDENTIFIER = PLUGIN_ID + ".compiler.problem.assertIdentifier"; //$NON-NLS-1$
313 * Possible configurable option ID.
314 * @see #getDefaultOptions
317 public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID + ".compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
319 * Possible configurable option ID.
320 * @see #getDefaultOptions
323 public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID + ".compiler.problem.noEffectAssignment"; //$NON-NLS-1$
325 * Possible configurable option ID.
326 * @see #getDefaultOptions
329 public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
331 * Possible configurable option ID.
332 * @see #getDefaultOptions
335 public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
337 * Possible configurable option ID.
338 * @see #getDefaultOptions
341 public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
343 * Possible configurable option ID.
344 * @see #getDefaultOptions
347 public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID + ".compiler.maxProblemPerUnit"; //$NON-NLS-1$
349 * Possible configurable option ID.
350 * @see #getDefaultOptions
353 public static final String COMPILER_SOURCE = PLUGIN_ID + ".compiler.source"; //$NON-NLS-1$
355 * Possible configurable option ID.
356 * @see #getDefaultOptions
359 public static final String COMPILER_COMPLIANCE = PLUGIN_ID + ".compiler.compliance"; //$NON-NLS-1$
361 * Possible configurable option ID.
362 * @see #getDefaultOptions
365 public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID + ".compiler.taskPriorities"; //$NON-NLS-1$
367 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
368 * @see #getDefaultOptions
371 public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$
373 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
374 * @see #getDefaultOptions
377 public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$
379 * Possible configurable option value for COMPILER_TASK_PRIORITIES.
380 * @see #getDefaultOptions
383 public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$
385 * Possible configurable option ID.
386 * @see #getDefaultOptions
388 public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder"; //$NON-NLS-1$
390 * Possible configurable option ID.
391 * @see #getDefaultOptions
394 public static final String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER = PLUGIN_ID + ".builder.resourceCopyExclusionFilter"; //$NON-NLS-1$
396 * Possible configurable option ID.
397 * @see #getDefaultOptions
400 public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID + ".builder.duplicateResourceTask"; //$NON-NLS-1$
402 * Possible configurable option ID.
403 * @see #getDefaultOptions
406 public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID + ".builder.cleanOutputFolder"; //$NON-NLS-1$
408 * Possible configurable option ID.
409 * @see #getDefaultOptions
412 public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID + ".incompleteClasspath"; //$NON-NLS-1$
414 * Possible configurable option ID.
415 * @see #getDefaultOptions
418 public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID + ".circularClasspath"; //$NON-NLS-1$
420 * Possible configurable option ID.
421 * @see #getDefaultOptions
424 public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID + ".builder.invalidClasspath"; //$NON-NLS-1$
426 * Possible configurable option ID.
427 * @see #getDefaultOptions
430 public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID + ".classpath.exclusionPatterns"; //$NON-NLS-1$
432 * Possible configurable option ID.
433 * @see #getDefaultOptions
436 public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID + ".classpath.multipleOutputLocations"; //$NON-NLS-1$
441 public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$
443 * Default task priority
446 public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; //$NON-NLS-1$
448 * Possible configurable option ID
449 * @see #getDefaultOptions
452 public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID + ".formatter.space.castexpression"; //$NON-NLS-1$
454 * Possible configurable option ID.
455 * @see #getDefaultOptions
458 public static final String CODEASSIST_VISIBILITY_CHECK = PLUGIN_ID + ".codeComplete.visibilityCheck"; //$NON-NLS-1$
460 * Possible configurable option ID.
461 * @see #getDefaultOptions
464 public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID + ".codeComplete.forceImplicitQualification"; //$NON-NLS-1$
466 * Possible configurable option ID.
467 * @see #getDefaultOptions
470 public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.fieldPrefixes"; //$NON-NLS-1$
472 * Possible configurable option ID.
473 * @see #getDefaultOptions
476 public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
478 * Possible configurable option ID.
479 * @see #getDefaultOptions
482 public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID + ".codeComplete.localPrefixes"; //$NON-NLS-1$
484 * Possible configurable option ID.
485 * @see #getDefaultOptions
488 public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID + ".codeComplete.argumentPrefixes"; //$NON-NLS-1$
490 * Possible configurable option ID.
491 * @see #getDefaultOptions
494 public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.fieldSuffixes"; //$NON-NLS-1$
496 * Possible configurable option ID.
497 * @see #getDefaultOptions
500 public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
502 * Possible configurable option ID.
503 * @see #getDefaultOptions
506 public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID + ".codeComplete.localSuffixes"; //$NON-NLS-1$
508 * Possible configurable option ID.
509 * @see #getDefaultOptions
512 public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID + ".codeComplete.argumentSuffixes"; //$NON-NLS-1$
514 // *************** Possible values for configurable options. ********************
517 * Possible configurable option value.
518 * @see #getDefaultOptions
520 public static final String GENERATE = "generate"; //$NON-NLS-1$
522 * Possible configurable option value.
523 * @see #getDefaultOptions
525 public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
527 * Possible configurable option value.
528 * @see #getDefaultOptions
530 public static final String PRESERVE = "preserve"; //$NON-NLS-1$
532 * Possible configurable option value.
533 * @see #getDefaultOptions
535 public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
537 * Possible configurable option value.
538 * @see #getDefaultOptions
540 public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$
542 * Possible configurable option value.
543 * @see #getDefaultOptions
545 public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$
547 * Possible configurable option value.
548 * @see #getDefaultOptions
551 public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
553 * Possible configurable option value.
554 * @see #getDefaultOptions
557 public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
559 * Possible configurable option value.
560 * @see #getDefaultOptions
563 public static final String ABORT = "abort"; //$NON-NLS-1$
565 * Possible configurable option value.
566 * @see #getDefaultOptions
568 public static final String ERROR = "error"; //$NON-NLS-1$
570 * Possible configurable option value.
571 * @see #getDefaultOptions
573 public static final String WARNING = "warning"; //$NON-NLS-1$
575 * Possible configurable option value.
576 * @see #getDefaultOptions
578 public static final String IGNORE = "ignore"; //$NON-NLS-1$
580 * Possible configurable option value.
581 * @see #getDefaultOptions
583 public static final String COMPUTE = "compute"; //$NON-NLS-1$
585 * Possible configurable option value.
586 * @see #getDefaultOptions
592 * Returns a table of all known configurable options with their default values.
593 * These options allow to configure the behaviour of the underlying components.
594 * The client may safely use the result as a template that they can modify and
595 * then pass to <code>setOptions</code>.
597 * Helper constants have been defined on JavaCore for each of the option ID and
598 * their possible constant values.
600 * Note: more options might be added in further releases.
602 * RECOGNIZED OPTIONS:
603 * COMPILER / Generating Local Variable Debug Attribute
604 * When generated, this attribute will enable local variable names
605 * to be displayed in debugger, only in place where variables are
606 * definitely assigned (.class file is then bigger)
607 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.localVariable"
608 * - possible values: { "generate", "do not generate" }
609 * - default: "generate"
611 * COMPILER / Generating Line Number Debug Attribute
612 * When generated, this attribute will enable source code highlighting in debugger
613 * (.class file is then bigger).
614 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.lineNumber"
615 * - possible values: { "generate", "do not generate" }
616 * - default: "generate"
618 * COMPILER / Generating Source Debug Attribute
619 * When generated, this attribute will enable the debugger to present the
620 * corresponding source code.
621 * - option id: "org.phpeclipse.phpdt.core.compiler.debug.sourceFile"
622 * - possible values: { "generate", "do not generate" }
623 * - default: "generate"
625 * COMPILER / Preserving Unused Local Variables
626 * Unless requested to preserve unused local variables (i.e. never read), the
627 * compiler will optimize them out, potentially altering debugging
628 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.unusedLocal"
629 * - possible values: { "preserve", "optimize out" }
630 * - default: "preserve"
632 * COMPILER / Defining Target Java Platform
633 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
634 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
635 * - option id: "org.phpeclipse.phpdt.core.compiler.codegen.targetPlatform"
636 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
639 * COMPILER / Reporting Unreachable Code
640 * Unreachable code can optionally be reported as an error, warning or simply
641 * ignored. The bytecode generation will always optimized it out.
642 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unreachableCode"
643 * - possible values: { "error", "warning", "ignore" }
646 * COMPILER / Reporting Invalid Import
647 * An import statement that cannot be resolved might optionally be reported
648 * as an error, as a warning or ignored.
649 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.invalidImport"
650 * - possible values: { "error", "warning", "ignore" }
653 * COMPILER / Reporting Attempt to Override Package-Default Method
654 * A package default method is not visible in a different package, and thus
655 * cannot be overridden. When enabling this option, the compiler will signal
656 * such scenarii either as an error or a warning.
657 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
658 * - possible values: { "error", "warning", "ignore" }
659 * - default: "warning"
661 * COMPILER / Reporting Method With Constructor Name
662 * Naming a method with a constructor name is generally considered poor
663 * style programming. When enabling this option, the compiler will signal such
664 * scenarii either as an error or a warning.
665 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.methodWithConstructorName"
666 * - possible values: { "error", "warning", "ignore" }
667 * - default: "warning"
669 * COMPILER / Reporting Deprecation
670 * When enabled, the compiler will signal use of deprecated API either as an
671 * error or a warning.
672 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecation"
673 * - possible values: { "error", "warning", "ignore" }
674 * - default: "warning"
676 * COMPILER / Reporting Deprecation Inside Deprecated Code
677 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
678 * The severity of the problem is controlled with option "org.phpeclipse.phpdt.core.compiler.problem.deprecation".
679 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
680 * - possible values: { "enabled", "disabled" }
681 * - default: "disabled"
683 * COMPILER / Reporting Hidden Catch Block
684 * Locally to a try statement, some catch blocks may hide others , e.g.
685 * try { throw new java.io.CharConversionException();
686 * } catch (java.io.CharConversionException e) {
687 * } catch (java.io.IOException e) {}.
688 * When enabling this option, the compiler will issue an error or a warning for hidden
689 * catch blocks corresponding to checked exceptions
690 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.hiddenCatchBlock"
691 * - possible values: { "error", "warning", "ignore" }
692 * - default: "warning"
694 * COMPILER / Reporting Unused Local
695 * When enabled, the compiler will issue an error or a warning for unused local
696 * variables (i.e. variables never read from)
697 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedLocal"
698 * - possible values: { "error", "warning", "ignore" }
699 * - default: "ignore"
701 * COMPILER / Reporting Unused Parameter
702 * When enabled, the compiler will issue an error or a warning for unused method
703 * parameters (i.e. parameters never read from)
704 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedParameter"
705 * - possible values: { "error", "warning", "ignore" }
706 * - default: "ignore"
708 * COMPILER / Reporting Unused Import
709 * When enabled, the compiler will issue an error or a warning for unused import
711 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.unusedImport"
712 * - possible values: { "error", "warning", "ignore" }
713 * - default: "warning"
715 * COMPILER / Reporting Synthetic Access Emulation
716 * When enabled, the compiler will issue an error or a warning whenever it emulates
717 * access to a non-accessible member of an enclosing type. Such access can have
718 * performance implications.
719 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.syntheticAccessEmulation"
720 * - possible values: { "error", "warning", "ignore" }
721 * - default: "ignore"
723 * COMPILER / Reporting Non-Externalized String Literal
724 * When enabled, the compiler will issue an error or a warning for non externalized
725 * String literal (i.e. non tagged with //$NON-NLS-<n>$).
726 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
727 * - possible values: { "error", "warning", "ignore" }
728 * - default: "ignore"
730 * COMPILER / Reporting Usage of 'assert' Identifier
731 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
732 * used as an identifier (reserved keyword in 1.4)
733 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.assertIdentifier"
734 * - possible values: { "error", "warning", "ignore" }
735 * - default: "ignore"
737 * COMPILER / Reporting Usage of expression receiver on static invocation/field access
738 * When enabled, the compiler will issue an error or a warning whenever a static field
739 * or method is accessed with an expression receiver.
740 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.staticAccessReceiver"
741 * - possible values: { "error", "warning", "ignore" }
742 * - default: "warning"
744 * COMPILER / Reporting Assignment with no effect
745 * When enabled, the compiler will issue an error or a warning whenever an assignment
746 * has no effect (e.g 'x = x').
747 * - option id: "org.phpeclipse.phpdt.core.compiler.problem.noEffectAssignment"
748 * - possible values: { "error", "warning", "ignore" }
749 * - default: "warning"
751 * COMPILER / Setting Source Compatibility Mode
752 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
753 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
754 * level should be set to "1.4" and the compliance mode should be "1.4".
755 * - option id: "org.phpeclipse.phpdt.core.compiler.source"
756 * - possible values: { "1.3", "1.4" }
759 * COMPILER / Setting Compliance Level
760 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
761 * should not go beyond "1.3" level.
762 * - option id: "org.phpeclipse.phpdt.core.compiler.compliance"
763 * - possible values: { "1.3", "1.4" }
766 * COMPILER / Maximum number of problems reported per compilation unit
767 * Specify the maximum number of problems reported on each compilation unit.
768 * - option id: "org.phpeclipse.phpdt.core.compiler.maxProblemPerUnit"
769 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
772 * COMPILER / Define the Automatic Task Tags
773 * When the tag is non empty, the compiler will issue a task marker whenever it encounters
774 * one of the corresponding tag inside any comment in Java source code.
775 * Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed.
776 * - option id: "org.phpeclipse.phpdt.core.compiler.taskTags"
777 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card
779 * COMPILER / Define the Automatic Task Priorities
780 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
781 * of the task markers issued by the compiler.
782 * If the default is specified, the priority of each task marker is "NORMAL".
783 * - option id: "org.phpeclipse.phpdt.core.compiler.taskPriorities"
784 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
787 * BUILDER / Specifying Filters for Resource Copying Control
788 * Allow to specify some filters to control the resource copy process.
789 * - option id: "org.phpeclipse.phpdt.core.builder.resourceCopyExclusionFilter"
790 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
791 * or the name of a folder which ends with '/'
794 * BUILDER / Abort if Invalid Classpath
795 * Allow to toggle the builder to abort if the classpath is invalid
796 * - option id: "org.phpeclipse.phpdt.core.builder.invalidClasspath"
797 * - possible values: { "abort", "ignore" }
798 * - default: "ignore"
800 * BUILDER / Cleaning Output Folder(s)
801 * Indicate whether the JavaBuilder is allowed to clean the output folders
802 * when performing full build operations.
803 * - option id: "org.phpeclipse.phpdt.core.builder.cleanOutputFolder"
804 * - possible values: { "clean", "ignore" }
807 * JAVACORE / Computing Project Build Order
808 * Indicate whether JavaCore should enforce the project build order to be based on
809 * the classpath prerequisite chain. When requesting to compute, this takes over
810 * the platform default order (based on project references).
811 * - option id: "org.phpeclipse.phpdt.core.computeJavaBuildOrder"
812 * - possible values: { "compute", "ignore" }
813 * - default: "ignore"
815 * JAVACORE / Specify Default Source Encoding Format
816 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
817 * to 'ResourcesPlugin.getEncoding()'.
818 * - option id: "org.phpeclipse.phpdt.core.encoding"
819 * - possible values: { any of the supported encoding name}.
820 * - default: <platform default>
822 * JAVACORE / Reporting Incomplete Classpath
823 * An entry on the classpath doesn't exist or is not visible (e.g. a referenced project is closed).
824 * - option id: "org.phpeclipse.phpdt.core.incompleteClasspath"
825 * - possible values: { "error", "warning"}
828 * JAVACORE / Reporting Classpath Cycle
829 * A project is involved in a cycle.
830 * - option id: "org.phpeclipse.phpdt.core.circularClasspath"
831 * - possible values: { "error", "warning" }
834 * FORMATTER / Inserting New Line Before Opening Brace
835 * When Insert, a new line is inserted before an opening brace, otherwise nothing
837 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.openingBrace"
838 * - possible values: { "insert", "do not insert" }
839 * - default: "do not insert"
841 * FORMATTER / Inserting New Line Inside Control Statement
842 * When Insert, a new line is inserted between } and following else, catch, finally
843 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.controlStatement"
844 * - possible values: { "insert", "do not insert" }
845 * - default: "do not insert"
847 * FORMATTER / Clearing Blank Lines
848 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
849 * and all others removed.
850 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.clearAll"
851 * - possible values: { "clear all", "preserve one" }
852 * - default: "preserve one"
854 * FORMATTER / Inserting New Line Between Else/If
855 * When Insert, a blank line is inserted between an else and an if when they are
856 * contiguous. When choosing to not insert, else-if will be kept on the same
857 * line when possible.
858 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.elseIf"
859 * - possible values: { "insert", "do not insert" }
860 * - default: "do not insert"
862 * FORMATTER / Inserting New Line In Empty Block
863 * When insert, a line break is inserted between contiguous { and }, if } is not followed
865 * - option id: "org.phpeclipse.phpdt.core.formatter.newline.emptyBlock"
866 * - possible values: { "insert", "do not insert" }
867 * - default: "insert"
869 * FORMATTER / Splitting Lines Exceeding Length
870 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
871 * disable line splitting
872 * - option id: "org.phpeclipse.phpdt.core.formatter.lineSplit"
873 * - possible values: "<n>", where n is zero or a positive integer
876 * FORMATTER / Compacting Assignment
877 * Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space
878 * is inserted before the assignment operator
879 * - option id: "org.phpeclipse.phpdt.core.formatter.style.assignment"
880 * - possible values: { "compact", "normal" }
881 * - default: "normal"
883 * FORMATTER / Defining Indentation Character
884 * Either choose to indent with tab characters or spaces
885 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.char"
886 * - possible values: { "tab", "space" }
889 * FORMATTER / Defining Space Indentation Length
890 * When using spaces, set the amount of space characters to use for each
892 * - option id: "org.phpeclipse.phpdt.core.formatter.tabulation.size"
893 * - possible values: "<n>", where n is a positive integer
896 * CODEASSIST / Activate Visibility Sensitive Completion
897 * When active, completion doesn't show that you can not see
898 * (e.g. you can not see private methods of a super class).
899 * - option id: "org.phpeclipse.phpdt.core.codeComplete.visibilityCheck"
900 * - possible values: { "enabled", "disabled" }
901 * - default: "disabled"
903 * CODEASSIST / Automatic Qualification of Implicit Members
904 * When active, completion automatically qualifies completion on implicit
905 * field references and message expressions.
906 * - option id: "org.phpeclipse.phpdt.core.codeComplete.forceImplicitQualification"
907 * - possible values: { "enabled", "disabled" }
908 * - default: "disabled"
910 * CODEASSIST / Define the Prefixes for Field Name
911 * When the prefixes is non empty, completion for field name will begin with
912 * one of the proposed prefixes.
913 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldPrefixes"
914 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
917 * CODEASSIST / Define the Prefixes for Static Field Name
918 * When the prefixes is non empty, completion for static field name will begin with
919 * one of the proposed prefixes.
920 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldPrefixes"
921 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
924 * CODEASSIST / Define the Prefixes for Local Variable Name
925 * When the prefixes is non empty, completion for local variable name will begin with
926 * one of the proposed prefixes.
927 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localPrefixes"
928 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
931 * CODEASSIST / Define the Prefixes for Argument Name
932 * When the prefixes is non empty, completion for argument name will begin with
933 * one of the proposed prefixes.
934 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentPrefixes"
935 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
938 * CODEASSIST / Define the Suffixes for Field Name
939 * When the suffixes is non empty, completion for field name will end with
940 * one of the proposed suffixes.
941 * - option id: "org.phpeclipse.phpdt.core.codeComplete.fieldSuffixes"
942 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
945 * CODEASSIST / Define the Suffixes for Static Field Name
946 * When the suffixes is non empty, completion for static field name will end with
947 * one of the proposed suffixes.
948 * - option id: "org.phpeclipse.phpdt.core.codeComplete.staticFieldSuffixes"
949 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
952 * CODEASSIST / Define the Suffixes for Local Variable Name
953 * When the suffixes is non empty, completion for local variable name will end with
954 * one of the proposed suffixes.
955 * - option id: "org.phpeclipse.phpdt.core.codeComplete.localSuffixes"
956 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
959 * CODEASSIST / Define the Suffixes for Argument Name
960 * When the suffixes is non empty, completion for argument name will end with
961 * one of the proposed suffixes.
962 * - option id: "org.phpeclipse.phpdt.core.codeComplete.argumentSuffixes"
963 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
967 * @return a mutable table containing the default settings of all known options
968 * (key type: <code>String</code>; value type: <code>String</code>)
971 // public static Hashtable getDefaultOptions() {
973 // Hashtable defaultOptions = new Hashtable(10);
975 // // see #initializeDefaultPluginPreferences() for changing default settings
976 // Preferences preferences = getPlugin().getPluginPreferences();
977 // HashSet optionNames = OptionNames;
979 // // get preferences set to their default
980 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
981 // for (int i = 0; i < defaultPropertyNames.length; i++) {
982 // String propertyName = defaultPropertyNames[i];
983 // if (optionNames.contains(propertyName)) {
984 // defaultOptions.put(propertyName, preferences.getDefaultString(propertyName));
987 // // get preferences not set to their default
988 // String[] propertyNames = preferences.propertyNames();
989 // for (int i = 0; i < propertyNames.length; i++) {
990 // String propertyName = propertyNames[i];
991 // if (optionNames.contains(propertyName)) {
992 // defaultOptions.put(propertyName, preferences.getDefaultString(propertyName));
995 // // get encoding through resource plugin
996 // defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
998 // return defaultOptions;
1001 * Helper method for returning one option value only. Equivalent to <code>(String)JavaCore.getOptions().get(optionName)</code>
1002 * Note that it may answer <code>null</code> if this option does not exist.
1004 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
1007 * @param optionName the name of an option
1008 * @return the String value of a given option
1009 * @see JavaCore#getDefaultOptions
1012 // public static String getOption(String optionName) {
1014 // if (CORE_ENCODING.equals(optionName)) {
1015 // return ResourcesPlugin.getEncoding();
1017 // if (OptionNames.contains(optionName)) {
1018 // Preferences preferences = getPlugin().getPluginPreferences();
1019 // return preferences.getString(optionName).trim();
1025 * Returns the table of the current options. Initially, all options have their default values,
1026 * and this method returns a table that includes all known options.
1028 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
1031 * @return table of current settings of all options
1032 * (key type: <code>String</code>; value type: <code>String</code>)
1033 * @see JavaCore#getDefaultOptions
1035 // public static Hashtable getOptions() {
1037 // Hashtable options = new Hashtable(10);
1039 // // see #initializeDefaultPluginPreferences() for changing default settings
1040 // Plugin plugin = getPlugin();
1041 // if (plugin != null) {
1042 // Preferences preferences = getPlugin().getPluginPreferences();
1043 // HashSet optionNames = OptionNames;
1045 // // get preferences set to their default
1046 // String[] defaultPropertyNames = preferences.defaultPropertyNames();
1047 // for (int i = 0; i < defaultPropertyNames.length; i++) {
1048 // String propertyName = defaultPropertyNames[i];
1049 // if (optionNames.contains(propertyName)) {
1050 // options.put(propertyName, preferences.getDefaultString(propertyName));
1053 // // get preferences not set to their default
1054 // String[] propertyNames = preferences.propertyNames();
1055 // for (int i = 0; i < propertyNames.length; i++) {
1056 // String propertyName = propertyNames[i];
1057 // if (optionNames.contains(propertyName)) {
1058 // options.put(propertyName, preferences.getString(propertyName).trim());
1061 // // get encoding through resource plugin
1062 // options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1067 * Sets the current table of options. All and only the options explicitly included in the given table
1068 * are remembered; all previous option settings are forgotten, including ones not explicitly
1071 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
1074 * @param newOptions the new options (key type: <code>String</code>; value type: <code>String</code>),
1075 * or <code>null</code> to reset all options to their default values
1076 * @see JavaCore#getDefaultOptions
1078 // public static void setOptions(Hashtable newOptions) {
1080 // // see #initializeDefaultPluginPreferences() for changing default settings
1081 // Preferences preferences = getPlugin().getPluginPreferences();
1083 // if (newOptions == null) {
1084 // newOptions = getDefaultOptions();
1086 // Enumeration keys = newOptions.keys();
1087 // while (keys.hasMoreElements()) {
1088 // String key = (String) keys.nextElement();
1089 // if (!OptionNames.contains(key))
1090 // continue; // unrecognized option
1091 // if (key.equals(CORE_ENCODING))
1092 // continue; // skipped, contributed by resource prefs
1093 // String value = (String) newOptions.get(key);
1094 // preferences.setValue(key, value);
1097 // // persist options
1098 // getPlugin().savePluginPreferences();
1100 public static IProject[] getPHPProjects() {
1101 List phpProjectsList = new ArrayList();
1102 IProject[] workspaceProjects = PHPeclipsePlugin.getWorkspace().getRoot().getProjects();
1104 for (int i = 0; i < workspaceProjects.length; i++) {
1105 IProject iProject = workspaceProjects[i];
1106 if (isPHPProject(iProject))
1107 phpProjectsList.add(iProject);
1110 IProject[] phpProjects = new IProject[phpProjectsList.size()];
1111 return (IProject[]) phpProjectsList.toArray(phpProjects);
1114 // public static PHPProject getPHPProject(String name) {
1115 // IProject aProject = PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
1116 // if (isPHPProject(aProject)) {
1117 // PHPProject thePHPProject = new PHPProject();
1118 // thePHPProject.setProject(aProject);
1119 // return thePHPProject;
1124 public static boolean isPHPProject(IProject aProject) {
1126 return aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID);
1127 } catch (CoreException e) {
1133 // public static PHPFile create(IFile aFile) {
1134 // if (PHPFile.EXTENSION.equalsIgnoreCase(aFile.getFileExtension()))
1135 // return new PHPFile(aFile);
1136 // if (PHPFile.EXTENSION1.equalsIgnoreCase(aFile.getFileExtension()))
1137 // return new PHPFile(aFile);
1138 // if (PHPFile.EXTENSION2.equalsIgnoreCase(aFile.getFileExtension()))
1139 // return new PHPFile(aFile);
1140 // if (PHPFile.EXTENSION3.equalsIgnoreCase(aFile.getFileExtension()))
1141 // return new PHPFile(aFile);
1142 // if (PHPFile.EXTENSION4.equalsIgnoreCase(aFile.getFileExtension()))
1143 // return new PHPFile(aFile);
1144 // if (PHPFile.EXTENSION5.equalsIgnoreCase(aFile.getFileExtension()))
1145 // return new PHPFile(aFile);
1150 // public static PHPProject create(IProject aProject) {
1153 // if (aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1154 // PHPProject project = new PHPProject();
1155 // project.setProject(aProject);
1158 // } catch (CoreException e) {
1159 // System.err.println("Exception occurred in PHPCore#create(IProject): " + e.toString());
1165 public static void addPHPNature(IProject project, IProgressMonitor monitor) throws CoreException {
1166 if (!project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1167 IProjectDescription description = project.getDescription();
1168 String[] prevNatures = description.getNatureIds();
1169 String[] newNatures = new String[prevNatures.length + 1];
1170 System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
1171 newNatures[prevNatures.length] = PHPeclipsePlugin.PHP_NATURE_ID;
1172 description.setNatureIds(newNatures);
1173 project.setDescription(description, monitor);
1178 * Returns the single instance of the PHP core plug-in runtime class.
1180 * @return the single instance of the PHP core plug-in runtime class
1182 public static Plugin getPlugin() {
1183 return PHPeclipsePlugin.getDefault();
1187 * Initializes the default preferences settings for this plug-in.
1191 * Runs the given action as an atomic Java model operation.
1193 * After running a method that modifies Java elements,
1194 * registered listeners receive after-the-fact notification of
1195 * what just transpired, in the form of a element changed event.
1196 * This method allows clients to call a number of
1197 * methods that modify java elements and only have element
1198 * changed event notifications reported at the end of the entire
1202 * If this method is called outside the dynamic scope of another such
1203 * call, this method runs the action and then reports a single
1204 * element changed event describing the net effect of all changes
1205 * done to java elements by the action.
1208 * If this method is called in the dynamic scope of another such
1209 * call, this method simply runs the action.
1212 * @param action the action to perform
1213 * @param monitor a progress monitor, or <code>null</code> if progress
1214 * reporting and cancellation are not desired
1215 * @exception CoreException if the operation failed.
1218 public static void run(IWorkspaceRunnable action, IProgressMonitor monitor) throws CoreException {
1219 IWorkspace workspace = ResourcesPlugin.getWorkspace();
1220 if (workspace.isTreeLocked()) {
1221 new BatchOperation(action).run(monitor);
1223 // use IWorkspace.run(...) to ensure that a build will be done in autobuild mode
1224 workspace.run(new BatchOperation(action), monitor);
1229 * Adds the given listener for changes to Java elements.
1230 * Has no effect if an identical listener is already registered.
1232 * This listener will only be notified during the POST_CHANGE resource change notification
1233 * and any reconcile operation (POST_RECONCILE).
1234 * For finer control of the notification, use <code>addElementChangedListener(IElementChangedListener,int)</code>,
1235 * which allows to specify a different eventMask.
1237 * @see ElementChangedEvent
1238 * @param listener the listener
1240 public static void addElementChangedListener(IElementChangedListener listener) {
1241 addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE | ElementChangedEvent.POST_RECONCILE);
1245 * Adds the given listener for changes to Java elements.
1246 * Has no effect if an identical listener is already registered.
1247 * After completion of this method, the given listener will be registered for exactly
1248 * the specified events. If they were previously registered for other events, they
1249 * will be deregistered.
1251 * Once registered, a listener starts receiving notification of changes to
1252 * java elements in the model. The listener continues to receive
1253 * notifications until it is replaced or removed.
1256 * Listeners can listen for several types of event as defined in <code>ElementChangeEvent</code>.
1257 * Clients are free to register for any number of event types however if they register
1258 * for more than one, it is their responsibility to ensure they correctly handle the
1259 * case where the same java element change shows up in multiple notifications.
1260 * Clients are guaranteed to receive only the events for which they are registered.
1263 * @param listener the listener
1264 * @param eventMask the bit-wise OR of all event types of interest to the listener
1265 * @see IElementChangedListener
1266 * @see ElementChangedEvent
1267 * @see #removeElementChangedListener(IElementChangedListener)
1270 public static void addElementChangedListener(IElementChangedListener listener, int eventMask) {
1271 JavaModelManager.getJavaModelManager().addElementChangedListener(listener, eventMask);
1275 * Configures the given marker attribute map for the given Java element.
1276 * Used for markers, which denote a Java element rather than a resource.
1278 * @param attributes the mutable marker attribute map (key type: <code>String</code>,
1279 * value type: <code>String</code>)
1280 * @param element the Java element for which the marker needs to be configured
1282 public static void addJavaElementMarkerAttributes(
1284 IJavaElement element) {
1285 // if (element instanceof IMember)
1286 // element = ((IMember) element).getClassFile();
1287 if (attributes != null && element != null)
1288 attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier());
1292 * Configures the given marker for the given Java element.
1293 * Used for markers, which denote a Java element rather than a resource.
1295 * @param marker the marker to be configured
1296 * @param element the Java element for which the marker needs to be configured
1297 * @exception CoreException if the <code>IMarker.setAttribute</code> on the marker fails
1299 public void configureJavaElementMarker(IMarker marker, IJavaElement element)
1300 throws CoreException {
1301 // if (element instanceof IMember)
1302 // element = ((IMember) element).getClassFile();
1303 if (marker != null && element != null)
1304 marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier());
1308 * Returns the Java model element corresponding to the given handle identifier
1309 * generated by <code>IJavaElement.getHandleIdentifier()</code>, or
1310 * <code>null</code> if unable to create the associated element.
1312 public static IJavaElement create(String handleIdentifier) {
1313 if (handleIdentifier == null) {
1317 return JavaModelManager.getJavaModelManager().getHandleFromMemento(handleIdentifier);
1318 } catch (JavaModelException e) {
1323 * Returns the Java element corresponding to the given file, or
1324 * <code>null</code> if unable to associate the given file
1325 * with a Java element.
1327 * <p>The file must be one of:<ul>
1328 * <li>a <code>.java</code> file - the element returned is the corresponding <code>ICompilationUnit</code></li>
1329 * <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li>
1330 * <li>a <code>.jar</code> file - the element returned is the corresponding <code>IPackageFragmentRoot</code></li>
1333 * Creating a Java element has the side effect of creating and opening all of the
1334 * element's parents if they are not yet open.
1336 * @param the given file
1337 * @return the Java element corresponding to the given file, or
1338 * <code>null</code> if unable to associate the given file
1339 * with a Java element
1341 public static IJavaElement create(IFile file) {
1342 return JavaModelManager.create(file, null);
1345 * Returns the package fragment or package fragment root corresponding to the given folder, or
1346 * <code>null</code> if unable to associate the given folder with a Java element.
1348 * Note that a package fragment root is returned rather than a default package.
1350 * Creating a Java element has the side effect of creating and opening all of the
1351 * element's parents if they are not yet open.
1353 * @param the given folder
1354 * @return the package fragment or package fragment root corresponding to the given folder, or
1355 * <code>null</code> if unable to associate the given folder with a Java element
1357 public static IJavaElement create(IFolder folder) {
1358 return JavaModelManager.create(folder, null);
1361 * Returns the Java project corresponding to the given project.
1363 * Creating a Java Project has the side effect of creating and opening all of the
1364 * project's parents if they are not yet open.
1366 * Note that no check is done at this time on the existence or the java nature of this project.
1368 * @param project the given project
1369 * @return the Java project corresponding to the given project, null if the given project is null
1371 public static IJavaProject create(IProject project) {
1372 if (project == null) {
1375 JavaModel javaModel = JavaModelManager.getJavaModelManager().getJavaModel();
1376 return javaModel.getJavaProject(project);
1379 * Returns the Java element corresponding to the given resource, or
1380 * <code>null</code> if unable to associate the given resource
1381 * with a Java element.
1383 * The resource must be one of:<ul>
1384 * <li>a project - the element returned is the corresponding <code>IJavaProject</code></li>
1385 * <li>a <code>.java</code> file - the element returned is the corresponding <code>ICompilationUnit</code></li>
1386 * <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li>
1387 * <li>a <code>.jar</code> file - the element returned is the corresponding <code>IPackageFragmentRoot</code></li>
1388 * <li>a folder - the element returned is the corresponding <code>IPackageFragmentRoot</code>
1389 * or <code>IPackageFragment</code></li>
1390 * <li>the workspace root resource - the element returned is the <code>IJavaModel</code></li>
1393 * Creating a Java element has the side effect of creating and opening all of the
1394 * element's parents if they are not yet open.
1396 * @param resource the given resource
1397 * @return the Java element corresponding to the given resource, or
1398 * <code>null</code> if unable to associate the given resource
1399 * with a Java element
1401 public static IJavaElement create(IResource resource) {
1402 return JavaModelManager.create(resource, null);
1405 * Returns the Java model.
1407 * @param root the given root
1408 * @return the Java model, or <code>null</code> if the root is null
1410 public static IJavaModel create(IWorkspaceRoot root) {
1414 return JavaModelManager.getJavaModelManager().getJavaModel();
1417 * Creates and returns a class file element for
1418 * the given <code>.class</code> file. Returns <code>null</code> if unable
1419 * to recognize the class file.
1421 * @param file the given <code>.class</code> file
1422 * @return a class file element for the given <code>.class</code> file, or <code>null</code> if unable
1423 * to recognize the class file
1425 //public static IClassFile createClassFileFrom(IFile file) {
1426 // return JavaModelManager.createClassFileFrom(file, null);
1429 * Creates and returns a compilation unit element for
1430 * the given <code>.java</code> file. Returns <code>null</code> if unable
1431 * to recognize the compilation unit.
1433 * @param file the given <code>.java</code> file
1434 * @return a compilation unit element for the given <code>.java</code> file, or <code>null</code> if unable
1435 * to recognize the compilation unit
1437 public static ICompilationUnit createCompilationUnitFrom(IFile file) {
1438 return JavaModelManager.createCompilationUnitFrom(file, null);
1441 * Creates and returns a handle for the given JAR file.
1442 * The Java model associated with the JAR's project may be
1443 * created as a side effect.
1445 * @param file the given JAR file
1446 * @return a handle for the given JAR file, or <code>null</code> if unable to create a JAR package fragment root.
1447 * (for example, if the JAR file represents a non-Java resource)
1449 //public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile file) {
1450 // return JavaModelManager.createJarPackageFragmentRootFrom(file, null);
1454 * Answers the project specific value for a given classpath container.
1455 * In case this container path could not be resolved, then will answer <code>null</code>.
1456 * Both the container path and the project context are supposed to be non-null.
1458 * The containerPath is a formed by a first ID segment followed with extra segments, which can be
1459 * used as additional hints for resolution. If no container was ever recorded for this container path
1460 * onto this project (using <code>setClasspathContainer</code>, then a
1461 * <code>ClasspathContainerInitializer</code> will be activated if any was registered for this container
1462 * ID onto the extension point "org.eclipse.jdt.core.classpathContainerInitializer".
1464 * There is no assumption that the returned container must answer the exact same containerPath
1465 * when requested <code>IClasspathContainer#getPath</code>.
1466 * Indeed, the containerPath is just an indication for resolving it to an actual container object.
1468 * Classpath container values are persisted locally to the workspace, but
1469 * are not preserved from a session to another. It is thus highly recommended to register a
1470 * <code>ClasspathContainerInitializer</code> for each referenced container
1471 * (through the extension point "org.eclipse.jdt.core.ClasspathContainerInitializer").
1473 * @param containerPath the name of the container, which needs to be resolved
1474 * @param project a specific project in which the container is being resolved
1475 * @return the corresponding classpath container or <code>null</code> if unable to find one.
1477 * @exception JavaModelException if an exception occurred while resolving the container, or if the resolved container
1478 * contains illegal entries (contains CPE_CONTAINER entries or null entries).
1480 * @see ClasspathContainerInitializer
1481 * @see IClasspathContainer
1482 * @see #setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor)
1485 //public static IClasspathContainer getClasspathContainer(final IPath containerPath, final IJavaProject project) throws JavaModelException {
1487 // IClasspathContainer container = JavaModelManager.containerGet(project, containerPath);
1488 // if (container == JavaModelManager.ContainerInitializationInProgress) return null; // break cycle
1490 // if (container == null){
1491 // final ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
1492 // if (initializer != null){
1493 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1494 // System.out.println("CPContainer INIT - triggering initialization of: ["+project.getElementName()+"] " + containerPath + " using initializer: "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
1495 // new Exception("FAKE exception for dumping current CPContainer (["+project.getElementName()+"] "+ containerPath+ ")INIT invocation stack trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
1497 // JavaModelManager.containerPut(project, containerPath, JavaModelManager.ContainerInitializationInProgress); // avoid initialization cycles
1498 // boolean ok = false;
1500 // // wrap initializer call with Safe runnable in case initializer would be causing some grief
1501 // Platform.run(new ISafeRunnable() {
1502 // public void handleException(Throwable exception) {
1503 // Util.log(exception, "Exception occurred in classpath container initializer: "+initializer); //$NON-NLS-1$
1505 // public void run() throws Exception {
1506 // initializer.initialize(containerPath, project);
1510 // // retrieve value (if initialization was successful)
1511 // container = JavaModelManager.containerGet(project, containerPath);
1512 // if (container == JavaModelManager.ContainerInitializationInProgress) return null; // break cycle
1515 // if (!ok) JavaModelManager.containerPut(project, containerPath, null); // flush cache
1517 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1518 // System.out.print("CPContainer INIT - after resolution: ["+project.getElementName()+"] " + containerPath + " --> "); //$NON-NLS-2$//$NON-NLS-1$//$NON-NLS-3$
1519 // if (container != null){
1520 // System.out.print("container: "+container.getDescription()+" {"); //$NON-NLS-2$//$NON-NLS-1$
1521 // IClasspathEntry[] entries = container.getClasspathEntries();
1522 // if (entries != null){
1523 // for (int i = 0; i < entries.length; i++){
1524 // if (i > 0) System.out.println(", ");//$NON-NLS-1$
1525 // System.out.println(entries[i]);
1528 // System.out.println("}");//$NON-NLS-1$
1530 // System.out.println("{unbound}");//$NON-NLS-1$
1534 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1535 // System.out.println("CPContainer INIT - no initializer found for: "+project.getElementName()+"] " + containerPath); //$NON-NLS-1$ //$NON-NLS-2$
1539 // return container;
1543 * Helper method finding the classpath container initializer registered for a given classpath container ID
1544 * or <code>null</code> if none was found while iterating over the contributions to extension point to
1545 * the extension point "org.eclipse.jdt.core.classpathContainerInitializer".
1547 * A containerID is the first segment of any container path, used to identify the registered container initializer.
1549 * @param String - a containerID identifying a registered initializer
1550 * @return ClasspathContainerInitializer - the registered classpath container initializer or <code>null</code> if
1554 //public static ClasspathContainerInitializer getClasspathContainerInitializer(String containerID){
1556 // Plugin jdtCorePlugin = JavaCore.getPlugin();
1557 // if (jdtCorePlugin == null) return null;
1559 // IExtensionPoint extension = jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID);
1560 // if (extension != null) {
1561 // IExtension[] extensions = extension.getExtensions();
1562 // for(int i = 0; i < extensions.length; i++){
1563 // IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
1564 // for(int j = 0; j < configElements.length; j++){
1565 // String initializerID = configElements[j].getAttribute("id"); //$NON-NLS-1$
1566 // if (initializerID != null && initializerID.equals(containerID)){
1567 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
1568 // System.out.println("CPContainer INIT - found initializer: "+containerID +" --> " + configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
1571 // Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
1572 // if (execExt instanceof ClasspathContainerInitializer){
1573 // return (ClasspathContainerInitializer)execExt;
1575 // } catch(CoreException e) {
1585 * Returns the path held in the given classpath variable.
1586 * Returns <node>null</code> if unable to bind.
1588 * Classpath variable values are persisted locally to the workspace, and
1589 * are preserved from session to session.
1591 * Note that classpath variables can be contributed registered initializers for,
1592 * using the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
1593 * If an initializer is registered for a variable, its persisted value will be ignored:
1594 * its initializer will thus get the opportunity to rebind the variable differently on
1597 * @param variableName the name of the classpath variable
1598 * @return the path, or <code>null</code> if none
1599 * @see #setClasspathVariable
1601 public static IPath getClasspathVariable(final String variableName) {
1603 IPath variablePath = JavaModelManager.variableGet(variableName);
1604 if (variablePath == JavaModelManager.VariableInitializationInProgress) return null; // break cycle
1606 if (variablePath != null) {
1607 return variablePath;
1610 // even if persisted value exists, initializer is given priority, only if no initializer is found the persisted value is reused
1611 // final ClasspathVariableInitializer initializer = PHPCore.getClasspathVariableInitializer(variableName);
1612 // if (initializer != null){
1613 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1614 // System.out.println("CPVariable INIT - triggering initialization of: " + variableName+ " using initializer: "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$
1615 // new Exception("FAKE exception for dumping current CPVariable ("+variableName+ ")INIT invocation stack trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$
1617 // JavaModelManager.variablePut(variableName, JavaModelManager.VariableInitializationInProgress); // avoid initialization cycles
1618 // boolean ok = false;
1620 // // wrap initializer call with Safe runnable in case initializer would be causing some grief
1621 // Platform.run(new ISafeRunnable() {
1622 // public void handleException(Throwable exception) {
1623 // Util.log(exception, "Exception occurred in classpath variable initializer: "+initializer+" while initializing variable: "+variableName); //$NON-NLS-1$ //$NON-NLS-2$
1625 // public void run() throws Exception {
1626 // initializer.initialize(variableName);
1629 // variablePath = (IPath) JavaModelManager.variableGet(variableName); // initializer should have performed side-effect
1630 // if (variablePath == JavaModelManager.VariableInitializationInProgress) return null; // break cycle (initializer did not init or reentering call)
1631 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1632 // System.out.println("CPVariable INIT - after initialization: " + variableName + " --> " + variablePath); //$NON-NLS-2$//$NON-NLS-1$
1636 // if (!ok) JavaModelManager.variablePut(variableName, null); // flush cache
1639 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
1640 // System.out.println("CPVariable INIT - no initializer found for: " + variableName); //$NON-NLS-1$
1643 return variablePath;
1647 * Helper method finding the classpath variable initializer registered for a given classpath variable name
1648 * or <code>null</code> if none was found while iterating over the contributions to extension point to
1649 * the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
1651 * @param the given variable
1652 * @return ClasspathVariableInitializer - the registered classpath variable initializer or <code>null</code> if
1656 public static ClasspathVariableInitializer getClasspathVariableInitializer(String variable){
1658 Plugin jdtCorePlugin = PHPCore.getPlugin();
1659 if (jdtCorePlugin == null) return null;
1661 // IExtensionPoint extension = jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID);
1662 // if (extension != null) {
1663 // IExtension[] extensions = extension.getExtensions();
1664 // for(int i = 0; i < extensions.length; i++){
1665 // IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
1666 // for(int j = 0; j < configElements.length; j++){
1668 // String varAttribute = configElements[j].getAttribute("variable"); //$NON-NLS-1$
1669 // if (variable.equals(varAttribute)) {
1670 // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
1671 // System.out.println("CPVariable INIT - found initializer: "+variable+" --> " + configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
1673 // Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
1674 // if (execExt instanceof ClasspathVariableInitializer){
1675 // return (ClasspathVariableInitializer)execExt;
1678 // } catch(CoreException e){
1687 * Returns the names of all known classpath variables.
1689 * Classpath variable values are persisted locally to the workspace, and
1690 * are preserved from session to session.
1693 * @return the list of classpath variable names
1694 * @see #setClasspathVariable
1696 //public static String[] getClasspathVariableNames() {
1697 // return JavaModelManager.variableNames();
1701 * Returns a table of all known configurable options with their default values.
1702 * These options allow to configure the behaviour of the underlying components.
1703 * The client may safely use the result as a template that they can modify and
1704 * then pass to <code>setOptions</code>.
1706 * Helper constants have been defined on JavaCore for each of the option ID and
1707 * their possible constant values.
1709 * Note: more options might be added in further releases.
1711 * RECOGNIZED OPTIONS:
1712 * COMPILER / Generating Local Variable Debug Attribute
1713 * When generated, this attribute will enable local variable names
1714 * to be displayed in debugger, only in place where variables are
1715 * definitely assigned (.class file is then bigger)
1716 * - option id: "org.eclipse.jdt.core.compiler.debug.localVariable"
1717 * - possible values: { "generate", "do not generate" }
1718 * - default: "generate"
1720 * COMPILER / Generating Line Number Debug Attribute
1721 * When generated, this attribute will enable source code highlighting in debugger
1722 * (.class file is then bigger).
1723 * - option id: "org.eclipse.jdt.core.compiler.debug.lineNumber"
1724 * - possible values: { "generate", "do not generate" }
1725 * - default: "generate"
1727 * COMPILER / Generating Source Debug Attribute
1728 * When generated, this attribute will enable the debugger to present the
1729 * corresponding source code.
1730 * - option id: "org.eclipse.jdt.core.compiler.debug.sourceFile"
1731 * - possible values: { "generate", "do not generate" }
1732 * - default: "generate"
1734 * COMPILER / Preserving Unused Local Variables
1735 * Unless requested to preserve unused local variables (that is, never read), the
1736 * compiler will optimize them out, potentially altering debugging
1737 * - option id: "org.eclipse.jdt.core.compiler.codegen.unusedLocal"
1738 * - possible values: { "preserve", "optimize out" }
1739 * - default: "preserve"
1741 * COMPILER / Defining Target Java Platform
1742 * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
1743 * Note that "1.4" target require to toggle compliance mode to "1.4" too.
1744 * - option id: "org.eclipse.jdt.core.compiler.codegen.targetPlatform"
1745 * - possible values: { "1.1", "1.2", "1.3", "1.4" }
1748 * COMPILER / Reporting Unreachable Code
1749 * Unreachable code can optionally be reported as an error, warning or simply
1750 * ignored. The bytecode generation will always optimized it out.
1751 * - option id: "org.eclipse.jdt.core.compiler.problem.unreachableCode"
1752 * - possible values: { "error", "warning", "ignore" }
1753 * - default: "error"
1755 * COMPILER / Reporting Invalid Import
1756 * An import statement that cannot be resolved might optionally be reported
1757 * as an error, as a warning or ignored.
1758 * - option id: "org.eclipse.jdt.core.compiler.problem.invalidImport"
1759 * - possible values: { "error", "warning", "ignore" }
1760 * - default: "error"
1762 * COMPILER / Reporting Attempt to Override Package-Default Method
1763 * A package default method is not visible in a different package, and thus
1764 * cannot be overridden. When enabling this option, the compiler will signal
1765 * such scenarii either as an error or a warning.
1766 * - option id: "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"
1767 * - possible values: { "error", "warning", "ignore" }
1768 * - default: "warning"
1770 * COMPILER / Reporting Method With Constructor Name
1771 * Naming a method with a constructor name is generally considered poor
1772 * style programming. When enabling this option, the compiler will signal such
1773 * scenarii either as an error or a warning.
1774 * - option id: "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"
1775 * - possible values: { "error", "warning", "ignore" }
1776 * - default: "warning"
1778 * COMPILER / Reporting Deprecation
1779 * When enabled, the compiler will signal use of deprecated API either as an
1780 * error or a warning.
1781 * - option id: "org.eclipse.jdt.core.compiler.problem.deprecation"
1782 * - possible values: { "error", "warning", "ignore" }
1783 * - default: "warning"
1785 * COMPILER / Reporting Deprecation Inside Deprecated Code
1786 * When enabled, the compiler will signal use of deprecated API inside deprecated code.
1787 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.deprecation".
1788 * - option id: "org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode"
1789 * - possible values: { "enabled", "disabled" }
1790 * - default: "disabled"
1792 * COMPILER / Reporting Hidden Catch Block
1793 * Locally to a try statement, some catch blocks may hide others . For example,
1794 * try { throw new java.io.CharConversionException();
1795 * } catch (java.io.CharConversionException e) {
1796 * } catch (java.io.IOException e) {}.
1797 * When enabling this option, the compiler will issue an error or a warning for hidden
1798 * catch blocks corresponding to checked exceptions
1799 * - option id: "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"
1800 * - possible values: { "error", "warning", "ignore" }
1801 * - default: "warning"
1803 * COMPILER / Reporting Unused Local
1804 * When enabled, the compiler will issue an error or a warning for unused local
1805 * variables (that is, variables never read from)
1806 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedLocal"
1807 * - possible values: { "error", "warning", "ignore" }
1808 * - default: "ignore"
1810 * COMPILER / Reporting Unused Parameter
1811 * When enabled, the compiler will issue an error or a warning for unused method
1812 * parameters (that is, parameters never read from)
1813 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameter"
1814 * - possible values: { "error", "warning", "ignore" }
1815 * - default: "ignore"
1817 * COMPILER / Reporting Unused Parameter if Implementing Abstract Method
1818 * When enabled, the compiler will signal unused parameters in abstract method implementations.
1819 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
1820 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"
1821 * - possible values: { "enabled", "disabled" }
1822 * - default: "disabled"
1824 * COMPILER / Reporting Unused Parameter if Overriding Concrete Method
1825 * When enabled, the compiler will signal unused parameters in methods overriding concrete ones.
1826 * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
1827 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"
1828 * - possible values: { "enabled", "disabled" }
1829 * - default: "disabled"
1831 * COMPILER / Reporting Unused Import
1832 * When enabled, the compiler will issue an error or a warning for unused import
1834 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedImport"
1835 * - possible values: { "error", "warning", "ignore" }
1836 * - default: "warning"
1838 * COMPILER / Reporting Unused Private Members
1839 * When enabled, the compiler will issue an error or a warning whenever a private
1840 * method or field is declared but never used within the same unit.
1841 * - option id: "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"
1842 * - possible values: { "error", "warning", "ignore" }
1843 * - default: "ignore"
1845 * COMPILER / Reporting Synthetic Access Emulation
1846 * When enabled, the compiler will issue an error or a warning whenever it emulates
1847 * access to a non-accessible member of an enclosing type. Such access can have
1848 * performance implications.
1849 * - option id: "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"
1850 * - possible values: { "error", "warning", "ignore" }
1851 * - default: "ignore"
1853 * COMPILER / Reporting Non-Externalized String Literal
1854 * When enabled, the compiler will issue an error or a warning for non externalized
1855 * String literal (that is, not tagged with //$NON-NLS-<n>$).
1856 * - option id: "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"
1857 * - possible values: { "error", "warning", "ignore" }
1858 * - default: "ignore"
1860 * COMPILER / Reporting Usage of 'assert' Identifier
1861 * When enabled, the compiler will issue an error or a warning whenever 'assert' is
1862 * used as an identifier (reserved keyword in 1.4)
1863 * - option id: "org.eclipse.jdt.core.compiler.problem.assertIdentifier"
1864 * - possible values: { "error", "warning", "ignore" }
1865 * - default: "ignore"
1867 * COMPILER / Reporting Non-Static Reference to a Static Member
1868 * When enabled, the compiler will issue an error or a warning whenever a static field
1869 * or method is accessed with an expression receiver. A reference to a static member should
1870 * be qualified with a type name.
1871 * - option id: "org.eclipse.jdt.core.compiler.problem.staticAccessReceiver"
1872 * - possible values: { "error", "warning", "ignore" }
1873 * - default: "warning"
1875 * COMPILER / Reporting Assignment with no Effect
1876 * When enabled, the compiler will issue an error or a warning whenever an assignment
1877 * has no effect (e.g 'x = x').
1878 * - option id: "org.eclipse.jdt.core.compiler.problem.noEffectAssignment"
1879 * - possible values: { "error", "warning", "ignore" }
1880 * - default: "warning"
1882 * COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods
1883 * When enabled, the compiler will issue an error or a warning whenever an interface
1884 * defines a method incompatible with a non-inherited Object method. Until this conflict
1885 * is resolved, such an interface cannot be implemented, For example,
1889 * - option id: "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"
1890 * - possible values: { "error", "warning", "ignore" }
1891 * - default: "warning"
1893 * COMPILER / Reporting Usage of char[] Expressions in String Concatenations
1894 * When enabled, the compiler will issue an error or a warning whenever a char[] expression
1895 * is used in String concatenations (for example, "hello" + new char[]{'w','o','r','l','d'}).
1896 * - option id: "org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion"
1897 * - possible values: { "error", "warning", "ignore" }
1898 * - default: "warning"
1900 * COMPILER / Setting Source Compatibility Mode
1901 * Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
1902 * reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
1903 * level should be set to "1.4" and the compliance mode should be "1.4".
1904 * - option id: "org.eclipse.jdt.core.compiler.source"
1905 * - possible values: { "1.3", "1.4" }
1908 * COMPILER / Setting Compliance Level
1909 * Select the compliance level for the compiler. In "1.3" mode, source and target settings
1910 * should not go beyond "1.3" level.
1911 * - option id: "org.eclipse.jdt.core.compiler.compliance"
1912 * - possible values: { "1.3", "1.4" }
1915 * COMPILER / Maximum number of problems reported per compilation unit
1916 * Specify the maximum number of problems reported on each compilation unit.
1917 * - option id: "org.eclipse.jdt.core.compiler.maxProblemPerUnit"
1918 * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
1921 * COMPILER / Define the Automatic Task Tags
1922 * When the tag list is not empty, the compiler will issue a task marker whenever it encounters
1923 * one of the corresponding tag inside any comment in Java source code.
1924 * Generated task messages will include the tag, and range until the next line separator or comment ending.
1925 * Note that tasks messages are trimmed.
1926 * - option id: "org.eclipse.jdt.core.compiler.taskTags"
1927 * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card or leading/trailing spaces
1930 * COMPILER / Define the Automatic Task Priorities
1931 * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
1932 * of the task markers issued by the compiler.
1933 * If the default is specified, the priority of each task marker is "NORMAL".
1934 * - option id: "org.eclipse.jdt.core.compiler.taskPriorities"
1935 * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
1938 * BUILDER / Specifying Filters for Resource Copying Control
1939 * Allow to specify some filters to control the resource copy process.
1940 * - option id: "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
1941 * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
1942 * or the name of a folder which ends with '/'
1945 * BUILDER / Abort if Invalid Classpath
1946 * Allow to toggle the builder to abort if the classpath is invalid
1947 * - option id: "org.eclipse.jdt.core.builder.invalidClasspath"
1948 * - possible values: { "abort", "ignore" }
1949 * - default: "abort"
1951 * BUILDER / Cleaning Output Folder(s)
1952 * Indicate whether the JavaBuilder is allowed to clean the output folders
1953 * when performing full build operations.
1954 * - option id: "org.eclipse.jdt.core.builder.cleanOutputFolder"
1955 * - possible values: { "clean", "ignore" }
1956 * - default: "clean"
1958 * BUILDER / Reporting Duplicate Resources
1959 * Indicate the severity of the problem reported when more than one occurrence
1960 * of a resource is to be copied into the output location.
1961 * - option id: "org.eclipse.jdt.core.builder.duplicateResourceTask"
1962 * - possible values: { "error", "warning" }
1963 * - default: "warning"
1965 * JAVACORE / Computing Project Build Order
1966 * Indicate whether JavaCore should enforce the project build order to be based on
1967 * the classpath prerequisite chain. When requesting to compute, this takes over
1968 * the platform default order (based on project references).
1969 * - option id: "org.eclipse.jdt.core.computeJavaBuildOrder"
1970 * - possible values: { "compute", "ignore" }
1971 * - default: "ignore"
1973 * JAVACORE / Specify Default Source Encoding Format
1974 * Get the encoding format for compiled sources. This setting is read-only, it is equivalent
1975 * to 'ResourcesPlugin.getEncoding()'.
1976 * - option id: "org.eclipse.jdt.core.encoding"
1977 * - possible values: { any of the supported encoding name}.
1978 * - default: <platform default>
1980 * JAVACORE / Reporting Incomplete Classpath
1981 * Indicate the severity of the problem reported when an entry on the classpath does not exist,
1982 * is not legite or is not visible (for example, a referenced project is closed).
1983 * - option id: "org.eclipse.jdt.core.incompleteClasspath"
1984 * - possible values: { "error", "warning"}
1985 * - default: "error"
1987 * JAVACORE / Reporting Classpath Cycle
1988 * Indicate the severity of the problem reported when a project is involved in a cycle.
1989 * - option id: "org.eclipse.jdt.core.circularClasspath"
1990 * - possible values: { "error", "warning" }
1991 * - default: "error"
1993 * JAVACORE / Enabling Usage of Classpath Exclusion Patterns
1994 * When disabled, no entry on a project classpath can be associated with
1995 * an exclusion pattern.
1996 * - option id: "org.eclipse.jdt.core.classpath.exclusionPatterns"
1997 * - possible values: { "enabled", "disabled" }
1998 * - default: "enabled"
2000 * JAVACORE / Enabling Usage of Classpath Multiple Output Locations
2001 * When disabled, no entry on a project classpath can be associated with
2002 * a specific output location, preventing thus usage of multiple output locations.
2003 * - option id: "org.eclipse.jdt.core.classpath.multipleOutputLocations"
2004 * - possible values: { "enabled", "disabled" }
2005 * - default: "enabled"
2007 * FORMATTER / Inserting New Line Before Opening Brace
2008 * When Insert, a new line is inserted before an opening brace, otherwise nothing
2010 * - option id: "org.eclipse.jdt.core.formatter.newline.openingBrace"
2011 * - possible values: { "insert", "do not insert" }
2012 * - default: "do not insert"
2014 * FORMATTER / Inserting New Line Inside Control Statement
2015 * When Insert, a new line is inserted between } and following else, catch, finally
2016 * - option id: "org.eclipse.jdt.core.formatter.newline.controlStatement"
2017 * - possible values: { "insert", "do not insert" }
2018 * - default: "do not insert"
2020 * FORMATTER / Clearing Blank Lines
2021 * When Clear all, all blank lines are removed. When Preserve one, only one is kept
2022 * and all others removed.
2023 * - option id: "org.eclipse.jdt.core.formatter.newline.clearAll"
2024 * - possible values: { "clear all", "preserve one" }
2025 * - default: "preserve one"
2027 * FORMATTER / Inserting New Line Between Else/If
2028 * When Insert, a blank line is inserted between an else and an if when they are
2029 * contiguous. When choosing to not insert, else-if will be kept on the same
2030 * line when possible.
2031 * - option id: "org.eclipse.jdt.core.formatter.newline.elseIf"
2032 * - possible values: { "insert", "do not insert" }
2033 * - default: "do not insert"
2035 * FORMATTER / Inserting New Line In Empty Block
2036 * When insert, a line break is inserted between contiguous { and }, if } is not followed
2038 * - option id: "org.eclipse.jdt.core.formatter.newline.emptyBlock"
2039 * - possible values: { "insert", "do not insert" }
2040 * - default: "insert"
2042 * FORMATTER / Splitting Lines Exceeding Length
2043 * Enable splitting of long lines (exceeding the configurable length). Length of 0 will
2044 * disable line splitting
2045 * - option id: "org.eclipse.jdt.core.formatter.lineSplit"
2046 * - possible values: "<n>", where n is zero or a positive integer
2049 * FORMATTER / Compacting Assignment
2050 * Assignments can be formatted asymmetrically, for example 'int x= 2;', when Normal, a space
2051 * is inserted before the assignment operator
2052 * - option id: "org.eclipse.jdt.core.formatter.style.assignment"
2053 * - possible values: { "compact", "normal" }
2054 * - default: "normal"
2056 * FORMATTER / Defining Indentation Character
2057 * Either choose to indent with tab characters or spaces
2058 * - option id: "org.eclipse.jdt.core.formatter.tabulation.char"
2059 * - possible values: { "tab", "space" }
2062 * FORMATTER / Defining Space Indentation Length
2063 * When using spaces, set the amount of space characters to use for each
2065 * - option id: "org.eclipse.jdt.core.formatter.tabulation.size"
2066 * - possible values: "<n>", where n is a positive integer
2069 * FORMATTER / Inserting space in cast expression
2070 * When Insert, a space is added between the type and the expression in a cast expression.
2071 * - option id: "org.eclipse.jdt.core.formatter.space.castexpression"
2072 * - possible values: { "insert", "do not insert" }
2073 * - default: "insert"
2075 * CODEASSIST / Activate Visibility Sensitive Completion
2076 * When active, completion doesn't show that you can not see
2077 * (for example, you can not see private methods of a super class).
2078 * - option id: "org.eclipse.jdt.core.codeComplete.visibilityCheck"
2079 * - possible values: { "enabled", "disabled" }
2080 * - default: "disabled"
2082 * CODEASSIST / Automatic Qualification of Implicit Members
2083 * When active, completion automatically qualifies completion on implicit
2084 * field references and message expressions.
2085 * - option id: "org.eclipse.jdt.core.codeComplete.forceImplicitQualification"
2086 * - possible values: { "enabled", "disabled" }
2087 * - default: "disabled"
2089 * CODEASSIST / Define the Prefixes for Field Name
2090 * When the prefixes is non empty, completion for field name will begin with
2091 * one of the proposed prefixes.
2092 * - option id: "org.eclipse.jdt.core.codeComplete.fieldPrefixes"
2093 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2096 * CODEASSIST / Define the Prefixes for Static Field Name
2097 * When the prefixes is non empty, completion for static field name will begin with
2098 * one of the proposed prefixes.
2099 * - option id: "org.eclipse.jdt.core.codeComplete.staticFieldPrefixes"
2100 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2103 * CODEASSIST / Define the Prefixes for Local Variable Name
2104 * When the prefixes is non empty, completion for local variable name will begin with
2105 * one of the proposed prefixes.
2106 * - option id: "org.eclipse.jdt.core.codeComplete.localPrefixes"
2107 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2110 * CODEASSIST / Define the Prefixes for Argument Name
2111 * When the prefixes is non empty, completion for argument name will begin with
2112 * one of the proposed prefixes.
2113 * - option id: "org.eclipse.jdt.core.codeComplete.argumentPrefixes"
2114 * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
2117 * CODEASSIST / Define the Suffixes for Field Name
2118 * When the suffixes is non empty, completion for field name will end with
2119 * one of the proposed suffixes.
2120 * - option id: "org.eclipse.jdt.core.codeComplete.fieldSuffixes"
2121 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2124 * CODEASSIST / Define the Suffixes for Static Field Name
2125 * When the suffixes is non empty, completion for static field name will end with
2126 * one of the proposed suffixes.
2127 * - option id: "org.eclipse.jdt.core.codeComplete.staticFieldSuffixes"
2128 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2131 * CODEASSIST / Define the Suffixes for Local Variable Name
2132 * When the suffixes is non empty, completion for local variable name will end with
2133 * one of the proposed suffixes.
2134 * - option id: "org.eclipse.jdt.core.codeComplete.localSuffixes"
2135 * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
2138 * CODEASSIST / Define the Suffixes for Argument Name
2139 * When the suffixes is non empty, completion for argument name will end with
2140 * one of the proposed suffixes.
2141 * - option id: "org.eclipse.jdt.core.codeComplete.argumentSuffixes"
2142 * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
2146 * @return a mutable table containing the default settings of all known options
2147 * (key type: <code>String</code>; value type: <code>String</code>)
2150 public static Hashtable getDefaultOptions(){
2152 Hashtable defaultOptions = new Hashtable(10);
2154 // see #initializeDefaultPluginPreferences() for changing default settings
2155 Preferences preferences = getPlugin().getPluginPreferences();
2156 HashSet optionNames = JavaModelManager.OptionNames;
2158 // get preferences set to their default
2159 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2160 for (int i = 0; i < defaultPropertyNames.length; i++){
2161 String propertyName = defaultPropertyNames[i];
2162 if (optionNames.contains(propertyName)) {
2163 defaultOptions.put(propertyName, preferences.getDefaultString(propertyName));
2166 // get preferences not set to their default
2167 String[] propertyNames = preferences.propertyNames();
2168 for (int i = 0; i < propertyNames.length; i++){
2169 String propertyName = propertyNames[i];
2170 if (optionNames.contains(propertyName)) {
2171 defaultOptions.put(propertyName, preferences.getDefaultString(propertyName));
2174 // get encoding through resource plugin
2175 defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2177 return defaultOptions;
2181 * Returns the single instance of the Java core plug-in runtime class.
2182 * Equivalent to <code>(JavaCore) getPlugin()</code>.
2184 * @return the single instance of the Java core plug-in runtime class
2186 public static PHPeclipsePlugin getJavaCore() {
2187 return (PHPeclipsePlugin) getPlugin();
2191 * Helper method for returning one option value only. Equivalent to <code>(String)JavaCore.getOptions().get(optionName)</code>
2192 * Note that it may answer <code>null</code> if this option does not exist.
2194 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
2197 * @param optionName the name of an option
2198 * @return the String value of a given option
2199 * @see JavaCore#getDefaultOptions
2202 public static String getOption(String optionName) {
2204 if (CORE_ENCODING.equals(optionName)){
2205 return ResourcesPlugin.getEncoding();
2207 if (JavaModelManager.OptionNames.contains(optionName)){
2208 Preferences preferences = getPlugin().getPluginPreferences();
2209 return preferences.getString(optionName).trim();
2215 * Returns the table of the current options. Initially, all options have their default values,
2216 * and this method returns a table that includes all known options.
2218 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
2221 * @return table of current settings of all options
2222 * (key type: <code>String</code>; value type: <code>String</code>)
2223 * @see JavaCore#getDefaultOptions
2225 public static Hashtable getOptions() {
2227 Hashtable options = new Hashtable(10);
2229 // see #initializeDefaultPluginPreferences() for changing default settings
2230 Plugin plugin = getPlugin();
2231 if (plugin != null) {
2232 Preferences preferences = getPlugin().getPluginPreferences();
2233 HashSet optionNames = JavaModelManager.OptionNames;
2235 // get preferences set to their default
2236 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2237 for (int i = 0; i < defaultPropertyNames.length; i++){
2238 String propertyName = defaultPropertyNames[i];
2239 if (optionNames.contains(propertyName)){
2240 options.put(propertyName, preferences.getDefaultString(propertyName));
2243 // get preferences not set to their default
2244 String[] propertyNames = preferences.propertyNames();
2245 for (int i = 0; i < propertyNames.length; i++){
2246 String propertyName = propertyNames[i];
2247 if (optionNames.contains(propertyName)){
2248 options.put(propertyName, preferences.getString(propertyName).trim());
2251 // get encoding through resource plugin
2252 options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2258 * This is a helper method, which returns the resolved classpath entry denoted
2259 * by a given entry (if it is a variable entry). It is obtained by resolving the variable
2260 * reference in the first segment. Returns <node>null</code> if unable to resolve using
2261 * the following algorithm:
2263 * <li> if variable segment cannot be resolved, returns <code>null</code></li>
2264 * <li> finds a project, JAR or binary folder in the workspace at the resolved path location</li>
2265 * <li> if none finds an external JAR file or folder outside the workspace at the resolved path location </li>
2266 * <li> if none returns <code>null</code></li>
2269 * Variable source attachment path and root path are also resolved and recorded in the resulting classpath entry.
2271 * NOTE: This helper method does not handle classpath containers, for which should rather be used
2272 * <code>JavaCore#getClasspathContainer(IPath, IJavaProject)</code>.
2275 * @param entry the given variable entry
2276 * @return the resolved library or project classpath entry, or <code>null</code>
2277 * if the given variable entry could not be resolved to a valid classpath entry
2279 public static IClasspathEntry getResolvedClasspathEntry(IClasspathEntry entry) {
2281 if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
2284 IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
2285 IPath resolvedPath = PHPCore.getResolvedVariablePath(entry.getPath());
2286 if (resolvedPath == null)
2289 Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false);
2293 // inside the workspace
2294 if (target instanceof IResource) {
2295 IResource resolvedResource = (IResource) target;
2296 if (resolvedResource != null) {
2297 switch (resolvedResource.getType()) {
2299 case IResource.PROJECT :
2301 return PHPCore.newProjectEntry(resolvedPath, entry.isExported());
2303 case IResource.FILE :
2304 // if (Util.isArchiveFileName(resolvedResource.getName())) {
2305 // // internal binary archive
2306 // return JavaCore.newLibraryEntry(
2308 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2309 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2310 // entry.isExported());
2314 case IResource.FOLDER :
2315 // internal binary folder
2316 // return JavaCore.newLibraryEntry(
2318 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2319 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2320 // entry.isExported());
2325 // outside the workspace
2326 if (target instanceof File) {
2327 File externalFile = (File) target;
2328 if (externalFile.isFile()) {
2329 String fileName = externalFile.getName().toLowerCase();
2330 // if (fileName.endsWith(".jar" //$NON-NLS-1$
2331 // ) || fileName.endsWith(".zip" //$NON-NLS-1$
2332 // )) { // external binary archive
2333 // return JavaCore.newLibraryEntry(
2335 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2336 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2337 // entry.isExported());
2339 } else { // external binary folder
2340 if (resolvedPath.isAbsolute()){
2341 // return JavaCore.newLibraryEntry(
2343 // getResolvedVariablePath(entry.getSourceAttachmentPath()),
2344 // getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2345 // entry.isExported());
2354 * Resolve a variable path (helper method).
2356 * @param variablePath the given variable path
2357 * @return the resolved variable path or <code>null</code> if none
2359 public static IPath getResolvedVariablePath(IPath variablePath) {
2361 if (variablePath == null)
2363 int count = variablePath.segmentCount();
2368 String variableName = variablePath.segment(0);
2369 IPath resolvedPath = PHPCore.getClasspathVariable(variableName);
2370 if (resolvedPath == null)
2373 // append path suffix
2375 resolvedPath = resolvedPath.append(variablePath.removeFirstSegments(1));
2377 return resolvedPath;
2381 * Answers the shared working copies currently registered for this buffer factory.
2382 * Working copies can be shared by several clients using the same buffer factory,see
2383 * <code>IWorkingCopy.getSharedWorkingCopy</code>.
2385 * @param factory the given buffer factory
2386 * @return the list of shared working copies for a given buffer factory
2390 public static IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory){
2392 // if factory is null, default factory must be used
2393 if (factory == null) factory = BufferManager.getDefaultBufferManager().getDefaultBufferFactory();
2394 Map sharedWorkingCopies = JavaModelManager.getJavaModelManager().sharedWorkingCopies;
2396 Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
2397 if (perFactoryWorkingCopies == null) return JavaModelManager.NoWorkingCopy;
2398 Collection copies = perFactoryWorkingCopies.values();
2399 IWorkingCopy[] result = new IWorkingCopy[copies.size()];
2400 copies.toArray(result);
2405 * Initializes the default preferences settings for this plug-in.
2407 protected static void initializeDefaultPluginPreferences() {
2409 Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
2410 HashSet optionNames = JavaModelManager.OptionNames;
2412 // Compiler settings
2413 preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
2414 optionNames.add(COMPILER_LOCAL_VARIABLE_ATTR);
2416 preferences.setDefault(COMPILER_LINE_NUMBER_ATTR, GENERATE);
2417 optionNames.add(COMPILER_LINE_NUMBER_ATTR);
2419 preferences.setDefault(COMPILER_SOURCE_FILE_ATTR, GENERATE);
2420 optionNames.add(COMPILER_SOURCE_FILE_ATTR);
2422 preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE);
2423 optionNames.add(COMPILER_CODEGEN_UNUSED_LOCAL);
2425 preferences.setDefault(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1);
2426 optionNames.add(COMPILER_CODEGEN_TARGET_PLATFORM);
2428 preferences.setDefault(COMPILER_PB_UNREACHABLE_CODE, ERROR);
2429 optionNames.add(COMPILER_PB_UNREACHABLE_CODE);
2431 preferences.setDefault(COMPILER_PB_INVALID_IMPORT, ERROR);
2432 optionNames.add(COMPILER_PB_INVALID_IMPORT);
2434 preferences.setDefault(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, WARNING);
2435 optionNames.add(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD);
2437 preferences.setDefault(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME, WARNING);
2438 optionNames.add(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME);
2440 preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING);
2441 optionNames.add(COMPILER_PB_DEPRECATION);
2443 preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE, DISABLED);
2444 optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE);
2446 preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING);
2447 optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK);
2449 preferences.setDefault(COMPILER_PB_UNUSED_LOCAL, IGNORE);
2450 optionNames.add(COMPILER_PB_UNUSED_LOCAL);
2452 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE);
2453 optionNames.add(COMPILER_PB_UNUSED_PARAMETER);
2455 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT, DISABLED);
2456 optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT);
2458 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE, DISABLED);
2459 optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE);
2461 preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING);
2462 optionNames.add(COMPILER_PB_UNUSED_IMPORT);
2464 preferences.setDefault(COMPILER_PB_UNUSED_PRIVATE_MEMBER, IGNORE);
2465 optionNames.add(COMPILER_PB_UNUSED_PRIVATE_MEMBER);
2467 preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE);
2468 optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION);
2470 preferences.setDefault(COMPILER_PB_NON_NLS_STRING_LITERAL, IGNORE);
2471 optionNames.add(COMPILER_PB_NON_NLS_STRING_LITERAL);
2473 preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE);
2474 optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER);
2476 preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING);
2477 optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER);
2479 preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING);
2480 optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT);
2482 preferences.setDefault(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD, WARNING);
2483 optionNames.add(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD);
2485 preferences.setDefault(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION, WARNING);
2486 optionNames.add(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION);
2488 preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAG); //$NON-NLS-1$
2489 optionNames.add(COMPILER_TASK_TAGS);
2491 preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITY); //$NON-NLS-1$
2492 optionNames.add(COMPILER_TASK_PRIORITIES);
2494 preferences.setDefault(COMPILER_SOURCE, VERSION_1_3);
2495 optionNames.add(COMPILER_SOURCE);
2497 preferences.setDefault(COMPILER_COMPLIANCE, VERSION_1_3);
2498 optionNames.add(COMPILER_COMPLIANCE);
2500 preferences.setDefault(COMPILER_PB_MAX_PER_UNIT, "100"); //$NON-NLS-1$
2501 optionNames.add(COMPILER_PB_MAX_PER_UNIT);
2504 preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
2505 optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
2507 preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT);
2508 optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH);
2510 preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING);
2511 optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE);
2513 preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN);
2514 optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER);
2516 // JavaCore settings
2517 preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE);
2518 optionNames.add(CORE_JAVA_BUILD_ORDER);
2520 preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR);
2521 optionNames.add(CORE_CIRCULAR_CLASSPATH);
2523 preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR);
2524 optionNames.add(CORE_INCOMPLETE_CLASSPATH);
2526 preferences.setDefault(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, ENABLED);
2527 optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS);
2529 preferences.setDefault(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, ENABLED);
2530 optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS);
2532 // encoding setting comes from resource plug-in
2533 optionNames.add(CORE_ENCODING);
2535 // Formatter settings
2536 preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT);
2537 optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE);
2539 preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT);
2540 optionNames.add(FORMATTER_NEWLINE_CONTROL);
2542 preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE);
2543 optionNames.add(FORMATTER_CLEAR_BLANK_LINES);
2545 preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT);
2546 optionNames.add(FORMATTER_NEWLINE_ELSE_IF);
2548 preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT);
2549 optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK);
2551 preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$
2552 optionNames.add(FORMATTER_LINE_SPLIT);
2554 preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL);
2555 optionNames.add(FORMATTER_COMPACT_ASSIGNMENT);
2557 preferences.setDefault(FORMATTER_TAB_CHAR, TAB);
2558 optionNames.add(FORMATTER_TAB_CHAR);
2560 preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$
2561 optionNames.add(FORMATTER_TAB_SIZE);
2563 preferences.setDefault(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$
2564 optionNames.add(FORMATTER_SPACE_CASTEXPRESSION);
2566 // CodeAssist settings
2567 preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$
2568 optionNames.add(CODEASSIST_VISIBILITY_CHECK);
2570 preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$
2571 optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION);
2573 preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
2574 optionNames.add(CODEASSIST_FIELD_PREFIXES);
2576 preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
2577 optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES);
2579 preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
2580 optionNames.add(CODEASSIST_LOCAL_PREFIXES);
2582 preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
2583 optionNames.add(CODEASSIST_ARGUMENT_PREFIXES);
2585 preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
2586 optionNames.add(CODEASSIST_FIELD_SUFFIXES);
2588 preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
2589 optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES);
2591 preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
2592 optionNames.add(CODEASSIST_LOCAL_SUFFIXES);
2594 preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
2595 optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES);
2599 * Returns whether the given marker references the given Java element.
2600 * Used for markers, which denote a Java element rather than a resource.
2602 * @param element the element
2603 * @param marker the marker
2604 * @return <code>true</code> if the marker references the element, false otherwise
2605 * @exception CoreException if the <code>IMarker.getAttribute</code> on the marker fails
2607 public static boolean isReferencedBy(IJavaElement element, IMarker marker) throws CoreException {
2609 // only match units or classfiles
2610 if (element instanceof IMember){
2611 IMember member = (IMember) element;
2612 if (member.isBinary()){
2613 element = null; //member.getClassFile();
2615 element = member.getCompilationUnit();
2618 if (element == null) return false;
2619 if (marker == null) return false;
2621 String markerHandleId = (String)marker.getAttribute(ATT_HANDLE_ID);
2622 if (markerHandleId == null) return false;
2624 IJavaElement markerElement = PHPCore.create(markerHandleId);
2626 if (element.equals(markerElement)) return true; // external elements may still be equal with different handleIDs.
2628 // cycle through enclosing types in case marker is associated with a classfile (15568)
2629 // if (markerElement instanceof IClassFile){
2630 // IType enclosingType = ((IClassFile)markerElement).getType().getDeclaringType();
2631 // if (enclosingType != null){
2632 // markerElement = enclosingType.getClassFile(); // retry with immediate enclosing classfile
2642 * Returns whether the given marker delta references the given Java element.
2643 * Used for markers deltas, which denote a Java element rather than a resource.
2645 * @param element the element
2646 * @param markerDelta the marker delta
2647 * @return <code>true</code> if the marker delta references the element
2648 * @exception CoreException if the <code>IMarkerDelta.getAttribute</code> on the marker delta fails
2650 public static boolean isReferencedBy(IJavaElement element, IMarkerDelta markerDelta) throws CoreException {
2652 // only match units or classfiles
2653 if (element instanceof IMember){
2654 IMember member = (IMember) element;
2655 if (member.isBinary()){
2656 element = null; //member.getClassFile();
2658 element = member.getCompilationUnit();
2661 if (element == null) return false;
2662 if (markerDelta == null) return false;
2664 String markerDeltarHandleId = (String)markerDelta.getAttribute(ATT_HANDLE_ID);
2665 if (markerDeltarHandleId == null) return false;
2667 IJavaElement markerElement = PHPCore.create(markerDeltarHandleId);
2669 if (element.equals(markerElement)) return true; // external elements may still be equal with different handleIDs.
2671 // cycle through enclosing types in case marker is associated with a classfile (15568)
2672 // if (markerElement instanceof IClassFile){
2673 // IType enclosingType = ((IClassFile)markerElement).getType().getDeclaringType();
2674 // if (enclosingType != null){
2675 // markerElement = enclosingType.getClassFile(); // retry with immediate enclosing classfile
2685 * Creates and returns a new classpath entry of kind <code>CPE_CONTAINER</code>
2686 * for the given path. The path of the container will be used during resolution so as to map this
2687 * container entry to a set of other classpath entries the container is acting for.
2689 * A container entry allows to express indirect references to a set of libraries, projects and variable entries,
2690 * which can be interpreted differently for each Java project where it is used.
2691 * A classpath container entry can be resolved using <code>JavaCore.getResolvedClasspathContainer</code>,
2692 * and updated with <code>JavaCore.classpathContainerChanged</code>
2694 * A container is exclusively resolved by a <code>ClasspathContainerInitializer</code> registered onto the
2695 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
2697 * A container path must be formed of at least one segment, where: <ul>
2698 * <li> the first segment is a unique ID identifying the target container, there must be a container initializer registered
2699 * onto this ID through the extension point "org.eclipse.jdt.core.classpathContainerInitializer". </li>
2700 * <li> the remaining segments will be passed onto the initializer, and can be used as additional
2701 * hints during the initialization phase. </li>
2704 * Example of an ClasspathContainerInitializer for a classpath container denoting a default JDK container:
2706 * containerEntry = JavaCore.newContainerEntry(new Path("MyProvidedJDK/default"));
2709 * point="org.eclipse.jdt.core.classpathContainerInitializer">
2710 * <containerInitializer
2711 * id="MyProvidedJDK"
2712 * class="com.example.MyInitializer"/>
2714 * Note that this operation does not attempt to validate classpath containers
2715 * or access the resources at the given paths.
2717 * The resulting entry is not exported to dependent projects. This method is equivalent to
2718 * <code>newContainerEntry(-,false)</code>.
2720 * @param containerPath the path identifying the container, it must be formed of two
2722 * @return a new container classpath entry
2724 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
2725 * @see JavaCore#newContainerEntry(IPath, boolean)
2728 public static IClasspathEntry newContainerEntry(IPath containerPath) {
2730 return newContainerEntry(containerPath, false);
2734 * Creates and returns a new classpath entry of kind <code>CPE_CONTAINER</code>
2735 * for the given path. The path of the container will be used during resolution so as to map this
2736 * container entry to a set of other classpath entries the container is acting for.
2738 * A container entry allows to express indirect references to a set of libraries, projects and variable entries,
2739 * which can be interpreted differently for each Java project where it is used.
2740 * A classpath container entry can be resolved using <code>JavaCore.getResolvedClasspathContainer</code>,
2741 * and updated with <code>JavaCore.classpathContainerChanged</code>
2743 * A container is exclusively resolved by a <code>ClasspathContainerInitializer</code> registered onto the
2744 * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
2746 * A container path must be formed of at least one segment, where: <ul>
2747 * <li> the first segment is a unique ID identifying the target container, there must be a container initializer registered
2748 * onto this ID through the extension point "org.eclipse.jdt.core.classpathContainerInitializer". </li>
2749 * <li> the remaining segments will be passed onto the initializer, and can be used as additional
2750 * hints during the initialization phase. </li>
2753 * Example of an ClasspathContainerInitializer for a classpath container denoting a default JDK container:
2755 * containerEntry = JavaCore.newContainerEntry(new Path("MyProvidedJDK/default"));
2758 * point="org.eclipse.jdt.core.classpathContainerInitializer">
2759 * <containerInitializer
2760 * id="MyProvidedJDK"
2761 * class="com.example.MyInitializer"/>
2763 * Note that this operation does not attempt to validate classpath containers
2764 * or access the resources at the given paths.
2766 * @param containerPath the path identifying the container, it must be formed of at least
2767 * one segment (ID+hints)
2768 * @param isExported a boolean indicating whether this entry is contributed to dependent
2769 * projects in addition to the output location
2770 * @return a new container classpath entry
2772 * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
2773 * @see JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor)
2774 * @see JavaCore#newContainerEntry(IPath, boolean)
2777 public static IClasspathEntry newContainerEntry(IPath containerPath, boolean isExported) {
2779 if (containerPath == null || containerPath.segmentCount() < 1) {
2782 "Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$
2784 return new ClasspathEntry(
2785 IPackageFragmentRoot.K_SOURCE,
2786 IClasspathEntry.CPE_CONTAINER,
2788 ClasspathEntry.NO_EXCLUSION_PATTERNS,
2789 null, // source attachment
2790 null, // source attachment root
2791 null, // specific output folder
2796 * Creates and returns a new non-exported classpath entry of kind <code>CPE_LIBRARY</code> for the
2797 * JAR or folder identified by the given absolute path. This specifies that all package fragments
2798 * within the root will have children of type <code>IClassFile</code>.
2800 * A library entry is used to denote a prerequisite JAR or root folder containing binaries.
2801 * The target JAR or folder can either be defined internally to the workspace (absolute path relative
2802 * to the workspace root) or externally to the workspace (absolute path in the file system).
2804 * e.g. Here are some examples of binary path usage<ul>
2805 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code> - reference to an external JAR</li>
2806 * <li><code> "/Project/someLib.jar" </code> - reference to an internal JAR </li>
2807 * <li><code> "c:/classes/" </code> - reference to an external binary folder</li>
2809 * Note that this operation does not attempt to validate or access the
2810 * resources at the given paths.
2812 * The resulting entry is not exported to dependent projects. This method is equivalent to
2813 * <code>newLibraryEntry(-,-,-,false)</code>.
2816 * @param path the absolute path of the binary archive
2817 * @param sourceAttachmentPath the absolute path of the corresponding source archive or folder,
2818 * or <code>null</code> if none
2819 * @param sourceAttachmentRootPath the location of the root within the source archive or folder
2820 * or <code>null</code> if this location should be automatically detected.
2821 * @return a new library classpath entry
2823 * @see #newLibraryEntry(IPath, IPath, IPath, boolean)
2825 //public static IClasspathEntry newLibraryEntry(
2827 // IPath sourceAttachmentPath,
2828 // IPath sourceAttachmentRootPath) {
2830 // return newLibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath, false);
2834 * Creates and returns a new classpath entry of kind <code>CPE_LIBRARY</code> for the JAR or folder
2835 * identified by the given absolute path. This specifies that all package fragments within the root
2836 * will have children of type <code>IClassFile</code>.
2838 * A library entry is used to denote a prerequisite JAR or root folder containing binaries.
2839 * The target JAR or folder can either be defined internally to the workspace (absolute path relative
2840 * to the workspace root) or externally to the workspace (absolute path in the file system).
2842 * e.g. Here are some examples of binary path usage<ul>
2843 * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code> - reference to an external JAR</li>
2844 * <li><code> "/Project/someLib.jar" </code> - reference to an internal JAR </li>
2845 * <li><code> "c:/classes/" </code> - reference to an external binary folder</li>
2847 * Note that this operation does not attempt to validate or access the
2848 * resources at the given paths.
2851 * @param path the absolute path of the binary archive
2852 * @param sourceAttachmentPath the absolute path of the corresponding source archive or folder,
2853 * or <code>null</code> if none
2854 * @param sourceAttachmentRootPath the location of the root within the source archive or folder
2855 * or <code>null</code> if this location should be automatically detected.
2856 * @param isExported indicates whether this entry is contributed to dependent
2857 * projects in addition to the output location
2858 * @return a new library classpath entry
2861 //public static IClasspathEntry newLibraryEntry(
2863 // IPath sourceAttachmentPath,
2864 // IPath sourceAttachmentRootPath,
2865 // boolean isExported) {
2867 // if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
2869 // return new ClasspathEntry(
2870 // IPackageFragmentRoot.K_BINARY,
2871 // IClasspathEntry.CPE_LIBRARY,
2872 // JavaProject.canonicalizedPath(path),
2873 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
2874 // sourceAttachmentPath,
2875 // sourceAttachmentRootPath,
2876 // null, // specific output folder
2881 * Creates and returns a new non-exported classpath entry of kind <code>CPE_PROJECT</code>
2882 * for the project identified by the given absolute path.
2884 * A project entry is used to denote a prerequisite project on a classpath.
2885 * The referenced project will be contributed as a whole, either as sources (in the Java Model, it
2886 * contributes all its package fragment roots) or as binaries (when building, it contributes its
2887 * whole output location).
2889 * A project reference allows to indirect through another project, independently from its internal layout.
2891 * The prerequisite project is referred to using an absolute path relative to the workspace root.
2893 * The resulting entry is not exported to dependent projects. This method is equivalent to
2894 * <code>newProjectEntry(_,false)</code>.
2897 * @param path the absolute path of the binary archive
2898 * @return a new project classpath entry
2900 * @see JavaCore#newProjectEntry(IPath, boolean)
2902 public static IClasspathEntry newProjectEntry(IPath path) {
2903 return newProjectEntry(path, false);
2907 * Creates and returns a new classpath entry of kind <code>CPE_PROJECT</code>
2908 * for the project identified by the given absolute path.
2910 * A project entry is used to denote a prerequisite project on a classpath.
2911 * The referenced project will be contributed as a whole, either as sources (in the Java Model, it
2912 * contributes all its package fragment roots) or as binaries (when building, it contributes its
2913 * whole output location).
2915 * A project reference allows to indirect through another project, independently from its internal layout.
2917 * The prerequisite project is referred to using an absolute path relative to the workspace root.
2920 * @param path the absolute path of the prerequisite project
2921 * @param isExported indicates whether this entry is contributed to dependent
2922 * projects in addition to the output location
2923 * @return a new project classpath entry
2926 public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) {
2928 if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
2930 return new ClasspathEntry(
2931 IPackageFragmentRoot.K_SOURCE,
2932 IClasspathEntry.CPE_PROJECT,
2934 ClasspathEntry.NO_EXCLUSION_PATTERNS,
2935 null, // source attachment
2936 null, // source attachment root
2937 null, // specific output folder
2942 * Returns a new empty region.
2944 * @return a new empty region
2946 public static IRegion newRegion() {
2947 return new Region();
2951 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
2952 * for the project's source folder identified by the given absolute
2953 * workspace-relative path. This specifies that all package fragments
2954 * within the root will have children of type <code>ICompilationUnit</code>.
2956 * The source folder is referred to using an absolute path relative to the
2957 * workspace root, e.g. <code>/Project/src</code>. A project's source
2958 * folders are located with that project. That is, a source classpath
2959 * entry specifying the path <code>/P1/src</code> is only usable for
2960 * project <code>P1</code>.
2963 * The source classpath entry created by this method includes all source
2964 * files below the given workspace-relative path. To selectively exclude
2965 * some of these source files, use the factory method
2966 * <code>JavaCore.newSourceEntry(IPath,IPath[])</code> instead.
2969 * Note that all sources/binaries inside a project are contributed as a whole through
2970 * a project entry (see <code>JavaCore.newProjectEntry</code>). Particular
2971 * source entries cannot be selectively exported.
2974 * @param path the absolute workspace-relative path of a source folder
2975 * @return a new source classpath entry with not exclusion patterns
2977 * @see #newSourceEntry(org.eclipse.core.runtime.IPath,org.eclipse.core.runtime.IPath[])
2979 public static IClasspathEntry newSourceEntry(IPath path) {
2981 return newSourceEntry(path, ClasspathEntry.NO_EXCLUSION_PATTERNS, null /*output location*/);
2985 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
2986 * for the project's source folder identified by the given absolute
2987 * workspace-relative path but excluding all source files with paths
2988 * matching any of the given patterns. This specifies that all package
2989 * fragments within the root will have children of type
2990 * <code>ICompilationUnit</code>.
2992 * The source folder is referred to using an absolute path relative to the
2993 * workspace root, e.g. <code>/Project/src</code>. A project's source
2994 * folders are located with that project. That is, a source classpath
2995 * entry specifying the path <code>/P1/src</code> is only usable for
2996 * project <code>P1</code>.
2999 * The source classpath entry created by this method includes all source
3000 * files below the given workspace-relative path except for those matched
3001 * by one (or more) of the given exclusion patterns. Each exclusion pattern
3002 * is represented by a relative path, which is interpreted as relative to
3003 * the source folder. For example, if the source folder path is
3004 * <code>/Project/src</code> and the exclusion pattern is
3005 * <code>com/xyz/tests/**</code>, then source files
3006 * like <code>/Project/src/com/xyz/Foo.java</code>
3007 * and <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3008 * whereas <code>/Project/src/com/xyz/tests/T1.java</code>
3009 * and <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3010 * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
3011 * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code>
3012 * for the full description of the syntax and semantics of exclusion
3015 * If the empty list of exclusion patterns is specified, the source folder
3016 * will automatically include all resources located inside the source
3017 * folder. In that case, the result is entirely equivalent to using the
3018 * factory method <code>JavaCore.newSourceEntry(IPath)</code>.
3021 * Note that all sources/binaries inside a project are contributed as a whole through
3022 * a project entry (see <code>JavaCore.newProjectEntry</code>). Particular
3023 * source entries cannot be selectively exported.
3026 * @param path the absolute workspace-relative path of a source folder
3027 * @param exclusionPatterns the possibly empty list of exclusion patterns
3028 * represented as relative paths
3029 * @return a new source classpath entry with the given exclusion patterns
3030 * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
3031 * @see IClasspathEntry#getExclusionPatterns
3035 public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns) {
3037 return newSourceEntry(path, exclusionPatterns, null /*output location*/);
3041 * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3042 * for the project's source folder identified by the given absolute
3043 * workspace-relative path but excluding all source files with paths
3044 * matching any of the given patterns, and associated with a specific output location
3045 * (that is, ".class" files are not going to the project default output location).
3046 * All package fragments within the root will have children of type
3047 * <code>ICompilationUnit</code>.
3049 * The source folder is referred to using an absolute path relative to the
3050 * workspace root, e.g. <code>/Project/src</code>. A project's source
3051 * folders are located with that project. That is, a source classpath
3052 * entry specifying the path <code>/P1/src</code> is only usable for
3053 * project <code>P1</code>.
3056 * The source classpath entry created by this method includes all source
3057 * files below the given workspace-relative path except for those matched
3058 * by one (or more) of the given exclusion patterns. Each exclusion pattern
3059 * is represented by a relative path, which is interpreted as relative to
3060 * the source folder. For example, if the source folder path is
3061 * <code>/Project/src</code> and the exclusion pattern is
3062 * <code>com/xyz/tests/**</code>, then source files
3063 * like <code>/Project/src/com/xyz/Foo.java</code>
3064 * and <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3065 * whereas <code>/Project/src/com/xyz/tests/T1.java</code>
3066 * and <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3067 * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
3068 * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code>
3069 * for the full description of the syntax and semantics of exclusion
3072 * If the empty list of exclusion patterns is specified, the source folder
3073 * will automatically include all resources located inside the source
3074 * folder. In that case, the result is entirely equivalent to using the
3075 * factory method <code>JavaCore.newSourceEntry(IPath)</code>.
3078 * Additionally, a source entry can be associated with a specific output location.
3079 * By doing so, the Java builder will ensure that the generated ".class" files will
3080 * be issued inside this output location, as opposed to be generated into the
3081 * project default output location (when output location is <code>null</code>).
3082 * Note that multiple source entries may target the same output location.
3083 * The output location is referred to using an absolute path relative to the
3084 * workspace root, e.g. <code>"/Project/bin"</code>, it must be located inside
3085 * the same project as the source folder.
3088 * Also note that all sources/binaries inside a project are contributed as a whole through
3089 * a project entry (see <code>JavaCore.newProjectEntry</code>). Particular
3090 * source entries cannot be selectively exported.
3093 * @param path the absolute workspace-relative path of a source folder
3094 * @param exclusionPatterns the possibly empty list of exclusion patterns
3095 * represented as relative paths
3096 * @param outputLocation the specific output location for this source entry (<code>null</code> if using project default ouput location)
3097 * @return a new source classpath entry with the given exclusion patterns
3098 * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
3099 * @see IClasspathEntry#getExclusionPatterns
3100 * @see IClasspathEntry#getOutputLocation()
3104 public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns, IPath specificOutputLocation) {
3106 if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3107 if (exclusionPatterns == null) Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$
3109 return new ClasspathEntry(
3110 IPackageFragmentRoot.K_SOURCE,
3111 IClasspathEntry.CPE_SOURCE,
3114 null, // source attachment
3115 null, // source attachment root
3116 specificOutputLocation, // custom output location
3121 * Creates and returns a new non-exported classpath entry of kind <code>CPE_VARIABLE</code>
3122 * for the given path. The first segment of the path is the name of a classpath variable.
3123 * The trailing segments of the path will be appended to resolved variable path.
3125 * A variable entry allows to express indirect references on a classpath to other projects or libraries,
3126 * depending on what the classpath variable is referring.
3128 * It is possible to register an automatic initializer (<code>ClasspathVariableInitializer</code>),
3129 * which will be invoked through the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
3130 * After resolution, a classpath variable entry may either correspond to a project or a library entry. </li>
3132 * e.g. Here are some examples of variable path usage<ul>
3133 * <li> "JDTCORE" where variable <code>JDTCORE</code> is
3134 * bound to "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the library "c:\jars\jdtcore.jar"</li>
3135 * <li> "JDTCORE" where variable <code>JDTCORE</code> is
3136 * bound to "/Project_JDTCORE". The resolved classpath entry is denoting the project "/Project_JDTCORE"</li>
3137 * <li> "PLUGINS/com.example/example.jar" where variable <code>PLUGINS</code>
3138 * is bound to "c:/eclipse/plugins". The resolved classpath entry is denoting the library "c:/eclipse/plugins/com.example/example.jar"</li>
3140 * Note that this operation does not attempt to validate classpath variables
3141 * or access the resources at the given paths.
3143 * The resulting entry is not exported to dependent projects. This method is equivalent to
3144 * <code>newVariableEntry(-,-,-,false)</code>.
3147 * @param variablePath the path of the binary archive; first segment is the
3148 * name of a classpath variable
3149 * @param variableSourceAttachmentPath the path of the corresponding source archive,
3150 * or <code>null</code> if none; if present, the first segment is the
3151 * name of a classpath variable (not necessarily the same variable
3152 * as the one that begins <code>variablePath</code>)
3153 * @param sourceAttachmentRootPath the location of the root within the source archive
3154 * or <code>null</code> if <code>archivePath</code> is also <code>null</code>
3155 * @return a new library classpath entry
3157 * @see JavaCore#newVariableEntry(IPath, IPath, IPath, boolean)
3159 //public static IClasspathEntry newVariableEntry(
3160 // IPath variablePath,
3161 // IPath variableSourceAttachmentPath,
3162 // IPath sourceAttachmentRootPath) {
3164 // return newVariableEntry(variablePath, variableSourceAttachmentPath, sourceAttachmentRootPath, false);
3168 * Creates and returns a new non-exported classpath entry of kind <code>CPE_VARIABLE</code>
3169 * for the given path. The first segment of the path is the name of a classpath variable.
3170 * The trailing segments of the path will be appended to resolved variable path.
3172 * A variable entry allows to express indirect references on a classpath to other projects or libraries,
3173 * depending on what the classpath variable is referring.
3175 * It is possible to register an automatic initializer (<code>ClasspathVariableInitializer</code>),
3176 * which will be invoked through the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
3177 * After resolution, a classpath variable entry may either correspond to a project or a library entry. </li>
3179 * e.g. Here are some examples of variable path usage<ul>
3180 * <li> "JDTCORE" where variable <code>JDTCORE</code> is
3181 * bound to "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the library "c:\jars\jdtcore.jar"</li>
3182 * <li> "JDTCORE" where variable <code>JDTCORE</code> is
3183 * bound to "/Project_JDTCORE". The resolved classpath entry is denoting the project "/Project_JDTCORE"</li>
3184 * <li> "PLUGINS/com.example/example.jar" where variable <code>PLUGINS</code>
3185 * is bound to "c:/eclipse/plugins". The resolved classpath entry is denoting the library "c:/eclipse/plugins/com.example/example.jar"</li>
3187 * Note that this operation does not attempt to validate classpath variables
3188 * or access the resources at the given paths.
3191 * @param variablePath the path of the binary archive; first segment is the
3192 * name of a classpath variable
3193 * @param variableSourceAttachmentPath the path of the corresponding source archive,
3194 * or <code>null</code> if none; if present, the first segment is the
3195 * name of a classpath variable (not necessarily the same variable
3196 * as the one that begins <code>variablePath</code>)
3197 * @param sourceAttachmentRootPath the location of the root within the source archive
3198 * or <code>null</code> if <code>archivePath</code> is also <code>null</code>
3199 * @param isExported indicates whether this entry is contributed to dependent
3200 * projects in addition to the output location
3201 * @return a new variable classpath entry
3204 //public static IClasspathEntry newVariableEntry(
3205 // IPath variablePath,
3206 // IPath variableSourceAttachmentPath,
3207 // IPath variableSourceAttachmentRootPath,
3208 // boolean isExported) {
3210 // if (variablePath == null || variablePath.segmentCount() < 1) {
3213 // "Illegal classpath variable path: \'" + variablePath.makeRelative().toString() + "\', must have at least one segment"); //$NON-NLS-1$//$NON-NLS-2$
3216 // return new ClasspathEntry(
3217 // IPackageFragmentRoot.K_SOURCE,
3218 // IClasspathEntry.CPE_VARIABLE,
3220 // ClasspathEntry.NO_EXCLUSION_PATTERNS,
3221 // variableSourceAttachmentPath, // source attachment
3222 // variableSourceAttachmentRootPath, // source attachment root
3223 // null, // specific output folder
3228 * Removed the given classpath variable. Does nothing if no value was
3229 * set for this classpath variable.
3231 * This functionality cannot be used while the resource tree is locked.
3233 * Classpath variable values are persisted locally to the workspace, and
3234 * are preserved from session to session.
3237 * @param variableName the name of the classpath variable
3238 * @see #setClasspathVariable
3240 * @deprecated - use version with extra IProgressMonitor
3242 //public static void removeClasspathVariable(String variableName) {
3243 // removeClasspathVariable(variableName, null);
3247 * Removed the given classpath variable. Does nothing if no value was
3248 * set for this classpath variable.
3250 * This functionality cannot be used while the resource tree is locked.
3252 * Classpath variable values are persisted locally to the workspace, and
3253 * are preserved from session to session.
3256 * @param variableName the name of the classpath variable
3257 * @param monitor the progress monitor to report progress
3258 * @see #setClasspathVariable
3260 //public static void removeClasspathVariable(
3261 // String variableName,
3262 // IProgressMonitor monitor) {
3265 // updateVariableValues(new String[]{ variableName}, new IPath[]{ null }, monitor);
3266 // } catch (JavaModelException e) {
3271 * Removes the given element changed listener.
3272 * Has no affect if an identical listener is not registered.
3274 * @param listener the listener
3276 public static void removeElementChangedListener(IElementChangedListener listener) {
3277 JavaModelManager.getJavaModelManager().removeElementChangedListener(listener);
3281 * Bind a container reference path to some actual containers (<code>IClasspathContainer</code>).
3282 * This API must be invoked whenever changes in container need to be reflected onto the JavaModel.
3283 * Containers can have distinct values in different projects, therefore this API considers a
3284 * set of projects with their respective containers.
3286 * <code>containerPath</code> is the path under which these values can be referenced through
3287 * container classpath entries (<code>IClasspathEntry#CPE_CONTAINER</code>). A container path
3288 * is formed by a first ID segment followed with extra segments, which can be used as additional hints
3289 * for the resolution. The container ID is used to identify a <code>ClasspathContainerInitializer</code>
3290 * registered on the extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3292 * There is no assumption that each individual container value passed in argument
3293 * (<code>respectiveContainers</code>) must answer the exact same path when requested
3294 * <code>IClasspathContainer#getPath</code>.
3295 * Indeed, the containerPath is just an indication for resolving it to an actual container object. It can be
3296 * delegated to a <code>ClasspathContainerInitializer</code>, which can be activated through the extension
3297 * point "org.eclipse.jdt.core.ClasspathContainerInitializer").
3299 * In reaction to changing container values, the JavaModel will be updated to reflect the new
3300 * state of the updated container.
3302 * This functionality cannot be used while the resource tree is locked.
3304 * Classpath container values are persisted locally to the workspace, but
3305 * are not preserved from a session to another. It is thus highly recommended to register a
3306 * <code>ClasspathContainerInitializer</code> for each referenced container
3307 * (through the extension point "org.eclipse.jdt.core.ClasspathContainerInitializer").
3309 * Note: setting a container to <code>null</code> will cause it to be lazily resolved again whenever
3310 * its value is required. In particular, this will cause a registered initializer to be invoked
3313 * @param containerPath - the name of the container reference, which is being updated
3314 * @param affectedProjects - the set of projects for which this container is being bound
3315 * @param respectiveContainers - the set of respective containers for the affected projects
3316 * @param monitor a monitor to report progress
3318 * @see ClasspathContainerInitializer
3319 * @see #getClasspathContainer(IPath, IJavaProject)
3320 * @see IClasspathContainer
3323 //public static void setClasspathContainer(final IPath containerPath, IJavaProject[] affectedProjects, IClasspathContainer[] respectiveContainers, IProgressMonitor monitor) throws JavaModelException {
3325 // if (affectedProjects.length != respectiveContainers.length) Assert.isTrue(false, "Projects and containers collections should have the same size"); //$NON-NLS-1$
3327 // if (monitor != null && monitor.isCanceled()) return;
3329 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3330 // System.out.println("CPContainer SET - setting container: ["+containerPath+"] for projects: {" //$NON-NLS-1$ //$NON-NLS-2$
3331 // + (Util.toString(affectedProjects,
3332 // new Util.Displayable(){
3333 // public String displayString(Object o) { return ((IJavaProject) o).getElementName(); }
3335 // + "} with values: " //$NON-NLS-1$
3336 // + (Util.toString(respectiveContainers,
3337 // new Util.Displayable(){
3338 // public String displayString(Object o) { return ((IClasspathContainer) o).getDescription(); }
3343 // final int projectLength = affectedProjects.length;
3344 // final IJavaProject[] modifiedProjects;
3345 // System.arraycopy(affectedProjects, 0, modifiedProjects = new IJavaProject[projectLength], 0, projectLength);
3346 // final IClasspathEntry[][] oldResolvedPaths = new IClasspathEntry[projectLength][];
3348 // // filter out unmodified project containers
3349 // int remaining = 0;
3350 // for (int i = 0; i < projectLength; i++){
3352 // if (monitor != null && monitor.isCanceled()) return;
3354 // IJavaProject affectedProject = affectedProjects[i];
3355 // IClasspathContainer newContainer = respectiveContainers[i];
3356 // if (newContainer == null) newContainer = JavaModelManager.ContainerInitializationInProgress; // 30920 - prevent infinite loop
3357 // boolean found = false;
3358 // if (JavaProject.hasJavaNature(affectedProject.getProject())){
3359 // IClasspathEntry[] rawClasspath = affectedProject.getRawClasspath();
3360 // for (int j = 0, cpLength = rawClasspath.length; j <cpLength; j++) {
3361 // IClasspathEntry entry = rawClasspath[j];
3362 // if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER && entry.getPath().equals(containerPath)){
3369 // modifiedProjects[i] = null; // filter out this project - does not reference the container path, or isnt't yet Java project
3370 // JavaModelManager.containerPut(affectedProject, containerPath, newContainer);
3373 // IClasspathContainer oldContainer = JavaModelManager.containerGet(affectedProject, containerPath);
3374 // if (oldContainer == JavaModelManager.ContainerInitializationInProgress) {
3375 // Map previousContainerValues = (Map)JavaModelManager.PreviousSessionContainers.get(affectedProject);
3376 // if (previousContainerValues != null){
3377 // IClasspathContainer previousContainer = (IClasspathContainer)previousContainerValues.get(containerPath);
3378 // if (previousContainer != null) {
3379 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3380 // System.out.println("CPContainer INIT - reentering access to project container: ["+affectedProject.getElementName()+"] " + containerPath + " during its initialization, will see previous value: "+ previousContainer.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
3382 // JavaModelManager.containerPut(affectedProject, containerPath, previousContainer);
3384 // oldContainer = null; //33695 - cannot filter out restored container, must update affected project to reset cached CP
3386 // oldContainer = null;
3389 // if (oldContainer != null && oldContainer.equals(respectiveContainers[i])){// TODO: could improve to only compare entries
3390 // modifiedProjects[i] = null; // filter out this project - container did not change
3394 // oldResolvedPaths[i] = affectedProject.getResolvedClasspath(true);
3395 // JavaModelManager.containerPut(affectedProject, containerPath, newContainer);
3398 // if (remaining == 0) return;
3400 // // trigger model refresh
3402 // JavaCore.run(new IWorkspaceRunnable() {
3403 // public void run(IProgressMonitor monitor) throws CoreException {
3404 // for(int i = 0; i < projectLength; i++){
3406 // if (monitor != null && monitor.isCanceled()) return;
3408 // JavaProject affectedProject = (JavaProject)modifiedProjects[i];
3409 // if (affectedProject == null) continue; // was filtered out
3411 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3412 // System.out.println("CPContainer SET - updating affected project: ["+affectedProject.getElementName()+"] due to setting container: " + containerPath); //$NON-NLS-1$ //$NON-NLS-2$
3415 // // force a refresh of the affected project (will compute deltas)
3416 // affectedProject.setRawClasspath(
3417 // affectedProject.getRawClasspath(),
3418 // SetClasspathOperation.ReuseOutputLocation,
3420 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can save resources
3421 // oldResolvedPaths[i],
3422 // false, // updating - no validation
3423 // false); // updating - no need to save
3428 // } catch(CoreException e) {
3429 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3430 // System.out.println("CPContainer SET - FAILED DUE TO EXCEPTION: "+containerPath); //$NON-NLS-1$
3431 // e.printStackTrace();
3433 // if (e instanceof JavaModelException) {
3434 // throw (JavaModelException)e;
3436 // throw new JavaModelException(e);
3439 // for (int i = 0; i < projectLength; i++) {
3440 // if (respectiveContainers[i] == null) {
3441 // JavaModelManager.containerPut(affectedProjects[i], containerPath, null); // reset init in progress marker
3449 * Sets the value of the given classpath variable.
3450 * The path must have at least one segment.
3452 * This functionality cannot be used while the resource tree is locked.
3454 * Classpath variable values are persisted locally to the workspace, and
3455 * are preserved from session to session.
3458 * @param variableName the name of the classpath variable
3459 * @param path the path
3460 * @see #getClasspathVariable
3462 * @deprecated - use API with IProgressMonitor
3464 //public static void setClasspathVariable(String variableName, IPath path)
3465 // throws JavaModelException {
3467 // setClasspathVariable(variableName, path, null);
3471 * Sets the value of the given classpath variable.
3472 * The path must not be null.
3474 * This functionality cannot be used while the resource tree is locked.
3476 * Classpath variable values are persisted locally to the workspace, and
3477 * are preserved from session to session.
3479 * Updating a variable with the same value has no effect.
3481 * @param variableName the name of the classpath variable
3482 * @param path the path
3483 * @param monitor a monitor to report progress
3484 * @see #getClasspathVariable
3486 //public static void setClasspathVariable(
3487 // String variableName,
3489 // IProgressMonitor monitor)
3490 // throws JavaModelException {
3492 // if (path == null) Assert.isTrue(false, "Variable path cannot be null"); //$NON-NLS-1$
3493 // setClasspathVariables(new String[]{variableName}, new IPath[]{ path }, monitor);
3497 * Sets the values of all the given classpath variables at once.
3498 * Null paths can be used to request corresponding variable removal.
3500 * This functionality cannot be used while the resource tree is locked.
3502 * Classpath variable values are persisted locally to the workspace, and
3503 * are preserved from session to session.
3505 * Updating a variable with the same value has no effect.
3507 * @param variableNames an array of names for the updated classpath variables
3508 * @param paths an array of path updates for the modified classpath variables (null
3509 * meaning that the corresponding value will be removed
3510 * @param monitor a monitor to report progress
3511 * @see #getClasspathVariable
3514 //public static void setClasspathVariables(
3515 // String[] variableNames,
3517 // IProgressMonitor monitor)
3518 // throws JavaModelException {
3520 // if (variableNames.length != paths.length) Assert.isTrue(false, "Variable names and paths collections should have the same size"); //$NON-NLS-1$
3521 // //TODO: should check that null cannot be used as variable paths
3522 // updateVariableValues(variableNames, paths, monitor);
3526 * Method declared on IExecutableExtension.
3527 * Record any necessary initialization data from the plugin.
3529 public void setInitializationData(
3530 IConfigurationElement cfig,
3531 String propertyName,
3533 throws CoreException {
3537 * Sets the current table of options. All and only the options explicitly included in the given table
3538 * are remembered; all previous option settings are forgotten, including ones not explicitly
3541 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
3544 * @param newOptions the new options (key type: <code>String</code>; value type: <code>String</code>),
3545 * or <code>null</code> to reset all options to their default values
3546 * @see JavaCore#getDefaultOptions
3548 public static void setOptions(Hashtable newOptions) {
3550 // see #initializeDefaultPluginPreferences() for changing default settings
3551 Preferences preferences = getPlugin().getPluginPreferences();
3553 if (newOptions == null){
3554 newOptions = PHPCore.getDefaultOptions();
3556 Enumeration keys = newOptions.keys();
3557 while (keys.hasMoreElements()){
3558 String key = (String)keys.nextElement();
3559 if (!JavaModelManager.OptionNames.contains(key)) continue; // unrecognized option
3560 if (key.equals(CORE_ENCODING)) continue; // skipped, contributed by resource prefs
3561 String value = (String)newOptions.get(key);
3562 preferences.setValue(key, value);
3566 getPlugin().savePluginPreferences();
3570 * Shutdown the JavaCore plug-in.
3572 * De-registers the JavaModelManager as a resource changed listener and save participant.
3574 * @see org.eclipse.core.runtime.Plugin#shutdown()
3576 public void shutdown() {
3578 //savePluginPreferences();
3579 getPlugin().savePluginPreferences();
3580 IWorkspace workspace = ResourcesPlugin.getWorkspace();
3581 workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaProcessor);
3582 workspace.removeSaveParticipant(PHPeclipsePlugin.getDefault());
3584 ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown();
3588 * Initiate the background indexing process.
3589 * This should be deferred after the plugin activation.
3591 //private void startIndexing() {
3593 // JavaModelManager.getJavaModelManager().getIndexManager().reset();
3597 * Startup of the JavaCore plug-in.
3599 * Registers the JavaModelManager as a resource changed listener and save participant.
3600 * Starts the background indexing, and restore saved classpath variable values.
3602 * @see org.eclipse.core.runtime.Plugin#startup()
3604 public void startup() {
3606 JavaModelManager manager = JavaModelManager.getJavaModelManager();
3608 manager.configurePluginDebugOptions();
3610 // request state folder creation (workaround 19885)
3611 PHPCore.getPlugin().getStateLocation();
3613 // retrieve variable values
3614 PHPCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new JavaModelManager.PluginPreferencesListener());
3615 // TODO khartlage temp-del
3616 // manager.loadVariablesAndContainers();
3618 IWorkspace workspace = ResourcesPlugin.getWorkspace();
3619 workspace.addResourceChangeListener(
3620 manager.deltaProcessor,
3621 IResourceChangeEvent.PRE_AUTO_BUILD
3622 | IResourceChangeEvent.POST_AUTO_BUILD
3623 | IResourceChangeEvent.POST_CHANGE
3624 | IResourceChangeEvent.PRE_DELETE
3625 | IResourceChangeEvent.PRE_CLOSE);
3628 workspace.addSaveParticipant(PHPeclipsePlugin.getDefault(), manager);
3630 } catch (CoreException e) {
3631 } catch (RuntimeException e) {
3639 * Internal updating of a variable values (null path meaning removal), allowing to change multiple variable values at once.
3641 //private static void updateVariableValues(
3642 // String[] variableNames,
3643 // IPath[] variablePaths,
3644 // IProgressMonitor monitor) throws JavaModelException {
3646 // if (monitor != null && monitor.isCanceled()) return;
3648 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3649 // System.out.println("CPVariable SET - setting variables: {" + Util.toString(variableNames) //$NON-NLS-1$
3650 // + "} with values: " + Util.toString(variablePaths)); //$NON-NLS-1$
3653 // int varLength = variableNames.length;
3655 // // gather classpath information for updating
3656 // final HashMap affectedProjects = new HashMap(5);
3657 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
3658 // IJavaModel model = manager.getJavaModel();
3660 // // filter out unmodified variables
3661 // int discardCount = 0;
3662 // for (int i = 0; i < varLength; i++){
3663 // String variableName = variableNames[i];
3664 // IPath oldPath = (IPath)JavaModelManager.variableGet(variableName); // if reentering will provide previous session value
3665 // if (oldPath == JavaModelManager.VariableInitializationInProgress){
3666 // IPath previousPath = (IPath)JavaModelManager.PreviousSessionVariables.get(variableName);
3667 // if (previousPath != null){
3668 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3669 // System.out.println("CPVariable INIT - reentering access to variable: " + variableName+ " during its initialization, will see previous value: "+ previousPath); //$NON-NLS-1$ //$NON-NLS-2$
3671 // JavaModelManager.variablePut(variableName, previousPath); // replace value so reentering calls are seeing old value
3673 // oldPath = null; //33695 - cannot filter out restored variable, must update affected project to reset cached CP
3675 // if (oldPath != null && oldPath.equals(variablePaths[i])){
3676 // variableNames[i] = null;
3680 // if (discardCount > 0){
3681 // if (discardCount == varLength) return;
3682 // int changedLength = varLength - discardCount;
3683 // String[] changedVariableNames = new String[changedLength];
3684 // IPath[] changedVariablePaths = new IPath[changedLength];
3685 // for (int i = 0, index = 0; i < varLength; i++){
3686 // if (variableNames[i] != null){
3687 // changedVariableNames[index] = variableNames[i];
3688 // changedVariablePaths[index] = variablePaths[i];
3692 // variableNames = changedVariableNames;
3693 // variablePaths = changedVariablePaths;
3694 // varLength = changedLength;
3697 // if (monitor != null && monitor.isCanceled()) return;
3699 // if (model != null) {
3700 // IJavaProject[] projects = model.getJavaProjects();
3701 // nextProject : for (int i = 0, projectLength = projects.length; i < projectLength; i++){
3702 // IJavaProject project = projects[i];
3704 // // check to see if any of the modified variables is present on the classpath
3705 // IClasspathEntry[] classpath = project.getRawClasspath();
3706 // for (int j = 0, cpLength = classpath.length; j < cpLength; j++){
3708 // IClasspathEntry entry = classpath[j];
3709 // for (int k = 0; k < varLength; k++){
3711 // String variableName = variableNames[k];
3712 // if (entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE){
3714 // if (variableName.equals(entry.getPath().segment(0))){
3715 // affectedProjects.put(project, project.getResolvedClasspath(true));
3716 // continue nextProject;
3718 // IPath sourcePath, sourceRootPath;
3719 // if (((sourcePath = entry.getSourceAttachmentPath()) != null && variableName.equals(sourcePath.segment(0)))
3720 // || ((sourceRootPath = entry.getSourceAttachmentRootPath()) != null && variableName.equals(sourceRootPath.segment(0)))) {
3722 // affectedProjects.put(project, project.getResolvedClasspath(true));
3723 // continue nextProject;
3730 // // update variables
3731 // for (int i = 0; i < varLength; i++){
3732 // JavaModelManager.variablePut(variableNames[i], variablePaths[i]);
3734 // final String[] dbgVariableNames = variableNames;
3736 // // update affected project classpaths
3737 // if (!affectedProjects.isEmpty()) {
3739 // JavaCore_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt.run(
3740 // new IWorkspaceRunnable() {
3741 // public void run(IProgressMonitor monitor) throws CoreException {
3742 // // propagate classpath change
3743 // Iterator projectsToUpdate = affectedProjects.keySet().iterator();
3744 // while (projectsToUpdate.hasNext()) {
3746 // if (monitor != null && monitor.isCanceled()) return;
3748 // JavaProject project = (JavaProject) projectsToUpdate.next();
3750 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3751 // System.out.println("CPVariable SET - updating affected project: ["+project.getElementName()+"] due to setting variables: "+ Util.toString(dbgVariableNames)); //$NON-NLS-1$ //$NON-NLS-2$
3755 // .setRawClasspath(
3756 // project.getRawClasspath(),
3757 // SetClasspathOperation.ReuseOutputLocation,
3758 // null, // don't call beginTask on the monitor (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=3717)
3759 // !ResourcesPlugin.getWorkspace().isTreeLocked(), // can change resources
3760 // (IClasspathEntry[]) affectedProjects.get(project),
3761 // false, // updating - no validation
3762 // false); // updating - no need to save
3767 // } catch (CoreException e) {
3768 // if (JavaModelManager.CP_RESOLVE_VERBOSE){
3769 // System.out.println("CPVariable SET - FAILED DUE TO EXCEPTION: "+Util.toString(dbgVariableNames)); //$NON-NLS-1$
3770 // e.printStackTrace();
3772 // if (e instanceof JavaModelException) {
3773 // throw (JavaModelException)e;
3775 // throw new JavaModelException(e);