Simple auto indent strategy when inserting templates
authoraxelcl <axelcl>
Sat, 6 Nov 2004 11:49:16 +0000 (11:49 +0000)
committeraxelcl <axelcl>
Sat, 6 Nov 2004 11:49:16 +0000 (11:49 +0000)
net.sourceforge.phpeclipse/plugin.xml
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/formatter/DefaultCodeFormatterConstants.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/JavaContext.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/JavaFormatter.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/util/CodeFormatterUtil.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/JavaIndenter.java [new file with mode: 0644]

index 940c251..72dcc0d 100644 (file)
                </enablement>
        </decorator>    
 </extension>
-
-   
+  
    <extension
          point="org.eclipse.team.core.fileTypes">
       <fileTypes
             name="%phpEditorName"
             default="true"
             icon="icons/obj16/phpedit.gif"
-            extensions="php"
+            extensions="php,php3,php4,php5,phtml,inc,module"
             contributorClass="net.sourceforge.phpeclipse.phpeditor.CompilationUnitEditorActionContributor"
             class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
             symbolicFontName="net.sourceforge.phpdt.ui.editors.textfont"
             id="net.sourceforge.phpeclipse.PHPUnitEditor">
       </editor>
-      <editor
+ <!--     <editor
             name="%phpEditorName"
             default="true"
             icon="icons/obj16/phpedit.gif"
             class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
             symbolicFontName="net.sourceforge.phpdt.ui.editors.textfont"
             id="net.sourceforge.phpeclipse.PHPUnitEditor">
-      </editor>
+      </editor> -->
       <editor
             name="%phpEditorName"
             default="true"
             icon="icons/obj16/htmledit.gif"
-            extensions="htm" 
+            extensions="htm,html,xhtml" 
             contributorClass="net.sourceforge.phpeclipse.phpeditor.CompilationUnitEditorActionContributor"
             class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
             symbolicFontName="net.sourceforge.phpdt.ui.editors.textfont"
             id="net.sourceforge.phpeclipse.PHPUnitEditor">
       </editor>
-      <editor
+  <!--    <editor
             name="%phpEditorName"
             default="true"
             icon="icons/obj16/htmledit.gif"
             class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
             symbolicFontName="net.sourceforge.phpdt.ui.editors.textfont"
             id="net.sourceforge.phpeclipse.PHPUnitEditor">
-      </editor>
+      </editor> -->
   <!--    <editor
             name="%phpEditorName"
             default="true"
    <extension
          point="org.eclipse.ui.editors.documentProviders">
       <provider
-            extensions="%phpFileExtension"
+            extensions="php,php3,php4,php5,phtml,inc,module,html,htm,xhtml"
             class="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider"
             id="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider">
       </provider>
    </extension>
-   <extension
+<!--   <extension
          point="org.eclipse.ui.editors.documentProviders">
       <provider
             extensions="%php3FileExtension"
             class="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider"
             id="net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider">
       </provider>
