1 package net.sourceforge.phpeclipse;
 
   3 import java.util.ArrayList;
 
   4 import java.util.Enumeration;
 
   5 import java.util.HashSet;
 
   6 import java.util.Hashtable;
 
   9 import net.sourceforge.phpeclipse.resourcesview.PHPFile;
 
  10 import net.sourceforge.phpeclipse.resourcesview.PHPProject;
 
  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;
 
  21 public class PHPCore {
 
  23   public static HashSet OptionNames = new HashSet(20);
 
  25    * The plug-in identifier of the Java core support
 
  26    * (value <code>"org.phpeclipse.phpdt.core"</code>).
 
  28   public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.core"; //$NON-NLS-1$
 
  31      * Possible  configurable option ID.
 
  32      * @see #getDefaultOptions
 
  35   public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; //$NON-NLS-1$
 
  38      * Possible  configurable option ID.
 
  39      * @see #getDefaultOptions
 
  42   public static final String FORMATTER_NEWLINE_OPENING_BRACE = PLUGIN_ID + ".formatter.newline.openingBrace"; //$NON-NLS-1$
 
  44    * Possible  configurable option ID.
 
  45    * @see #getDefaultOptions
 
  48   public static final String FORMATTER_NEWLINE_CONTROL = PLUGIN_ID + ".formatter.newline.controlStatement"; //$NON-NLS-1$
 
  50    * Possible  configurable option ID.
 
  51    * @see #getDefaultOptions
 
  54   public static final String FORMATTER_NEWLINE_ELSE_IF = PLUGIN_ID + ".formatter.newline.elseIf"; //$NON-NLS-1$
 
  56    * Possible  configurable option ID.
 
  57    * @see #getDefaultOptions
 
  60   public static final String FORMATTER_NEWLINE_EMPTY_BLOCK = PLUGIN_ID + ".formatter.newline.emptyBlock"; //$NON-NLS-1$
 
  62    * Possible  configurable option ID.
 
  63    * @see #getDefaultOptions
 
  66   public static final String FORMATTER_CLEAR_BLANK_LINES = PLUGIN_ID + ".formatter.newline.clearAll"; //$NON-NLS-1$
 
  68    * Possible  configurable option ID.
 
  69    * @see #getDefaultOptions
 
  72   public static final String FORMATTER_LINE_SPLIT = PLUGIN_ID + ".formatter.lineSplit"; //$NON-NLS-1$
 
  74    * Possible  configurable option ID.
 
  75    * @see #getDefaultOptions
 
  78   public static final String FORMATTER_COMPACT_ASSIGNMENT = PLUGIN_ID + ".formatter.style.assignment"; //$NON-NLS-1$
 
  80    * Possible  configurable option ID.
 
  81    * @see #getDefaultOptions
 
  84   public static final String FORMATTER_TAB_CHAR = PLUGIN_ID + ".formatter.tabulation.char"; //$NON-NLS-1$
 
  86    * Possible  configurable option ID.
 
  87    * @see #getDefaultOptions
 
  90   public static final String FORMATTER_TAB_SIZE = PLUGIN_ID + ".formatter.tabulation.size"; //$NON-NLS-1$
 
  92    * Possible  configurable option value.
 
  93    * @see #getDefaultOptions
 
  96   public static final String INSERT = "insert"; //$NON-NLS-1$
 
  98    * Possible  configurable option value.
 
  99    * @see #getDefaultOptions
 
 102   public static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$
 
 105    * Possible  configurable option value.
 
 106    * @see #getDefaultOptions
 
 109   public static final String PRESERVE_ONE = "preserve one"; //$NON-NLS-1$
 
 111    * Possible  configurable option value.
 
 112    * @see #getDefaultOptions
 
 115   public static final String CLEAR_ALL = "clear all"; //$NON-NLS-1$
 
 117    * Possible  configurable option value.
 
 118    * @see #getDefaultOptions
 
 121   public static final String NORMAL = "normal"; //$NON-NLS-1$
 
 123    * Possible  configurable option value.
 
 124    * @see #getDefaultOptions
 
 127   public static final String COMPACT = "compact"; //$NON-NLS-1$
 
 129    * Possible  configurable option value.
 
 130    * @see #getDefaultOptions
 
 133   public static final String TAB = "tab"; //$NON-NLS-1$
 
 135    * Possible  configurable option value.
 
 136    * @see #getDefaultOptions
 
 139   public static final String SPACE = "space"; //$NON-NLS-1$
 
 141    * Possible  configurable option value.
 
 142    * @see #getDefaultOptions
 
 145   public static final String ENABLED = "enabled"; //$NON-NLS-1$
 
 147    * Possible  configurable option value.
 
 148    * @see #getDefaultOptions
 
 151   public static final String DISABLED = "disabled"; //$NON-NLS-1$
 
 153    * Possible  configurable option value.
 
 154    * @see #getDefaultOptions
 
 157   public static final String CLEAN = "clean"; //$NON-NLS-1$
 
 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>.
 
 165    * Helper constants have been defined on JavaCore for each of the option ID and 
 
 166    * their possible constant values.
 
 168    * Note: more options might be added in further releases.
 
 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"
 
 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"
 
 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"
 
 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"
 
 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" }
 
 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" }
 
 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" }
 
 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"
 
 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"
 
 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"
 
 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"
 
 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"
 
 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"
 
 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"
 
 276    * COMPILER / Reporting Unused Import
 
 277    *    When enabled, the compiler will issue an error or a warning for unused import 
 
 279    *     - option id:         "org.phpeclipse.phpdt.core.compiler.problem.unusedImport"
 
 280    *     - possible values:   { "error", "warning", "ignore" }
 
 281    *     - default:           "warning"
 
 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"
 
 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"
 
 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"
 
 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"
 
 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"
 
 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" }
 
 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" }
 
 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).
 
 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 
 
 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"
 
 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 '/'
 
 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"
 
 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" }
 
 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"   
 
 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>
 
 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"}
 
 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" }
 
 403    *    FORMATTER / Inserting New Line Before Opening Brace
 
 404    *    When Insert, a new line is inserted before an opening brace, otherwise nothing
 
 406    *     - option id:         "org.phpeclipse.phpdt.core.formatter.newline.openingBrace"
 
 407    *     - possible values:   { "insert", "do not insert" }
 
 408    *     - default:           "do not insert"
 
 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"
 
 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"
 
 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"
 
 431    *    FORMATTER / Inserting New Line In Empty Block
 
 432    *    When insert, a line break is inserted between contiguous { and }, if } is not followed
 
 434    *     - option id:         "org.phpeclipse.phpdt.core.formatter.newline.emptyBlock"
 
 435    *     - possible values:   { "insert", "do not insert" }
 
 436    *     - default:           "insert"
 
 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
 
 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"
 
 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" }
 
 458    *    FORMATTER / Defining Space Indentation Length
 
 459    *    When using spaces, set the amount of space characters to use for each 
 
 461    *     - option id:         "org.phpeclipse.phpdt.core.formatter.tabulation.size"
 
 462    *     - possible values:     "<n>", where n is a positive integer
 
 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"
 
 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"
 
 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 
 
 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 
 
 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 
 
 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 
 
 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 
 
 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 
 
 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 
 
 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 
 
 536    * @return a mutable table containing the default settings of all known options
 
 537    *   (key type: <code>String</code>; value type: <code>String</code>)
 
 540   public static Hashtable getDefaultOptions() {
 
 542     Hashtable defaultOptions = new Hashtable(10);
 
 544     // see #initializeDefaultPluginPreferences() for changing default settings
 
 545     Preferences preferences = getPlugin().getPluginPreferences();
 
 546     HashSet optionNames = OptionNames;
 
 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)) {
 
 555           preferences.getDefaultString(propertyName));
 
 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)) {
 
 565           preferences.getDefaultString(propertyName));
 
 568     // get encoding through resource plugin
 
 569     defaultOptions.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
 
 571     return defaultOptions;
 
 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.
 
 577    * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
 
 580    * @param optionName the name of an option
 
 581    * @return the String value of a given option
 
 582    * @see JavaCore#getDefaultOptions
 
 585   public static String getOption(String optionName) {
 
 587     if (CORE_ENCODING.equals(optionName)) {
 
 588       return ResourcesPlugin.getEncoding();
 
 590     if (OptionNames.contains(optionName)) {
 
 591       Preferences preferences = getPlugin().getPluginPreferences();
 
 592       return preferences.getString(optionName).trim();
 
 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.
 
 601    * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
 
 604    * @return table of current settings of all options 
 
 605    *   (key type: <code>String</code>; value type: <code>String</code>)
 
 606    * @see JavaCore#getDefaultOptions
 
 608   public static Hashtable getOptions() {
 
 610     Hashtable options = new Hashtable(10);
 
 612     // see #initializeDefaultPluginPreferences() for changing default settings
 
 613     Plugin plugin = getPlugin();
 
 614     if (plugin != null) {
 
 615       Preferences preferences = getPlugin().getPluginPreferences();
 
 616       HashSet optionNames = OptionNames;
 
 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));
 
 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());
 
 634       // get encoding through resource plugin
 
 635       options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
 
 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
 
 644    * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
 
 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
 
 651   public static void setOptions(Hashtable newOptions) {
 
 653     // see #initializeDefaultPluginPreferences() for changing default settings
 
 654     Preferences preferences = getPlugin().getPluginPreferences();
 
 656     if (newOptions == null) {
 
 657       newOptions = getDefaultOptions();
 
 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);
 
 671     getPlugin().savePluginPreferences();
 
 673   public static IProject[] getPHPProjects() {
 
 674     List phpProjectsList = new ArrayList();
 
 675     IProject[] workspaceProjects =
 
 676       PHPeclipsePlugin.getWorkspace().getRoot().getProjects();
 
 678     for (int i = 0; i < workspaceProjects.length; i++) {
 
 679       IProject iProject = workspaceProjects[i];
 
 680       if (isPHPProject(iProject))
 
 681         phpProjectsList.add(iProject);
 
 684     IProject[] phpProjects = new IProject[phpProjectsList.size()];
 
 685     return (IProject[]) phpProjectsList.toArray(phpProjects);
 
 688   public static PHPProject getPHPProject(String name) {
 
 690       PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
 
 691     if (isPHPProject(aProject)) {
 
 692       PHPProject thePHPProject = new PHPProject();
 
 693       thePHPProject.setProject(aProject);
 
 694       return thePHPProject;
 
 699   public static boolean isPHPProject(IProject aProject) {
 
 701       return aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID);
 
 702     } catch (CoreException e) {
 
 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);
 
 725   public static PHPProject create(IProject aProject) {
 
 727       if (aProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
 
 728         PHPProject project = new PHPProject();
 
 729         project.setProject(aProject);
 
 732     } catch (CoreException e) {
 
 734         "Exception occurred in PHPCore#create(IProject): " + e.toString());
 
 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);
 
 754    * Returns the single instance of the PHP core plug-in runtime class.
 
 756    * @return the single instance of the PHP core plug-in runtime class
 
 758   public static Plugin getPlugin() {
 
 759     return PHPeclipsePlugin.getDefault();
 
 763    * Initializes the default preferences settings for this plug-in.
 
 765   protected static void initializeDefaultPluginPreferences() {
 
 767     Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
 
 768     HashSet optionNames = OptionNames;
 
 770 //    // Compiler settings
 
 771 //    preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
 
 772 //    optionNames.add(COMPILER_LOCAL_VARIABLE_ATTR);
 
 774 //    preferences.setDefault(COMPILER_LINE_NUMBER_ATTR, GENERATE); 
 
 775 //    optionNames.add(COMPILER_LINE_NUMBER_ATTR);
 
 777 //    preferences.setDefault(COMPILER_SOURCE_FILE_ATTR, GENERATE); 
 
 778 //    optionNames.add(COMPILER_SOURCE_FILE_ATTR);
 
 780 //    preferences.setDefault(COMPILER_CODEGEN_UNUSED_LOCAL, PRESERVE); 
 
 781 //    optionNames.add(COMPILER_CODEGEN_UNUSED_LOCAL);
 
 783 //    preferences.setDefault(COMPILER_CODEGEN_TARGET_PLATFORM, VERSION_1_1); 
 
 784 //    optionNames.add(COMPILER_CODEGEN_TARGET_PLATFORM);
 
 786 //    preferences.setDefault(COMPILER_PB_UNREACHABLE_CODE, ERROR); 
 
 787 //    optionNames.add(COMPILER_PB_UNREACHABLE_CODE);
 
 789 //    preferences.setDefault(COMPILER_PB_INVALID_IMPORT, ERROR); 
 
 790 //    optionNames.add(COMPILER_PB_INVALID_IMPORT);
 
 792 //    preferences.setDefault(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, WARNING); 
 
 793 //    optionNames.add(COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD);
 
 795 //    preferences.setDefault(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME, WARNING); 
 
 796 //    optionNames.add(COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME);
 
 798 //    preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING);
 
 799 //    optionNames.add(COMPILER_PB_DEPRECATION);
 
 801 //    preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE, DISABLED);
 
 802 //    optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE);
 
 804 //    preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING); 
 
 805 //    optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK);
 
 807 //    preferences.setDefault(COMPILER_PB_UNUSED_LOCAL, IGNORE); 
 
 808 //    optionNames.add(COMPILER_PB_UNUSED_LOCAL);
 
 810 //    preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE); 
 
 811 //    optionNames.add(COMPILER_PB_UNUSED_PARAMETER);
 
 813 //    preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING); 
 
 814 //    optionNames.add(COMPILER_PB_UNUSED_IMPORT);
 
 816 //    preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE); 
 
 817 //    optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION);
 
 819 //    preferences.setDefault(COMPILER_PB_NON_NLS_STRING_LITERAL, IGNORE); 
 
 820 //    optionNames.add(COMPILER_PB_NON_NLS_STRING_LITERAL);
 
 822 //    preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE); 
 
 823 //    optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER);
 
 825 //    preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING); 
 
 826 //    optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER);
 
 828 //    preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING); 
 
 829 //    optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT);
 
 831 //    preferences.setDefault(COMPILER_TASK_TAGS, ""); //$NON-NLS-1$
 
 832 //    optionNames.add(COMPILER_TASK_TAGS);
 
 834 //    preferences.setDefault(COMPILER_TASK_PRIORITIES, ""); //$NON-NLS-1$
 
 835 //    optionNames.add(COMPILER_TASK_PRIORITIES);
 
 837 //    preferences.setDefault(COMPILER_SOURCE, VERSION_1_3);
 
 838 //    optionNames.add(COMPILER_SOURCE);
 
 840 //    preferences.setDefault(COMPILER_COMPLIANCE, VERSION_1_3); 
 
 841 //    optionNames.add(COMPILER_COMPLIANCE);
 
 843 //    preferences.setDefault(COMPILER_PB_MAX_PER_UNIT, "100"); //$NON-NLS-1$
 
 844 //    optionNames.add(COMPILER_PB_MAX_PER_UNIT);
 
 846 //    // Builder settings
 
 847 //    preferences.setDefault(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$
 
 848 //    optionNames.add(CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
 
 850 //    preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT); 
 
 851 //    optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH);
 
 853 //    preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING); 
 
 854 //    optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE);
 
 856 //    preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN); 
 
 857 //    optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER);
 
 859 //    // JavaCore settings
 
 860 //    preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE); 
 
 861 //    optionNames.add(CORE_JAVA_BUILD_ORDER);
 
 863 //    preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR); 
 
 864 //    optionNames.add(CORE_CIRCULAR_CLASSPATH);
 
 866 //    preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR); 
 
 867 //    optionNames.add(CORE_INCOMPLETE_CLASSPATH);
 
 869     // encoding setting comes from resource plug-in
 
 870     optionNames.add(CORE_ENCODING);
 
 872     // Formatter settings
 
 873     preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT); 
 
 874     optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE);
 
 876     preferences.setDefault(FORMATTER_NEWLINE_CONTROL, DO_NOT_INSERT);
 
 877     optionNames.add(FORMATTER_NEWLINE_CONTROL);
 
 879     preferences.setDefault(FORMATTER_CLEAR_BLANK_LINES, PRESERVE_ONE); 
 
 880     optionNames.add(FORMATTER_CLEAR_BLANK_LINES);
 
 882     preferences.setDefault(FORMATTER_NEWLINE_ELSE_IF, DO_NOT_INSERT);
 
 883     optionNames.add(FORMATTER_NEWLINE_ELSE_IF);
 
 885     preferences.setDefault(FORMATTER_NEWLINE_EMPTY_BLOCK, INSERT); 
 
 886     optionNames.add(FORMATTER_NEWLINE_EMPTY_BLOCK);
 
 888     preferences.setDefault(FORMATTER_LINE_SPLIT, "80"); //$NON-NLS-1$
 
 889     optionNames.add(FORMATTER_LINE_SPLIT);
 
 891     preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL); 
 
 892     optionNames.add(FORMATTER_COMPACT_ASSIGNMENT);
 
 894     preferences.setDefault(FORMATTER_TAB_CHAR, TAB); 
 
 895     optionNames.add(FORMATTER_TAB_CHAR);
 
 897     preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$ 
 
 898     optionNames.add(FORMATTER_TAB_SIZE);
 
 900     // CodeAssist settings
 
 901 //    preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$
 
 902 //    optionNames.add(CODEASSIST_VISIBILITY_CHECK);
 
 904 //    preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$
 
 905 //    optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION);
 
 907 //    preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
 
 908 //    optionNames.add(CODEASSIST_FIELD_PREFIXES);
 
 910 //    preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
 
 911 //    optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES);
 
 913 //    preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
 
 914 //    optionNames.add(CODEASSIST_LOCAL_PREFIXES);
 
 916 //    preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
 
 917 //    optionNames.add(CODEASSIST_ARGUMENT_PREFIXES);
 
 919 //    preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
 
 920 //    optionNames.add(CODEASSIST_FIELD_SUFFIXES);
 
 922 //    preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
 
 923 //    optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES);
 
 925 //    preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
 
 926 //    optionNames.add(CODEASSIST_LOCAL_SUFFIXES);
 
 928 //    preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
 
 929 //    optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES);