52d906bce9175e29b9328a9d879cd2d55b1bd386
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / PHPCore.java
1 package net.sourceforge.phpeclipse;
2
3 import java.util.ArrayList;
4 import java.util.Enumeration;
5 import java.util.HashSet;
6 import java.util.Hashtable;
7 import java.util.List;
8
9 import net.sourceforge.phpeclipse.resourcesview.PHPFile;
10 import net.sourceforge.phpeclipse.resourcesview.PHPProject;
11
12 import org.eclipse.core.resources.IFile;
13 import org.eclipse.core.resources.IProject;
14 import org.eclipse.core.resources.IProjectDescription;
15 import org.eclipse.core.resources.ResourcesPlugin;
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.IProgressMonitor;
18 import org.eclipse.core.runtime.Plugin;
19 import org.eclipse.core.runtime.Preferences;
20
21 public class PHPCore {
22
23   public static HashSet OptionNames = new HashSet(20);
24   /**
25    * The plug-in identifier of the Java core support
26    * (value <code>"org.phpeclipse.phpdt.core"</code>).
27    */
28   public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.core"; //$NON-NLS-1$
29
30   /**
31      * Possible  configurable option ID.
32      * @see #getDefaultOptions
33      * @since 2.0
34      */
35   public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; //$NON-NLS-1$
36
37   /**
38      * Possible  configurable option ID.
39      * @see #getDefaultOptions
40      * @since 2.0
41      */
42   public static final String FORMATTER_NEWLINE_OPENING_BRACE = PLUGIN_ID + ".formatter.newline.openingBrace"; //$NON-NLS-1$
43   /**
44    * Possible  configurable option ID.
45    * @see #getDefaultOptions
46    * @since 2.0
47    */
48   public static final String FORMATTER_NEWLINE_CONTROL = PLUGIN_ID + ".formatter.newline.controlStatement"; //$NON-NLS-1$
49   /**
50    * Possible  configurable option ID.
51    * @see #getDefaultOptions
52    * @since 2.0
53    */
54   public static final String FORMATTER_NEWLINE_ELSE_IF = PLUGIN_ID + ".formatter.newline.elseIf"; //$NON-NLS-1$
55   /**
56    * Possible  configurable option ID.
57    * @see #getDefaultOptions
58    * @since 2.0
59    */
60   public static final String FORMATTER_NEWLINE_EMPTY_BLOCK = PLUGIN_ID + ".formatter.newline.emptyBlock"; //$NON-NLS-1$
61   /**
62    * Possible  configurable option ID.
63    * @see #getDefaultOptions
64    * @since 2.0
65    */
66   public static final String FORMATTER_CLEAR_BLANK_LINES = PLUGIN_ID + ".formatter.newline.clearAll"; //$NON-NLS-1$
67   /**
68    * Possible  configurable option ID.
69    * @see #getDefaultOptions
70    * @since 2.0
71    */
72   public static final String FORMATTER_LINE_SPLIT = PLUGIN_ID + ".formatter.lineSplit"; //$NON-NLS-1$
73   /**
74    * Possible  configurable option ID.
75    * @see #getDefaultOptions
76    * @since 2.0
77    */
78   public static final String FORMATTER_COMPACT_ASSIGNMENT = PLUGIN_ID + ".formatter.style.assignment"; //$NON-NLS-1$
79   /**
80    * Possible  configurable option ID.
81    * @see #getDefaultOptions
82    * @since 2.0
83    */
84   public static final String FORMATTER_TAB_CHAR = PLUGIN_ID + ".formatter.tabulation.char"; //$NON-NLS-1$
85   /**
86    * Possible  configurable option ID.
87    * @see #getDefaultOptions
88    * @since 2.0
89    */
90   public static final String FORMATTER_TAB_SIZE = PLUGIN_ID + ".formatter.tabulation.size"; //$NON-NLS-1$
91   /**
92    * Possible  configurable option value.
93    * @see #getDefaultOptions
94    * @since 2.0
95    */
96   public static final String INSERT = "insert"; //$NON-NLS-1$
97   /**
98    * Possible  configurable option value.
99    * @see #getDefaultOptions
100    * @since 2.0
101    */
102   public static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$
103
104   /**
105    * Possible  configurable option value.
106    * @see #getDefaultOptions
107    * @since 2.0
108    */
109   public static final String PRESERVE_ONE = "preserve one"; //$NON-NLS-1$
110   /**
111    * Possible  configurable option value.
112    * @see #getDefaultOptions
113    * @since 2.0
114    */
115   public static final String CLEAR_ALL = "clear all"; //$NON-NLS-1$
116   /**
117    * Possible  configurable option value.
118    * @see #getDefaultOptions
119    * @since 2.0
120    */
121   public static final String NORMAL = "normal"; //$NON-NLS-1$
122   /**
123    * Possible  configurable option value.
124    * @see #getDefaultOptions
125    * @since 2.0
126    */
127   public static final String COMPACT = "compact"; //$NON-NLS-1$
128   /**
129    * Possible  configurable option value.
130    * @see #getDefaultOptions
131    * @since 2.0
132    */
133   public static final String TAB = "tab"; //$NON-NLS-1$
134   /**
135    * Possible  configurable option value.
136    * @see #getDefaultOptions
137    * @since 2.0
138    */
139   public static final String SPACE = "space"; //$NON-NLS-1$
140   /**
141    * Possible  configurable option value.
142    * @see #getDefaultOptions
143    * @since 2.0
144    */
145   public static final String ENABLED = "enabled"; //$NON-NLS-1$
146   /**
147    * Possible  configurable option value.
148    * @see #getDefaultOptions
149    * @since 2.0
150    */
151   public static final String DISABLED = "disabled"; //$NON-NLS-1$
152   /**
153    * Possible  configurable option value.
154    * @see #getDefaultOptions
155    * @since 2.1
156    */
157   public static final String CLEAN = "clean"; //$NON-NLS-1$
158         
159   /**
160    * Returns a table of all known configurable options with their default values.
161    * These options allow to configure the behaviour of the underlying components.
162    * The client may safely use the result as a template that they can modify and
163    * then pass to <code>setOptions</code>.
164    * 
165    * Helper constants have been defined on JavaCore for each of the option ID and 
166    * their possible constant values.
167    * 
168    * Note: more options might be added in further releases.
169    * <pre>
170    * RECOGNIZED OPTIONS:
171    * COMPILER / Generating Local Variable Debug Attribute
172    *    When generated, this attribute will enable local variable names 
173    *    to be displayed in debugger, only in place where variables are 
174    *    definitely assigned (.class file is then bigger)
175    *     - option id:         "org.phpeclipse.phpdt.core.compiler.debug.localVariable"
176    *     - possible values:   { "generate", "do not generate" }
177    *     - default:           "generate"
178    *
179    * COMPILER / Generating Line Number Debug Attribute 
180    *    When generated, this attribute will enable source code highlighting in debugger 
181    *    (.class file is then bigger).
182    *     - option id:         "org.phpeclipse.phpdt.core.compiler.debug.lineNumber"
183    *     - possible values:   { "generate", "do not generate" }
184    *     - default:           "generate"
185    *    
186    * COMPILER / Generating Source Debug Attribute 
187    *    When generated, this attribute will enable the debugger to present the 
188    *    corresponding source code.
189    *     - option id:         "org.phpeclipse.phpdt.core.compiler.debug.sourceFile"
190    *     - possible values:   { "generate", "do not generate" }
191    *     - default:           "generate"
192    *    
193    * COMPILER / Preserving Unused Local Variables
194    *    Unless requested to preserve unused local variables (i.e. never read), the 
195    *    compiler will optimize them out, potentially altering debugging
196    *     - option id:         "org.phpeclipse.phpdt.core.compiler.codegen.unusedLocal"
197    *     - possible values:   { "preserve", "optimize out" }
198    *     - default:           "preserve"
199    * 
200    * COMPILER / Defining Target Java Platform
201    *    For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
202    *    Note that "1.4" target require to toggle compliance mode to "1.4" too.
203    *     - option id:         "org.phpeclipse.phpdt.core.compiler.codegen.targetPlatform"
204    *     - possible values:   { "1.1", "1.2", "1.3", "1.4" }
205    *     - default:           "1.1"
206    *
207    * COMPILER / Reporting Unreachable Code
208    *    Unreachable code can optionally be reported as an error, warning or simply 
209    *    ignored. The bytecode generation will always optimized it out.
210    *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.unreachableCode"
211    *     - possible values:   { "error", "warning", "ignore" }
212    *     - default:           "error"
213    *
214    * COMPILER / Reporting Invalid Import
215    *    An import statement that cannot be resolved might optionally be reported 
216    *    as an error, as a warning or ignored.
217    *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.invalidImport"
218    *     - possible values:   { "error", "warning", "ignore" }
219    *     - default:           "error"
220    *
221    * COMPILER / Reporting Attempt to Override Package-Default Method
222    *    A package default method is not visible in a different package, and thus 
223    *    cannot be overridden. When enabling this option, the compiler will signal 
224    *    such scenarii either as an error or a warning.
225    *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.overridingPackageDefaultMethod"
226    *     - possible values:   { "error", "warning", "ignore" }
227    *     - default:           "warning"
228    *
229    * COMPILER / Reporting Method With Constructor Name
230    *    Naming a method with a constructor name is generally considered poor 
231    *    style programming. When enabling this option, the compiler will signal such 
232    *    scenarii either as an error or a warning.
233    *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.methodWithConstructorName"
234    *     - possible values:   { "error", "warning", "ignore" }
235    *     - default:           "warning"
236    *
237    * COMPILER / Reporting Deprecation
238    *    When enabled, the compiler will signal use of deprecated API either as an 
239    *    error or a warning.
240    *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.deprecation"
241    *     - possible values:   { "error", "warning", "ignore" }
242    *     - default:           "warning"
243    *
244    * COMPILER / Reporting Deprecation Inside Deprecated Code
245    *    When enabled, the compiler will signal use of deprecated API inside deprecated code.
246    *    The severity of the problem is controlled with option "org.phpeclipse.phpdt.core.compiler.problem.deprecation".
247    *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.deprecationInDeprecatedCode"
248    *     - possible values:   { "enabled", "disabled" }
249    *     - default:           "disabled"
250    *
251    * COMPILER / Reporting Hidden Catch Block
252    *    Locally to a try statement, some catch blocks may hide others , e.g.
253    *      try {  throw new java.io.CharConversionException();
254    *      } catch (java.io.CharConversionException e) {
255    *      } catch (java.io.IOException e) {}. 
256    *    When enabling this option, the compiler will issue an error or a warning for hidden 
257    *    catch blocks corresponding to checked exceptions
258    *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.hiddenCatchBlock"
259    *     - possible values:   { "error", "warning", "ignore" }
260    *     - default:           "warning"
261    *
262    * COMPILER / Reporting Unused Local
263    *    When enabled, the compiler will issue an error or a warning for unused local 
264    *    variables (i.e. variables never read from)
265    *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.unusedLocal"
266    *     - possible values:   { "error", "warning", "ignore" }
267    *     - default:           "ignore"
268    *
269    * COMPILER / Reporting Unused Parameter
270    *    When enabled, the compiler will issue an error or a warning for unused method 
271    *    parameters (i.e. parameters never read from)
272    *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.unusedParameter"
273    *     - possible values:   { "error", "warning", "ignore" }
274    *     - default:           "ignore"
275    *
276    * COMPILER / Reporting Unused Import
277    *    When enabled, the compiler will issue an error or a warning for unused import 
278    *    reference 
279    *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.unusedImport"
280    *     - possible values:   { "error", "warning", "ignore" }
281    *     - default:           "warning"
282    *
283    * COMPILER / Reporting Synthetic Access Emulation
284    *    When enabled, the compiler will issue an error or a warning whenever it emulates 
285    *    access to a non-accessible member of an enclosing type. Such access can have
286    *    performance implications.
287    *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.syntheticAccessEmulation"
288    *     - possible values:   { "error", "warning", "ignore" }
289    *     - default:           "ignore"
290    *
291    * COMPILER / Reporting Non-Externalized String Literal
292    *    When enabled, the compiler will issue an error or a warning for non externalized 
293    *    String literal (i.e. non tagged with //$NON-NLS-<n>$). 
294    *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.nonExternalizedStringLiteral"
295    *     - possible values:   { "error", "warning", "ignore" }
296    *     - default:           "ignore"
297    * 
298    * COMPILER / Reporting Usage of 'assert' Identifier
299    *    When enabled, the compiler will issue an error or a warning whenever 'assert' is 
300    *    used as an identifier (reserved keyword in 1.4)
301    *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.assertIdentifier"
302    *     - possible values:   { "error", "warning", "ignore" }
303    *     - default:           "ignore"
304    * 
305    * COMPILER / Reporting Usage of expression receiver on static invocation/field access
306    *    When enabled, the compiler will issue an error or a warning whenever a static field
307    *    or method is accessed with an expression receiver.
308    *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.staticAccessReceiver"
309    *     - possible values:   { "error", "warning", "ignore" }
310    *     - default:           "warning"
311    * 
312    * COMPILER / Reporting Assignment with no effect
313    *    When enabled, the compiler will issue an error or a warning whenever an assignment
314    *    has no effect (e.g 'x = x').
315    *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.noEffectAssignment"
316    *     - possible values:   { "error", "warning", "ignore" }
317    *     - default:           "warning"
318    * 
319    * COMPILER / Setting Source Compatibility Mode
320    *    Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
321    *    reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
322    *   level should be set to "1.4" and the compliance mode should be "1.4".
323    *     - option id:         "org.phpeclipse.phpdt.core.compiler.source"
324    *     - possible values:   { "1.3", "1.4" }
325    *     - default:           "1.3"
326    * 
327    * COMPILER / Setting Compliance Level
328    *    Select the compliance level for the compiler. In "1.3" mode, source and target settings
329    *    should not go beyond "1.3" level.
330    *     - option id:         "org.phpeclipse.phpdt.core.compiler.compliance"
331    *     - possible values:   { "1.3", "1.4" }
332    *     - default:           "1.3"
333    * 
334    * COMPILER / Maximum number of problems reported per compilation unit
335    *    Specify the maximum number of problems reported on each compilation unit.
336    *     - option id:         "org.phpeclipse.phpdt.core.compiler.maxProblemPerUnit"
337    *     - possible values:     "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
338    *     - default:           "100"
339    * 
340    * COMPILER / Define the Automatic Task Tags
341    *    When the tag is non empty, the compiler will issue a task marker whenever it encounters
342    *    one of the corresponding tag inside any comment in Java source code.
343    *    Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed.
344    *     - option id:         "org.phpeclipse.phpdt.core.compiler.taskTags"
345    *     - possible values:   { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card 
346    *     - default:           ""
347    * 
348    * COMPILER / Define the Automatic Task Priorities
349    *    In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
350    *    of the task markers issued by the compiler.
351    *    If the default is specified, the priority of each task marker is "NORMAL".
352    *     - option id:         "org.phpeclipse.phpdt.core.compiler.taskPriorities"
353    *     - possible values:   { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
354    *     - default:           ""
355    * 
356    * BUILDER / Specifying Filters for Resource Copying Control
357    *    Allow to specify some filters to control the resource copy process.
358    *     - option id:         "org.phpeclipse.phpdt.core.builder.resourceCopyExclusionFilter"
359    *     - possible values:   { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
360    *       or the name of a folder which ends with '/'
361    *     - default:           ""
362    * 
363    * BUILDER / Abort if Invalid Classpath
364    *    Allow to toggle the builder to abort if the classpath is invalid
365    *     - option id:         "org.phpeclipse.phpdt.core.builder.invalidClasspath"
366    *     - possible values:   { "abort", "ignore" }
367    *     - default:           "ignore"
368    * 
369    * BUILDER / Cleaning Output Folder(s)
370    *    Indicate whether the JavaBuilder is allowed to clean the output folders
371    *    when performing full build operations.
372    *     - option id:         "org.phpeclipse.phpdt.core.builder.cleanOutputFolder"
373    *     - possible values:   { "clean", "ignore" }
374    *     - default:           "clean"
375    * 
376    * JAVACORE / Computing Project Build Order
377    *    Indicate whether JavaCore should enforce the project build order to be based on
378    *    the classpath prerequisite chain. When requesting to compute, this takes over
379    *    the platform default order (based on project references).
380    *     - option id:         "org.phpeclipse.phpdt.core.computeJavaBuildOrder"
381    *     - possible values:   { "compute", "ignore" }
382    *     - default:           "ignore"   
383    * 
384    * JAVACORE / Specify Default Source Encoding Format
385    *    Get the encoding format for compiled sources. This setting is read-only, it is equivalent
386    *    to 'ResourcesPlugin.getEncoding()'.
387    *     - option id:         "org.phpeclipse.phpdt.core.encoding"
388    *     - possible values:   { any of the supported encoding name}.
389    *     - default:           <platform default>
390    * 
391    * JAVACORE / Reporting Incomplete Classpath
392    *    An entry on the classpath doesn't exist or is not visible (e.g. a referenced project is closed).
393    *     - option id:         "org.phpeclipse.phpdt.core.incompleteClasspath"
394    *     - possible values:   { "error", "warning"}
395    *     - default:           "error"
396    * 
397    * JAVACORE / Reporting Classpath Cycle
398    *    A project is involved in a cycle.
399    *     - option id:         "org.phpeclipse.phpdt.core.circularClasspath"
400    *     - possible values:   { "error", "warning" }
401    *     - default:           "error"
402    * 
403    *    FORMATTER / Inserting New Line Before Opening Brace
404    *    When Insert, a new line is inserted before an opening brace, otherwise nothing
405    *    is inserted
406    *     - option id:         "org.phpeclipse.phpdt.core.formatter.newline.openingBrace"
407    *     - possible values:   { "insert", "do not insert" }
408    *     - default:           "do not insert"
409    * 
410    *    FORMATTER / Inserting New Line Inside Control Statement
411    *    When Insert, a new line is inserted between } and following else, catch, finally
412    *     - option id:         "org.phpeclipse.phpdt.core.formatter.newline.controlStatement"
413    *     - possible values:   { "insert", "do not insert" }
414    *     - default:           "do not insert"
415    * 
416    *    FORMATTER / Clearing Blank Lines
417    *    When Clear all, all blank lines are removed. When Preserve one, only one is kept
418    *    and all others removed.
419    *     - option id:         "org.phpeclipse.phpdt.core.formatter.newline.clearAll"
420    *     - possible values:   { "clear all", "preserve one" }
421    *     - default:           "preserve one"
422    * 
423    *    FORMATTER / Inserting New Line Between Else/If 
424    *    When Insert, a blank line is inserted between an else and an if when they are 
425    *    contiguous. When choosing to not insert, else-if will be kept on the same
426    *    line when possible.
427    *     - option id:         "org.phpeclipse.phpdt.core.formatter.newline.elseIf"
428    *     - possible values:   { "insert", "do not insert" }
429    *     - default:           "do not insert"
430    * 
431    *    FORMATTER / Inserting New Line In Empty Block
432    *    When insert, a line break is inserted between contiguous { and }, if } is not followed
433    *    by a keyword.
434    *     - option id:         "org.phpeclipse.phpdt.core.formatter.newline.emptyBlock"
435    *     - possible values:   { "insert", "do not insert" }
436    *     - default:           "insert"
437    * 
438    *    FORMATTER / Splitting Lines Exceeding Length
439    *    Enable splitting of long lines (exceeding the configurable length). Length of 0 will
440    *    disable line splitting
441    *     - option id:         "org.phpeclipse.phpdt.core.formatter.lineSplit"
442    *     - possible values:     "<n>", where n is zero or a positive integer
443    *     - default:           "80"
444    * 
445    *    FORMATTER / Compacting Assignment
446    *    Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space
447    *    is inserted before the assignment operator
448    *     - option id:         "org.phpeclipse.phpdt.core.formatter.style.assignment"
449    *     - possible values:   { "compact", "normal" }
450    *     - default:           "normal"
451    * 
452    *    FORMATTER / Defining Indentation Character
453    *    Either choose to indent with tab characters or spaces
454    *     - option id:         "org.phpeclipse.phpdt.core.formatter.tabulation.char"
455    *     - possible values:   { "tab", "space" }
456    *     - default:           "tab"
457    * 
458    *    FORMATTER / Defining Space Indentation Length
459    *    When using spaces, set the amount of space characters to use for each 
460    *    indentation mark.
461    *     - option id:         "org.phpeclipse.phpdt.core.formatter.tabulation.size"
462    *     - possible values:     "<n>", where n is a positive integer
463    *     - default:           "4"
464    * 
465    *    CODEASSIST / Activate Visibility Sensitive Completion
466    *    When active, completion doesn't show that you can not see
467    *    (e.g. you can not see private methods of a super class).
468    *     - option id:         "org.phpeclipse.phpdt.core.codeComplete.visibilityCheck"
469    *     - possible values:   { "enabled", "disabled" }
470    *     - default:           "disabled"
471    * 
472    *    CODEASSIST / Automatic Qualification of Implicit Members
473    *    When active, completion automatically qualifies completion on implicit
474    *    field references and message expressions.
475    *     - option id:         "org.phpeclipse.phpdt.core.codeComplete.forceImplicitQualification"
476    *     - possible values:   { "enabled", "disabled" }
477    *     - default:           "disabled"
478    * 
479    *  CODEASSIST / Define the Prefixes for Field Name
480    *    When the prefixes is non empty, completion for field name will begin with
481    *    one of the proposed prefixes.
482    *     - option id:         "org.phpeclipse.phpdt.core.codeComplete.fieldPrefixes"
483    *     - possible values:   { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card 
484    *     - default:           ""
485    * 
486    *  CODEASSIST / Define the Prefixes for Static Field Name
487    *    When the prefixes is non empty, completion for static field name will begin with
488    *    one of the proposed prefixes.
489    *     - option id:         "org.phpeclipse.phpdt.core.codeComplete.staticFieldPrefixes"
490    *     - possible values:   { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card 
491    *     - default:           ""
492    * 
493    *  CODEASSIST / Define the Prefixes for Local Variable Name
494    *    When the prefixes is non empty, completion for local variable name will begin with
495    *    one of the proposed prefixes.
496    *     - option id:         "org.phpeclipse.phpdt.core.codeComplete.localPrefixes"
497    *     - possible values:   { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card 
498    *     - default:           ""
499    * 
500    *  CODEASSIST / Define the Prefixes for Argument Name
501    *    When the prefixes is non empty, completion for argument name will begin with
502    *    one of the proposed prefixes.
503    *     - option id:         "org.phpeclipse.phpdt.core.codeComplete.argumentPrefixes"
504    *     - possible values:   { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card 
505    *     - default:           ""
506    * 
507    *  CODEASSIST / Define the Suffixes for Field Name
508    *    When the suffixes is non empty, completion for field name will end with
509    *    one of the proposed suffixes.
510    *     - option id:         "org.phpeclipse.phpdt.core.codeComplete.fieldSuffixes"
511    *     - possible values:   { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card 
512    *     - default:           ""
513    * 
514    *  CODEASSIST / Define the Suffixes for Static Field Name
515    *    When the suffixes is non empty, completion for static field name will end with
516    *    one of the proposed suffixes.
517    *     - option id:         "org.phpeclipse.phpdt.core.codeComplete.staticFieldSuffixes"
518    *     - possible values:   { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card 
519    *     - default:           ""
520    * 
521    *  CODEASSIST / Define the Suffixes for Local Variable Name
522    *    When the suffixes is non empty, completion for local variable name will end with
523    *    one of the proposed suffixes.
524    *     - option id:         "org.phpeclipse.phpdt.core.codeComplete.localSuffixes"
525    *     - possible values:   { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card 
526    *     - default:           ""
527    * 
528    *  CODEASSIST / Define the Suffixes for Argument Name
529    *    When the suffixes is non empty, completion for argument name will end with
530    *    one of the proposed suffixes.
531    *     - option id:         "org.phpeclipse.phpdt.core.codeComplete.argumentSuffixes"
532    *     - possible values:   { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card 
533    *     - default:           ""
534    * </pre>
535    * 
536    * @return a mutable table containing the default settings of all known options
537    *   (key type: <code>String</code>; value type: <code>String</code>)
538    * @see #setOptions
539    */
540   public static Hashtable getDefaultOptions() {
541
542     Hashtable defaultOptions = new Hashtable(10);
543
544     // see #initializeDefaultPluginPreferences() for changing default settings
545     Preferences preferences = getPlugin().getPluginPreferences();
546     HashSet optionNames = OptionNames;
547
548     // get preferences set to their default
549     String[] defaultPropertyNames = preferences.defaultPropertyNames();
550     for (int i = 0; i < defaultPropertyNames.length; i++) {
551       String propertyName = defaultPropertyNames[i];
552       if (optionNames.contains(propertyName)) {
553         defaultOptions.put(
554           propertyName,
555           preferences.getDefaultString(propertyName));
556       }
557     }
558     // get preferences not set to their default
559     String[] propertyNames = preferences.propertyNames();
560     for (int i = 0; i < propertyNames.length; i++) {
561       String propertyName = propertyNames[i];
562       if (optionNames.contains(propertyName)) {
563         defaultOptions.put(
564           propertyName,
565           preferences.getDefaultString(propertyName));
566       }
567     }
568     // get encoding through resource plugin
569     defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
570
571     return defaultOptions;
572   }
573   /**
574    * Helper method for returning one option value only. Equivalent to <code>(String)JavaCore.getOptions().get(optionName)</code>
575    * Note that it may answer <code>null</code> if this option does not exist.
576    * <p>
577    * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
578    * </p>
579    * 
580    * @param optionName the name of an option
581    * @return the String value of a given option
582    * @see JavaCore#getDefaultOptions
583    * @since 2.0
584    */
585   public static String getOption(String optionName) {
586
587     if (CORE_ENCODING.equals(optionName)) {
588       return ResourcesPlugin.getEncoding();
589     }
590     if (OptionNames.contains(optionName)) {
591       Preferences preferences = getPlugin().getPluginPreferences();
592       return preferences.getString(optionName).trim();
593     }
594     return null;
595   }
596
597   /**
598    * Returns the table of the current options. Initially, all options have their default values,
599    * and this method returns a table that includes all known options.
600    * <p>
601    * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
602    * </p>
603    * 
604    * @return table of current settings of all options 
605    *   (key type: <code>String</code>; value type: <code>String</code>)
606    * @see JavaCore#getDefaultOptions
607    */
608   public static Hashtable getOptions() {
609
610     Hashtable options = new Hashtable(10);
611
612     // see #initializeDefaultPluginPreferences() for changing default settings
613     Plugin plugin = getPlugin();
614     if (plugin != null) {
615       Preferences preferences = getPlugin().getPluginPreferences();
616       HashSet optionNames = OptionNames;
617
618       // get preferences set to their default
619       String[] defaultPropertyNames = preferences.defaultPropertyNames();
620       for (int i = 0; i < defaultPropertyNames.length; i++) {
621         String propertyName = defaultPropertyNames[i];
622         if (optionNames.contains(propertyName)) {
623           options.put(propertyName, preferences.getDefaultString(propertyName));
624         }
625       }
626       // get preferences not set to their default
627       String[] propertyNames = preferences.propertyNames();
628       for (int i = 0; i < propertyNames.length; i++) {
629         String propertyName = propertyNames[i];
630         if (optionNames.contains(propertyName)) {
631           options.put(propertyName, preferences.getString(propertyName).trim());
632         }
633       }
634       // get encoding through resource plugin
635       options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
636     }
637     return options;
638   }
639   /**
640    * Sets the current table of options. All and only the options explicitly included in the given table 
641    * are remembered; all previous option settings are forgotten, including ones not explicitly
642    * mentioned.
643    * <p>
644    * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
645    * </p>
646    * 
647    * @param newOptions the new options (key type: <code>String</code>; value type: <code>String</code>),
648    *   or <code>null</code> to reset all options to their default values
649    * @see JavaCore#getDefaultOptions
650    */
651   public static void setOptions(Hashtable newOptions) {
652
653     // see #initializeDefaultPluginPreferences() for changing default settings
654     Preferences preferences = getPlugin().getPluginPreferences();
655
656     if (newOptions == null) {
657       newOptions = getDefaultOptions();
658     }
659     Enumeration keys = newOptions.keys();
660     while (keys.hasMoreElements()) {
661       String key = (String) keys.nextElement();
662       if (!OptionNames.contains(key))
663         continue; // unrecognized option
664       if (key.equals(CORE_ENCODING))
665         continue; // skipped, contributed by resource prefs
666       String value = (String) newOptions.get(key);
667       preferences.setValue(key, value);
668     }
669
670     // persist options
671     getPlugin().savePluginPreferences();
672   }
673   public static IProject[] getPHPProjects() {
674     List phpProjectsList = new ArrayList();
675     IProject[] workspaceProjects =
676       PHPeclipsePlugin.getWorkspace().getRoot().getProjects();
677
678     for (int i = 0; i < workspaceProjects.length; i++) {
679       IProject iProject = workspaceProjects[i];
680       if (isPHPProject(iProject))
681         phpProjectsList.add(iProject);
682     }
683
684     IProject[] phpProjects = new IProject[phpProjectsList.size()];
685     return (IProject[]) phpProjectsList.toArray(phpProjects);
686   }
687
688   public static PHPProject getPHPProject(String name) {
689     IProject aProject =
690       PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
691     if (isPHPProject(aProject)) {
692       PHPProject thePHPProject = new PHPProject();
693       thePHPProject.setProject(aProject);
694       return thePHPProject;
695     }
696     return null;
697   }
698
699   public static boolean isPHPProject(IProject aProject) {
700     try {
701       return aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID);
702     } catch (CoreException e) {
703     }
704
705     return false;
706   }
707
708   public static PHPFile create(IFile aFile) {
709     if (PHPFile.EXTENSION.equalsIgnoreCase(aFile.getFileExtension()))
710       return new PHPFile(aFile);
711     if (PHPFile.EXTENSION1.equalsIgnoreCase(aFile.getFileExtension()))
712       return new PHPFile(aFile);
713     if (PHPFile.EXTENSION2.equalsIgnoreCase(aFile.getFileExtension()))
714       return new PHPFile(aFile);
715     if (PHPFile.EXTENSION3.equalsIgnoreCase(aFile.getFileExtension()))
716       return new PHPFile(aFile);
717     if (PHPFile.EXTENSION4.equalsIgnoreCase(aFile.getFileExtension()))
718       return new PHPFile(aFile);
719     if (PHPFile.EXTENSION5.equalsIgnoreCase(aFile.getFileExtension()))
720       return new PHPFile(aFile);
721
722     return null;
723   }
724
725   public static PHPProject create(IProject aProject) {
726     try {
727       if (aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
728         PHPProject project = new PHPProject();
729         project.setProject(aProject);
730         return project;
731       }
732     } catch (CoreException e) {
733       System.err.println(
734         "Exception occurred in PHPCore#create(IProject): " + e.toString());
735     }
736
737     return null;
738   }
739
740   public static void addPHPNature(IProject project, IProgressMonitor monitor)
741     throws CoreException {
742     if (!project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
743       IProjectDescription description = project.getDescription();
744       String[] prevNatures = description.getNatureIds();
745       String[] newNatures = new String[prevNatures.length + 1];
746       System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
747       newNatures[prevNatures.length] = PHPeclipsePlugin.PHP_NATURE_ID;
748       description.setNatureIds(newNatures);
749       project.setDescription(description, monitor);
750     }
751   }
752
753   /**
754    * Returns the single instance of the PHP core plug-in runtime class.
755    * 
756    * @return the single instance of the PHP core plug-in runtime class
757    */
758   public static Plugin getPlugin() {
759     return PHPeclipsePlugin.getDefault();
760   }
761   
762 /**
763    * Initializes the default preferences settings for this plug-in.
764    */
765   protected static void initializeDefaultPluginPreferences() {
766                 
767     Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
768     HashSet optionNames = OptionNames;
769                 
770 //    // Compiler settings
771 //    preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
772 //    optionNames.add(COMPILER_LOCAL_VARIABLE_ATTR);
773 //
774 //    preferences.setDefault(COMPILER_LINE_NUMBER_ATTR, GENERATE); 
775 //    optionNames.add(COMPILER_LINE_NUMBER_ATTR);
776 //
777 //    preferences.setDefault(COMPILER_SOURCE_FILE_ATTR, GENERATE); 
778 //    optionNames.add(COMPILER_SOURCE_FILE_ATTR);
779 //
780 //    preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE); 
781 //    optionNames.add(COMPILER_CODEGEN_UNUSED_LOCAL);
782 //
783 //    preferences.setDefault(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1); 
784 //    optionNames.add(COMPILER_CODEGEN_TARGET_PLATFORM);
785 //
786 //    preferences.setDefault(COMPILER_PB_UNREACHABLE_CODE, ERROR); 
787 //    optionNames.add(COMPILER_PB_UNREACHABLE_CODE);
788 //
789 //    preferences.setDefault(COMPILER_PB_INVALID_IMPORT, ERROR); 
790 //    optionNames.add(COMPILER_PB_INVALID_IMPORT);
791 //
792 //    preferences.setDefault(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, WARNING); 
793 //    optionNames.add(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD);
794 //
795 //    preferences.setDefault(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME, WARNING); 
796 //    optionNames.add(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME);
797 //
798 //    preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING);
799 //    optionNames.add(COMPILER_PB_DEPRECATION);
800 //
801 //    preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE, DISABLED);
802 //    optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE);
803 //
804 //    preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING); 
805 //    optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK);
806 //
807 //    preferences.setDefault(COMPILER_PB_UNUSED_LOCAL, IGNORE); 
808 //    optionNames.add(COMPILER_PB_UNUSED_LOCAL);
809 //
810 //    preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE); 
811 //    optionNames.add(COMPILER_PB_UNUSED_PARAMETER);
812 //
813 //    preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING); 
814 //    optionNames.add(COMPILER_PB_UNUSED_IMPORT);
815 //
816 //    preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE); 
817 //    optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION);
818 //
819 //    preferences.setDefault(COMPILER_PB_NON_NLS_STRING_LITERAL, IGNORE); 
820 //    optionNames.add(COMPILER_PB_NON_NLS_STRING_LITERAL);
821 //
822 //    preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE); 
823 //    optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER);
824 //
825 //    preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING); 
826 //    optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER);
827 //
828 //    preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING); 
829 //    optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT);
830 //
831 //    preferences.setDefault(COMPILER_TASK_TAGS, ""); //$NON-NLS-1$
832 //    optionNames.add(COMPILER_TASK_TAGS);
833 //
834 //    preferences.setDefault(COMPILER_TASK_PRIORITIES, ""); //$NON-NLS-1$
835 //    optionNames.add(COMPILER_TASK_PRIORITIES);
836 //
837 //    preferences.setDefault(COMPILER_SOURCE, VERSION_1_3);
838 //    optionNames.add(COMPILER_SOURCE);
839 //
840 //    preferences.setDefault(COMPILER_COMPLIANCE, VERSION_1_3); 
841 //    optionNames.add(COMPILER_COMPLIANCE);
842 //
843 //    preferences.setDefault(COMPILER_PB_MAX_PER_UNIT, "100"); //$NON-NLS-1$
844 //    optionNames.add(COMPILER_PB_MAX_PER_UNIT);
845 //              
846 //    // Builder settings
847 //    preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
848 //    optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
849 //
850 //    preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT); 
851 //    optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH);
852 //      
853 //    preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING); 
854 //    optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE);
855 //              
856 //    preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN); 
857 //    optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER);
858 //
859 //    // JavaCore settings
860 //    preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE); 
861 //    optionNames.add(CORE_JAVA_BUILD_ORDER);
862 //      
863 //    preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR); 
864 //    optionNames.add(CORE_CIRCULAR_CLASSPATH);
865 //              
866 //    preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR); 
867 //    optionNames.add(CORE_INCOMPLETE_CLASSPATH);
868                 
869     // encoding setting comes from resource plug-in
870     optionNames.add(CORE_ENCODING);
871                 
872     // Formatter settings
873     preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT); 
874     optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE);
875
876     preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT);
877     optionNames.add(FORMATTER_NEWLINE_CONTROL);
878
879     preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE); 
880     optionNames.add(FORMATTER_CLEAR_BLANK_LINES);
881
882     preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT);
883     optionNames.add(FORMATTER_NEWLINE_ELSE_IF);
884
885     preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT); 
886     optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK);
887
888     preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$
889     optionNames.add(FORMATTER_LINE_SPLIT);
890
891     preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL); 
892     optionNames.add(FORMATTER_COMPACT_ASSIGNMENT);
893
894     preferences.setDefault(FORMATTER_TAB_CHAR, TAB); 
895     optionNames.add(FORMATTER_TAB_CHAR);
896
897     preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$ 
898     optionNames.add(FORMATTER_TAB_SIZE);
899                 
900     // CodeAssist settings
901 //    preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$
902 //    optionNames.add(CODEASSIST_VISIBILITY_CHECK);
903 //
904 //    preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$
905 //    optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION);
906 //              
907 //    preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
908 //    optionNames.add(CODEASSIST_FIELD_PREFIXES);
909 //              
910 //    preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
911 //    optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES);
912 //              
913 //    preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
914 //    optionNames.add(CODEASSIST_LOCAL_PREFIXES);
915 //              
916 //    preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
917 //    optionNames.add(CODEASSIST_ARGUMENT_PREFIXES);
918 //              
919 //    preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
920 //    optionNames.add(CODEASSIST_FIELD_SUFFIXES);
921 //              
922 //    preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
923 //    optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES);
924 //              
925 //    preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
926 //    optionNames.add(CODEASSIST_LOCAL_SUFFIXES);
927 //              
928 //    preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
929 //    optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES);
930                 
931   }
932 }