-   </extension>
+   </extension> -->
  <!--  <extension
          point="org.eclipse.ui.editors.documentProviders">
       <provider
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/formatter/DefaultCodeFormatterConstants.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/formatter/DefaultCodeFormatterConstants.java
new file mode 100644 (file)
index 0000000..fcdd29c
--- /dev/null
@@ -0,0 +1,2493 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.core.formatter;
+
+//import java.util.Map;
+
+import net.sourceforge.phpdt.core.JavaCore;
+//import net.sourceforge.phpdt.internal.formatter.DefaultCodeFormatterOptions;
+//import net.sourceforge.phpdt.internal.formatter.align.Alignment;
+
+/**
+ * Constants used to set up the options of the code formatter.
+ * 
+ * @since 3.0
+ */
+public class DefaultCodeFormatterConstants {
+
+       /*
+        * Private constants. Not in javadoc
+        */
+       private static final IllegalArgumentException WRONG_ARGUMENT = new IllegalArgumentException();
+
+       /**
+        * <pre>
+        * FORMATTER / Value to set a brace location at the end of a line.
+        * </pre>
+        * @see #FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION
+        * @see #FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER
+        * @see #FORMATTER_BRACE_POSITION_FOR_BLOCK
+        * @see #FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION
+        * @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION
+        * @see #FORMATTER_BRACE_POSITION_FOR_SWITCH
+        * @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
+        * @since 3.0
+        */
+       public static final String END_OF_LINE = "end_of_line"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Value to set a brace location at the start of the next line with
+        *             the right indentation.
+        * </pre>
+        * @see #FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION
+        * @see #FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER
+        * @see #FORMATTER_BRACE_POSITION_FOR_BLOCK
+        * @see #FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION
+        * @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION
+        * @see #FORMATTER_BRACE_POSITION_FOR_SWITCH
+        * @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
+        * @since 3.0
+        */
+       public static final String NEXT_LINE = "next_line"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Value to set a brace location at the start of the next line with
+        *             an extra indentation.
+        * </pre>
+        * @see #FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION
+        * @see #FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER
+        * @see #FORMATTER_BRACE_POSITION_FOR_BLOCK
+        * @see #FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION
+        * @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION
+        * @see #FORMATTER_BRACE_POSITION_FOR_SWITCH
+        * @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
+        * @since 3.0
+        */
+       public static final String NEXT_LINE_SHIFTED = "next_line_shifted";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Value to set a brace location at the start of the next line if a wrapping
+        *             occured.
+        * </pre>
+        * @see #FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION
+        * @see #FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER
+        * @see #FORMATTER_BRACE_POSITION_FOR_BLOCK
+        * @see #FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION
+        * @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION
+        * @see #FORMATTER_BRACE_POSITION_FOR_SWITCH
+        * @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
+        * @since 3.0
+        */
+    public static final String NEXT_LINE_ON_WRAP = "next_line_on_wrap"; //$NON-NLS-1$
+
+       /**
+        * <pre>
+        * FORMATTER / Value to set an option to true.
+        * </pre>
+        * @since 3.0
+        */
+    public static final String FALSE = "false"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Value to set an option to false.
+        * </pre>
+        * @since 3.0
+        */
+       public static final String TRUE = "true"; //$NON-NLS-1$
+
+       /**
+        * <pre>
+        * FORMATTER / Value to disable alignment.
+        * </pre>
+        * @since 3.0
+        */
+       public static final int WRAP_NO_SPLIT= 0;
+       /**
+        * <pre>
+        * FORMATTER / The wrapping is done using as few lines as possible.
+        * </pre>
+        * @since 3.0
+        */
+       public static final int WRAP_COMPACT= 1;
+       /**
+        * <pre>
+        * FORMATTER / The wrapping is done putting the first element on a new
+        *             line and then wrapping next elements using as few lines as possible.
+        * </pre>
+        * @since 3.0
+        */
+       public static final int WRAP_COMPACT_FIRST_BREAK= 2;
+       /**
+        * <pre>
+        * FORMATTER / The wrapping is done by putting each element on its own line.
+        * </pre>
+        * @since 3.0
+        */
+       public static final int WRAP_ONE_PER_LINE= 3;
+       /**
+        * <pre>
+        * FORMATTER / The wrapping is done by putting each element on its own line.
+        *             All elements are indented by one except the first element.
+        * </pre>
+        * @since 3.0
+        */
+       public static final int WRAP_NEXT_SHIFTED= 4;
+       /**
+        * <pre>
+        * FORMATTER / The wrapping is done by putting each element on its own line
+        *             except the first element.
+        * </pre>
+        * @since 3.0
+        */
+       public static final int WRAP_NEXT_PER_LINE= 5;
+       
+       /**
+        * <pre>
+        * FORMATTER / The wrapping is done by using the current indentation.
+        * </pre>
+        * @since 3.0
+        */
+       public static final int INDENT_DEFAULT= 0;
+       /**
+        * <pre>
+        * FORMATTER / The wrapping is done by indenting on column under the splitting location.
+        * </pre>
+        * @since 3.0
+        */
+       public static final int INDENT_ON_COLUMN = 1;
+       /**
+        * <pre>
+        * FORMATTER / The wrapping is done by indenting by one compare to the current indentation.
+        * </pre>
+        * @since 3.0
+        */
+       public static final int INDENT_BY_ONE= 2;
+       
+       /**
+        * <pre>
+        * FORMATTER / Option for alignment of arguments in allocation expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.alignment_for_arguments_in_allocation_expression"
+        *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
+        *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
+        * </pre>
+        * @see #createAlignmentValue(boolean, int, int)
+        * @since 3.0
+        */
+       public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION = JavaCore.PLUGIN_ID + ".formatter.alignment_for_arguments_in_allocation_expression";      //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option for alignment of arguments in explicit constructor call
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call"
+        *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
+        *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
+        * </pre>
+        * @see #createAlignmentValue(boolean, int, int)
+        * @since 3.0
+        */
+       public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL = JavaCore.PLUGIN_ID + ".formatter.alignment_for_arguments_in_explicit_constructor_call";      //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option for alignment of arguments in method invocation
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.alignment_for_arguments_in_method_invocation"
+        *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
+        *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
+        * </pre>
+        * @see #createAlignmentValue(boolean, int, int)
+        * @since 3.0
+        */
+       public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION = JavaCore.PLUGIN_ID + ".formatter.alignment_for_arguments_in_method_invocation";      //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option for alignment of arguments in qualified allocation expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression"
+        *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
+        *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
+        * </pre>
+        * @see #createAlignmentValue(boolean, int, int)
+        * @since 3.0
+        */
+       public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_QUALIFIED_ALLOCATION_EXPRESSION = JavaCore.PLUGIN_ID + ".formatter.alignment_for_arguments_in_qualified_allocation_expression";  //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option for alignment of binary expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.alignment_for_binary_expression"
+        *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
+        *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
+        * </pre>
+        * @see #createAlignmentValue(boolean, int, int)
+        * @since 3.0
+        */
+       public static final String FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION = JavaCore.PLUGIN_ID + ".formatter.alignment_for_binary_expression";        //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option for alignment of compact if
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.alignment_for_compact_if"
+        *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
+        *     - default:           createAlignmentValue(false, WRAP_ONE_PER_LINE, INDENT_BY_ONE)
+        * </pre>
+        * @see #createAlignmentValue(boolean, int, int)
+        * @since 3.0
+        */
+       public static final String FORMATTER_ALIGNMENT_FOR_COMPACT_IF = JavaCore.PLUGIN_ID + ".formatter.alignment_for_compact_if";      //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option for alignment of conditional expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.alignment_for_conditional_expression"
+        *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
+        *     - default:           createAlignmentValue(false, WRAP_ONE_PER_LINE, INDENT_DEFAULT)
+        * </pre>
+        * @see #createAlignmentValue(boolean, int, int)
+        * @since 3.0
+        */
+       public static final String FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION = JavaCore.PLUGIN_ID + ".formatter.alignment_for_conditional_expression";      //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option for alignment of expressions in array initializer
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.alignment_for_expressions_in_array_initializer"
+        *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
+        *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
+        * </pre>
+        * @see #createAlignmentValue(boolean, int, int)
+        * @since 3.0
+        */
+       public static final String FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER = JavaCore.PLUGIN_ID + ".formatter.alignment_for_expressions_in_array_initializer";  //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option for alignment of multiple fields
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.alignment_for_multiple_fields"
+        *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
+        *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
+        * </pre>
+        * @see #createAlignmentValue(boolean, int, int)
+        * @since 3.0
+        */
+       public static final String FORMATTER_ALIGNMENT_FOR_MULTIPLE_FIELDS = JavaCore.PLUGIN_ID + ".formatter.alignment_for_multiple_fields";//$NON-NLS-1$      
+       /**
+        * <pre>
+        * FORMATTER / Option for alignment of parameters in constructor declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.alignment_for_parameters_in_constructor_declaration"
+        *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
+        *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
+        * </pre>
+        * @see #createAlignmentValue(boolean, int, int)
+        * @since 3.0
+        */
+       public static final String FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.alignment_for_parameters_in_constructor_declaration";        //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option for alignment of parameters in method declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.alignment_for_parameters_in_method_declaration"
+        *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
+        *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
+        * </pre>
+        * @see #createAlignmentValue(boolean, int, int)
+        * @since 3.0
+        */
+       public static final String FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.alignment_for_parameters_in_method_declaration";  //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option for alignment of selector in method invocation
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.alignment_for_selector_in_method_invocation"
+        *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
+        *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
+        * </pre>
+        * @see #createAlignmentValue(boolean, int, int)
+        * @since 3.0
+        */
+       public static final String FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION = JavaCore.PLUGIN_ID + ".formatter.alignment_for_selector_in_method_invocation";        //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option for alignment of superclass in type declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.alignment_for_superclass_in_type_declaration"
+        *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
+        *     - default:           createAlignmentValue(false, WRAP_NEXT_SHIFTED, INDENT_DEFAULT)
+        * </pre>
+        * @see #createAlignmentValue(boolean, int, int)
+        * @since 3.0
+        */
+       public static final String FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.alignment_for_superclass_in_type_declaration";      //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option for alignment of superinterfaces in type declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.alignment_for_superinterfaces_in_type_declaration"
+        *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
+        *     - default:           createAlignmentValue(false, WRAP_NEXT_SHIFTED, INDENT_DEFAULT)
+        * </pre>
+        * @see #createAlignmentValue(boolean, int, int)
+        * @since 3.0
+        */
+       public static final String FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_TYPE_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.alignment_for_superinterfaces_in_type_declaration";    //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option for alignment of throws clause in constructor declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration"
+        *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
+        *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
+        * </pre>
+        * @see #createAlignmentValue(boolean, int, int)
+        * @since 3.0
+        */
+       public static final String FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.alignment_for_throws_clause_in_constructor_declaration";  //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option for alignment of throws clause in method declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.alignment_for_throws_clause_in_method_declaration"
+        *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
+        *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
+        * </pre>
+        * @see #createAlignmentValue(boolean, int, int)
+        * @since 3.0
+        */
+       public static final String FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.alignment_for_throws_clause_in_method_declaration";    //$NON-NLS-1$
+       
+       /**
+        * <pre>
+        * FORMATTER / Option to align type members of a type declaration on column
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.alignment_for_throws_clause_in_method_declaration"
+        *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
+        *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
+        * </pre>
+        * @see #createAlignmentValue(boolean, int, int)
+        * @since 3.0
+        */
+       public static final String FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS = JavaCore.PLUGIN_ID + ".formatter.align_type_members_on_columns";    //$NON-NLS-1$
+       
+       /**
+        * <pre>
+        * FORMATTER / Option to position the braces of a anonymous type declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.brace_position_for_anonymous_type_declaration"
+        *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
+        *     - default:           END_OF_LINE
+        * </pre>
+        * @see #END_OF_LINE
+        * @see #NEXT_LINE
+        * @see #NEXT_LINE_SHIFTED
+        * @see #NEXT_LINE_ON_WRAP
+        * @since 3.0
+        */
+       public static final String FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.brace_position_for_anonymous_type_declaration";   //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to position the braces of an array initializer
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.brace_position_for_array_initializer"
+        *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
+        *     - default:           END_OF_LINE
+        * </pre>
+        * @see #END_OF_LINE
+        * @see #NEXT_LINE
+        * @see #NEXT_LINE_SHIFTED
+        * @see #NEXT_LINE_ON_WRAP
+        * @since 3.0
+        */
+       public static final String FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER = JavaCore.PLUGIN_ID + ".formatter.brace_position_for_array_initializer";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to position the braces of a block
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.brace_position_for_block"
+        *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
+        *     - default:           END_OF_LINE
+        * </pre>
+        * @see #END_OF_LINE
+        * @see #NEXT_LINE
+        * @see #NEXT_LINE_SHIFTED
+        * @see #NEXT_LINE_ON_WRAP
+        * @since 3.0
+        */
+       public static final String FORMATTER_BRACE_POSITION_FOR_BLOCK = JavaCore.PLUGIN_ID + ".formatter.brace_position_for_block";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to position the braces of a block in a case statement when the block is the first statement following
+        *             the case
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.brace_position_for_block_in_case"
+        *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
+        *     - default:           END_OF_LINE
+        * </pre>
+        * @see #END_OF_LINE
+        * @see #NEXT_LINE
+        * @see #NEXT_LINE_SHIFTED
+        * @see #NEXT_LINE_ON_WRAP
+        * @since 3.0
+        */
+       public static final String FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE = JavaCore.PLUGIN_ID + ".formatter.brace_position_for_block_in_case";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to position the braces of a constructor declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.brace_position_for_constructor_declaration"
+        *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
+        *     - default:           END_OF_LINE
+        * </pre>
+        * @see #END_OF_LINE
+        * @see #NEXT_LINE
+        * @see #NEXT_LINE_SHIFTED
+        * @see #NEXT_LINE_ON_WRAP
+        * @since 3.0
+        */
+       public static final String FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.brace_position_for_constructor_declaration"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to position the braces of a method declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.brace_position_for_method_declaration"
+        *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
+        *     - default:           END_OF_LINE
+        * </pre>
+        * @see #END_OF_LINE
+        * @see #NEXT_LINE
+        * @see #NEXT_LINE_SHIFTED
+        * @see #NEXT_LINE_ON_WRAP
+        * @since 3.0
+        */
+       public static final String FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.brace_position_for_method_declaration";   //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to position the braces of a type declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.brace_position_for_type_declaration"
+        *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
+        *     - default:           END_OF_LINE
+        * </pre>
+        * @see #END_OF_LINE
+        * @see #NEXT_LINE
+        * @see #NEXT_LINE_SHIFTED
+        * @see #NEXT_LINE_ON_WRAP
+        * @since 3.0
+        */
+       public static final String FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.brace_position_for_type_declaration";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to position the braces of a switch statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.brace_position_for_switch"
+        *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
+        *     - default:           END_OF_LINE
+        * </pre>
+        * @see #END_OF_LINE
+        * @see #NEXT_LINE
+        * @see #NEXT_LINE_SHIFTED
+        * @see #NEXT_LINE_ON_WRAP
+        * @since 3.0
+        */
+       public static final String FORMATTER_BRACE_POSITION_FOR_SWITCH = JavaCore.PLUGIN_ID + ".formatter.brace_position_for_switch";   //$NON-NLS-1$
+
+       /**
+        * <pre>
+        * FORMATTER / Option to set the continuation indentation
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.continuation_indentation"
+        *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
+        *     - default:           "2"
+        * </pre>
+        * @since 3.0
+        */
+       public static final String FORMATTER_CONTINUATION_INDENTATION = JavaCore.PLUGIN_ID + ".formatter.continuation_indentation";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to set the continuation indentation inside array initializer
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.continuation_indentation_for_array_initializer"
+        *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
+        *     - default:           "2"
+        * </pre>
+        * @since 3.0
+        */
+       public static final String FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER = JavaCore.PLUGIN_ID + ".formatter.continuation_indentation_for_array_initializer"; //$NON-NLS-1$
+
+       /**
+        * <pre>
+        * FORMATTER / Option to add blank lines after the imports declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.blank_lines_after_imports"
+        *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
+        *     - default:           "0"
+        * </pre>
+        * @since 3.0
+        */
+       public static final String FORMATTER_BLANK_LINES_AFTER_IMPORTS = JavaCore.PLUGIN_ID + ".formatter.blank_lines_after_imports";   //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to add blank lines after the package declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.blank_lines_after_package"
+        *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
+        *     - default:           "0"
+        * </pre>
+        * @since 3.0
+        */
+       public static final String FORMATTER_BLANK_LINES_AFTER_PACKAGE = JavaCore.PLUGIN_ID + ".formatter.blank_lines_after_package";   //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to add blank lines before a field declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.blank_lines_before_field"
+        *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
+        *     - default:           "0"
+        * </pre>
+        * @since 3.0
+        */
+       public static final String FORMATTER_BLANK_LINES_BEFORE_FIELD = JavaCore.PLUGIN_ID + ".formatter.blank_lines_before_field";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to add blank lines before the first class body declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.blank_lines_before_first_class_body_declaration"
+        *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
+        *     - default:           "0"
+        * </pre>
+        * @since 3.0
+        */
+       public static final String FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.blank_lines_before_first_class_body_declaration";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to add blank lines before the imports declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.blank_lines_before_imports"
+        *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
+        *     - default:           "0"
+        * </pre>
+        * @since 3.0
+        */
+       public static final String FORMATTER_BLANK_LINES_BEFORE_IMPORTS = JavaCore.PLUGIN_ID + ".formatter.blank_lines_before_imports"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to add blank lines before a member type declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.blank_lines_before_member_type"
+        *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
+        *     - default:           "0"
+        * </pre>
+        * @since 3.0
+        */
+       public static final String FORMATTER_BLANK_LINES_BEFORE_MEMBER_TYPE = JavaCore.PLUGIN_ID + ".formatter.blank_lines_before_member_type"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to add blank lines before a method declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.blank_lines_before_method"
+        *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
+        *     - default:           "0"
+        * </pre>
+        * @since 3.0
+        */
+       public static final String FORMATTER_BLANK_LINES_BEFORE_METHOD = JavaCore.PLUGIN_ID + ".formatter.blank_lines_before_method";   //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to add blank lines before a new chunk
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.blank_lines_before_new_chunk"
+        *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
+        *     - default:           "0"
+        * </pre>
+        * @since 3.0
+        */
+       public static final String FORMATTER_BLANK_LINES_BEFORE_NEW_CHUNK = JavaCore.PLUGIN_ID + ".formatter.blank_lines_before_new_chunk";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to add blank lines before the package declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.blank_lines_before_package"
+        *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
+        *     - default:           "0"
+        * </pre>
+        * @since 3.0
+        */
+       public static final String FORMATTER_BLANK_LINES_BEFORE_PACKAGE = JavaCore.PLUGIN_ID + ".formatter.blank_lines_before_package"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to add blank lines between type declarations
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.blank_lines_between_type_declarations"
+        *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
+        *     - default:           "0"
+        * </pre>
+        * @since 3.0
+        */
+       public static final String FORMATTER_BLANK_LINES_BETWEEN_TYPE_DECLARATIONS = JavaCore.PLUGIN_ID + ".formatter.blank_lines_between_type_declarations";   //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to add blank lines at the beginning of the method body
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body"
+        *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
+        *     - default:           "0"
+        * </pre>
+        * @since 3.0
+        */
+       public static final String FORMATTER_BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY = JavaCore.PLUGIN_ID + ".formatter.number_of_blank_lines_at_beginning_of_method_body"; //$NON-NLS-1$
+
+       /**
+        * <pre>
+        * FORMATTER / Option to indent body declarations compare to its enclosing type header
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.indent_body_declarations_compare_to_type_header"
+        *     - possible values:   { TRUE, FALSE }
+        *     - default:           TRUE
+        * </pre>
+        * @see #TRUE
+        * @see #FALSE
+        * @since 3.0
+        */
+       public static final String FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER = JavaCore.PLUGIN_ID + ".formatter.indent_body_declarations_compare_to_type_header";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to indent breaks compare to cases
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.indent_breaks_compare_to_cases"
+        *     - possible values:   { TRUE, FALSE }
+        *     - default:           TRUE
+        * </pre>
+        * @see #TRUE
+        * @see #FALSE
+        * @since 3.0
+        */
+       public static final String FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES = JavaCore.PLUGIN_ID + ".formatter.indent_breaks_compare_to_cases"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to indent statements inside a block
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.indent_statements_compare_to_block"
+        *     - possible values:   { TRUE, FALSE }
+        *     - default:           TRUE
+        * </pre>
+        * @see #TRUE
+        * @see #FALSE
+        * @since 3.0
+        */
+       public static final String FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK = JavaCore.PLUGIN_ID + ".formatter.indent_statements_compare_to_block"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to indent statements inside the body of a method or a constructor
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.indent_statements_compare_to_body"
+        *     - possible values:   { TRUE, FALSE }
+        *     - default:           TRUE
+        * </pre>
+        * @see #TRUE
+        * @see #FALSE
+        * @since 3.0
+        */
+       public static final String FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY = JavaCore.PLUGIN_ID + ".formatter.indent_statements_compare_to_body"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to indent switch statements compare to cases
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.indent_switchstatements_compare_to_cases"
+        *     - possible values:   { TRUE, FALSE }
+        *     - default:           TRUE
+        * </pre>
+        * @see #TRUE
+        * @see #FALSE
+        * @since 3.0
+        */
+       public static final String FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES = JavaCore.PLUGIN_ID + ".formatter.indent_switchstatements_compare_to_cases";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to indent switch statements compare to switch
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.indent_switchstatements_compare_to_switch"
+        *     - possible values:   { TRUE, FALSE }
+        *     - default:           TRUE
+        * </pre>
+        * @see #TRUE
+        * @see #FALSE
+        * @since 3.0
+        */
+       public static final String FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH = JavaCore.PLUGIN_ID + ".formatter.indent_switchstatements_compare_to_switch";   //$NON-NLS-1$
+
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a new line after the opening brace in an array initializer
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_after_opening_brace_in_array_initializer";//$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a new line before the catch keyword in try statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_new_line_before_catch_in_try_statement"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_before_catch_in_try_statement";   //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a new line before the closing brace in an array initializer
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_before_closing_brace_in_array_initializer";//$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a new line before the else keyword in if statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_new_line_before_else_in_if_statement"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_before_else_in_if_statement";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a new line before the finally keyword in try statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_new_line_before_finally_in_try_statement"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_before_finally_in_try_statement";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a new line before while in do statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_new_line_before_while_in_do_statement"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_before_while_in_do_statement";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a new line in an empty anonymous type declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANONYMOUS_TYPE_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_in_empty_anonymous_type_declaration";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a new line in an empty block
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_new_line_in_empty_block"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_in_empty_block"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a new line in an empty method body
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_new_line_in_empty_method_body"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_in_empty_method_body";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a new line in an empty type declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_new_line_in_empty_type_declaration"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_in_empty_type_declaration";   //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after an assignment operator
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_assignment_operator"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_assignment_operator"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after a binary operator
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_binary_operator"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_binary_operator"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the closing parenthesis of a cast expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_closing_paren_in_cast"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_closing_paren_in_cast"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the closing brace of a block
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_closing_brace_in_block"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_closing_brace_in_block"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the colon in an assert statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_colon_in_assert"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_ASSERT = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_colon_in_assert"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after colon in a case statement when a opening brace follows the colon
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_colon_in_case"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CASE = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_colon_in_case";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the colon in a conditional expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_colon_in_conditional"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_colon_in_conditional"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the colon in a labeled statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_colon_in_labeled_statement"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_colon_in_labeled_statement"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the comma in an allocation expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_comma_in_allocation_expression"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ALLOCATION_EXPRESSION = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_allocation_expression"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the comma in an array initializer
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_comma_in_array_initializer"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_array_initializer"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the comma in the parameters of a constructor declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_constructor_declaration_parameters"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the comma in the exception names in a throws clause of a constructor declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_constructor_declaration_throws"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the comma in the arguments of an explicit constructor call
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_explicitconstructorcall_arguments"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the comma in the increments of a for statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_comma_in_for_increments"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_for_increments"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the comma in the initializations of a for statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_comma_in_for_inits"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_for_inits"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the comma in the arguments of a method invocation
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_method_invocation_arguments"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the comma in the parameters of a method declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_method_declaration_parameters"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the comma in the exception names in a throws clause of a method declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_comma_in_method_declaration_throws"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_method_declaration_throws"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the comma in multiple field declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_multiple_field_declarations"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the comma in multiple local declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_multiple_local_declarations"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the comma in superinterfaces names of a type header
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_comma_in_superinterfaces"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_SUPERINTERFACES = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_comma_in_superinterfaces"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the opening bracket inside an array allocation expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_opening_bracket_in_array_allocation_expression";//$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the opening bracket inside an array reference
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_opening_bracket_in_array_reference"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_REFERENCE = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_opening_bracket_in_array_reference";//$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the opening brace in an array initializer
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_opening_brace_in_array_initializer"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_opening_brace_in_array_initializer";   //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the opening parenthesis in a cast expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_opening_paren_in_cast"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_cast"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the opening parenthesis in a catch
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_opening_paren_in_catch"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_catch"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the opening parenthesis in a constructor declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_constructor_declaration";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the opening parenthesis in a for statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_opening_paren_in_for"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_for"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the opening parenthesis in an if statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_opening_paren_in_if"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_if"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the opening parenthesis in a method declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_opening_paren_in_method_declaration"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_method_declaration"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the opening parenthesis in a method invocation
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_opening_paren_in_method_invocation"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_method_invocation"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the opening parenthesis in a parenthesized expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_parenthesized_expression"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the opening parenthesis in a switch statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_opening_paren_in_switch"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_switch"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the opening parenthesis in a synchronized statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_opening_paren_in_synchronized"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SYNCHRONIZED = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_synchronized"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after the opening parenthesis in a while statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_opening_paren_in_while"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_while"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after a postfix operator
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_postfix_operator"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_postfix_operator"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after a prefix operator
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_prefix_operator"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_prefix_operator"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after question mark in a conditional expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_question_in_conditional"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_question_in_conditional"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after semicolon in a for statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_semicolon_in_for"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_semicolon_in_for"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space after an unary operator
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_after_unary_operator"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR = JavaCore.PLUGIN_ID + ".formatter.insert_space_after_unary_operator"; //$NON-NLS-1$
+       
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before an assignment operator
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_assignment_operator"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_assignment_operator";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before an binary operator
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_binary_operator"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_binary_operator";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the closing brace in an array initializer
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_closing_brace_in_array_initializer"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_closing_brace_in_array_initializer";         //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the closing bracket in an array allocation expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_closing_bracket_in_array_allocation_expression";//$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the closing bracket in an array reference
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_closing_bracket_in_array_reference"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_REFERENCE = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_closing_bracket_in_array_reference";//$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the closing parenthesis in a cast expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_closing_paren_in_cast"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_cast";   //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the closing parenthesis in a catch
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_closing_paren_in_catch"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_catch"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the closing parenthesis in a constructor declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CONSTRUCTOR_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_constructor_declaration";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the closing parenthesis in a for statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_closing_paren_in_for"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_for";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the closing parenthesis in an if statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_closing_paren_in_if"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_if";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the closing parenthesis in a method declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_closing_paren_in_method_declaration"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_method_declaration";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the closing parenthesis in a method invocation
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_closing_paren_in_method_invocation"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_method_invocation"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the closing parenthesis in a parenthesized expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_parenthesized_expression"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the closing parenthesis in a switch statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_closing_paren_in_switch"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_switch";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the closing parenthesis in a synchronized statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_closing_paren_in_synchronized"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SYNCHRONIZED = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_synchronized";   //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the closing parenthesis in a while statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_closing_paren_in_while"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_while"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before colon in an assert statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_colon_in_assert"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_ASSERT = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_colon_in_assert";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before colon in a case statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_colon_in_case"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_colon_in_case";   //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before colon in a conditional expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_colon_in_conditional"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_colon_in_conditional";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before colon in a default statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_colon_in_default"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_colon_in_default";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before colon in a labeled statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_colon_in_labeled_statement"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_colon_in_labeled_statement"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before comma in an allocation expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_comma_in_allocation_expression"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ALLOCATION_EXPRESSION = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_allocation_expression"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before comma in an array initializer
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_comma_in_array_initializer"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ARRAY_INITIALIZER = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_array_initializer"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before comma in the parameters of a constructor declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_constructor_declaration_parameters";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before comma in the exception names of the throws clause of a constructor declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_constructor_declaration_throws";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before comma in the arguments of an explicit constructor call
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_explicitconstructorcall_arguments";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before comma in the increments of a for statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_comma_in_for_increments"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_for_increments";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before comma in the initializations of a for statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_comma_in_for_inits"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_for_inits"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before comma in the arguments of a method invocation
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_method_invocation_arguments";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before comma in the parameters of a method declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_method_declaration_parameters"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before comma in the exception names of the throws clause of a method declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_comma_in_method_declaration_throws"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_method_declaration_throws"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before comma in a multiple field declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_multiple_field_declarations";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before comma in a multiple local declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_multiple_local_declarations";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before comma in the superinterfaces names in a type header
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_comma_in_superinterfaces"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_SUPERINTERFACES = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_comma_in_superinterfaces";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening brace in an anonymous type declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANONYMOUS_TYPE_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_anonymous_type_declaration";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening brace in an array initializer
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_brace_in_array_initializer"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_array_initializer"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening brace in a block
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_brace_in_block"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_block"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening brace in a constructor declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_CONSTRUCTOR_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_constructor_declaration";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening brace in a method declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_brace_in_method_declaration"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_method_declaration";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening brace in a switch statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_brace_in_switch"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_switch";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening brace in a type declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_brace_in_type_declaration"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_type_declaration";   //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening bracket in an array allocation expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_bracket_in_array_allocation_expression";//$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening bracket in an array reference
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_bracket_in_array_reference"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_REFERENCE = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_bracket_in_array_reference";//$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening bracket in an array type reference
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_TYPE_REFERENCE = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_bracket_in_array_type_reference";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening parenthesis in a catch
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_paren_in_catch"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_catch"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening parenthesis in a constructor declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_constructor_declaration";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening parenthesis in a for statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_paren_in_for"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_for";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening parenthesis in an if statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_paren_in_if"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_if";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening parenthesis in a method invocation
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_paren_in_method_invocation"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_method_invocation"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening parenthesis in a method declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_paren_in_method_declaration"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_method_declaration";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening parenthesis in a switch statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_paren_in_switch"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_switch";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening parenthesis in a synchronized statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_paren_in_synchronized"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SYNCHRONIZED = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_synchronized";   //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening parenthesis in a parenthesized expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_parenthesized_expression"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before the opening parenthesis in a while statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_opening_paren_in_while"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_while"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before a postfix operator
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_postfix_operator"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_postfix_operator";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before a prefix operator
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_prefix_operator"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_prefix_operator";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before question mark in a conditional expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_question_in_conditional"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_question_in_conditional";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before semicolon
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_semicolon"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_semicolon";   //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before semicolon in for statement
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_semicolon_in_for"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_semicolon_in_for";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space before unary operator
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_before_unary_operator"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR = JavaCore.PLUGIN_ID + ".formatter.insert_space_before_unary_operator"; //$NON-NLS-1$
+
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space between brackets in an array type reference
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_between_brackets_in_array_type_reference"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BETWEEN_BRACKETS_IN_ARRAY_TYPE_REFERENCE = JavaCore.PLUGIN_ID + ".formatter.insert_space_between_brackets_in_array_type_reference";   //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space between empty braces in an array initializer
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_between_empty_braces_in_array_initializer"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER = JavaCore.PLUGIN_ID + ".formatter.insert_space_between_empty_braces_in_array_initializer"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space between empty brackets in an array allocation expression
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS_IN_ARRAY_ALLOCATION_EXPRESSION = JavaCore.PLUGIN_ID + ".formatter.insert_space_between_empty_brackets_in_array_allocation_expression"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space between empty parenthesis in a constructor declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_CONSTRUCTOR_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.insert_space_between_empty_parens_in_constructor_declaration";     //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space between empty parenthesis in a method declaration
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_between_empty_parens_in_method_declaration"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.insert_space_between_empty_parens_in_method_declaration";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to insert a space between empty parenthesis in a method invocation
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.insert_space_between_empty_parens_in_method_invocation"
+        *     - possible values:   { INSERT, DO_NOT_INSERT }
+        *     - default:           DO_NOT_INSERT
+        * </pre>
+        * @see JavaCore#INSERT
+        * @see JavaCore#DO_NOT_INSERT
+        * @since 3.0
+        */
+       public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION = JavaCore.PLUGIN_ID + ".formatter.insert_space_between_empty_parens_in_method_invocation"; //$NON-NLS-1$
+
+       /**
+        * <pre>
+        * FORMATTER / Option to compact else/if
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.compact_else_if"
+        *     - possible values:   { TRUE, FALSE }
+        *     - default:           TRUE
+        * </pre>
+        * @see #TRUE
+        * @see #FALSE
+        * @since 3.0
+        */
+       public static final String FORMATTER_COMPACT_ELSE_IF = JavaCore.PLUGIN_ID + ".formatter.compact_else_if";       //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to keep guardian clause on one line
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.format_guardian_clause_on_one_line"
+        *     - possible values:   { TRUE, FALSE }
+        *     - default:           FALSE
+        * </pre>
+        * @see #TRUE
+        * @see #FALSE
+        * @since 3.0
+        */
+       public static final String FORMATTER_KEEP_GUARDIAN_CLAUSE_ON_ONE_LINE = JavaCore.PLUGIN_ID + ".formatter.format_guardian_clause_on_one_line";   //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to keep else statement on the same line
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.keep_else_statement_on_same_line"
+        *     - possible values:   { TRUE, FALSE }
+        *     - default:           FALSE
+        * </pre>
+        * @see #TRUE
+        * @see #FALSE
+        * @since 3.0
+        */
+       public static final String FORMATTER_KEEP_ELSE_STATEMENT_ON_SAME_LINE = JavaCore.PLUGIN_ID + ".formatter.keep_else_statement_on_same_line"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to keep empty array initializer one one line
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.keep_empty_array_initializer_on_one_line"
+        *     - possible values:   { TRUE, FALSE }
+        *     - default:           FALSE
+        * </pre>
+        * @see #TRUE
+        * @see #FALSE
+        * @since 3.0
+        */
+       public static final String FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE = JavaCore.PLUGIN_ID + ".formatter.keep_empty_array_initializer_on_one_line"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to keep simple if statement on the one line
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.keep_imple_if_on_one_line"
+        *     - possible values:   { TRUE, FALSE }
+        *     - default:           FALSE
+        * </pre>
+        * @see #TRUE
+        * @see #FALSE
+        * @since 3.0
+        */
+       public static final String FORMATTER_KEEP_SIMPLE_IF_ON_ONE_LINE = JavaCore.PLUGIN_ID + ".formatter.keep_imple_if_on_one_line"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to keep then statement on the same line
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.keep_then_statement_on_same_line"
+        *     - possible values:   { TRUE, FALSE }
+        *     - default:           FALSE
+        * </pre>
+        * @see #TRUE
+        * @see #FALSE
+        * @since 3.0
+        */
+       public static final String FORMATTER_KEEP_THEN_STATEMENT_ON_SAME_LINE = JavaCore.PLUGIN_ID + ".formatter.keep_then_statement_on_same_line";//$NON-NLS-1$
+
+       /**
+        * <pre>
+        * FORMATTER / Option to specify the number of empty lines to preserve
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.number_of_empty_lines_to_preserve"
+        *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
+        *     - default:           "0"
+        * </pre>
+        * @since 3.0
+        */
+       public static final String FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE = JavaCore.PLUGIN_ID + ".formatter.number_of_empty_lines_to_preserve";   //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to specify whether or not empty statement should be on a new line
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.put_empty_statement_on_new_line"
+        *     - possible values:   { TRUE, FALSE }
+        *     - default:           FALSE
+        * </pre>
+        * @see #TRUE
+        * @see #FALSE
+        * @since 3.0
+        */
+       public static final String FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE = JavaCore.PLUGIN_ID + ".formatter.put_empty_statement_on_new_line";       //$NON-NLS-1$
+
+       /**
+        * <pre>
+        * FORMATTER / Option to specify the length of the page. Beyond this length, the formatter will try to split the code
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.lineSplit"
+        *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
+        *     - default:           "80"
+        * </pre>
+        * @since 3.0
+        */
+       public static final String FORMATTER_LINE_SPLIT = JavaCore.PLUGIN_ID + ".formatter.lineSplit"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to specify the tabulation size
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.tabulation.size"
+        *     - possible values:   { TAB, SPACE }
+        *     - default:           TAB
+        * </pre>
+        * @see JavaCore#TAB
+        * @see JavaCore#SPACE
+        * @since 3.0
+        */
+       public static final String FORMATTER_TAB_CHAR = JavaCore.PLUGIN_ID + ".formatter.tabulation.char"; //$NON-NLS-1$
+       /**
+        * <pre>
+        * FORMATTER / Option to specify the tabulation size
+        *     - option id:         "net.sourceforge.phpdt.core.formatter.tabulation.size"
+        *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
+        *     - default:           "4"
+        * </pre>
+        * @since 3.0
+        */
+       public static final String FORMATTER_TAB_SIZE = JavaCore.PLUGIN_ID + ".formatter.tabulation.size"; //$NON-NLS-1$
+
+       /**
+        * Returns the formatter settings that most closely approximate
+        * the default formatter settings of Eclipse version 2.1.
+        * 
+        * @return the Eclipse 2.1 settings
+        * @since 3.0
+        */
+//     public static Map getEclipse21Settings() {
+//             return DefaultCodeFormatterOptions.getDefaultSettings().getMap();
+//     }
+
+       /**
+        * Returns the settings according to the Java conventions.
+        * 
+        * @return the settings according to the Java conventions
+        * @since 3.0
+        */
+//     public static Map getJavaConventionsSettings() {
+//             return DefaultCodeFormatterOptions.getJavaConventionsSettings().getMap();
+//     }
+
+       /**
+        * <p>Return the force value of the given alignment value.
+        * The given alignment value should be created using the <code>createAlignmentValue(boolean, int, int)</code>
+        * API.
+        * </p>
+        *
+        * @param value the given alignment value
+        * @return the force value of the given alignment value
+        * @see #createAlignmentValue(boolean, int, int)
+        * @exception IllegalArgumentException if the given alignment value is null, or if it 
+        * doesn't have a valid format.
+        */
+//     public static boolean getForceWrapping(String value) {
+//             if (value == null) {
+//                     throw WRONG_ARGUMENT;
+//             }
+//             try {
+//                     int existingValue = Integer.parseInt(value);
+//                     return (existingValue & Alignment.M_FORCE) != 0;
+//             } catch (NumberFormatException e) {
+//                     throw WRONG_ARGUMENT;
+//             }
+//     }
+       
+       /**
+        * <p>Return the indentation style of the given alignment value.
+        * The given alignment value should be created using the <code>createAlignmentValue(boolean, int, int)</code>
+        * API.
+        * </p>
+        *
+        * @param value the given alignment value
+        * @return the indentation style of the given alignment value
+        * @see #createAlignmentValue(boolean, int, int)
+        * @exception IllegalArgumentException if the given alignment value is null, or if it 
+        * doesn't have a valid format.
+        */
+       public static int getIndentStyle(String value) {
+               if (value == null) {
+                       throw WRONG_ARGUMENT;
+               }
+               try {
+                       int existingValue = Integer.parseInt(value);
+//                     if ((existingValue & Alignment.M_INDENT_BY_ONE) != 0) {
+//                             return INDENT_BY_ONE;
+//                     } else if ((existingValue & Alignment.M_INDENT_ON_COLUMN) != 0) {
+//                             return INDENT_ON_COLUMN;
+//                     } else {
+                               return INDENT_DEFAULT;
+//                     }
+               } catch (NumberFormatException e) {
+                       throw WRONG_ARGUMENT;
+               }
+       }
+       /**
+        * <p>Return the wrapping style of the given alignment value.
+        * The given alignment value should be created using the <code>createAlignmentValue(boolean, int, int)</code>
+        * API.
+        * </p>
+        *
+        * @param value the given alignment value
+        * @return the wrapping style of the given alignment value
+        * @see #createAlignmentValue(boolean, int, int)
+        * @exception IllegalArgumentException if the given alignment value is null, or if it 
+        * doesn't have a valid format.
+        */
+//     public static int getWrappingStyle(String value) {
+//             if (value == null) {
+//                     throw WRONG_ARGUMENT;
+//             }
+//             try {
+//                     int existingValue = Integer.parseInt(value) & Alignment.SPLIT_MASK;
+//                     switch(existingValue) {
+//                             case Alignment.M_COMPACT_SPLIT :
+//                                     return WRAP_COMPACT;
+//                             case Alignment.M_COMPACT_FIRST_BREAK_SPLIT :
+//                                     return WRAP_COMPACT_FIRST_BREAK;
+//                             case Alignment.M_NEXT_PER_LINE_SPLIT :
+//                                     return WRAP_NEXT_PER_LINE;
+//                             case Alignment.M_NEXT_SHIFTED_SPLIT :
+//                                     return WRAP_NEXT_SHIFTED;
+//                             case Alignment.M_ONE_PER_LINE_SPLIT :
+//                                     return WRAP_ONE_PER_LINE;
+//                             default:
+//                                     return WRAP_NO_SPLIT;
+//                     }
+//             } catch (NumberFormatException e) {
+//                     throw WRONG_ARGUMENT;
+//             }
+//     }
+       
+       /**
+        * <p>Set the indentation style of the given alignment value and return the new value.
+        * The given value should be created using the <code>createAlignmentValue(boolean, int, int)</code>
+        * API.
+        * </p>
+        *
+        * @param value the given alignment value
+        * @param indentStyle the given indentation style
+        * @return the new alignment value
+        * @see #INDENT_BY_ONE
+        * @see #INDENT_DEFAULT
+        * @see #INDENT_ON_COLUMN
+        * @see #createAlignmentValue(boolean, int, int)
+        * @exception IllegalArgumentException if the given alignment value is null, if the given
+        * indentation style is not one of the possible indentation styles, or if the given
+        * alignment value doesn't have a valid format.
+        */
+//     public static String setIndentStyle(String value, int indentStyle) {
+//             if (value == null) {
+//                     throw WRONG_ARGUMENT;
+//             }
+//             switch(indentStyle) {
+//                     case INDENT_BY_ONE :
+//                     case INDENT_DEFAULT :
+//                     case INDENT_ON_COLUMN :
+//                             break;
+//                     default :
+//                             throw WRONG_ARGUMENT;
+//             }
+//             try {
+//                     int existingValue = Integer.parseInt(value);
+//                     // clear existing indent bits
+//                     existingValue &= ~(Alignment.M_INDENT_BY_ONE | Alignment.M_INDENT_ON_COLUMN);
+//                     switch(indentStyle) {
+//                             case INDENT_BY_ONE :
+//                                     existingValue |= Alignment.M_INDENT_BY_ONE;
+//                                     break;
+//                             case INDENT_ON_COLUMN :
+//                                     existingValue |= Alignment.M_INDENT_ON_COLUMN;
+//                     }
+//                     return String.valueOf(existingValue);
+//             } catch (NumberFormatException e) {
+//                     throw WRONG_ARGUMENT;
+//             }
+//     }
+       /**
+        * <p>Set the force value of the given alignment value and return the new value.
+        * The given alignment value should be created using the <code>createAlignmentValue(boolean, int, int)</code>
+        * API.
+        * </p>
+        *
+        * @param value the given alignment value
+        * @param force the given force value
+        * @return the new alignment value
+        * @see #createAlignmentValue(boolean, int, int)
+        * @exception IllegalArgumentException if the given alignment value is null, or if it 
+        * doesn't have a valid format.
+        */
+//     public static String setForceWrapping(String value, boolean force) {
+//             if (value == null) {
+//                     throw WRONG_ARGUMENT;
+//             }
+//             try {
+//                     int existingValue = Integer.parseInt(value);
+//                     // clear existing force bit
+//                     existingValue &= ~Alignment.M_FORCE;
+//                     if (force) {
+//                             existingValue |= Alignment.M_FORCE;
+//                     }
+//                     return String.valueOf(existingValue);
+//             } catch (NumberFormatException e) {
+//                     throw WRONG_ARGUMENT;
+//             }               
+//     }
+       /**
+        * <p>Set the wrapping style of the given alignment value and return the new value.
+        * The given value should be created using the <code>createAlignmentValue(boolean, int, int)</code>
+        * API.
+        * </p>
+        *
+        * @param value the given alignment value
+        * @param wrappingStyle the given wrapping style
+        * @return the new alignment value
+        * @see #WRAP_COMPACT
+        * @see #WRAP_COMPACT_FIRST_BREAK
+        * @see #WRAP_NEXT_PER_LINE
+        * @see #WRAP_NEXT_SHIFTED
+        * @see #WRAP_NO_SPLIT
+        * @see #WRAP_ONE_PER_LINE
+        * @see #createAlignmentValue(boolean, int, int)
+        * @exception IllegalArgumentException if the given alignment value is null, if the given
+        * wrapping style is not one of the possible wrapping styles, or if the given
+        * alignment value doesn't have a valid format.
+        */
+//     public static String setWrappingStyle(String value, int wrappingStyle) {
+//             if (value == null) {
+//                     throw WRONG_ARGUMENT;
+//             }
+//             switch(wrappingStyle) {
+//                     case WRAP_COMPACT :
+//                     case WRAP_COMPACT_FIRST_BREAK :
+//                     case WRAP_NEXT_PER_LINE :
+//                     case WRAP_NEXT_SHIFTED :
+//                     case WRAP_NO_SPLIT :
+//                     case WRAP_ONE_PER_LINE :
+//                             break;
+//                     default:
+//                             throw WRONG_ARGUMENT;
+//             }
+//             try {
+//                     int existingValue = Integer.parseInt(value);
+//                     // clear existing split bits
+//                     existingValue &= ~(Alignment.SPLIT_MASK);
+//                     switch(wrappingStyle) {
+//                             case WRAP_COMPACT :
+//                                     existingValue |= Alignment.M_COMPACT_SPLIT;
+//                                     break;
+//                             case WRAP_COMPACT_FIRST_BREAK :
+//                                     existingValue |= Alignment.M_COMPACT_FIRST_BREAK_SPLIT;
+//                                     break;
+//                             case WRAP_NEXT_PER_LINE :
+//                                     existingValue |= Alignment.M_NEXT_PER_LINE_SPLIT;
+//                                     break;
+//                             case WRAP_NEXT_SHIFTED :
+//                                     existingValue |= Alignment.M_NEXT_SHIFTED_SPLIT;
+//                                     break;
+//                             case WRAP_ONE_PER_LINE :
+//                                     existingValue |= Alignment.M_ONE_PER_LINE_SPLIT;
+//                                     break;
+//                     }
+//                     return String.valueOf(existingValue);
+//             } catch (NumberFormatException e) {
+//                     throw WRONG_ARGUMENT;
+//             }
+//     }
+       /**
+        * Create a new alignment value according to the given values. This must be used to set up
+        * the alignment options.
+        * 
+        * @param forceSplit the given force value
+        * @param wrapStyle the given wrapping style
+        * @param indentStyle the given indent style
+        * 
+        * @return the new alignement value
+        */
+//     public static String createAlignmentValue(boolean forceSplit, int wrapStyle, int indentStyle) {
+//             int alignmentValue = 0; 
+//             switch(wrapStyle) {
+//                     case WRAP_COMPACT :
+//                             alignmentValue |= Alignment.M_COMPACT_SPLIT;
+//                             break;
+//                     case WRAP_COMPACT_FIRST_BREAK :
+//                             alignmentValue |= Alignment.M_COMPACT_FIRST_BREAK_SPLIT;
+//                             break;
+//                     case WRAP_NEXT_PER_LINE :
+//                             alignmentValue |= Alignment.M_NEXT_PER_LINE_SPLIT;
+//                             break;
+//                     case WRAP_NEXT_SHIFTED :
+//                             alignmentValue |= Alignment.M_NEXT_SHIFTED_SPLIT;
+//                             break;
+//                     case WRAP_ONE_PER_LINE :
+//                             alignmentValue |= Alignment.M_ONE_PER_LINE_SPLIT;
+//                             break;
+//             }               
+//             if (forceSplit) {
+//                     alignmentValue |= Alignment.M_FORCE;
+//             }
+//             switch(indentStyle) {
+//                     case INDENT_BY_ONE :
+//                             alignmentValue |= Alignment.M_INDENT_BY_ONE;
+//                             break;
+//                     case INDENT_ON_COLUMN :
+//                             alignmentValue |= Alignment.M_INDENT_ON_COLUMN;
+//             }
+//             return String.valueOf(alignmentValue);
+//     }
+}
index 30cebda..2ce6d3e 100644 (file)
@@ -44,578 +44,557 @@ import org.eclipse.swt.widgets.Shell;
  */
 public class JavaContext extends CompilationUnitContext {
 
-       /** The platform default line delimiter. */
-       private static final String PLATFORM_LINE_DELIMITER= System.getProperty("line.separator"); //$NON-NLS-1$
-
-       /** A code completion requestor for guessing local variable names. */
-       private CompilationUnitCompletion fCompletion;
-       
-       /**
-        * Creates a java template context.
-        * 
-        * @param type   the context type.
-        * @param document the document.
-        * @param completionOffset the completion offset within the document.
-        * @param completionLength the completion length.
-        * @param compilationUnit the compilation unit (may be <code>null</code>).
-        */
-       public JavaContext(TemplateContextType type, IDocument document, int completionOffset, int completionLength,
-               ICompilationUnit compilationUnit)
-       {
-               super(type, document, completionOffset, completionLength, compilationUnit);
-       }
-       
-       /**
-        * Returns the indentation level at the position of code completion.
-        */
-       private int getIndentation() {
-               int start= getStart();
-               IDocument document= getDocument();
-               try {
-                       IRegion region= document.getLineInformationOfOffset(start);
-                       String lineContent= document.get(region.getOffset(), region.getLength());
-                   return Strings.computeIndent(lineContent, CodeFormatterPreferencePage.getTabSize());
-//                     return Strings.computeIndent(lineContent, CodeFormatterUtil.getTabWidth());
-               } catch (BadLocationException e) {
-                       return 0;
-               }
-       }       
-       
-       
-
-       /*
-        * @see TemplateContext#evaluate(Template template)
-        */
-       public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
-
-               if (!canEvaluate(template))
-                       throw new TemplateException(JavaTemplateMessages.getString("Context.error.cannot.evaluate")); //$NON-NLS-1$
-               
-               TemplateTranslator translator= new TemplateTranslator() {
-                       /*
-                        * @see org.eclipse.jface.text.templates.TemplateTranslator#createVariable(java.lang.String, java.lang.String, int[])
-                        */
-                       protected TemplateVariable createVariable(String type, String name, int[] offsets) {
-                               return new MultiVariable(type, name, offsets);
-                       }
-               };
-               TemplateBuffer buffer= translator.translate(template);
-
-               getContextType().resolve(buffer, this);
-                       
-               String lineDelimiter= null;
-               try {
-                       lineDelimiter= getDocument().getLineDelimiter(0);
-               } catch (BadLocationException e) {
-               }
-
-               if (lineDelimiter == null)
-                       lineDelimiter= PLATFORM_LINE_DELIMITER;
-                       
-               IPreferenceStore prefs= PHPeclipsePlugin.getDefault().getPreferenceStore();
-               boolean useCodeFormatter= prefs.getBoolean(PreferenceConstants.TEMPLATES_USE_CODEFORMATTER);                    
-               
-//             JavaFormatter formatter= new JavaFormatter(lineDelimiter, getIndentation(), useCodeFormatter);
-//             formatter.format(buffer, this);
-               
-               return buffer;
-       }
-       
-       /*
-        * @see TemplateContext#canEvaluate(Template templates)
-        */
-       public boolean canEvaluate(Template template) {
-               String key= getKey();
-
-               if (fForceEvaluation)
-                       return true;
-
-               return
-                       template.matches(key, getContextType().getId()) &&
-                       key.length() != 0 && template.getName().toLowerCase().startsWith(key.toLowerCase());
-       }
-
-       public boolean canEvaluate(String identifier) {
-           String prefix = getKey();
-           return
-             identifier.toLowerCase().startsWith(prefix.toLowerCase());
-         }
-       /*
-        * @see DocumentTemplateContext#getCompletionPosition();
-        */
-       public int getStart() {
-
-               try {
-                       IDocument document= getDocument();
-
-                       if (getCompletionLength() == 0) {
-
-                               int start= getCompletionOffset();               
-                               while ((start != 0) && Character.isUnicodeIdentifierPart(document.getChar(start - 1)))
-                                       start--;
-                                       
-                               if ((start != 0) && Character.isUnicodeIdentifierStart(document.getChar(start - 1)))
-                                       start--;
-               
-                               return start;
-                       
-                       } else {
-
-                               int start= getCompletionOffset();
-                               int end= getCompletionOffset() + getCompletionLength();
-                               
-                               while (start != 0 && Character.isUnicodeIdentifierPart(document.getChar(start - 1)))
-                                       start--;
-                               
-                               while (start != end && Character.isWhitespace(document.getChar(start)))
-                                       start++;
-                               
-                               if (start == end)
-                                       start= getCompletionOffset();   
-                               
-                               return start;   
-                       }
-
-               } catch (BadLocationException e) {
-                       return super.getStart();        
-               }
-       }
-
-       /*
-        * @see net.sourceforge.phpdt.internal.corext.template.DocumentTemplateContext#getEnd()
-        */
-       public int getEnd() {
-               
-               if (getCompletionLength() == 0)
-                       return super.getEnd();
-
-               try {                   
-                       IDocument document= getDocument();
-
-                       int start= getCompletionOffset();
-                       int end= getCompletionOffset() + getCompletionLength();
-                       
-                       while (start != end && Character.isWhitespace(document.getChar(end - 1)))
-                               end--;
-                       
-                       return end;     
-
-               } catch (BadLocationException e) {
-                       return super.getEnd();
-               }               
-       }
-
-       /*
-        * @see net.sourceforge.phpdt.internal.corext.template.DocumentTemplateContext#getKey()
-        */
-       public String getKey() {
-
-               if (getCompletionLength() == 0)         
-                       return super.getKey();
-
-               try {
-                       IDocument document= getDocument();
-
-                       int start= getStart();
-                       int end= getCompletionOffset();
-                       return start <= end
-                               ? document.get(start, end - start)
-                               : ""; //$NON-NLS-1$
-                       
-               } catch (BadLocationException e) {
-                       return super.getKey();                  
-               }
-       }
-
-       /**
-        * Returns the character before start position of completion.
-        */
-       public char getCharacterBeforeStart() {
-               int start= getStart();
-               
-               try {
-                       return start == 0
-                               ? ' '
-                               : getDocument().getChar(start - 1);
-
-               } catch (BadLocationException e) {
-                       return ' ';
-               }
-       }
-
-       private static void handleException(Shell shell, Exception e) {
-               String title= JavaTemplateMessages.getString("JavaContext.error.title"); //$NON-NLS-1$
-               if (e instanceof CoreException)
-                       ExceptionHandler.handle((CoreException)e, shell, title, null);
-               else if (e instanceof InvocationTargetException)
-                       ExceptionHandler.handle((InvocationTargetException)e, shell, title, null);
-               else {
-                       PHPeclipsePlugin.log(e);
-                       MessageDialog.openError(shell, title, e.getMessage());
-               }
-       }       
-
-//     private CompilationUnitCompletion getCompletion() {
-//             ICompilationUnit compilationUnit= getCompilationUnit();
-//             if (fCompletion == null) {
-//                     fCompletion= new CompilationUnitCompletion(compilationUnit);
-//                     
-//                     if (compilationUnit != null) {
-//                             try {
-//                                     compilationUnit.codeComplete(getStart(), fCompletion);
-//                             } catch (JavaModelException e) {
-//                                     // ignore
-//                             }
-//                     }
-//             }
-//             
-//             return fCompletion;
-//     }
-
-       /**
-        * Returns the name of a guessed local array, <code>null</code> if no local
-        * array exists.
-        */
-//     public String guessArray() {
-//             return firstOrNull(guessArrays());
-//     }
-       
-       /**
-        * Returns the name of a guessed local array, <code>null</code> if no local
-        * array exists.
-        */
-//     public String[] guessArrays() {
-//             CompilationUnitCompletion completion= getCompletion();
-//             LocalVariable[] localArrays= completion.findLocalArrays();
-//                             
-//             String[] ret= new String[localArrays.length];
-//             for (int i= 0; i < ret.length; i++) {
-//                     ret[ret.length - i - 1]= localArrays[i].name;
-//             }
-//             return ret;
-//     }
-       
-       /**
-        * Returns the name of the type of a local array, <code>null</code> if no local
-        * array exists.
-        */
-//     public String guessArrayType() {
-//             return firstOrNull(guessArrayTypes());
-//     }
-       
-       private String firstOrNull(String[] strings) {
-               if (strings.length > 0)
-                       return strings[0];
-               else
-                       return null;
-       }
-       
-       /**
-        * Returns the name of the type of a local array, <code>null</code> if no local
-        * array exists.
-        */
-//     public String[][] guessGroupedArrayTypes() {
-//             CompilationUnitCompletion completion= getCompletion();
-//             LocalVariable[] localArrays= completion.findLocalArrays();
-//             
-//             String[][] ret= new String[localArrays.length][];
-//             
-//             for (int i= 0; i < localArrays.length; i++) {
-//                     String type= getArrayTypeFromLocalArray(completion, localArrays[localArrays.length - i - 1]);
-//                     ret[i]= new String[] {type};
-//             }
-//             
-//             return ret;
-//     }
-       
-       /**
-        * Returns the name of the type of a local array, <code>null</code> if no local
-        * array exists.
-        */
-//     public String[] guessArrayTypes() {
-//             CompilationUnitCompletion completion= getCompletion();
-//             LocalVariable[] localArrays= completion.findLocalArrays();
-//             
-//             List ret= new ArrayList();
-//             
-//             for (int i= 0; i < localArrays.length; i++) {
-//                     String type= getArrayTypeFromLocalArray(completion, localArrays[localArrays.length - i - 1]);
-//                     if (!ret.contains(type))
-//                             ret.add(type);
-//             }
-//             
-//             return (String[]) ret.toArray(new String[ret.size()]);
-//     }
-       
-       private String getArrayTypeFromLocalArray(CompilationUnitCompletion completion, LocalVariable array) {
-                       String arrayTypeName= array.typeName;
-                       String typeName= getScalarType(arrayTypeName);
-                       int dimension= getArrayDimension(arrayTypeName) - 1;
-                       Assert.isTrue(dimension >= 0);
-                       
-                       String qualifiedName= createQualifiedTypeName(array.typePackageName, typeName);
-                       String innerTypeName= completion.simplifyTypeName(qualifiedName);
-                       
-                       return innerTypeName == null
-                               ? createArray(typeName, dimension)
-                               : createArray(innerTypeName, dimension);
-       }
-       
-       private static String createArray(String type, int dimension) {
-               StringBuffer buffer= new StringBuffer(type);
-               for (int i= 0; i < dimension; i++)
-                       buffer.append("[]"); //$NON-NLS-1$
-               return buffer.toString();
-       }
-
-       private static String getScalarType(String type) {
-               return type.substring(0, type.indexOf('['));
-       }
-       
-       private static int getArrayDimension(String type) {
-
-               int dimension= 0;               
-               int index= type.indexOf('[');
-
-               while (index != -1) {
-                       dimension++;
-                       index= type.indexOf('[', index + 1);    
-               }
-               
-               return dimension;               
-       }
-
-       private static String createQualifiedTypeName(String packageName, String className) {
-               StringBuffer buffer= new StringBuffer();
-
-               if (packageName.length() != 0) {
-                       buffer.append(packageName);
-                       buffer.append('.');
-               }
-               buffer.append(className);
-               
-               return buffer.toString();
-       }
-       
-       /**
-        * Returns a proposal for a variable name of a local array element, <code>null</code>
-        * if no local array exists.
-        */
-//     public String guessArrayElement() {
-//             return firstOrNull(guessArrayElements());
-//     }
-       /**
-        * Returns a proposal for a variable name of a local array element, <code>null</code>
-        * if no local array exists.
-        */
-//     public String[] guessArrayElements() {
-//             ICompilationUnit cu= getCompilationUnit();
-//             if (cu == null) {
-//                     return new String[0];
-//             }
-//             
-//             CompilationUnitCompletion completion= getCompletion();
-//             LocalVariable[] localArrays= completion.findLocalArrays();
-//             
-//             List ret= new ArrayList();
-//             
-//             for (int i= 0; i < localArrays.length; i++) {
-//                     int idx= localArrays.length - i - 1;
-//                     
-//                     LocalVariable var= localArrays[idx];
-//                     
-//                     IJavaProject project= cu.getJavaProject();
-//                     String typeName= var.typeName;
-//                     String baseTypeName= typeName.substring(0, typeName.lastIndexOf('['));
-//
-//                     String indexName= getIndex();
-//                     String[] excludedNames= completion.getLocalVariableNames();
-//                     if (indexName != null) {
-//                             ArrayList excludedNamesList= new ArrayList(Arrays.asList(excludedNames));
-//                             excludedNamesList.add(indexName);
-//                             excludedNames= (String[])excludedNamesList.toArray(new String[excludedNamesList.size()]);
-//                     }
-//                     String[] proposals= NamingConventions.suggestLocalVariableNames(project, var.typePackageName, baseTypeName, 0, excludedNames);
-//                     for (int j= 0; j < proposals.length; j++) {
-//                             if (!ret.contains(proposals[j]))
-//                                     ret.add(proposals[j]);
-//                     }
-//             }
-//             
-//             return (String[]) ret.toArray(new String[ret.size()]);
-//     }
-
-       /**
-        * Returns a proposal for a variable name of a local array element, <code>null</code>
-        * if no local array exists.
-        */
-//     public String[][] guessGroupedArrayElements() {
-//             ICompilationUnit cu= getCompilationUnit();
-//             if (cu == null) {
-//                     return new String[0][];
-//             }
-//             
-//             CompilationUnitCompletion completion= getCompletion();
-//             LocalVariable[] localArrays= completion.findLocalArrays();
-//             
-//             String[][] ret= new String[localArrays.length][];
-//             
-//             for (int i= 0; i < localArrays.length; i++) {
-//                     int idx= localArrays.length - i - 1;
-//                     
-//                     LocalVariable var= localArrays[idx];
-//                     
-//                     IJavaProject project= cu.getJavaProject();
-//                     String typeName= var.typeName;
-//                     int dim= -1; // we expect at least one array
-//                     int lastIndex= typeName.length();
-//                     int bracket= typeName.lastIndexOf('[');
-//                     while (bracket != -1) {
-//                             lastIndex= bracket;
-//                             dim++;
-//                             bracket= typeName.lastIndexOf('[', bracket - 1);
-//                     }
-//                     typeName= typeName.substring(0, lastIndex);
-//                     
-//                     String indexName= getIndex();
-//                     String[] excludedNames= completion.getLocalVariableNames();
-//                     if (indexName != null) {
-//                             ArrayList excludedNamesList= new ArrayList(Arrays.asList(excludedNames));
-//                             excludedNamesList.add(indexName);
-//                             excludedNames= (String[])excludedNamesList.toArray(new String[excludedNamesList.size()]);
-//                     }
-//                     String[] proposals= NamingConventions.suggestLocalVariableNames(project, var.typePackageName, typeName, dim, excludedNames);
-//                     
-//                     ret[i]= proposals;
-//             }
-//             
-//             return ret;
-//     }
-
-       /**
-        * Returns an array index name. 'i', 'j', 'k' are tried until no name collision with
-        * an existing local variable occurs. If all names collide, <code>null</code> is returned.
-        */     
-//     public String getIndex() {
-//             CompilationUnitCompletion completion= getCompletion();
-//             String[] proposals= {"i", "j", "k"};  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-//             
-//             for (int i= 0; i != proposals.length; i++) {
-//                     String proposal = proposals[i];
-//
-//                     if (!completion.existsLocalName(proposal))
-//                             return proposal;
-//             }
-//
-//             return null;
-//     }
-       
-       /**
-        * Returns the name of a local collection, <code>null</code> if no local collection
-        * exists.
-        */
-//     public String guessCollection() {
-//             return firstOrNull(guessCollections());
-//     }
-       
-       /**
-        * Returns the names of local collections.
-        */
-//     public String[] guessCollections() {
-//             CompilationUnitCompletion completion= getCompletion();
-//             try {
-//                     LocalVariable[] localCollections= completion.findLocalCollections();
-//                     String[] ret= new String[localCollections.length];
-//                     for (int i= 0; i < ret.length; i++) {
-//                             ret[ret.length - i - 1]= localCollections[i].name;
-//                     }
-//                     
-//                     return ret;
-//
-//             } catch (JavaModelException e) {
-//                     JavaPlugin.log(e);
-//             }
-//
-//             return new String[0];
-//     }
-       
-
-       /**
-        * Returns an iterator name ('iter'). If 'iter' already exists as local variable,
-        * <code>null</code> is returned.
-        */
-//     public String getIterator() {
-//             CompilationUnitCompletion completion= getCompletion();          
-//             String[] proposals= {"iter"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-//             
-//             for (int i= 0; i != proposals.length; i++) {
-//                     String proposal = proposals[i];
-//
-//                     if (!completion.existsLocalName(proposal))
-//                             return proposal;
-//             }
-//
-//             return null;
-//     }
-
-
-//     public void addIteratorImport() {
-//             ICompilationUnit cu= getCompilationUnit();
-//             if (cu == null) {
-//                     return;
-//             }
-//     
-//             try {
-//                     Position position= new Position(getCompletionOffset(), getCompletionLength());
-//                     IDocument document= getDocument();
-//                     final String category= "__template_position_importer" + System.currentTimeMillis(); //$NON-NLS-1$
-//                     IPositionUpdater updater= new DefaultPositionUpdater(category);
-//                     document.addPositionCategory(category);
-//                     document.addPositionUpdater(updater);
-//                     document.addPosition(position);
-//
-//                     CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings();
-//                     ImportsStructure structure= new ImportsStructure(cu, settings.importOrder, settings.importThreshold, true);
-//                     structure.addImport("java.util.Iterator"); //$NON-NLS-1$
-//                     structure.create(false, null);
-//
-//                     document.removePosition(position);
-//                     document.removePositionUpdater(updater);
-//                     document.removePositionCategory(category);
-//                     
-//                     setCompletionOffset(position.getOffset());
-//                     setCompletionLength(position.getLength());
-//                     
-//             } catch (CoreException e) {
-//                     handleException(null, e);
-//             } catch (BadLocationException e) {
-//                     handleException(null, e);
-//             } catch (BadPositionCategoryException e) {
-//                     handleException(null, e);
-//             }
-//     }
-       
-       /**
-        * Evaluates a 'java' template in thecontext of a compilation unit
-        */
-       public static String evaluateTemplate(Template template, ICompilationUnit compilationUnit, int position) throws CoreException, BadLocationException, TemplateException {
-
-               TemplateContextType contextType= PHPeclipsePlugin.getDefault().getTemplateContextRegistry().getContextType("java"); //$NON-NLS-1$
-               if (contextType == null)
-                       throw new CoreException(new Status(IStatus.ERROR, PHPeclipsePlugin.PLUGIN_ID, IStatus.ERROR, JavaTemplateMessages.getString("JavaContext.error.message"), null)); //$NON-NLS-1$
-
-               IDocument document= new Document();
-               if (compilationUnit != null && compilationUnit.exists())
-                       document.set(compilationUnit.getSource());
-
-               JavaContext context= new JavaContext(contextType, document, position, 0, compilationUnit);
-               context.setForceEvaluation(true);
-
-               TemplateBuffer buffer= context.evaluate(template);
-               if (buffer == null)
-                       return null;
-               return buffer.getString();
-       }
+  /** The platform default line delimiter. */
+  private static final String PLATFORM_LINE_DELIMITER = System.getProperty("line.separator"); //$NON-NLS-1$
+
+  /** A code completion requestor for guessing local variable names. */
+  private CompilationUnitCompletion fCompletion;
+
+  /**
+   * Creates a java template context.
+   * 
+   * @param type
+   *          the context type.
+   * @param document
+   *          the document.
+   * @param completionOffset
+   *          the completion offset within the document.
+   * @param completionLength
+   *          the completion length.
+   * @param compilationUnit
+   *          the compilation unit (may be <code>null</code>).
+   */
+  public JavaContext(TemplateContextType type, IDocument document, int completionOffset, int completionLength,
+      ICompilationUnit compilationUnit) {
+    super(type, document, completionOffset, completionLength, compilationUnit);
+  }
+
+  /**
+   * Returns the indentation level at the position of code completion.
+   */
+  private int getIndentation() {
+    int start = getStart();
+    IDocument document = getDocument();
+    try {
+      IRegion region = document.getLineInformationOfOffset(start);
+      String lineContent = document.get(region.getOffset(), region.getLength());
+      return Strings.computeIndent(lineContent, CodeFormatterPreferencePage.getTabSize());
+      //                       return Strings.computeIndent(lineContent, CodeFormatterUtil.getTabWidth());
+    } catch (BadLocationException e) {
+      return 0;
+    }
+  }
+
+  /*
+   * @see TemplateContext#evaluate(Template template)
+   */
+  public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
+
+    if (!canEvaluate(template))
+      throw new TemplateException(JavaTemplateMessages.getString("Context.error.cannot.evaluate")); //$NON-NLS-1$
+
+    TemplateTranslator translator = new TemplateTranslator() {
+      /*
+       * @see org.eclipse.jface.text.templates.TemplateTranslator#createVariable(java.lang.String, java.lang.String, int[])
+       */
+      protected TemplateVariable createVariable(String type, String name, int[] offsets) {
+        return new MultiVariable(type, name, offsets);
+      }
+    };
+    TemplateBuffer buffer = translator.translate(template);
+
+    getContextType().resolve(buffer, this);
+    String lineDelimiter = null;
+    try {
+      lineDelimiter = getDocument().getLineDelimiter(0);
+    } catch (BadLocationException e) {
+    }
+
+    if (lineDelimiter == null)
+      lineDelimiter = PLATFORM_LINE_DELIMITER;
+    IPreferenceStore prefs = PHPeclipsePlugin.getDefault().getPreferenceStore();
+    // axelcl start
+    // boolean useCodeFormatter = prefs.getBoolean(PreferenceConstants.TEMPLATES_USE_CODEFORMATTER);
+    boolean useCodeFormatter = false;
+    // axelcl end
+
+    JavaFormatter formatter = new JavaFormatter(lineDelimiter, getIndentation(), useCodeFormatter);
+    formatter.format(buffer, this);
+    //  debug start
+    //        String res = buffer.getString();
+    //        res = res.replaceAll("\n","/n");
+    //        res = res.replaceAll("\t","/t");
+    //        System.out.println(res);
+    // debug end
+    return buffer;
+  }
+
+  /*
+   * @see TemplateContext#canEvaluate(Template templates)
+   */
+  public boolean canEvaluate(Template template) {
+    String key = getKey();
+
+    if (fForceEvaluation)
+      return true;
+
+    return template.matches(key, getContextType().getId()) && key.length() != 0
+        && template.getName().toLowerCase().startsWith(key.toLowerCase());
+  }
+
+  public boolean canEvaluate(String identifier) {
+    String prefix = getKey();
+    return identifier.toLowerCase().startsWith(prefix.toLowerCase());
+  }
+
+  /*
+   * @see DocumentTemplateContext#getCompletionPosition();
+   */
+  public int getStart() {
+
+    try {
+      IDocument document = getDocument();
+
+      if (getCompletionLength() == 0) {
+
+        int start = getCompletionOffset();
+        while ((start != 0) && Character.isUnicodeIdentifierPart(document.getChar(start - 1)))
+          start--;
+
+        if ((start != 0) && Character.isUnicodeIdentifierStart(document.getChar(start - 1)))
+          start--;
+
+        return start;
+
+      } else {
+
+        int start = getCompletionOffset();
+        int end = getCompletionOffset() + getCompletionLength();
+
+        while (start != 0 && Character.isUnicodeIdentifierPart(document.getChar(start - 1)))
+          start--;
+
+        while (start != end && Character.isWhitespace(document.getChar(start)))
+          start++;
+
+        if (start == end)
+          start = getCompletionOffset();
+
+        return start;
+      }
+
+    } catch (BadLocationException e) {
+      return super.getStart();
+    }
+  }
+
+  /*
+   * @see net.sourceforge.phpdt.internal.corext.template.DocumentTemplateContext#getEnd()
+   */
+  public int getEnd() {
+
+    if (getCompletionLength() == 0)
+      return super.getEnd();
+
+    try {
+      IDocument document = getDocument();
+
+      int start = getCompletionOffset();
+      int end = getCompletionOffset() + getCompletionLength();
+
+      while (start != end && Character.isWhitespace(document.getChar(end - 1)))
+        end--;
+
+      return end;
+
+    } catch (BadLocationException e) {
+      return super.getEnd();
+    }
+  }
+
+  /*
+   * @see net.sourceforge.phpdt.internal.corext.template.DocumentTemplateContext#getKey()
+   */
+  public String getKey() {
+
+    if (getCompletionLength() == 0)
+      return super.getKey();
+
+    try {
+      IDocument document = getDocument();
+
+      int start = getStart();
+      int end = getCompletionOffset();
+      return start <= end ? document.get(start, end - start) : ""; //$NON-NLS-1$
+
+    } catch (BadLocationException e) {
+      return super.getKey();
+    }
+  }
+
+  /**
+   * Returns the character before start position of completion.
+   */
+  public char getCharacterBeforeStart() {
+    int start = getStart();
+
+    try {
+      return start == 0 ? ' ' : getDocument().getChar(start - 1);
+
+    } catch (BadLocationException e) {
+      return ' ';
+    }
+  }
+
+  private static void handleException(Shell shell, Exception e) {
+    String title = JavaTemplateMessages.getString("JavaContext.error.title"); //$NON-NLS-1$
+    if (e instanceof CoreException)
+      ExceptionHandler.handle((CoreException) e, shell, title, null);
+    else if (e instanceof InvocationTargetException)
+      ExceptionHandler.handle((InvocationTargetException) e, shell, title, null);
+    else {
+      PHPeclipsePlugin.log(e);
+      MessageDialog.openError(shell, title, e.getMessage());
+    }
+  }
+
+  //   private CompilationUnitCompletion getCompletion() {
+  //           ICompilationUnit compilationUnit= getCompilationUnit();
+  //           if (fCompletion == null) {
+  //                   fCompletion= new CompilationUnitCompletion(compilationUnit);
+  //                   
+  //                   if (compilationUnit != null) {
+  //                           try {
+  //                                   compilationUnit.codeComplete(getStart(), fCompletion);
+  //                           } catch (JavaModelException e) {
+  //                                   // ignore
+  //                           }
+  //                   }
+  //           }
+  //           
+  //           return fCompletion;
+  //   }
+
+  /**
+   * Returns the name of a guessed local array, <code>null</code> if no local array exists.
+   */
+  //   public String guessArray() {
+  //           return firstOrNull(guessArrays());
+  //   }
+  /**
+   * Returns the name of a guessed local array, <code>null</code> if no local array exists.
+   */
+  //   public String[] guessArrays() {
+  //           CompilationUnitCompletion completion= getCompletion();
+  //           LocalVariable[] localArrays= completion.findLocalArrays();
+  //                           
+  //           String[] ret= new String[localArrays.length];
+  //           for (int i= 0; i < ret.length; i++) {
+  //                   ret[ret.length - i - 1]= localArrays[i].name;
+  //           }
+  //           return ret;
+  //   }
+  /**
+   * Returns the name of the type of a local array, <code>null</code> if no local array exists.
+   */
+  //   public String guessArrayType() {
+  //           return firstOrNull(guessArrayTypes());
+  //   }
+  private String firstOrNull(String[] strings) {
+    if (strings.length > 0)
+      return strings[0];
+    else
+      return null;
+  }
+
+  /**
+   * Returns the name of the type of a local array, <code>null</code> if no local array exists.
+   */
+  //   public String[][] guessGroupedArrayTypes() {
+  //           CompilationUnitCompletion completion= getCompletion();
+  //           LocalVariable[] localArrays= completion.findLocalArrays();
+  //           
+  //           String[][] ret= new String[localArrays.length][];
+  //           
+  //           for (int i= 0; i < localArrays.length; i++) {
+  //                   String type= getArrayTypeFromLocalArray(completion, localArrays[localArrays.length - i - 1]);
+  //                   ret[i]= new String[] {type};
+  //           }
+  //           
+  //           return ret;
+  //   }
+  /**
+   * Returns the name of the type of a local array, <code>null</code> if no local array exists.
+   */
+  //   public String[] guessArrayTypes() {
+  //           CompilationUnitCompletion completion= getCompletion();
+  //           LocalVariable[] localArrays= completion.findLocalArrays();
+  //           
+  //           List ret= new ArrayList();
+  //           
+  //           for (int i= 0; i < localArrays.length; i++) {
+  //                   String type= getArrayTypeFromLocalArray(completion, localArrays[localArrays.length - i - 1]);
+  //                   if (!ret.contains(type))
+  //                           ret.add(type);
+  //           }
+  //           
+  //           return (String[]) ret.toArray(new String[ret.size()]);
+  //   }
+  private String getArrayTypeFromLocalArray(CompilationUnitCompletion completion, LocalVariable array) {
+    String arrayTypeName = array.typeName;
+    String typeName = getScalarType(arrayTypeName);
+    int dimension = getArrayDimension(arrayTypeName) - 1;
+    Assert.isTrue(dimension >= 0);
+
+    String qualifiedName = createQualifiedTypeName(array.typePackageName, typeName);
+    String innerTypeName = completion.simplifyTypeName(qualifiedName);
+
+    return innerTypeName == null ? createArray(typeName, dimension) : createArray(innerTypeName, dimension);
+  }
+
+  private static String createArray(String type, int dimension) {
+    StringBuffer buffer = new StringBuffer(type);
+    for (int i = 0; i < dimension; i++)
+      buffer.append("[]"); //$NON-NLS-1$
+    return buffer.toString();
+  }
+
+  private static String getScalarType(String type) {
+    return type.substring(0, type.indexOf('['));
+  }
+
+  private static int getArrayDimension(String type) {
+
+    int dimension = 0;
+    int index = type.indexOf('[');
+
+    while (index != -1) {
+      dimension++;
+      index = type.indexOf('[', index + 1);
+    }
+
+    return dimension;
+  }
+
+  private static String createQualifiedTypeName(String packageName, String className) {
+    StringBuffer buffer = new StringBuffer();
+
+    if (packageName.length() != 0) {
+      buffer.append(packageName);
+      buffer.append('.');
+    }
+    buffer.append(className);
+
+    return buffer.toString();
+  }
+
+  /**
+   * Returns a proposal for a variable name of a local array element, <code>null</code> if no local array exists.
+   */
+  //   public String guessArrayElement() {
+  //           return firstOrNull(guessArrayElements());
+  //   }
+  /**
+   * Returns a proposal for a variable name of a local array element, <code>null</code> if no local array exists.
+   */
+  //   public String[] guessArrayElements() {
+  //           ICompilationUnit cu= getCompilationUnit();
+  //           if (cu == null) {
+  //                   return new String[0];
+  //           }
+  //           
+  //           CompilationUnitCompletion completion= getCompletion();
+  //           LocalVariable[] localArrays= completion.findLocalArrays();
+  //           
+  //           List ret= new ArrayList();
+  //           
+  //           for (int i= 0; i < localArrays.length; i++) {
+  //                   int idx= localArrays.length - i - 1;
+  //                   
+  //                   LocalVariable var= localArrays[idx];
+  //                   
+  //                   IJavaProject project= cu.getJavaProject();
+  //                   String typeName= var.typeName;
+  //                   String baseTypeName= typeName.substring(0, typeName.lastIndexOf('['));
+  //
+  //                   String indexName= getIndex();
+  //                   String[] excludedNames= completion.getLocalVariableNames();
+  //                   if (indexName != null) {
+  //                           ArrayList excludedNamesList= new ArrayList(Arrays.asList(excludedNames));
+  //                           excludedNamesList.add(indexName);
+  //                           excludedNames= (String[])excludedNamesList.toArray(new String[excludedNamesList.size()]);
+  //                   }
+  //                   String[] proposals= NamingConventions.suggestLocalVariableNames(project, var.typePackageName, baseTypeName, 0, excludedNames);
+  //                   for (int j= 0; j < proposals.length; j++) {
+  //                           if (!ret.contains(proposals[j]))
+  //                                   ret.add(proposals[j]);
+  //                   }
+  //           }
+  //           
+  //           return (String[]) ret.toArray(new String[ret.size()]);
+  //   }
+  /**
+   * Returns a proposal for a variable name of a local array element, <code>null</code> if no local array exists.
+   */
+  //   public String[][] guessGroupedArrayElements() {
+  //           ICompilationUnit cu= getCompilationUnit();
+  //           if (cu == null) {
+  //                   return new String[0][];
+  //           }
+  //           
+  //           CompilationUnitCompletion completion= getCompletion();
+  //           LocalVariable[] localArrays= completion.findLocalArrays();
+  //           
+  //           String[][] ret= new String[localArrays.length][];
+  //           
+  //           for (int i= 0; i < localArrays.length; i++) {
+  //                   int idx= localArrays.length - i - 1;
+  //                   
+  //                   LocalVariable var= localArrays[idx];
+  //                   
+  //                   IJavaProject project= cu.getJavaProject();
+  //                   String typeName= var.typeName;
+  //                   int dim= -1; // we expect at least one array
+  //                   int lastIndex= typeName.length();
+  //                   int bracket= typeName.lastIndexOf('[');
+  //                   while (bracket != -1) {
+  //                           lastIndex= bracket;
+  //                           dim++;
+  //                           bracket= typeName.lastIndexOf('[', bracket - 1);
+  //                   }
+  //                   typeName= typeName.substring(0, lastIndex);
+  //                   
+  //                   String indexName= getIndex();
+  //                   String[] excludedNames= completion.getLocalVariableNames();
+  //                   if (indexName != null) {
+  //                           ArrayList excludedNamesList= new ArrayList(Arrays.asList(excludedNames));
+  //                           excludedNamesList.add(indexName);
+  //                           excludedNames= (String[])excludedNamesList.toArray(new String[excludedNamesList.size()]);
+  //                   }
+  //                   String[] proposals= NamingConventions.suggestLocalVariableNames(project, var.typePackageName, typeName, dim, excludedNames);
+  //                   
+  //                   ret[i]= proposals;
+  //           }
+  //           
+  //           return ret;
+  //   }
+  /**
+   * Returns an array index name. 'i', 'j', 'k' are tried until no name collision with an existing local variable occurs. If all
+   * names collide, <code>null</code> is returned.
+   */
+  //   public String getIndex() {
+  //           CompilationUnitCompletion completion= getCompletion();
+  //           String[] proposals= {"i", "j", "k"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+  //           
+  //           for (int i= 0; i != proposals.length; i++) {
+  //                   String proposal = proposals[i];
+  //
+  //                   if (!completion.existsLocalName(proposal))
+  //                           return proposal;
+  //           }
+  //
+  //           return null;
+  //   }
+  /**
+   * Returns the name of a local collection, <code>null</code> if no local collection exists.
+   */
+  //   public String guessCollection() {
+  //           return firstOrNull(guessCollections());
+  //   }
+  /**
+   * Returns the names of local collections.
+   */
+  //   public String[] guessCollections() {
+  //           CompilationUnitCompletion completion= getCompletion();
+  //           try {
+  //                   LocalVariable[] localCollections= completion.findLocalCollections();
+  //                   String[] ret= new String[localCollections.length];
+  //                   for (int i= 0; i < ret.length; i++) {
+  //                           ret[ret.length - i - 1]= localCollections[i].name;
+  //                   }
+  //                   
+  //                   return ret;
+  //
+  //           } catch (JavaModelException e) {
+  //                   JavaPlugin.log(e);
+  //           }
+  //
+  //           return new String[0];
+  //   }
+  /**
+   * Returns an iterator name ('iter'). If 'iter' already exists as local variable, <code>null</code> is returned.
+   */
+  //   public String getIterator() {
+  //           CompilationUnitCompletion completion= getCompletion();
+  //           String[] proposals= {"iter"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+  //           
+  //           for (int i= 0; i != proposals.length; i++) {
+  //                   String proposal = proposals[i];
+  //
+  //                   if (!completion.existsLocalName(proposal))
+  //                           return proposal;
+  //           }
+  //
+  //           return null;
+  //   }
+  //   public void addIteratorImport() {
+  //           ICompilationUnit cu= getCompilationUnit();
+  //           if (cu == null) {
+  //                   return;
+  //           }
+  //   
+  //           try {
+  //                   Position position= new Position(getCompletionOffset(), getCompletionLength());
+  //                   IDocument document= getDocument();
+  //                   final String category= "__template_position_importer" + System.currentTimeMillis(); //$NON-NLS-1$
+  //                   IPositionUpdater updater= new DefaultPositionUpdater(category);
+  //                   document.addPositionCategory(category);
+  //                   document.addPositionUpdater(updater);
+  //                   document.addPosition(position);
+  //
+  //                   CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings();
+  //                   ImportsStructure structure= new ImportsStructure(cu, settings.importOrder, settings.importThreshold, true);
+  //                   structure.addImport("java.util.Iterator"); //$NON-NLS-1$
+  //                   structure.create(false, null);
+  //
+  //                   document.removePosition(position);
+  //                   document.removePositionUpdater(updater);
+  //                   document.removePositionCategory(category);
+  //                   
+  //                   setCompletionOffset(position.getOffset());
+  //                   setCompletionLength(position.getLength());
+  //                   
+  //           } catch (CoreException e) {
+  //                   handleException(null, e);
+  //           } catch (BadLocationException e) {
+  //                   handleException(null, e);
+  //           } catch (BadPositionCategoryException e) {
+  //                   handleException(null, e);
+  //           }
+  //   }
+  /**
+   * Evaluates a 'java' template in thecontext of a compilation unit
+   */
+  public static String evaluateTemplate(Template template, ICompilationUnit compilationUnit, int position) throws CoreException,
+      BadLocationException, TemplateException {
+
+    TemplateContextType contextType = PHPeclipsePlugin.getDefault().getTemplateContextRegistry().getContextType("java"); //$NON-NLS-1$
+    if (contextType == null)
+      throw new CoreException(new Status(IStatus.ERROR, PHPeclipsePlugin.PLUGIN_ID, IStatus.ERROR, JavaTemplateMessages
+          .getString("JavaContext.error.message"), null)); //$NON-NLS-1$
+
+    IDocument document = new Document();
+    if (compilationUnit != null && compilationUnit.exists())
+      document.set(compilationUnit.getSource());
+
+    JavaContext context = new JavaContext(contextType, document, position, 0, compilationUnit);
+    context.setForceEvaluation(true);
+
+    TemplateBuffer buffer = context.evaluate(template);
+    if (buffer == null)
+      return null;
+    return buffer.getString();
+  }
 
 }
 
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/JavaFormatter.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/JavaFormatter.java
new file mode 100644 (file)
index 0000000..5a9666d
--- /dev/null
@@ -0,0 +1,358 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.corext.template.php;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.phpdt.core.JavaCore;
+import net.sourceforge.phpdt.internal.corext.util.CodeFormatterUtil;
+import net.sourceforge.phpdt.internal.corext.util.Strings;
+import net.sourceforge.phpdt.internal.formatter.CodeFormatter;
+import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
+import net.sourceforge.phpdt.internal.ui.text.JavaHeuristicScanner;
+import net.sourceforge.phpdt.internal.ui.text.JavaIndenter;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.templates.DocumentTemplateContext;
+import org.eclipse.jface.text.templates.GlobalTemplateVariables;
+import org.eclipse.jface.text.templates.TemplateBuffer;
+import org.eclipse.jface.text.templates.TemplateContext;
+import org.eclipse.jface.text.templates.TemplateVariable;
+import org.eclipse.text.edits.DeleteEdit;
+import org.eclipse.text.edits.InsertEdit;
+import org.eclipse.text.edits.MalformedTreeException;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.RangeMarker;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.text.edits.TextEdit;
+
+/**
+ * A template editor using the Java formatter to format a template buffer.
+ */
+public class JavaFormatter {
+
+  private static final String MARKER = "/*${" + GlobalTemplateVariables.Cursor.NAME + "}*/"; //$NON-NLS-1$ //$NON-NLS-2$
+
+  /** The line delimiter to use if code formatter is not used. */
+  private final String fLineDelimiter;
+
+  /** The initial indent level */
+  private final int fInitialIndentLevel;
+
+  /** The java partitioner */
+  private boolean fUseCodeFormatter;
+
+  /**
+   * Creates a JavaFormatter with the target line delimiter.
+   * 
+   * @param lineDelimiter
+   *          the line delimiter to use
+   * @param initialIndentLevel
+   *          the initial indentation level
+   * @param useCodeFormatter
+   *          <code>true</code> if the core code formatter should be used
+   */
+  public JavaFormatter(String lineDelimiter, int initialIndentLevel, boolean useCodeFormatter) {
+    fLineDelimiter = lineDelimiter;
+    fUseCodeFormatter = useCodeFormatter;
+    fInitialIndentLevel = initialIndentLevel;
+  }
+
+  /**
+   * Formats the template buffer.
+   * 
+   * @param buffer
+   * @param context
+   * @throws BadLocationException
+   */
+  public void format(TemplateBuffer buffer, TemplateContext context) throws BadLocationException {
+    try {
+      if (fUseCodeFormatter)
+        // try to format and fall back to indenting
+        try {
+          format(buffer, (JavaContext) context);
+        } catch (BadLocationException e) {
+          indent(buffer);
+        } catch (MalformedTreeException e) {
+          indent(buffer);
+        }
+      else
+        indent(buffer);
+
+      // don't trim the buffer if the replacement area is empty
+      // case: surrounding empty lines with block
+      if (context instanceof DocumentTemplateContext) {
+        DocumentTemplateContext dtc = (DocumentTemplateContext) context;
+        if (dtc.getStart() == dtc.getCompletionOffset())
+          if (dtc.getDocument().get(dtc.getStart(), dtc.getEnd() - dtc.getEnd()).trim().length() == 0)
+            return;
+      }
+
+      trimBegin(buffer);
+    } catch (MalformedTreeException e) {
+      throw new BadLocationException();
+    }
+  }
+
+  private static int getCaretOffset(TemplateVariable[] variables) {
+    for (int i = 0; i != variables.length; i++) {
+      TemplateVariable variable = variables[i];
+
+      if (variable.getType().equals(GlobalTemplateVariables.Cursor.NAME))
+        return variable.getOffsets()[0];
+    }
+
+    return -1;
+  }
+
+  private boolean isInsideCommentOrString(String string, int offset) {
+
+    IDocument document = new Document(string);
+    PHPeclipsePlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(document);
+
+    try {
+      ITypedRegion partition = document.getPartition(offset);
+      String partitionType = partition.getType();
+
+      return partitionType != null
+          && (partitionType.equals(IPHPPartitions.PHP_MULTILINE_COMMENT)
+              || partitionType.equals(IPHPPartitions.PHP_SINGLELINE_COMMENT) || partitionType.equals(IPHPPartitions.PHP_STRING_DQ)
+              || partitionType.equals(IPHPPartitions.PHP_STRING_SQ) || partitionType.equals(IPHPPartitions.PHP_PHPDOC_COMMENT));
+
+    } catch (BadLocationException e) {
+      return false;
+    }
+  }
+
+  private void format(TemplateBuffer templateBuffer, JavaContext context) throws BadLocationException {
+    // XXX 4360, 15247
+    // workaround for code formatter limitations
+    // handle a special case where cursor position is surrounded by whitespaces
+
+    String string = templateBuffer.getString();
+    TemplateVariable[] variables = templateBuffer.getVariables();
+
+    int caretOffset = getCaretOffset(variables);
+    if ((caretOffset > 0) && Character.isWhitespace(string.charAt(caretOffset - 1)) && (caretOffset < string.length())
+        && Character.isWhitespace(string.charAt(caretOffset)) && !isInsideCommentOrString(string, caretOffset)) {
+      List positions = variablesToPositions(variables);
+
+      TextEdit insert = new InsertEdit(caretOffset, MARKER);
+      string = edit(string, positions, insert);
+      positionsToVariables(positions, variables);
+      templateBuffer.setContent(string, variables);
+
+      plainFormat(templateBuffer, context);
+
+      string = templateBuffer.getString();
+      variables = templateBuffer.getVariables();
+      caretOffset = getCaretOffset(variables);
+
+      positions = variablesToPositions(variables);
+      TextEdit delete = new DeleteEdit(caretOffset, MARKER.length());
+      string = edit(string, positions, delete);
+      positionsToVariables(positions, variables);
+      templateBuffer.setContent(string, variables);
+
+    } else {
+      plainFormat(templateBuffer, context);
+    }
+  }
+
+  private void plainFormat(TemplateBuffer templateBuffer, JavaContext context) throws BadLocationException {
+  }
+
+  //   private void plainFormat(TemplateBuffer templateBuffer, JavaContext context) throws BadLocationException {
+  //           
+  //           IDocument doc= new Document(templateBuffer.getString());
+  //           
+  //           TemplateVariable[] variables= templateBuffer.getVariables();
+  //           
+  //           List offsets= variablesToPositions(variables);
+  //           
+  //           Map options;
+  //           if (context.getCompilationUnit() != null)
+  //                   options= context.getCompilationUnit().getJavaProject().getOptions(true);
+  //           else
+  //                   options= JavaCore.getOptions();
+  //           
+  //           TextEdit edit= CodeFormatterUtil.format2(CodeFormatter.K_UNKNOWN, doc.get(), fInitialIndentLevel, fLineDelimiter, options);
+  //           if (edit == null)
+  //                   throw new BadLocationException(); // fall back to indenting
+  //           
+  //           MultiTextEdit root;
+  //           if (edit instanceof MultiTextEdit)
+  //                   root= (MultiTextEdit) edit;
+  //           else {
+  //                   root= new MultiTextEdit(0, doc.getLength());
+  //                   root.addChild(edit);
+  //           }
+  //           for (Iterator it= offsets.iterator(); it.hasNext();) {
+  //                   TextEdit position= (TextEdit) it.next();
+  //                   try {
+  //                           root.addChild(position);
+  //                   } catch (MalformedTreeException e) {
+  //                           // position conflicts with formatter edit
+  //                           // ignore this position
+  //                   }
+  //           }
+  //           
+  //           root.apply(doc, TextEdit.UPDATE_REGIONS);
+  //           
+  //           positionsToVariables(offsets, variables);
+  //           
+  //           templateBuffer.setContent(doc.get(), variables);
+  //   }
+
+  private void indent(TemplateBuffer templateBuffer) throws BadLocationException, MalformedTreeException {
+
+    TemplateVariable[] variables = templateBuffer.getVariables();
+    List positions = variablesToPositions(variables);
+
+    IDocument document = new Document(templateBuffer.getString());
+    MultiTextEdit root = new MultiTextEdit(0, document.getLength());
+    root.addChildren((TextEdit[]) positions.toArray(new TextEdit[positions.size()]));
+
+    JavaHeuristicScanner scanner = new JavaHeuristicScanner(document);
+    JavaIndenter indenter = new JavaIndenter(document, scanner);
+
+    // first line
+    int offset = document.getLineOffset(0);
+    TextEdit edit = new InsertEdit(offset, CodeFormatterUtil.createIndentString(fInitialIndentLevel));
+    root.addChild(edit);
+    root.apply(document, TextEdit.UPDATE_REGIONS);
+    root.removeChild(edit);
+
+    formatDelimiter(document, root, 0);
+
+    // following lines
+    int lineCount = document.getNumberOfLines();
+
+    for (int line = 1; line < lineCount; line++) {
+      IRegion region = document.getLineInformation(line);
+      offset = region.getOffset();
+      StringBuffer indent = indenter.computeIndentation(offset);
+      if (indent == null)
+        continue;
+  // axelcl delete start
+//      int nonWS = scanner.findNonWhitespaceForwardInAnyPartition(offset, offset + region.getLength());
+//      if (nonWS == JavaHeuristicScanner.NOT_FOUND)
+//        continue;
+//      edit = new ReplaceEdit(offset, nonWS - offset, indent.toString());
+//    axelcl delete end
+//    axelcl insert start
+      int nonWS = offset;
+      edit = new ReplaceEdit(offset, nonWS - offset, CodeFormatterUtil.createIndentString(fInitialIndentLevel));
+   // axelcl insert end
+      root.addChild(edit);
+      root.apply(document, TextEdit.UPDATE_REGIONS);
+      root.removeChild(edit);
+
+      formatDelimiter(document, root, line);
+    }
+
+    positionsToVariables(positions, variables);
+    templateBuffer.setContent(document.get(), variables);
+  }
+
+  /**
+   * Changes the delimiter to the configured line delimiter.
+   * 
+   * @param document
+   *          the temporary document being edited
+   * @param root
+   *          the root edit containing all positions that will be updated along the way
+   * @param line
+   *          the line to format
+   * @throws BadLocationException
+   *           if applying the changes fails
+   */
+  private void formatDelimiter(IDocument document, MultiTextEdit root, int line) throws BadLocationException {
+    IRegion region = document.getLineInformation(line);
+    String lineDelimiter = document.getLineDelimiter(line);
+    if (lineDelimiter != null) {
+      TextEdit edit = new ReplaceEdit(region.getOffset() + region.getLength(), lineDelimiter.length(), fLineDelimiter);
+      root.addChild(edit);
+      root.apply(document, TextEdit.UPDATE_REGIONS);
+      root.removeChild(edit);
+    }
+  }
+
+  private static void trimBegin(TemplateBuffer templateBuffer) throws BadLocationException {
+    String string = templateBuffer.getString();
+    TemplateVariable[] variables = templateBuffer.getVariables();
+
+    List positions = variablesToPositions(variables);
+
+    int i = 0;
+    while ((i != string.length()) && Character.isWhitespace(string.charAt(i)))
+      i++;
+
+    string = edit(string, positions, new DeleteEdit(0, i));
+    positionsToVariables(positions, variables);
+
+    templateBuffer.setContent(string, variables);
+  }
+
+  private static String edit(String string, List positions, TextEdit edit) throws BadLocationException {
+    MultiTextEdit root = new MultiTextEdit(0, string.length());
+    root.addChildren((TextEdit[]) positions.toArray(new TextEdit[positions.size()]));
+    root.addChild(edit);
+    IDocument document = new Document(string);
+    root.apply(document);
+
+    return document.get();
+  }
+
+  private static List variablesToPositions(TemplateVariable[] variables) {
+    List positions = new ArrayList(5);
+    for (int i = 0; i != variables.length; i++) {
+      int[] offsets = variables[i].getOffsets();
+
+      // trim positions off whitespace
+      String value = variables[i].getDefaultValue();
+      int wsStart = 0;
+      while (wsStart < value.length() && Character.isWhitespace(value.charAt(wsStart))
+          && !Strings.isLineDelimiterChar(value.charAt(wsStart)))
+        wsStart++;
+
+      variables[i].getValues()[0] = value.substring(wsStart);
+
+      for (int j = 0; j != offsets.length; j++) {
+        offsets[j] += wsStart;
+        positions.add(new RangeMarker(offsets[j], 0));
+      }
+    }
+    return positions;
+  }
+
+  private static void positionsToVariables(List positions, TemplateVariable[] variables) {
+    Iterator iterator = positions.iterator();
+
+    for (int i = 0; i != variables.length; i++) {
+      TemplateVariable variable = variables[i];
+
+      int[] offsets = new int[variable.getOffsets().length];
+      for (int j = 0; j != offsets.length; j++)
+        offsets[j] = ((TextEdit) iterator.next()).getOffset();
+
+      variable.setOffsets(offsets);
+    }
+  }
+}
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/util/CodeFormatterUtil.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/util/CodeFormatterUtil.java
new file mode 100644 (file)
index 0000000..60fc71d
--- /dev/null
@@ -0,0 +1,291 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.corext.util;
+
+import java.util.Map;
+
+import net.sourceforge.phpdt.core.IJavaProject;
+import net.sourceforge.phpdt.core.ToolFactory;
+import net.sourceforge.phpdt.core.formatter.CodeFormatter;
+import net.sourceforge.phpdt.internal.corext.Assert;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.DefaultPositionUpdater;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.Position;
+import org.eclipse.text.edits.DeleteEdit;
+import org.eclipse.text.edits.InsertEdit;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.text.edits.TextEdit;
+
+public class CodeFormatterUtil {
+                       
+       /**
+        * Creates a string that represents the given number of indents (can be spaces or tabs..)
+        */
+       public static String createIndentString(int indent) {
+         // axelcl change start
+//             String str= format(CodeFormatter.K_EXPRESSION, "x", indent, null, "", (Map) null); //$NON-NLS-1$ //$NON-NLS-2$
+               String str = ToolFactory.createCodeFormatter().format("x", indent, null, ""); 
+               return str.substring(0, str.indexOf('x'));
+               // axelcl change end
+       } 
+               
+//     public static int getTabWidth() {
+//             Preferences preferences= JavaCore.getPlugin().getPluginPreferences();
+//             return preferences.getInt(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
+//     }
+
+       // transition code
+
+       /**
+        * Old API. Consider to use format2 (TextEdit)
+        */     
+//     public static String format(int kind, String string, int indentationLevel, int[] positions, String lineSeparator, Map options) {
+//             return format(kind, string, 0, string.length(), indentationLevel, positions, lineSeparator, options);
+//     }
+//     
+//     public static String format(int kind, String string, int indentationLevel, int[] positions, String lineSeparator, IJavaProject project) {
+//             Map options= project != null ? project.getOptions(true) : null;
+//             return format(kind, string, 0, string.length(), indentationLevel, positions, lineSeparator, options);
+//     }
+       
+
+       /**
+        * Old API. Consider to use format2 (TextEdit)
+        */     
+//     public static String format(int kind, String string, int offset, int length, int indentationLevel, int[] positions, String lineSeparator, Map options) {
+//             TextEdit edit= format2(kind, string, offset, length, indentationLevel, lineSeparator, options);
+//             if (edit == null) {
+//                     //JavaPlugin.logErrorMessage("formatter failed to format (no edit returned). Will use unformatted text instead. kind: " + kind + ", string: " + string); //$NON-NLS-1$ //$NON-NLS-2$
+//                     return string.substring(offset, offset + length);
+//             }
+//             String formatted= getOldAPICompatibleResult(string, edit, indentationLevel, positions, lineSeparator, options);
+//             return formatted.substring(offset, formatted.length() - (string.length() - (offset + length)));
+//     }
+       
+       /**
+        * Old API. Consider to use format2 (TextEdit)
+        */     
+//     public static String format(ASTNode node, String string, int indentationLevel, int[] positions, String lineSeparator, Map options) {
+//             
+//             TextEdit edit= format2(node, string, indentationLevel, lineSeparator, options);
+//             if (edit == null) {
+//                     //JavaPlugin.logErrorMessage("formatter failed to format (no edit returned). Will use unformatted text instead. node: " + node.getNodeType() + ", string: " + string); //$NON-NLS-1$ //$NON-NLS-2$
+//                     return string;
+//             }
+//             return getOldAPICompatibleResult(string, edit, indentationLevel, positions, lineSeparator, options);
+//     }
+       
+       private static String getOldAPICompatibleResult(String string, TextEdit edit, int indentationLevel, int[] positions, String lineSeparator, Map options) {
+               Position[] p= null;
+               
+               if (positions != null) {
+                       p= new Position[positions.length];
+                       for (int i= 0; i < positions.length; i++) {
+                               p[i]= new Position(positions[i], 0);
+                       }
+               }
+               String res= evaluateFormatterEdit(string, edit, p);
+               
+               if (positions != null) {
+                       for (int i= 0; i < positions.length; i++) {
+                               Position curr= p[i];
+                               positions[i]= curr.getOffset();
+                       }
+               }                       
+               return res;
+       }
+       
+       /**
+        * Evaluates the edit on the given string.
+        * @throws IllegalArgumentException If the positions are not inside the string, a
+        *  IllegalArgumentException is thrown.
+        */
+       public static String evaluateFormatterEdit(String string, TextEdit edit, Position[] positions) {
+               try {
+                       Document doc= createDocument(string, positions);
+                       edit.apply(doc, 0);
+                       if (positions != null) {
+                               for (int i= 0; i < positions.length; i++) {
+                                       Assert.isTrue(!positions[i].isDeleted, "Position got deleted"); //$NON-NLS-1$
+                               }
+                       }
+                       return doc.get();
+               } catch (BadLocationException e) {
+                       PHPeclipsePlugin.log(e); // bug in the formatter
+                       Assert.isTrue(false, "Fromatter created edits with wrong positions: " + e.getMessage()); //$NON-NLS-1$
+               }
+               return null;
+       }
+       
+       /**
+        * Creates edits that describe how to format the given string. Returns <code>null</code> if the code could not be formatted for the given kind.
+        * @throws IllegalArgumentException If the offset and length are not inside the string, a
+        *  IllegalArgumentException is thrown.
+        */
+//     public static TextEdit format2(int kind, String string, int offset, int length, int indentationLevel, String lineSeparator, Map options) {
+//             if (offset < 0 || length < 0 || offset + length > string.length()) {
+//                     throw new IllegalArgumentException("offset or length outside of string. offset: " + offset + ", length: " + length + ", string size: " + string.length());   //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+//             }
+//             
+//             return createCodeFormatter(options).format(kind, string, offset, length, indentationLevel, lineSeparator);
+//             
+//     }
+       
+//     public static TextEdit format2(int kind, String string, int indentationLevel, String lineSeparator, Map options) {
+//             return format2(kind, string, 0, string.length(), indentationLevel, lineSeparator, options);
+//     }
+       
+       /**
+        * Creates edits that describe how to format the given string. Returns <code>null</code> if the code could not be formatted for the given kind.
+        * @throws IllegalArgumentException If the offset and length are not inside the string, a
+        *  IllegalArgumentException is thrown.
+        */
+//     public static TextEdit format2(ASTNode node, String str, int indentationLevel, String lineSeparator, Map options) {
+//             int code;
+//             String prefix= ""; //$NON-NLS-1$
+//             String suffix= ""; //$NON-NLS-1$
+//             if (node instanceof Statement) {
+//                     code= CodeFormatter.K_STATEMENTS;
+//                     if (node.getNodeType() == ASTNode.SWITCH_CASE) {
+//                             prefix= "switch(1) {"; //$NON-NLS-1$
+//                             suffix= "}"; //$NON-NLS-1$
+//                             code= CodeFormatter.K_STATEMENTS;
+//                     }
+//             } else if (node instanceof Expression && node.getNodeType() != ASTNode.VARIABLE_DECLARATION_EXPRESSION) {
+//                     code= CodeFormatter.K_EXPRESSION;
+//             } else {
+//                     switch (node.getNodeType()) {
+//                             case ASTNode.METHOD_DECLARATION:
+//                             case ASTNode.TYPE_DECLARATION:
+//                             case ASTNode.FIELD_DECLARATION:
+//                             case ASTNode.INITIALIZER:
+//                                     code= CodeFormatter.K_CLASS_BODY_DECLARATIONS;
+//                                     break;
+//                             case ASTNode.ARRAY_TYPE:
+//                             case ASTNode.PRIMITIVE_TYPE:
+//                             case ASTNode.SIMPLE_TYPE:
+//                                     suffix= " x;"; //$NON-NLS-1$
+//                                     code= CodeFormatter.K_EXPRESSION;
+//                                     break;
+//                             case ASTNode.COMPILATION_UNIT:
+//                                     code= CodeFormatter.K_COMPILATION_UNIT;
+//                                     break;
+//                             case ASTNode.VARIABLE_DECLARATION_EXPRESSION:
+//                             case ASTNode.SINGLE_VARIABLE_DECLARATION:
+//                                     suffix= ";"; //$NON-NLS-1$
+//                                     code= CodeFormatter.K_STATEMENTS;
+//                                     break;
+//                             case ASTNode.VARIABLE_DECLARATION_FRAGMENT:
+//                                     prefix= "A "; //$NON-NLS-1$
+//                                     suffix= ";"; //$NON-NLS-1$
+//                                     code= CodeFormatter.K_STATEMENTS;
+//                                     break;                  
+//                             case ASTNode.PACKAGE_DECLARATION:
+//                             case ASTNode.IMPORT_DECLARATION:
+//                                     suffix= "\nclass A {}"; //$NON-NLS-1$
+//                                     code= CodeFormatter.K_COMPILATION_UNIT;
+//                                     break;
+//                             case ASTNode.JAVADOC:
+//                                     suffix= "void foo();"; //$NON-NLS-1$
+//                                     code= CodeFormatter.K_CLASS_BODY_DECLARATIONS;
+//                                     break;
+//                             case ASTNode.CATCH_CLAUSE:
+//                                     prefix= "try {}"; //$NON-NLS-1$
+//                                     code= CodeFormatter.K_STATEMENTS;
+//                                     break;
+//                             case ASTNode.ANONYMOUS_CLASS_DECLARATION:
+//                                     prefix= "new A()"; //$NON-NLS-1$
+//                                     suffix= ";"; //$NON-NLS-1$
+//                                     code= CodeFormatter.K_STATEMENTS;
+//                                     break;
+//                             case ASTNode.MEMBER_REF:
+//                             case ASTNode.METHOD_REF:
+//                             case ASTNode.METHOD_REF_PARAMETER:
+//                             case ASTNode.TAG_ELEMENT:
+//                             case ASTNode.TEXT_ELEMENT:
+//                                     // not yet supported
+//                                     return null;
+//                             default:
+//                                     Assert.isTrue(false, "Node type not covered: " + node.getClass().getName()); //$NON-NLS-1$
+//                                     return null;
+//                     }
+//             }
+//             
+//             String concatStr= prefix + str + suffix;
+//             TextEdit edit= format2(code, concatStr, prefix.length(), str.length(), indentationLevel, lineSeparator, options);
+//             if (prefix.length() > 0) {
+//                     edit= shifEdit(edit, prefix.length());
+//             }               
+//             return edit;
+//     }       
+                       
+       private static TextEdit shifEdit(TextEdit oldEdit, int diff) {
+               TextEdit newEdit;
+               if (oldEdit instanceof ReplaceEdit) {
+                       ReplaceEdit edit= (ReplaceEdit) oldEdit;
+                       newEdit= new ReplaceEdit(edit.getOffset() - diff, edit.getLength(), edit.getText());
+               } else if (oldEdit instanceof InsertEdit) {
+                       InsertEdit edit= (InsertEdit) oldEdit;
+                       newEdit= new InsertEdit(edit.getOffset() - diff,  edit.getText());
+               } else if (oldEdit instanceof DeleteEdit) {
+                       DeleteEdit edit= (DeleteEdit) oldEdit;
+                       newEdit= new DeleteEdit(edit.getOffset() - diff,  edit.getLength());
+               } else if (oldEdit instanceof MultiTextEdit) {
+                       newEdit= new MultiTextEdit();                   
+               } else {
+                       return null; // not supported
+               }
+               TextEdit[] children= oldEdit.getChildren();
+               for (int i= 0; i < children.length; i++) {
+                       TextEdit shifted= shifEdit(children[i], diff);
+                       if (shifted != null) {
+                               newEdit.addChild(shifted);
+                       }
+               }
+               return newEdit;
+       }
+               
+       private static Document createDocument(String string, Position[] positions) throws IllegalArgumentException {
+               Document doc= new Document(string);
+               try {
+                       if (positions != null) {
+                               final String POS_CATEGORY= "myCategory"; //$NON-NLS-1$
+                               
+                               doc.addPositionCategory(POS_CATEGORY);
+                               doc.addPositionUpdater(new DefaultPositionUpdater(POS_CATEGORY) {
+                                       protected boolean notDeleted() {
+                                               if (fOffset < fPosition.offset && (fPosition.offset + fPosition.length < fOffset + fLength)) {
+                                                       fPosition.offset= fOffset + fLength; // deleted positions: set to end of remove
+                                                       return false;
+                                               }
+                                               return true;
+                                       }
+                               });
+                               for (int i= 0; i < positions.length; i++) {
+                                       try {
+                                               doc.addPosition(POS_CATEGORY, positions[i]);
+                                       } catch (BadLocationException e) {
+                                               throw new IllegalArgumentException("Position outside of string. offset: " + positions[i].offset + ", length: " + positions[i].length + ", string size: " + string.length());   //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+                                       }
+                               }
+                       }
+               } catch (BadPositionCategoryException cannotHappen) {
+                       // can not happen: category is correctly set up
+               }
+               return doc;
+       }
+       
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/JavaIndenter.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/JavaIndenter.java
new file mode 100644 (file)
index 0000000..39a3b29
--- /dev/null
@@ -0,0 +1,1372 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.text;
+
+import net.sourceforge.phpdt.core.JavaCore;
+import net.sourceforge.phpdt.core.formatter.DefaultCodeFormatterConstants;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.jface.text.Assert;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
+
+
+/**
+ * Uses the {@link net.sourceforge.phpdt.internal.ui.text.JavaHeuristicScanner}to
+ * get the indentation level for a certain position in a document.
+ * 
+ * <p>
+ * An instance holds some internal position in the document and is therefore
+ * not threadsafe.
+ * </p>
+ * 
+ * @since 3.0
+ */
+public class JavaIndenter {
+
+       /** The document being scanned. */
+       private IDocument fDocument;
+       /** The indentation accumulated by <code>findPreviousIndenationUnit</code>. */
+       private int fIndent;
+       /**
+        * The absolute (character-counted) indentation offset for special cases
+        * (method defs, array initializers)
+        */
+       private int fAlign;
+       /** The stateful scanposition for the indentation methods. */
+       private int fPosition;
+       /** The previous position. */
+       private int fPreviousPos;
+       /** The most recent token. */
+       private int fToken;
+       /** The line of <code>fPosition</code>. */
+       private int fLine;
+       /**
+        * The scanner we will use to scan the document. It has to be installed
+        * on the same document as the one we get.
+        */
+       private JavaHeuristicScanner fScanner;
+       
+       /**
+        * Creates a new instance.
+        * 
+        * @param document the document to scan
+        * @param scanner the {@link JavaHeuristicScanner} to be used for scanning
+        * the document. It must be installed on the same <code>IDocument</code>.
+        */
+       public JavaIndenter(IDocument document, JavaHeuristicScanner scanner) {
+               Assert.isNotNull(document);
+               Assert.isNotNull(scanner);
+               fDocument= document;
+               fScanner= scanner;
+       }
+       
+       /**
+        * Computes the indentation at the reference point of <code>position</code>.
+        * 
+        * @param offset the offset in the document
+        * @return a String which reflects the indentation at the line in which the
+        *         reference position to <code>offset</code> resides, or <code>null</code>
+        *         if it cannot be determined
+        */
+       public StringBuffer getReferenceIndentation(int offset) {
+               return getReferenceIndentation(offset, false);
+       }
+       
+       /**
+        * Computes the indentation at the reference point of <code>position</code>.
+        * 
+        * @param offset the offset in the document
+        * @param assumeOpeningBrace <code>true</code> if an opening brace should be assumed
+        * @return a String which reflects the indentation at the line in which the
+        *         reference position to <code>offset</code> resides, or <code>null</code>
+        *         if it cannot be determined
+        */
+       private StringBuffer getReferenceIndentation(int offset, boolean assumeOpeningBrace) {
+
+               int unit;
+               if (assumeOpeningBrace)
+                       unit= findReferencePosition(offset, Symbols.TokenLBRACE);
+               else
+                       unit= findReferencePosition(offset, peekChar(offset));
+               
+               // if we were unable to find anything, return null
+               if (unit == JavaHeuristicScanner.NOT_FOUND)
+                       return null;
+               
+               return getLeadingWhitespace(unit);
+               
+       }
+       
+       /**
+        * Computes the indentation at <code>offset</code>.
+        * 
+        * @param offset the offset in the document
+        * @return a String which reflects the correct indentation for the line in
+        *         which offset resides, or <code>null</code> if it cannot be
+        *         determined
+        */
+       public StringBuffer computeIndentation(int offset) {
+               return computeIndentation(offset, false);
+       }
+       
+       /**
+        * Computes the indentation at <code>offset</code>.
+        * 
+        * @param offset the offset in the document
+        * @param assumeOpeningBrace <code>true</code> if an opening brace should be assumed
+        * @return a String which reflects the correct indentation for the line in
+        *         which offset resides, or <code>null</code> if it cannot be
+        *         determined
+        */
+       public StringBuffer computeIndentation(int offset, boolean assumeOpeningBrace) {
+               
+               StringBuffer indent= getReferenceIndentation(offset, assumeOpeningBrace);
+               
+               // handle special alignment
+               if (fAlign != JavaHeuristicScanner.NOT_FOUND) {
+                       try {
+                               // a special case has been detected.
+                               IRegion line= fDocument.getLineInformationOfOffset(fAlign);
+                               int lineOffset= line.getOffset();
+                               return createIndent(lineOffset, fAlign);
+                       } catch (BadLocationException e) {
+                               return null;
+                       }
+               }
+               
+               if (indent == null)
+                       return null;
+               
+               // add additional indent
+               indent.append(createIndent(fIndent));
+               if (fIndent < 0)
+                       unindent(indent);
+               
+               return indent;
+       }
+
+       /**
+        * Returns the indentation of the line at <code>offset</code> as a
+        * <code>StringBuffer</code>. If the offset is not valid, the empty string
+        * is returned.
+        * 
+        * @param offset the offset in the document
+        * @return the indentation (leading whitespace) of the line in which
+        *                 <code>offset</code> is located
+        */
+       private StringBuffer getLeadingWhitespace(int offset) {
+               StringBuffer indent= new StringBuffer();
+               try {
+                       IRegion line= fDocument.getLineInformationOfOffset(offset);
+                       int lineOffset= line.getOffset();
+                       int nonWS= fScanner.findNonWhitespaceForwardInAnyPartition(lineOffset, lineOffset + line.getLength());
+                       indent.append(fDocument.get(lineOffset, nonWS - lineOffset));
+                       return indent;
+               } catch (BadLocationException e) {
+                       return indent;
+               }
+       }
+
+       /**
+        * Reduces indentation in <code>indent</code> by one indentation unit.
+        * 
+        * @param indent the indentation to be modified
+        */
+       private void unindent(StringBuffer indent) {
+               CharSequence oneIndent= createIndent();
+               int i= indent.lastIndexOf(oneIndent.toString()); //$NON-NLS-1$
+               if (i != -1) {
+                       indent.delete(i, i + oneIndent.length());
+               }                       
+       }
+
+       /**
+        * Creates an indentation string of the length indent - start + 1,
+        * consisting of the content in <code>fDocument</code> in the range
+        * [start, indent), with every character replaced by a space except for
+        * tabs, which are kept as such.
+        * 
+        * <p>Every run of the number of spaces that make up a tab are replaced
+        * by a tab character.</p>
+        * 
+        * @return the indentation corresponding to the document content specified
+        *         by <code>start</code> and <code>indent</code>
+        */
+       private StringBuffer createIndent(int start, int indent) {
+               final int tabLen= prefTabLength();              
+               StringBuffer ret= new StringBuffer();
+               try {
+                       int spaces= 0;
+                       while (start < indent) {
+                               
+                               char ch= fDocument.getChar(start);
+                               if (ch == '\t') {
+                                       ret.append('\t');
+                                       spaces= 0;
+                               } else if (tabLen == -1){
+                                       ret.append(' ');
+                               } else {
+                                       spaces++;
+                                       if (spaces == tabLen) {
+                                               ret.append('\t');
+                                               spaces= 0;
+                                       }
+                               }
+                               
+                               start++;
+                       }
+                       // remainder
+                       if (spaces == tabLen)
+                               ret.append('\t');
+                       else
+                               while (spaces-- > 0)
+                                       ret.append(' ');
+                       
+               } catch (BadLocationException e) {
+               }
+               
+               return ret;
+       }
+
+       /**
+        * Creates a string that represents the given number of indents (can be
+        * spaces or tabs..)
+        * 
+        * @param indent the requested indentation level.
+        * 
+        * @return the indentation specified by <code>indent</code>
+        */
+       private StringBuffer createIndent(int indent) {
+               StringBuffer oneIndent= createIndent();                 
+
+               StringBuffer ret= new StringBuffer();
+               while (indent-- > 0)
+                       ret.append(oneIndent);
+               
+               return ret;
+       }
+       
+       /**
+        * Creates a string that represents one indent (can be
+        * spaces or tabs..)
+        * 
+        * @return one indentation
+        */
+       private StringBuffer createIndent() {
+               // get a sensible default when running without the infrastructure for testing
+               StringBuffer oneIndent= new StringBuffer();
+//             JavaCore plugin= JavaCore.getJavaCore();
+               PHPeclipsePlugin plugin = PHPeclipsePlugin.getDefault();
+               if (plugin == null) {
+                       oneIndent.append('\t');
+               } else {
+                       if (JavaCore.SPACE.equals(JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR))) {
+                               int tabLen= Integer.parseInt(JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE));
+                               for (int i= 0; i < tabLen; i++)
+                                       oneIndent.append(' ');
+                       } else if (JavaCore.TAB.equals(JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)))
+                               oneIndent.append('\t');
+                       else
+                               oneIndent.append('\t'); // default
+               }
+               return oneIndent;
+       }
+
+       /**
+        * Returns the reference position regarding to indentation for <code>offset</code>,
+        * or <code>NOT_FOUND</code>. This method calls
+        * {@link #findReferencePosition(int, int) findReferencePosition(offset, nextChar)} where
+        * <code>nextChar</code> is the next character after <code>offset</code>.
+        * 
+        * @param offset the offset for which the reference is computed
+        * @return the reference statement relative to which <code>offset</code>
+        *         should be indented, or {@link JavaHeuristicScanner#NOT_FOUND}
+        */
+       public int findReferencePosition(int offset) {
+               return findReferencePosition(offset, peekChar(offset));
+       }
+       
+       /**
+        * Peeks the next char in the document that comes after <code>offset</code>
+        * on the same line as <code>offset</code>.
+        * 
+        * @param offset the offset into document
+        * @return the token symbol of the next element, or TokenEOF if there is none
+        */
+       private int peekChar(int offset) {
+               if (offset < fDocument.getLength()) {
+                       try {
+                               IRegion line= fDocument.getLineInformationOfOffset(offset);
+                               int lineOffset= line.getOffset();
+                               int next= fScanner.nextToken(offset, lineOffset + line.getLength());
+                               return next;
+                       } catch (BadLocationException e) {
+                       }
+               }
+               return Symbols.TokenEOF;
+       }
+       
+       /**
+        * Returns the reference position regarding to indentation for <code>position</code>,
+        * or <code>NOT_FOUND</code>.
+        * 
+        * <p>If <code>peekNextChar</code> is <code>true</code>, the next token after
+        * <code>offset</code> is read and taken into account when computing the
+        * indentation. Currently, if the next token is the first token on the line
+        * (i.e. only preceded by whitespace), the following tokens are specially
+        * handled:
+        * <ul>
+        *      <li><code>switch</code> labels are indented relative to the switch block</li>
+        *      <li>opening curly braces are aligned correctly with the introducing code</li>
+        *      <li>closing curly braces are aligned properly with the introducing code of
+        *              the matching opening brace</li>
+        *      <li>closing parenthesis' are aligned with their opening peer</li>
+        *      <li>the <code>else</code> keyword is aligned with its <code>if</code>, anything
+        *              else is aligned normally (i.e. with the base of any introducing statements).</li>
+        *  <li>if there is no token on the same line after <code>offset</code>, the indentation
+        *              is the same as for an <code>else</code> keyword</li>
+        * </ul>
+        * 
+        * @param offset the offset for which the reference is computed
+        * @param nextToken the next token to assume in the document
+        * @return the reference statement relative to which <code>offset</code>
+        *         should be indented, or {@link JavaHeuristicScanner#NOT_FOUND}
+        */
+       public int findReferencePosition(int offset, int nextToken) {
+               boolean danglingElse= false;
+               boolean unindent= false;
+               boolean indent= false;
+               boolean matchBrace= false;
+               boolean matchParen= false;
+               boolean matchCase= false;
+               
+               // account for unindenation characters already typed in, but after position
+               // if they are on a line by themselves, the indentation gets adjusted
+               // accordingly
+               //
+               // also account for a dangling else 
+               if (offset < fDocument.getLength()) {
+                       try {
+                               IRegion line= fDocument.getLineInformationOfOffset(offset);
+                               int lineOffset= line.getOffset();
+                               int prevPos= Math.max(offset - 1, 0);
+                               boolean isFirstTokenOnLine= fDocument.get(lineOffset, prevPos + 1 - lineOffset).trim().length() == 0;
+                               int prevToken= fScanner.previousToken(prevPos, JavaHeuristicScanner.UNBOUND);
+                               boolean bracelessBlockStart= fScanner.isBracelessBlockStart(prevPos, JavaHeuristicScanner.UNBOUND);
+                               
+                               switch (nextToken) {
+                                       case Symbols.TokenEOF:
+                                       case Symbols.TokenELSE:
+                                               danglingElse= true;
+                                               break;
+                                       case Symbols.TokenCASE:
+                                       case Symbols.TokenDEFAULT:
+                                               if (isFirstTokenOnLine)
+                                                       matchCase= true;
+                                               break;
+                                       case Symbols.TokenLBRACE: // for opening-brace-on-new-line style
+//                                             if (bracelessBlockStart && !prefIndentBracesForBlocks())
+//                                                     unindent= true;
+//                                             else if ((prevToken == Symbols.TokenCOLON || prevToken == Symbols.TokenEQUAL || prevToken == Symbols.TokenRBRACKET) && !prefIndentBracesForArrays())
+//                                                     unindent= true;
+//                                             else if (!bracelessBlockStart && prefIndentBracesForMethods())
+//                                                     indent= true;
+//                                             break;
+                                               if (bracelessBlockStart )
+                                                       unindent= true;
+                                               else if ((prevToken == Symbols.TokenCOLON || prevToken == Symbols.TokenEQUAL || prevToken == Symbols.TokenRBRACKET) )
+                                                       unindent= true;
+                                               else if (!bracelessBlockStart)
+                                                       indent= true;
+                                               break;
+                                       case Symbols.TokenRBRACE: // closing braces get unindented
+                                               if (isFirstTokenOnLine)
+                                                       matchBrace= true;
+                                               break;
+                                       case Symbols.TokenRPAREN:
+                                               if (isFirstTokenOnLine)
+                                                       matchParen= true;
+                                               break;
+                                       }
+                       } catch (BadLocationException e) {
+                       }
+               } else {
+                       // assume an else could come if we are at the end of file
+                       danglingElse= true; 
+               }
+               
+               int ref= findReferencePosition(offset, danglingElse, matchBrace, matchParen, matchCase);
+               if (unindent)
+                       fIndent--;
+               if (indent)
+                       fIndent++;
+               return ref;
+       }
+       
+       /**
+        * Returns the reference position regarding to indentation for <code>position</code>,
+        * or <code>NOT_FOUND</code>.<code>fIndent</code> will contain the
+        * relative indentation (in indentation units, not characters) after the
+        * call. If there is a special alignment (e.g. for a method declaration
+        * where parameters should be aligned), <code>fAlign</code> will contain
+        * the absolute position of the alignment reference in <code>fDocument</code>,
+        * otherwise <code>fAlign</code> is set to <code>JavaHeuristicScanner.NOT_FOUND</code>.
+        * 
+        * @param offset the offset for which the reference is computed
+        * @param danglingElse whether a dangling else should be assumed at <code>position</code>
+        * @param matchBrace whether the position of the matching brace should be
+        *            returned instead of doing code analysis
+        * @param matchParen whether the position of the matching parenthesis
+        *            should be returned instead of doing code analysis
+        * @param matchCase whether the position of a switch statement reference
+        *            should be returned (either an earlier case statement or the
+        *            switch block brace)
+        * @return the reference statement relative to which <code>position</code>
+        *         should be indented, or {@link JavaHeuristicScanner#NOT_FOUND}
+        */
+       public int findReferencePosition(int offset, boolean danglingElse, boolean matchBrace, boolean matchParen, boolean matchCase) {
+               fIndent= 0; // the indentation modification
+               fAlign= JavaHeuristicScanner.NOT_FOUND;
+               fPosition= offset;
+               
+               // forward cases
+               // an unindentation happens sometimes if the next token is special, namely on braces, parens and case labels
+               // align braces, but handle the case where we align with the method declaration start instead of
+               // the opening brace.
+//             if (matchBrace) {
+//                     if (skipScope(Symbols.TokenLBRACE, Symbols.TokenRBRACE)) {
+//                             try {
+//                                     // align with the opening brace that is on a line by its own
+//                                     int lineOffset= fDocument.getLineOffset(fLine);
+//                                     if (lineOffset <= fPosition && fDocument.get(lineOffset, fPosition - lineOffset).trim().length() == 0)
+//                                             return fPosition;
+//                             } catch (BadLocationException e) {
+//                                     // concurrent modification - walk default path
+//                             }
+//                             // if the opening brace is not on the start of the line, skip to the start
+//                             int pos= skipToStatementStart(true, true);
+//                             fIndent= 0; // indent is aligned with reference position
+//                             return pos;
+//                     } else {
+//                             // if we can't find the matching brace, the heuristic is to unindent
+//                             // by one against the normal position
+//                             int pos= findReferencePosition(offset, danglingElse, false, matchParen, matchCase);
+//                             fIndent--;
+//                             return pos;
+//                     }
+//             }
+               
+               // align parenthesis'
+               if (matchParen) {
+                       if (skipScope(Symbols.TokenLPAREN, Symbols.TokenRPAREN))
+                               return fPosition;
+                       else {
+                               // if we can't find the matching paren, the heuristic is to unindent
+                               // by one against the normal position
+                               int pos= findReferencePosition(offset, danglingElse, matchBrace, false, matchCase);
+                               fIndent--;
+                               return pos;
+                       }
+               }
+               
+               // the only reliable way to get case labels aligned (due to many different styles of using braces in a block)
+               // is to go for another case statement, or the scope opening brace
+//             if (matchCase) {
+//                     return matchCaseAlignment();
+//             }
+               
+               nextToken();
+               switch (fToken) {
+                       case Symbols.TokenRBRACE:
+                               // skip the block and fall through
+                               // if we can't complete the scope, reset the scan position
+                               int pos= fPosition;
+                               if (!skipScope())
+                                       fPosition= pos;
+                       case Symbols.TokenSEMICOLON:
+                               // this is the 90% case: after a statement block 
+                               // the end of the previous statement / block previous.end
+                               // search to the end of the statement / block before the previous; the token just after that is previous.start
+                               return skipToStatementStart(danglingElse, false);
+                       
+                       // scope introduction: special treat who special is
+                       case Symbols.TokenLPAREN:
+                       case Symbols.TokenLBRACE:
+                       case Symbols.TokenLBRACKET:
+                               return handleScopeIntroduction(offset + 1);
+                               
+                       case Symbols.TokenEOF:
+                               // trap when hitting start of document
+                               return 0;
+                       
+                       case Symbols.TokenEQUAL:
+                               // indent assignments
+                               fIndent= prefAssignmentIndent();
+                               return fPosition;
+                               
+                       case Symbols.TokenCOLON:
+                               // TODO handle ternary deep indentation
+                               fIndent= prefCaseBlockIndent();
+                               return fPosition;
+                       
+                       case Symbols.TokenQUESTIONMARK:
+                               if (prefTernaryDeepAlign()) {
+                                       setFirstElementAlignment(fPosition, offset + 1);
+                                       return fPosition;
+                               } else {
+                                       fIndent= prefTernaryIndent();
+                                       return fPosition;
+                               }
+                               
+                       // indentation for blockless introducers:
+                       case Symbols.TokenDO:
+                       case Symbols.TokenWHILE:
+                       case Symbols.TokenELSE:
+                               fIndent= prefSimpleIndent();
+                               return fPosition;
+                       case Symbols.TokenRPAREN:
+                               int line= fLine;
+                               if (skipScope(Symbols.TokenLPAREN, Symbols.TokenRPAREN)) {
+                                       int scope= fPosition;
+                                       nextToken();
+                                       if (fToken == Symbols.TokenIF || fToken == Symbols.TokenWHILE || fToken == Symbols.TokenFOR) {
+                                               fIndent= prefSimpleIndent();
+                                               return fPosition;
+                                       }
+                                       fPosition= scope;
+                                       if (looksLikeMethodDecl()) {
+                                               return skipToStatementStart(danglingElse, false);
+                                       }
+                               }
+                               // restore
+                               fPosition= offset;
+                               fLine= line;
+                               // else: fall through to default
+                               
+                       case Symbols.TokenCOMMA:
+                               // inside a list of some type
+                               // easy if there is already a list item before with its own indentation - we just align
+                               // if not: take the start of the list ( LPAREN, LBRACE, LBRACKET ) and either align or
+                               // indent by list-indent
+                       default:
+                               // inside whatever we don't know about: similar to the list case:
+                               // if we are inside a continued expression, then either align with a previous line that has indentation
+                               // or indent from the expression start line (either a scope introducer or the start of the expr).
+                               return skipToPreviousListItemOrListStart();
+                               
+               }
+       }
+
+       /**
+        * Skips to the start of a statement that ends at the current position.
+        * 
+        * @param danglingElse whether to indent aligned with the last <code>if</code>
+        * @param isInBlock whether the current position is inside a block, which limits the search scope to the next scope introducer
+        * @return the reference offset of the start of the statement 
+        */
+       private int skipToStatementStart(boolean danglingElse, boolean isInBlock) {
+               while (true) {
+                       nextToken();
+                       
+                       if (isInBlock) {
+                               switch (fToken) {
+                                       // exit on all block introducers
+                                       case Symbols.TokenIF:
+                                       case Symbols.TokenELSE:
+                                       case Symbols.TokenSYNCHRONIZED:
+                                       case Symbols.TokenCOLON:
+                                       case Symbols.TokenSTATIC:
+                                       case Symbols.TokenCATCH:
+                                       case Symbols.TokenDO:
+                                       case Symbols.TokenWHILE:
+                                       case Symbols.TokenFINALLY:
+                                       case Symbols.TokenFOR:
+                                       case Symbols.TokenTRY:
+                                               return fPosition;
+                                               
+                                       case Symbols.TokenSWITCH:
+                                               fIndent= prefCaseIndent();
+                                               return fPosition;
+                               }
+                       }
+                       
+                       switch (fToken) {
+                               // scope introduction through: LPAREN, LBRACE, LBRACKET
+                               // search stop on SEMICOLON, RBRACE, COLON, EOF
+                               // -> the next token is the start of the statement (i.e. previousPos when backward scanning)
+                               case Symbols.TokenLPAREN:
+                               case Symbols.TokenLBRACE:
+                               case Symbols.TokenLBRACKET:
+                               case Symbols.TokenSEMICOLON:
+                               case Symbols.TokenEOF:
+                                       return fPreviousPos;
+                                       
+                               case Symbols.TokenCOLON:
+                                       int pos= fPreviousPos;
+                                       if (!isConditional())
+                                               return pos;
+                                       break;
+                               
+                               case Symbols.TokenRBRACE:
+                                       // RBRACE is a little tricky: it can be the end of an array definition, but
+                                       // usually it is the end of a previous block
+                                       pos= fPreviousPos; // store state
+                                       if (skipScope() && looksLikeArrayInitializerIntro())
+                                               continue; // it's an array
+                                       else
+                                               return pos; // it's not - do as with all the above
+                                       
+                               // scopes: skip them
+                               case Symbols.TokenRPAREN:
+                               case Symbols.TokenRBRACKET:
+                                       pos= fPreviousPos;
+                                       if (skipScope())
+                                               break;
+                                       else
+                                               return pos; 
+                                       
+                               // IF / ELSE: align the position after the conditional block with the if
+                               // so we are ready for an else, except if danglingElse is false
+                               // in order for this to work, we must skip an else to its if
+                               case Symbols.TokenIF:
+                                       if (danglingElse)
+                                               return fPosition;
+                                       else
+                                               break;
+                               case Symbols.TokenELSE:
+                                       // skip behind the next if, as we have that one covered
+                                       pos= fPosition;
+                                       if (skipNextIF())
+                                               break;
+                                       else
+                                               return pos;
+                               
+                               case Symbols.TokenDO:
+                                       // align the WHILE position with its do
+                                       return fPosition;
+                                       
+                               case Symbols.TokenWHILE:
+                                       // this one is tricky: while can be the start of a while loop
+                                       // or the end of a do - while 
+                                       pos= fPosition;
+                                       if (hasMatchingDo()) {
+                                               // continue searching from the DO on 
+                                               break;
+                                       } else {
+                                               // continue searching from the WHILE on
+                                               fPosition= pos;
+                                               break;
+                                       }
+                               default:
+                                       // keep searching
+                                       
+                       }
+
+               }
+       }
+       
+       /**
+        * Returns true if the colon at the current position is part of a conditional
+        * (ternary) expression, false otherwise.
+        * 
+        * @return true if the colon at the current position is part of a conditional
+        */
+       private boolean isConditional() {
+               while (true) {
+                       nextToken();
+                       switch (fToken) {
+                               
+                               // search for case, otherwise return true
+                               case Symbols.TokenIDENT:
+                                       continue;
+                               case Symbols.TokenCASE:
+                                       return false;
+                                       
+                               default:
+                                       return true;
+                       }
+               }
+       }
+
+       /**
+        * Returns as a reference any previous <code>switch</code> labels (<code>case</code>
+        * or <code>default</code>) or the offset of the brace that scopes the switch 
+        * statement. Sets <code>fIndent</code> to <code>prefCaseIndent</code> upon
+        * a match.
+        *  
+        * @return the reference offset for a <code>switch</code> label
+        */
+//     private int matchCaseAlignment() {
+//             while (true) {
+//                     nextToken();
+//                     switch (fToken) {
+//                             // invalid cases: another case label or an LBRACE must come before a case
+//                             // -> bail out with the current position
+//                             case Symbols.TokenLPAREN:
+//                             case Symbols.TokenLBRACKET:
+//                             case Symbols.TokenEOF:
+//                                     return fPosition;
+//                             case Symbols.TokenLBRACE:
+//                                     // opening brace of switch statement
+//                                     fIndent= prefCaseIndent();
+//                                     return fPosition;
+//                             case Symbols.TokenCASE:
+//                             case Symbols.TokenDEFAULT:
+//                                     // align with previous label
+//                                     fIndent= 0;
+//                                     return fPosition;
+//                             
+//                             // scopes: skip them
+//                             case Symbols.TokenRPAREN:
+//                             case Symbols.TokenRBRACKET:
+//                             case Symbols.TokenRBRACE:
+//                                     skipScope();
+//                                     break;
+//                                     
+//                             default:
+//                                     // keep searching
+//                                     continue;
+//                                     
+//                     }
+//             }
+//     }
+
+       /**
+        * Returns the reference position for a list element. The algorithm
+        * tries to match any previous indentation on the same list. If there is none,
+        * the reference position returned is determined depending on the type of list:
+        * The indentation will either match the list scope introducer (e.g. for
+        * method declarations), so called deep indents, or simply increase the
+        * indentation by a number of standard indents. See also {@link #handleScopeIntroduction(int)}.
+        * 
+        * @return the reference position for a list item: either a previous list item
+        * that has its own indentation, or the list introduction start.
+        */
+       private int skipToPreviousListItemOrListStart() {
+               int startLine= fLine;
+               int startPosition= fPosition;
+               while (true) {
+                       nextToken();
+                       
+                       // if any line item comes with its own indentation, adapt to it
+                       if (fLine < startLine) {
+                               try {
+                                       int lineOffset= fDocument.getLineOffset(startLine);
+                                       int bound= Math.min(fDocument.getLength(), startPosition + 1);
+                                       fAlign= fScanner.findNonWhitespaceForwardInAnyPartition(lineOffset, bound);
+                               } catch (BadLocationException e) {
+                                       // ignore and return just the position
+                               }
+                               return startPosition;
+                       }
+                       
+                       switch (fToken) {
+                               // scopes: skip them
+                               case Symbols.TokenRPAREN:
+                               case Symbols.TokenRBRACKET:
+                               case Symbols.TokenRBRACE:
+                                       skipScope();
+                                       break;
+                               
+                               // scope introduction: special treat who special is
+                               case Symbols.TokenLPAREN:
+                               case Symbols.TokenLBRACE:
+                               case Symbols.TokenLBRACKET:
+                                       return handleScopeIntroduction(startPosition + 1);
+                                       
+                               case Symbols.TokenSEMICOLON:
+                                       return fPosition;
+                               case Symbols.TokenQUESTIONMARK:
+                                       if (prefTernaryDeepAlign()) {
+                                               setFirstElementAlignment(fPosition - 1, fPosition + 1);
+                                               return fPosition;
+                                       } else {
+                                               fIndent= prefTernaryIndent();
+                                               return fPosition;
+                                       }
+                               case Symbols.TokenEOF:
+                                       return 0;
+                                       
+                       }
+               }
+       }
+       
+       /**
+        * Skips a scope and positions the cursor (<code>fPosition</code>) on the 
+        * token that opens the scope. Returns <code>true</code> if a matching peer
+        * could be found, <code>false</code> otherwise. The current token when calling
+        * must be one out of <code>Symbols.TokenRPAREN</code>, <code>Symbols.TokenRBRACE</code>,
+        * and <code>Symbols.TokenRBRACKET</code>.  
+        * 
+        * @return <code>true</code> if a matching peer was found, <code>false</code> otherwise
+        */
+       private boolean skipScope() {
+               switch (fToken) {
+                       case Symbols.TokenRPAREN:
+                               return skipScope(Symbols.TokenLPAREN, Symbols.TokenRPAREN);
+                       case Symbols.TokenRBRACKET:
+                               return skipScope(Symbols.TokenLBRACKET, Symbols.TokenRBRACKET);
+                       case Symbols.TokenRBRACE:
+                               return skipScope(Symbols.TokenLBRACE, Symbols.TokenRBRACE);
+                       default:
+                               Assert.isTrue(false);
+                               return false;
+               }
+       }
+
+       /**
+        * Handles the introduction of a new scope. The current token must be one out
+        * of <code>Symbols.TokenLPAREN</code>, <code>Symbols.TokenLBRACE</code>,
+        * and <code>Symbols.TokenLBRACKET</code>. Returns as the reference position
+        * either the token introducing the scope or - if available - the first
+        * java token after that.
+        * 
+        * <p>Depending on the type of scope introduction, the indentation will align
+        * (deep indenting) with the reference position (<code>fAlign</code> will be 
+        * set to the reference position) or <code>fIndent</code> will be set to 
+        * the number of indentation units.
+        * </p>
+        * 
+        * @param bound the bound for the search for the first token after the scope 
+        * introduction.
+        * @return
+        */
+       private int handleScopeIntroduction(int bound) {
+               switch (fToken) {
+                       // scope introduction: special treat who special is
+                       case Symbols.TokenLPAREN:
+                               int pos= fPosition; // store
+                               
+                               // special: method declaration deep indentation
+                               if (looksLikeMethodDecl()) {
+                                       if (prefMethodDeclDeepIndent())
+                                               return setFirstElementAlignment(pos, bound);
+                                       else {
+                                               fIndent= prefMethodDeclIndent();
+                                               return pos;
+                                       }
+                               } else {
+                                       fPosition= pos;
+                                       if (looksLikeMethodCall()) {
+                                               if (prefMethodCallDeepIndent())
+                                                       return setFirstElementAlignment(pos, bound);
+                                               else {
+                                                       fIndent= prefMethodCallIndent();
+                                                       return pos;
+                                               }
+                                       } else if (prefParenthesisDeepIndent())
+                                               return setFirstElementAlignment(pos, bound);
+                               }
+                               
+                               // normal: return the parenthesis as reference
+                               fIndent= prefParenthesisIndent();
+                               return pos;
+                               
+                       case Symbols.TokenLBRACE:
+                               pos= fPosition; // store
+                               
+                               // special: array initializer
+                               if (looksLikeArrayInitializerIntro())
+                                       if (prefArrayDeepIndent())
+                                               return setFirstElementAlignment(pos, bound);
+                                       else
+                                               fIndent= prefArrayIndent();
+                               else
+                                       fIndent= prefBlockIndent();
+                               
+                               // normal: skip to the statement start before the scope introducer
+                               // opening braces are often on differently ending indents than e.g. a method definition
+                               fPosition= pos; // restore
+                               return skipToStatementStart(true, true); // set to true to match the first if
+                               
+                       case Symbols.TokenLBRACKET:
+                               pos= fPosition; // store
+                               
+                               // special: method declaration deep indentation
+                               if (prefArrayDimensionsDeepIndent()) {
+                                       return setFirstElementAlignment(pos, bound);
+                               }
+                               
+                               // normal: return the bracket as reference
+                               fIndent= prefBracketIndent();
+                               return pos; // restore
+                               
+                       default:
+                               Assert.isTrue(false);
+                               return -1; // dummy
+               }
+       }
+
+       /**
+        * Sets the deep indent offset (<code>fAlign</code>) to either the offset
+        * right after <code>scopeIntroducerOffset</code> or - if available - the
+        * first Java token after <code>scopeIntroducerOffset</code>, but before
+        * <code>bound</code>.
+        * 
+        * @param scopeIntroducerOffset the offset of the scope introducer
+        * @param bound the bound for the search for another element
+        * @return the reference position
+        */
+       private int setFirstElementAlignment(int scopeIntroducerOffset, int bound) {
+               int firstPossible= scopeIntroducerOffset + 1; // align with the first position after the scope intro
+               fAlign= fScanner.findNonWhitespaceForwardInAnyPartition(firstPossible, bound);
+               if (fAlign == JavaHeuristicScanner.NOT_FOUND)
+                       fAlign= firstPossible;
+               return fAlign;
+       }
+
+
+       /**
+        * Returns <code>true</code> if the next token received after calling
+        * <code>nextToken</code> is either an equal sign or an array designator ('[]').
+        * 
+        * @return <code>true</code> if the next elements look like the start of an array definition
+        */
+       private boolean looksLikeArrayInitializerIntro() {
+               nextToken();
+               if (fToken == Symbols.TokenEQUAL || skipBrackets()) {
+                       return true;
+               }
+               return false;
+       }
+
+       /**
+        * Skips over the next <code>if</code> keyword. The current token when calling
+        * this method must be an <code>else</code> keyword. Returns <code>true</code>
+        * if a matching <code>if</code> could be found, <code>false</code> otherwise.
+        * The cursor (<code>fPosition</code>) is set to the offset of the <code>if</code>
+        * token.
+        * 
+        * @return <code>true</code> if a matching <code>if</code> token was found, <code>false</code> otherwise
+        */
+       private boolean skipNextIF() {
+               Assert.isTrue(fToken == Symbols.TokenELSE);
+               
+               while (true) {
+                       nextToken();
+                       switch (fToken) {
+                               // scopes: skip them
+                               case Symbols.TokenRPAREN:
+                               case Symbols.TokenRBRACKET:
+                               case Symbols.TokenRBRACE:
+                                       skipScope();
+                                       break;
+                                       
+                               case Symbols.TokenIF:
+                                       // found it, return
+                                       return true;
+                               case Symbols.TokenELSE:
+                                       // recursively skip else-if blocks
+                                       skipNextIF();
+                                       break;
+                               
+                               // shortcut scope starts
+                               case Symbols.TokenLPAREN:
+                               case Symbols.TokenLBRACE:
+                               case Symbols.TokenLBRACKET:
+                               case Symbols.TokenEOF:
+                                       return false;
+                               }
+               }
+       }
+
+
+       /**
+        * while(condition); is ambiguous when parsed backwardly, as it is a valid
+        * statement by its own, so we have to check whether there is a matching
+        * do. A <code>do</code> can either be separated from the while by a
+        * block, or by a single statement, which limits our search distance.
+        * 
+        * @return <code>true</code> if the <code>while</code> currently in
+        *         <code>fToken</code> has a matching <code>do</code>.
+        */
+       private boolean hasMatchingDo() {
+               Assert.isTrue(fToken == Symbols.TokenWHILE);
+               nextToken();
+               switch (fToken) {
+                       case Symbols.TokenRBRACE:
+                               skipScope(); // and fall thru
+                       case Symbols.TokenSEMICOLON:
+                               skipToStatementStart(false, false);
+                               return fToken == Symbols.TokenDO;
+               }
+               return false;
+       }
+       
+       /**
+        * Skips brackets if the current token is a RBRACKET. There can be nothing
+        * but whitespace in between, this is only to be used for <code>[]</code> elements.
+        * 
+        * @return <code>true</code> if a <code>[]</code> could be scanned, the
+        *         current token is left at the LBRACKET.
+        */
+       private boolean skipBrackets() {
+               if (fToken == Symbols.TokenRBRACKET) {
+                       nextToken();
+                       if (fToken == Symbols.TokenLBRACKET) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+       
+       /**
+        * Reads the next token in backward direction from the heuristic scanner
+        * and sets the fields <code>fToken, fPreviousPosition</code> and <code>fPosition</code>
+        * accordingly.
+        */
+       private void nextToken() {
+               nextToken(fPosition);
+       }
+       
+       /**
+        * Reads the next token in backward direction of <code>start</code> from
+        * the heuristic scanner and sets the fields <code>fToken, fPreviousPosition</code>
+        * and <code>fPosition</code> accordingly.
+        */
+       private void nextToken(int start) {
+               fToken= fScanner.previousToken(start - 1, JavaHeuristicScanner.UNBOUND);
+               fPreviousPos= start;
+               fPosition= fScanner.getPosition() + 1;
+               try {
+                       fLine= fDocument.getLineOfOffset(fPosition);
+               } catch (BadLocationException e) {
+                       fLine= -1;
+               }
+       }
+       
+       /**
+        * Returns <code>true</code> if the current tokens look like a method
+        * declaration header (i.e. only the return type and method name). The
+        * heuristic calls <code>nextToken</code> and expects an identifier
+        * (method name) and a type declaration (an identifier with optional 
+        * brackets) which also covers the visibility modifier of constructors; it
+        * does not recognize package visible constructors. 
+        * 
+        * @return <code>true</code> if the current position looks like a method
+        *         declaration header.
+        */
+       private boolean looksLikeMethodDecl() {
+               /*
+                * TODO This heuristic does not recognize package private constructors
+                * since those do have neither type nor visibility keywords.
+                * One option would be to go over the parameter list, but that might
+                * be empty as well - hard to do without an AST...
+                */
+               
+               nextToken();
+               if (fToken == Symbols.TokenIDENT) { // method name
+                       do nextToken();
+                       while (skipBrackets()); // optional brackets for array valued return types
+                       return fToken == Symbols.TokenIDENT; // type name
+                       
+               }
+               return false;
+       }
+       
+       /**
+        * Returns <code>true</code> if the current tokens look like a method
+        * call header (i.e. an identifier as opposed to a keyword taking parenthesized
+        * parameters such as <code>if</code>).
+        * <p>The heuristic calls <code>nextToken</code> and expects an identifier
+        * (method name).
+        * 
+        * @return <code>true</code> if the current position looks like a method call
+        *         header.
+        */
+       private boolean looksLikeMethodCall() {
+               nextToken();
+               return fToken == Symbols.TokenIDENT; // method name
+       }
+       
+       /**
+        * Scans tokens for the matching opening peer. The internal cursor
+        * (<code>fPosition</code>) is set to the offset of the opening peer if found.
+        * 
+        * @return <code>true</code> if a matching token was found, <code>false</code>
+        *         otherwise
+        */
+       private boolean skipScope(int openToken, int closeToken) {
+               
+               int depth= 1;
+
+               while (true) {
+                       nextToken();
+                       
+                       if (fToken == closeToken) {
+                               depth++;
+                       } else if (fToken == openToken) {
+                               depth--;
+                               if (depth == 0)
+                                       return true;
+                       } else if (fToken == Symbols.TokenEOF) {
+                                       return false;
+                       }
+               }
+       }
+
+       // TODO adjust once there are per-project settings
+       
+       private int prefTabLength() {
+               int tabLen;
+//             JavaCore core= JavaCore.getJavaCore();
+               PHPeclipsePlugin plugin= PHPeclipsePlugin.getDefault();
+//             if (core != null && plugin != null)
+                 if (plugin != null)
+                       if (JavaCore.SPACE.equals(JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)))
+                               // if the formatter uses chars to mark indentation, then don't substitute any chars
+                               tabLen= -1; // results in no tabs being substituted for space runs
+                       else
+                               // if the formatter uses tabs to mark indentations, use the visual setting from the editor 
+                               // to get nicely aligned indentations
+                               tabLen= plugin.getPreferenceStore().getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
+               else
+                       tabLen= 4; // sensible default for testing
+
+               return tabLen;
+       }
+       
+       private boolean prefArrayDimensionsDeepIndent() {
+               return true; // sensible default
+       }
+
+       private int prefArrayIndent() {
+               Plugin plugin= JavaCore.getPlugin();
+               if (plugin != null) {
+                       String option= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER);
+                       try {
+                               if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
+                                       return 1;
+                       } catch (IllegalArgumentException e) {
+                               // ignore and return default
+                       }
+               }
+               
+               return prefContinuationIndent(); // default
+       }
+
+       private boolean prefArrayDeepIndent() {
+               Plugin plugin= JavaCore.getPlugin();
+               if (plugin != null) {
+                       String option= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER);
+                       try {
+                               return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
+                       } catch (IllegalArgumentException e) {
+                               // ignore and return default
+                       }
+               }
+               
+               return true;
+       }
+
+       private boolean prefTernaryDeepAlign() {
+               Plugin plugin= JavaCore.getPlugin();
+               if (plugin != null) {
+                       String option= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION);
+                       try {
+                               return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
+                       } catch (IllegalArgumentException e) {
+                               // ignore and return default
+                       }
+               }
+               return false;
+       }
+
+       private int prefTernaryIndent() {
+               Plugin plugin= JavaCore.getPlugin();
+               if (plugin != null) {
+                       String option= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION);
+                       try {
+                               if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
+                                       return 1;
+                               else
+                                       return prefContinuationIndent();
+                       } catch (IllegalArgumentException e) {
+                               // ignore and return default
+                       }
+               }
+               
+               return prefContinuationIndent();
+       }
+
+       private int prefCaseIndent() {
+               Plugin plugin= JavaCore.getPlugin();
+               if (plugin != null) {
+                       if (DefaultCodeFormatterConstants.TRUE.equals(JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH)))
+                               return prefBlockIndent();
+                       else
+                               return 0;
+               }
+               
+               return 0; // sun standard
+       }
+
+       private int prefAssignmentIndent() {
+               return prefBlockIndent();
+       }
+
+       private int prefCaseBlockIndent() {
+               if (true)
+                       return prefBlockIndent();
+               
+               Plugin plugin= JavaCore.getPlugin();
+               if (plugin != null) {
+                       if (DefaultCodeFormatterConstants.TRUE.equals(JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES)))
+                               return prefBlockIndent();
+                       else
+                               return 0;
+               }
+               return prefBlockIndent(); // sun standard
+       }
+
+       private int prefSimpleIndent() {
+               return prefBlockIndent();
+       }
+
+       private int prefBracketIndent() {
+               return prefBlockIndent();
+       }
+
+       private boolean prefMethodDeclDeepIndent() {
+               Plugin plugin= JavaCore.getPlugin();
+               if (plugin != null) {
+                       String option= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
+                       try {
+                               return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
+                       } catch (IllegalArgumentException e) {
+                               // ignore and return default
+                       }
+               }
+               
+               return true;
+       }
+
+       private int prefMethodDeclIndent() {
+               Plugin plugin= JavaCore.getPlugin();
+               if (plugin != null) {
+                       String option= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
+                       try {
+                               if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
+                                       return 1;
+                               else
+                                       return prefContinuationIndent();
+                       } catch (IllegalArgumentException e) {
+                               // ignore and return default
+                       }
+               }
+               return 1;
+       }
+
+       private boolean prefMethodCallDeepIndent() {
+               Plugin plugin= JavaCore.getPlugin();
+               if (plugin != null) {
+                       String option= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
+                       try {
+                               return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
+                       } catch (IllegalArgumentException e) {
+                               // ignore and return default
+                       }
+               }
+               return false; // sensible default
+       }
+
+       private int prefMethodCallIndent() {
+               Plugin plugin= JavaCore.getPlugin();
+               if (plugin != null) {
+                       String option= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
+                       try {
+                               if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
+                                       return 1;
+                               else
+                                       return prefContinuationIndent();
+                       } catch (IllegalArgumentException e) {
+                               // ignore and return default
+                       }
+               }
+               
+               return 1; // sensible default
+       }
+
+       private boolean prefParenthesisDeepIndent() {
+               
+               if (true) // don't do parenthesis deep indentation
+                       return false;
+               
+               Plugin plugin= JavaCore.getPlugin();
+               if (plugin != null) {
+                       String option= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION);
+                       try {
+                               return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
+                       } catch (IllegalArgumentException e) {
+                               // ignore and return default
+                       }
+               }
+               
+               return false; // sensible default
+       }
+
+       private int prefParenthesisIndent() {
+               return prefContinuationIndent();
+       }
+
+       private int prefBlockIndent() {
+               return 1; // sensible default
+       }
+       
+       private boolean prefIndentBracesForBlocks() {
+               Plugin plugin= JavaCore.getPlugin();
+               if (plugin != null) {
+                       String option= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK);
+                       return option.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED);
+               }
+               
+               return false; // sensible default
+       }
+       
+       private boolean prefIndentBracesForArrays() {
+               Plugin plugin= JavaCore.getPlugin();
+               if (plugin != null) {
+                       String option= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER);
+                       return option.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED);
+               }
+               
+               return false; // sensible default
+       }
+       
+       private boolean prefIndentBracesForMethods() {
+               Plugin plugin= JavaCore.getPlugin();
+               if (plugin != null) {
+                       String option= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION);
+                       return option.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED);
+               }
+               
+               return false; // sensible default
+       }
+       
+       private int prefContinuationIndent() {
+               Plugin plugin= JavaCore.getPlugin();
+               if (plugin != null) {
+                       String option= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION);
+                       try {
+                               return Integer.parseInt(option);
+                       } catch (NumberFormatException e) {
+                               // ignore and return default
+                       }
+               }
+               
+               return 2; // sensible default
+       }
+
+}