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