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