6e8531b1b8532ab3d1b06736427f58a66cfe14c7
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / core / JavaCore.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *     IBM Corporation - added the following constants:
11  *                                 COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE
12  *                                 COMPILER_PB_STATIC_ACCESS_RECEIVER
13  *                                 COMPILER_TASK_TAGS
14  *                                 CORE_CIRCULAR_CLASSPATH
15  *                                 CORE_INCOMPLETE_CLASSPATH
16  *     IBM Corporation - added run(IWorkspaceRunnable, IProgressMonitor)
17  *     IBM Corporation - added exclusion patterns to source classpath entries
18  *     IBM Corporation - added specific output location to source classpath entries
19  *     IBM Corporation - added the following constants:
20  *                                 CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER
21  *                                 CLEAN
22  *     IBM Corporation - added getClasspathContainerInitializer(String)
23  *     IBM Corporation - added the following constants:
24  *                                 CODEASSIST_ARGUMENT_PREFIXES
25  *                                 CODEASSIST_ARGUMENT_SUFFIXES
26  *                                 CODEASSIST_FIELD_PREFIXES
27  *                                 CODEASSIST_FIELD_SUFFIXES
28  *                                 CODEASSIST_LOCAL_PREFIXES
29  *                                 CODEASSIST_LOCAL_SUFFIXES
30  *                                 CODEASSIST_STATIC_FIELD_PREFIXES
31  *                                 CODEASSIST_STATIC_FIELD_SUFFIXES
32  *                                 COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION
33  *******************************************************************************/
34 package net.sourceforge.phpdt.core;
35
36 import java.util.Collection;
37 import java.util.Enumeration;
38 import java.util.HashSet;
39 import java.util.Hashtable;
40 import java.util.Map;
41
42 import net.sourceforge.phpdt.internal.core.BatchOperation;
43 import net.sourceforge.phpdt.internal.core.BufferManager;
44 import net.sourceforge.phpdt.internal.core.JavaModel;
45 import net.sourceforge.phpdt.internal.core.JavaModelManager;
46 import net.sourceforge.phpdt.internal.core.Region;
47
48 import org.eclipse.core.resources.IFile;
49 import org.eclipse.core.resources.IFolder;
50 import org.eclipse.core.resources.IMarker;
51 import org.eclipse.core.resources.IMarkerDelta;
52 import org.eclipse.core.resources.IProject;
53 import org.eclipse.core.resources.IResource;
54 import org.eclipse.core.resources.IResourceChangeEvent;
55 import org.eclipse.core.resources.IWorkspace;
56 import org.eclipse.core.resources.IWorkspaceRoot;
57 import org.eclipse.core.resources.IWorkspaceRunnable;
58 import org.eclipse.core.resources.ResourcesPlugin;
59 import org.eclipse.core.runtime.CoreException;
60 import org.eclipse.core.runtime.IConfigurationElement;
61 import org.eclipse.core.runtime.IExecutableExtension;
62 import org.eclipse.core.runtime.IPluginDescriptor;
63 import org.eclipse.core.runtime.IProgressMonitor;
64 import org.eclipse.core.runtime.Plugin;
65 import org.eclipse.core.runtime.Preferences;
66
67
68 /**
69  * The plug-in runtime class for the Java model plug-in containing the core
70  * (UI-free) support for Java projects.
71  * <p>
72  * Like all plug-in runtime classes (subclasses of <code>Plugin</code>), this
73  * class is automatically instantiated by the platform when the plug-in gets
74  * activated. Clients must not attempt to instantiate plug-in runtime classes
75  * directly.
76  * </p>
77  * <p>
78  * The single instance of this class can be accessed from any plug-in declaring
79  * the Java model plug-in as a prerequisite via 
80  * <code>JavaCore.getJavaCore()</code>. The Java model plug-in will be activated
81  * automatically if not already active.
82  * </p>
83  */
84 public final class JavaCore extends Plugin implements IExecutableExtension {
85
86         private static Plugin JAVA_CORE_PLUGIN = null; 
87         /**
88          * The plug-in identifier of the Java core support
89          * (value <code>"org.eclipse.jdt.core"</code>).
90          */
91         public static final String PLUGIN_ID = "org.eclipse.jdt.core" ; //$NON-NLS-1$
92
93         /**
94          * The identifier for the Java builder
95          * (value <code>"org.eclipse.jdt.core.javabuilder"</code>).
96          */
97         public static final String BUILDER_ID = PLUGIN_ID + ".javabuilder" ; //$NON-NLS-1$
98
99         /**
100          * The identifier for the Java model
101          * (value <code>"org.eclipse.jdt.core.javamodel"</code>).
102          */
103         public static final String MODEL_ID = PLUGIN_ID + ".javamodel" ; //$NON-NLS-1$
104
105         /**
106          * The identifier for the Java nature
107          * (value <code>"org.eclipse.jdt.core.javanature"</code>).
108          * The presence of this nature on a project indicates that it is 
109          * Java-capable.
110          *
111          * @see org.eclipse.core.resources.IProject#hasNature(java.lang.String)
112          */
113         public static final String NATURE_ID = PLUGIN_ID + ".javanature" ; //$NON-NLS-1$
114
115         /**
116          * Name of the handle id attribute in a Java marker.
117          */
118         protected static final String ATT_HANDLE_ID =
119                 "org.eclipse.jdt.internal.core.JavaModelManager.handleId" ; //$NON-NLS-1$
120
121         // *************** Possible IDs for configurable options. ********************
122
123         /**
124          * Possible  configurable option ID.
125          * @see #getDefaultOptions()
126          */
127         public static final String COMPILER_LOCAL_VARIABLE_ATTR = PLUGIN_ID + ".compiler.debug.localVariable"; //$NON-NLS-1$
128         /**
129          * Possible  configurable option ID.
130          * @see #getDefaultOptions()
131          */
132         public static final String COMPILER_LINE_NUMBER_ATTR = PLUGIN_ID + ".compiler.debug.lineNumber"; //$NON-NLS-1$
133         /**
134          * Possible  configurable option ID.
135          * @see #getDefaultOptions
136          */
137         public static final String COMPILER_SOURCE_FILE_ATTR = PLUGIN_ID + ".compiler.debug.sourceFile"; //$NON-NLS-1$
138         /**
139          * Possible  configurable option ID.
140          * @see #getDefaultOptions
141          */
142         public static final String COMPILER_CODEGEN_UNUSED_LOCAL = PLUGIN_ID + ".compiler.codegen.unusedLocal"; //$NON-NLS-1$
143         /**
144          * Possible  configurable option ID.
145          * @see #getDefaultOptions
146          */
147         public static final String COMPILER_CODEGEN_TARGET_PLATFORM = PLUGIN_ID + ".compiler.codegen.targetPlatform"; //$NON-NLS-1$
148         /**
149          * Possible  configurable option ID.
150          * @see #getDefaultOptions
151          */
152         public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID + ".compiler.problem.unreachableCode"; //$NON-NLS-1$
153         /**
154          * Possible  configurable option ID.
155          * @see #getDefaultOptions
156          */
157         public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID + ".compiler.problem.invalidImport"; //$NON-NLS-1$
158         /**
159          * Possible  configurable option ID.
160          * @see #getDefaultOptions
161          */
162         public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID + ".compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
163         /**
164          * Possible  configurable option ID.
165          * @see #getDefaultOptions
166          */
167         public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID + ".compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
168         /**
169          * Possible  configurable option ID.
170          * @see #getDefaultOptions
171          */
172         public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID + ".compiler.problem.deprecation"; //$NON-NLS-1$
173         /**
174          * Possible  configurable option ID.
175          * @see #getDefaultOptions
176          * @since 2.1
177          */
178         public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID + ".compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
179         /**
180          * Possible  configurable option ID.
181          * @see #getDefaultOptions
182          */
183         public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID + ".compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
184         /**
185          * Possible  configurable option ID.
186          * @see #getDefaultOptions
187          */
188         public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID + ".compiler.problem.unusedLocal"; //$NON-NLS-1$
189         /**
190          * Possible  configurable option ID.
191          * @see #getDefaultOptions
192          */
193         public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID + ".compiler.problem.unusedParameter"; //$NON-NLS-1$
194         /**
195          * Possible  configurable option ID.
196          * @see #getDefaultOptions
197          * @since 2.1
198          */
199         public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID + ".compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
200         /**
201          * Possible  configurable option ID.
202          * @see #getDefaultOptions
203          * @since 2.1
204          */
205         public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID + ".compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
206         /**
207          * Possible  configurable option ID.
208          * @see #getDefaultOptions
209          * @since 2.0
210          */
211         public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID + ".compiler.problem.unusedImport"; //$NON-NLS-1$
212         /**
213          * Possible  configurable option ID.
214          * @see #getDefaultOptions
215          */
216         public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID + ".compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
217         /**
218          * Possible  configurable option ID.
219          * @see #getDefaultOptions
220          * @since 2.0
221          */
222         public static final String COMPILER_PB_NON_NLS_STRING_LITERAL = PLUGIN_ID + ".compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
223         /**
224          * Possible  configurable option ID.
225          * @see #getDefaultOptions
226          * @since 2.0
227          */
228         public static final String COMPILER_PB_ASSERT_IDENTIFIER = PLUGIN_ID + ".compiler.problem.assertIdentifier"; //$NON-NLS-1$
229         /**
230          * Possible  configurable option ID.
231          * @see #getDefaultOptions
232          * @since 2.1
233          */
234         public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID + ".compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
235         /**
236          * Possible  configurable option ID.
237          * @see #getDefaultOptions
238          * @since 2.1
239          */
240         public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID + ".compiler.problem.noEffectAssignment"; //$NON-NLS-1$
241         /**
242          * Possible  configurable option ID.
243          * @see #getDefaultOptions
244          * @since 2.1
245          */
246         public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
247         /**
248          * Possible  configurable option ID.
249          * @see #getDefaultOptions
250          * @since 2.1
251          */
252         public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
253         /**
254          * Possible  configurable option ID.
255          * @see #getDefaultOptions
256          * @since 2.1
257          */
258         public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
259         /**
260          * Possible  configurable option ID.
261          * @see #getDefaultOptions
262          * @since 2.0
263          */
264         public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID + ".compiler.maxProblemPerUnit"; //$NON-NLS-1$
265         /**
266          * Possible  configurable option ID.
267          * @see #getDefaultOptions
268          * @since 2.0
269          */
270         public static final String COMPILER_SOURCE = PLUGIN_ID + ".compiler.source"; //$NON-NLS-1$
271         /**
272          * Possible  configurable option ID.
273          * @see #getDefaultOptions
274          * @since 2.0
275          */
276         public static final String COMPILER_COMPLIANCE = PLUGIN_ID + ".compiler.compliance"; //$NON-NLS-1$
277         /**
278          * Possible  configurable option ID.
279          * @see #getDefaultOptions
280          * @since 2.1
281          */
282         public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID + ".compiler.taskPriorities"; //$NON-NLS-1$
283         /**
284          * Possible  configurable option value for COMPILER_TASK_PRIORITIES.
285          * @see #getDefaultOptions
286          * @since 2.1
287          */
288         public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$
289         /**
290          * Possible  configurable option value for COMPILER_TASK_PRIORITIES.
291          * @see #getDefaultOptions
292          * @since 2.1
293          */
294         public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$
295         /**
296          * Possible  configurable option value for COMPILER_TASK_PRIORITIES.
297          * @see #getDefaultOptions
298          * @since 2.1
299          */
300         public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$
301         /**
302          * Possible  configurable option ID.
303          * @see #getDefaultOptions
304          * @since 2.1
305          */
306         public static final String COMPILER_TASK_TAGS = PLUGIN_ID + ".compiler.taskTags"; //$NON-NLS-1$
307         /**
308          * Possible  configurable option ID.
309          * @see #getDefaultOptions
310          */
311         public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder"; //$NON-NLS-1$
312         /**
313          * Possible  configurable option ID.
314          * @see #getDefaultOptions
315          * @since 2.0
316          */
317         public static final String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER = PLUGIN_ID + ".builder.resourceCopyExclusionFilter"; //$NON-NLS-1$
318         /**
319          * Possible  configurable option ID.
320          * @see #getDefaultOptions
321          * @since 2.1
322          */
323         public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID + ".builder.duplicateResourceTask"; //$NON-NLS-1$
324         /**
325          * Possible  configurable option ID.
326          * @see #getDefaultOptions
327          * @since 2.1
328          */
329         public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID + ".builder.cleanOutputFolder"; //$NON-NLS-1$                
330         /**
331          * Possible  configurable option ID.
332          * @see #getDefaultOptions
333          * @since 2.1
334          */
335         public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID + ".incompleteClasspath"; //$NON-NLS-1$
336         /**
337          * Possible  configurable option ID.
338          * @see #getDefaultOptions
339          * @since 2.1
340          */
341         public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID + ".circularClasspath"; //$NON-NLS-1$
342         /**
343          * Possible  configurable option ID.
344          * @see #getDefaultOptions
345          * @since 2.0
346          */
347         public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID + ".builder.invalidClasspath"; //$NON-NLS-1$
348         /**
349          * Possible  configurable option ID.
350          * @see #getDefaultOptions
351          * @since 2.0
352          */
353         public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; //$NON-NLS-1$
354         /**
355          * Possible  configurable option ID.
356          * @see #getDefaultOptions
357          * @since 2.1 
358          */
359         public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID + ".classpath.exclusionPatterns"; //$NON-NLS-1$
360         /**
361          * Possible  configurable option ID.
362          * @see #getDefaultOptions
363          * @since 2.1
364          */
365         public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID + ".classpath.multipleOutputLocations"; //$NON-NLS-1$
366         /**
367          * Default task tag
368          * @since 2.1
369          */
370         public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$
371         /**
372          * Default task priority
373          * @since 2.1
374          */
375         public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; //$NON-NLS-1$
376         /**
377          * Possible  configurable option ID.
378          * @see #getDefaultOptions
379          * @since 2.0
380          */
381         public static final String FORMATTER_NEWLINE_OPENING_BRACE = PLUGIN_ID + ".formatter.newline.openingBrace"; //$NON-NLS-1$
382         /**
383          * Possible  configurable option ID.
384          * @see #getDefaultOptions
385          * @since 2.0
386          */
387         public static final String FORMATTER_NEWLINE_CONTROL = PLUGIN_ID + ".formatter.newline.controlStatement"; //$NON-NLS-1$
388         /**
389          * Possible  configurable option ID.
390          * @see #getDefaultOptions
391          * @since 2.0
392          */
393         public static final String FORMATTER_NEWLINE_ELSE_IF = PLUGIN_ID + ".formatter.newline.elseIf"; //$NON-NLS-1$
394         /**
395          * Possible  configurable option ID.
396          * @see #getDefaultOptions
397          * @since 2.0
398          */
399         public static final String FORMATTER_NEWLINE_EMPTY_BLOCK = PLUGIN_ID + ".formatter.newline.emptyBlock"; //$NON-NLS-1$
400         /**
401          * Possible  configurable option ID.
402          * @see #getDefaultOptions
403          * @since 2.0
404          */
405         public static final String FORMATTER_CLEAR_BLANK_LINES = PLUGIN_ID + ".formatter.newline.clearAll"; //$NON-NLS-1$
406         /**
407          * Possible  configurable option ID.
408          * @see #getDefaultOptions
409          * @since 2.0
410          */
411         public static final String FORMATTER_LINE_SPLIT = PLUGIN_ID + ".formatter.lineSplit"; //$NON-NLS-1$
412         /**
413          * Possible  configurable option ID.
414          * @see #getDefaultOptions
415          * @since 2.0
416          */
417         public static final String FORMATTER_COMPACT_ASSIGNMENT = PLUGIN_ID + ".formatter.style.assignment"; //$NON-NLS-1$
418         /**
419          * Possible  configurable option ID.
420          * @see #getDefaultOptions
421          * @since 2.0
422          */
423         public static final String FORMATTER_TAB_CHAR = PLUGIN_ID + ".formatter.tabulation.char"; //$NON-NLS-1$
424         /**
425          * Possible  configurable option ID.
426          * @see #getDefaultOptions
427          * @since 2.0
428          */
429         public static final String FORMATTER_TAB_SIZE = PLUGIN_ID + ".formatter.tabulation.size"; //$NON-NLS-1$
430         /**
431          * Possible configurable option ID
432          * @see #getDefaultOptions
433          * @since 2.1
434          */
435         public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID + ".formatter.space.castexpression"; //$NON-NLS-1$
436         /**
437          * Possible  configurable option ID.
438          * @see #getDefaultOptions
439          * @since 2.0
440          */
441         public static final String CODEASSIST_VISIBILITY_CHECK = PLUGIN_ID + ".codeComplete.visibilityCheck"; //$NON-NLS-1$
442         /**
443          * Possible  configurable option ID.
444          * @see #getDefaultOptions
445          * @since 2.0
446          */
447         public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID + ".codeComplete.forceImplicitQualification"; //$NON-NLS-1$
448         /**
449          * Possible  configurable option ID.
450          * @see #getDefaultOptions
451          * @since 2.1
452          */
453         public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.fieldPrefixes"; //$NON-NLS-1$
454         /**
455          * Possible  configurable option ID.
456          * @see #getDefaultOptions
457          * @since 2.1
458          */
459         public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
460         /**
461          * Possible  configurable option ID.
462          * @see #getDefaultOptions
463          * @since 2.1
464          */
465         public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID + ".codeComplete.localPrefixes"; //$NON-NLS-1$
466         /**
467          * Possible  configurable option ID.
468          * @see #getDefaultOptions
469          * @since 2.1
470          */
471         public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID + ".codeComplete.argumentPrefixes"; //$NON-NLS-1$
472         /**
473          * Possible  configurable option ID.
474          * @see #getDefaultOptions
475          * @since 2.1
476          */
477         public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.fieldSuffixes"; //$NON-NLS-1$
478         /**
479          * Possible  configurable option ID.
480          * @see #getDefaultOptions
481          * @since 2.1
482          */
483         public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
484         /**
485          * Possible  configurable option ID.
486          * @see #getDefaultOptions
487          * @since 2.1
488          */
489         public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID + ".codeComplete.localSuffixes"; //$NON-NLS-1$
490         /**
491          * Possible  configurable option ID.
492          * @see #getDefaultOptions
493          * @since 2.1
494          */
495         public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID + ".codeComplete.argumentSuffixes"; //$NON-NLS-1$
496
497         // *************** Possible values for configurable options. ********************
498         
499         /**
500          * Possible  configurable option value.
501          * @see #getDefaultOptions
502          */
503         public static final String GENERATE = "generate"; //$NON-NLS-1$
504         /**
505          * Possible  configurable option value.
506          * @see #getDefaultOptions
507          */
508         public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
509         /**
510          * Possible  configurable option value.
511          * @see #getDefaultOptions
512          */
513         public static final String PRESERVE = "preserve"; //$NON-NLS-1$
514         /**
515          * Possible  configurable option value.
516          * @see #getDefaultOptions
517          */
518         public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
519         /**
520          * Possible  configurable option value.
521          * @see #getDefaultOptions
522          */
523         public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$
524         /**
525          * Possible  configurable option value.
526          * @see #getDefaultOptions
527          */
528         public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$
529         /**
530          * Possible  configurable option value.
531          * @see #getDefaultOptions
532          * @since 2.0
533          */
534         public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
535         /**
536          * Possible  configurable option value.
537          * @see #getDefaultOptions
538          * @since 2.0
539          */
540         public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
541         /**
542          * Possible  configurable option value.
543          * @see #getDefaultOptions
544          * @since 2.0
545          */
546         public static final String ABORT = "abort"; //$NON-NLS-1$
547         /**
548          * Possible  configurable option value.
549          * @see #getDefaultOptions
550          */
551         public static final String ERROR = "error"; //$NON-NLS-1$
552         /**
553          * Possible  configurable option value.
554          * @see #getDefaultOptions
555          */
556         public static final String WARNING = "warning"; //$NON-NLS-1$
557         /**
558          * Possible  configurable option value.
559          * @see #getDefaultOptions
560          */
561         public static final String IGNORE = "ignore"; //$NON-NLS-1$
562         /**
563          * Possible  configurable option value.
564          * @see #getDefaultOptions
565          */
566         public static final String COMPUTE = "compute"; //$NON-NLS-1$
567         /**
568          * Possible  configurable option value.
569          * @see #getDefaultOptions
570          * @since 2.0
571          */
572         public static final String INSERT = "insert"; //$NON-NLS-1$
573         /**
574          * Possible  configurable option value.
575          * @see #getDefaultOptions
576          * @since 2.0
577          */
578         public static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$
579         /**
580          * Possible  configurable option value.
581          * @see #getDefaultOptions
582          * @since 2.0
583          */
584         public static final String PRESERVE_ONE = "preserve one"; //$NON-NLS-1$
585         /**
586          * Possible  configurable option value.
587          * @see #getDefaultOptions
588          * @since 2.0
589          */
590         public static final String CLEAR_ALL = "clear all"; //$NON-NLS-1$
591         /**
592          * Possible  configurable option value.
593          * @see #getDefaultOptions
594          * @since 2.0
595          */
596         public static final String NORMAL = "normal"; //$NON-NLS-1$
597         /**
598          * Possible  configurable option value.
599          * @see #getDefaultOptions
600          * @since 2.0
601          */
602         public static final String COMPACT = "compact"; //$NON-NLS-1$
603         /**
604          * Possible  configurable option value.
605          * @see #getDefaultOptions
606          * @since 2.0
607          */
608         public static final String TAB = "tab"; //$NON-NLS-1$
609         /**
610          * Possible  configurable option value.
611          * @see #getDefaultOptions
612          * @since 2.0
613          */
614         public static final String SPACE = "space"; //$NON-NLS-1$
615         /**
616          * Possible  configurable option value.
617          * @see #getDefaultOptions
618          * @since 2.0
619          */
620         public static final String ENABLED = "enabled"; //$NON-NLS-1$
621         /**
622          * Possible  configurable option value.
623          * @see #getDefaultOptions
624          * @since 2.0
625          */
626         public static final String DISABLED = "disabled"; //$NON-NLS-1$
627         /**
628          * Possible  configurable option value.
629          * @see #getDefaultOptions
630          * @since 2.1
631          */
632         public static final String CLEAN = "clean"; //$NON-NLS-1$
633         
634         /**
635          * Creates the Java core plug-in.
636          * @since 2.1
637          */
638         public JavaCore(IPluginDescriptor pluginDescriptor) {
639                 super(pluginDescriptor);
640                 JAVA_CORE_PLUGIN = this;
641         }
642
643         /**
644          * Adds the given listener for changes to Java elements.
645          * Has no effect if an identical listener is already registered.
646          *
647          * This listener will only be notified during the POST_CHANGE resource change notification
648          * and any reconcile operation (POST_RECONCILE).
649          * For finer control of the notification, use <code>addElementChangedListener(IElementChangedListener,int)</code>,
650          * which allows to specify a different eventMask.
651          * 
652          * @see ElementChangedEvent
653          * @param listener the listener
654          */
655         public static void addElementChangedListener(IElementChangedListener listener) {
656                 addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE | ElementChangedEvent.POST_RECONCILE);
657         }
658
659         /**
660          * Adds the given listener for changes to Java elements.
661          * Has no effect if an identical listener is already registered.
662          * After completion of this method, the given listener will be registered for exactly
663          * the specified events.  If they were previously registered for other events, they
664          * will be deregistered.  
665          * <p>
666          * Once registered, a listener starts receiving notification of changes to
667          * java elements in the model. The listener continues to receive 
668          * notifications until it is replaced or removed. 
669          * </p>
670          * <p>
671          * Listeners can listen for several types of event as defined in <code>ElementChangeEvent</code>.
672          * Clients are free to register for any number of event types however if they register
673          * for more than one, it is their responsibility to ensure they correctly handle the
674          * case where the same java element change shows up in multiple notifications.  
675          * Clients are guaranteed to receive only the events for which they are registered.
676          * </p>
677          * 
678          * @param listener the listener
679          * @param eventMask the bit-wise OR of all event types of interest to the listener
680          * @see IElementChangedListener
681          * @see ElementChangedEvent
682          * @see #removeElementChangedListener(IElementChangedListener)
683          * @since 2.0
684          */
685         public static void addElementChangedListener(IElementChangedListener listener, int eventMask) {
686                 JavaModelManager.getJavaModelManager().addElementChangedListener(listener, eventMask);
687         }
688
689         /**
690          * Configures the given marker attribute map for the given Java element.
691          * Used for markers, which denote a Java element rather than a resource.
692          *
693          * @param attributes the mutable marker attribute map (key type: <code>String</code>,
694          *   value type: <code>String</code>)
695          * @param element the Java element for which the marker needs to be configured
696          */
697         public static void addJavaElementMarkerAttributes(
698                 Map attributes,
699                 IJavaElement element) {
700 //              if (element instanceof IMember)
701 //                      element = ((IMember) element).getClassFile();
702                 if (attributes != null && element != null)
703                         attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier());
704         }
705         
706         /**
707          * Configures the given marker for the given Java element.
708          * Used for markers, which denote a Java element rather than a resource.
709          *
710          * @param marker the marker to be configured
711          * @param element the Java element for which the marker needs to be configured
712          * @exception CoreException if the <code>IMarker.setAttribute</code> on the marker fails
713          */
714         public void configureJavaElementMarker(IMarker marker, IJavaElement element)
715                 throws CoreException {
716 //              if (element instanceof IMember)
717 //                      element = ((IMember) element).getClassFile();
718                 if (marker != null && element != null)
719                         marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier());
720         }
721         
722         /**
723          * Returns the Java model element corresponding to the given handle identifier
724          * generated by <code>IJavaElement.getHandleIdentifier()</code>, or
725          * <code>null</code> if unable to create the associated element.
726          */
727         public static IJavaElement create(String handleIdentifier) {
728                 if (handleIdentifier == null) {
729                         return null;
730                 }
731                 try {
732                         return JavaModelManager.getJavaModelManager().getHandleFromMemento(handleIdentifier);
733                 } catch (JavaModelException e) {
734                         return null;
735                 }
736         }
737         /**
738          * Returns the Java element corresponding to the given file, or
739          * <code>null</code> if unable to associate the given file
740          * with a Java element.
741          *
742          * <p>The file must be one of:<ul>
743          *      <li>a <code>.java</code> file - the element returned is the corresponding <code>ICompilationUnit</code></li>
744          *      <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li>
745          *      <li>a <code>.jar</code> file - the element returned is the corresponding <code>IPackageFragmentRoot</code></li>
746          *      </ul>
747          * <p>
748          * Creating a Java element has the side effect of creating and opening all of the
749          * element's parents if they are not yet open.
750          * 
751          * @param the given file
752          * @return the Java element corresponding to the given file, or
753          * <code>null</code> if unable to associate the given file
754          * with a Java element
755          */
756         public static IJavaElement create(IFile file) {
757                 return JavaModelManager.create(file, null);
758         }
759         /**
760          * Returns the package fragment or package fragment root corresponding to the given folder, or
761          * <code>null</code> if unable to associate the given folder with a Java element.
762          * <p>
763          * Note that a package fragment root is returned rather than a default package.
764          * <p>
765          * Creating a Java element has the side effect of creating and opening all of the
766          * element's parents if they are not yet open.
767          * 
768          * @param the given folder
769          * @return the package fragment or package fragment root corresponding to the given folder, or
770          * <code>null</code> if unable to associate the given folder with a Java element
771          */
772         public static IJavaElement create(IFolder folder) {
773                 return JavaModelManager.create(folder, null);
774         }
775         /**
776          * Returns the Java project corresponding to the given project.
777          * <p>
778          * Creating a Java Project has the side effect of creating and opening all of the
779          * project's parents if they are not yet open.
780          * <p>
781          * Note that no check is done at this time on the existence or the java nature of this project.
782          * 
783          * @param project the given project
784          * @return the Java project corresponding to the given project, null if the given project is null
785          */
786         public static IJavaProject create(IProject project) {
787                 if (project == null) {
788                         return null;
789                 }
790                 JavaModel javaModel = JavaModelManager.getJavaModelManager().getJavaModel();
791                 return javaModel.getJavaProject(project);
792         }
793         /**
794          * Returns the Java element corresponding to the given resource, or
795          * <code>null</code> if unable to associate the given resource
796          * with a Java element.
797          * <p>
798          * The resource must be one of:<ul>
799          *      <li>a project - the element returned is the corresponding <code>IJavaProject</code></li>
800          *      <li>a <code>.java</code> file - the element returned is the corresponding <code>ICompilationUnit</code></li>
801          *      <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li>
802          *      <li>a <code>.jar</code> file - the element returned is the corresponding <code>IPackageFragmentRoot</code></li>
803          *  <li>a folder - the element returned is the corresponding <code>IPackageFragmentRoot</code>
804          *      or <code>IPackageFragment</code></li>
805          *  <li>the workspace root resource - the element returned is the <code>IJavaModel</code></li>
806          *      </ul>
807          * <p>
808          * Creating a Java element has the side effect of creating and opening all of the
809          * element's parents if they are not yet open.
810          * 
811          * @param resource the given resource
812          * @return the Java element corresponding to the given resource, or
813          * <code>null</code> if unable to associate the given resource
814          * with a Java element
815          */
816         public static IJavaElement create(IResource resource) {
817                 return JavaModelManager.create(resource, null);
818         }
819         /**
820          * Returns the Java model.
821          * 
822          * @param root the given root
823          * @return the Java model, or <code>null</code> if the root is null
824          */
825         public static IJavaModel create(IWorkspaceRoot root) {
826                 if (root == null) {
827                         return null;
828                 }
829                 return JavaModelManager.getJavaModelManager().getJavaModel();
830         }
831         /**
832          * Creates and returns a class file element for
833          * the given <code>.class</code> file. Returns <code>null</code> if unable
834          * to recognize the class file.
835          * 
836          * @param file the given <code>.class</code> file
837          * @return a class file element for the given <code>.class</code> file, or <code>null</code> if unable
838          * to recognize the class file
839          */
840 //      public static IClassFile createClassFileFrom(IFile file) {
841 //              return JavaModelManager.createClassFileFrom(file, null);
842 //      }
843         /**
844          * Creates and returns a compilation unit element for
845          * the given <code>.java</code> file. Returns <code>null</code> if unable
846          * to recognize the compilation unit.
847          * 
848          * @param file the given <code>.java</code> file
849          * @return a compilation unit element for the given <code>.java</code> file, or <code>null</code> if unable
850          * to recognize the compilation unit
851          */
852         public static ICompilationUnit createCompilationUnitFrom(IFile file) {
853                 return JavaModelManager.createCompilationUnitFrom(file, null);
854         }
855         /**
856          * Creates and returns a handle for the given JAR file.
857          * The Java model associated with the JAR's project may be
858          * created as a side effect. 
859          * 
860          * @param file the given JAR file
861          * @return a handle for the given JAR file, or <code>null</code> if unable to create a JAR package fragment root.
862          * (for example, if the JAR file represents a non-Java resource)
863          */
864 //      public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile file) {
865 //              return JavaModelManager.createJarPackageFragmentRootFrom(file, null);
866 //      }
867
868         /** 
869          * Answers the project specific value for a given classpath container.
870          * In case this container path could not be resolved, then will answer <code>null</code>.
871          * Both the container path and the project context are supposed to be non-null.
872          * <p>
873          * The containerPath is a formed by a first ID segment followed with extra segments, which can be 
874          * used as additional hints for resolution. If no container was ever recorded for this container path 
875          * onto this project (using <code>setClasspathContainer</code>, then a 
876          * <code>ClasspathContainerInitializer</code> will be activated if any was registered for this container 
877          * ID onto the extension point "org.eclipse.jdt.core.classpathContainerInitializer".
878          * <p>
879          * There is no assumption that the returned container must answer the exact same containerPath
880          * when requested <code>IClasspathContainer#getPath</code>. 
881          * Indeed, the containerPath is just an indication for resolving it to an actual container object.
882          * <p>
883          * Classpath container values are persisted locally to the workspace, but 
884          * are not preserved from a session to another. It is thus highly recommended to register a 
885          * <code>ClasspathContainerInitializer</code> for each referenced container 
886          * (through the extension point "org.eclipse.jdt.core.ClasspathContainerInitializer").
887          * <p>
888          * @param containerPath the name of the container, which needs to be resolved
889          * @param project a specific project in which the container is being resolved
890          * @return the corresponding classpath container or <code>null</code> if unable to find one.
891          * 
892          * @exception JavaModelException if an exception occurred while resolving the container, or if the resolved container
893          *   contains illegal entries (contains CPE_CONTAINER entries or null entries).  
894          * 
895          * @see ClasspathContainerInitializer
896          * @see IClasspathContainer
897          * @see #setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor)
898          * @since 2.0
899          */
900 //      public static IClasspathContainer getClasspathContainer(final IPath containerPath, final IJavaProject project) throws JavaModelException {
901 //
902 //              IClasspathContainer container = JavaModelManager.containerGet(project, containerPath);
903 //              if (container == JavaModelManager.ContainerInitializationInProgress) return null; // break cycle
904 //
905 //              if (container == null){
906 //                      final ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
907 //                      if (initializer != null){
908 //                              if (JavaModelManager.CP_RESOLVE_VERBOSE){
909 //                                      System.out.println("CPContainer INIT - triggering initialization of: ["+project.getElementName()+"] " + containerPath + " using initializer: "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
910 //                                      new Exception("FAKE exception for dumping current CPContainer (["+project.getElementName()+"] "+ containerPath+ ")INIT invocation stack trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
911 //                              }
912 //                              JavaModelManager.containerPut(project, containerPath, JavaModelManager.ContainerInitializationInProgress); // avoid initialization cycles
913 //                              boolean ok = false;
914 //                              try {
915 //                                      // wrap initializer call with Safe runnable in case initializer would be causing some grief
916 //                                      Platform.run(new ISafeRunnable() {
917 //                                              public void handleException(Throwable exception) {
918 //                                                      Util.log(exception, "Exception occurred in classpath container initializer: "+initializer); //$NON-NLS-1$
919 //                                              }
920 //                                              public void run() throws Exception {
921 //                                                      initializer.initialize(containerPath, project);
922 //                                              }
923 //                                      });
924 //                                      
925 //                                      // retrieve value (if initialization was successful)
926 //                                      container = JavaModelManager.containerGet(project, containerPath);
927 //                                      if (container == JavaModelManager.ContainerInitializationInProgress) return null; // break cycle
928 //                                      ok = true;
929 //                              } finally {
930 //                                      if (!ok) JavaModelManager.containerPut(project, containerPath, null); // flush cache
931 //                              }
932 //                              if (JavaModelManager.CP_RESOLVE_VERBOSE){
933 //                                      System.out.print("CPContainer INIT - after resolution: ["+project.getElementName()+"] " + containerPath + " --> "); //$NON-NLS-2$//$NON-NLS-1$//$NON-NLS-3$
934 //                                      if (container != null){
935 //                                              System.out.print("container: "+container.getDescription()+" {"); //$NON-NLS-2$//$NON-NLS-1$
936 //                                              IClasspathEntry[] entries = container.getClasspathEntries();
937 //                                              if (entries != null){
938 //                                                      for (int i = 0; i < entries.length; i++){
939 //                                                              if (i > 0) System.out.println(", ");//$NON-NLS-1$
940 //                                                              System.out.println(entries[i]);
941 //                                                      }
942 //                                              }
943 //                                              System.out.println("}");//$NON-NLS-1$
944 //                                      } else {
945 //                                              System.out.println("{unbound}");//$NON-NLS-1$
946 //                                      }
947 //                              }
948 //                      } else {
949 //                              if (JavaModelManager.CP_RESOLVE_VERBOSE){
950 //                                      System.out.println("CPContainer INIT - no initializer found for: "+project.getElementName()+"] " + containerPath); //$NON-NLS-1$ //$NON-NLS-2$
951 //                              }
952 //                      }
953 //              }
954 //              return container;                       
955 //      }
956
957         /**
958          * Helper method finding the classpath container initializer registered for a given classpath container ID 
959          * or <code>null</code> if none was found while iterating over the contributions to extension point to
960          * the extension point "org.eclipse.jdt.core.classpathContainerInitializer".
961          * <p>
962          * A containerID is the first segment of any container path, used to identify the registered container initializer.
963          * <p>
964          * @param String - a containerID identifying a registered initializer
965          * @return ClasspathContainerInitializer - the registered classpath container initializer or <code>null</code> if 
966          * none was found.
967          * @since 2.1
968          */
969 //      public static ClasspathContainerInitializer getClasspathContainerInitializer(String containerID){
970 //              
971 //              Plugin jdtCorePlugin = JavaCore.getPlugin();
972 //              if (jdtCorePlugin == null) return null;
973 //
974 //              IExtensionPoint extension = jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID);
975 //              if (extension != null) {
976 //                      IExtension[] extensions =  extension.getExtensions();
977 //                      for(int i = 0; i < extensions.length; i++){
978 //                              IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
979 //                              for(int j = 0; j < configElements.length; j++){
980 //                                      String initializerID = configElements[j].getAttribute("id"); //$NON-NLS-1$
981 //                                      if (initializerID != null && initializerID.equals(containerID)){
982 //                                              if (JavaModelManager.CP_RESOLVE_VERBOSE) {
983 //                                                      System.out.println("CPContainer INIT - found initializer: "+containerID +" --> " + configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
984 //                                              }                                               
985 //                                              try {
986 //                                                      Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
987 //                                                      if (execExt instanceof ClasspathContainerInitializer){
988 //                                                              return (ClasspathContainerInitializer)execExt;
989 //                                                      }
990 //                                              } catch(CoreException e) {
991 //                                              }
992 //                                      }
993 //                              }
994 //                      }       
995 //              }
996 //              return null;
997 //      }
998
999         /**
1000          * Returns the path held in the given classpath variable.
1001          * Returns <node>null</code> if unable to bind.
1002          * <p>
1003          * Classpath variable values are persisted locally to the workspace, and 
1004          * are preserved from session to session.
1005          * <p>
1006          * Note that classpath variables can be contributed registered initializers for,
1007          * using the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
1008          * If an initializer is registered for a variable, its persisted value will be ignored:
1009          * its initializer will thus get the opportunity to rebind the variable differently on
1010          * each session.
1011          *
1012          * @param variableName the name of the classpath variable
1013          * @return the path, or <code>null</code> if none 
1014          * @see #setClasspathVariable
1015          */
1016 //      public static IPath getClasspathVariable(final String variableName) {
1017 //      
1018 //              IPath variablePath = JavaModelManager.variableGet(variableName);
1019 //              if (variablePath == JavaModelManager.VariableInitializationInProgress) return null; // break cycle
1020 //              
1021 //              if (variablePath != null) {
1022 //                      return variablePath;
1023 //              }
1024 //
1025 //              // even if persisted value exists, initializer is given priority, only if no initializer is found the persisted value is reused
1026 //              final ClasspathVariableInitializer initializer = JavaCore.getClasspathVariableInitializer(variableName);
1027 //              if (initializer != null){
1028 //                      if (JavaModelManager.CP_RESOLVE_VERBOSE){
1029 //                              System.out.println("CPVariable INIT - triggering initialization of: " + variableName+ " using initializer: "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$
1030 //                              new Exception("FAKE exception for dumping current CPVariable ("+variableName+ ")INIT invocation stack trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$
1031 //                      }
1032 //                      JavaModelManager.variablePut(variableName, JavaModelManager.VariableInitializationInProgress); // avoid initialization cycles
1033 //                      boolean ok = false;
1034 //                      try {
1035 //                              // wrap initializer call with Safe runnable in case initializer would be causing some grief
1036 //                              Platform.run(new ISafeRunnable() {
1037 //                                      public void handleException(Throwable exception) {
1038 //                                              Util.log(exception, "Exception occurred in classpath variable initializer: "+initializer+" while initializing variable: "+variableName); //$NON-NLS-1$ //$NON-NLS-2$
1039 //                                      }
1040 //                                      public void run() throws Exception {
1041 //                                              initializer.initialize(variableName);
1042 //                                      }
1043 //                              });
1044 //                              variablePath = (IPath) JavaModelManager.variableGet(variableName); // initializer should have performed side-effect
1045 //                              if (variablePath == JavaModelManager.VariableInitializationInProgress) return null; // break cycle (initializer did not init or reentering call)
1046 //                              if (JavaModelManager.CP_RESOLVE_VERBOSE){
1047 //                                      System.out.println("CPVariable INIT - after initialization: " + variableName + " --> " + variablePath); //$NON-NLS-2$//$NON-NLS-1$
1048 //                              }
1049 //                              ok = true;
1050 //                      } finally {
1051 //                              if (!ok) JavaModelManager.variablePut(variableName, null); // flush cache
1052 //                      }
1053 //              } else {
1054 //                      if (JavaModelManager.CP_RESOLVE_VERBOSE){
1055 //                              System.out.println("CPVariable INIT - no initializer found for: " + variableName); //$NON-NLS-1$
1056 //                      }
1057 //              }
1058 //              return variablePath;
1059 //      }
1060
1061         /**
1062          * Helper method finding the classpath variable initializer registered for a given classpath variable name 
1063          * or <code>null</code> if none was found while iterating over the contributions to extension point to
1064          * the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
1065          * <p>
1066          * @param the given variable
1067          * @return ClasspathVariableInitializer - the registered classpath variable initializer or <code>null</code> if 
1068          * none was found.
1069          * @since 2.1
1070          */
1071 //      public static ClasspathVariableInitializer getClasspathVariableInitializer(String variable){
1072 //              
1073 //              Plugin jdtCorePlugin = JavaCore.getPlugin();
1074 //              if (jdtCorePlugin == null) return null;
1075 //
1076 //              IExtensionPoint extension = jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID);
1077 //              if (extension != null) {
1078 //                      IExtension[] extensions =  extension.getExtensions();
1079 //                      for(int i = 0; i < extensions.length; i++){
1080 //                              IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
1081 //                              for(int j = 0; j < configElements.length; j++){
1082 //                                      try {
1083 //                                              String varAttribute = configElements[j].getAttribute("variable"); //$NON-NLS-1$
1084 //                                              if (variable.equals(varAttribute)) {
1085 //                                                      if (JavaModelManager.CP_RESOLVE_VERBOSE) {
1086 //                                                              System.out.println("CPVariable INIT - found initializer: "+variable+" --> " + configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
1087 //                                                      }                                               
1088 //                                                      Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
1089 //                                                      if (execExt instanceof ClasspathVariableInitializer){
1090 //                                                              return (ClasspathVariableInitializer)execExt;
1091 //                                                      }
1092 //                                              }
1093 //                                      } catch(CoreException e){
1094 //                                      }
1095 //                                      }
1096 //                      }       
1097 //              }
1098 //              return null;
1099 //      }       
1100         
1101         /**
1102          * Returns the names of all known classpath variables.
1103          * <p>
1104          * Classpath variable values are persisted locally to the workspace, and 
1105          * are preserved from session to session.
1106          * <p>
1107          *
1108          * @return the list of classpath variable names
1109          * @see #setClasspathVariable
1110          */
1111 //      public static String[] getClasspathVariableNames() {
1112 //              return JavaModelManager.variableNames();
1113 //      }
1114
1115         /**
1116          * Returns a table of all known configurable options with their default values.
1117          * These options allow to configure the behaviour of the underlying components.
1118          * The client may safely use the result as a template that they can modify and
1119          * then pass to <code>setOptions</code>.
1120          * 
1121          * Helper constants have been defined on JavaCore for each of the option ID and 
1122          * their possible constant values.
1123          * 
1124          * Note: more options might be added in further releases.
1125          * <pre>
1126          * RECOGNIZED OPTIONS:
1127          * COMPILER / Generating Local Variable Debug Attribute
1128          *    When generated, this attribute will enable local variable names 
1129          *    to be displayed in debugger, only in place where variables are 
1130          *    definitely assigned (.class file is then bigger)
1131          *     - option id:         "org.eclipse.jdt.core.compiler.debug.localVariable"
1132          *     - possible values:   { "generate", "do not generate" }
1133          *     - default:           "generate"
1134          *
1135          * COMPILER / Generating Line Number Debug Attribute 
1136          *    When generated, this attribute will enable source code highlighting in debugger 
1137          *    (.class file is then bigger).
1138          *     - option id:         "org.eclipse.jdt.core.compiler.debug.lineNumber"
1139          *     - possible values:   { "generate", "do not generate" }
1140          *     - default:           "generate"
1141          *    
1142          * COMPILER / Generating Source Debug Attribute 
1143          *    When generated, this attribute will enable the debugger to present the 
1144          *    corresponding source code.
1145          *     - option id:         "org.eclipse.jdt.core.compiler.debug.sourceFile"
1146          *     - possible values:   { "generate", "do not generate" }
1147          *     - default:           "generate"
1148          *    
1149          * COMPILER / Preserving Unused Local Variables
1150          *    Unless requested to preserve unused local variables (that is, never read), the 
1151          *    compiler will optimize them out, potentially altering debugging
1152          *     - option id:         "org.eclipse.jdt.core.compiler.codegen.unusedLocal"
1153          *     - possible values:   { "preserve", "optimize out" }
1154          *     - default:           "preserve"
1155          * 
1156          * COMPILER / Defining Target Java Platform
1157          *    For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
1158          *    Note that "1.4" target require to toggle compliance mode to "1.4" too.
1159          *     - option id:         "org.eclipse.jdt.core.compiler.codegen.targetPlatform"
1160          *     - possible values:   { "1.1", "1.2", "1.3", "1.4" }
1161          *     - default:           "1.1"
1162          *
1163          * COMPILER / Reporting Unreachable Code
1164          *    Unreachable code can optionally be reported as an error, warning or simply 
1165          *    ignored. The bytecode generation will always optimized it out.
1166          *     - option id:         "org.eclipse.jdt.core.compiler.problem.unreachableCode"
1167          *     - possible values:   { "error", "warning", "ignore" }
1168          *     - default:           "error"
1169          *
1170          * COMPILER / Reporting Invalid Import
1171          *    An import statement that cannot be resolved might optionally be reported 
1172          *    as an error, as a warning or ignored.
1173          *     - option id:         "org.eclipse.jdt.core.compiler.problem.invalidImport"
1174          *     - possible values:   { "error", "warning", "ignore" }
1175          *     - default:           "error"
1176          *
1177          * COMPILER / Reporting Attempt to Override Package-Default Method
1178          *    A package default method is not visible in a different package, and thus 
1179          *    cannot be overridden. When enabling this option, the compiler will signal 
1180          *    such scenarii either as an error or a warning.
1181          *     - option id:         "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"
1182          *     - possible values:   { "error", "warning", "ignore" }
1183          *     - default:           "warning"
1184          *
1185          * COMPILER / Reporting Method With Constructor Name
1186          *    Naming a method with a constructor name is generally considered poor 
1187          *    style programming. When enabling this option, the compiler will signal such 
1188          *    scenarii either as an error or a warning.
1189          *     - option id:         "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"
1190          *     - possible values:   { "error", "warning", "ignore" }
1191          *     - default:           "warning"
1192          *
1193          * COMPILER / Reporting Deprecation
1194          *    When enabled, the compiler will signal use of deprecated API either as an 
1195          *    error or a warning.
1196          *     - option id:         "org.eclipse.jdt.core.compiler.problem.deprecation"
1197          *     - possible values:   { "error", "warning", "ignore" }
1198          *     - default:           "warning"
1199          *
1200          * COMPILER / Reporting Deprecation Inside Deprecated Code
1201          *    When enabled, the compiler will signal use of deprecated API inside deprecated code.
1202          *    The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.deprecation".
1203          *     - option id:         "org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode"
1204          *     - possible values:   { "enabled", "disabled" }
1205          *     - default:           "disabled"
1206          *
1207          * COMPILER / Reporting Hidden Catch Block
1208          *    Locally to a try statement, some catch blocks may hide others . For example,
1209          *      try {  throw new java.io.CharConversionException();
1210          *      } catch (java.io.CharConversionException e) {
1211          *      } catch (java.io.IOException e) {}. 
1212          *    When enabling this option, the compiler will issue an error or a warning for hidden 
1213          *    catch blocks corresponding to checked exceptions
1214          *     - option id:         "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"
1215          *     - possible values:   { "error", "warning", "ignore" }
1216          *     - default:           "warning"
1217          *
1218          * COMPILER / Reporting Unused Local
1219          *    When enabled, the compiler will issue an error or a warning for unused local 
1220          *    variables (that is, variables never read from)
1221          *     - option id:         "org.eclipse.jdt.core.compiler.problem.unusedLocal"
1222          *     - possible values:   { "error", "warning", "ignore" }
1223          *     - default:           "ignore"
1224          *
1225          * COMPILER / Reporting Unused Parameter
1226          *    When enabled, the compiler will issue an error or a warning for unused method 
1227          *    parameters (that is, parameters never read from)
1228          *     - option id:         "org.eclipse.jdt.core.compiler.problem.unusedParameter"
1229          *     - possible values:   { "error", "warning", "ignore" }
1230          *     - default:           "ignore"
1231          *
1232          * COMPILER / Reporting Unused Parameter if Implementing Abstract Method
1233          *    When enabled, the compiler will signal unused parameters in abstract method implementations.
1234          *    The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
1235          *     - option id:         "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"
1236          *     - possible values:   { "enabled", "disabled" }
1237          *     - default:           "disabled"
1238          *
1239          * COMPILER / Reporting Unused Parameter if Overriding Concrete Method
1240          *    When enabled, the compiler will signal unused parameters in methods overriding concrete ones.
1241          *    The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
1242          *     - option id:         "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"
1243          *     - possible values:   { "enabled", "disabled" }
1244          *     - default:           "disabled"
1245          *
1246          * COMPILER / Reporting Unused Import
1247          *    When enabled, the compiler will issue an error or a warning for unused import 
1248          *    reference 
1249          *     - option id:         "org.eclipse.jdt.core.compiler.problem.unusedImport"
1250          *     - possible values:   { "error", "warning", "ignore" }
1251          *     - default:           "warning"
1252          *
1253          * COMPILER / Reporting Unused Private Members
1254          *    When enabled, the compiler will issue an error or a warning whenever a private 
1255          *    method or field is declared but never used within the same unit.
1256          *     - option id:         "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"
1257          *     - possible values:   { "error", "warning", "ignore" }
1258          *     - default:           "ignore"
1259          *
1260          * COMPILER / Reporting Synthetic Access Emulation
1261          *    When enabled, the compiler will issue an error or a warning whenever it emulates 
1262          *    access to a non-accessible member of an enclosing type. Such access can have
1263          *    performance implications.
1264          *     - option id:         "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"
1265          *     - possible values:   { "error", "warning", "ignore" }
1266          *     - default:           "ignore"
1267          *
1268          * COMPILER / Reporting Non-Externalized String Literal
1269          *    When enabled, the compiler will issue an error or a warning for non externalized 
1270          *    String literal (that is, not tagged with //$NON-NLS-<n>$). 
1271          *     - option id:         "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"
1272          *     - possible values:   { "error", "warning", "ignore" }
1273          *     - default:           "ignore"
1274          * 
1275          * COMPILER / Reporting Usage of 'assert' Identifier
1276          *    When enabled, the compiler will issue an error or a warning whenever 'assert' is 
1277          *    used as an identifier (reserved keyword in 1.4)
1278          *     - option id:         "org.eclipse.jdt.core.compiler.problem.assertIdentifier"
1279          *     - possible values:   { "error", "warning", "ignore" }
1280          *     - default:           "ignore"
1281          * 
1282          * COMPILER / Reporting Non-Static Reference to a Static Member
1283          *    When enabled, the compiler will issue an error or a warning whenever a static field
1284          *    or method is accessed with an expression receiver. A reference to a static member should
1285          *    be qualified with a type name.
1286          *     - option id:         "org.eclipse.jdt.core.compiler.problem.staticAccessReceiver"
1287          *     - possible values:   { "error", "warning", "ignore" }
1288          *     - default:           "warning"
1289          * 
1290          * COMPILER / Reporting Assignment with no Effect
1291          *    When enabled, the compiler will issue an error or a warning whenever an assignment
1292          *    has no effect (e.g 'x = x').
1293          *     - option id:         "org.eclipse.jdt.core.compiler.problem.noEffectAssignment"
1294          *     - possible values:   { "error", "warning", "ignore" }
1295          *     - default:           "warning"
1296          * 
1297          * COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods
1298          *    When enabled, the compiler will issue an error or a warning whenever an interface
1299          *    defines a method incompatible with a non-inherited Object method. Until this conflict
1300          *    is resolved, such an interface cannot be implemented, For example, 
1301          *      interface I { 
1302          *         int clone();
1303          *      } 
1304          *     - option id:         "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"
1305          *     - possible values:   { "error", "warning", "ignore" }
1306          *     - default:           "warning"
1307          * 
1308          * COMPILER / Reporting Usage of char[] Expressions in String Concatenations
1309          *    When enabled, the compiler will issue an error or a warning whenever a char[] expression
1310          *    is used in String concatenations (for example, "hello" + new char[]{'w','o','r','l','d'}).
1311          *     - option id:         "org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion"
1312          *     - possible values:   { "error", "warning", "ignore" }
1313          *     - default:           "warning"
1314          *
1315          * COMPILER / Setting Source Compatibility Mode
1316          *    Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
1317          *    reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
1318          *   level should be set to "1.4" and the compliance mode should be "1.4".
1319          *     - option id:         "org.eclipse.jdt.core.compiler.source"
1320          *     - possible values:   { "1.3", "1.4" }
1321          *     - default:           "1.3"
1322          * 
1323          * COMPILER / Setting Compliance Level
1324          *    Select the compliance level for the compiler. In "1.3" mode, source and target settings
1325          *    should not go beyond "1.3" level.
1326          *     - option id:         "org.eclipse.jdt.core.compiler.compliance"
1327          *     - possible values:   { "1.3", "1.4" }
1328          *     - default:           "1.3"
1329          * 
1330          * COMPILER / Maximum number of problems reported per compilation unit
1331          *    Specify the maximum number of problems reported on each compilation unit.
1332          *     - option id:         "org.eclipse.jdt.core.compiler.maxProblemPerUnit"
1333          *     - possible values:       "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
1334          *     - default:           "100"
1335          * 
1336          * COMPILER / Define the Automatic Task Tags
1337          *    When the tag list is not empty, the compiler will issue a task marker whenever it encounters
1338          *    one of the corresponding tag inside any comment in Java source code.
1339          *    Generated task messages will include the tag, and range until the next line separator or comment ending.
1340          *    Note that tasks messages are trimmed.
1341          *     - option id:         "org.eclipse.jdt.core.compiler.taskTags"
1342          *     - possible values:   { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card or leading/trailing spaces 
1343          *     - default:           ""
1344          * 
1345          * COMPILER / Define the Automatic Task Priorities
1346          *    In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
1347          *    of the task markers issued by the compiler.
1348          *    If the default is specified, the priority of each task marker is "NORMAL".
1349          *     - option id:         "org.eclipse.jdt.core.compiler.taskPriorities"
1350          *     - possible values:   { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
1351          *     - default:           ""
1352          *
1353          * BUILDER / Specifying Filters for Resource Copying Control
1354          *    Allow to specify some filters to control the resource copy process.
1355          *     - option id:         "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
1356          *     - possible values:   { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
1357          *       or the name of a folder which ends with '/'
1358          *     - default:           ""
1359          * 
1360          * BUILDER / Abort if Invalid Classpath
1361          *    Allow to toggle the builder to abort if the classpath is invalid
1362          *     - option id:         "org.eclipse.jdt.core.builder.invalidClasspath"
1363          *     - possible values:   { "abort", "ignore" }
1364          *     - default:           "abort"
1365          * 
1366          * BUILDER / Cleaning Output Folder(s)
1367          *    Indicate whether the JavaBuilder is allowed to clean the output folders
1368          *    when performing full build operations.
1369          *     - option id:         "org.eclipse.jdt.core.builder.cleanOutputFolder"
1370          *     - possible values:   { "clean", "ignore" }
1371          *     - default:           "clean"
1372          * 
1373          * BUILDER / Reporting Duplicate Resources
1374          *    Indicate the severity of the problem reported when more than one occurrence
1375          *    of a resource is to be copied into the output location.
1376          *     - option id:         "org.eclipse.jdt.core.builder.duplicateResourceTask"
1377          *     - possible values:   { "error", "warning" }
1378          *     - default:           "warning"
1379          * 
1380          * JAVACORE / Computing Project Build Order
1381          *    Indicate whether JavaCore should enforce the project build order to be based on
1382          *    the classpath prerequisite chain. When requesting to compute, this takes over
1383          *    the platform default order (based on project references).
1384          *     - option id:         "org.eclipse.jdt.core.computeJavaBuildOrder"
1385          *     - possible values:   { "compute", "ignore" }
1386          *     - default:           "ignore"     
1387          * 
1388          * JAVACORE / Specify Default Source Encoding Format
1389          *    Get the encoding format for compiled sources. This setting is read-only, it is equivalent
1390          *    to 'ResourcesPlugin.getEncoding()'.
1391          *     - option id:         "org.eclipse.jdt.core.encoding"
1392          *     - possible values:   { any of the supported encoding name}.
1393          *     - default:           <platform default>
1394          * 
1395          * JAVACORE / Reporting Incomplete Classpath
1396          *    Indicate the severity of the problem reported when an entry on the classpath does not exist, 
1397          *    is not legite or is not visible (for example, a referenced project is closed).
1398          *     - option id:         "org.eclipse.jdt.core.incompleteClasspath"
1399          *     - possible values:   { "error", "warning"}
1400          *     - default:           "error"
1401          * 
1402          * JAVACORE / Reporting Classpath Cycle
1403          *    Indicate the severity of the problem reported when a project is involved in a cycle.
1404          *     - option id:         "org.eclipse.jdt.core.circularClasspath"
1405          *     - possible values:   { "error", "warning" }
1406          *     - default:           "error"
1407          * 
1408          * JAVACORE / Enabling Usage of Classpath Exclusion Patterns
1409          *    When disabled, no entry on a project classpath can be associated with
1410          *    an exclusion pattern.
1411          *     - option id:         "org.eclipse.jdt.core.classpath.exclusionPatterns"
1412          *     - possible values:   { "enabled", "disabled" }
1413          *     - default:           "enabled"
1414          * 
1415          * JAVACORE / Enabling Usage of Classpath Multiple Output Locations
1416          *    When disabled, no entry on a project classpath can be associated with
1417          *    a specific output location, preventing thus usage of multiple output locations.
1418          *     - option id:         "org.eclipse.jdt.core.classpath.multipleOutputLocations"
1419          *     - possible values:   { "enabled", "disabled" }
1420          *     - default:           "enabled"
1421          * 
1422          *      FORMATTER / Inserting New Line Before Opening Brace
1423          *    When Insert, a new line is inserted before an opening brace, otherwise nothing
1424          *    is inserted
1425          *     - option id:         "org.eclipse.jdt.core.formatter.newline.openingBrace"
1426          *     - possible values:   { "insert", "do not insert" }
1427          *     - default:           "do not insert"
1428          * 
1429          *      FORMATTER / Inserting New Line Inside Control Statement
1430          *    When Insert, a new line is inserted between } and following else, catch, finally
1431          *     - option id:         "org.eclipse.jdt.core.formatter.newline.controlStatement"
1432          *     - possible values:   { "insert", "do not insert" }
1433          *     - default:           "do not insert"
1434          * 
1435          *      FORMATTER / Clearing Blank Lines
1436          *    When Clear all, all blank lines are removed. When Preserve one, only one is kept
1437          *    and all others removed.
1438          *     - option id:         "org.eclipse.jdt.core.formatter.newline.clearAll"
1439          *     - possible values:   { "clear all", "preserve one" }
1440          *     - default:           "preserve one"
1441          * 
1442          *      FORMATTER / Inserting New Line Between Else/If 
1443          *    When Insert, a blank line is inserted between an else and an if when they are 
1444          *    contiguous. When choosing to not insert, else-if will be kept on the same
1445          *    line when possible.
1446          *     - option id:         "org.eclipse.jdt.core.formatter.newline.elseIf"
1447          *     - possible values:   { "insert", "do not insert" }
1448          *     - default:           "do not insert"
1449          * 
1450          *      FORMATTER / Inserting New Line In Empty Block
1451          *    When insert, a line break is inserted between contiguous { and }, if } is not followed
1452          *    by a keyword.
1453          *     - option id:         "org.eclipse.jdt.core.formatter.newline.emptyBlock"
1454          *     - possible values:   { "insert", "do not insert" }
1455          *     - default:           "insert"
1456          * 
1457          *      FORMATTER / Splitting Lines Exceeding Length
1458          *    Enable splitting of long lines (exceeding the configurable length). Length of 0 will
1459          *    disable line splitting
1460          *     - option id:         "org.eclipse.jdt.core.formatter.lineSplit"
1461          *     - possible values:       "<n>", where n is zero or a positive integer
1462          *     - default:           "80"
1463          * 
1464          *      FORMATTER / Compacting Assignment
1465          *    Assignments can be formatted asymmetrically, for example 'int x= 2;', when Normal, a space
1466          *    is inserted before the assignment operator
1467          *     - option id:         "org.eclipse.jdt.core.formatter.style.assignment"
1468          *     - possible values:   { "compact", "normal" }
1469          *     - default:           "normal"
1470          * 
1471          *      FORMATTER / Defining Indentation Character
1472          *    Either choose to indent with tab characters or spaces
1473          *     - option id:         "org.eclipse.jdt.core.formatter.tabulation.char"
1474          *     - possible values:   { "tab", "space" }
1475          *     - default:           "tab"
1476          * 
1477          *      FORMATTER / Defining Space Indentation Length
1478          *    When using spaces, set the amount of space characters to use for each 
1479          *    indentation mark.
1480          *     - option id:         "org.eclipse.jdt.core.formatter.tabulation.size"
1481          *     - possible values:       "<n>", where n is a positive integer
1482          *     - default:           "4"
1483          * 
1484          *      FORMATTER / Inserting space in cast expression
1485          *    When Insert, a space is added between the type and the expression in a cast expression.
1486          *     - option id:         "org.eclipse.jdt.core.formatter.space.castexpression"
1487          *     - possible values:   { "insert", "do not insert" }
1488          *     - default:           "insert"
1489          * 
1490          *      CODEASSIST / Activate Visibility Sensitive Completion
1491          *    When active, completion doesn't show that you can not see
1492          *    (for example, you can not see private methods of a super class).
1493          *     - option id:         "org.eclipse.jdt.core.codeComplete.visibilityCheck"
1494          *     - possible values:   { "enabled", "disabled" }
1495          *     - default:           "disabled"
1496          * 
1497          *      CODEASSIST / Automatic Qualification of Implicit Members
1498          *    When active, completion automatically qualifies completion on implicit
1499          *    field references and message expressions.
1500          *     - option id:         "org.eclipse.jdt.core.codeComplete.forceImplicitQualification"
1501          *     - possible values:   { "enabled", "disabled" }
1502          *     - default:           "disabled"
1503          * 
1504          *  CODEASSIST / Define the Prefixes for Field Name
1505          *    When the prefixes is non empty, completion for field name will begin with
1506          *    one of the proposed prefixes.
1507          *     - option id:         "org.eclipse.jdt.core.codeComplete.fieldPrefixes"
1508          *     - possible values:   { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card 
1509          *     - default:           ""
1510          * 
1511          *  CODEASSIST / Define the Prefixes for Static Field Name
1512          *    When the prefixes is non empty, completion for static field name will begin with
1513          *    one of the proposed prefixes.
1514          *     - option id:         "org.eclipse.jdt.core.codeComplete.staticFieldPrefixes"
1515          *     - possible values:   { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card 
1516          *     - default:           ""
1517          * 
1518          *  CODEASSIST / Define the Prefixes for Local Variable Name
1519          *    When the prefixes is non empty, completion for local variable name will begin with
1520          *    one of the proposed prefixes.
1521          *     - option id:         "org.eclipse.jdt.core.codeComplete.localPrefixes"
1522          *     - possible values:   { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card 
1523          *     - default:           ""
1524          * 
1525          *  CODEASSIST / Define the Prefixes for Argument Name
1526          *    When the prefixes is non empty, completion for argument name will begin with
1527          *    one of the proposed prefixes.
1528          *     - option id:         "org.eclipse.jdt.core.codeComplete.argumentPrefixes"
1529          *     - possible values:   { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card 
1530          *     - default:           ""
1531          * 
1532          *  CODEASSIST / Define the Suffixes for Field Name
1533          *    When the suffixes is non empty, completion for field name will end with
1534          *    one of the proposed suffixes.
1535          *     - option id:         "org.eclipse.jdt.core.codeComplete.fieldSuffixes"
1536          *     - possible values:   { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card 
1537          *     - default:           ""
1538          * 
1539          *  CODEASSIST / Define the Suffixes for Static Field Name
1540          *    When the suffixes is non empty, completion for static field name will end with
1541          *    one of the proposed suffixes.
1542          *     - option id:         "org.eclipse.jdt.core.codeComplete.staticFieldSuffixes"
1543          *     - possible values:   { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card 
1544          *     - default:           ""
1545          * 
1546          *  CODEASSIST / Define the Suffixes for Local Variable Name
1547          *    When the suffixes is non empty, completion for local variable name will end with
1548          *    one of the proposed suffixes.
1549          *     - option id:         "org.eclipse.jdt.core.codeComplete.localSuffixes"
1550          *     - possible values:   { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card 
1551          *     - default:           ""
1552          * 
1553          *  CODEASSIST / Define the Suffixes for Argument Name
1554          *    When the suffixes is non empty, completion for argument name will end with
1555          *    one of the proposed suffixes.
1556          *     - option id:         "org.eclipse.jdt.core.codeComplete.argumentSuffixes"
1557          *     - possible values:   { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card 
1558          *     - default:           ""
1559          * </pre>
1560          * 
1561          * @return a mutable table containing the default settings of all known options
1562          *   (key type: <code>String</code>; value type: <code>String</code>)
1563          * @see #setOptions
1564          */
1565         public static Hashtable getDefaultOptions(){
1566         
1567                 Hashtable defaultOptions = new Hashtable(10);
1568
1569                 // see #initializeDefaultPluginPreferences() for changing default settings
1570                 Preferences preferences = getPlugin().getPluginPreferences();
1571                 HashSet optionNames = JavaModelManager.OptionNames;
1572                 
1573                 // get preferences set to their default
1574                 String[] defaultPropertyNames = preferences.defaultPropertyNames();
1575                 for (int i = 0; i < defaultPropertyNames.length; i++){
1576                         String propertyName = defaultPropertyNames[i];
1577                         if (optionNames.contains(propertyName)) {
1578                                 defaultOptions.put(propertyName, preferences.getDefaultString(propertyName));
1579                         }
1580                 }               
1581                 // get preferences not set to their default
1582                 String[] propertyNames = preferences.propertyNames();
1583                 for (int i = 0; i < propertyNames.length; i++){
1584                         String propertyName = propertyNames[i];
1585                         if (optionNames.contains(propertyName)) {
1586                                 defaultOptions.put(propertyName, preferences.getDefaultString(propertyName));
1587                         }
1588                 }               
1589                 // get encoding through resource plugin
1590                 defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding()); 
1591                 
1592                 return defaultOptions;
1593         }
1594
1595         /**
1596          * Returns the single instance of the Java core plug-in runtime class.
1597          * Equivalent to <code>(JavaCore) getPlugin()</code>.
1598          * 
1599          * @return the single instance of the Java core plug-in runtime class
1600          */
1601         public static JavaCore getJavaCore() {
1602                 return (JavaCore) getPlugin();
1603         }
1604         
1605         /**
1606          * Helper method for returning one option value only. Equivalent to <code>(String)JavaCore.getOptions().get(optionName)</code>
1607          * Note that it may answer <code>null</code> if this option does not exist.
1608          * <p>
1609          * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
1610          * </p>
1611          * 
1612          * @param optionName the name of an option
1613          * @return the String value of a given option
1614          * @see JavaCore#getDefaultOptions
1615          * @since 2.0
1616          */
1617         public static String getOption(String optionName) {
1618                 
1619                 if (CORE_ENCODING.equals(optionName)){
1620                         return ResourcesPlugin.getEncoding();
1621                 }
1622                 if (JavaModelManager.OptionNames.contains(optionName)){
1623                         Preferences preferences = getPlugin().getPluginPreferences();
1624                         return preferences.getString(optionName).trim();
1625                 }
1626                 return null;
1627         }
1628         
1629         /**
1630          * Returns the table of the current options. Initially, all options have their default values,
1631          * and this method returns a table that includes all known options.
1632          * <p>
1633          * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
1634          * </p>
1635          * 
1636          * @return table of current settings of all options 
1637          *   (key type: <code>String</code>; value type: <code>String</code>)
1638          * @see JavaCore#getDefaultOptions
1639          */
1640         public static Hashtable getOptions() {
1641                 
1642                 Hashtable options = new Hashtable(10);
1643
1644                 // see #initializeDefaultPluginPreferences() for changing default settings
1645                 Plugin plugin = getPlugin();
1646                 if (plugin != null) {
1647                         Preferences preferences = getPlugin().getPluginPreferences();
1648                         HashSet optionNames = JavaModelManager.OptionNames;
1649                         
1650                         // get preferences set to their default
1651                         String[] defaultPropertyNames = preferences.defaultPropertyNames();
1652                         for (int i = 0; i < defaultPropertyNames.length; i++){
1653                                 String propertyName = defaultPropertyNames[i];
1654                                 if (optionNames.contains(propertyName)){
1655                                         options.put(propertyName, preferences.getDefaultString(propertyName));
1656                                 }
1657                         }               
1658                         // get preferences not set to their default
1659                         String[] propertyNames = preferences.propertyNames();
1660                         for (int i = 0; i < propertyNames.length; i++){
1661                                 String propertyName = propertyNames[i];
1662                                 if (optionNames.contains(propertyName)){
1663                                         options.put(propertyName, preferences.getString(propertyName).trim());
1664                                 }
1665                         }               
1666                         // get encoding through resource plugin
1667                         options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
1668                 }
1669                 return options;
1670         }
1671                 
1672         /**
1673          * Returns the single instance of the Java core plug-in runtime class.
1674          * 
1675          * @return the single instance of the Java core plug-in runtime class
1676          */
1677         public static Plugin getPlugin() {
1678                 return JAVA_CORE_PLUGIN;
1679         }
1680
1681         /**
1682          * This is a helper method, which returns the resolved classpath entry denoted 
1683          * by a given entry (if it is a variable entry). It is obtained by resolving the variable 
1684          * reference in the first segment. Returns <node>null</code> if unable to resolve using 
1685          * the following algorithm:
1686          * <ul>
1687          * <li> if variable segment cannot be resolved, returns <code>null</code></li>
1688          * <li> finds a project, JAR or binary folder in the workspace at the resolved path location</li>
1689          * <li> if none finds an external JAR file or folder outside the workspace at the resolved path location </li>
1690          * <li> if none returns <code>null</code></li>
1691          * </ul>
1692          * <p>
1693          * Variable source attachment path and root path are also resolved and recorded in the resulting classpath entry.
1694          * <p>
1695          * NOTE: This helper method does not handle classpath containers, for which should rather be used
1696          * <code>JavaCore#getClasspathContainer(IPath, IJavaProject)</code>.
1697          * <p>
1698          * 
1699          * @param entry the given variable entry
1700          * @return the resolved library or project classpath entry, or <code>null</code>
1701          *   if the given variable entry could not be resolved to a valid classpath entry
1702          */
1703 //      public static IClasspathEntry getResolvedClasspathEntry(IClasspathEntry entry) {
1704 //      
1705 //              if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
1706 //                      return entry;
1707 //      
1708 //              IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
1709 //              IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath());
1710 //              if (resolvedPath == null)
1711 //                      return null;
1712 //      
1713 //              Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false);
1714 //              if (target == null)
1715 //                      return null;
1716 //      
1717 //              // inside the workspace
1718 //              if (target instanceof IResource) {
1719 //                      IResource resolvedResource = (IResource) target;
1720 //                      if (resolvedResource != null) {
1721 //                              switch (resolvedResource.getType()) {
1722 //                                      
1723 //                                      case IResource.PROJECT :  
1724 //                                              // internal project
1725 //                                              return JavaCore.newProjectEntry(resolvedPath, entry.isExported());
1726 //                                              
1727 //                                      case IResource.FILE : 
1728 //                                              if (Util.isArchiveFileName(resolvedResource.getName())) {
1729 //                                                      // internal binary archive
1730 //                                                      return JavaCore.newLibraryEntry(
1731 //                                                                      resolvedPath,
1732 //                                                                      getResolvedVariablePath(entry.getSourceAttachmentPath()),
1733 //                                                                      getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
1734 //                                                                      entry.isExported());
1735 //                                              }
1736 //                                              break;
1737 //                                              
1738 //                                      case IResource.FOLDER : 
1739 //                                              // internal binary folder
1740 //                                              return JavaCore.newLibraryEntry(
1741 //                                                              resolvedPath,
1742 //                                                              getResolvedVariablePath(entry.getSourceAttachmentPath()),
1743 //                                                              getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
1744 //                                                              entry.isExported());
1745 //                              }
1746 //                      }
1747 //              }
1748 //              // outside the workspace
1749 //              if (target instanceof File) {
1750 //                      File externalFile = (File) target;
1751 //                      if (externalFile.isFile()) {
1752 //                              String fileName = externalFile.getName().toLowerCase();
1753 //                              if (fileName.endsWith(".jar"  //$NON-NLS-1$
1754 //                                      ) || fileName.endsWith(".zip"  //$NON-NLS-1$
1755 //                                      )) { // external binary archive
1756 //                                      return JavaCore.newLibraryEntry(
1757 //                                                      resolvedPath,
1758 //                                                      getResolvedVariablePath(entry.getSourceAttachmentPath()),
1759 //                                                      getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
1760 //                                                      entry.isExported());
1761 //                              }
1762 //                      } else { // external binary folder
1763 //                              if (resolvedPath.isAbsolute()){
1764 //                                      return JavaCore.newLibraryEntry(
1765 //                                                      resolvedPath,
1766 //                                                      getResolvedVariablePath(entry.getSourceAttachmentPath()),
1767 //                                                      getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
1768 //                                                      entry.isExported());
1769 //                              }
1770 //                      }
1771 //              }
1772 //              return null;
1773 //      }
1774
1775
1776         /**
1777          * Resolve a variable path (helper method).
1778          * 
1779          * @param variablePath the given variable path
1780          * @return the resolved variable path or <code>null</code> if none
1781          */
1782 //      public static IPath getResolvedVariablePath(IPath variablePath) {
1783 //      
1784 //              if (variablePath == null)
1785 //                      return null;
1786 //              int count = variablePath.segmentCount();
1787 //              if (count == 0)
1788 //                      return null;
1789 //      
1790 //              // lookup variable      
1791 //              String variableName = variablePath.segment(0);
1792 //              IPath resolvedPath = JavaCore.getClasspathVariable(variableName);
1793 //              if (resolvedPath == null)
1794 //                      return null;
1795 //      
1796 //              // append path suffix
1797 //              if (count > 1) {
1798 //                      resolvedPath = resolvedPath.append(variablePath.removeFirstSegments(1));
1799 //              }
1800 //              return resolvedPath; 
1801 //      }
1802
1803         /**
1804          * Answers the shared working copies currently registered for this buffer factory. 
1805          * Working copies can be shared by several clients using the same buffer factory,see 
1806          * <code>IWorkingCopy.getSharedWorkingCopy</code>.
1807          * 
1808          * @param factory the given buffer factory
1809          * @return the list of shared working copies for a given buffer factory
1810          * @see IWorkingCopy
1811          * @since 2.0
1812          */
1813         public static IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory){
1814                 
1815                 // if factory is null, default factory must be used
1816                 if (factory == null) factory = BufferManager.getDefaultBufferManager().getDefaultBufferFactory();
1817                 Map sharedWorkingCopies = JavaModelManager.getJavaModelManager().sharedWorkingCopies;
1818                 
1819                 Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
1820                 if (perFactoryWorkingCopies == null) return JavaModelManager.NoWorkingCopy;
1821                 Collection copies = perFactoryWorkingCopies.values();
1822                 IWorkingCopy[] result = new IWorkingCopy[copies.size()];
1823                 copies.toArray(result);
1824                 return result;
1825         }
1826         
1827         /**
1828          * Initializes the default preferences settings for this plug-in.
1829          */
1830         protected void initializeDefaultPluginPreferences() {
1831                 
1832                 Preferences preferences = getPluginPreferences();
1833                 HashSet optionNames = JavaModelManager.OptionNames;
1834                 
1835                 // Compiler settings
1836                 preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
1837                 optionNames.add(COMPILER_LOCAL_VARIABLE_ATTR);
1838
1839                 preferences.setDefault(COMPILER_LINE_NUMBER_ATTR, GENERATE); 
1840                 optionNames.add(COMPILER_LINE_NUMBER_ATTR);
1841
1842                 preferences.setDefault(COMPILER_SOURCE_FILE_ATTR, GENERATE); 
1843                 optionNames.add(COMPILER_SOURCE_FILE_ATTR);
1844
1845                 preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE); 
1846                 optionNames.add(COMPILER_CODEGEN_UNUSED_LOCAL);
1847
1848                 preferences.setDefault(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1); 
1849                 optionNames.add(COMPILER_CODEGEN_TARGET_PLATFORM);
1850
1851                 preferences.setDefault(COMPILER_PB_UNREACHABLE_CODE, ERROR); 
1852                 optionNames.add(COMPILER_PB_UNREACHABLE_CODE);
1853
1854                 preferences.setDefault(COMPILER_PB_INVALID_IMPORT, ERROR); 
1855                 optionNames.add(COMPILER_PB_INVALID_IMPORT);
1856
1857                 preferences.setDefault(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, WARNING); 
1858                 optionNames.add(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD);
1859
1860                 preferences.setDefault(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME, WARNING); 
1861                 optionNames.add(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME);
1862
1863                 preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING);
1864                 optionNames.add(COMPILER_PB_DEPRECATION);
1865
1866                 preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE, DISABLED);
1867                 optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE);
1868
1869                 preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING); 
1870                 optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK);
1871
1872                 preferences.setDefault(COMPILER_PB_UNUSED_LOCAL, IGNORE); 
1873                 optionNames.add(COMPILER_PB_UNUSED_LOCAL);
1874
1875                 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE); 
1876                 optionNames.add(COMPILER_PB_UNUSED_PARAMETER);
1877
1878                 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT, DISABLED); 
1879                 optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT);
1880
1881                 preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE, DISABLED); 
1882                 optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE);
1883
1884                 preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING); 
1885                 optionNames.add(COMPILER_PB_UNUSED_IMPORT);
1886
1887                 preferences.setDefault(COMPILER_PB_UNUSED_PRIVATE_MEMBER, IGNORE); 
1888                 optionNames.add(COMPILER_PB_UNUSED_PRIVATE_MEMBER);
1889
1890                 preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE); 
1891                 optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION);
1892
1893                 preferences.setDefault(COMPILER_PB_NON_NLS_STRING_LITERAL, IGNORE); 
1894                 optionNames.add(COMPILER_PB_NON_NLS_STRING_LITERAL);
1895
1896                 preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE); 
1897                 optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER);
1898
1899                 preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING); 
1900                 optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER);
1901
1902                 preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING); 
1903                 optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT);
1904
1905                 preferences.setDefault(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD, WARNING); 
1906                 optionNames.add(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD);
1907
1908                 preferences.setDefault(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION, WARNING); 
1909                 optionNames.add(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION);
1910
1911                 preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAG); //$NON-NLS-1$
1912                 optionNames.add(COMPILER_TASK_TAGS);
1913
1914                 preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITY); //$NON-NLS-1$
1915                 optionNames.add(COMPILER_TASK_PRIORITIES);
1916
1917                 preferences.setDefault(COMPILER_SOURCE, VERSION_1_3);
1918                 optionNames.add(COMPILER_SOURCE);
1919
1920                 preferences.setDefault(COMPILER_COMPLIANCE, VERSION_1_3); 
1921                 optionNames.add(COMPILER_COMPLIANCE);
1922
1923                 preferences.setDefault(COMPILER_PB_MAX_PER_UNIT, "100"); //$NON-NLS-1$
1924                 optionNames.add(COMPILER_PB_MAX_PER_UNIT);
1925                 
1926                 // Builder settings
1927                 preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
1928                 optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
1929
1930                 preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT); 
1931                 optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH);
1932         
1933                 preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING); 
1934                 optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE);
1935                 
1936                 preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN); 
1937                 optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER);
1938
1939                 // JavaCore settings
1940                 preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE); 
1941                 optionNames.add(CORE_JAVA_BUILD_ORDER);
1942         
1943                 preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR); 
1944                 optionNames.add(CORE_CIRCULAR_CLASSPATH);
1945                 
1946                 preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR); 
1947                 optionNames.add(CORE_INCOMPLETE_CLASSPATH);
1948                 
1949                 preferences.setDefault(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, ENABLED); 
1950                 optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS);
1951
1952                 preferences.setDefault(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, ENABLED); 
1953                 optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS);
1954
1955                 // encoding setting comes from resource plug-in
1956                 optionNames.add(CORE_ENCODING);
1957                 
1958                 // Formatter settings
1959                 preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT); 
1960                 optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE);
1961
1962                 preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT);
1963                 optionNames.add(FORMATTER_NEWLINE_CONTROL);
1964
1965                 preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE); 
1966                 optionNames.add(FORMATTER_CLEAR_BLANK_LINES);
1967
1968                 preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT);
1969                 optionNames.add(FORMATTER_NEWLINE_ELSE_IF);
1970
1971                 preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT); 
1972                 optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK);
1973
1974                 preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$
1975                 optionNames.add(FORMATTER_LINE_SPLIT);
1976
1977                 preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL); 
1978                 optionNames.add(FORMATTER_COMPACT_ASSIGNMENT);
1979
1980                 preferences.setDefault(FORMATTER_TAB_CHAR, TAB); 
1981                 optionNames.add(FORMATTER_TAB_CHAR);
1982
1983                 preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$ 
1984                 optionNames.add(FORMATTER_TAB_SIZE);
1985                 
1986                 preferences.setDefault(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$ 
1987                 optionNames.add(FORMATTER_SPACE_CASTEXPRESSION);
1988
1989                 // CodeAssist settings
1990                 preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$
1991                 optionNames.add(CODEASSIST_VISIBILITY_CHECK);
1992
1993                 preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$
1994                 optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION);
1995                 
1996                 preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
1997                 optionNames.add(CODEASSIST_FIELD_PREFIXES);
1998                 
1999                 preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
2000                 optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES);
2001                 
2002                 preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
2003                 optionNames.add(CODEASSIST_LOCAL_PREFIXES);
2004                 
2005                 preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
2006                 optionNames.add(CODEASSIST_ARGUMENT_PREFIXES);
2007                 
2008                 preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
2009                 optionNames.add(CODEASSIST_FIELD_SUFFIXES);
2010                 
2011                 preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
2012                 optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES);
2013                 
2014                 preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
2015                 optionNames.add(CODEASSIST_LOCAL_SUFFIXES);
2016                 
2017                 preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
2018                 optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES);
2019         }
2020         
2021         /**
2022          * Returns whether the given marker references the given Java element.
2023          * Used for markers, which denote a Java element rather than a resource.
2024          *
2025          * @param element the element
2026          * @param marker the marker
2027          * @return <code>true</code> if the marker references the element, false otherwise
2028          * @exception CoreException if the <code>IMarker.getAttribute</code> on the marker fails         
2029          */
2030         public static boolean isReferencedBy(IJavaElement element, IMarker marker) throws CoreException {
2031                 
2032                 // only match units or classfiles
2033                 if (element instanceof IMember){
2034                         IMember member = (IMember) element;
2035                         if (member.isBinary()){
2036                                 element = null; //member.getClassFile();
2037                         } else {
2038                                 element = member.getCompilationUnit();
2039                         }
2040                 }
2041                 if (element == null) return false;                      
2042                 if (marker == null) return false;
2043
2044                 String markerHandleId = (String)marker.getAttribute(ATT_HANDLE_ID);
2045                 if (markerHandleId == null) return false;
2046                 
2047                 IJavaElement markerElement = JavaCore.create(markerHandleId);
2048 //              while (true){
2049                         if (element.equals(markerElement)) return true; // external elements may still be equal with different handleIDs.
2050                         
2051                         // cycle through enclosing types in case marker is associated with a classfile (15568)
2052 //                      if (markerElement instanceof IClassFile){
2053 //                              IType enclosingType = ((IClassFile)markerElement).getType().getDeclaringType();
2054 //                              if (enclosingType != null){
2055 //                                      markerElement = enclosingType.getClassFile(); // retry with immediate enclosing classfile
2056 //                                      continue;
2057 //                              }
2058 //                      }
2059 //                      break;
2060 //              }
2061                 return false;
2062         }
2063
2064         /**
2065          * Returns whether the given marker delta references the given Java element.
2066          * Used for markers deltas, which denote a Java element rather than a resource.
2067          *
2068          * @param element the element
2069          * @param markerDelta the marker delta
2070          * @return <code>true</code> if the marker delta references the element
2071          * @exception CoreException if the  <code>IMarkerDelta.getAttribute</code> on the marker delta fails     
2072          */
2073         public static boolean isReferencedBy(IJavaElement element, IMarkerDelta markerDelta) throws CoreException {
2074                 
2075                 // only match units or classfiles
2076                 if (element instanceof IMember){
2077                         IMember member = (IMember) element;
2078                         if (member.isBinary()){
2079                                 element = null; //member.getClassFile();
2080                         } else {
2081                                 element = member.getCompilationUnit();
2082                         }
2083                 }
2084                 if (element == null) return false;                      
2085                 if (markerDelta == null) return false;
2086
2087                 String markerDeltarHandleId = (String)markerDelta.getAttribute(ATT_HANDLE_ID);
2088                 if (markerDeltarHandleId == null) return false;
2089                 
2090                 IJavaElement markerElement = JavaCore.create(markerDeltarHandleId);
2091 //              while (true){
2092                         if (element.equals(markerElement)) return true; // external elements may still be equal with different handleIDs.
2093                         
2094                         // cycle through enclosing types in case marker is associated with a classfile (15568)
2095 //                      if (markerElement instanceof IClassFile){
2096 //                              IType enclosingType = ((IClassFile)markerElement).getType().getDeclaringType();
2097 //                              if (enclosingType != null){
2098 //                                      markerElement = enclosingType.getClassFile(); // retry with immediate enclosing classfile
2099 //                                      continue;
2100 //                              }
2101 //                      }
2102 //                      break;
2103 //              }
2104                 return false;
2105         }
2106
2107         /**
2108          * Creates and returns a new classpath entry of kind <code>CPE_CONTAINER</code>
2109          * for the given path. The path of the container will be used during resolution so as to map this
2110          * container entry to a set of other classpath entries the container is acting for.
2111          * <p>
2112          * A container entry allows to express indirect references to a set of libraries, projects and variable entries,
2113          * which can be interpreted differently for each Java project where it is used.
2114          * A classpath container entry can be resolved using <code>JavaCore.getResolvedClasspathContainer</code>,
2115          * and updated with <code>JavaCore.classpathContainerChanged</code>
2116          * <p>
2117          * A container is exclusively resolved by a <code>ClasspathContainerInitializer</code> registered onto the
2118          * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
2119          * <p>
2120          * A container path must be formed of at least one segment, where: <ul>
2121          * <li> the first segment is a unique ID identifying the target container, there must be a container initializer registered
2122          *      onto this ID through the extension point  "org.eclipse.jdt.core.classpathContainerInitializer". </li>
2123          * <li> the remaining segments will be passed onto the initializer, and can be used as additional
2124          *      hints during the initialization phase. </li>
2125          * </ul>
2126          * <p>
2127          * Example of an ClasspathContainerInitializer for a classpath container denoting a default JDK container:
2128          * 
2129          * containerEntry = JavaCore.newContainerEntry(new Path("MyProvidedJDK/default"));
2130          * 
2131          * <extension
2132          *    point="org.eclipse.jdt.core.classpathContainerInitializer">
2133          *    <containerInitializer
2134          *       id="MyProvidedJDK"
2135          *       class="com.example.MyInitializer"/> 
2136          * <p>
2137          * Note that this operation does not attempt to validate classpath containers
2138          * or access the resources at the given paths.
2139          * <p>
2140          * The resulting entry is not exported to dependent projects. This method is equivalent to
2141          * <code>newContainerEntry(-,false)</code>.
2142          * <p>
2143          * @param containerPath the path identifying the container, it must be formed of two
2144          *      segments
2145          * @return a new container classpath entry
2146          * 
2147          * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
2148          * @see JavaCore#newContainerEntry(IPath, boolean)
2149          * @since 2.0
2150          */
2151 //      public static IClasspathEntry newContainerEntry(IPath containerPath) {
2152 //                      
2153 //              return newContainerEntry(containerPath, false);
2154 //      }
2155
2156         /**
2157          * Creates and returns a new classpath entry of kind <code>CPE_CONTAINER</code>
2158          * for the given path. The path of the container will be used during resolution so as to map this
2159          * container entry to a set of other classpath entries the container is acting for.
2160          * <p>
2161          * A container entry allows to express indirect references to a set of libraries, projects and variable entries,
2162          * which can be interpreted differently for each Java project where it is used.
2163          * A classpath container entry can be resolved using <code>JavaCore.getResolvedClasspathContainer</code>,
2164          * and updated with <code>JavaCore.classpathContainerChanged</code>
2165          * <p>
2166          * A container is exclusively resolved by a <code>ClasspathContainerInitializer</code> registered onto the
2167          * extension point "org.eclipse.jdt.core.classpathContainerInitializer".
2168          * <p>
2169          * A container path must be formed of at least one segment, where: <ul>
2170          * <li> the first segment is a unique ID identifying the target container, there must be a container initializer registered
2171          *      onto this ID through the extension point  "org.eclipse.jdt.core.classpathContainerInitializer". </li>
2172          * <li> the remaining segments will be passed onto the initializer, and can be used as additional
2173          *      hints during the initialization phase. </li>
2174          * </ul>
2175          * <p>
2176          * Example of an ClasspathContainerInitializer for a classpath container denoting a default JDK container:
2177          * 
2178          * containerEntry = JavaCore.newContainerEntry(new Path("MyProvidedJDK/default"));
2179          * 
2180          * <extension
2181          *    point="org.eclipse.jdt.core.classpathContainerInitializer">
2182          *    <containerInitializer
2183          *       id="MyProvidedJDK"
2184          *       class="com.example.MyInitializer"/> 
2185          * <p>
2186          * Note that this operation does not attempt to validate classpath containers
2187          * or access the resources at the given paths.
2188          * <p>
2189          * @param containerPath the path identifying the container, it must be formed of at least
2190          *      one segment (ID+hints)
2191          * @param isExported a boolean indicating whether this entry is contributed to dependent
2192          *    projects in addition to the output location
2193          * @return a new container classpath entry
2194          * 
2195          * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
2196          * @see JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor)
2197          * @see JavaCore#newContainerEntry(IPath, boolean)
2198          * @since 2.0
2199          */
2200 //      public static IClasspathEntry newContainerEntry(IPath containerPath, boolean isExported) {
2201 //                      
2202 //              if (containerPath == null || containerPath.segmentCount() < 1) {
2203 //                      Assert.isTrue(
2204 //                              false,
2205 //                              "Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$
2206 //              }
2207 //              return new ClasspathEntry(
2208 //                      IPackageFragmentRoot.K_SOURCE,
2209 //                      IClasspathEntry.CPE_CONTAINER,
2210 //                      containerPath,
2211 //                      ClasspathEntry.NO_EXCLUSION_PATTERNS, 
2212 //                      null, // source attachment
2213 //                      null, // source attachment root
2214 //                      null, // specific output folder
2215 //                      isExported);
2216 //      }
2217
2218         /**
2219          * Creates and returns a new non-exported classpath entry of kind <code>CPE_LIBRARY</code> for the 
2220          * JAR or folder identified by the given absolute path. This specifies that all package fragments 
2221          * within the root will have children of type <code>IClassFile</code>.
2222          * <p>
2223          * A library entry is used to denote a prerequisite JAR or root folder containing binaries.
2224          * The target JAR or folder can either be defined internally to the workspace (absolute path relative
2225          * to the workspace root) or externally to the workspace (absolute path in the file system).
2226          * <p>
2227          * e.g. Here are some examples of binary path usage<ul>
2228          *      <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code> - reference to an external JAR</li>
2229          *      <li><code> "/Project/someLib.jar" </code> - reference to an internal JAR </li>
2230          *      <li><code> "c:/classes/" </code> - reference to an external binary folder</li>
2231          * </ul>
2232          * Note that this operation does not attempt to validate or access the 
2233          * resources at the given paths.
2234          * <p>
2235          * The resulting entry is not exported to dependent projects. This method is equivalent to
2236          * <code>newLibraryEntry(-,-,-,false)</code>.
2237          * <p>
2238          * 
2239          * @param path the absolute path of the binary archive
2240          * @param sourceAttachmentPath the absolute path of the corresponding source archive or folder, 
2241          *    or <code>null</code> if none
2242          * @param sourceAttachmentRootPath the location of the root within the source archive or folder
2243          *    or <code>null</code> if this location should be automatically detected.
2244          * @return a new library classpath entry
2245          * 
2246          * @see #newLibraryEntry(IPath, IPath, IPath, boolean)
2247          */
2248 //      public static IClasspathEntry newLibraryEntry(
2249 //              IPath path,
2250 //              IPath sourceAttachmentPath,
2251 //              IPath sourceAttachmentRootPath) {
2252 //                      
2253 //              return newLibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath, false);
2254 //      }
2255
2256         /**
2257          * Creates and returns a new classpath entry of kind <code>CPE_LIBRARY</code> for the JAR or folder
2258          * identified by the given absolute path. This specifies that all package fragments within the root 
2259          * will have children of type <code>IClassFile</code>.
2260          * <p>
2261          * A library entry is used to denote a prerequisite JAR or root folder containing binaries.
2262          * The target JAR or folder can either be defined internally to the workspace (absolute path relative
2263          * to the workspace root) or externally to the workspace (absolute path in the file system).
2264          *      <p>
2265          * e.g. Here are some examples of binary path usage<ul>
2266          *      <li><code> "c:/jdk1.2.2/jre/lib/rt.jar" </code> - reference to an external JAR</li>
2267          *      <li><code> "/Project/someLib.jar" </code> - reference to an internal JAR </li>
2268          *      <li><code> "c:/classes/" </code> - reference to an external binary folder</li>
2269          * </ul>
2270          * Note that this operation does not attempt to validate or access the 
2271          * resources at the given paths.
2272          * <p>
2273          * 
2274          * @param path the absolute path of the binary archive
2275          * @param sourceAttachmentPath the absolute path of the corresponding source archive or folder, 
2276          *    or <code>null</code> if none
2277          * @param sourceAttachmentRootPath the location of the root within the source archive or folder
2278          *    or <code>null</code> if this location should be automatically detected.
2279          * @param isExported indicates whether this entry is contributed to dependent
2280          *        projects in addition to the output location
2281          * @return a new library classpath entry
2282          * @since 2.0
2283          */
2284 //      public static IClasspathEntry newLibraryEntry(
2285 //              IPath path,
2286 //              IPath sourceAttachmentPath,
2287 //              IPath sourceAttachmentRootPath,
2288 //              boolean isExported) {
2289 //                      
2290 //              if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
2291 //
2292 //              return new ClasspathEntry(
2293 //                      IPackageFragmentRoot.K_BINARY,
2294 //                      IClasspathEntry.CPE_LIBRARY,
2295 //                      JavaProject.canonicalizedPath(path),
2296 //                      ClasspathEntry.NO_EXCLUSION_PATTERNS, 
2297 //                      sourceAttachmentPath,
2298 //                      sourceAttachmentRootPath,
2299 //                      null, // specific output folder
2300 //                      isExported);
2301 //      }
2302
2303         /**
2304          * Creates and returns a new non-exported classpath entry of kind <code>CPE_PROJECT</code>
2305          * for the project identified by the given absolute path.
2306          * <p>
2307          * A project entry is used to denote a prerequisite project on a classpath.
2308          * The referenced project will be contributed as a whole, either as sources (in the Java Model, it
2309          * contributes all its package fragment roots) or as binaries (when building, it contributes its 
2310          * whole output location).
2311          * <p>
2312          * A project reference allows to indirect through another project, independently from its internal layout. 
2313          * <p>
2314          * The prerequisite project is referred to using an absolute path relative to the workspace root.
2315          * <p>
2316          * The resulting entry is not exported to dependent projects. This method is equivalent to
2317          * <code>newProjectEntry(_,false)</code>.
2318          * <p>
2319          * 
2320          * @param path the absolute path of the binary archive
2321          * @return a new project classpath entry
2322          * 
2323          * @see JavaCore#newProjectEntry(IPath, boolean)
2324          */
2325 //      public static IClasspathEntry newProjectEntry(IPath path) {
2326 //              return newProjectEntry(path, false);
2327 //      }
2328         
2329         /**
2330          * Creates and returns a new classpath entry of kind <code>CPE_PROJECT</code>
2331          * for the project identified by the given absolute path.
2332          * <p>
2333          * A project entry is used to denote a prerequisite project on a classpath.
2334          * The referenced project will be contributed as a whole, either as sources (in the Java Model, it
2335          * contributes all its package fragment roots) or as binaries (when building, it contributes its 
2336          * whole output location).
2337          * <p>
2338          * A project reference allows to indirect through another project, independently from its internal layout. 
2339          * <p>
2340          * The prerequisite project is referred to using an absolute path relative to the workspace root.
2341          * <p>
2342          * 
2343          * @param path the absolute path of the prerequisite project
2344          * @param isExported indicates whether this entry is contributed to dependent
2345          *        projects in addition to the output location
2346          * @return a new project classpath entry
2347          * @since 2.0
2348          */
2349 //      public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) {
2350 //              
2351 //              if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
2352 //              
2353 //              return new ClasspathEntry(
2354 //                      IPackageFragmentRoot.K_SOURCE,
2355 //                      IClasspathEntry.CPE_PROJECT,
2356 //                      path,
2357 //                      ClasspathEntry.NO_EXCLUSION_PATTERNS, 
2358 //                      null, // source attachment
2359 //                      null, // source attachment root
2360 //                      null, // specific output folder
2361 //                      isExported);
2362 //      }
2363
2364         /**
2365          * Returns a new empty region.
2366          * 
2367          * @return a new empty region
2368          */
2369         public static IRegion newRegion() {
2370                 return new Region();
2371         }
2372
2373         /**
2374          * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
2375          * for the project's source folder identified by the given absolute 
2376          * workspace-relative path. This specifies that all package fragments
2377          * within the root will have children of type <code>ICompilationUnit</code>.
2378          * <p>
2379          * The source folder is referred to using an absolute path relative to the
2380          * workspace root, e.g. <code>/Project/src</code>. A project's source 
2381          * folders are located with that project. That is, a source classpath
2382          * entry specifying the path <code>/P1/src</code> is only usable for
2383          * project <code>P1</code>.
2384          * </p>
2385          * <p>
2386          * The source classpath entry created by this method includes all source
2387          * files below the given workspace-relative path. To selectively exclude
2388          * some of these source files, use the factory method 
2389          * <code>JavaCore.newSourceEntry(IPath,IPath[])</code> instead.
2390          * </p>
2391          * <p>
2392          * Note that all sources/binaries inside a project are contributed as a whole through
2393          * a project entry (see <code>JavaCore.newProjectEntry</code>). Particular
2394          * source entries cannot be selectively exported.
2395          * </p>
2396          * 
2397          * @param path the absolute workspace-relative path of a source folder
2398          * @return a new source classpath entry with not exclusion patterns
2399          * 
2400          * @see #newSourceEntry(org.eclipse.core.runtime.IPath,org.eclipse.core.runtime.IPath[])
2401          */
2402 //      public static IClasspathEntry newSourceEntry(IPath path) {
2403 //
2404 //              return newSourceEntry(path, ClasspathEntry.NO_EXCLUSION_PATTERNS, null /*output location*/);
2405 //      }
2406         
2407         /**
2408          * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
2409          * for the project's source folder identified by the given absolute 
2410          * workspace-relative path but excluding all source files with paths
2411          * matching any of the given patterns. This specifies that all package
2412          * fragments within the root will have children of type 
2413          * <code>ICompilationUnit</code>.
2414          * <p>
2415          * The source folder is referred to using an absolute path relative to the
2416          * workspace root, e.g. <code>/Project/src</code>. A project's source 
2417          * folders are located with that project. That is, a source classpath
2418          * entry specifying the path <code>/P1/src</code> is only usable for
2419          * project <code>P1</code>.
2420          * </p>
2421          * <p>
2422          * The source classpath entry created by this method includes all source
2423          * files below the given workspace-relative path except for those matched
2424          * by one (or more) of the given exclusion patterns. Each exclusion pattern
2425          * is represented by a relative path, which is interpreted as relative to
2426          * the source folder. For example, if the source folder path is 
2427          * <code>/Project/src</code> and the exclusion pattern is 
2428          * <code>com/xyz/tests/&#42;&#42;</code>, then source files
2429          * like <code>/Project/src/com/xyz/Foo.java</code>
2430          * and <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
2431          * whereas <code>/Project/src/com/xyz/tests/T1.java</code>
2432          * and <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
2433          * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
2434          * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code>
2435          * for the full description of the syntax and semantics of exclusion
2436          * patterns.
2437          * </p>
2438          * If the empty list of exclusion patterns is specified, the source folder
2439          * will automatically include all resources located inside the source
2440          * folder. In that case, the result is entirely equivalent to using the
2441          * factory method <code>JavaCore.newSourceEntry(IPath)</code>. 
2442          * </p>
2443          * <p>
2444          * Note that all sources/binaries inside a project are contributed as a whole through
2445          * a project entry (see <code>JavaCore.newProjectEntry</code>). Particular
2446          * source entries cannot be selectively exported.
2447          * </p>
2448          *
2449          * @param path the absolute workspace-relative path of a source folder
2450          * @param exclusionPatterns the possibly empty list of exclusion patterns
2451          *    represented as relative paths
2452          * @return a new source classpath entry with the given exclusion patterns
2453          * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
2454          * @see IClasspathEntry#getExclusionPatterns
2455          * 
2456          * @since 2.1
2457          */
2458 //      public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns) {
2459 //
2460 //              return newSourceEntry(path, exclusionPatterns, null /*output location*/); 
2461 //      }
2462
2463         /**
2464          * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
2465          * for the project's source folder identified by the given absolute 
2466          * workspace-relative path but excluding all source files with paths
2467          * matching any of the given patterns, and associated with a specific output location
2468          * (that is, ".class" files are not going to the project default output location). 
2469          * All package fragments within the root will have children of type 
2470          * <code>ICompilationUnit</code>.
2471          * <p>
2472          * The source folder is referred to using an absolute path relative to the
2473          * workspace root, e.g. <code>/Project/src</code>. A project's source 
2474          * folders are located with that project. That is, a source classpath
2475          * entry specifying the path <code>/P1/src</code> is only usable for
2476          * project <code>P1</code>.
2477          * </p>
2478          * <p>
2479          * The source classpath entry created by this method includes all source
2480          * files below the given workspace-relative path except for those matched
2481          * by one (or more) of the given exclusion patterns. Each exclusion pattern
2482          * is represented by a relative path, which is interpreted as relative to
2483          * the source folder. For example, if the source folder path is 
2484          * <code>/Project/src</code> and the exclusion pattern is 
2485          * <code>com/xyz/tests/&#42;&#42;</code>, then source files
2486          * like <code>/Project/src/com/xyz/Foo.java</code>
2487          * and <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
2488          * whereas <code>/Project/src/com/xyz/tests/T1.java</code>
2489          * and <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
2490          * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
2491          * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code>
2492          * for the full description of the syntax and semantics of exclusion
2493          * patterns.
2494          * </p>
2495          * If the empty list of exclusion patterns is specified, the source folder
2496          * will automatically include all resources located inside the source
2497          * folder. In that case, the result is entirely equivalent to using the
2498          * factory method <code>JavaCore.newSourceEntry(IPath)</code>. 
2499          * </p>
2500          * <p>
2501          * Additionally, a source entry can be associated with a specific output location. 
2502          * By doing so, the Java builder will ensure that the generated ".class" files will 
2503          * be issued inside this output location, as opposed to be generated into the 
2504          * project default output location (when output location is <code>null</code>). 
2505          * Note that multiple source entries may target the same output location.
2506          * The output location is referred to using an absolute path relative to the 
2507          * workspace root, e.g. <code>"/Project/bin"</code>, it must be located inside 
2508          * the same project as the source folder.
2509          * </p>
2510          * <p>
2511          * Also note that all sources/binaries inside a project are contributed as a whole through
2512          * a project entry (see <code>JavaCore.newProjectEntry</code>). Particular
2513          * source entries cannot be selectively exported.
2514          * </p>
2515          *
2516          * @param path the absolute workspace-relative path of a source folder
2517          * @param exclusionPatterns the possibly empty list of exclusion patterns
2518          *    represented as relative paths
2519          * @param outputLocation the specific output location for this source entry (<code>null</code> if using project default ouput location)
2520          * @return a new source classpath entry with the given exclusion patterns
2521          * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
2522          * @see IClasspathEntry#getExclusionPatterns
2523          * @see IClasspathEntry#getOutputLocation()
2524          * 
2525          * @since 2.1
2526          */
2527 //      public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns, IPath specificOutputLocation) {
2528 //
2529 //              if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
2530 //              if (exclusionPatterns == null) Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$
2531 //
2532 //              return new ClasspathEntry(
2533 //                      IPackageFragmentRoot.K_SOURCE,
2534 //                      IClasspathEntry.CPE_SOURCE,
2535 //                      path,
2536 //                      exclusionPatterns,
2537 //                      null, // source attachment
2538 //                      null, // source attachment root
2539 //                      specificOutputLocation, // custom output location
2540 //                      false);
2541 //      }
2542                 
2543         /**
2544          * Creates and returns a new non-exported classpath entry of kind <code>CPE_VARIABLE</code>
2545          * for the given path. The first segment of the path is the name of a classpath variable.
2546          * The trailing segments of the path will be appended to resolved variable path.
2547          * <p>
2548          * A variable entry allows to express indirect references on a classpath to other projects or libraries,
2549          * depending on what the classpath variable is referring.
2550          * <p>
2551          *      It is possible to register an automatic initializer (<code>ClasspathVariableInitializer</code>),
2552          * which will be invoked through the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
2553          * After resolution, a classpath variable entry may either correspond to a project or a library entry. </li>     
2554          * <p>
2555          * e.g. Here are some examples of variable path usage<ul>
2556          * <li> "JDTCORE" where variable <code>JDTCORE</code> is 
2557          *              bound to "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the library "c:\jars\jdtcore.jar"</li>
2558          * <li> "JDTCORE" where variable <code>JDTCORE</code> is 
2559          *              bound to "/Project_JDTCORE". The resolved classpath entry is denoting the project "/Project_JDTCORE"</li>
2560          * <li> "PLUGINS/com.example/example.jar" where variable <code>PLUGINS</code>
2561          *      is bound to "c:/eclipse/plugins". The resolved classpath entry is denoting the library "c:/eclipse/plugins/com.example/example.jar"</li>
2562          * </ul>
2563          * Note that this operation does not attempt to validate classpath variables
2564          * or access the resources at the given paths.
2565          * <p>
2566          * The resulting entry is not exported to dependent projects. This method is equivalent to
2567          * <code>newVariableEntry(-,-,-,false)</code>.
2568          * <p>
2569          * 
2570          * @param variablePath the path of the binary archive; first segment is the
2571          *   name of a classpath variable
2572          * @param variableSourceAttachmentPath the path of the corresponding source archive, 
2573          *    or <code>null</code> if none; if present, the first segment is the
2574          *    name of a classpath variable (not necessarily the same variable
2575          *    as the one that begins <code>variablePath</code>)
2576          * @param sourceAttachmentRootPath the location of the root within the source archive
2577          *    or <code>null</code> if <code>archivePath</code> is also <code>null</code>
2578          * @return a new library classpath entry
2579          * 
2580          * @see JavaCore#newVariableEntry(IPath, IPath, IPath, boolean)
2581          */
2582 //      public static IClasspathEntry newVariableEntry(
2583 //              IPath variablePath,
2584 //              IPath variableSourceAttachmentPath,
2585 //              IPath sourceAttachmentRootPath) {
2586 //
2587 //              return newVariableEntry(variablePath, variableSourceAttachmentPath, sourceAttachmentRootPath, false);
2588 //      }
2589
2590         /**
2591          * Creates and returns a new non-exported classpath entry of kind <code>CPE_VARIABLE</code>
2592          * for the given path. The first segment of the path is the name of a classpath variable.
2593          * The trailing segments of the path will be appended to resolved variable path.
2594          * <p>
2595          * A variable entry allows to express indirect references on a classpath to other projects or libraries,
2596          * depending on what the classpath variable is referring.
2597          * <p>
2598          *      It is possible to register an automatic initializer (<code>ClasspathVariableInitializer</code>),
2599          * which will be invoked through the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
2600          * After resolution, a classpath variable entry may either correspond to a project or a library entry. </li>     
2601          * <p>
2602          * e.g. Here are some examples of variable path usage<ul>
2603          * <li> "JDTCORE" where variable <code>JDTCORE</code> is 
2604          *              bound to "c:/jars/jdtcore.jar". The resolved classpath entry is denoting the library "c:\jars\jdtcore.jar"</li>
2605          * <li> "JDTCORE" where variable <code>JDTCORE</code> is 
2606          *              bound to "/Project_JDTCORE". The resolved classpath entry is denoting the project "/Project_JDTCORE"</li>
2607          * <li> "PLUGINS/com.example/example.jar" where variable <code>PLUGINS</code>
2608          *      is bound to "c:/eclipse/plugins". The resolved classpath entry is denoting the library "c:/eclipse/plugins/com.example/example.jar"</li>
2609          * </ul>
2610          * Note that this operation does not attempt to validate classpath variables
2611          * or access the resources at the given paths.
2612          * <p>
2613          *
2614          * @param variablePath the path of the binary archive; first segment is the
2615          *   name of a classpath variable
2616          * @param variableSourceAttachmentPath the path of the corresponding source archive, 
2617          *    or <code>null</code> if none; if present, the first segment is the
2618          *    name of a classpath variable (not necessarily the same variable
2619          *    as the one that begins <code>variablePath</code>)
2620          * @param sourceAttachmentRootPath the location of the root within the source archive
2621          *    or <code>null</code> if <code>archivePath</code> is also <code>null</code>
2622          * @param isExported indicates whether this entry is contributed to dependent
2623          *        projects in addition to the output location
2624          * @return a new variable classpath entry
2625          * @since 2.0
2626          */
2627 //      public static IClasspathEntry newVariableEntry(
2628 //              IPath variablePath,
2629 //              IPath variableSourceAttachmentPath,
2630 //              IPath variableSourceAttachmentRootPath,
2631 //              boolean isExported) {
2632 //                      
2633 //              if (variablePath == null || variablePath.segmentCount() < 1) {
2634 //                      Assert.isTrue(
2635 //                              false,
2636 //                              "Illegal classpath variable path: \'" + variablePath.makeRelative().toString() + "\', must have at least one segment"); //$NON-NLS-1$//$NON-NLS-2$
2637 //              }
2638 //      
2639 //              return new ClasspathEntry(
2640 //                      IPackageFragmentRoot.K_SOURCE,
2641 //                      IClasspathEntry.CPE_VARIABLE,
2642 //                      variablePath,
2643 //                      ClasspathEntry.NO_EXCLUSION_PATTERNS, 
2644 //                      variableSourceAttachmentPath, // source attachment
2645 //                      variableSourceAttachmentRootPath, // source attachment root                     
2646 //                      null, // specific output folder
2647 //                      isExported);
2648 //      }
2649
2650         /**
2651          * Removed the given classpath variable. Does nothing if no value was
2652          * set for this classpath variable.
2653          * <p>
2654          * This functionality cannot be used while the resource tree is locked.
2655          * <p>
2656          * Classpath variable values are persisted locally to the workspace, and 
2657          * are preserved from session to session.
2658          * <p>
2659          *
2660          * @param variableName the name of the classpath variable
2661          * @see #setClasspathVariable
2662          *
2663          * @deprecated - use version with extra IProgressMonitor
2664          */
2665 //      public static void removeClasspathVariable(String variableName) {
2666 //              removeClasspathVariable(variableName, null);
2667 //      }
2668
2669         /**
2670          * Removed the given classpath variable. Does nothing if no value was
2671          * set for this classpath variable.
2672          * <p>
2673          * This functionality cannot be used while the resource tree is locked.
2674          * <p>
2675          * Classpath variable values are persisted locally to the workspace, and 
2676          * are preserved from session to session.
2677          * <p>
2678          *
2679          * @param variableName the name of the classpath variable
2680          * @param monitor the progress monitor to report progress
2681          * @see #setClasspathVariable
2682          */
2683 //      public static void removeClasspathVariable(
2684 //              String variableName,
2685 //              IProgressMonitor monitor) {
2686 //
2687 //              try {
2688 //                      updateVariableValues(new String[]{ variableName}, new IPath[]{ null }, monitor);
2689 //              } catch (JavaModelException e) {
2690 //              }
2691 //      }
2692
2693         /**
2694          * Removes the given element changed listener.
2695          * Has no affect if an identical listener is not registered.
2696          *
2697          * @param listener the listener
2698          */
2699         public static void removeElementChangedListener(IElementChangedListener listener) {
2700                 JavaModelManager.getJavaModelManager().removeElementChangedListener(listener);
2701         }
2702         /**
2703          * Runs the given action as an atomic Java model operation.
2704          * <p>
2705          * After running a method that modifies Java elements,
2706          * registered listeners receive after-the-fact notification of
2707          * what just transpired, in the form of a element changed event.
2708          * This method allows clients to call a number of
2709          * methods that modify java elements and only have element
2710          * changed event notifications reported at the end of the entire
2711          * batch.
2712          * </p>
2713          * <p>
2714          * If this method is called outside the dynamic scope of another such
2715          * call, this method runs the action and then reports a single
2716          * element changed event describing the net effect of all changes
2717          * done to java elements by the action.
2718          * </p>
2719          * <p>
2720          * If this method is called in the dynamic scope of another such
2721          * call, this method simply runs the action.
2722          * </p>
2723          *
2724          * @param action the action to perform
2725          * @param monitor a progress monitor, or <code>null</code> if progress
2726          *    reporting and cancellation are not desired
2727          * @exception CoreException if the operation failed.
2728          * @since 2.1
2729          */
2730         public static void run(IWorkspaceRunnable action, IProgressMonitor monitor) throws CoreException {
2731                 IWorkspace workspace = ResourcesPlugin.getWorkspace();
2732                 if (workspace.isTreeLocked()) {
2733                         new BatchOperation(action).run(monitor);
2734                 } else {
2735                         // use IWorkspace.run(...) to ensure that a build will be done in autobuild mode
2736                         workspace.run(new BatchOperation(action), monitor);
2737                 }
2738         }
2739         /** 
2740          * Bind a container reference path to some actual containers (<code>IClasspathContainer</code>).
2741          * This API must be invoked whenever changes in container need to be reflected onto the JavaModel.
2742          * Containers can have distinct values in different projects, therefore this API considers a
2743          * set of projects with their respective containers.
2744          * <p>
2745          * <code>containerPath</code> is the path under which these values can be referenced through
2746          * container classpath entries (<code>IClasspathEntry#CPE_CONTAINER</code>). A container path 
2747          * is formed by a first ID segment followed with extra segments, which can be used as additional hints
2748          * for the resolution. The container ID is used to identify a <code>ClasspathContainerInitializer</code> 
2749          * registered on the extension point "org.eclipse.jdt.core.classpathContainerInitializer".
2750          * <p>
2751          * There is no assumption that each individual container value passed in argument 
2752          * (<code>respectiveContainers</code>) must answer the exact same path when requested 
2753          * <code>IClasspathContainer#getPath</code>. 
2754          * Indeed, the containerPath is just an indication for resolving it to an actual container object. It can be 
2755          * delegated to a <code>ClasspathContainerInitializer</code>, which can be activated through the extension
2756          * point "org.eclipse.jdt.core.ClasspathContainerInitializer"). 
2757          * <p>
2758          * In reaction to changing container values, the JavaModel will be updated to reflect the new
2759          * state of the updated container. 
2760          * <p>
2761          * This functionality cannot be used while the resource tree is locked.
2762          * <p>
2763          * Classpath container values are persisted locally to the workspace, but 
2764          * are not preserved from a session to another. It is thus highly recommended to register a 
2765          * <code>ClasspathContainerInitializer</code> for each referenced container 
2766          * (through the extension point "org.eclipse.jdt.core.ClasspathContainerInitializer").
2767          * <p>
2768          * Note: setting a container to <code>null</code> will cause it to be lazily resolved again whenever
2769          * its value is required. In particular, this will cause a registered initializer to be invoked
2770          * again.
2771          * <p>
2772          * @param containerPath - the name of the container reference, which is being updated
2773          * @param affectedProjects - the set of projects for which this container is being bound
2774          * @param respectiveContainers - the set of respective containers for the affected projects
2775          * @param monitor a monitor to report progress
2776          * 
2777          * @see ClasspathContainerInitializer
2778          * @see #getClasspathContainer(IPath, IJavaProject)
2779          * @see IClasspathContainer
2780          * @since 2.0
2781          */
2782 //      public static void setClasspathContainer(final IPath containerPath, IJavaProject[] affectedProjects, IClasspathContainer[] respectiveContainers, IProgressMonitor monitor) throws JavaModelException {
2783 //
2784 //              if (affectedProjects.length != respectiveContainers.length) Assert.isTrue(false, "Projects and containers collections should have the same size"); //$NON-NLS-1$
2785 //      
2786 //              if (monitor != null && monitor.isCanceled()) return;
2787 //      
2788 //              if (JavaModelManager.CP_RESOLVE_VERBOSE){
2789 //                      System.out.println("CPContainer SET  - setting container: ["+containerPath+"] for projects: {" //$NON-NLS-1$ //$NON-NLS-2$
2790 //                              + (Util.toString(affectedProjects, 
2791 //                                              new Util.Displayable(){ 
2792 //                                                      public String displayString(Object o) { return ((IJavaProject) o).getElementName(); }
2793 //                                              }))
2794 //                              + "} with values: " //$NON-NLS-1$
2795 //                              + (Util.toString(respectiveContainers, 
2796 //                                              new Util.Displayable(){ 
2797 //                                                      public String displayString(Object o) { return ((IClasspathContainer) o).getDescription(); }
2798 //                                              }))
2799 //                                      );
2800 //              }
2801 //
2802 //              final int projectLength = affectedProjects.length;
2803 //              final IJavaProject[] modifiedProjects;
2804 //              System.arraycopy(affectedProjects, 0, modifiedProjects = new IJavaProject[projectLength], 0, projectLength);
2805 //              final IClasspathEntry[][] oldResolvedPaths = new IClasspathEntry[projectLength][];
2806 //                      
2807 //              // filter out unmodified project containers
2808 //              int remaining = 0;
2809 //              for (int i = 0; i < projectLength; i++){
2810 //      
2811 //                      if (monitor != null && monitor.isCanceled()) return;
2812 //      
2813 //                      IJavaProject affectedProject = affectedProjects[i];
2814 //                      IClasspathContainer newContainer = respectiveContainers[i];
2815 //                      if (newContainer == null) newContainer = JavaModelManager.ContainerInitializationInProgress; // 30920 - prevent infinite loop
2816 //                      boolean found = false;
2817 //                      if (JavaProject.hasJavaNature(affectedProject.getProject())){
2818 //                              IClasspathEntry[] rawClasspath = affectedProject.getRawClasspath();
2819 //                              for (int j = 0, cpLength = rawClasspath.length; j <cpLength; j++) {
2820 //                                      IClasspathEntry entry = rawClasspath[j];
2821 //                                      if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER && entry.getPath().equals(containerPath)){
2822 //                                              found = true;
2823 //                                              break;
2824 //                                      }
2825 //                              }
2826 //                      }
2827 //                      if (!found){
2828 //                              modifiedProjects[i] = null; // filter out this project - does not reference the container path, or isnt't yet Java project
2829 //                              JavaModelManager.containerPut(affectedProject, containerPath, newContainer);
2830 //                              continue;
2831 //                      }
2832 //                      IClasspathContainer oldContainer = JavaModelManager.containerGet(affectedProject, containerPath);
2833 //                      if (oldContainer == JavaModelManager.ContainerInitializationInProgress) {
2834 //                              Map previousContainerValues = (Map)JavaModelManager.PreviousSessionContainers.get(affectedProject);
2835 //                              if (previousContainerValues != null){
2836 //                                      IClasspathContainer previousContainer = (IClasspathContainer)previousContainerValues.get(containerPath);
2837 //                                      if (previousContainer != null) {
2838 //                                              if (JavaModelManager.CP_RESOLVE_VERBOSE){
2839 //                                                      System.out.println("CPContainer INIT - reentering access to project container: ["+affectedProject.getElementName()+"] " + containerPath + " during its initialization, will see previous value: "+ previousContainer.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
2840 //                                              }
2841 //                                              JavaModelManager.containerPut(affectedProject, containerPath, previousContainer); 
2842 //                                      }
2843 //                                      oldContainer = null; //33695 - cannot filter out restored container, must update affected project to reset cached CP
2844 //                              } else {
2845 //                                      oldContainer = null;
2846 //                              }
2847 //                      }
2848 //                      if (oldContainer != null && oldContainer.equals(respectiveContainers[i])){// TODO: could improve to only compare entries
2849 //                              modifiedProjects[i] = null; // filter out this project - container did not change
2850 //                              continue;
2851 //                      }
2852 //                      remaining++; 
2853 //                      oldResolvedPaths[i] = affectedProject.getResolvedClasspath(true);
2854 //                      JavaModelManager.containerPut(affectedProject, containerPath, newContainer);
2855 //              }
2856 //              
2857 //              if (remaining == 0) return;
2858 //              
2859 //              // trigger model refresh
2860 //              try {
2861 //                      JavaCore.run(new IWorkspaceRunnable() {
2862 //                              public void run(IProgressMonitor monitor) throws CoreException {
2863 //                                      for(int i = 0; i < projectLength; i++){
2864 //              
2865 //                                              if (monitor != null && monitor.isCanceled()) return;
2866 //              
2867 //                                              JavaProject affectedProject = (JavaProject)modifiedProjects[i];
2868 //                                              if (affectedProject == null) continue; // was filtered out
2869 //                                              
2870 //                                              if (JavaModelManager.CP_RESOLVE_VERBOSE){
2871 //                                                      System.out.println("CPContainer SET  - updating affected project: ["+affectedProject.getElementName()+"] due to setting container: " + containerPath); //$NON-NLS-1$ //$NON-NLS-2$
2872 //                                              }
2873 //
2874 //                                              // force a refresh of the affected project (will compute deltas)
2875 //                                              affectedProject.setRawClasspath(
2876 //                                                              affectedProject.getRawClasspath(),
2877 //                                                              SetClasspathOperation.ReuseOutputLocation,
2878 //                                                              monitor,
2879 //                                                              !ResourcesPlugin.getWorkspace().isTreeLocked(), // can save resources
2880 //                                                              oldResolvedPaths[i],
2881 //                                                              false, // updating - no validation
2882 //                                                              false); // updating - no need to save
2883 //                                      }
2884 //                              }
2885 //                      },
2886 //                      monitor);
2887 //              } catch(CoreException e) {
2888 //                      if (JavaModelManager.CP_RESOLVE_VERBOSE){
2889 //                              System.out.println("CPContainer SET  - FAILED DUE TO EXCEPTION: "+containerPath); //$NON-NLS-1$
2890 //                              e.printStackTrace();
2891 //                      }
2892 //                      if (e instanceof JavaModelException) {
2893 //                              throw (JavaModelException)e;
2894 //                      } else {
2895 //                              throw new JavaModelException(e);
2896 //                      }
2897 //              } finally {
2898 //                      for (int i = 0; i < projectLength; i++) {
2899 //                              if (respectiveContainers[i] == null) {
2900 //                                      JavaModelManager.containerPut(affectedProjects[i], containerPath, null); // reset init in progress marker
2901 //                              }
2902 //                      }
2903 //              }
2904 //                                      
2905 //      }
2906
2907         /**
2908          * Sets the value of the given classpath variable.
2909          * The path must have at least one segment.
2910          * <p>
2911          * This functionality cannot be used while the resource tree is locked.
2912          * <p>
2913          * Classpath variable values are persisted locally to the workspace, and 
2914          * are preserved from session to session.
2915          * <p>
2916          *
2917          * @param variableName the name of the classpath variable
2918          * @param path the path
2919          * @see #getClasspathVariable
2920          *
2921          * @deprecated - use API with IProgressMonitor
2922          */
2923 //      public static void setClasspathVariable(String variableName, IPath path)
2924 //              throws JavaModelException {
2925 //
2926 //              setClasspathVariable(variableName, path, null);
2927 //      }
2928
2929         /**
2930          * Sets the value of the given classpath variable.
2931          * The path must not be null.
2932          * <p>
2933          * This functionality cannot be used while the resource tree is locked.
2934          * <p>
2935          * Classpath variable values are persisted locally to the workspace, and 
2936          * are preserved from session to session.
2937          * <p>
2938          * Updating a variable with the same value has no effect.
2939          *
2940          * @param variableName the name of the classpath variable
2941          * @param path the path
2942          * @param monitor a monitor to report progress
2943          * @see #getClasspathVariable
2944          */
2945 //      public static void setClasspathVariable(
2946 //              String variableName,
2947 //              IPath path,
2948 //              IProgressMonitor monitor)
2949 //              throws JavaModelException {
2950 //
2951 //              if (path == null) Assert.isTrue(false, "Variable path cannot be null"); //$NON-NLS-1$
2952 //              setClasspathVariables(new String[]{variableName}, new IPath[]{ path }, monitor);
2953 //      }
2954
2955         /**
2956          * Sets the values of all the given classpath variables at once.
2957          * Null paths can be used to request corresponding variable removal.
2958          * <p>
2959          * This functionality cannot be used while the resource tree is locked.
2960          * <p>
2961          * Classpath variable values are persisted locally to the workspace, and 
2962          * are preserved from session to session.
2963          * <p>
2964          * Updating a variable with the same value has no effect.
2965          * 
2966          * @param variableNames an array of names for the updated classpath variables
2967          * @param paths an array of path updates for the modified classpath variables (null
2968          *       meaning that the corresponding value will be removed
2969          * @param monitor a monitor to report progress
2970          * @see #getClasspathVariable
2971          * @since 2.0
2972          */
2973 //      public static void setClasspathVariables(
2974 //              String[] variableNames,
2975 //              IPath[] paths,
2976 //              IProgressMonitor monitor)
2977 //              throws JavaModelException {
2978 //
2979 //              if (variableNames.length != paths.length)       Assert.isTrue(false, "Variable names and paths collections should have the same size"); //$NON-NLS-1$
2980 //              //TODO: should check that null cannot be used as variable paths
2981 //              updateVariableValues(variableNames, paths, monitor);
2982 //      }
2983
2984         /* (non-Javadoc)
2985          * Method declared on IExecutableExtension.
2986          * Record any necessary initialization data from the plugin.
2987          */
2988         public void setInitializationData(
2989                 IConfigurationElement cfig,
2990                 String propertyName,
2991                 Object data)
2992                 throws CoreException {
2993         }
2994
2995         /**
2996          * Sets the current table of options. All and only the options explicitly included in the given table 
2997          * are remembered; all previous option settings are forgotten, including ones not explicitly
2998          * mentioned.
2999          * <p>
3000          * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
3001          * </p>
3002          * 
3003          * @param newOptions the new options (key type: <code>String</code>; value type: <code>String</code>),
3004          *   or <code>null</code> to reset all options to their default values
3005          * @see JavaCore#getDefaultOptions
3006          */
3007         public static void setOptions(Hashtable newOptions) {
3008                 
3009                 // see #initializeDefaultPluginPreferences() for changing default settings
3010                 Preferences preferences = getPlugin().getPluginPreferences();
3011
3012                 if (newOptions == null){
3013                         newOptions = JavaCore.getDefaultOptions();
3014                 }
3015                 Enumeration keys = newOptions.keys();
3016                 while (keys.hasMoreElements()){
3017                         String key = (String)keys.nextElement();
3018                         if (!JavaModelManager.OptionNames.contains(key)) continue; // unrecognized option
3019                         if (key.equals(CORE_ENCODING)) continue; // skipped, contributed by resource prefs
3020                         String value = (String)newOptions.get(key);
3021                         preferences.setValue(key, value);
3022                 }
3023                 
3024                 // persist options
3025                 getPlugin().savePluginPreferences();
3026         }
3027         
3028         /**
3029          * Shutdown the JavaCore plug-in.
3030          * <p>
3031          * De-registers the JavaModelManager as a resource changed listener and save participant.
3032          * <p>
3033          * @see org.eclipse.core.runtime.Plugin#shutdown()
3034          */
3035         public void shutdown() {
3036
3037                 savePluginPreferences();
3038                 IWorkspace workspace = ResourcesPlugin.getWorkspace();
3039                 workspace.removeResourceChangeListener(JavaModelManager.getJavaModelManager().deltaProcessor);
3040                 workspace.removeSaveParticipant(this);
3041
3042                 ((JavaModelManager) JavaModelManager.getJavaModelManager()).shutdown();
3043         }
3044
3045         /**
3046          * Initiate the background indexing process.
3047          * This should be deferred after the plugin activation.
3048          */
3049 //      private void startIndexing() {
3050 //
3051 //              JavaModelManager.getJavaModelManager().getIndexManager().reset();
3052 //      }
3053
3054         /**
3055          * Startup of the JavaCore plug-in.
3056          * <p>
3057          * Registers the JavaModelManager as a resource changed listener and save participant.
3058          * Starts the background indexing, and restore saved classpath variable values.
3059          * <p>
3060          * @see org.eclipse.core.runtime.Plugin#startup()
3061          */
3062         public void startup() {
3063                 
3064                 JavaModelManager manager = JavaModelManager.getJavaModelManager();
3065                 try {
3066                         manager.configurePluginDebugOptions();
3067
3068                         // request state folder creation (workaround 19885)
3069                         JavaCore.getPlugin().getStateLocation();
3070
3071                         // retrieve variable values
3072                         JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new JavaModelManager.PluginPreferencesListener());
3073 //              TODO khartlage temp-del
3074 //                      manager.loadVariablesAndContainers();
3075
3076                         IWorkspace workspace = ResourcesPlugin.getWorkspace();
3077                         workspace.addResourceChangeListener(
3078                                 manager.deltaProcessor,
3079                                 IResourceChangeEvent.PRE_AUTO_BUILD
3080                                         | IResourceChangeEvent.POST_AUTO_BUILD
3081                                         | IResourceChangeEvent.POST_CHANGE
3082                                         | IResourceChangeEvent.PRE_DELETE
3083                                         | IResourceChangeEvent.PRE_CLOSE);
3084
3085 //                      startIndexing();
3086                         workspace.addSaveParticipant(this, manager);
3087                         
3088                 } catch (CoreException e) {
3089                 } catch (RuntimeException e) {
3090                         manager.shutdown();
3091                         throw e;
3092                 }
3093         }
3094
3095
3096         /**
3097          * Internal updating of a variable values (null path meaning removal), allowing to change multiple variable values at once.
3098          */
3099 //      private static void updateVariableValues(
3100 //              String[] variableNames,
3101 //              IPath[] variablePaths,
3102 //              IProgressMonitor monitor) throws JavaModelException {
3103 //      
3104 //              if (monitor != null && monitor.isCanceled()) return;
3105 //              
3106 //              if (JavaModelManager.CP_RESOLVE_VERBOSE){
3107 //                      System.out.println("CPVariable SET  - setting variables: {" + Util.toString(variableNames)  //$NON-NLS-1$
3108 //                              + "} with values: " + Util.toString(variablePaths)); //$NON-NLS-1$
3109 //              }
3110 //
3111 //              int varLength = variableNames.length;
3112 //              
3113 //              // gather classpath information for updating
3114 //              final HashMap affectedProjects = new HashMap(5);
3115 //              JavaModelManager manager = JavaModelManager.getJavaModelManager();
3116 //              IJavaModel model = manager.getJavaModel();
3117 //      
3118 //              // filter out unmodified variables
3119 //              int discardCount = 0;
3120 //              for (int i = 0; i < varLength; i++){
3121 //                      String variableName = variableNames[i];
3122 //                      IPath oldPath = (IPath)JavaModelManager.variableGet(variableName); // if reentering will provide previous session value 
3123 //                      if (oldPath == JavaModelManager.VariableInitializationInProgress){
3124 //                              IPath previousPath = (IPath)JavaModelManager.PreviousSessionVariables.get(variableName);
3125 //                              if (previousPath != null){
3126 //                                      if (JavaModelManager.CP_RESOLVE_VERBOSE){
3127 //                                              System.out.println("CPVariable INIT - reentering access to variable: " + variableName+ " during its initialization, will see previous value: "+ previousPath); //$NON-NLS-1$ //$NON-NLS-2$
3128 //                                      }
3129 //                                      JavaModelManager.variablePut(variableName, previousPath); // replace value so reentering calls are seeing old value
3130 //                              }
3131 //                              oldPath = null;  //33695 - cannot filter out restored variable, must update affected project to reset cached CP
3132 //                      }
3133 //                      if (oldPath != null && oldPath.equals(variablePaths[i])){
3134 //                              variableNames[i] = null;
3135 //                              discardCount++;
3136 //                      }
3137 //              }
3138 //              if (discardCount > 0){
3139 //                      if (discardCount == varLength) return;
3140 //                      int changedLength = varLength - discardCount;
3141 //                      String[] changedVariableNames = new String[changedLength];
3142 //                      IPath[] changedVariablePaths = new IPath[changedLength];
3143 //                      for (int i = 0, index = 0; i < varLength; i++){
3144 //                              if (variableNames[i] != null){
3145 //                                      changedVariableNames[index] = variableNames[i];
3146 //                                      changedVariablePaths[index] = variablePaths[i];
3147 //                                      index++;
3148 //                              }
3149 //                      }
3150 //                      variableNames = changedVariableNames;
3151 //                      variablePaths = changedVariablePaths;
3152 //                      varLength = changedLength;
3153 //              }
3154 //              
3155 //              if (monitor != null && monitor.isCanceled()) return;
3156 //
3157 //              if (model != null) {
3158 //                      IJavaProject[] projects = model.getJavaProjects();
3159 //                      nextProject : for (int i = 0, projectLength = projects.length; i < projectLength; i++){
3160 //                              IJavaProject project = projects[i];
3161 //                                              
3162 //                              // check to see if any of the modified variables is present on the classpath
3163 //                              IClasspathEntry[] classpath = project.getRawClasspath();
3164 //                              for (int j = 0, cpLength = classpath.length; j < cpLength; j++){
3165 //                                      
3166 //                                      IClasspathEntry entry = classpath[j];
3167 //                                      for (int k = 0; k < varLength; k++){
3168 //      
3169 //                                              String variableName = variableNames[k];                                         
3170 //                                              if (entry.getEntryKind() ==  IClasspathEntry.CPE_VARIABLE){
3171 //      
3172 //                                                      if (variableName.equals(entry.getPath().segment(0))){
3173 //                                                              affectedProjects.put(project, project.getResolvedClasspath(true));
3174 //                                                              continue nextProject;
3175 //                                                      }
3176 //                                                      IPath sourcePath, sourceRootPath;
3177 //                                                      if (((sourcePath = entry.getSourceAttachmentPath()) != null     && variableName.equals(sourcePath.segment(0)))
3178 //                                                              || ((sourceRootPath = entry.getSourceAttachmentRootPath()) != null      && variableName.equals(sourceRootPath.segment(0)))) {
3179 //      
3180 //                                                              affectedProjects.put(project, project.getResolvedClasspath(true));
3181 //                                                              continue nextProject;
3182 //                                                      }
3183 //                                              }                                                                                               
3184 //                                      }
3185 //                              }
3186 //                      }
3187 //              }
3188 //              // update variables
3189 //              for (int i = 0; i < varLength; i++){
3190 //                      JavaModelManager.variablePut(variableNames[i], variablePaths[i]);
3191 //              }
3192 //              final String[] dbgVariableNames = variableNames;
3193 //                              
3194 //              // update affected project classpaths
3195 //              if (!affectedProjects.isEmpty()) {
3196 //                      try {
3197 //                              JavaCore.run(
3198 //                                      new IWorkspaceRunnable() {
3199 //                                              public void run(IProgressMonitor monitor) throws CoreException {
3200 //                                                      // propagate classpath change
3201 //                                                      Iterator projectsToUpdate = affectedProjects.keySet().iterator();
3202 //                                                      while (projectsToUpdate.hasNext()) {
3203 //                      
3204 //                                                              if (monitor != null && monitor.isCanceled()) return;
3205 //                      
3206 //                                                              JavaProject project = (JavaProject) projectsToUpdate.next();
3207 //
3208 //                                                              if (JavaModelManager.CP_RESOLVE_VERBOSE){
3209 //                                                                      System.out.println("CPVariable SET  - updating affected project: ["+project.getElementName()+"] due to setting variables: "+ Util.toString(dbgVariableNames)); //$NON-NLS-1$ //$NON-NLS-2$
3210 //                                                              }
3211 //                                                              
3212 //                                                              project
3213 //                                                                      .setRawClasspath(
3214 //                                                                              project.getRawClasspath(),
3215 //                                                                              SetClasspathOperation.ReuseOutputLocation,
3216 //                                                                              null, // don't call beginTask on the monitor (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=3717)
3217 //                                                                              !ResourcesPlugin.getWorkspace().isTreeLocked(), // can change resources
3218 //                                                                              (IClasspathEntry[]) affectedProjects.get(project),
3219 //                                                                              false, // updating - no validation
3220 //                                                                              false); // updating - no need to save
3221 //                                                      }
3222 //                                              }
3223 //                                      },
3224 //                                      monitor);
3225 //                      } catch (CoreException e) {
3226 //                              if (JavaModelManager.CP_RESOLVE_VERBOSE){
3227 //                                      System.out.println("CPVariable SET  - FAILED DUE TO EXCEPTION: "+Util.toString(dbgVariableNames)); //$NON-NLS-1$
3228 //                                      e.printStackTrace();
3229 //                              }
3230 //                              if (e instanceof JavaModelException) {
3231 //                                      throw (JavaModelException)e;
3232 //                              } else {
3233 //                                      throw new JavaModelException(e);
3234 //                              }
3235 //                      }
3236 //              }
3237 //      }
3238 }