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