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