e16da972146333fecef6d325b7118c804958516b
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / core / JavaCore.java
1 package net.sourceforge.phpdt.core;
2
3 import java.io.File;
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;
9 import java.util.List;
10 import java.util.Map;
11
12 import net.sourceforge.phpdt.internal.core.BatchOperation;
13 import net.sourceforge.phpdt.internal.core.BufferManager;
14 import net.sourceforge.phpdt.internal.core.ClasspathEntry;
15 import net.sourceforge.phpdt.internal.core.JavaModel;
16 import net.sourceforge.phpdt.internal.core.JavaModelManager;
17 import net.sourceforge.phpdt.internal.core.Region;
18 import net.sourceforge.phpdt.internal.corext.Assert;
19 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
20
21 import org.eclipse.core.resources.IFile;
22 import org.eclipse.core.resources.IFolder;
23 import org.eclipse.core.resources.IMarker;
24 import org.eclipse.core.resources.IMarkerDelta;
25 import org.eclipse.core.resources.IProject;
26 import org.eclipse.core.resources.IProjectDescription;
27 import org.eclipse.core.resources.IResource;
28 import org.eclipse.core.resources.IResourceChangeEvent;
29 import org.eclipse.core.resources.IResourceChangeListener;
30 import org.eclipse.core.resources.ISavedState;
31 import org.eclipse.core.resources.IWorkspace;
32 import org.eclipse.core.resources.IWorkspaceRoot;
33 import org.eclipse.core.resources.IWorkspaceRunnable;
34 import org.eclipse.core.resources.ResourcesPlugin;
35 import org.eclipse.core.runtime.CoreException;
36 import org.eclipse.core.runtime.IConfigurationElement;
37 import org.eclipse.core.runtime.IPath;
38 import org.eclipse.core.runtime.IProgressMonitor;
39 import org.eclipse.core.runtime.IStatus;
40 import org.eclipse.core.runtime.Plugin;
41 import org.eclipse.core.runtime.Preferences;
42 import org.eclipse.core.runtime.Status;
43 import org.eclipse.core.runtime.jobs.ISchedulingRule;
44 import org.eclipse.core.runtime.jobs.Job;
45 import net.sourceforge.phpdt.internal.core.util.Util;
46 import org.osgi.framework.BundleContext;
47
48 public class JavaCore {
49
50         //  public static HashSet OptionNames = new HashSet(20);
51         /**
52          * The plug-in identifier of the Java core support (value
53          * <code>"net.sourceforge.phpeclipse"</code>)
54          */
55         //  public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.core";
56         // //$NON-NLS-1$
57         public static final String PLUGIN_ID = PHPeclipsePlugin.PLUGIN_ID;
58
59         /**
60          * Possible configurable option ID.
61          * 
62          * @see #getDefaultOptions
63          * @since 2.0
64          */
65         public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; //$NON-NLS-1$
66
67         /**
68          * Possible configurable option ID.
69          * 
70          * @see #getDefaultOptions
71          * @since 2.0
72          */
73         public static final String FORMATTER_NEWLINE_OPENING_BRACE = PLUGIN_ID
74                         + ".formatter.newline.openingBrace"; //$NON-NLS-1$
75
76         /**
77          * Possible configurable option ID.
78          * 
79          * @see #getDefaultOptions
80          * @since 2.0
81          */
82         public static final String FORMATTER_NEWLINE_CONTROL = PLUGIN_ID
83                         + ".formatter.newline.controlStatement"; //$NON-NLS-1$
84
85         /**
86          * Possible configurable option ID.
87          * 
88          * @see #getDefaultOptions
89          * @since 2.0
90          */
91         public static final String FORMATTER_NEWLINE_ELSE_IF = PLUGIN_ID
92                         + ".formatter.newline.elseIf"; //$NON-NLS-1$
93
94         /**
95          * Possible configurable option ID.
96          * 
97          * @see #getDefaultOptions
98          * @since 2.0
99          */
100         public static final String FORMATTER_NEWLINE_EMPTY_BLOCK = PLUGIN_ID
101                         + ".formatter.newline.emptyBlock"; //$NON-NLS-1$
102
103         /**
104          * Possible configurable option ID.
105          * 
106          * @see #getDefaultOptions
107          * @since 2.0
108          */
109         public static final String FORMATTER_CLEAR_BLANK_LINES = PLUGIN_ID
110                         + ".formatter.newline.clearAll"; //$NON-NLS-1$
111
112         /**
113          * Possible configurable option ID.
114          * 
115          * @see #getDefaultOptions
116          * @since 2.0
117          */
118         public static final String FORMATTER_LINE_SPLIT = PLUGIN_ID
119                         + ".formatter.lineSplit"; //$NON-NLS-1$
120
121         /**
122          * Possible configurable option ID.
123          * 
124          * @see #getDefaultOptions
125          * @since 2.0
126          */
127         public static final String FORMATTER_COMPACT_ASSIGNMENT = PLUGIN_ID
128                         + ".formatter.style.assignment"; //$NON-NLS-1$
129
130         /**
131          * Possible configurable option ID.
132          * 
133          * @see #getDefaultOptions
134          * @since 2.0
135          */
136         public static final String FORMATTER_TAB_CHAR = PLUGIN_ID
137                         + ".formatter.tabulation.char"; //$NON-NLS-1$
138
139         /**
140          * Possible configurable option ID.
141          * 
142          * @see #getDefaultOptions
143          * @since 2.0
144          */
145         public static final String FORMATTER_TAB_SIZE = PLUGIN_ID
146                         + ".formatter.tabulation.size"; //$NON-NLS-1$
147
148         /**
149          * Possible configurable option value.
150          * 
151          * @see #getDefaultOptions
152          * @since 2.0
153          */
154         public static final String INSERT = "insert"; //$NON-NLS-1$
155
156         /**
157          * Possible configurable option value.
158          * 
159          * @see #getDefaultOptions
160          * @since 2.0
161          */
162         public static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$
163
164         /**
165          * Possible configurable option value.
166          * 
167          * @see #getDefaultOptions
168          * @since 2.0
169          */
170         public static final String PRESERVE_ONE = "preserve one"; //$NON-NLS-1$
171
172         /**
173          * Possible configurable option value.
174          * 
175          * @see #getDefaultOptions
176          * @since 2.0
177          */
178         public static final String CLEAR_ALL = "clear all"; //$NON-NLS-1$
179
180         /**
181          * Possible configurable option value.
182          * 
183          * @see #getDefaultOptions
184          * @since 2.0
185          */
186         public static final String NORMAL = "normal"; //$NON-NLS-1$
187
188         /**
189          * Possible configurable option value.
190          * 
191          * @see #getDefaultOptions
192          * @since 2.0
193          */
194         public static final String COMPACT = "compact"; //$NON-NLS-1$
195
196         /**
197          * Possible configurable option value.
198          * 
199          * @see #getDefaultOptions
200          * @since 2.0
201          */
202         public static final String TAB = "tab"; //$NON-NLS-1$
203
204         /**
205          * Possible configurable option value.
206          * 
207          * @see #getDefaultOptions
208          * @since 2.0
209          */
210         public static final String SPACE = "space"; //$NON-NLS-1$
211
212         /**
213          * Possible configurable option value.
214          * 
215          * @see #getDefaultOptions
216          * @since 2.0
217          */
218         public static final String ENABLED = "enabled"; //$NON-NLS-1$
219
220         /**
221          * Possible configurable option value.
222          * 
223          * @see #getDefaultOptions
224          * @since 2.0
225          */
226         public static final String DISABLED = "disabled"; //$NON-NLS-1$
227
228         /**
229          * Possible configurable option value.
230          * 
231          * @see #getDefaultOptions
232          * @since 2.1
233          */
234         public static final String CLEAN = "clean"; //$NON-NLS-1$
235
236         /**
237          * Possible configurable option ID.
238          * 
239          * @see #getDefaultOptions
240          * @since 2.1
241          */
242         public static final String COMPILER_TASK_TAGS = PLUGIN_ID
243                         + ".compiler.taskTags"; //$NON-NLS-1$
244
245         /**
246          * Name of the handle id attribute in a Java marker.
247          */
248         protected static final String ATT_HANDLE_ID = "net.sourceforge.phpdt.internal.core.JavaModelManager.handleId"; //$NON-NLS-1$
249
250         // *************** Possible IDs for configurable options.
251         // ********************
252
253         /**
254          * Possible configurable option ID.
255          * 
256          * @see #getDefaultOptions()
257          */
258         public static final String COMPILER_LOCAL_VARIABLE_ATTR = PLUGIN_ID
259                         + ".compiler.debug.localVariable"; //$NON-NLS-1$
260
261         /**
262          * Possible configurable option ID.
263          * 
264          * @see #getDefaultOptions()
265          */
266         public static final String COMPILER_LINE_NUMBER_ATTR = PLUGIN_ID
267                         + ".compiler.debug.lineNumber"; //$NON-NLS-1$
268
269         /**
270          * Possible configurable option ID.
271          * 
272          * @see #getDefaultOptions
273          */
274         public static final String COMPILER_SOURCE_FILE_ATTR = PLUGIN_ID
275                         + ".compiler.debug.sourceFile"; //$NON-NLS-1$
276
277         /**
278          * Possible configurable option ID.
279          * 
280          * @see #getDefaultOptions
281          */
282         public static final String COMPILER_CODEGEN_UNUSED_LOCAL = PLUGIN_ID
283                         + ".compiler.codegen.unusedLocal"; //$NON-NLS-1$
284
285         /**
286          * Possible configurable option ID.
287          * 
288          * @see #getDefaultOptions
289          */
290         public static final String COMPILER_CODEGEN_TARGET_PLATFORM = PLUGIN_ID
291                         + ".compiler.codegen.targetPlatform"; //$NON-NLS-1$
292
293         /**
294          * Possible configurable option ID.
295          * 
296          * @see #getDefaultOptions
297          */
298         public static final String COMPILER_PB_PHP_VAR_DEPRECATED = PLUGIN_ID
299                         + ".compiler.problem.phpVarDeprecatedWarning"; //$NON-NLS-1$
300         
301         public static final String COMPILER_PB_PHP_KEYWORD = PLUGIN_ID
302                 + ".compiler.problem.phpBadStyleKeywordWarning"; //$NON-NLS-1$
303         
304         public static final String COMPILER_PB_PHP_UPPERCASE_IDENTIFIER = PLUGIN_ID
305                 + ".compiler.problem.phpBadStyleUppercaseIdentifierWarning"; //$NON-NLS-1$
306         
307         /**
308          * Possible configurable option ID.
309          * 
310          * @see #getDefaultOptions
311          */
312         public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID
313                         + ".compiler.problem.unreachableCode"; //$NON-NLS-1$
314
315         /**
316          * Possible configurable option ID.
317          * 
318          * @see #getDefaultOptions
319          */
320         public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID
321                         + ".compiler.problem.invalidImport"; //$NON-NLS-1$
322
323         /**
324          * Possible configurable option ID.
325          * 
326          * @see #getDefaultOptions
327          */
328         public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID
329                         + ".compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
330
331         /**
332          * Possible configurable option ID.
333          * 
334          * @see #getDefaultOptions
335          */
336         public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID
337                         + ".compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
338
339         /**
340          * Possible configurable option ID.
341          * 
342          * @see #getDefaultOptions
343          */
344         public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID
345                         + ".compiler.problem.deprecation"; //$NON-NLS-1$
346
347         /**
348          * Possible configurable option ID.
349          * 
350          * @see #getDefaultOptions
351          * @since 2.1
352          */
353         public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID
354                         + ".compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
355
356         /**
357          * Possible configurable option ID.
358          * 
359          * @see #getDefaultOptions
360          */
361         public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID
362                         + ".compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
363
364         /**
365          * Possible configurable option ID.
366          * 
367          * @see #getDefaultOptions
368          */
369         public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID
370                         + ".compiler.problem.unusedLocal"; //$NON-NLS-1$
371
372         /**
373          * Possible configurable option ID.
374          * 
375          * @see #getDefaultOptions
376          */
377         public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID
378                         + ".compiler.problem.unusedParameter"; //$NON-NLS-1$
379
380         /**
381          * Possible configurable option ID.
382          * 
383          * @see #getDefaultOptions
384          * @since 2.1
385          */
386         public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID
387                         + ".compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
388
389         /**
390          * Possible configurable option ID.
391          * 
392          * @see #getDefaultOptions
393          * @since 2.1
394          */
395         public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID
396                         + ".compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
397
398         /**
399          * Possible configurable option ID.
400          * 
401          * @see #getDefaultOptions
402          * @since 2.0
403          */
404         public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID
405                         + ".compiler.problem.unusedImport"; //$NON-NLS-1$
406
407         /**
408          * Possible configurable option ID.
409          * 
410          * @see #getDefaultOptions
411          */
412         public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID
413                         + ".compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
414
415         /**
416          * Possible configurable option ID.
417          * 
418          * @see #getDefaultOptions
419          * @since 2.0
420          */
421         public static final String COMPILER_PB_NON_NLS_STRING_LITERAL = PLUGIN_ID
422                         + ".compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
423
424         /**
425          * Possible configurable option ID.
426          * 
427          * @see #getDefaultOptions
428          * @since 2.0
429          */
430         public static final String COMPILER_PB_ASSERT_IDENTIFIER = PLUGIN_ID
431                         + ".compiler.problem.assertIdentifier"; //$NON-NLS-1$
432
433         /**
434          * Possible configurable option ID.
435          * 
436          * @see #getDefaultOptions
437          * @since 2.1
438          */
439         public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID
440                         + ".compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
441
442         /**
443          * Possible configurable option ID.
444          * 
445          * @see #getDefaultOptions
446          * @since 2.1
447          */
448         public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID
449                         + ".compiler.problem.noEffectAssignment"; //$NON-NLS-1$
450
451         /**
452          * Possible configurable option ID.
453          * 
454          * @see #getDefaultOptions
455          * @since 2.1
456          */
457         public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID
458                         + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
459
460         /**
461          * Possible configurable option ID.
462          * 
463          * @see #getDefaultOptions
464          * @since 2.1
465          */
466         public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID
467                         + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
468
469         /**
470          * Possible configurable option ID.
471          * 
472          * @see #getDefaultOptions
473          * @since 2.1
474          */
475         public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID
476                         + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
477
478         /**
479          * Possible configurable option ID.
480          * 
481          * @see #getDefaultOptions
482          * @since 2.0
483          */
484         public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID
485                         + ".compiler.maxProblemPerUnit"; //$NON-NLS-1$
486
487         /**
488          * Possible configurable option ID.
489          * 
490          * @see #getDefaultOptions
491          * @since 2.0
492          */
493         public static final String COMPILER_SOURCE = PLUGIN_ID + ".compiler.source"; //$NON-NLS-1$
494
495         /**
496          * Possible configurable option ID.
497          * 
498          * @see #getDefaultOptions
499          * @since 2.0
500          */
501         public static final String COMPILER_COMPLIANCE = PLUGIN_ID
502                         + ".compiler.compliance"; //$NON-NLS-1$
503
504         /**
505          * Possible configurable option ID.
506          * 
507          * @see #getDefaultOptions
508          * @since 2.1
509          */
510         public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID
511                         + ".compiler.taskPriorities"; //$NON-NLS-1$
512
513         /**
514          * Possible configurable option value for COMPILER_TASK_PRIORITIES.
515          * 
516          * @see #getDefaultOptions
517          * @since 2.1
518          */
519         public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$
520
521         /**
522          * Possible configurable option value for COMPILER_TASK_PRIORITIES.
523          * 
524          * @see #getDefaultOptions
525          * @since 2.1
526          */
527         public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$
528
529         /**
530          * Possible configurable option value for COMPILER_TASK_PRIORITIES.
531          * 
532          * @see #getDefaultOptions
533          * @since 2.1
534          */
535         public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$
536
537         /**
538          * Possible configurable option ID.
539          * 
540          * @see #getDefaultOptions
541          */
542         public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID
543                         + ".computeJavaBuildOrder"; //$NON-NLS-1$
544
545         /**
546          * Possible configurable option ID.
547          * 
548          * @see #getDefaultOptions
549          * @since 2.0
550          */
551         public static final String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER = PLUGIN_ID
552                         + ".builder.resourceCopyExclusionFilter"; //$NON-NLS-1$
553
554         /**
555          * Possible configurable option ID.
556          * 
557          * @see #getDefaultOptions
558          * @since 2.1
559          */
560         public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID
561                         + ".builder.duplicateResourceTask"; //$NON-NLS-1$
562
563         /**
564          * Possible configurable option ID.
565          * 
566          * @see #getDefaultOptions
567          * @since 2.1
568          */
569         public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID
570                         + ".builder.cleanOutputFolder"; //$NON-NLS-1$           
571
572         /**
573          * Possible configurable option ID.
574          * 
575          * @see #getDefaultOptions
576          * @since 2.1
577          */
578         public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID
579                         + ".incompleteClasspath"; //$NON-NLS-1$
580
581         /**
582          * Possible configurable option ID.
583          * 
584          * @see #getDefaultOptions
585          * @since 2.1
586          */
587         public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID
588                         + ".circularClasspath"; //$NON-NLS-1$
589
590         /**
591          * Possible configurable option ID.
592          * 
593          * @see #getDefaultOptions
594          * @since 2.0
595          */
596         public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID
597                         + ".builder.invalidClasspath"; //$NON-NLS-1$
598
599         /**
600          * Possible configurable option ID.
601          * 
602          * @see #getDefaultOptions
603          * @since 2.1
604          */
605         public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID
606                         + ".classpath.exclusionPatterns"; //$NON-NLS-1$
607
608         /**
609          * Possible configurable option ID.
610          * 
611          * @see #getDefaultOptions
612          * @since 2.1
613          */
614         public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID
615                         + ".classpath.multipleOutputLocations"; //$NON-NLS-1$
616
617         /**
618          * Default task tag
619          * 
620          * @since 2.1
621          */
622         public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$
623
624         /**
625          * Default task priority
626          * 
627          * @since 2.1
628          */
629         public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; //$NON-NLS-1$
630
631         /**
632          * Possible configurable option ID
633          * 
634          * @see #getDefaultOptions
635          * @since 2.1
636          */
637         public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID
638                         + ".formatter.space.castexpression"; //$NON-NLS-1$
639
640         /**
641          * Possible configurable option ID.
642          * 
643          * @see #getDefaultOptions
644          * @since 2.0
645          */
646         public static final String CODEASSIST_VISIBILITY_CHECK = PLUGIN_ID
647                         + ".codeComplete.visibilityCheck"; //$NON-NLS-1$
648
649         /**
650          * Possible configurable option ID.
651          * 
652          * @see #getDefaultOptions
653          * @since 2.0
654          */
655         public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID
656                         + ".codeComplete.forceImplicitQualification"; //$NON-NLS-1$
657
658         /**
659          * Possible configurable option ID.
660          * 
661          * @see #getDefaultOptions
662          * @since 2.1
663          */
664         public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID
665                         + ".codeComplete.fieldPrefixes"; //$NON-NLS-1$
666
667         /**
668          * Possible configurable option ID.
669          * 
670          * @see #getDefaultOptions
671          * @since 2.1
672          */
673         public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID
674                         + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
675
676         /**
677          * Possible configurable option ID.
678          * 
679          * @see #getDefaultOptions
680          * @since 2.1
681          */
682         public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID
683                         + ".codeComplete.localPrefixes"; //$NON-NLS-1$
684
685         /**
686          * Possible configurable option ID.
687          * 
688          * @see #getDefaultOptions
689          * @since 2.1
690          */
691         public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID
692                         + ".codeComplete.argumentPrefixes"; //$NON-NLS-1$
693
694         /**
695          * Possible configurable option ID.
696          * 
697          * @see #getDefaultOptions
698          * @since 2.1
699          */
700         public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID
701                         + ".codeComplete.fieldSuffixes"; //$NON-NLS-1$
702
703         /**
704          * Possible configurable option ID.
705          * 
706          * @see #getDefaultOptions
707          * @since 2.1
708          */
709         public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID
710                         + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
711
712         /**
713          * Possible configurable option ID.
714          * 
715          * @see #getDefaultOptions
716          * @since 2.1
717          */
718         public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID
719                         + ".codeComplete.localSuffixes"; //$NON-NLS-1$
720
721         /**
722          * Possible configurable option ID.
723          * 
724          * @see #getDefaultOptions
725          * @since 2.1
726          */
727         public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID
728                         + ".codeComplete.argumentSuffixes"; //$NON-NLS-1$
729
730         // *************** Possible values for configurable options.
731         // ********************
732
733         /**
734          * Possible configurable option value.
735          * 
736          * @see #getDefaultOptions
737          */
738         public static final String GENERATE = "generate"; //$NON-NLS-1$
739
740         /**
741          * Possible configurable option value.
742          * 
743          * @see #getDefaultOptions
744          */
745         public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
746
747         /**
748          * Possible configurable option value.
749          * 
750          * @see #getDefaultOptions
751          */
752         public static final String PRESERVE = "preserve"; //$NON-NLS-1$
753
754         /**
755          * Possible configurable option value.
756          * 
757          * @see #getDefaultOptions
758          */
759         public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
760
761         /**
762          * Possible configurable option value.
763          * 
764          * @see #getDefaultOptions
765          */
766         public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$
767
768         /**
769          * Possible configurable option value.
770          * 
771          * @see #getDefaultOptions
772          */
773         public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$
774
775         /**
776          * Possible configurable option value.
777          * 
778          * @see #getDefaultOptions
779          * @since 2.0
780          */
781         public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
782
783         /**
784          * Possible configurable option value.
785          * 
786          * @see #getDefaultOptions
787          * @since 2.0
788          */
789         public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
790
791         /**
792          * Possible configurable option value.
793          * 
794          * @see #getDefaultOptions
795          * @since 2.0
796          */
797         public static final String ABORT = "abort"; //$NON-NLS-1$
798
799         /**
800          * Possible configurable option value.
801          * 
802          * @see #getDefaultOptions
803          */
804         public static final String ERROR = "error"; //$NON-NLS-1$
805
806         /**
807          * Possible configurable option value.
808          * 
809          * @see #getDefaultOptions
810          */
811         public static final String WARNING = "warning"; //$NON-NLS-1$
812
813         /**
814          * Possible configurable option value.
815          * 
816          * @see #getDefaultOptions
817          */
818         public static final String IGNORE = "ignore"; //$NON-NLS-1$
819
820         /**
821          * Possible configurable option value.
822          * 
823          * @see #getDefaultOptions
824          */
825         public static final String COMPUTE = "compute"; //$NON-NLS-1$
826
827         /**
828          * Possible configurable option value.
829          * 
830          * @see #getDefaultOptions
831          * @since 2.0
832          */
833
834         /**
835          * Returns a table of all known configurable options with their default
836          * values. These options allow to configure the behaviour of the underlying
837          * components. The client may safely use the result as a template that they
838          * can modify and then pass to <code>setOptions</code>.
839          * 
840          * Helper constants have been defined on JavaCore for each of the option ID
841          * and their possible constant values.
842          * 
843          * Note: more options might be added in further releases.
844          * 
845          * <pre>
846          * 
847          *  RECOGNIZED OPTIONS:
848          *  COMPILER / Generating Local Variable Debug Attribute
849          *     When generated, this attribute will enable local variable names 
850          *     to be displayed in debugger, only in place where variables are 
851          *     definitely assigned (.class file is then bigger)
852          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.debug.localVariable&quot;
853          *      - possible values:   { &quot;generate&quot;, &quot;do not generate&quot; }
854          *      - default:           &quot;generate&quot;
855          * 
856          *  COMPILER / Generating Line Number Debug Attribute 
857          *     When generated, this attribute will enable source code highlighting in debugger 
858          *     (.class file is then bigger).
859          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.debug.lineNumber&quot;
860          *      - possible values:   { &quot;generate&quot;, &quot;do not generate&quot; }
861          *      - default:           &quot;generate&quot;
862          *     
863          *  COMPILER / Generating Source Debug Attribute 
864          *     When generated, this attribute will enable the debugger to present the 
865          *     corresponding source code.
866          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.debug.sourceFile&quot;
867          *      - possible values:   { &quot;generate&quot;, &quot;do not generate&quot; }
868          *      - default:           &quot;generate&quot;
869          *     
870          *  COMPILER / Preserving Unused Local Variables
871          *     Unless requested to preserve unused local variables (i.e. never read), the 
872          *     compiler will optimize them out, potentially altering debugging
873          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.codegen.unusedLocal&quot;
874          *      - possible values:   { &quot;preserve&quot;, &quot;optimize out&quot; }
875          *      - default:           &quot;preserve&quot;
876          *  
877          *  COMPILER / Defining Target Java Platform
878          *     For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
879          *     Note that &quot;1.4&quot; target require to toggle compliance mode to &quot;1.4&quot; too.
880          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.codegen.targetPlatform&quot;
881          *      - possible values:   { &quot;1.1&quot;, &quot;1.2&quot;, &quot;1.3&quot;, &quot;1.4&quot; }
882          *      - default:           &quot;1.1&quot;
883          * 
884          *  COMPILER / Reporting Unreachable Code
885          *     Unreachable code can optionally be reported as an error, warning or simply 
886          *     ignored. The bytecode generation will always optimized it out.
887          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.problem.unreachableCode&quot;
888          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
889          *      - default:           &quot;error&quot;
890          * 
891          *  COMPILER / Reporting Invalid Import
892          *     An import statement that cannot be resolved might optionally be reported 
893          *     as an error, as a warning or ignored.
894          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.problem.invalidImport&quot;
895          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
896          *      - default:           &quot;error&quot;
897          * 
898          *  COMPILER / Reporting Attempt to Override Package-Default Method
899          *     A package default method is not visible in a different package, and thus 
900          *     cannot be overridden. When enabling this option, the compiler will signal 
901          *     such scenarii either as an error or a warning.
902          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.problem.overridingPackageDefaultMethod&quot;
903          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
904          *      - default:           &quot;warning&quot;
905          * 
906          *  COMPILER / Reporting Method With Constructor Name
907          *     Naming a method with a constructor name is generally considered poor 
908          *     style programming. When enabling this option, the compiler will signal such 
909          *     scenarii either as an error or a warning.
910          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.problem.methodWithConstructorName&quot;
911          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
912          *      - default:           &quot;warning&quot;
913          * 
914          *  COMPILER / Reporting Deprecation
915          *     When enabled, the compiler will signal use of deprecated API either as an 
916          *     error or a warning.
917          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.problem.deprecation&quot;
918          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
919          *      - default:           &quot;warning&quot;
920          * 
921          *  COMPILER / Reporting Deprecation Inside Deprecated Code
922          *     When enabled, the compiler will signal use of deprecated API inside deprecated code.
923          *     The severity of the problem is controlled with option &quot;org.phpeclipse.phpdt.core.compiler.problem.deprecation&quot;.
924          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.problem.deprecationInDeprecatedCode&quot;
925          *      - possible values:   { &quot;enabled&quot;, &quot;disabled&quot; }
926          *      - default:           &quot;disabled&quot;
927          * 
928          *  COMPILER / Reporting Hidden Catch Block
929          *     Locally to a try statement, some catch blocks may hide others , e.g.
930          *       try {  throw new java.io.CharConversionException();
931          *       } catch (java.io.CharConversionException e) {
932          *       } catch (java.io.IOException e) {}. 
933          *     When enabling this option, the compiler will issue an error or a warning for hidden 
934          *     catch blocks corresponding to checked exceptions
935          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.problem.hiddenCatchBlock&quot;
936          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
937          *      - default:           &quot;warning&quot;
938          * 
939          *  COMPILER / Reporting Unused Local
940          *     When enabled, the compiler will issue an error or a warning for unused local 
941          *     variables (i.e. variables never read from)
942          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.problem.unusedLocal&quot;
943          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
944          *      - default:           &quot;ignore&quot;
945          * 
946          *  COMPILER / Reporting Unused Parameter
947          *     When enabled, the compiler will issue an error or a warning for unused method 
948          *     parameters (i.e. parameters never read from)
949          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.problem.unusedParameter&quot;
950          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
951          *      - default:           &quot;ignore&quot;
952          * 
953          *  COMPILER / Reporting Unused Import
954          *     When enabled, the compiler will issue an error or a warning for unused import 
955          *     reference 
956          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.problem.unusedImport&quot;
957          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
958          *      - default:           &quot;warning&quot;
959          * 
960          *  COMPILER / Reporting Synthetic Access Emulation
961          *     When enabled, the compiler will issue an error or a warning whenever it emulates 
962          *     access to a non-accessible member of an enclosing type. Such access can have
963          *     performance implications.
964          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.problem.syntheticAccessEmulation&quot;
965          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
966          *      - default:           &quot;ignore&quot;
967          * 
968          *  COMPILER / Reporting Non-Externalized String Literal
969          *     When enabled, the compiler will issue an error or a warning for non externalized 
970          *     String literal (i.e. non tagged with //$NON-NLS-&lt;n&gt;$). 
971          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.problem.nonExternalizedStringLiteral&quot;
972          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
973          *      - default:           &quot;ignore&quot;
974          *  
975          *  COMPILER / Reporting Usage of 'assert' Identifier
976          *     When enabled, the compiler will issue an error or a warning whenever 'assert' is 
977          *     used as an identifier (reserved keyword in 1.4)
978          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.problem.assertIdentifier&quot;
979          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
980          *      - default:           &quot;ignore&quot;
981          *  
982          *  COMPILER / Reporting Usage of expression receiver on static invocation/field access
983          *     When enabled, the compiler will issue an error or a warning whenever a static field
984          *     or method is accessed with an expression receiver.
985          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.problem.staticAccessReceiver&quot;
986          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
987          *      - default:           &quot;warning&quot;
988          *  
989          *  COMPILER / Reporting Assignment with no effect
990          *     When enabled, the compiler will issue an error or a warning whenever an assignment
991          *     has no effect (e.g 'x = x').
992          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.problem.noEffectAssignment&quot;
993          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
994          *      - default:           &quot;warning&quot;
995          *  
996          *  COMPILER / Setting Source Compatibility Mode
997          *     Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
998          *     reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
999          *    level should be set to &quot;1.4&quot; and the compliance mode should be &quot;1.4&quot;.
1000          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.source&quot;
1001          *      - possible values:   { &quot;1.3&quot;, &quot;1.4&quot; }
1002          *      - default:           &quot;1.3&quot;
1003          *  
1004          *  COMPILER / Setting Compliance Level
1005          *     Select the compliance level for the compiler. In &quot;1.3&quot; mode, source and target settings
1006          *     should not go beyond &quot;1.3&quot; level.
1007          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.compliance&quot;
1008          *      - possible values:   { &quot;1.3&quot;, &quot;1.4&quot; }
1009          *      - default:           &quot;1.3&quot;
1010          *  
1011          *  COMPILER / Maximum number of problems reported per compilation unit
1012          *     Specify the maximum number of problems reported on each compilation unit.
1013          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.maxProblemPerUnit&quot;
1014          *      - possible values:      &quot;&lt;n&gt;&quot; where &lt;n&gt; is zero or a positive integer (if zero then all problems are reported).
1015          *      - default:           &quot;100&quot;
1016          *  
1017          *  COMPILER / Define the Automatic Task Tags
1018          *     When the tag is non empty, the compiler will issue a task marker whenever it encounters
1019          *     one of the corresponding tag inside any comment in Java source code.
1020          *     Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed.
1021          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.taskTags&quot;
1022          *      - possible values:   { &quot;&lt;tag&gt;[,&lt;tag&gt;]*&quot; } where &lt;tag&gt; is a String without any wild-card 
1023          *      - default:           &quot;&quot;
1024          *  COMPILER / Define the Automatic Task Priorities
1025          *     In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
1026          *     of the task markers issued by the compiler.
1027          *     If the default is specified, the priority of each task marker is &quot;NORMAL&quot;.
1028          *      - option id:         &quot;org.phpeclipse.phpdt.core.compiler.taskPriorities&quot;
1029          *      - possible values:   { &quot;&lt;priority&gt;[,&lt;priority&gt;]*&quot; } where &lt;priority&gt; is one of &quot;HIGH&quot;, &quot;NORMAL&quot; or &quot;LOW&quot;
1030          *      - default:           &quot;&quot;
1031          *  
1032          *  BUILDER / Specifying Filters for Resource Copying Control
1033          *     Allow to specify some filters to control the resource copy process.
1034          *      - option id:         &quot;org.phpeclipse.phpdt.core.builder.resourceCopyExclusionFilter&quot;
1035          *      - possible values:   { &quot;&lt;name&gt;[,&lt;name&gt;]* } where &lt;name&gt; is a file name pattern (* and ? wild-cards allowed)
1036          *        or the name of a folder which ends with '/'
1037          *      - default:           &quot;&quot;
1038          *  
1039          *  BUILDER / Abort if Invalid Classpath
1040          *     Allow to toggle the builder to abort if the classpath is invalid
1041          *      - option id:         &quot;org.phpeclipse.phpdt.core.builder.invalidClasspath&quot;
1042          *      - possible values:   { &quot;abort&quot;, &quot;ignore&quot; }
1043          *      - default:           &quot;ignore&quot;
1044          *  
1045          *  BUILDER / Cleaning Output Folder(s)
1046          *     Indicate whether the JavaBuilder is allowed to clean the output folders
1047          *     when performing full build operations.
1048          *      - option id:         &quot;org.phpeclipse.phpdt.core.builder.cleanOutputFolder&quot;
1049          *      - possible values:   { &quot;clean&quot;, &quot;ignore&quot; }
1050          *      - default:           &quot;clean&quot;
1051          *  
1052          *  JAVACORE / Computing Project Build Order
1053          *     Indicate whether JavaCore should enforce the project build order to be based on
1054          *     the classpath prerequisite chain. When requesting to compute, this takes over
1055          *     the platform default order (based on project references).
1056          *      - option id:         &quot;org.phpeclipse.phpdt.core.computeJavaBuildOrder&quot;
1057          *      - possible values:   { &quot;compute&quot;, &quot;ignore&quot; }
1058          *      - default:           &quot;ignore&quot;  
1059          *  
1060          *  JAVACORE / Specify Default Source Encoding Format
1061          *     Get the encoding format for compiled sources. This setting is read-only, it is equivalent
1062          *     to 'ResourcesPlugin.getEncoding()'.
1063          *      - option id:         &quot;org.phpeclipse.phpdt.core.encoding&quot;
1064          *      - possible values:   { any of the supported encoding name}.
1065          *      - default:           &lt;platform default&gt;
1066          *  
1067          *  JAVACORE / Reporting Incomplete Classpath
1068          *     An entry on the classpath doesn't exist or is not visible (e.g. a referenced project is closed).
1069          *      - option id:         &quot;org.phpeclipse.phpdt.core.incompleteClasspath&quot;
1070          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;}
1071          *      - default:           &quot;error&quot;
1072          *  
1073          *  JAVACORE / Reporting Classpath Cycle
1074          *     A project is involved in a cycle.
1075          *      - option id:         &quot;org.phpeclipse.phpdt.core.circularClasspath&quot;
1076          *      - possible values:   { &quot;error&quot;, &quot;warning&quot; }
1077          *      - default:           &quot;error&quot;
1078          *  
1079          *      FORMATTER / Inserting New Line Before Opening Brace
1080          *     When Insert, a new line is inserted before an opening brace, otherwise nothing
1081          *     is inserted
1082          *      - option id:         &quot;org.phpeclipse.phpdt.core.formatter.newline.openingBrace&quot;
1083          *      - possible values:   { &quot;insert&quot;, &quot;do not insert&quot; }
1084          *      - default:           &quot;do not insert&quot;
1085          *  
1086          *      FORMATTER / Inserting New Line Inside Control Statement
1087          *     When Insert, a new line is inserted between } and following else, catch, finally
1088          *      - option id:         &quot;org.phpeclipse.phpdt.core.formatter.newline.controlStatement&quot;
1089          *      - possible values:   { &quot;insert&quot;, &quot;do not insert&quot; }
1090          *      - default:           &quot;do not insert&quot;
1091          *  
1092          *      FORMATTER / Clearing Blank Lines
1093          *     When Clear all, all blank lines are removed. When Preserve one, only one is kept
1094          *     and all others removed.
1095          *      - option id:         &quot;org.phpeclipse.phpdt.core.formatter.newline.clearAll&quot;
1096          *      - possible values:   { &quot;clear all&quot;, &quot;preserve one&quot; }
1097          *      - default:           &quot;preserve one&quot;
1098          *  
1099          *      FORMATTER / Inserting New Line Between Else/If 
1100          *     When Insert, a blank line is inserted between an else and an if when they are 
1101          *     contiguous. When choosing to not insert, else-if will be kept on the same
1102          *     line when possible.
1103          *      - option id:         &quot;org.phpeclipse.phpdt.core.formatter.newline.elseIf&quot;
1104          *      - possible values:   { &quot;insert&quot;, &quot;do not insert&quot; }
1105          *      - default:           &quot;do not insert&quot;
1106          *  
1107          *      FORMATTER / Inserting New Line In Empty Block
1108          *     When insert, a line break is inserted between contiguous { and }, if } is not followed
1109          *     by a keyword.
1110          *      - option id:         &quot;org.phpeclipse.phpdt.core.formatter.newline.emptyBlock&quot;
1111          *      - possible values:   { &quot;insert&quot;, &quot;do not insert&quot; }
1112          *      - default:           &quot;insert&quot;
1113          *  
1114          *      FORMATTER / Splitting Lines Exceeding Length
1115          *     Enable splitting of long lines (exceeding the configurable length). Length of 0 will
1116          *     disable line splitting
1117          *      - option id:         &quot;org.phpeclipse.phpdt.core.formatter.lineSplit&quot;
1118          *      - possible values:      &quot;&lt;n&gt;&quot;, where n is zero or a positive integer
1119          *      - default:           &quot;80&quot;
1120          *  
1121          *      FORMATTER / Compacting Assignment
1122          *     Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space
1123          *     is inserted before the assignment operator
1124          *      - option id:         &quot;org.phpeclipse.phpdt.core.formatter.style.assignment&quot;
1125          *      - possible values:   { &quot;compact&quot;, &quot;normal&quot; }
1126          *      - default:           &quot;normal&quot;
1127          *  
1128          *      FORMATTER / Defining Indentation Character
1129          *     Either choose to indent with tab characters or spaces
1130          *      - option id:         &quot;org.phpeclipse.phpdt.core.formatter.tabulation.char&quot;
1131          *      - possible values:   { &quot;tab&quot;, &quot;space&quot; }
1132          *      - default:           &quot;tab&quot;
1133          *  
1134          *      FORMATTER / Defining Space Indentation Length
1135          *     When using spaces, set the amount of space characters to use for each 
1136          *     indentation mark.
1137          *      - option id:         &quot;org.phpeclipse.phpdt.core.formatter.tabulation.size&quot;
1138          *      - possible values:      &quot;&lt;n&gt;&quot;, where n is a positive integer
1139          *      - default:           &quot;4&quot;
1140          *  
1141          *      CODEASSIST / Activate Visibility Sensitive Completion
1142          *     When active, completion doesn't show that you can not see
1143          *     (e.g. you can not see private methods of a super class).
1144          *      - option id:         &quot;org.phpeclipse.phpdt.core.codeComplete.visibilityCheck&quot;
1145          *      - possible values:   { &quot;enabled&quot;, &quot;disabled&quot; }
1146          *      - default:           &quot;disabled&quot;
1147          *  
1148          *      CODEASSIST / Automatic Qualification of Implicit Members
1149          *     When active, completion automatically qualifies completion on implicit
1150          *     field references and message expressions.
1151          *      - option id:         &quot;org.phpeclipse.phpdt.core.codeComplete.forceImplicitQualification&quot;
1152          *      - possible values:   { &quot;enabled&quot;, &quot;disabled&quot; }
1153          *      - default:           &quot;disabled&quot;
1154          *  
1155          *   CODEASSIST / Define the Prefixes for Field Name
1156          *     When the prefixes is non empty, completion for field name will begin with
1157          *     one of the proposed prefixes.
1158          *      - option id:         &quot;org.phpeclipse.phpdt.core.codeComplete.fieldPrefixes&quot;
1159          *      - possible values:   { &quot;&lt;prefix&gt;[,&lt;prefix&gt;]*&quot; } where &lt;prefix&gt; is a String without any wild-card 
1160          *      - default:           &quot;&quot;
1161          *  
1162          *   CODEASSIST / Define the Prefixes for Static Field Name
1163          *     When the prefixes is non empty, completion for static field name will begin with
1164          *     one of the proposed prefixes.
1165          *      - option id:         &quot;org.phpeclipse.phpdt.core.codeComplete.staticFieldPrefixes&quot;
1166          *      - possible values:   { &quot;&lt;prefix&gt;[,&lt;prefix&gt;]*&quot; } where &lt;prefix&gt; is a String without any wild-card 
1167          *      - default:           &quot;&quot;
1168          *  
1169          *   CODEASSIST / Define the Prefixes for Local Variable Name
1170          *     When the prefixes is non empty, completion for local variable name will begin with
1171          *     one of the proposed prefixes.
1172          *      - option id:         &quot;org.phpeclipse.phpdt.core.codeComplete.localPrefixes&quot;
1173          *      - possible values:   { &quot;&lt;prefix&gt;[,&lt;prefix&gt;]*&quot; } where &lt;prefix&gt; is a String without any wild-card 
1174          *      - default:           &quot;&quot;
1175          *  
1176          *   CODEASSIST / Define the Prefixes for Argument Name
1177          *     When the prefixes is non empty, completion for argument name will begin with
1178          *     one of the proposed prefixes.
1179          *      - option id:         &quot;org.phpeclipse.phpdt.core.codeComplete.argumentPrefixes&quot;
1180          *      - possible values:   { &quot;&lt;prefix&gt;[,&lt;prefix&gt;]*&quot; } where &lt;prefix&gt; is a String without any wild-card 
1181          *      - default:           &quot;&quot;
1182          *  
1183          *   CODEASSIST / Define the Suffixes for Field Name
1184          *     When the suffixes is non empty, completion for field name will end with
1185          *     one of the proposed suffixes.
1186          *      - option id:         &quot;org.phpeclipse.phpdt.core.codeComplete.fieldSuffixes&quot;
1187          *      - possible values:   { &quot;&lt;suffix&gt;[,&lt;suffix&gt;]*&quot; } where &lt;suffix&gt; is a String without any wild-card 
1188          *      - default:           &quot;&quot;
1189          *  
1190          *   CODEASSIST / Define the Suffixes for Static Field Name
1191          *     When the suffixes is non empty, completion for static field name will end with
1192          *     one of the proposed suffixes.
1193          *      - option id:         &quot;org.phpeclipse.phpdt.core.codeComplete.staticFieldSuffixes&quot;
1194          *      - possible values:   { &quot;&lt;suffix&gt;[,&lt;suffix&gt;]*&quot; } where &lt;suffix&gt; is a String without any wild-card 
1195          *      - default:           &quot;&quot;
1196          *  
1197          *   CODEASSIST / Define the Suffixes for Local Variable Name
1198          *     When the suffixes is non empty, completion for local variable name will end with
1199          *     one of the proposed suffixes.
1200          *      - option id:         &quot;org.phpeclipse.phpdt.core.codeComplete.localSuffixes&quot;
1201          *      - possible values:   { &quot;&lt;suffix&gt;[,&lt;suffix&gt;]*&quot; } where &lt;suffix&gt; is a String without any wild-card 
1202          *      - default:           &quot;&quot;
1203          *  
1204          *   CODEASSIST / Define the Suffixes for Argument Name
1205          *     When the suffixes is non empty, completion for argument name will end with
1206          *     one of the proposed suffixes.
1207          *      - option id:         &quot;org.phpeclipse.phpdt.core.codeComplete.argumentSuffixes&quot;
1208          *      - possible values:   { &quot;&lt;suffix&gt;[,&lt;suffix&gt;]*&quot; } where &lt;prefix&gt; is a String without any wild-card 
1209          *      - default:           &quot;&quot;
1210          *  &lt;/pre&gt;
1211          *  
1212          *  @return a mutable table containing the default settings of all known options
1213          *    (key type: 
1214          * <code>
1215          * String
1216          * </code>
1217          * ; value type: 
1218          * <code>
1219          * String
1220          * </code>
1221          * )
1222          *  @see #setOptions
1223          * 
1224          */
1225         //  public static Hashtable getDefaultOptions() {
1226         //
1227         //    Hashtable defaultOptions = new Hashtable(10);
1228         //
1229         //    // see #initializeDefaultPluginPreferences() for changing default
1230         // settings
1231         //    Preferences preferences = getPlugin().getPluginPreferences();
1232         //    HashSet optionNames = OptionNames;
1233         //
1234         //    // get preferences set to their default
1235         //    String[] defaultPropertyNames = preferences.defaultPropertyNames();
1236         //    for (int i = 0; i < defaultPropertyNames.length; i++) {
1237         //      String propertyName = defaultPropertyNames[i];
1238         //      if (optionNames.contains(propertyName)) {
1239         //        defaultOptions.put(propertyName,
1240         // preferences.getDefaultString(propertyName));
1241         //      }
1242         //    }
1243         //    // get preferences not set to their default
1244         //    String[] propertyNames = preferences.propertyNames();
1245         //    for (int i = 0; i < propertyNames.length; i++) {
1246         //      String propertyName = propertyNames[i];
1247         //      if (optionNames.contains(propertyName)) {
1248         //        defaultOptions.put(propertyName,
1249         // preferences.getDefaultString(propertyName));
1250         //      }
1251         //    }
1252         //    // get encoding through resource plugin
1253         //    defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1254         //
1255         //    return defaultOptions;
1256         //  }
1257         /**
1258          * Helper method for returning one option value only. Equivalent to
1259          * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
1260          * may answer <code>null</code> if this option does not exist.
1261          * <p>
1262          * For a complete description of the configurable options, see
1263          * <code>getDefaultOptions</code>.
1264          * </p>
1265          * 
1266          * @param optionName
1267          *            the name of an option
1268          * @return the String value of a given option
1269          * @see JavaCore#getDefaultOptions
1270          * @since 2.0
1271          */
1272         //  public static String getOption(String optionName) {
1273         //
1274         //    if (CORE_ENCODING.equals(optionName)) {
1275         //      return ResourcesPlugin.getEncoding();
1276         //    }
1277         //    if (OptionNames.contains(optionName)) {
1278         //      Preferences preferences = getPlugin().getPluginPreferences();
1279         //      return preferences.getString(optionName).trim();
1280         //    }
1281         //    return null;
1282         //  }
1283         /**
1284          * Returns the table of the current options. Initially, all options have
1285          * their default values, and this method returns a table that includes all
1286          * known options.
1287          * <p>
1288          * For a complete description of the configurable options, see
1289          * <code>getDefaultOptions</code>.
1290          * </p>
1291          * 
1292          * @return table of current settings of all options (key type:
1293          *         <code>String</code>; value type: <code>String</code>)
1294          * @see JavaCore#getDefaultOptions
1295          */
1296         //  public static Hashtable getOptions() {
1297         //
1298         //    Hashtable options = new Hashtable(10);
1299         //
1300         //    // see #initializeDefaultPluginPreferences() for changing default
1301         // settings
1302         //    Plugin plugin = getPlugin();
1303         //    if (plugin != null) {
1304         //      Preferences preferences = getPlugin().getPluginPreferences();
1305         //      HashSet optionNames = OptionNames;
1306         //
1307         //      // get preferences set to their default
1308         //      String[] defaultPropertyNames = preferences.defaultPropertyNames();
1309         //      for (int i = 0; i < defaultPropertyNames.length; i++) {
1310         //        String propertyName = defaultPropertyNames[i];
1311         //        if (optionNames.contains(propertyName)) {
1312         //          options.put(propertyName, preferences.getDefaultString(propertyName));
1313         //        }
1314         //      }
1315         //      // get preferences not set to their default
1316         //      String[] propertyNames = preferences.propertyNames();
1317         //      for (int i = 0; i < propertyNames.length; i++) {
1318         //        String propertyName = propertyNames[i];
1319         //        if (optionNames.contains(propertyName)) {
1320         //          options.put(propertyName, preferences.getString(propertyName).trim());
1321         //        }
1322         //      }
1323         //      // get encoding through resource plugin
1324         //      options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1325         //    }
1326         //    return options;
1327         //  }
1328         /**
1329          * Sets the current table of options. All and only the options explicitly
1330          * included in the given table are remembered; all previous option settings
1331          * are forgotten, including ones not explicitly mentioned.
1332          * <p>
1333          * For a complete description of the configurable options, see
1334          * <code>getDefaultOptions</code>.
1335          * </p>
1336          * 
1337          * @param newOptions
1338          *            the new options (key type: <code>String</code>; value type:
1339          *            <code>String</code>), or <code>null</code> to reset all
1340          *            options to their default values
1341          * @see JavaCore#getDefaultOptions
1342          */
1343         //  public static void setOptions(Hashtable newOptions) {
1344         //
1345         //    // see #initializeDefaultPluginPreferences() for changing default
1346         // settings
1347         //    Preferences preferences = getPlugin().getPluginPreferences();
1348         //
1349         //    if (newOptions == null) {
1350         //      newOptions = getDefaultOptions();
1351         //    }
1352         //    Enumeration keys = newOptions.keys();
1353         //    while (keys.hasMoreElements()) {
1354         //      String key = (String) keys.nextElement();
1355         //      if (!OptionNames.contains(key))
1356         //        continue; // unrecognized option
1357         //      if (key.equals(CORE_ENCODING))
1358         //        continue; // skipped, contributed by resource prefs
1359         //      String value = (String) newOptions.get(key);
1360         //      preferences.setValue(key, value);
1361         //    }
1362         //
1363         //    // persist options
1364         //    getPlugin().savePluginPreferences();
1365         //  }
1366         public static IProject[] getPHPProjects() {
1367                 List phpProjectsList = new ArrayList();
1368                 IProject[] workspaceProjects = PHPeclipsePlugin.getWorkspace()
1369                                 .getRoot().getProjects();
1370
1371                 for (int i = 0; i < workspaceProjects.length; i++) {
1372                         IProject iProject = workspaceProjects[i];
1373                         if (isPHPProject(iProject))
1374                                 phpProjectsList.add(iProject);
1375                 }
1376
1377                 IProject[] phpProjects = new IProject[phpProjectsList.size()];
1378                 return (IProject[]) phpProjectsList.toArray(phpProjects);
1379         }
1380
1381         //  public static PHPProject getPHPProject(String name) {
1382         //    IProject aProject =
1383         // PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
1384         //    if (isPHPProject(aProject)) {
1385         //      PHPProject thePHPProject = new PHPProject();
1386         //      thePHPProject.setProject(aProject);
1387         //      return thePHPProject;
1388         //    }
1389         //    return null;
1390         //  }
1391
1392         public static boolean isPHPProject(IProject aProject) {
1393                 try {
1394                         return aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID);
1395                 } catch (CoreException e) {
1396                 }
1397
1398                 return false;
1399         }
1400
1401         //  public static PHPFile create(IFile aFile) {
1402         //    if (PHPFile.EXTENSION.equalsIgnoreCase(aFile.getFileExtension()))
1403         //      return new PHPFile(aFile);
1404         //    if (PHPFile.EXTENSION1.equalsIgnoreCase(aFile.getFileExtension()))
1405         //      return new PHPFile(aFile);
1406         //    if (PHPFile.EXTENSION2.equalsIgnoreCase(aFile.getFileExtension()))
1407         //      return new PHPFile(aFile);
1408         //    if (PHPFile.EXTENSION3.equalsIgnoreCase(aFile.getFileExtension()))
1409         //      return new PHPFile(aFile);
1410         //    if (PHPFile.EXTENSION4.equalsIgnoreCase(aFile.getFileExtension()))
1411         //      return new PHPFile(aFile);
1412         //    if (PHPFile.EXTENSION5.equalsIgnoreCase(aFile.getFileExtension()))
1413         //      return new PHPFile(aFile);
1414         //
1415         //    return null;
1416         //  }
1417
1418         //  public static PHPProject create(IProject aProject) {
1419         //      
1420         //    try {
1421         //      if (aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1422         //        PHPProject project = new PHPProject();
1423         //        project.setProject(aProject);
1424         //        return project;
1425         //      }
1426         //    } catch (CoreException e) {
1427         //      System.err.println("Exception occurred in PHPCore#create(IProject): " +
1428         // e.toString());
1429         //    }
1430         //
1431         //    return null;
1432         //  }
1433
1434         public static void addPHPNature(IProject project, IProgressMonitor monitor)
1435                         throws CoreException {
1436                 if (!project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
1437                         IProjectDescription description = project.getDescription();
1438                         String[] prevNatures = description.getNatureIds();
1439                         String[] newNatures = new String[prevNatures.length + 1];
1440                         System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
1441                         newNatures[prevNatures.length] = PHPeclipsePlugin.PHP_NATURE_ID;
1442                         description.setNatureIds(newNatures);
1443                         project.setDescription(description, monitor);
1444                 }
1445         }
1446
1447         /**
1448          * Returns the single instance of the PHP core plug-in runtime class.
1449          * 
1450          * @return the single instance of the PHP core plug-in runtime class
1451          */
1452         public static Plugin getPlugin() {
1453                 return PHPeclipsePlugin.getDefault();
1454         }
1455
1456         /**
1457          * Runs the given action as an atomic Java model operation.
1458          * <p>
1459          * After running a method that modifies java elements, registered listeners
1460          * receive after-the-fact notification of what just transpired, in the form
1461          * of a element changed event. This method allows clients to call a number
1462          * of methods that modify java elements and only have element changed event
1463          * notifications reported at the end of the entire batch.
1464          * </p>
1465          * <p>
1466          * If this method is called outside the dynamic scope of another such call,
1467          * this method runs the action and then reports a single element changed
1468          * event describing the net effect of all changes done to java elements by
1469          * the action.
1470          * </p>
1471          * <p>
1472          * If this method is called in the dynamic scope of another such call, this
1473          * method simply runs the action.
1474          * </p>
1475          * 
1476          * @param action
1477          *            the action to perform
1478          * @param monitor
1479          *            a progress monitor, or <code>null</code> if progress
1480          *            reporting and cancellation are not desired
1481          * @exception CoreException
1482          *                if the operation failed.
1483          * @since 2.1
1484          */
1485         //      public static void run(IWorkspaceRunnable action, IProgressMonitor
1486         // monitor) throws CoreException {
1487         //              run(action, ResourcesPlugin.getWorkspace().getRoot(), monitor);
1488         //      }
1489         /**
1490          * Runs the given action as an atomic Java model operation.
1491          * <p>
1492          * After running a method that modifies java elements, registered listeners
1493          * receive after-the-fact notification of what just transpired, in the form
1494          * of a element changed event. This method allows clients to call a number
1495          * of methods that modify java elements and only have element changed event
1496          * notifications reported at the end of the entire batch.
1497          * </p>
1498          * <p>
1499          * If this method is called outside the dynamic scope of another such call,
1500          * this method runs the action and then reports a single element changed
1501          * event describing the net effect of all changes done to java elements by
1502          * the action.
1503          * </p>
1504          * <p>
1505          * If this method is called in the dynamic scope of another such call, this
1506          * method simply runs the action.
1507          * </p>
1508          * <p>
1509          * The supplied scheduling rule is used to determine whether this operation
1510          * can be run simultaneously with workspace changes in other threads. See
1511          * <code>IWorkspace.run(...)</code> for more details.
1512          * </p>
1513          * 
1514          * @param action
1515          *            the action to perform
1516          * @param rule
1517          *            the scheduling rule to use when running this operation, or
1518          *            <code>null</code> if there are no scheduling restrictions
1519          *            for this operation.
1520          * @param monitor
1521          *            a progress monitor, or <code>null</code> if progress
1522          *            reporting and cancellation are not desired
1523          * @exception CoreException
1524          *                if the operation failed.
1525          * @since 3.0
1526          */
1527         //      public static void run(IWorkspaceRunnable action, ISchedulingRule rule,
1528         // IProgressMonitor monitor) throws CoreException {
1529         //              IWorkspace workspace = ResourcesPlugin.getWorkspace();
1530         //              if (workspace.isTreeLocked()) {
1531         //                      new BatchOperation(action).run(monitor);
1532         //              } else {
1533         //                      // use IWorkspace.run(...) to ensure that a build will be done in
1534         // autobuild mode
1535         //                      workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE,
1536         // monitor);
1537         //              }
1538         //      }
1539
1540         /**
1541          * Adds the given listener for changes to Java elements. Has no effect if an
1542          * identical listener is already registered.
1543          * 
1544          * This listener will only be notified during the POST_CHANGE resource
1545          * change notification and any reconcile operation (POST_RECONCILE). For
1546          * finer control of the notification, use
1547          * <code>addElementChangedListener(IElementChangedListener,int)</code>,
1548          * which allows to specify a different eventMask.
1549          * 
1550          * @see ElementChangedEvent
1551          * @param listener
1552          *            the listener
1553          */
1554         public static void addElementChangedListener(
1555                         IElementChangedListener listener) {
1556                 addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE
1557                                 | ElementChangedEvent.POST_RECONCILE);
1558         }
1559
1560         /**
1561          * Adds the given listener for changes to Java elements. Has no effect if an
1562          * identical listener is already registered. After completion of this
1563          * method, the given listener will be registered for exactly the specified
1564          * events. If they were previously registered for other events, they will be
1565          * deregistered.
1566          * <p>
1567          * Once registered, a listener starts receiving notification of changes to
1568          * java elements in the model. The listener continues to receive
1569          * notifications until it is replaced or removed.
1570          * </p>
1571          * <p>
1572          * Listeners can listen for several types of event as defined in
1573          * <code>ElementChangeEvent</code>. Clients are free to register for any
1574          * number of event types however if they register for more than one, it is
1575          * their responsibility to ensure they correctly handle the case where the
1576          * same java element change shows up in multiple notifications. Clients are
1577          * guaranteed to receive only the events for which they are registered.
1578          * </p>
1579          * 
1580          * @param listener
1581          *            the listener
1582          * @param eventMask
1583          *            the bit-wise OR of all event types of interest to the listener
1584          * @see IElementChangedListener
1585          * @see ElementChangedEvent
1586          * @see #removeElementChangedListener(IElementChangedListener)
1587          * @since 2.0
1588          */
1589         public static void addElementChangedListener(
1590                         IElementChangedListener listener, int eventMask) {
1591                 JavaModelManager.getJavaModelManager().addElementChangedListener(
1592                                 listener, eventMask);
1593         }
1594
1595         /**
1596          * Configures the given marker attribute map for the given Java element.
1597          * Used for markers, which denote a Java element rather than a resource.
1598          * 
1599          * @param attributes
1600          *            the mutable marker attribute map (key type:
1601          *            <code>String</code>, value type: <code>String</code>)
1602          * @param element
1603          *            the Java element for which the marker needs to be configured
1604          */
1605         public static void addJavaElementMarkerAttributes(Map attributes,
1606                         IJavaElement element) {
1607                 //      if (element instanceof IMember)
1608                 //              element = ((IMember) element).getClassFile();
1609                 if (attributes != null && element != null)
1610                         attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier());
1611         }
1612
1613         /**
1614          * Adds the given listener for POST_CHANGE resource change events to the Java core. 
1615          * The listener is guarantied to be notified of the POST_CHANGE resource change event before
1616          * the Java core starts processing the resource change event itself.
1617          * <p>
1618          * Has no effect if an identical listener is already registered.
1619          * </p>
1620          * 
1621          * @param listener the listener
1622          * @see #removePreProcessingResourceChangedListener(IResourceChangeListener)
1623          * @since 3.0
1624          */
1625         public static void addPreProcessingResourceChangedListener(IResourceChangeListener listener) {
1626                 JavaModelManager.getJavaModelManager().deltaState.addPreResourceChangedListener(listener);
1627         }
1628         /**
1629          * Configures the given marker for the given Java element. Used for markers,
1630          * which denote a Java element rather than a resource.
1631          * 
1632          * @param marker
1633          *            the marker to be configured
1634          * @param element
1635          *            the Java element for which the marker needs to be configured
1636          * @exception CoreException
1637          *                if the <code>IMarker.setAttribute</code> on the marker
1638          *                fails
1639          */
1640         public void configureJavaElementMarker(IMarker marker, IJavaElement element)
1641                         throws CoreException {
1642                 //      if (element instanceof IMember)
1643                 //              element = ((IMember) element).getClassFile();
1644                 if (marker != null && element != null)
1645                         marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier());
1646         }
1647
1648         /**
1649          * Returns the Java model element corresponding to the given handle
1650          * identifier generated by <code>IJavaElement.getHandleIdentifier()</code>,
1651          * or <code>null</code> if unable to create the associated element.
1652          */
1653         public static IJavaElement create(String handleIdentifier) {
1654                 if (handleIdentifier == null) {
1655                         return null;
1656                 }
1657                 try {
1658                         return JavaModelManager.getJavaModelManager().getHandleFromMemento(
1659                                         handleIdentifier);
1660                 } catch (JavaModelException e) {
1661                         return null;
1662                 }
1663         }
1664
1665         /**
1666          * Returns the Java element corresponding to the given file, or
1667          * <code>null</code> if unable to associate the given file with a Java
1668          * element.
1669          * 
1670          * <p>
1671          * The file must be one of:
1672          * <ul>
1673          * <li>a <code>.java</code> file - the element returned is the
1674          * corresponding <code>ICompilationUnit</code></li>
1675          * <li>a <code>.class</code> file - the element returned is the
1676          * corresponding <code>IClassFile</code></li>
1677          * <li>a <code>.jar</code> file - the element returned is the
1678          * corresponding <code>IPackageFragmentRoot</code></li>
1679          * </ul>
1680          * <p>
1681          * Creating a Java element has the side effect of creating and opening all
1682          * of the element's parents if they are not yet open.
1683          * 
1684          * @param the
1685          *            given file
1686          * @return the Java element corresponding to the given file, or
1687          *         <code>null</code> if unable to associate the given file with a
1688          *         Java element
1689          */
1690         public static IJavaElement create(IFile file) {
1691                 return JavaModelManager.create(file, null);
1692         }
1693
1694         /**
1695          * Returns the package fragment or package fragment root corresponding to
1696          * the given folder, or <code>null</code> if unable to associate the given
1697          * folder with a Java element.
1698          * <p>
1699          * Note that a package fragment root is returned rather than a default
1700          * package.
1701          * <p>
1702          * Creating a Java element has the side effect of creating and opening all
1703          * of the element's parents if they are not yet open.
1704          * 
1705          * @param the
1706          *            given folder
1707          * @return the package fragment or package fragment root corresponding to
1708          *         the given folder, or <code>null</code> if unable to associate
1709          *         the given folder with a Java element
1710          */
1711         public static IJavaElement create(IFolder folder) {
1712                 return JavaModelManager.create(folder, null);
1713         }
1714
1715         /**
1716          * Returns the Java project corresponding to the given project.
1717          * <p>
1718          * Creating a Java Project has the side effect of creating and opening all
1719          * of the project's parents if they are not yet open.
1720          * <p>
1721          * Note that no check is done at this time on the existence or the java
1722          * nature of this project.
1723          * 
1724          * @param project
1725          *            the given project
1726          * @return the Java project corresponding to the given project, null if the
1727          *         given project is null
1728          */
1729         public static IJavaProject create(IProject project) {
1730                 if (project == null) {
1731                         return null;
1732                 }
1733                 JavaModel javaModel = JavaModelManager.getJavaModelManager()
1734                                 .getJavaModel();
1735                 return javaModel.getJavaProject(project);
1736         }
1737
1738         /**
1739          * Returns the Java element corresponding to the given resource, or
1740          * <code>null</code> if unable to associate the given resource with a Java
1741          * element.
1742          * <p>
1743          * The resource must be one of:
1744          * <ul>
1745          * <li>a project - the element returned is the corresponding
1746          * <code>IJavaProject</code></li>
1747          * <li>a <code>.java</code> file - the element returned is the
1748          * corresponding <code>ICompilationUnit</code></li>
1749          * <li>a <code>.class</code> file - the element returned is the
1750          * corresponding <code>IClassFile</code></li>
1751          * <li>a <code>.jar</code> file - the element returned is the
1752          * corresponding <code>IPackageFragmentRoot</code></li>
1753          * <li>a folder - the element returned is the corresponding
1754          * <code>IPackageFragmentRoot</code> or <code>IPackageFragment</code>
1755          * </li>
1756          * <li>the workspace root resource - the element returned is the
1757          * <code>IJavaModel</code></li>
1758          * </ul>
1759          * <p>
1760          * Creating a Java element has the side effect of creating and opening all
1761          * of the element's parents if they are not yet open.
1762          * 
1763          * @param resource
1764          *            the given resource
1765          * @return the Java element corresponding to the given resource, or
1766          *         <code>null</code> if unable to associate the given resource
1767          *         with a Java element
1768          */
1769         public static IJavaElement create(IResource resource) {
1770                 return JavaModelManager.create(resource, null);
1771         }
1772
1773         /**
1774          * Returns the Java model.
1775          * 
1776          * @param root
1777          *            the given root
1778          * @return the Java model, or <code>null</code> if the root is null
1779          */
1780         public static IJavaModel create(IWorkspaceRoot root) {
1781                 if (root == null) {
1782                         return null;
1783                 }
1784                 return JavaModelManager.getJavaModelManager().getJavaModel();
1785         }
1786
1787         /**
1788          * Creates and returns a class file element for the given
1789          * <code>.class</code> file. Returns <code>null</code> if unable to
1790          * recognize the class file.
1791          * 
1792          * @param file
1793          *            the given <code>.class</code> file
1794          * @return a class file element for the given <code>.class</code> file, or
1795          *         <code>null</code> if unable to recognize the class file
1796          */
1797         //public static IClassFile createClassFileFrom(IFile file) {
1798         //      return JavaModelManager.createClassFileFrom(file, null);
1799         //}
1800         /**
1801          * Creates and returns a compilation unit element for the given
1802          * <code>.java</code> file. Returns <code>null</code> if unable to
1803          * recognize the compilation unit.
1804          * 
1805          * @param file
1806          *            the given <code>.java</code> file
1807          * @return a compilation unit element for the given <code>.java</code>
1808          *         file, or <code>null</code> if unable to recognize the
1809          *         compilation unit
1810          */
1811         public static ICompilationUnit createCompilationUnitFrom(IFile file) {
1812                 return JavaModelManager.createCompilationUnitFrom(file, null);
1813         }
1814
1815         /**
1816          * Creates and returns a handle for the given JAR file. The Java model
1817          * associated with the JAR's project may be created as a side effect.
1818          * 
1819          * @param file
1820          *            the given JAR file
1821          * @return a handle for the given JAR file, or <code>null</code> if unable
1822          *         to create a JAR package fragment root. (for example, if the JAR
1823          *         file represents a non-Java resource)
1824          */
1825         //public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile
1826         // file) {
1827         //      return JavaModelManager.createJarPackageFragmentRootFrom(file, null);
1828         //}
1829         /**
1830          * Answers the project specific value for a given classpath container. In
1831          * case this container path could not be resolved, then will answer
1832          * <code>null</code>. Both the container path and the project context are
1833          * supposed to be non-null.
1834          * <p>
1835          * The containerPath is a formed by a first ID segment followed with extra
1836          * segments, which can be used as additional hints for resolution. If no
1837          * container was ever recorded for this container path onto this project
1838          * (using <code>setClasspathContainer</code>, then a
1839          * <code>ClasspathContainerInitializer</code> will be activated if any was
1840          * registered for this container ID onto the extension point
1841          * "org.eclipse.jdt.core.classpathContainerInitializer".
1842          * <p>
1843          * There is no assumption that the returned container must answer the exact
1844          * same containerPath when requested
1845          * <code>IClasspathContainer#getPath</code>. Indeed, the containerPath is
1846          * just an indication for resolving it to an actual container object.
1847          * <p>
1848          * Classpath container values are persisted locally to the workspace, but
1849          * are not preserved from a session to another. It is thus highly
1850          * recommended to register a <code>ClasspathContainerInitializer</code>
1851          * for each referenced container (through the extension point
1852          * "org.eclipse.jdt.core.ClasspathContainerInitializer").
1853          * <p>
1854          * 
1855          * @param containerPath
1856          *            the name of the container, which needs to be resolved
1857          * @param project
1858          *            a specific project in which the container is being resolved
1859          * @return the corresponding classpath container or <code>null</code> if
1860          *         unable to find one.
1861          * 
1862          * @exception JavaModelException
1863          *                if an exception occurred while resolving the container, or
1864          *                if the resolved container contains illegal entries
1865          *                (contains CPE_CONTAINER entries or null entries).
1866          * 
1867          * @see ClasspathContainerInitializer
1868          * @see IClasspathContainer
1869          * @see #setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[],
1870          *      IProgressMonitor)
1871          * @since 2.0
1872          */
1873         //public static IClasspathContainer getClasspathContainer(final IPath
1874         // containerPath, final IJavaProject project) throws JavaModelException {
1875         //
1876         //      IClasspathContainer container = JavaModelManager.containerGet(project,
1877         // containerPath);
1878         //      if (container == JavaModelManager.ContainerInitializationInProgress)
1879         // return null; // break cycle
1880         //
1881         //      if (container == null){
1882         //              final ClasspathContainerInitializer initializer =
1883         // JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
1884         //              if (initializer != null){
1885         //                      if (JavaModelManager.CP_RESOLVE_VERBOSE){
1886         //                              System.out.println("CPContainer INIT - triggering initialization of:
1887         // ["+project.getElementName()+"] " + containerPath + " using initializer:
1888         // "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
1889         //                              new Exception("FAKE exception for dumping current CPContainer
1890         // (["+project.getElementName()+"] "+ containerPath+ ")INIT invocation stack
1891         // trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
1892         //                      }
1893         //                      JavaModelManager.containerPut(project, containerPath,
1894         // JavaModelManager.ContainerInitializationInProgress); // avoid
1895         // initialization cycles
1896         //                      boolean ok = false;
1897         //                      try {
1898         //                              // wrap initializer call with Safe runnable in case initializer would be
1899         // causing some grief
1900         //                              Platform.run(new ISafeRunnable() {
1901         //                                      public void handleException(Throwable exception) {
1902         //                                              ProjectPrefUtil.log(exception, "Exception occurred in classpath container
1903         // initializer: "+initializer); //$NON-NLS-1$
1904         //                                      }
1905         //                                      public void run() throws Exception {
1906         //                                              initializer.initialize(containerPath, project);
1907         //                                      }
1908         //                              });
1909         //                                      
1910         //                              // retrieve value (if initialization was successful)
1911         //                              container = JavaModelManager.containerGet(project, containerPath);
1912         //                              if (container == JavaModelManager.ContainerInitializationInProgress)
1913         // return null; // break cycle
1914         //                              ok = true;
1915         //                      } finally {
1916         //                              if (!ok) JavaModelManager.containerPut(project, containerPath, null); //
1917         // flush cache
1918         //                      }
1919         //                      if (JavaModelManager.CP_RESOLVE_VERBOSE){
1920         //                              System.out.print("CPContainer INIT - after resolution:
1921         // ["+project.getElementName()+"] " + containerPath + " --> ");
1922         // //$NON-NLS-2$//$NON-NLS-1$//$NON-NLS-3$
1923         //                              if (container != null){
1924         //                                      System.out.print("container: "+container.getDescription()+" {");
1925         // //$NON-NLS-2$//$NON-NLS-1$
1926         //                                      IClasspathEntry[] entries = container.getClasspathEntries();
1927         //                                      if (entries != null){
1928         //                                              for (int i = 0; i < entries.length; i++){
1929         //                                                      if (i > 0) System.out.println(", ");//$NON-NLS-1$
1930         //                                                      System.out.println(entries[i]);
1931         //                                              }
1932         //                                      }
1933         //                                      System.out.println("}");//$NON-NLS-1$
1934         //                              } else {
1935         //                                      System.out.println("{unbound}");//$NON-NLS-1$
1936         //                              }
1937         //                      }
1938         //              } else {
1939         //                      if (JavaModelManager.CP_RESOLVE_VERBOSE){
1940         //                              System.out.println("CPContainer INIT - no initializer found for:
1941         // "+project.getElementName()+"] " + containerPath); //$NON-NLS-1$
1942         // //$NON-NLS-2$
1943         //                      }
1944         //              }
1945         //      }
1946         //      return container;
1947         //}
1948         /**
1949          * Helper method finding the classpath container initializer registered for
1950          * a given classpath container ID or <code>null</code> if none was found
1951          * while iterating over the contributions to extension point to the
1952          * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
1953          * <p>
1954          * A containerID is the first segment of any container path, used to
1955          * identify the registered container initializer.
1956          * <p>
1957          * 
1958          * @param String -
1959          *            a containerID identifying a registered initializer
1960          * @return ClasspathContainerInitializer - the registered classpath
1961          *         container initializer or <code>null</code> if none was found.
1962          * @since 2.1
1963          */
1964         //public static ClasspathContainerInitializer
1965         // getClasspathContainerInitializer(String containerID){
1966         //              
1967         //      Plugin jdtCorePlugin = JavaCore.getPlugin();
1968         //      if (jdtCorePlugin == null) return null;
1969         //
1970         //      IExtensionPoint extension =
1971         // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID);
1972         //      if (extension != null) {
1973         //              IExtension[] extensions = extension.getExtensions();
1974         //              for(int i = 0; i < extensions.length; i++){
1975         //                      IConfigurationElement [] configElements =
1976         // extensions[i].getConfigurationElements();
1977         //                      for(int j = 0; j < configElements.length; j++){
1978         //                              String initializerID = configElements[j].getAttribute("id");
1979         // //$NON-NLS-1$
1980         //                              if (initializerID != null && initializerID.equals(containerID)){
1981         //                                      if (JavaModelManager.CP_RESOLVE_VERBOSE) {
1982         //                                              System.out.println("CPContainer INIT - found initializer: "+containerID
1983         // +" --> " +
1984         // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
1985         //                                      }
1986         //                                      try {
1987         //                                              Object execExt = configElements[j].createExecutableExtension("class");
1988         // //$NON-NLS-1$
1989         //                                              if (execExt instanceof ClasspathContainerInitializer){
1990         //                                                      return (ClasspathContainerInitializer)execExt;
1991         //                                              }
1992         //                                      } catch(CoreException e) {
1993         //                                      }
1994         //                              }
1995         //                      }
1996         //              }
1997         //      }
1998         //      return null;
1999         //}
2000         /**
2001          * Returns the path held in the given classpath variable. Returns <node>null
2002          * </code> if unable to bind.
2003          * <p>
2004          * Classpath variable values are persisted locally to the workspace, and are
2005          * preserved from session to session.
2006          * <p>
2007          * Note that classpath variables can be contributed registered initializers
2008          * for, using the extension point
2009          * "org.eclipse.jdt.core.classpathVariableInitializer". If an initializer is
2010          * registered for a variable, its persisted value will be ignored: its
2011          * initializer will thus get the opportunity to rebind the variable
2012          * differently on each session.
2013          * 
2014          * @param variableName
2015          *            the name of the classpath variable
2016          * @return the path, or <code>null</code> if none
2017          * @see #setClasspathVariable
2018          */
2019         public static IPath getClasspathVariable(final String variableName) {
2020
2021                 IPath variablePath = JavaModelManager.variableGet(variableName);
2022                 if (variablePath == JavaModelManager.VariableInitializationInProgress)
2023                         return null; // break cycle
2024
2025                 if (variablePath != null) {
2026                         return variablePath;
2027                 }
2028
2029                 // even if persisted value exists, initializer is given priority, only
2030                 // if no initializer is found the persisted value is reused
2031                 //      final ClasspathVariableInitializer initializer =
2032                 // PHPCore.getClasspathVariableInitializer(variableName);
2033                 //      if (initializer != null){
2034                 //              if (JavaModelManager.CP_RESOLVE_VERBOSE){
2035                 //                      System.out.println("CPVariable INIT - triggering initialization of: "
2036                 // + variableName+ " using initializer: "+ initializer); //$NON-NLS-1$
2037                 // //$NON-NLS-2$
2038                 //                      new Exception("FAKE exception for dumping current CPVariable
2039                 // ("+variableName+ ")INIT invocation stack trace").printStackTrace();
2040                 // //$NON-NLS-1$//$NON-NLS-2$
2041                 //              }
2042                 //              JavaModelManager.variablePut(variableName,
2043                 // JavaModelManager.VariableInitializationInProgress); // avoid
2044                 // initialization cycles
2045                 //              boolean ok = false;
2046                 //              try {
2047                 //                      // wrap initializer call with Safe runnable in case initializer would
2048                 // be causing some grief
2049                 //                      Platform.run(new ISafeRunnable() {
2050                 //                              public void handleException(Throwable exception) {
2051                 //                                      ProjectPrefUtil.log(exception, "Exception occurred in classpath variable
2052                 // initializer: "+initializer+" while initializing variable:
2053                 // "+variableName); //$NON-NLS-1$ //$NON-NLS-2$
2054                 //                              }
2055                 //                              public void run() throws Exception {
2056                 //                                      initializer.initialize(variableName);
2057                 //                              }
2058                 //                      });
2059                 //                      variablePath = (IPath) JavaModelManager.variableGet(variableName); //
2060                 // initializer should have performed side-effect
2061                 //                      if (variablePath ==
2062                 // JavaModelManager.VariableInitializationInProgress) return null; //
2063                 // break cycle (initializer did not init or reentering call)
2064                 //                      if (JavaModelManager.CP_RESOLVE_VERBOSE){
2065                 //                              System.out.println("CPVariable INIT - after initialization: " +
2066                 // variableName + " --> " + variablePath); //$NON-NLS-2$//$NON-NLS-1$
2067                 //                      }
2068                 //                      ok = true;
2069                 //              } finally {
2070                 //                      if (!ok) JavaModelManager.variablePut(variableName, null); // flush
2071                 // cache
2072                 //              }
2073                 //      } else {
2074                 //              if (JavaModelManager.CP_RESOLVE_VERBOSE){
2075                 //                      System.out.println("CPVariable INIT - no initializer found for: " +
2076                 // variableName); //$NON-NLS-1$
2077                 //              }
2078                 //      }
2079                 return variablePath;
2080         }
2081
2082         /**
2083          * Helper method finding the classpath variable initializer registered for a
2084          * given classpath variable name or <code>null</code> if none was found
2085          * while iterating over the contributions to extension point to the
2086          * extension point "org.eclipse.jdt.core.classpathVariableInitializer".
2087          * <p>
2088          * 
2089          * @param the
2090          *            given variable
2091          * @return ClasspathVariableInitializer - the registered classpath variable
2092          *         initializer or <code>null</code> if none was found.
2093          * @since 2.1
2094          */
2095         public static ClasspathVariableInitializer getClasspathVariableInitializer(
2096                         String variable) {
2097
2098                 Plugin jdtCorePlugin = JavaCore.getPlugin();
2099                 if (jdtCorePlugin == null)
2100                         return null;
2101
2102                 //      IExtensionPoint extension =
2103                 // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID);
2104                 //      if (extension != null) {
2105                 //              IExtension[] extensions = extension.getExtensions();
2106                 //              for(int i = 0; i < extensions.length; i++){
2107                 //                      IConfigurationElement [] configElements =
2108                 // extensions[i].getConfigurationElements();
2109                 //                      for(int j = 0; j < configElements.length; j++){
2110                 //                              try {
2111                 //                                      String varAttribute = configElements[j].getAttribute("variable");
2112                 // //$NON-NLS-1$
2113                 //                                      if (variable.equals(varAttribute)) {
2114                 //                                              if (JavaModelManager.CP_RESOLVE_VERBOSE) {
2115                 //                                                      System.out.println("CPVariable INIT - found initializer: "+variable+"
2116                 // --> " +
2117                 // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
2118                 //                                              }
2119                 //                                              Object execExt =
2120                 // configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
2121                 //                                              if (execExt instanceof ClasspathVariableInitializer){
2122                 //                                                      return (ClasspathVariableInitializer)execExt;
2123                 //                                              }
2124                 //                                      }
2125                 //                              } catch(CoreException e){
2126                 //                              }
2127                 //                              }
2128                 //              }
2129                 //      }
2130                 return null;
2131         }
2132
2133         /**
2134          * Returns the names of all known classpath variables.
2135          * <p>
2136          * Classpath variable values are persisted locally to the workspace, and are
2137          * preserved from session to session.
2138          * <p>
2139          * 
2140          * @return the list of classpath variable names
2141          * @see #setClasspathVariable
2142          */
2143         //public static String[] getClasspathVariableNames() {
2144         //      return JavaModelManager.variableNames();
2145         //}
2146         /**
2147          * Returns a table of all known configurable options with their default
2148          * values. These options allow to configure the behaviour of the underlying
2149          * components. The client may safely use the result as a template that they
2150          * can modify and then pass to <code>setOptions</code>.
2151          * 
2152          * Helper constants have been defined on JavaCore for each of the option ID
2153          * and their possible constant values.
2154          * 
2155          * Note: more options might be added in further releases.
2156          * 
2157          * <pre>
2158          * 
2159          *  RECOGNIZED OPTIONS:
2160          *  COMPILER / Generating Local Variable Debug Attribute
2161          *     When generated, this attribute will enable local variable names 
2162          *     to be displayed in debugger, only in place where variables are 
2163          *     definitely assigned (.class file is then bigger)
2164          *      - option id:         &quot;org.eclipse.jdt.core.compiler.debug.localVariable&quot;
2165          *      - possible values:   { &quot;generate&quot;, &quot;do not generate&quot; }
2166          *      - default:           &quot;generate&quot;
2167          * 
2168          *  COMPILER / Generating Line Number Debug Attribute 
2169          *     When generated, this attribute will enable source code highlighting in debugger 
2170          *     (.class file is then bigger).
2171          *      - option id:         &quot;org.eclipse.jdt.core.compiler.debug.lineNumber&quot;
2172          *      - possible values:   { &quot;generate&quot;, &quot;do not generate&quot; }
2173          *      - default:           &quot;generate&quot;
2174          *     
2175          *  COMPILER / Generating Source Debug Attribute 
2176          *     When generated, this attribute will enable the debugger to present the 
2177          *     corresponding source code.
2178          *      - option id:         &quot;org.eclipse.jdt.core.compiler.debug.sourceFile&quot;
2179          *      - possible values:   { &quot;generate&quot;, &quot;do not generate&quot; }
2180          *      - default:           &quot;generate&quot;
2181          *     
2182          *  COMPILER / Preserving Unused Local Variables
2183          *     Unless requested to preserve unused local variables (that is, never read), the 
2184          *     compiler will optimize them out, potentially altering debugging
2185          *      - option id:         &quot;org.eclipse.jdt.core.compiler.codegen.unusedLocal&quot;
2186          *      - possible values:   { &quot;preserve&quot;, &quot;optimize out&quot; }
2187          *      - default:           &quot;preserve&quot;
2188          *  
2189          *  COMPILER / Defining Target Java Platform
2190          *     For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
2191          *     Note that &quot;1.4&quot; target require to toggle compliance mode to &quot;1.4&quot; too.
2192          *      - option id:         &quot;org.eclipse.jdt.core.compiler.codegen.targetPlatform&quot;
2193          *      - possible values:   { &quot;1.1&quot;, &quot;1.2&quot;, &quot;1.3&quot;, &quot;1.4&quot; }
2194          *      - default:           &quot;1.1&quot;
2195          * 
2196          *  COMPILER / Reporting Unreachable Code
2197          *     Unreachable code can optionally be reported as an error, warning or simply 
2198          *     ignored. The bytecode generation will always optimized it out.
2199          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.unreachableCode&quot;
2200          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
2201          *      - default:           &quot;error&quot;
2202          * 
2203          *  COMPILER / Reporting Invalid Import
2204          *     An import statement that cannot be resolved might optionally be reported 
2205          *     as an error, as a warning or ignored.
2206          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.invalidImport&quot;
2207          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
2208          *      - default:           &quot;error&quot;
2209          * 
2210          *  COMPILER / Reporting Attempt to Override Package-Default Method
2211          *     A package default method is not visible in a different package, and thus 
2212          *     cannot be overridden. When enabling this option, the compiler will signal 
2213          *     such scenarii either as an error or a warning.
2214          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod&quot;
2215          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
2216          *      - default:           &quot;warning&quot;
2217          * 
2218          *  COMPILER / Reporting Method With Constructor Name
2219          *     Naming a method with a constructor name is generally considered poor 
2220          *     style programming. When enabling this option, the compiler will signal such 
2221          *     scenarii either as an error or a warning.
2222          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.methodWithConstructorName&quot;
2223          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
2224          *      - default:           &quot;warning&quot;
2225          * 
2226          *  COMPILER / Reporting Deprecation
2227          *     When enabled, the compiler will signal use of deprecated API either as an 
2228          *     error or a warning.
2229          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.deprecation&quot;
2230          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
2231          *      - default:           &quot;warning&quot;
2232          * 
2233          *  COMPILER / Reporting Deprecation Inside Deprecated Code
2234          *     When enabled, the compiler will signal use of deprecated API inside deprecated code.
2235          *     The severity of the problem is controlled with option &quot;org.eclipse.jdt.core.compiler.problem.deprecation&quot;.
2236          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode&quot;
2237          *      - possible values:   { &quot;enabled&quot;, &quot;disabled&quot; }
2238          *      - default:           &quot;disabled&quot;
2239          * 
2240          *  COMPILER / Reporting Hidden Catch Block
2241          *     Locally to a try statement, some catch blocks may hide others . For example,
2242          *       try {  throw new java.io.CharConversionException();
2243          *       } catch (java.io.CharConversionException e) {
2244          *       } catch (java.io.IOException e) {}. 
2245          *     When enabling this option, the compiler will issue an error or a warning for hidden 
2246          *     catch blocks corresponding to checked exceptions
2247          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock&quot;
2248          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
2249          *      - default:           &quot;warning&quot;
2250          * 
2251          *  COMPILER / Reporting Unused Local
2252          *     When enabled, the compiler will issue an error or a warning for unused local 
2253          *     variables (that is, variables never read from)
2254          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.unusedLocal&quot;
2255          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
2256          *      - default:           &quot;ignore&quot;
2257          * 
2258          *  COMPILER / Reporting Unused Parameter
2259          *     When enabled, the compiler will issue an error or a warning for unused method 
2260          *     parameters (that is, parameters never read from)
2261          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.unusedParameter&quot;
2262          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
2263          *      - default:           &quot;ignore&quot;
2264          * 
2265          *  COMPILER / Reporting Unused Parameter if Implementing Abstract Method
2266          *     When enabled, the compiler will signal unused parameters in abstract method implementations.
2267          *     The severity of the problem is controlled with option &quot;org.eclipse.jdt.core.compiler.problem.unusedParameter&quot;.
2268          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract&quot;
2269          *      - possible values:   { &quot;enabled&quot;, &quot;disabled&quot; }
2270          *      - default:           &quot;disabled&quot;
2271          * 
2272          *  COMPILER / Reporting Unused Parameter if Overriding Concrete Method
2273          *     When enabled, the compiler will signal unused parameters in methods overriding concrete ones.
2274          *     The severity of the problem is controlled with option &quot;org.eclipse.jdt.core.compiler.problem.unusedParameter&quot;.
2275          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete&quot;
2276          *      - possible values:   { &quot;enabled&quot;, &quot;disabled&quot; }
2277          *      - default:           &quot;disabled&quot;
2278          * 
2279          *  COMPILER / Reporting Unused Import
2280          *     When enabled, the compiler will issue an error or a warning for unused import 
2281          *     reference 
2282          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.unusedImport&quot;
2283          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
2284          *      - default:           &quot;warning&quot;
2285          * 
2286          *  COMPILER / Reporting Unused Private Members
2287          *     When enabled, the compiler will issue an error or a warning whenever a private 
2288          *     method or field is declared but never used within the same unit.
2289          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.unusedPrivateMember&quot;
2290          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
2291          *      - default:           &quot;ignore&quot;
2292          * 
2293          *  COMPILER / Reporting Synthetic Access Emulation
2294          *     When enabled, the compiler will issue an error or a warning whenever it emulates 
2295          *     access to a non-accessible member of an enclosing type. Such access can have
2296          *     performance implications.
2297          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation&quot;
2298          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
2299          *      - default:           &quot;ignore&quot;
2300          * 
2301          *  COMPILER / Reporting Non-Externalized String Literal
2302          *     When enabled, the compiler will issue an error or a warning for non externalized 
2303          *     String literal (that is, not tagged with //$NON-NLS-&lt;n&gt;$). 
2304          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral&quot;
2305          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
2306          *      - default:           &quot;ignore&quot;
2307          *  
2308          *  COMPILER / Reporting Usage of 'assert' Identifier
2309          *     When enabled, the compiler will issue an error or a warning whenever 'assert' is 
2310          *     used as an identifier (reserved keyword in 1.4)
2311          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.assertIdentifier&quot;
2312          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
2313          *      - default:           &quot;ignore&quot;
2314          *  
2315          *  COMPILER / Reporting Non-Static Reference to a Static Member
2316          *     When enabled, the compiler will issue an error or a warning whenever a static field
2317          *     or method is accessed with an expression receiver. A reference to a static member should
2318          *     be qualified with a type name.
2319          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.staticAccessReceiver&quot;
2320          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
2321          *      - default:           &quot;warning&quot;
2322          *  
2323          *  COMPILER / Reporting Assignment with no Effect
2324          *     When enabled, the compiler will issue an error or a warning whenever an assignment
2325          *     has no effect (e.g 'x = x').
2326          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.noEffectAssignment&quot;
2327          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
2328          *      - default:           &quot;warning&quot;
2329          *  
2330          *  COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods
2331          *     When enabled, the compiler will issue an error or a warning whenever an interface
2332          *     defines a method incompatible with a non-inherited Object method. Until this conflict
2333          *     is resolved, such an interface cannot be implemented, For example, 
2334          *       interface I { 
2335          *          int clone();
2336          *       } 
2337          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod&quot;
2338          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
2339          *      - default:           &quot;warning&quot;
2340          *  
2341          *  COMPILER / Reporting Usage of char[] Expressions in String Concatenations
2342          *     When enabled, the compiler will issue an error or a warning whenever a char[] expression
2343          *     is used in String concatenations (for example, &quot;hello&quot; + new char[]{'w','o','r','l','d'}).
2344          *      - option id:         &quot;org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion&quot;
2345          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;, &quot;ignore&quot; }
2346          *      - default:           &quot;warning&quot;
2347          * 
2348          *  COMPILER / Setting Source Compatibility Mode
2349          *     Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
2350          *     reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
2351          *    level should be set to &quot;1.4&quot; and the compliance mode should be &quot;1.4&quot;.
2352          *      - option id:         &quot;org.eclipse.jdt.core.compiler.source&quot;
2353          *      - possible values:   { &quot;1.3&quot;, &quot;1.4&quot; }
2354          *      - default:           &quot;1.3&quot;
2355          *  
2356          *  COMPILER / Setting Compliance Level
2357          *     Select the compliance level for the compiler. In &quot;1.3&quot; mode, source and target settings
2358          *     should not go beyond &quot;1.3&quot; level.
2359          *      - option id:         &quot;org.eclipse.jdt.core.compiler.compliance&quot;
2360          *      - possible values:   { &quot;1.3&quot;, &quot;1.4&quot; }
2361          *      - default:           &quot;1.3&quot;
2362          *  
2363          *  COMPILER / Maximum number of problems reported per compilation unit
2364          *     Specify the maximum number of problems reported on each compilation unit.
2365          *      - option id:         &quot;org.eclipse.jdt.core.compiler.maxProblemPerUnit&quot;
2366          *      - possible values:      &quot;&lt;n&gt;&quot; where &lt;n&gt; is zero or a positive integer (if zero then all problems are reported).
2367          *      - default:           &quot;100&quot;
2368          *  
2369          *  COMPILER / Define the Automatic Task Tags
2370          *     When the tag list is not empty, the compiler will issue a task marker whenever it encounters
2371          *     one of the corresponding tag inside any comment in Java source code.
2372          *     Generated task messages will include the tag, and range until the next line separator or comment ending.
2373          *     Note that tasks messages are trimmed.
2374          *      - option id:         &quot;org.eclipse.jdt.core.compiler.taskTags&quot;
2375          *      - possible values:   { &quot;&lt;tag&gt;[,&lt;tag&gt;]*&quot; } where &lt;tag&gt; is a String without any wild-card or leading/trailing spaces 
2376          *      - default:           &quot;&quot;
2377          *  
2378          *  COMPILER / Define the Automatic Task Priorities
2379          *     In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
2380          *     of the task markers issued by the compiler.
2381          *     If the default is specified, the priority of each task marker is &quot;NORMAL&quot;.
2382          *      - option id:         &quot;org.eclipse.jdt.core.compiler.taskPriorities&quot;
2383          *      - possible values:   { &quot;&lt;priority&gt;[,&lt;priority&gt;]*&quot; } where &lt;priority&gt; is one of &quot;HIGH&quot;, &quot;NORMAL&quot; or &quot;LOW&quot;
2384          *      - default:           &quot;&quot;
2385          * 
2386          *  BUILDER / Specifying Filters for Resource Copying Control
2387          *     Allow to specify some filters to control the resource copy process.
2388          *      - option id:         &quot;org.eclipse.jdt.core.builder.resourceCopyExclusionFilter&quot;
2389          *      - possible values:   { &quot;&lt;name&gt;[,&lt;name&gt;]* } where &lt;name&gt; is a file name pattern (* and ? wild-cards allowed)
2390          *        or the name of a folder which ends with '/'
2391          *      - default:           &quot;&quot;
2392          *  
2393          *  BUILDER / Abort if Invalid Classpath
2394          *     Allow to toggle the builder to abort if the classpath is invalid
2395          *      - option id:         &quot;org.eclipse.jdt.core.builder.invalidClasspath&quot;
2396          *      - possible values:   { &quot;abort&quot;, &quot;ignore&quot; }
2397          *      - default:           &quot;abort&quot;
2398          *  
2399          *  BUILDER / Cleaning Output Folder(s)
2400          *     Indicate whether the JavaBuilder is allowed to clean the output folders
2401          *     when performing full build operations.
2402          *      - option id:         &quot;org.eclipse.jdt.core.builder.cleanOutputFolder&quot;
2403          *      - possible values:   { &quot;clean&quot;, &quot;ignore&quot; }
2404          *      - default:           &quot;clean&quot;
2405          *  
2406          *  BUILDER / Reporting Duplicate Resources
2407          *     Indicate the severity of the problem reported when more than one occurrence
2408          *     of a resource is to be copied into the output location.
2409          *      - option id:         &quot;org.eclipse.jdt.core.builder.duplicateResourceTask&quot;
2410          *      - possible values:   { &quot;error&quot;, &quot;warning&quot; }
2411          *      - default:           &quot;warning&quot;
2412          *  
2413          *  JAVACORE / Computing Project Build Order
2414          *     Indicate whether JavaCore should enforce the project build order to be based on
2415          *     the classpath prerequisite chain. When requesting to compute, this takes over
2416          *     the platform default order (based on project references).
2417          *      - option id:         &quot;org.eclipse.jdt.core.computeJavaBuildOrder&quot;
2418          *      - possible values:   { &quot;compute&quot;, &quot;ignore&quot; }
2419          *      - default:           &quot;ignore&quot;  
2420          *  
2421          *  JAVACORE / Specify Default Source Encoding Format
2422          *     Get the encoding format for compiled sources. This setting is read-only, it is equivalent
2423          *     to 'ResourcesPlugin.getEncoding()'.
2424          *      - option id:         &quot;org.eclipse.jdt.core.encoding&quot;
2425          *      - possible values:   { any of the supported encoding name}.
2426          *      - default:           &lt;platform default&gt;
2427          *  
2428          *  JAVACORE / Reporting Incomplete Classpath
2429          *     Indicate the severity of the problem reported when an entry on the classpath does not exist, 
2430          *     is not legite or is not visible (for example, a referenced project is closed).
2431          *      - option id:         &quot;org.eclipse.jdt.core.incompleteClasspath&quot;
2432          *      - possible values:   { &quot;error&quot;, &quot;warning&quot;}
2433          *      - default:           &quot;error&quot;
2434          *  
2435          *  JAVACORE / Reporting Classpath Cycle
2436          *     Indicate the severity of the problem reported when a project is involved in a cycle.
2437          *      - option id:         &quot;org.eclipse.jdt.core.circularClasspath&quot;
2438          *      - possible values:   { &quot;error&quot;, &quot;warning&quot; }
2439          *      - default:           &quot;error&quot;
2440          *  
2441          *  JAVACORE / Enabling Usage of Classpath Exclusion Patterns
2442          *     When disabled, no entry on a project classpath can be associated with
2443          *     an exclusion pattern.
2444          *      - option id:         &quot;org.eclipse.jdt.core.classpath.exclusionPatterns&quot;
2445          *      - possible values:   { &quot;enabled&quot;, &quot;disabled&quot; }
2446          *      - default:           &quot;enabled&quot;
2447          *  
2448          *  JAVACORE / Enabling Usage of Classpath Multiple Output Locations
2449          *     When disabled, no entry on a project classpath can be associated with
2450          *     a specific output location, preventing thus usage of multiple output locations.
2451          *      - option id:         &quot;org.eclipse.jdt.core.classpath.multipleOutputLocations&quot;
2452          *      - possible values:   { &quot;enabled&quot;, &quot;disabled&quot; }
2453          *      - default:           &quot;enabled&quot;
2454          *  
2455          *      FORMATTER / Inserting New Line Before Opening Brace
2456          *     When Insert, a new line is inserted before an opening brace, otherwise nothing
2457          *     is inserted
2458          *      - option id:         &quot;org.eclipse.jdt.core.formatter.newline.openingBrace&quot;
2459          *      - possible values:   { &quot;insert&quot;, &quot;do not insert&quot; }
2460          *      - default:           &quot;do not insert&quot;
2461          *  
2462          *      FORMATTER / Inserting New Line Inside Control Statement
2463          *     When Insert, a new line is inserted between } and following else, catch, finally
2464          *      - option id:         &quot;org.eclipse.jdt.core.formatter.newline.controlStatement&quot;
2465          *      - possible values:   { &quot;insert&quot;, &quot;do not insert&quot; }
2466          *      - default:           &quot;do not insert&quot;
2467          *  
2468          *      FORMATTER / Clearing Blank Lines
2469          *     When Clear all, all blank lines are removed. When Preserve one, only one is kept
2470          *     and all others removed.
2471          *      - option id:         &quot;org.eclipse.jdt.core.formatter.newline.clearAll&quot;
2472          *      - possible values:   { &quot;clear all&quot;, &quot;preserve one&quot; }
2473          *      - default:           &quot;preserve one&quot;
2474          *  
2475          *      FORMATTER / Inserting New Line Between Else/If 
2476          *     When Insert, a blank line is inserted between an else and an if when they are 
2477          *     contiguous. When choosing to not insert, else-if will be kept on the same
2478          *     line when possible.
2479          *      - option id:         &quot;org.eclipse.jdt.core.formatter.newline.elseIf&quot;
2480          *      - possible values:   { &quot;insert&quot;, &quot;do not insert&quot; }
2481          *      - default:           &quot;do not insert&quot;
2482          *  
2483          *      FORMATTER / Inserting New Line In Empty Block
2484          *     When insert, a line break is inserted between contiguous { and }, if } is not followed
2485          *     by a keyword.
2486          *      - option id:         &quot;org.eclipse.jdt.core.formatter.newline.emptyBlock&quot;
2487          *      - possible values:   { &quot;insert&quot;, &quot;do not insert&quot; }
2488          *      - default:           &quot;insert&quot;
2489          *  
2490          *      FORMATTER / Splitting Lines Exceeding Length
2491          *     Enable splitting of long lines (exceeding the configurable length). Length of 0 will
2492          *     disable line splitting
2493          *      - option id:         &quot;org.eclipse.jdt.core.formatter.lineSplit&quot;
2494          *      - possible values:      &quot;&lt;n&gt;&quot;, where n is zero or a positive integer
2495          *      - default:           &quot;80&quot;
2496          *  
2497          *      FORMATTER / Compacting Assignment
2498          *     Assignments can be formatted asymmetrically, for example 'int x= 2;', when Normal, a space
2499          *     is inserted before the assignment operator
2500          *      - option id:         &quot;org.eclipse.jdt.core.formatter.style.assignment&quot;
2501          *      - possible values:   { &quot;compact&quot;, &quot;normal&quot; }
2502          *      - default:           &quot;normal&quot;
2503          *  
2504          *      FORMATTER / Defining Indentation Character
2505          *     Either choose to indent with tab characters or spaces
2506          *      - option id:         &quot;org.eclipse.jdt.core.formatter.tabulation.char&quot;
2507          *      - possible values:   { &quot;tab&quot;, &quot;space&quot; }
2508          *      - default:           &quot;tab&quot;
2509          *  
2510          *      FORMATTER / Defining Space Indentation Length
2511          *     When using spaces, set the amount of space characters to use for each 
2512          *     indentation mark.
2513          *      - option id:         &quot;org.eclipse.jdt.core.formatter.tabulation.size&quot;
2514          *      - possible values:      &quot;&lt;n&gt;&quot;, where n is a positive integer
2515          *      - default:           &quot;4&quot;
2516          *  
2517          *      FORMATTER / Inserting space in cast expression
2518          *     When Insert, a space is added between the type and the expression in a cast expression.
2519          *      - option id:         &quot;org.eclipse.jdt.core.formatter.space.castexpression&quot;
2520          *      - possible values:   { &quot;insert&quot;, &quot;do not insert&quot; }
2521          *      - default:           &quot;insert&quot;
2522          *  
2523          *      CODEASSIST / Activate Visibility Sensitive Completion
2524          *     When active, completion doesn't show that you can not see
2525          *     (for example, you can not see private methods of a super class).
2526          *      - option id:         &quot;org.eclipse.jdt.core.codeComplete.visibilityCheck&quot;
2527          *      - possible values:   { &quot;enabled&quot;, &quot;disabled&quot; }
2528          *      - default:           &quot;disabled&quot;
2529          *  
2530          *      CODEASSIST / Automatic Qualification of Implicit Members
2531          *     When active, completion automatically qualifies completion on implicit
2532          *     field references and message expressions.
2533          *      - option id:         &quot;org.eclipse.jdt.core.codeComplete.forceImplicitQualification&quot;
2534          *      - possible values:   { &quot;enabled&quot;, &quot;disabled&quot; }
2535          *      - default:           &quot;disabled&quot;
2536          *  
2537          *   CODEASSIST / Define the Prefixes for Field Name
2538          *     When the prefixes is non empty, completion for field name will begin with
2539          *     one of the proposed prefixes.
2540          *      - option id:         &quot;org.eclipse.jdt.core.codeComplete.fieldPrefixes&quot;
2541          *      - possible values:   { &quot;&lt;prefix&gt;[,&lt;prefix&gt;]*&quot; } where &lt;prefix&gt; is a String without any wild-card 
2542          *      - default:           &quot;&quot;
2543          *  
2544          *   CODEASSIST / Define the Prefixes for Static Field Name
2545          *     When the prefixes is non empty, completion for static field name will begin with
2546          *     one of the proposed prefixes.
2547          *      - option id:         &quot;org.eclipse.jdt.core.codeComplete.staticFieldPrefixes&quot;
2548          *      - possible values:   { &quot;&lt;prefix&gt;[,&lt;prefix&gt;]*&quot; } where &lt;prefix&gt; is a String without any wild-card 
2549          *      - default:           &quot;&quot;
2550          *  
2551          *   CODEASSIST / Define the Prefixes for Local Variable Name
2552          *     When the prefixes is non empty, completion for local variable name will begin with
2553          *     one of the proposed prefixes.
2554          *      - option id:         &quot;org.eclipse.jdt.core.codeComplete.localPrefixes&quot;
2555          *      - possible values:   { &quot;&lt;prefix&gt;[,&lt;prefix&gt;]*&quot; } where &lt;prefix&gt; is a String without any wild-card 
2556          *      - default:           &quot;&quot;
2557          *  
2558          *   CODEASSIST / Define the Prefixes for Argument Name
2559          *     When the prefixes is non empty, completion for argument name will begin with
2560          *     one of the proposed prefixes.
2561          *      - option id:         &quot;org.eclipse.jdt.core.codeComplete.argumentPrefixes&quot;
2562          *      - possible values:   { &quot;&lt;prefix&gt;[,&lt;prefix&gt;]*&quot; } where &lt;prefix&gt; is a String without any wild-card 
2563          *      - default:           &quot;&quot;
2564          *  
2565          *   CODEASSIST / Define the Suffixes for Field Name
2566          *     When the suffixes is non empty, completion for field name will end with
2567          *     one of the proposed suffixes.
2568          *      - option id:         &quot;org.eclipse.jdt.core.codeComplete.fieldSuffixes&quot;
2569          *      - possible values:   { &quot;&lt;suffix&gt;[,&lt;suffix&gt;]*&quot; } where &lt;suffix&gt; is a String without any wild-card 
2570          *      - default:           &quot;&quot;
2571          *  
2572          *   CODEASSIST / Define the Suffixes for Static Field Name
2573          *     When the suffixes is non empty, completion for static field name will end with
2574          *     one of the proposed suffixes.
2575          *      - option id:         &quot;org.eclipse.jdt.core.codeComplete.staticFieldSuffixes&quot;
2576          *      - possible values:   { &quot;&lt;suffix&gt;[,&lt;suffix&gt;]*&quot; } where &lt;suffix&gt; is a String without any wild-card 
2577          *      - default:           &quot;&quot;
2578          *  
2579          *   CODEASSIST / Define the Suffixes for Local Variable Name
2580          *     When the suffixes is non empty, completion for local variable name will end with
2581          *     one of the proposed suffixes.
2582          *      - option id:         &quot;org.eclipse.jdt.core.codeComplete.localSuffixes&quot;
2583          *      - possible values:   { &quot;&lt;suffix&gt;[,&lt;suffix&gt;]*&quot; } where &lt;suffix&gt; is a String without any wild-card 
2584          *      - default:           &quot;&quot;
2585          *  
2586          *   CODEASSIST / Define the Suffixes for Argument Name
2587          *     When the suffixes is non empty, completion for argument name will end with
2588          *     one of the proposed suffixes.
2589          *      - option id:         &quot;org.eclipse.jdt.core.codeComplete.argumentSuffixes&quot;
2590          *      - possible values:   { &quot;&lt;suffix&gt;[,&lt;suffix&gt;]*&quot; } where &lt;prefix&gt; is a String without any wild-card 
2591          *      - default:           &quot;&quot;
2592          *  &lt;/pre&gt;
2593          *  
2594          *  @return a mutable table containing the default settings of all known options
2595          *    (key type: 
2596          * <code>
2597          * String
2598          * </code>
2599          * ; value type: 
2600          * <code>
2601          * String
2602          * </code>
2603          * )
2604          *  @see #setOptions
2605          * 
2606          */
2607         public static Hashtable getDefaultOptions() {
2608
2609                 Hashtable defaultOptions = new Hashtable(10);
2610
2611                 // see #initializeDefaultPluginPreferences() for changing default
2612                 // settings
2613                 Preferences preferences = getPlugin().getPluginPreferences();
2614                 HashSet optionNames = JavaModelManager.OptionNames;
2615
2616                 // get preferences set to their default
2617                 String[] defaultPropertyNames = preferences.defaultPropertyNames();
2618                 for (int i = 0; i < defaultPropertyNames.length; i++) {
2619                         String propertyName = defaultPropertyNames[i];
2620                         if (optionNames.contains(propertyName)) {
2621                                 defaultOptions.put(propertyName, preferences
2622                                                 .getDefaultString(propertyName));
2623                         }
2624                 }
2625                 // get preferences not set to their default
2626                 String[] propertyNames = preferences.propertyNames();
2627                 for (int i = 0; i < propertyNames.length; i++) {
2628                         String propertyName = propertyNames[i];
2629                         if (optionNames.contains(propertyName)) {
2630                                 defaultOptions.put(propertyName, preferences
2631                                                 .getDefaultString(propertyName));
2632                         }
2633                 }
2634                 // get encoding through resource plugin
2635                 defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2636
2637                 return defaultOptions;
2638         }
2639
2640         /**
2641          * Returns the single instance of the Java core plug-in runtime class.
2642          * Equivalent to <code>(JavaCore) getPlugin()</code>.
2643          * 
2644          * @return the single instance of the Java core plug-in runtime class
2645          */
2646         public static PHPeclipsePlugin getJavaCore() {
2647                 return (PHPeclipsePlugin) getPlugin();
2648         }
2649
2650         /**
2651          * Helper method for returning one option value only. Equivalent to
2652          * <code>(String)JavaCore.getOptions().get(optionName)</code> Note that it
2653          * may answer <code>null</code> if this option does not exist.
2654          * <p>
2655          * For a complete description of the configurable options, see
2656          * <code>getDefaultOptions</code>.
2657          * </p>
2658          * 
2659          * @param optionName
2660          *            the name of an option
2661          * @return the String value of a given option
2662          * @see JavaCore#getDefaultOptions
2663          * @since 2.0
2664          */
2665         public static String getOption(String optionName) {
2666
2667                 if (CORE_ENCODING.equals(optionName)) {
2668                         return ResourcesPlugin.getEncoding();
2669                 }
2670                 if (JavaModelManager.OptionNames.contains(optionName)) {
2671                         Preferences preferences = getPlugin().getPluginPreferences();
2672                         return preferences.getString(optionName).trim();
2673                 }
2674                 return null;
2675         }
2676
2677         /**
2678          * Returns the table of the current options. Initially, all options have
2679          * their default values, and this method returns a table that includes all
2680          * known options.
2681          * <p>
2682          * For a complete description of the configurable options, see
2683          * <code>getDefaultOptions</code>.
2684          * </p>
2685          * 
2686          * @return table of current settings of all options (key type:
2687          *         <code>String</code>; value type: <code>String</code>)
2688          * @see JavaCore#getDefaultOptions
2689          */
2690         public static Hashtable getOptions() {
2691
2692                 Hashtable options = new Hashtable(10);
2693
2694                 // see #initializeDefaultPluginPreferences() for changing default
2695                 // settings
2696                 Plugin plugin = getPlugin();
2697                 if (plugin != null) {
2698                         Preferences preferences = getPlugin().getPluginPreferences();
2699                         HashSet optionNames = JavaModelManager.OptionNames;
2700
2701                         // get preferences set to their default
2702                         String[] defaultPropertyNames = preferences.defaultPropertyNames();
2703                         for (int i = 0; i < defaultPropertyNames.length; i++) {
2704                                 String propertyName = defaultPropertyNames[i];
2705                                 if (optionNames.contains(propertyName)) {
2706                                         options.put(propertyName, preferences
2707                                                         .getDefaultString(propertyName));
2708                                 }
2709                         }
2710                         // get preferences not set to their default
2711                         String[] propertyNames = preferences.propertyNames();
2712                         for (int i = 0; i < propertyNames.length; i++) {
2713                                 String propertyName = propertyNames[i];
2714                                 if (optionNames.contains(propertyName)) {
2715                                         options.put(propertyName, preferences.getString(
2716                                                         propertyName).trim());
2717                                 }
2718                         }
2719                         // get encoding through resource plugin
2720                         options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
2721                 }
2722                 return options;
2723         }
2724
2725         /**
2726          * This is a helper method, which returns the resolved classpath entry
2727          * denoted by a given entry (if it is a variable entry). It is obtained by
2728          * resolving the variable reference in the first segment. Returns <node>null
2729          * </code> if unable to resolve using the following algorithm:
2730          * <ul>
2731          * <li>if variable segment cannot be resolved, returns <code>null</code>
2732          * </li>
2733          * <li>finds a project, JAR or binary folder in the workspace at the
2734          * resolved path location</li>
2735          * <li>if none finds an external JAR file or folder outside the workspace
2736          * at the resolved path location</li>
2737          * <li>if none returns <code>null</code></li>
2738          * </ul>
2739          * <p>
2740          * Variable source attachment path and root path are also resolved and
2741          * recorded in the resulting classpath entry.
2742          * <p>
2743          * NOTE: This helper method does not handle classpath containers, for which
2744          * should rather be used <code>JavaCore#getClasspathContainer(IPath,
2745          * IJavaProject)</code>.
2746          * <p>
2747          * 
2748          * @param entry
2749          *            the given variable entry
2750          * @return the resolved library or project classpath entry, or <code>null
2751          *         </code> if the given variable entry could not be resolved to a
2752          *         valid classpath entry
2753          */
2754         public static IClasspathEntry getResolvedClasspathEntry(
2755                         IClasspathEntry entry) {
2756
2757                 if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
2758                         return entry;
2759
2760                 IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
2761                 IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath());
2762                 if (resolvedPath == null)
2763                         return null;
2764
2765                 Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false);
2766                 if (target == null)
2767                         return null;
2768
2769                 // inside the workspace
2770                 if (target instanceof IResource) {
2771                         IResource resolvedResource = (IResource) target;
2772                         if (resolvedResource != null) {
2773                                 switch (resolvedResource.getType()) {
2774
2775                                 case IResource.PROJECT:
2776                                         // internal project
2777                                         return JavaCore.newProjectEntry(resolvedPath, entry
2778                                                         .isExported());
2779
2780                                 case IResource.FILE:
2781                                         //                                      if (ProjectPrefUtil.isArchiveFileName(resolvedResource.getName())) {
2782                                         //                                              // internal binary archive
2783                                         //                                              return JavaCore.newLibraryEntry(
2784                                         //                                                              resolvedPath,
2785                                         //                                                              getResolvedVariablePath(entry.getSourceAttachmentPath()),
2786                                         //                                                              getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2787                                         //                                                              entry.isExported());
2788                                         //                                      }
2789                                         break;
2790
2791                                 case IResource.FOLDER:
2792                                         // internal binary folder
2793                                         //                                      return JavaCore.newLibraryEntry(
2794                                         //                                                      resolvedPath,
2795                                         //                                                      getResolvedVariablePath(entry.getSourceAttachmentPath()),
2796                                         //                                                      getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2797                                         //                                                      entry.isExported());
2798                                         break;
2799                                 }
2800                         }
2801                 }
2802                 // outside the workspace
2803                 if (target instanceof File) {
2804                         File externalFile = (File) target;
2805                         if (externalFile.isFile()) {
2806                                 String fileName = externalFile.getName().toLowerCase();
2807                                 //                      if (fileName.endsWith(".jar" //$NON-NLS-1$
2808                                 //                              ) || fileName.endsWith(".zip" //$NON-NLS-1$
2809                                 //                              )) { // external binary archive
2810                                 //                              return JavaCore.newLibraryEntry(
2811                                 //                                              resolvedPath,
2812                                 //                                              getResolvedVariablePath(entry.getSourceAttachmentPath()),
2813                                 //                                              getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2814                                 //                                              entry.isExported());
2815                                 //                      }
2816                         } else { // external binary folder
2817                                 if (resolvedPath.isAbsolute()) {
2818                                         //                              return JavaCore.newLibraryEntry(
2819                                         //                                              resolvedPath,
2820                                         //                                              getResolvedVariablePath(entry.getSourceAttachmentPath()),
2821                                         //                                              getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
2822                                         //                                              entry.isExported());
2823                                 }
2824                         }
2825                 }
2826                 return null;
2827         }
2828
2829         /**
2830          * Resolve a variable path (helper method).
2831          * 
2832          * @param variablePath
2833          *            the given variable path
2834          * @return the resolved variable path or <code>null</code> if none
2835          */
2836         public static IPath getResolvedVariablePath(IPath variablePath) {
2837
2838                 if (variablePath == null)
2839                         return null;
2840                 int count = variablePath.segmentCount();
2841                 if (count == 0)
2842                         return null;
2843
2844                 // lookup variable
2845                 String variableName = variablePath.segment(0);
2846                 IPath resolvedPath = JavaCore.getClasspathVariable(variableName);
2847                 if (resolvedPath == null)
2848                         return null;
2849
2850                 // append path suffix
2851                 if (count > 1) {
2852                         resolvedPath = resolvedPath.append(variablePath
2853                                         .removeFirstSegments(1));
2854                 }
2855                 return resolvedPath;
2856         }
2857
2858         /**
2859          * Answers the shared working copies currently registered for this buffer
2860          * factory. Working copies can be shared by several clients using the same
2861          * buffer factory,see <code>IWorkingCopy.getSharedWorkingCopy</code>.
2862          * 
2863          * @param factory
2864          *            the given buffer factory
2865          * @return the list of shared working copies for a given buffer factory
2866          * @see IWorkingCopy
2867          * @since 2.0
2868          */
2869         public static IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory) {
2870
2871                 // if factory is null, default factory must be used
2872                 if (factory == null)
2873                         factory = BufferManager.getDefaultBufferManager()
2874                                         .getDefaultBufferFactory();
2875                 Map sharedWorkingCopies = JavaModelManager.getJavaModelManager().sharedWorkingCopies;
2876
2877                 Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
2878                 if (perFactoryWorkingCopies == null)
2879                         return JavaModelManager.NoWorkingCopy;
2880                 Collection copies = perFactoryWorkingCopies.values();
2881                 IWorkingCopy[] result = new IWorkingCopy[copies.size()];
2882                 copies.toArray(result);
2883                 return result;
2884         }
2885
2886         /**
2887          * Initializes the default preferences settings for this plug-in.
2888          */
2889         public static void initializeDefaultPluginPreferences() {
2890
2891                 Preferences preferences = PHPeclipsePlugin.getDefault()
2892                                 .getPluginPreferences();
2893                 HashSet optionNames = JavaModelManager.OptionNames;
2894
2895                 // Compiler settings
2896                 preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
2897                 optionNames.add(COMPILER_LOCAL_VARIABLE_ATTR);
2898
2899                 preferences.setDefault(COMPILER_LINE_NUMBER_ATTR, GENERATE);
2900                 optionNames.add(COMPILER_LINE_NUMBER_ATTR);
2901
2902                 preferences.setDefault(COMPILER_SOURCE_FILE_ATTR, GENERATE);
2903                 optionNames.add(COMPILER_SOURCE_FILE_ATTR);
2904
2905                 preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE);
2906                 optionNames.add(COMPILER_CODEGEN_UNUSED_LOCAL);
2907
2908                 preferences.setDefault(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1);
2909                 optionNames.add(COMPILER_CODEGEN_TARGET_PLATFORM);
2910
2911                 preferences.setDefault(COMPILER_PB_PHP_VAR_DEPRECATED, WARNING);
2912                 optionNames.add(COMPILER_PB_PHP_VAR_DEPRECATED);
2913                 preferences.setDefault(COMPILER_PB_PHP_KEYWORD, WARNING);
2914                 optionNames.add(COMPILER_PB_PHP_KEYWORD);
2915                 preferences.setDefault(COMPILER_PB_PHP_UPPERCASE_IDENTIFIER, IGNORE);
2916                 optionNames.add(COMPILER_PB_PHP_UPPERCASE_IDENTIFIER);
2917  
2918                 preferences.setDefault(COMPILER_PB_UNREACHABLE_CODE, ERROR);
2919                 optionNames.add(COMPILER_PB_UNREACHABLE_CODE);
2920
2921                 preferences.setDefault(COMPILER_PB_INVALID_IMPORT, ERROR);
2922                 optionNames.add(COMPILER_PB_INVALID_IMPORT);
2923
2924                 preferences.setDefault(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD,
2925                                 WARNING);
2926                 optionNames.add(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD);
2927
2928                 preferences.setDefault(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME,
2929                                 WARNING);
2930                 optionNames.add(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME);
2931
2932                 preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING);
2933                 optionNames.add(COMPILER_PB_DEPRECATION);
2934
2935                 preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE,
2936                                 DISABLED);
2937                 optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE);
2938
2939                 preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING);
2940                 optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK);
2941
2942                 preferences.setDefault(COMPILER_PB_UNUSED_LOCAL, IGNORE);
2943                 optionNames.add(COMPILER_PB_UNUSED_LOCAL);
2944
2945                 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE);
2946                 optionNames.add(COMPILER_PB_UNUSED_PARAMETER);
2947
2948                 preferences.setDefault(
2949                                 COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT,
2950                                 DISABLED);
2951                 optionNames
2952                                 .add(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT);
2953
2954                 preferences
2955                                 .setDefault(
2956                                                 COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE,
2957                                                 DISABLED);
2958                 optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE);
2959
2960                 preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING);
2961                 optionNames.add(COMPILER_PB_UNUSED_IMPORT);
2962
2963                 preferences.setDefault(COMPILER_PB_UNUSED_PRIVATE_MEMBER, IGNORE);
2964                 optionNames.add(COMPILER_PB_UNUSED_PRIVATE_MEMBER);
2965
2966                 preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE);
2967                 optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION);
2968
2969                 preferences.setDefault(COMPILER_PB_NON_NLS_STRING_LITERAL, IGNORE);
2970                 optionNames.add(COMPILER_PB_NON_NLS_STRING_LITERAL);
2971
2972                 preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE);
2973                 optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER);
2974
2975                 preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING);
2976                 optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER);
2977
2978                 preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING);
2979                 optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT);
2980
2981                 preferences.setDefault(
2982                                 COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD,
2983                                 WARNING);
2984                 optionNames
2985                                 .add(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD);
2986
2987                 preferences.setDefault(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION,
2988                                 WARNING);
2989                 optionNames.add(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION);
2990
2991                 preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAG); //$NON-NLS-1$
2992                 optionNames.add(COMPILER_TASK_TAGS);
2993
2994                 preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITY); //$NON-NLS-1$
2995                 optionNames.add(COMPILER_TASK_PRIORITIES);
2996
2997                 preferences.setDefault(COMPILER_SOURCE, VERSION_1_3);
2998                 optionNames.add(COMPILER_SOURCE);
2999
3000                 preferences.setDefault(COMPILER_COMPLIANCE, VERSION_1_3);
3001                 optionNames.add(COMPILER_COMPLIANCE);
3002
3003                 preferences.setDefault(COMPILER_PB_MAX_PER_UNIT, "100"); //$NON-NLS-1$
3004                 optionNames.add(COMPILER_PB_MAX_PER_UNIT);
3005
3006                 // Builder settings
3007                 preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
3008                 optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
3009
3010                 preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT);
3011                 optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH);
3012
3013                 preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING);
3014                 optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE);
3015
3016                 preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN);
3017                 optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER);
3018
3019                 // JavaCore settings
3020                 preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE);
3021                 optionNames.add(CORE_JAVA_BUILD_ORDER);
3022
3023                 preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR);
3024                 optionNames.add(CORE_CIRCULAR_CLASSPATH);
3025
3026                 preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR);
3027                 optionNames.add(CORE_INCOMPLETE_CLASSPATH);
3028
3029                 preferences.setDefault(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS,
3030                                 ENABLED);
3031                 optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS);
3032
3033                 preferences.setDefault(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS,
3034                                 ENABLED);
3035                 optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS);
3036
3037                 // encoding setting comes from resource plug-in
3038                 optionNames.add(CORE_ENCODING);
3039
3040                 // Formatter settings
3041                 preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT);
3042                 optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE);
3043
3044                 preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT);
3045                 optionNames.add(FORMATTER_NEWLINE_CONTROL);
3046
3047                 preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE);
3048                 optionNames.add(FORMATTER_CLEAR_BLANK_LINES);
3049
3050                 preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT);
3051                 optionNames.add(FORMATTER_NEWLINE_ELSE_IF);
3052
3053                 preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT);
3054                 optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK);
3055
3056                 preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$
3057                 optionNames.add(FORMATTER_LINE_SPLIT);
3058
3059                 preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL);
3060                 optionNames.add(FORMATTER_COMPACT_ASSIGNMENT);
3061
3062                 preferences.setDefault(FORMATTER_TAB_CHAR, TAB);
3063                 optionNames.add(FORMATTER_TAB_CHAR);
3064
3065                 preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$ 
3066                 optionNames.add(FORMATTER_TAB_SIZE);
3067
3068                 preferences.setDefault(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$ 
3069                 optionNames.add(FORMATTER_SPACE_CASTEXPRESSION);
3070
3071                 // CodeAssist settings
3072                 preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$
3073                 optionNames.add(CODEASSIST_VISIBILITY_CHECK);
3074
3075                 preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$
3076                 optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION);
3077
3078                 preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
3079                 optionNames.add(CODEASSIST_FIELD_PREFIXES);
3080
3081                 preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
3082                 optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES);
3083
3084                 preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
3085                 optionNames.add(CODEASSIST_LOCAL_PREFIXES);
3086
3087                 preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
3088                 optionNames.add(CODEASSIST_ARGUMENT_PREFIXES);
3089
3090                 preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3091                 optionNames.add(CODEASSIST_FIELD_SUFFIXES);
3092
3093                 preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
3094                 optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES);
3095
3096                 preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
3097                 optionNames.add(CODEASSIST_LOCAL_SUFFIXES);
3098
3099                 preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
3100                 optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES);
3101         }
3102
3103         /**
3104          * Returns whether the given marker references the given Java element. Used
3105          * for markers, which denote a Java element rather than a resource.
3106          * 
3107          * @param element
3108          *            the element
3109          * @param marker
3110          *            the marker
3111          * @return <code>true</code> if the marker references the element, false
3112          *         otherwise
3113          * @exception CoreException
3114          *                if the <code>IMarker.getAttribute</code> on the marker
3115          *                fails
3116          */
3117         public static boolean isReferencedBy(IJavaElement element, IMarker marker)
3118                         throws CoreException {
3119
3120                 // only match units or classfiles
3121                 if (element instanceof IMember) {
3122                         IMember member = (IMember) element;
3123                         if (member.isBinary()) {
3124                                 element = null; //member.getClassFile();
3125                         } else {
3126                                 element = member.getCompilationUnit();
3127                         }
3128                 }
3129                 if (element == null)
3130                         return false;
3131                 if (marker == null)
3132                         return false;
3133
3134                 String markerHandleId = (String) marker.getAttribute(ATT_HANDLE_ID);
3135                 if (markerHandleId == null)
3136                         return false;
3137
3138                 IJavaElement markerElement = JavaCore.create(markerHandleId);
3139                 //      while (true){
3140                 if (element.equals(markerElement))
3141                         return true; // external elements may still be equal with different
3142                                                  // handleIDs.
3143
3144                 // cycle through enclosing types in case marker is associated with a
3145                 // classfile (15568)
3146                 //              if (markerElement instanceof IClassFile){
3147                 //                      IType enclosingType =
3148                 // ((IClassFile)markerElement).getType().getDeclaringType();
3149                 //                      if (enclosingType != null){
3150                 //                              markerElement = enclosingType.getClassFile(); // retry with immediate
3151                 // enclosing classfile
3152                 //                              continue;
3153                 //                      }
3154                 //              }
3155                 //              break;
3156                 //      }
3157                 return false;
3158         }
3159
3160         /**
3161          * Returns whether the given marker delta references the given Java element.
3162          * Used for markers deltas, which denote a Java element rather than a
3163          * resource.
3164          * 
3165          * @param element
3166          *            the element
3167          * @param markerDelta
3168          *            the marker delta
3169          * @return <code>true</code> if the marker delta references the element
3170          * @exception CoreException
3171          *                if the <code>IMarkerDelta.getAttribute</code> on the
3172          *                marker delta fails
3173          */
3174         public static boolean isReferencedBy(IJavaElement element,
3175                         IMarkerDelta markerDelta) throws CoreException {
3176
3177                 // only match units or classfiles
3178                 if (element instanceof IMember) {
3179                         IMember member = (IMember) element;
3180                         if (member.isBinary()) {
3181                                 element = null; //member.getClassFile();
3182                         } else {
3183                                 element = member.getCompilationUnit();
3184                         }
3185                 }
3186                 if (element == null)
3187                         return false;
3188                 if (markerDelta == null)
3189                         return false;
3190
3191                 String markerDeltarHandleId = (String) markerDelta
3192                                 .getAttribute(ATT_HANDLE_ID);
3193                 if (markerDeltarHandleId == null)
3194                         return false;
3195
3196                 IJavaElement markerElement = JavaCore.create(markerDeltarHandleId);
3197                 //      while (true){
3198                 if (element.equals(markerElement))
3199                         return true; // external elements may still be equal with different
3200                                                  // handleIDs.
3201
3202                 // cycle through enclosing types in case marker is associated with a
3203                 // classfile (15568)
3204                 //              if (markerElement instanceof IClassFile){
3205                 //                      IType enclosingType =
3206                 // ((IClassFile)markerElement).getType().getDeclaringType();
3207                 //                      if (enclosingType != null){
3208                 //                              markerElement = enclosingType.getClassFile(); // retry with immediate
3209                 // enclosing classfile
3210                 //                              continue;
3211                 //                      }
3212                 //              }
3213                 //              break;
3214                 //      }
3215                 return false;
3216         }
3217
3218         /**
3219          * Creates and returns a new classpath entry of kind
3220          * <code>CPE_CONTAINER</code> for the given path. The path of the
3221          * container will be used during resolution so as to map this container
3222          * entry to a set of other classpath entries the container is acting for.
3223          * <p>
3224          * A container entry allows to express indirect references to a set of
3225          * libraries, projects and variable entries, which can be interpreted
3226          * differently for each Java project where it is used. A classpath container
3227          * entry can be resolved using
3228          * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3229          * <code>JavaCore.classpathContainerChanged</code>
3230          * <p>
3231          * A container is exclusively resolved by a
3232          * <code>ClasspathContainerInitializer</code> registered onto the
3233          * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3234          * <p>
3235          * A container path must be formed of at least one segment, where:
3236          * <ul>
3237          * <li>the first segment is a unique ID identifying the target container,
3238          * there must be a container initializer registered onto this ID through the
3239          * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3240          * </li>
3241          * <li>the remaining segments will be passed onto the initializer, and can
3242          * be used as additional hints during the initialization phase.</li>
3243          * </ul>
3244          * <p>
3245          * Example of an ClasspathContainerInitializer for a classpath container
3246          * denoting a default JDK container:
3247          * 
3248          * containerEntry = JavaCore.newContainerEntry(new
3249          * Path("MyProvidedJDK/default"));
3250          * 
3251          * <extension point="org.eclipse.jdt.core.classpathContainerInitializer">
3252          * <containerInitializer id="MyProvidedJDK"
3253          * class="com.example.MyInitializer"/>
3254          * <p>
3255          * Note that this operation does not attempt to validate classpath
3256          * containers or access the resources at the given paths.
3257          * <p>
3258          * The resulting entry is not exported to dependent projects. This method is
3259          * equivalent to <code>newContainerEntry(-,false)</code>.
3260          * <p>
3261          * 
3262          * @param containerPath
3263          *            the path identifying the container, it must be formed of two
3264          *            segments
3265          * @return a new container classpath entry
3266          * 
3267          * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3268          * @see JavaCore#newContainerEntry(IPath, boolean)
3269          * @since 2.0
3270          */
3271         public static IClasspathEntry newContainerEntry(IPath containerPath) {
3272
3273     return newContainerEntry(containerPath, false);
3274   }
3275
3276   /**
3277    * Creates and returns a new classpath entry of kind
3278    * <code>CPE_CONTAINER</code> for the given path. The path of the
3279    * container will be used during resolution so as to map this container
3280    * entry to a set of other classpath entries the container is acting for.
3281    * <p>
3282    * A container entry allows to express indirect references to a set of
3283    * libraries, projects and variable entries, which can be interpreted
3284    * differently for each Java project where it is used. A classpath container
3285    * entry can be resolved using
3286    * <code>JavaCore.getResolvedClasspathContainer</code>, and updated with
3287    * <code>JavaCore.classpathContainerChanged</code>
3288    * <p>
3289    * A container is exclusively resolved by a
3290    * <code>ClasspathContainerInitializer</code> registered onto the
3291    * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3292    * <p>
3293    * A container path must be formed of at least one segment, where:
3294    * <ul>
3295    * <li>the first segment is a unique ID identifying the target container,
3296    * there must be a container initializer registered onto this ID through the
3297    * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3298    * </li>
3299    * <li>the remaining segments will be passed onto the initializer, and can
3300    * be used as additional hints during the initialization phase.</li>
3301    * </ul>
3302    * <p>
3303    * Example of an ClasspathContainerInitializer for a classpath container
3304    * denoting a default JDK container:
3305    * 
3306    * containerEntry = JavaCore.newContainerEntry(new
3307    * Path("MyProvidedJDK/default"));
3308    * 
3309    * <extension point="org.eclipse.jdt.core.classpathContainerInitializer">
3310    * <containerInitializer id="MyProvidedJDK"
3311    * class="com.example.MyInitializer"/>
3312    * <p>
3313    * Note that this operation does not attempt to validate classpath
3314    * containers or access the resources at the given paths.
3315    * <p>
3316    * 
3317    * @param containerPath
3318    *            the path identifying the container, it must be formed of at
3319    *            least one segment (ID+hints)
3320    * @param isExported
3321    *            a boolean indicating whether this entry is contributed to
3322    *            dependent projects in addition to the output location
3323    * @return a new container classpath entry
3324    * 
3325    * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
3326    * @see JavaCore#setClasspathContainer(IPath, IJavaProject[],
3327    *      IClasspathContainer[], IProgressMonitor)
3328    * @see JavaCore#newContainerEntry(IPath, boolean)
3329    * @since 2.0
3330    */
3331   public static IClasspathEntry newContainerEntry(IPath containerPath,
3332       boolean isExported) {
3333
3334     if (containerPath == null || containerPath.segmentCount() < 1) {
3335       Assert
3336           .isTrue(
3337               false,
3338               "Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$
3339     }
3340     return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3341         IClasspathEntry.CPE_CONTAINER, containerPath,
3342         ClasspathEntry.NO_EXCLUSION_PATTERNS, null, // source attachment
3343         null, // source attachment root
3344         null, // specific output folder
3345         isExported);
3346   }
3347
3348   /**
3349    * Creates and returns a new non-exported classpath entry of kind
3350    * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3351    * absolute path. This specifies that all package fragments within the root
3352    * will have children of type <code>IClassFile</code>.
3353    * <p>
3354    * A library entry is used to denote a prerequisite JAR or root folder
3355    * containing binaries. The target JAR or folder can either be defined
3356    * internally to the workspace (absolute path relative to the workspace
3357    * root) or externally to the workspace (absolute path in the file system).
3358    * <p>
3359    * e.g. Here are some examples of binary path usage
3360    * <ul>
3361    * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3362    * external JAR</li>
3363    * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3364    * </li>
3365    * <li><code> "c:/classes/" </code>- reference to an external binary
3366    * folder</li>
3367    * </ul>
3368    * Note that this operation does not attempt to validate or access the
3369    * resources at the given paths.
3370    * <p>
3371    * The resulting entry is not exported to dependent projects. This method is
3372    * equivalent to <code>newLibraryEntry(-,-,-,false)</code>.
3373    * <p>
3374    * 
3375    * @param path
3376    *            the absolute path of the binary archive
3377    * @param sourceAttachmentPath
3378    *            the absolute path of the corresponding source archive or
3379    *            folder, or <code>null</code> if none
3380    * @param sourceAttachmentRootPath
3381    *            the location of the root within the source archive or folder
3382    *            or <code>null</code> if this location should be
3383    *            automatically detected.
3384    * @return a new library classpath entry
3385    * 
3386    * @see #newLibraryEntry(IPath, IPath, IPath, boolean)
3387    */
3388   //public static IClasspathEntry newLibraryEntry(
3389   //    IPath path,
3390   //    IPath sourceAttachmentPath,
3391   //    IPath sourceAttachmentRootPath) {
3392   //                    
3393   //    return newLibraryEntry(path, sourceAttachmentPath,
3394   // sourceAttachmentRootPath, false);
3395   //}
3396   /**
3397    * Creates and returns a new classpath entry of kind
3398    * <code>CPE_LIBRARY</code> for the JAR or folder identified by the given
3399    * absolute path. This specifies that all package fragments within the root
3400    * will have children of type <code>IClassFile</code>.
3401    * <p>
3402    * A library entry is used to denote a prerequisite JAR or root folder
3403    * containing binaries. The target JAR or folder can either be defined
3404    * internally to the workspace (absolute path relative to the workspace
3405    * root) or externally to the workspace (absolute path in the file system).
3406    * <p>
3407    * e.g. Here are some examples of binary path usage
3408    * <ul>
3409    * <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code>- reference to an
3410    * external JAR</li>
3411    * <li><code> "/Project/someLib.jar" </code>- reference to an internal JAR
3412    * </li>
3413    * <li><code> "c:/classes/" </code>- reference to an external binary
3414    * folder</li>
3415    * </ul>
3416    * Note that this operation does not attempt to validate or access the
3417    * resources at the given paths.
3418    * <p>
3419    * 
3420    * @param path
3421    *            the absolute path of the binary archive
3422    * @param sourceAttachmentPath
3423    *            the absolute path of the corresponding source archive or
3424    *            folder, or <code>null</code> if none
3425    * @param sourceAttachmentRootPath
3426    *            the location of the root within the source archive or folder
3427    *            or <code>null</code> if this location should be
3428    *            automatically detected.
3429    * @param isExported
3430    *            indicates whether this entry is contributed to dependent
3431    *            projects in addition to the output location
3432    * @return a new library classpath entry
3433    * @since 2.0
3434    */
3435   //public static IClasspathEntry newLibraryEntry(
3436   //    IPath path,
3437   //    IPath sourceAttachmentPath,
3438   //    IPath sourceAttachmentRootPath,
3439   //    boolean isExported) {
3440   //                    
3441   //    if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry
3442   // must be absolute"); //$NON-NLS-1$
3443   //
3444   //    return new ClasspathEntry(
3445   //            IPackageFragmentRoot.K_BINARY,
3446   //            IClasspathEntry.CPE_LIBRARY,
3447   //            JavaProject.canonicalizedPath(path),
3448   //            ClasspathEntry.NO_EXCLUSION_PATTERNS,
3449   //            sourceAttachmentPath,
3450   //            sourceAttachmentRootPath,
3451   //            null, // specific output folder
3452   //            isExported);
3453   //}
3454   /**
3455    * Creates and returns a new non-exported classpath entry of kind
3456    * <code>CPE_PROJECT</code> for the project identified by the given
3457    * absolute path.
3458    * <p>
3459    * A project entry is used to denote a prerequisite project on a classpath.
3460    * The referenced project will be contributed as a whole, either as sources
3461    * (in the Java Model, it contributes all its package fragment roots) or as
3462    * binaries (when building, it contributes its whole output location).
3463    * <p>
3464    * A project reference allows to indirect through another project,
3465    * independently from its internal layout.
3466    * <p>
3467    * The prerequisite project is referred to using an absolute path relative
3468    * to the workspace root.
3469    * <p>
3470    * The resulting entry is not exported to dependent projects. This method is
3471    * equivalent to <code>newProjectEntry(_,false)</code>.
3472    * <p>
3473    * 
3474    * @param path
3475    *            the absolute path of the binary archive
3476    * @return a new project classpath entry
3477    * 
3478    * @see JavaCore#newProjectEntry(IPath, boolean)
3479    */
3480   public static IClasspathEntry newProjectEntry(IPath path) {
3481     return newProjectEntry(path, false);
3482   }
3483
3484   /**
3485    * Creates and returns a new classpath entry of kind
3486    * <code>CPE_PROJECT</code> for the project identified by the given
3487    * absolute path.
3488    * <p>
3489    * A project entry is used to denote a prerequisite project on a classpath.
3490    * The referenced project will be contributed as a whole, either as sources
3491    * (in the Java Model, it contributes all its package fragment roots) or as
3492    * binaries (when building, it contributes its whole output location).
3493    * <p>
3494    * A project reference allows to indirect through another project,
3495    * independently from its internal layout.
3496    * <p>
3497    * The prerequisite project is referred to using an absolute path relative
3498    * to the workspace root.
3499    * <p>
3500    * 
3501    * @param path
3502    *            the absolute path of the prerequisite project
3503    * @param isExported
3504    *            indicates whether this entry is contributed to dependent
3505    *            projects in addition to the output location
3506    * @return a new project classpath entry
3507    * @since 2.0
3508    */
3509   public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) {
3510
3511     if (!path.isAbsolute())
3512       Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3513
3514     return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3515         IClasspathEntry.CPE_PROJECT, path,
3516         ClasspathEntry.NO_EXCLUSION_PATTERNS, null, // source attachment
3517         null, // source attachment root
3518         null, // specific output folder
3519         isExported);
3520   }
3521
3522   /**
3523    * Returns a new empty region.
3524    * 
3525    * @return a new empty region
3526    */
3527   public static IRegion newRegion() {
3528     return new Region();
3529   }
3530
3531   /**
3532    * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3533    * for the project's source folder identified by the given absolute
3534    * workspace-relative path. This specifies that all package fragments within
3535    * the root will have children of type <code>ICompilationUnit</code>.
3536    * <p>
3537    * The source folder is referred to using an absolute path relative to the
3538    * workspace root, e.g. <code>/Project/src</code>. A project's source
3539    * folders are located with that project. That is, a source classpath entry
3540    * specifying the path <code>/P1/src</code> is only usable for project
3541    * <code>P1</code>.
3542    * </p>
3543    * <p>
3544    * The source classpath entry created by this method includes all source
3545    * files below the given workspace-relative path. To selectively exclude
3546    * some of these source files, use the factory method
3547    * <code>JavaCore.newSourceEntry(IPath,IPath[])</code> instead.
3548    * </p>
3549    * <p>
3550    * Note that all sources/binaries inside a project are contributed as a
3551    * whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
3552    * Particular source entries cannot be selectively exported.
3553    * </p>
3554    * 
3555    * @param path
3556    *            the absolute workspace-relative path of a source folder
3557    * @return a new source classpath entry with not exclusion patterns
3558    * 
3559    * @see #newSourceEntry(org.eclipse.core.runtime.IPath,org.eclipse.core.runtime.IPath[])
3560    */
3561   public static IClasspathEntry newSourceEntry(IPath path) {
3562
3563     return newSourceEntry(path, ClasspathEntry.NO_EXCLUSION_PATTERNS, null /*
3564      * output
3565      * location
3566      */);
3567   }
3568
3569   /**
3570    * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3571    * for the project's source folder identified by the given absolute
3572    * workspace-relative path but excluding all source files with paths
3573    * matching any of the given patterns. This specifies that all package
3574    * fragments within the root will have children of type
3575    * <code>ICompilationUnit</code>.
3576    * <p>
3577    * The source folder is referred to using an absolute path relative to the
3578    * workspace root, e.g. <code>/Project/src</code>. A project's source
3579    * folders are located with that project. That is, a source classpath entry
3580    * specifying the path <code>/P1/src</code> is only usable for project
3581    * <code>P1</code>.
3582    * </p>
3583    * <p>
3584    * The source classpath entry created by this method includes all source
3585    * files below the given workspace-relative path except for those matched by
3586    * one (or more) of the given exclusion patterns. Each exclusion pattern is
3587    * represented by a relative path, which is interpreted as relative to the
3588    * source folder. For example, if the source folder path is
3589    * <code>/Project/src</code> and the exclusion pattern is
3590    * <code>com/xyz/tests/&#42;&#42;</code>, then source files like
3591    * <code>/Project/src/com/xyz/Foo.java</code> and
3592    * <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3593    * whereas <code>/Project/src/com/xyz/tests/T1.java</code> and
3594    * <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3595    * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
3596    * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code> for
3597    * the full description of the syntax and semantics of exclusion patterns.
3598    * </p>
3599    * If the empty list of exclusion patterns is specified, the source folder
3600    * will automatically include all resources located inside the source
3601    * folder. In that case, the result is entirely equivalent to using the
3602    * factory method <code>JavaCore.newSourceEntry(IPath)</code>.
3603    * </p>
3604    * <p>
3605    * Note that all sources/binaries inside a project are contributed as a
3606    * whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
3607    * Particular source entries cannot be selectively exported.
3608    * </p>
3609    * 
3610    * @param path
3611    *            the absolute workspace-relative path of a source folder
3612    * @param exclusionPatterns
3613    *            the possibly empty list of exclusion patterns represented as
3614    *            relative paths
3615    * @return a new source classpath entry with the given exclusion patterns
3616    * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
3617    * @see IClasspathEntry#getExclusionPatterns
3618    * 
3619    * @since 2.1
3620    */
3621   public static IClasspathEntry newSourceEntry(IPath path,
3622       IPath[] exclusionPatterns) {
3623
3624     return newSourceEntry(path, exclusionPatterns, null /* output location */);
3625   }
3626
3627   /**
3628    * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
3629    * for the project's source folder identified by the given absolute
3630    * workspace-relative path but excluding all source files with paths
3631    * matching any of the given patterns, and associated with a specific output
3632    * location (that is, ".class" files are not going to the project default
3633    * output location). All package fragments within the root will have
3634    * children of type <code>ICompilationUnit</code>.
3635    * <p>
3636    * The source folder is referred to using an absolute path relative to the
3637    * workspace root, e.g. <code>/Project/src</code>. A project's source
3638    * folders are located with that project. That is, a source classpath entry
3639    * specifying the path <code>/P1/src</code> is only usable for project
3640    * <code>P1</code>.
3641    * </p>
3642    * <p>
3643    * The source classpath entry created by this method includes all source
3644    * files below the given workspace-relative path except for those matched by
3645    * one (or more) of the given exclusion patterns. Each exclusion pattern is
3646    * represented by a relative path, which is interpreted as relative to the
3647    * source folder. For example, if the source folder path is
3648    * <code>/Project/src</code> and the exclusion pattern is
3649    * <code>com/xyz/tests/&#42;&#42;</code>, then source files like
3650    * <code>/Project/src/com/xyz/Foo.java</code> and
3651    * <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
3652    * whereas <code>/Project/src/com/xyz/tests/T1.java</code> and
3653    * <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
3654    * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
3655    * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code> for
3656    * the full description of the syntax and semantics of exclusion patterns.
3657    * </p>
3658    * If the empty list of exclusion patterns is specified, the source folder
3659    * will automatically include all resources located inside the source
3660    * folder. In that case, the result is entirely equivalent to using the
3661    * factory method <code>JavaCore.newSourceEntry(IPath)</code>.
3662    * </p>
3663    * <p>
3664    * Additionally, a source entry can be associated with a specific output
3665    * location. By doing so, the Java builder will ensure that the generated
3666    * ".class" files will be issued inside this output location, as opposed to
3667    * be generated into the project default output location (when output
3668    * location is <code>null</code>). Note that multiple source entries may
3669    * target the same output location. The output location is referred to using
3670    * an absolute path relative to the workspace root, e.g.
3671    * <code>"/Project/bin"</code>, it must be located inside the same
3672    * project as the source folder.
3673    * </p>
3674    * <p>
3675    * Also note that all sources/binaries inside a project are contributed as a
3676    * whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
3677    * Particular source entries cannot be selectively exported.
3678    * </p>
3679    * 
3680    * @param path
3681    *            the absolute workspace-relative path of a source folder
3682    * @param exclusionPatterns
3683    *            the possibly empty list of exclusion patterns represented as
3684    *            relative paths
3685    * @param outputLocation
3686    *            the specific output location for this source entry (
3687    *            <code>null</code> if using project default ouput location)
3688    * @return a new source classpath entry with the given exclusion patterns
3689    * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
3690    * @see IClasspathEntry#getExclusionPatterns
3691    * @see IClasspathEntry#getOutputLocation()
3692    * 
3693    * @since 2.1
3694    */
3695   public static IClasspathEntry newSourceEntry(IPath path,
3696       IPath[] exclusionPatterns, IPath specificOutputLocation) {
3697
3698     if (!path.isAbsolute())
3699       Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
3700     if (exclusionPatterns == null)
3701       Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$
3702
3703     return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
3704         IClasspathEntry.CPE_SOURCE, path, exclusionPatterns, null, // source
3705         // attachment
3706         null, // source attachment root
3707         specificOutputLocation, // custom output location
3708         false);
3709   }
3710
3711   /**
3712    * Creates and returns a new non-exported classpath entry of kind
3713    * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3714    * path is the name of a classpath variable. The trailing segments of the
3715    * path will be appended to resolved variable path.
3716    * <p>
3717    * A variable entry allows to express indirect references on a classpath to
3718    * other projects or libraries, depending on what the classpath variable is
3719    * referring.
3720    * <p>
3721    * It is possible to register an automatic initializer (
3722    * <code>ClasspathVariableInitializer</code>), which will be invoked
3723    * through the extension point
3724    * "org.eclipse.jdt.core.classpathVariableInitializer". After resolution, a
3725    * classpath variable entry may either correspond to a project or a library
3726    * entry.</li>
3727    * <p>
3728    * e.g. Here are some examples of variable path usage
3729    * <ul>
3730    * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3731    * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3732    * library "c:\jars\jdtcore.jar"</li>
3733    * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3734    * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3735    * "/Project_JDTCORE"</li>
3736    * <li>"PLUGINS/com.example/example.jar" where variable
3737    * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3738    * classpath entry is denoting the library
3739    * "c:/eclipse/plugins/com.example/example.jar"</li>
3740    * </ul>
3741    * Note that this operation does not attempt to validate classpath variables
3742    * or access the resources at the given paths.
3743    * <p>
3744    * The resulting entry is not exported to dependent projects. This method is
3745    * equivalent to <code>newVariableEntry(-,-,-,false)</code>.
3746    * <p>
3747    * 
3748    * @param variablePath
3749    *            the path of the binary archive; first segment is the name of a
3750    *            classpath variable
3751    * @param variableSourceAttachmentPath
3752    *            the path of the corresponding source archive, or
3753    *            <code>null</code> if none; if present, the first segment is
3754    *            the name of a classpath variable (not necessarily the same
3755    *            variable as the one that begins <code>variablePath</code>)
3756    * @param sourceAttachmentRootPath
3757    *            the location of the root within the source archive or
3758    *            <code>null</code> if <code>archivePath</code> is also
3759    *            <code>null</code>
3760    * @return a new library classpath entry
3761    * 
3762    * @see JavaCore#newVariableEntry(IPath, IPath, IPath, boolean)
3763    */
3764   //public static IClasspathEntry newVariableEntry(
3765   //    IPath variablePath,
3766   //    IPath variableSourceAttachmentPath,
3767   //    IPath sourceAttachmentRootPath) {
3768   //
3769   //    return newVariableEntry(variablePath, variableSourceAttachmentPath,
3770   // sourceAttachmentRootPath, false);
3771   //}
3772   /**
3773    * Creates and returns a new non-exported classpath entry of kind
3774    * <code>CPE_VARIABLE</code> for the given path. The first segment of the
3775    * path is the name of a classpath variable. The trailing segments of the
3776    * path will be appended to resolved variable path.
3777    * <p>
3778    * A variable entry allows to express indirect references on a classpath to
3779    * other projects or libraries, depending on what the classpath variable is
3780    * referring.
3781    * <p>
3782    * It is possible to register an automatic initializer (
3783    * <code>ClasspathVariableInitializer</code>), which will be invoked
3784    * through the extension point
3785    * "org.eclipse.jdt.core.classpathVariableInitializer". After resolution, a
3786    * classpath variable entry may either correspond to a project or a library
3787    * entry.</li>
3788    * <p>
3789    * e.g. Here are some examples of variable path usage
3790    * <ul>
3791    * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3792    * "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the
3793    * library "c:\jars\jdtcore.jar"</li>
3794    * <li>"JDTCORE" where variable <code>JDTCORE</code> is bound to
3795    * "/Project_JDTCORE". The resolved classpath entry is denoting the project
3796    * "/Project_JDTCORE"</li>
3797    * <li>"PLUGINS/com.example/example.jar" where variable
3798    * <code>PLUGINS</code> is bound to "c:/eclipse/plugins". The resolved
3799    * classpath entry is denoting the library
3800    * "c:/eclipse/plugins/com.example/example.jar"</li>
3801    * </ul>
3802    * Note that this operation does not attempt to validate classpath variables
3803    * or access the resources at the given paths.
3804    * <p>
3805    * 
3806    * @param variablePath
3807    *            the path of the binary archive; first segment is the name of a
3808    *            classpath variable
3809    * @param variableSourceAttachmentPath
3810    *            the path of the corresponding source archive, or
3811    *            <code>null</code> if none; if present, the first segment is
3812    *            the name of a classpath variable (not necessarily the same
3813    *            variable as the one that begins <code>variablePath</code>)
3814    * @param sourceAttachmentRootPath
3815    *            the location of the root within the source archive or
3816    *            <code>null</code> if <code>archivePath</code> is also
3817    *            <code>null</code>
3818    * @param isExported
3819    *            indicates whether this entry is contributed to dependent
3820    *            projects in addition to the output location
3821    * @return a new variable classpath entry
3822    * @since 2.0
3823    */
3824   //public static IClasspathEntry newVariableEntry(
3825   //    IPath variablePath,
3826   //    IPath variableSourceAttachmentPath,
3827   //    IPath variableSourceAttachmentRootPath,
3828   //    boolean isExported) {
3829   //                    
3830   //    if (variablePath == null || variablePath.segmentCount() < 1) {
3831   //            Assert.isTrue(
3832   //                    false,
3833   //                    "Illegal classpath variable path: \'" +
3834   // variablePath.makeRelative().toString() + "\', must have at least one
3835   // segment"); //$NON-NLS-1$//$NON-NLS-2$
3836   //    }
3837   //    
3838   //    return new ClasspathEntry(
3839   //            IPackageFragmentRoot.K_SOURCE,
3840   //            IClasspathEntry.CPE_VARIABLE,
3841   //            variablePath,
3842   //            ClasspathEntry.NO_EXCLUSION_PATTERNS,
3843   //            variableSourceAttachmentPath, // source attachment
3844   //            variableSourceAttachmentRootPath, // source attachment root
3845   //            null, // specific output folder
3846   //            isExported);
3847   //}
3848   /**
3849    * Removed the given classpath variable. Does nothing if no value was set
3850    * for this classpath variable.
3851    * <p>
3852    * This functionality cannot be used while the resource tree is locked.
3853    * <p>
3854    * Classpath variable values are persisted locally to the workspace, and are
3855    * preserved from session to session.
3856    * <p>
3857    * 
3858    * @param variableName
3859    *            the name of the classpath variable
3860    * @see #setClasspathVariable
3861    * 
3862    * @deprecated - use version with extra IProgressMonitor
3863    */
3864   //public static void removeClasspathVariable(String variableName) {
3865   //    removeClasspathVariable(variableName, null);
3866   //}
3867   /**
3868    * Removed the given classpath variable. Does nothing if no value was set
3869    * for this classpath variable.
3870    * <p>
3871    * This functionality cannot be used while the resource tree is locked.
3872    * <p>
3873    * Classpath variable values are persisted locally to the workspace, and are
3874    * preserved from session to session.
3875    * <p>
3876    * 
3877    * @param variableName
3878    *            the name of the classpath variable
3879    * @param monitor
3880    *            the progress monitor to report progress
3881    * @see #setClasspathVariable
3882    */
3883   //public static void removeClasspathVariable(
3884   //    String variableName,
3885   //    IProgressMonitor monitor) {
3886   //
3887   //    try {
3888   //            updateVariableValues(new String[]{ variableName}, new IPath[]{ null },
3889   // monitor);
3890   //    } catch (JavaModelException e) {
3891   //    }
3892   //}
3893   /**
3894    * Removes the given element changed listener. Has no affect if an identical
3895    * listener is not registered.
3896    * 
3897    * @param listener
3898    *            the listener
3899    */
3900   public static void removeElementChangedListener(
3901       IElementChangedListener listener) {
3902     JavaModelManager.getJavaModelManager().removeElementChangedListener(
3903         listener);
3904   }
3905
3906   /**
3907    * Bind a container reference path to some actual containers (
3908    * <code>IClasspathContainer</code>). This API must be invoked whenever
3909    * changes in container need to be reflected onto the JavaModel. Containers
3910    * can have distinct values in different projects, therefore this API
3911    * considers a set of projects with their respective containers.
3912    * <p>
3913    * <code>containerPath</code> is the path under which these values can be
3914    * referenced through container classpath entries (
3915    * <code>IClasspathEntry#CPE_CONTAINER</code>). A container path is
3916    * formed by a first ID segment followed with extra segments, which can be
3917    * used as additional hints for the resolution. The container ID is used to
3918    * identify a <code>ClasspathContainerInitializer</code> registered on the
3919    * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
3920    * <p>
3921    * There is no assumption that each individual container value passed in
3922    * argument (<code>respectiveContainers</code>) must answer the exact
3923    * same path when requested <code>IClasspathContainer#getPath</code>.
3924    * Indeed, the containerPath is just an indication for resolving it to an
3925    * actual container object. It can be delegated to a
3926    * <code>ClasspathContainerInitializer</code>, which can be activated
3927    * through the extension point
3928    * "org.eclipse.jdt.core.ClasspathContainerInitializer").
3929    * <p>
3930    * In reaction to changing container values, the JavaModel will be updated
3931    * to reflect the new state of the updated container.
3932    * <p>
3933    * This functionality cannot be used while the resource tree is locked.
3934    * <p>
3935    * Classpath container values are persisted locally to the workspace, but
3936    * are not preserved from a session to another. It is thus highly
3937    * recommended to register a <code>ClasspathContainerInitializer</code>
3938    * for each referenced container (through the extension point
3939    * "org.eclipse.jdt.core.ClasspathContainerInitializer").
3940    * <p>
3941    * Note: setting a container to <code>null</code> will cause it to be
3942    * lazily resolved again whenever its value is required. In particular, this
3943    * will cause a registered initializer to be invoked again.
3944    * <p>
3945    * 
3946    * @param containerPath -
3947    *            the name of the container reference, which is being updated
3948    * @param affectedProjects -
3949    *            the set of projects for which this container is being bound
3950    * @param respectiveContainers -
3951    *            the set of respective containers for the affected projects
3952    * @param monitor
3953    *            a monitor to report progress
3954    * 
3955    * @see ClasspathContainerInitializer
3956    * @see #getClasspathContainer(IPath, IJavaProject)
3957    * @see IClasspathContainer
3958    * @since 2.0
3959    */
3960   //public static void setClasspathContainer(final IPath containerPath,
3961   // IJavaProject[] affectedProjects, IClasspathContainer[]
3962   // respectiveContainers, IProgressMonitor monitor) throws JavaModelException
3963   // {
3964   //
3965   //    if (affectedProjects.length != respectiveContainers.length)
3966   // Assert.isTrue(false, "Projects and containers collections should have the
3967   // same size"); //$NON-NLS-1$
3968   //    
3969   //    if (monitor != null && monitor.isCanceled()) return;
3970   //    
3971   //    if (JavaModelManager.CP_RESOLVE_VERBOSE){
3972   //            System.out.println("CPContainer SET - setting container:
3973   // ["+containerPath+"] for projects: {" //$NON-NLS-1$ //$NON-NLS-2$
3974   //                    + (ProjectPrefUtil.toString(affectedProjects,
3975   //                                    new ProjectPrefUtil.Displayable(){
3976   //                                            public String displayString(Object o) { return ((IJavaProject)
3977   // o).getElementName(); }
3978   //                                    }))
3979   //                    + "} with values: " //$NON-NLS-1$
3980   //                    + (ProjectPrefUtil.toString(respectiveContainers,
3981   //                                    new ProjectPrefUtil.Displayable(){
3982   //                                            public String displayString(Object o) { return ((IClasspathContainer)
3983   // o).getDescription(); }
3984   //                                    }))
3985   //                            );
3986   //    }
3987   //
3988   //    final int projectLength = affectedProjects.length;
3989   //    final IJavaProject[] modifiedProjects;
3990   //    System.arraycopy(affectedProjects, 0, modifiedProjects = new
3991   // IJavaProject[projectLength], 0, projectLength);
3992   //    final IClasspathEntry[][] oldResolvedPaths = new
3993   // IClasspathEntry[projectLength][];
3994   //                    
3995   //    // filter out unmodified project containers
3996   //    int remaining = 0;
3997   //    for (int i = 0; i < projectLength; i++){
3998   //    
3999   //            if (monitor != null && monitor.isCanceled()) return;
4000   //    
4001   //            IJavaProject affectedProject = affectedProjects[i];
4002   //            IClasspathContainer newContainer = respectiveContainers[i];
4003   //            if (newContainer == null) newContainer =
4004   // JavaModelManager.ContainerInitializationInProgress; // 30920 - prevent
4005   // infinite loop
4006   //            boolean found = false;
4007   //            if (JavaProject.hasJavaNature(affectedProject.getProject())){
4008   //                    IClasspathEntry[] rawClasspath = affectedProject.getRawClasspath();
4009   //                    for (int j = 0, cpLength = rawClasspath.length; j <cpLength; j++) {
4010   //                            IClasspathEntry entry = rawClasspath[j];
4011   //                            if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER &&
4012   // entry.getPath().equals(containerPath)){
4013   //                                    found = true;
4014   //                                    break;
4015   //                            }
4016   //                    }
4017   //            }
4018   //            if (!found){
4019   //                    modifiedProjects[i] = null; // filter out this project - does not
4020   // reference the container path, or isnt't yet Java project
4021   //                    JavaModelManager.containerPut(affectedProject, containerPath,
4022   // newContainer);
4023   //                    continue;
4024   //            }
4025   //            IClasspathContainer oldContainer =
4026   // JavaModelManager.containerGet(affectedProject, containerPath);
4027   //            if (oldContainer == JavaModelManager.ContainerInitializationInProgress) {
4028   //                    Map previousContainerValues =
4029   // (Map)JavaModelManager.PreviousSessionContainers.get(affectedProject);
4030   //                    if (previousContainerValues != null){
4031   //                            IClasspathContainer previousContainer =
4032   // (IClasspathContainer)previousContainerValues.get(containerPath);
4033   //                            if (previousContainer != null) {
4034   //                                    if (JavaModelManager.CP_RESOLVE_VERBOSE){
4035   //                                            System.out.println("CPContainer INIT - reentering access to project
4036   // container: ["+affectedProject.getElementName()+"] " + containerPath + "
4037   // during its initialization, will see previous value: "+
4038   // previousContainer.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
4039   // //$NON-NLS-3$
4040   //                                    }
4041   //                                    JavaModelManager.containerPut(affectedProject, containerPath,
4042   // previousContainer);
4043   //                            }
4044   //                            oldContainer = null; //33695 - cannot filter out restored container, must
4045   // update affected project to reset cached CP
4046   //                    } else {
4047   //                            oldContainer = null;
4048   //                    }
4049   //            }
4050   //            if (oldContainer != null &&
4051   // oldContainer.equals(respectiveContainers[i])){// TODO: could improve to
4052   // only compare entries
4053   //                    modifiedProjects[i] = null; // filter out this project - container did
4054   // not change
4055   //                    continue;
4056   //            }
4057   //            remaining++;
4058   //            oldResolvedPaths[i] = affectedProject.getResolvedClasspath(true);
4059   //            JavaModelManager.containerPut(affectedProject, containerPath,
4060   // newContainer);
4061   //    }
4062   //            
4063   //    if (remaining == 0) return;
4064   //            
4065   //    // trigger model refresh
4066   //    try {
4067   //            JavaCore.run(new IWorkspaceRunnable() {
4068   //                    public void run(IProgressMonitor monitor) throws CoreException {
4069   //                            for(int i = 0; i < projectLength; i++){
4070   //            
4071   //                                    if (monitor != null && monitor.isCanceled()) return;
4072   //            
4073   //                                    JavaProject affectedProject = (JavaProject)modifiedProjects[i];
4074   //                                    if (affectedProject == null) continue; // was filtered out
4075   //                                            
4076   //                                    if (JavaModelManager.CP_RESOLVE_VERBOSE){
4077   //                                            System.out.println("CPContainer SET - updating affected project:
4078   // ["+affectedProject.getElementName()+"] due to setting container: " +
4079   // containerPath); //$NON-NLS-1$ //$NON-NLS-2$
4080   //                                    }
4081   //
4082   //                                    // force a refresh of the affected project (will compute deltas)
4083   //                                    affectedProject.setRawClasspath(
4084   //                                                    affectedProject.getRawClasspath(),
4085   //                                                    SetClasspathOperation.ReuseOutputLocation,
4086   //                                                    monitor,
4087   //                                                    !ResourcesPlugin.getWorkspace().isTreeLocked(), // can save resources
4088   //                                                    oldResolvedPaths[i],
4089   //                                                    false, // updating - no validation
4090   //                                                    false); // updating - no need to save
4091   //                            }
4092   //                    }
4093   //            },
4094   //            monitor);
4095   //    } catch(CoreException e) {
4096   //            if (JavaModelManager.CP_RESOLVE_VERBOSE){
4097   //                    System.out.println("CPContainer SET - FAILED DUE TO EXCEPTION:
4098   // "+containerPath); //$NON-NLS-1$
4099   //                    e.printStackTrace();
4100   //            }
4101   //            if (e instanceof JavaModelException) {
4102   //                    throw (JavaModelException)e;
4103   //            } else {
4104   //                    throw new JavaModelException(e);
4105   //            }
4106   //    } finally {
4107   //            for (int i = 0; i < projectLength; i++) {
4108   //                    if (respectiveContainers[i] == null) {
4109   //                            JavaModelManager.containerPut(affectedProjects[i], containerPath, null);
4110   // // reset init in progress marker
4111   //                    }
4112   //            }
4113   //    }
4114   //                                    
4115   //}
4116   /**
4117    * Sets the value of the given classpath variable. The path must have at
4118    * least one segment.
4119    * <p>
4120    * This functionality cannot be used while the resource tree is locked.
4121    * <p>
4122    * Classpath variable values are persisted locally to the workspace, and are
4123    * preserved from session to session.
4124    * <p>
4125    * 
4126    * @param variableName
4127    *            the name of the classpath variable
4128    * @param path
4129    *            the path
4130    * @see #getClasspathVariable
4131    * 
4132    * @deprecated - use API with IProgressMonitor
4133    */
4134   //public static void setClasspathVariable(String variableName, IPath path)
4135   //    throws JavaModelException {
4136   //
4137   //    setClasspathVariable(variableName, path, null);
4138   //}
4139   /**
4140    * Sets the value of the given classpath variable. The path must not be
4141    * null.
4142    * <p>
4143    * This functionality cannot be used while the resource tree is locked.
4144    * <p>
4145    * Classpath variable values are persisted locally to the workspace, and are
4146    * preserved from session to session.
4147    * <p>
4148    * Updating a variable with the same value has no effect.
4149    * 
4150    * @param variableName
4151    *            the name of the classpath variable
4152    * @param path
4153    *            the path
4154    * @param monitor
4155    *            a monitor to report progress
4156    * @see #getClasspathVariable
4157    */
4158   //public static void setClasspathVariable(
4159   //    String variableName,
4160   //    IPath path,
4161   //    IProgressMonitor monitor)
4162   //    throws JavaModelException {
4163   //
4164   //    if (path == null) Assert.isTrue(false, "Variable path cannot be null");
4165   // //$NON-NLS-1$
4166   //    setClasspathVariables(new String[]{variableName}, new IPath[]{ path },
4167   // monitor);
4168   //}
4169   /**
4170    * Sets the values of all the given classpath variables at once. Null paths
4171    * can be used to request corresponding variable removal.
4172    * <p>
4173    * This functionality cannot be used while the resource tree is locked.
4174    * <p>
4175    * Classpath variable values are persisted locally to the workspace, and are
4176    * preserved from session to session.
4177    * <p>
4178    * Updating a variable with the same value has no effect.
4179    * 
4180    * @param variableNames
4181    *            an array of names for the updated classpath variables
4182    * @param paths
4183    *            an array of path updates for the modified classpath variables
4184    *            (null meaning that the corresponding value will be removed
4185    * @param monitor
4186    *            a monitor to report progress
4187    * @see #getClasspathVariable
4188    * @since 2.0
4189    */
4190   //public static void setClasspathVariables(
4191   //    String[] variableNames,
4192   //    IPath[] paths,
4193   //    IProgressMonitor monitor)
4194   //    throws JavaModelException {
4195   //
4196   //    if (variableNames.length != paths.length) Assert.isTrue(false, "Variable
4197   // names and paths collections should have the same size"); //$NON-NLS-1$
4198   //    //TODO: should check that null cannot be used as variable paths
4199   //    updateVariableValues(variableNames, paths, monitor);
4200   //}
4201   /*
4202    * (non-Javadoc) Method declared on IExecutableExtension. Record any
4203    * necessary initialization data from the plugin.
4204    */
4205   public void setInitializationData(IConfigurationElement cfig,
4206       String propertyName, Object data) throws CoreException {
4207   }
4208
4209   /**
4210    * Sets the current table of options. All and only the options explicitly
4211    * included in the given table are remembered; all previous option settings
4212    * are forgotten, including ones not explicitly mentioned.
4213    * <p>
4214    * For a complete description of the configurable options, see
4215    * <code>getDefaultOptions</code>.
4216    * </p>
4217    * 
4218    * @param newOptions
4219    *            the new options (key type: <code>String</code>; value type:
4220    *            <code>String</code>), or <code>null</code> to reset all
4221    *            options to their default values
4222    * @see JavaCore#getDefaultOptions
4223    */
4224   public static void setOptions(Hashtable newOptions) {
4225
4226     // see #initializeDefaultPluginPreferences() for changing default
4227     // settings
4228     Preferences preferences = getPlugin().getPluginPreferences();
4229
4230     if (newOptions == null) {
4231       newOptions = JavaCore.getDefaultOptions();
4232     }
4233     Enumeration keys = newOptions.keys();
4234     while (keys.hasMoreElements()) {
4235       String key = (String) keys.nextElement();
4236       if (!JavaModelManager.OptionNames.contains(key))
4237         continue; // unrecognized option
4238       if (key.equals(CORE_ENCODING))
4239         continue; // skipped, contributed by resource prefs
4240       String value = (String) newOptions.get(key);
4241       preferences.setValue(key, value);
4242     }
4243
4244     // persist options
4245     getPlugin().savePluginPreferences();
4246   }
4247
4248   /**
4249    * Shutdown the JavaCore plug-in.
4250    * <p>
4251    * De-registers the JavaModelManager as a resource changed listener and save
4252    * participant.
4253    * <p>
4254    * 
4255    * @see org.eclipse.core.runtime.Plugin#shutdown()
4256    */
4257   // moved to PHPeclipsePlugin#shutdown()
4258   //public void shutdown() {
4259   //
4260   //    //savePluginPreferences();
4261   //    getPlugin().savePluginPreferences();
4262   //    IWorkspace workspace = ResourcesPlugin.getWorkspace();
4263   //    workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaProcessor);
4264   //    workspace.removeSaveParticipant(PHPeclipsePlugin.getDefault());
4265   //
4266   //    ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown();
4267   //}
4268   /**
4269    * Initiate the background indexing process. This should be deferred after
4270    * the plugin activation.
4271    */
4272   //private void startIndexing() {
4273   //
4274   //    JavaModelManager.getJavaModelManager().getIndexManager().reset();
4275   //}
4276   /**
4277    * Startup of the JavaCore plug-in.
4278    * <p>
4279    * Registers the JavaModelManager as a resource changed listener and save
4280    * participant. Starts the background indexing, and restore saved classpath
4281    * variable values.
4282    * <p>
4283    * 
4284    * @see org.eclipse.core.runtime.Plugin#startup()
4285    */
4286
4287   // moved to PHPeclipsePlugin#startup()
4288   //public void startup() {
4289   //            
4290   //    JavaModelManager manager = JavaModelManager.getJavaModelManager();
4291   //    try {
4292   //            manager.configurePluginDebugOptions();
4293   //
4294   //            // request state folder creation (workaround 19885)
4295   //            JavaCore.getPlugin().getStateLocation();
4296   //
4297   //            // retrieve variable values
4298   //            JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4299   // JavaModelManager.PluginPreferencesListener());
4300   //// TODO : jsurfer temp-del
4301   //// manager.loadVariablesAndContainers();
4302   //
4303   //            IWorkspace workspace = ResourcesPlugin.getWorkspace();
4304   //            workspace.addResourceChangeListener(
4305   //                    manager.deltaProcessor,
4306   //                    IResourceChangeEvent.PRE_AUTO_BUILD
4307   //                            | IResourceChangeEvent.POST_AUTO_BUILD
4308   //                            | IResourceChangeEvent.POST_CHANGE
4309   //                            | IResourceChangeEvent.PRE_DELETE
4310   //                            | IResourceChangeEvent.PRE_CLOSE);
4311   //
4312   //// startIndexing();
4313   //            workspace.addSaveParticipant(PHPeclipsePlugin.getDefault(), manager);
4314   //                    
4315   //    } catch (CoreException e) {
4316   //    } catch (RuntimeException e) {
4317   //            manager.shutdown();
4318   //            throw e;
4319   //    }
4320   //}
4321   /**
4322    * Internal updating of a variable values (null path meaning removal),
4323    * allowing to change multiple variable values at once.
4324    */
4325   //private static void updateVariableValues(
4326   //    String[] variableNames,
4327   //    IPath[] variablePaths,
4328   //    IProgressMonitor monitor) throws JavaModelException {
4329   //    
4330   //    if (monitor != null && monitor.isCanceled()) return;
4331   //            
4332   //    if (JavaModelManager.CP_RESOLVE_VERBOSE){
4333   //            System.out.println("CPVariable SET - setting variables: {" +
4334   // ProjectPrefUtil.toString(variableNames) //$NON-NLS-1$
4335   //                    + "} with values: " + ProjectPrefUtil.toString(variablePaths)); //$NON-NLS-1$
4336   //    }
4337   //
4338   //    int varLength = variableNames.length;
4339   //            
4340   //    // gather classpath information for updating
4341   //    final HashMap affectedProjects = new HashMap(5);
4342   //    JavaModelManager manager = JavaModelManager.getJavaModelManager();
4343   //    IJavaModel model = manager.getJavaModel();
4344   //    
4345   //    // filter out unmodified variables
4346   //    int discardCount = 0;
4347   //    for (int i = 0; i < varLength; i++){
4348   //            String variableName = variableNames[i];
4349   //            IPath oldPath = (IPath)JavaModelManager.variableGet(variableName); // if
4350   // reentering will provide previous session value
4351   //            if (oldPath == JavaModelManager.VariableInitializationInProgress){
4352   //                    IPath previousPath =
4353   // (IPath)JavaModelManager.PreviousSessionVariables.get(variableName);
4354   //                    if (previousPath != null){
4355   //                            if (JavaModelManager.CP_RESOLVE_VERBOSE){
4356   //                                    System.out.println("CPVariable INIT - reentering access to variable: " +
4357   // variableName+ " during its initialization, will see previous value: "+
4358   // previousPath); //$NON-NLS-1$ //$NON-NLS-2$
4359   //                            }
4360   //                            JavaModelManager.variablePut(variableName, previousPath); // replace
4361   // value so reentering calls are seeing old value
4362   //                    }
4363   //                    oldPath = null; //33695 - cannot filter out restored variable, must
4364   // update affected project to reset cached CP
4365   //            }
4366   //            if (oldPath != null && oldPath.equals(variablePaths[i])){
4367   //                    variableNames[i] = null;
4368   //                    discardCount++;
4369   //            }
4370   //    }
4371   //    if (discardCount > 0){
4372   //            if (discardCount == varLength) return;
4373   //            int changedLength = varLength - discardCount;
4374   //            String[] changedVariableNames = new String[changedLength];
4375   //            IPath[] changedVariablePaths = new IPath[changedLength];
4376   //            for (int i = 0, index = 0; i < varLength; i++){
4377   //                    if (variableNames[i] != null){
4378   //                            changedVariableNames[index] = variableNames[i];
4379   //                            changedVariablePaths[index] = variablePaths[i];
4380   //                            index++;
4381   //                    }
4382   //            }
4383   //            variableNames = changedVariableNames;
4384   //            variablePaths = changedVariablePaths;
4385   //            varLength = changedLength;
4386   //    }
4387   //            
4388   //    if (monitor != null && monitor.isCanceled()) return;
4389   //
4390   //    if (model != null) {
4391   //            IJavaProject[] projects = model.getJavaProjects();
4392   //            nextProject : for (int i = 0, projectLength = projects.length; i <
4393   // projectLength; i++){
4394   //                    IJavaProject project = projects[i];
4395   //                                            
4396   //                    // check to see if any of the modified variables is present on the
4397   // classpath
4398   //                    IClasspathEntry[] classpath = project.getRawClasspath();
4399   //                    for (int j = 0, cpLength = classpath.length; j < cpLength; j++){
4400   //                                    
4401   //                            IClasspathEntry entry = classpath[j];
4402   //                            for (int k = 0; k < varLength; k++){
4403   //    
4404   //                                    String variableName = variableNames[k];
4405   //                                    if (entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE){
4406   //    
4407   //                                            if (variableName.equals(entry.getPath().segment(0))){
4408   //                                                    affectedProjects.put(project, project.getResolvedClasspath(true));
4409   //                                                    continue nextProject;
4410   //                                            }
4411   //                                            IPath sourcePath, sourceRootPath;
4412   //                                            if (((sourcePath = entry.getSourceAttachmentPath()) != null &&
4413   // variableName.equals(sourcePath.segment(0)))
4414   //                                                    || ((sourceRootPath = entry.getSourceAttachmentRootPath()) != null &&
4415   // variableName.equals(sourceRootPath.segment(0)))) {
4416   //    
4417   //                                                    affectedProjects.put(project, project.getResolvedClasspath(true));
4418   //                                                    continue nextProject;
4419   //                                            }
4420   //                                    }
4421   //                            }
4422   //                    }
4423   //            }
4424   //    }
4425   //    // update variables
4426   //    for (int i = 0; i < varLength; i++){
4427   //            JavaModelManager.variablePut(variableNames[i], variablePaths[i]);
4428   //    }
4429   //    final String[] dbgVariableNames = variableNames;
4430   //                            
4431   //    // update affected project classpaths
4432   //    if (!affectedProjects.isEmpty()) {
4433   //            try {
4434   //                    JavaCore_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt_DeleteIt.run(
4435   //                            new IWorkspaceRunnable() {
4436   //                                    public void run(IProgressMonitor monitor) throws CoreException {
4437   //                                            // propagate classpath change
4438   //                                            Iterator projectsToUpdate = affectedProjects.keySet().iterator();
4439   //                                            while (projectsToUpdate.hasNext()) {
4440   //                    
4441   //                                                    if (monitor != null && monitor.isCanceled()) return;
4442   //                    
4443   //                                                    JavaProject project = (JavaProject) projectsToUpdate.next();
4444   //
4445   //                                                    if (JavaModelManager.CP_RESOLVE_VERBOSE){
4446   //                                                            System.out.println("CPVariable SET - updating affected project:
4447   // ["+project.getElementName()+"] due to setting variables: "+
4448   // ProjectPrefUtil.toString(dbgVariableNames)); //$NON-NLS-1$ //$NON-NLS-2$
4449   //                                                    }
4450   //                                                            
4451   //                                                    project
4452   //                                                            .setRawClasspath(
4453   //                                                                    project.getRawClasspath(),
4454   //                                                                    SetClasspathOperation.ReuseOutputLocation,
4455   //                                                                    null, // don't call beginTask on the monitor (see
4456   // http://bugs.eclipse.org/bugs/show_bug.cgi?id=3717)
4457   //                                                                    !ResourcesPlugin.getWorkspace().isTreeLocked(), // can change resources
4458   //                                                                    (IClasspathEntry[]) affectedProjects.get(project),
4459   //                                                                    false, // updating - no validation
4460   //                                                                    false); // updating - no need to save
4461   //                                            }
4462   //                                    }
4463   //                            },
4464   //                            monitor);
4465   //            } catch (CoreException e) {
4466   //                    if (JavaModelManager.CP_RESOLVE_VERBOSE){
4467   //                            System.out.println("CPVariable SET - FAILED DUE TO EXCEPTION:
4468   // "+ProjectPrefUtil.toString(dbgVariableNames)); //$NON-NLS-1$
4469   //                            e.printStackTrace();
4470   //                    }
4471   //                    if (e instanceof JavaModelException) {
4472   //                            throw (JavaModelException)e;
4473   //                    } else {
4474   //                            throw new JavaModelException(e);
4475   //                    }
4476   //            }
4477   //    }
4478   //}
4479   /*
4480    * (non-Javadoc) Startup the JavaCore plug-in. <p> Registers the
4481    * JavaModelManager as a resource changed listener and save participant.
4482    * Starts the background indexing, and restore saved classpath variable
4483    * values. <p> @throws Exception
4484    * 
4485    * @see org.eclipse.core.runtime.Plugin#start(BundleContext)
4486    */
4487   //public static void start(final Plugin plugin, BundleContext context)
4488   // throws Exception {
4489   //// super.start(context);
4490   //    
4491   //    final JavaModelManager manager = JavaModelManager.getJavaModelManager();
4492   //    try {
4493   //            manager.configurePluginDebugOptions();
4494   //
4495   //            // request state folder creation (workaround 19885)
4496   //            JavaCore.getPlugin().getStateLocation();
4497   //
4498   //            // retrieve variable values
4499   //            //JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new
4500   // JavaModelManager.PluginPreferencesListener());
4501   //// manager.loadVariablesAndContainers();
4502   //
4503   //            final IWorkspace workspace = ResourcesPlugin.getWorkspace();
4504   //            workspace.addResourceChangeListener(
4505   //                    manager.deltaState,
4506   //                    IResourceChangeEvent.PRE_BUILD
4507   //                            | IResourceChangeEvent.POST_BUILD
4508   //                            | IResourceChangeEvent.POST_CHANGE
4509   //                            | IResourceChangeEvent.PRE_DELETE
4510   //                            | IResourceChangeEvent.PRE_CLOSE);
4511   //
4512   //// startIndexing();
4513   //            
4514   //            // process deltas since last activated in indexer thread so that indexes
4515   // are up-to-date.
4516   //            // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658
4517   //            Job processSavedState = new Job(ProjectPrefUtil.bind("savedState.jobName")) {
4518   // //$NON-NLS-1$
4519   //                    protected IStatus run(IProgressMonitor monitor) {
4520   //                            try {
4521   //                                    // add save participant and process delta atomically
4522   //                                    // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59937
4523   //                                    workspace.run(
4524   //                                            new IWorkspaceRunnable() {
4525   //                                                    public void run(IProgressMonitor progress) throws CoreException {
4526   //// ISavedState savedState = workspace.addSaveParticipant(JavaCore.this,
4527   // manager);
4528   //                                                            ISavedState savedState = workspace.addSaveParticipant(plugin, manager);
4529   //                                                            if (savedState != null) {
4530   //                                                                    // the event type coming from the saved state is always POST_AUTO_BUILD
4531   //                                                                    // force it to be POST_CHANGE so that the delta processor can handle it
4532   //                                                                    manager.deltaState.getDeltaProcessor().overridenEventType =
4533   // IResourceChangeEvent.POST_CHANGE;
4534   //                                                                    savedState.processResourceChangeEvents(manager.deltaState);
4535   //                                                            }
4536   //                                                    }
4537   //                                            },
4538   //                                            monitor);
4539   //                            } catch (CoreException e) {
4540   //                                    return e.getStatus();
4541   //                            }
4542   //                            return Status.OK_STATUS;
4543   //                    }
4544   //            };
4545   //            processSavedState.setSystem(true);
4546   //            processSavedState.setPriority(Job.SHORT); // process asap
4547   //            processSavedState.schedule();
4548   //    } catch (RuntimeException e) {
4549   //            manager.shutdown();
4550   //            throw e;
4551   //    }
4552   //}
4553   /*
4554    * (non-Javadoc) Shutdown the JavaCore plug-in. <p> De-registers the
4555    * JavaModelManager as a resource changed listener and save participant. <p>
4556    * 
4557    * @see org.eclipse.core.runtime.Plugin#stop(BundleContext)
4558    */
4559 //  public static void stop(Plugin plugin, BundleContext context)
4560 //      throws Exception {
4561 //    try {
4562 //      plugin.savePluginPreferences();
4563 //      IWorkspace workspace = ResourcesPlugin.getWorkspace();
4564 //      workspace.removeResourceChangeListener(JavaModelManager
4565 //          .getJavaModelManager().deltaState);
4566 //      workspace.removeSaveParticipant(plugin);
4567 //
4568 //      JavaModelManager.getJavaModelManager().shutdown();
4569 //    } finally {
4570 //      // ensure we call super.stop as the last thing
4571 //      //              super.stop(context);
4572 //    }
4573 //  }
4574 }