Goto line/Goto Matching Bracket Shortcuts should work
authorkhartlage <khartlage>
Mon, 21 Jun 2004 20:01:47 +0000 (20:01 +0000)
committerkhartlage <khartlage>
Mon, 21 Jun 2004 20:01:47 +0000 (20:01 +0000)
Open Declaration shows exact matches

22 files changed:
net.sourceforge.phpeclipse/plugin.properties
net.sourceforge.phpeclipse/plugin.xml
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/Compiler.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/SourceElementParser.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/AddBlockCommentAction.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/RemoveBlockCommentAction.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/AbstractAnnotationHover.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/ProblemHover.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/GenerateActionGroup.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/IncludesScanner.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPOpenAllIncludesEditorAction.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPOpenDeclarationEditorAction.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/PHPIdentifierLocation.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/BasicEditorActionContributor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CompilationUnitEditorActionContributor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/EditorUtility.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorMessages.properties
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java

index e03c089..98bbc47 100644 (file)
@@ -83,12 +83,16 @@ CodingActionSet.description= Action set containing coding related PHP actions
 ##########################################################################
 SourceMenu.label= &Source
 
-CommentAction.label= Co&mment@Ctrl+/
+CommentAction.label= Co&mment
 
-UncommentAction.label= &Uncomment@Ctrl+\\
+UncommentAction.label= &Uncomment
 
 ToggleCommentAction.label= Togg&le Comment
 
+AddBlockCommentAction.label= Add &Block Comment
+
+RemoveBlockCommentAction.label= Remove Bloc&k Comment
+
 ShiftRightAction.label= Sh&ift Right
 
 ShiftLeftAction.label= S&hift Left
@@ -133,6 +137,29 @@ CreatePHPDocAction.tooltip= Run PHPDoc Wizard
 PHPWorkingSetPage.name= PHP
 
 
+sourceHover= Source
+sourceHoverDescription= Shows the source of the selected element.
+javadocHover= Javadoc
+javadocHoverDescription= Shows the Javadoc of the selected element.
+sequentialHover= Combined Hover
+sequentialHoverDescription= Tries the hovers in the sequence listed in the table below this one and uses the one which fits best for the selected element and the current context.
+annotationHover= Annotation Description
+annotationHoverDescription= Shows the description of the selected annotation.
+problemHover= Problem Description
+problemHoverDescription= Shows the description of the selected problem.
+
+##########################################################################
+# Action Definitions
+##########################################################################
+
+category.source.name=Source
+category.source.description= PHP Source Actions
+
+context.editingPHPSource.name= Editing PHP Source
+context.editingPHPSource.description= Editing PHP Source Context
+
+scope.javaEditor.name=Java Editor
+
 ##########################################################################
 # Action Definitions
 ##########################################################################
@@ -187,7 +214,7 @@ ActionDefinition.addBlockComment.name= Add Block Comment
 ActionDefinition.addBlockComment.description= Enclose the selection with a block comment
 
 ActionDefinition.removeBlockComment.name= Remove Block Comment
-ActionDefinition.removeBlockComment.description= Remove the block comment around the selection
+ActionDefinition.removeBlockComment.description= Remove the block comment enclosing the selection
 
 ActionDefinition.format.name= Format
 ActionDefinition.format.description= Format the selected text
index 2508d8a..e56035b 100644 (file)
          label="%sourceHover"
          description="%sourceHoverDescription">
    </hover>
-</extension>
-   <extension
-      point="net.sourceforge.phpeclipse.phpEditorTextHovers">
+   <hover
+            label="%problemHover"
+            description="%problemHoverDescription"
+            class="net.sourceforge.phpdt.internal.ui.text.java.hover.ProblemHover"
+            id="net.sourceforge.phpdt.ui.ProblemHover">
+   </hover>
    <hover
          class="net.sourceforge.phpdt.internal.ui.text.java.hover.AnnotationHover"
          id="net.sourceforge.phpdt.ui.AnnotationHover"
       </viewerContribution>
    </extension>
  <!-- =========================================================================== -->
-<!-- JDT/UI command definitions                                                   -->
+<!-- PHPDT/UI command definitions                                                   -->
 <!-- =========================================================================== -->
+   <extension point="org.eclipse.ui.contexts">
+      <context name="%context.editingPHPSource.name" 
+       description="%context.editingPHPSource.description" 
+       parentId="org.eclipse.ui.textEditorScope" 
+       id="net.sourceforge.phpdt.ui.phpEditorScope" /> 
+   </extension>
    <extension
          point="org.eclipse.ui.commands">
       <category
             description="%category.source.description"
             id="net.sourceforge.phpeclipse.ui.category.source">
       </category>
-      <command
-            name="%ActionDefinition.showJavadoc.name"
-            description="%ActionDefinition.showJavadoc.description"
-            category="org.eclipse.ui.category.edit"
-            id="net.sourceforge.phpeclipse.show.javadoc">
-      </command>
-      <keyBinding
-            string="F2"
-            scope="net.sourceforge.phpdt.ui.phpEditorScope"
-            command="net.sourceforge.phpeclipse.show.javadoc"
-            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
-      </keyBinding>
       
  <!-- source -->
       <command
             category="net.sourceforge.phpeclipse.ui.category.source"
             id="net.sourceforge.phpeclipse.phpeditor.uncomment">
       </command>
-      <command
+      <command 
             name="%ActionDefinition.toggleComment.name"
             description="%ActionDefinition.toggleComment.description"
             category="net.sourceforge.phpeclipse.ui.category.source"
             configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
       </keyBinding>
       <keyBinding
+            string="Ctrl+/"
+            scope="net.sourceforge.phpdt.ui.phpEditorScope"
+            command="net.sourceforge.phpeclipse.phpeditor.toggle.comment"
+            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </keyBinding>
+      <keyBinding
+            string="Ctrl+7"
+            scope="net.sourceforge.phpdt.ui.phpEditorScope"
+            command="net.sourceforge.phpeclipse.phpeditor.toggle.comment"
+            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </keyBinding>
+      <keyBinding
             platform="carbon"
             string="Ctrl+Shift+C"
             scope="net.sourceforge.phpdt.ui.phpEditorScope"
             configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
       </keyBinding>
       <keyBinding
+            platform="carbon"
+            string="Ctrl+/"
+            scope="net.sourceforge.phpdt.ui.phpEditorScope"
+            command=""
+            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </keyBinding>
+      <keyBinding
+            platform="carbon"
+            string="Command+/"
+            scope="net.sourceforge.phpdt.ui.phpEditorScope"
+            command="net.sourceforge.phpeclipse.phpeditor.toggle.comment"
+            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </keyBinding>
+      <keyBinding
+            platform="carbon"
+            string="Ctrl+7"
+            scope="net.sourceforge.phpdt.ui.phpEditorScope"
+            command=""
+            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </keyBinding>
+      <keyBinding
+            platform="carbon"
+            string="Command+7"
+            scope="net.sourceforge.phpdt.ui.phpEditorScope"
+            command="net.sourceforge.phpeclipse.phpeditor.toggle.comment"
+            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </keyBinding>
+      <keyBinding
             platform="gtk"
             string="Ctrl+Shift+C"
             scope="net.sourceforge.phpdt.ui.phpEditorScope"
       <keyBinding
             platform="gtk"
             string="Esc Ctrl+C"
-            scope="net.sourceforge.phpdt.ui.phpEditorScope" 
+            scope="net.sourceforge.phpdt.ui.phpEditorScope"
             command="net.sourceforge.phpeclipse.phpeditor.toggle.comment"
             configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
       </keyBinding>
             command="net.sourceforge.phpeclipse.phpeditor.format"
             configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
       </keyBinding>
+      
+      <!-- navigate -->
+      <command
+            name="%ActionDefinition.gotoMatchingBracket.name"
+            description="%ActionDefinition.gotoMatchingBracket.description"
+            category="org.eclipse.ui.category.navigate"
+            id="net.sourceforge.phpeclipse.ui.edit.text.php.goto.matching.bracket">
+      </command>
+      <keyBinding
+            string="Ctrl+Shift+P"
+            scope="net.sourceforge.phpdt.ui.phpEditorScope"
+            command="net.sourceforge.phpeclipse.ui.edit.text.php.goto.matching.bracket"
+            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </keyBinding>
+      <keyBinding
+            platform="carbon"
+            string="Ctrl+Shift+P"
+            scope="net.sourceforge.phpdt.ui.phpEditorScope"
+            command=""
+            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </keyBinding>
+      <keyBinding
+            platform="carbon"
+            string="Command+Shift+P"
+            scope="net.sourceforge.phpdt.ui.phpEditorScope"
+            command="net.sourceforge.phpeclipse.ui.edit.text.php.goto.matching.bracket"
+            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </keyBinding>
    </extension>
    <extension
          id="net.sourceforge.phpeclipse.JavaDocumentSetupParticipant"
       </view>
    </extension>
 
-<!-- =========================================================================== -->
-<!-- PHPDT/UI Editor Key Bindings -->
-<!-- =========================================================================== -->
-   <extension
-         point="org.eclipse.ui.acceleratorSets">
-      <acceleratorSet
-            scopeId="org.eclipse.ui.textEditorScope"
-            configurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
-<!-- edit -->
-         <accelerator
-               key="Ctrl+Shift+P"
-               id="net.sourceforge.phpeclipse.ui.edit.text.php.goto.matching.bracket">
-         </accelerator>
-         <accelerator
-               key="Ctrl+1"
-               id="org.eclipse.ui.edit.text.contentAssist.proposals">
-         </accelerator>
-<!-- source -->
-         <accelerator
-               key="Ctrl+/"
-               id="net.sourceforge.phpeclipse.phpeditor.comment">
-         </accelerator>
-         <accelerator
-               key="Ctrl+\"
-               id="net.sourceforge.phpeclipse.phpeditor.uncomment">
-         </accelerator> 
-         <accelerator
-               key="Ctrl+Shift+F"
-               id="net.sourceforge.phpeclipse.phpeditor.format">
-         </accelerator>
-         <accelerator
-               key="Ctrl+O"
-               id="net.sourceforge.phpeclipse.ui.edit.text.php.show.outline">
-         </accelerator>
-         <accelerator
-               key="Ctrl+F3"
-               id="net.sourceforge.phpeclipse.ui.navigate.php.open.structure">
-         </accelerator>
-      </acceleratorSet>
-      <acceleratorSet
-            scopeId="org.eclipse.ui.textEditorScope"
-            configurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
-<!-- edit -->
-         <accelerator
-               key="Ctrl+Shift+P"
-               id="net.sourceforge.phpeclipse.ui.edit.text.php.goto.matching.bracket">
-         </accelerator>
-         <accelerator
-               key="Ctrl+Space"
-               id="org.eclipse.ui.edit.text.contentAssist.proposals">
-         </accelerator> 
-<!-- source -->
-         <accelerator
-               key="Ctrl+/"
-               id="net.sourceforge.phpeclipse.phpeditor.comment">
-         </accelerator>
-         <accelerator
-               key="Ctrl+\"
-               id="net.sourceforge.phpeclipse.phpeditor.uncomment">
-         </accelerator>
-         <accelerator
-               key="Ctrl+Shift+F"
-               id="net.sourceforge.phpeclipse.phpeditor.format">
-         </accelerator>
-         <accelerator
-               key="Ctrl+F3"
-               id="net.sourceforge.phpeclipse.ui.navigate.php.open.structure">
-         </accelerator>
-         <accelerator
-               key="Ctrl+O"
-               id="net.sourceforge.phpeclipse.ui.edit.text.php.show.outline">
-         </accelerator>
-      </acceleratorSet>
-      <acceleratorSet
-            scopeId="org.eclipse.ui.textEditorScope"
-            configurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
-<!-- edit -->
-         <accelerator
-               platform="carbon"
-               key="Command+Shift+P"
-               id="net.sourceforge.phpeclipse.ui.edit.text.php.goto.matching.bracket">
-         </accelerator>
-         <accelerator
-               platform="carbon"
-               key="Command+1"
-               id="org.eclipse.ui.edit.text.contentAssist.proposals">
-         </accelerator>
-<!-- source -->
-         <accelerator
-               platform="carbon"
-               key="Command+/"
-               id="net.sourceforge.phpeclipse.phpeditor.comment">
-         </accelerator>
-         <accelerator
-               platform="carbon"
-               key="Command+\"
-               id="net.sourceforge.phpeclipse.phpeditor.uncomment">
-         </accelerator> 
-      </acceleratorSet>
-   </extension>
-
 <!-- external tools -->
 
 <!-- extension point definitions -->
index 274b056..ea02cbb 100644 (file)
@@ -30,6 +30,7 @@ import net.sourceforge.phpdt.internal.compiler.problem.ProblemSeverities;
 import net.sourceforge.phpdt.internal.compiler.util.Util;
 import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
 import net.sourceforge.phpeclipse.internal.compiler.ast.TypeDeclaration;
+
 public class Compiler implements ITypeRequestor, ProblemSeverities {
   public UnitParser parser;
   public ICompilerRequestor requestor;
index 21df17c..3ff7c78 100644 (file)
@@ -108,7 +108,9 @@ public class SourceElementParser extends CommentRecorderParser {//extends
     super(new ProblemReporter(DefaultErrorHandlingPolicies.exitAfterAllProblems(), options, problemFactory) {
       public void record(IProblem problem, CompilationResult unitResult, ReferenceContext referenceContext) {
         unitResult.record(problem, referenceContext);
-        requestor.acceptProblem(problem);
+        if (requestor!=null) {
+          requestor.acceptProblem(problem);
+        }
       }
     });
     // true);
@@ -1115,6 +1117,38 @@ public class SourceElementParser extends CommentRecorderParser {//extends
     return null;
   }
 
+  public CompilationUnitDeclaration parseCompletionUnit(ICompilationUnit unit, boolean fullParse) {
+
+    //         boolean old = diet;
+    //         if (fullParse) {
+    //                 unknownRefs = new NameReference[10];
+    //                 unknownRefsCounter = 0;
+    //         }
+
+    try {
+      //                       diet = true;
+      this.reportReferenceInfo = fullParse;
+      CompilationResult compilationUnitResult = new CompilationResult(unit, 0, 0, this.options.maxProblemsPerUnit);
+      CompilationUnitDeclaration parsedUnit = parse(unit, compilationUnitResult, false);
+//      if (scanner.recordLineSeparator) {
+//        requestor.acceptLineSeparatorPositions(scanner.getLineEnds());
+//      }
+//      int initialStart = this.scanner.initialPosition;
+//      int initialEnd = this.scanner.eofPosition;
+//      //                     if (this.localDeclarationVisitor != null || fullParse){
+//      //                             diet = false;
+//      //                             this.getMethodBodies(parsedUnit);
+//      //                     }
+//      this.scanner.resetTo(initialStart, initialEnd);
+//      notifySourceElementRequestor(parsedUnit);
+      return parsedUnit;
+    } catch (AbortCompilation e) {
+      // ignore this exception
+    } finally {
+      //                       diet = old;
+    }
+    return null;
+  }
   //public void parseTypeMemberDeclarations(
   //   ISourceType sourceType,
   //   ICompilationUnit sourceUnit,
index 1f76111..45fa6e4 100644 (file)
@@ -70,7 +70,7 @@ public class Parser //extends PHPParserSuperclass
   //private boolean phpMode;
   protected int modifiers;
   protected int modifiersSourceStart;
-  protected IdentifierIndexManager indexManager;
+//  protected IdentifierIndexManager indexManager;
   
   protected Parser(ProblemReporter problemReporter) {
     this.problemReporter = problemReporter;
@@ -78,7 +78,7 @@ public class Parser //extends PHPParserSuperclass
     this.currentPHPString = 0;
     //         PHPParserSuperclass.fileToParse = fileToParse;
     this.phpList = null;
-    this.indexManager = null;
+//    this.indexManager = null;
     this.str = "";
     this.token = TokenNameEOF;
     //    this.chIndx = 0;
@@ -92,7 +92,7 @@ public class Parser //extends PHPParserSuperclass
     this.currentPHPString = 0;
     //    PHPParserSuperclass.fileToParse = fileToParse;
     this.phpList = null;
-    this.indexManager = null;
+//    this.indexManager = null;
     this.str = "";
     this.token = TokenNameEOF;
     this.phpEnd = false;
@@ -230,7 +230,7 @@ public class Parser //extends PHPParserSuperclass
     compilationUnit = null;
     referenceContext = null;
     includesList = new ArrayList();
-    this.indexManager = indexManager;
+//    this.indexManager = indexManager;
     this.str = "";
     this.token = TokenNameEOF;
     //    this.chIndx = 0;
@@ -1391,9 +1391,12 @@ public class Parser //extends PHPParserSuperclass
     // | class_variable_declaration ',' T_VARIABLE '=' static_scalar
     // | T_VARIABLE
     // | T_VARIABLE '=' static_scalar
+    char[] classVariable;
     do {
       if (token == TokenNameVariable) {
-        FieldDeclaration fieldDeclaration = new FieldDeclaration(scanner.getCurrentIdentifierSource(), scanner
+        classVariable = scanner.getCurrentIdentifierSource();
+      //  indexManager.addIdentifierInformation('v', classVariable, buf, -1, -1);
+        FieldDeclaration fieldDeclaration = new FieldDeclaration(classVariable, scanner
             .getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition());
         fieldDeclaration.modifiers = this.modifiers;
         fieldDeclaration.declarationSourceStart = declarationSourceStart;
index 2da463d..28fc336 100644 (file)
@@ -53,8 +53,9 @@ public class AddBlockCommentAction extends BlockCommentAction {
                int selectionOffset= selection.getOffset();
                int selectionEndOffset= selectionOffset + selection.getLength();
                List edits= new LinkedList();
-               ITypedRegion partition= docExtension.getPartition(IPHPPartitions.PHP_PARTITIONING, selectionOffset, false);
-
+               //ITypedRegion partition= docExtension.getPartition(IPHPPartitions.PHP_PARTITIONING, selectionOffset, false);
+               ITypedRegion partition= docExtension.getPartition(IDocumentExtension3.DEFAULT_PARTITIONING, selectionOffset, false);
+               
                handleFirstPartition(partition, edits, factory, selectionOffset);
 
                while (partition.getOffset() + partition.getLength() < selectionEndOffset) {
@@ -82,7 +83,8 @@ public class AddBlockCommentAction extends BlockCommentAction {
                Assert.isTrue(partOffset <= offset, "illegal partition"); //$NON-NLS-1$
                
                // first partition: mark start of comment
-               if (partType == IDocument.DEFAULT_CONTENT_TYPE) {
+//             if (partType == IDocument.DEFAULT_CONTENT_TYPE) 
+               if (partType == IPHPPartitions.PHP_PARTITIONING) {
                        // Java code: right where selection starts
                        edits.add(factory.createEdit(offset, 0, getCommentStart()));
                } else if (isSpecialPartition(partType)) {
@@ -162,7 +164,8 @@ public class AddBlockCommentAction extends BlockCommentAction {
 
                String partType= partition.getType();
                
-               if (partType == IDocument.DEFAULT_CONTENT_TYPE) {
+//             if (partType == IDocument.DEFAULT_CONTENT_TYPE) {
+        if (partType == IPHPPartitions.PHP_PARTITIONING) {
                        // normal java: end comment where selection ends
                        edits.add(factory.createEdit(endOffset, 0, getCommentEnd()));
                } else if (isSpecialPartition(partType)) {
index 2af8550..38c0291 100644 (file)
@@ -30,7 +30,8 @@ import org.eclipse.ui.texteditor.ITextEditor;
  * @since 3.0
  */
 public class RemoveBlockCommentAction extends BlockCommentAction {
-
+    final static String DEFAULT_PARTITIONING_CONTENT_TYPE = "__dftl_partition_content_type"; //$NON-NLS-1$
+       
        /**
         * Creates a new instance.
         * 
@@ -54,7 +55,9 @@ public class RemoveBlockCommentAction extends BlockCommentAction {
                int offset= selection.getOffset();
                int endOffset= offset + selection.getLength();
 
-               ITypedRegion partition= docExtension.getPartition(IPHPPartitions.PHP_PARTITIONING, offset, false);
+//             ITypedRegion partition= docExtension.getPartition(IPHPPartitions.PHP_PARTITIONING, offset, false);
+               ITypedRegion partition= docExtension.getPartition(IDocumentExtension3.DEFAULT_PARTITIONING, offset, false);
+               
                int partOffset= partition.getOffset();
                int partEndOffset= partOffset + partition.getLength();
                
@@ -65,12 +68,15 @@ public class RemoveBlockCommentAction extends BlockCommentAction {
                                edits.add(factory.createEdit(partEndOffset - tokenLength, tokenLength, "")); //$NON-NLS-1$
                        }
                        
-                       partition= docExtension.getPartition(IPHPPartitions.PHP_PARTITIONING, partEndOffset, false);
+//                     partition= docExtension.getPartition(IPHPPartitions.PHP_PARTITIONING, partEndOffset, false);
+                       partition= docExtension.getPartition(IDocumentExtension3.DEFAULT_PARTITIONING, partEndOffset, false);
+                       
                        partOffset= partition.getOffset();
                        partEndOffset= partOffset + partition.getLength();
                }
 
-               if (partition.getType() == IPHPPartitions.PHP_PHPDOC_COMMENT) {
+//             if (partition.getType() == IPHPPartitions.PHP_PHPDOC_COMMENT) {
+               if (partition.getType() ==   DEFAULT_PARTITIONING_CONTENT_TYPE) {
                        edits.add(factory.createEdit(partOffset, tokenLength, "")); //$NON-NLS-1$
                        edits.add(factory.createEdit(partEndOffset - tokenLength, tokenLength, "")); //$NON-NLS-1$
                }
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/AbstractAnnotationHover.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/AbstractAnnotationHover.java
new file mode 100644 (file)
index 0000000..d87878c
--- /dev/null
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * 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.java.hover;
+
+import java.util.Iterator;
+
+import net.sourceforge.phpdt.internal.ui.text.HTMLPrinter;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import net.sourceforge.phpeclipse.phpeditor.JavaAnnotationIterator;
+import net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.texteditor.AnnotationPreference;
+import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+
+
+/**
+ * Abstract super class for annotation hovers.
+ * 
+ * @since 3.0
+ */
+public abstract class AbstractAnnotationHover extends AbstractJavaEditorTextHover {
+
+       private IPreferenceStore fStore= PHPeclipsePlugin.getDefault().getCombinedPreferenceStore();
+       private DefaultMarkerAnnotationAccess fAnnotationAccess= new DefaultMarkerAnnotationAccess();
+       private boolean fAllAnnotations;
+       
+       
+       public AbstractAnnotationHover(boolean allAnnotations) {
+               fAllAnnotations= allAnnotations;
+       }
+       
+       /*
+        * Formats a message as HTML text.
+        */
+       private String formatMessage(String message) {
+               StringBuffer buffer= new StringBuffer();
+               HTMLPrinter.addPageProlog(buffer);
+               HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(message));
+               HTMLPrinter.addPageEpilog(buffer);
+               return buffer.toString();
+       }
+       
+       /*
+        * @see ITextHover#getHoverInfo(ITextViewer, IRegion)
+        */
+       public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
+               
+               if (getEditor() == null)
+                       return null;
+               
+               IDocumentProvider provider= PHPeclipsePlugin.getDefault().getCompilationUnitDocumentProvider();
+               IAnnotationModel model= provider.getAnnotationModel(getEditor().getEditorInput());
+               
+               if (model != null) {
+                       Iterator e= new JavaAnnotationIterator(model, true, fAllAnnotations);
+                       int layer= -1;
+                       String message= null;
+                       while (e.hasNext()) {
+                               Annotation a= (Annotation) e.next();
+
+                               AnnotationPreference preference= getAnnotationPreference(a);
+                               if (preference == null || !(preference.getTextPreferenceKey() != null && fStore.getBoolean(preference.getTextPreferenceKey()) || (preference.getHighlightPreferenceKey() != null && fStore.getBoolean(preference.getHighlightPreferenceKey()))))
+                                       continue;
+
+                               Position p= model.getPosition(a);
+                               
+                               int l= fAnnotationAccess.getLayer(a);
+                               
+                               if (l > layer && p != null && p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
+                                       String msg= a.getText();
+                                       if (msg != null && msg.trim().length() > 0) {
+                                               message= msg;
+                                               layer= l;
+                                       }
+                               }
+                       }
+                       if (layer > -1)
+                               return formatMessage(message);
+               }
+               
+               return null;
+       }
+       
+       /*
+        * @see IJavaEditorTextHover#setEditor(IEditorPart)
+        */
+       public void setEditor(IEditorPart editor) {
+               if (editor instanceof PHPUnitEditor)
+                       super.setEditor(editor);
+               else
+                       super.setEditor(null);
+       }
+
+       /**
+        * Returns the annotation preference for the given annotation.
+        *
+        * @param annotation the annotation
+        * @return the annotation preference or <code>null</code> if none
+        */     
+       private AnnotationPreference getAnnotationPreference(Annotation annotation) {
+               
+               if (annotation.isMarkedDeleted())
+                       return null;
+               return EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
+       }
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/ProblemHover.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/ProblemHover.java
new file mode 100644 (file)
index 0000000..e7e7a34
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.java.hover;
+
+/**
+ * This annotation hover shows the description of the
+ * selected java annotation.
+ * 
+ * XXX: Currently this problem hover only works for
+ *             Java problems.
+ *             see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=62081
+ *  
+ * @since 3.0
+ */
+public class ProblemHover extends AbstractAnnotationHover {
+
+       public ProblemHover() {
+               super(false);
+       }
+
+}
index 36797b8..40aa451 100644 (file)
@@ -49,6 +49,12 @@ import org.eclipse.ui.texteditor.IUpdate;
  * @since 2.0
  */
 public class GenerateActionGroup extends ActionGroup {
+  /**
+        * Pop-up menu: id of the source sub menu (value <code>org.eclipse.jdt.ui.source.menu</code>).
+        * 
+        * @since 3.0
+        */
+       public static final String MENU_ID= "net.sourceforge.pheclipse.ui.source.menu"; //$NON-NLS-1$
        
   private PHPEditor fEditor;
 //     private boolean fEditorIsOwner;
@@ -252,24 +258,46 @@ public class GenerateActionGroup extends ActionGroup {
        /* (non-Javadoc)
         * Method declared in ActionGroup
         */
+//     public void fillContextMenu(IMenuManager menu) {
+//             super.fillContextMenu(menu);
+//             IMenuManager subMenu= null;
+//             if (isEditorOwner()) {
+//                     subMenu= fillEditorSubMenu(menu);
+//             } else {
+//     //              subMenu= createViewSubMenu(menu);
+//             }
+//             if (subMenu != null)
+//                     menu.appendToGroup(fGroupName, subMenu);
+//     }
        public void fillContextMenu(IMenuManager menu) {
                super.fillContextMenu(menu);
-               IMenuManager subMenu= null;
+               String shortCut= null; //$NON-NLS-1$
+//             if (fQuickAccessAction != null) {
+//                     shortCut= fQuickAccessAction.getShortCutString(); //$NON-NLS-1$
+//             }               
+               IMenuManager subMenu= new MenuManager(
+                       ActionMessages.getString("SourceMenu.label") + (shortCut != null ? "\t" + shortCut : ""), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                       MENU_ID); 
+               int added= 0;
                if (isEditorOwner()) {
-                       subMenu= createEditorSubMenu(menu);
-               } else {
-       //              subMenu= createViewSubMenu(menu);
-               }
-               if (subMenu != null)
+                       added= fillEditorSubMenu(subMenu);
+               } 
+//             else {
+//                     added= fillViewSubMenu(subMenu);
+//             }
+               if (added > 0)
                        menu.appendToGroup(fGroupName, subMenu);
        }
-       
-  private IMenuManager createEditorSubMenu(IMenuManager mainMenu) {
-    IMenuManager result= new MenuManager(ActionMessages.getString("SourceMenu.label")); //$NON-NLS-1$
+  private int fillEditorSubMenu(IMenuManager source) {
+//    IMenuManager result= new MenuManager(ActionMessages.getString("SourceMenu.label")); //$NON-NLS-1$
     int added= 0;
-    added+= addEditorAction(result, "Comment"); //$NON-NLS-1$
-    added+= addEditorAction(result, "Uncomment"); //$NON-NLS-1$
-               added+= addEditorAction(result, "Format"); //$NON-NLS-1$
+    added+= addEditorAction(source, "Comment"); //$NON-NLS-1$
+    added+= addEditorAction(source, "Uncomment"); //$NON-NLS-1$
+    added+= addEditorAction(source, "ToggleComment"); //$NON-NLS-1$
+       added+= addEditorAction(source, "AddBlockComment"); //$NON-NLS-1$
+       added+= addEditorAction(source, "RemoveBlockComment"); //$NON-NLS-1$
+       added+= addEditorAction(source, "Format"); //$NON-NLS-1$
+       added+= addEditorAction(source, "Indent"); //$NON-NLS-1$
 //    result.add(new Separator());
 //    added+= addAction(result, fOrganizeImports);
 //    added+= addAction(result, fAddImport);
@@ -282,9 +310,9 @@ public class GenerateActionGroup extends ActionGroup {
 //    result.add(new Separator());             
 //    added+= addAction(result, fSurroundWithTryCatch);
 //    added+= addAction(result, fExternalizeStrings);
-    if (added == 0)
-      result= null;
-    return result;
+//    if (added == 0)
+//      result= null;
+    return added;
   }
        /* (non-Javadoc)
         * Method declared in ActionGroup
index 439f302..839d1e7 100644 (file)
@@ -6,6 +6,7 @@ import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import net.sourceforge.phpdt.core.compiler.ITerminalSymbols;
 import net.sourceforge.phpdt.core.compiler.InvalidInputException;
@@ -22,13 +23,13 @@ import org.eclipse.ui.IFileEditorInput;
 
 
 public class IncludesScanner implements ITerminalSymbols {
-  private final PHPOpenAllIncludesEditorAction fLineCreator;
+//  private final PHPOpenAllIncludesEditorAction fOpenAllIncludesAction;
   private IProject fProject;
   private IFileEditorInput fEditorInput;
   HashSet fSet;
-  public IncludesScanner(PHPOpenAllIncludesEditorAction action, IProject project, IFileEditorInput editorInput) {
+  public IncludesScanner(IProject project, IFileEditorInput editorInput) {
     fProject = project;
-    this.fLineCreator = action;
+//    fOpenAllIncludesAction = action;
     fEditorInput = editorInput;
     fSet = new HashSet();
   }
@@ -118,8 +119,15 @@ public class IncludesScanner implements ITerminalSymbols {
      // e.printStackTrace();
     }
   }
+  
+  private IContainer getWorkingLocation(IFileEditorInput editorInput) {
+    if (editorInput == null || editorInput.getFile() == null) {
+      return null;
+    }
+    return editorInput.getFile().getParent();
+  }
   public IFile getIncludeFile(String relativeFilename) {
-    IContainer container = this.fLineCreator.getWorkingLocation(fEditorInput);
+    IContainer container = getWorkingLocation(fEditorInput);
     String fullPath = fProject.getLocation().toString();
     IFile file = null;
     if (relativeFilename.startsWith("../")) {
@@ -151,4 +159,10 @@ public class IncludesScanner implements ITerminalSymbols {
     return list;
   }
 
+  /**
+   * @return Returns the set.
+   */
+  public Set getSet() {
+    return fSet;
+  }
 }
\ No newline at end of file
index 5396755..aec734b 100644 (file)
@@ -41,7 +41,7 @@ public class PHPOpenAllIncludesEditorAction extends ActionDelegate implements IE
   private IWorkbenchWindow fWindow;
   private PHPEditor fEditor;
   private IProject fProject;
-  private IncludesScanner fLineCreator;
+  private IncludesScanner fIncludesScanner;
   public void dispose() {
   }
 
@@ -109,22 +109,22 @@ public class PHPOpenAllIncludesEditorAction extends ActionDelegate implements IE
 
       ITextSelection selection = (ITextSelection) fEditor.getSelectionProvider().getSelection();
       IDocument doc = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
-      fLineCreator = new IncludesScanner(this, fProject, (IFileEditorInput) fEditor.getEditorInput());
+      fIncludesScanner = new IncludesScanner(fProject, (IFileEditorInput) fEditor.getEditorInput());
       int pos = selection.getOffset();
       //  System.out.println(selection.getText());
       String filename = getPHPIncludeText(doc, pos);
 
       if (filename != null && !filename.equals("")) {
         try {
-          IFile file = fLineCreator.getIncludeFile(filename);
-          fLineCreator.addFile(file);
+          IFile file = fIncludesScanner.getIncludeFile(filename);
+          fIncludesScanner.addFile(file);
         } catch (Exception e) {
           // ignore
         }
 
         try {
 
-          List list = fLineCreator.getList();
+          List list = fIncludesScanner.getList();
           if (list != null && list.size() > 0) {
             String workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString();
 
index a582f1f..c4e5d76 100644 (file)
@@ -1,16 +1,18 @@
-/**********************************************************************
-Copyright (c) 2000, 2002 IBM Corp. 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:
-    Klaus Hartlage - www.eclipseproject.de
-**********************************************************************/
+/*******************************************************************************
+ * Copyright (c) 2000, 2002 IBM Corp. 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: Klaus Hartlage - www.eclipseproject.de
+ ******************************************************************************/
 package net.sourceforge.phpeclipse.actions;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
+import java.util.Set;
 
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.builder.IdentifierIndexManager;
@@ -38,10 +40,64 @@ import org.eclipse.ui.actions.ActionDelegate;
 import org.eclipse.ui.dialogs.ListSelectionDialog;
 import org.eclipse.ui.internal.dialogs.ListContentProvider;
 
-public class PHPOpenDeclarationEditorAction extends ActionDelegate implements IEditorActionDelegate {
+public class PHPOpenDeclarationEditorAction extends ActionDelegate implements
+    IEditorActionDelegate {
+
+//  class Include implements Comparable {
+//    final public static int UNDEFINED_MATCH = 0;
+//    final public static int PATTERN_MATCH = 1;
+//    final public static int EXACT_MATCH = 2;
+//
+//    String fName;
+//
+//    int fMatch;
+//
+//    public Include(String name, int match) {
+//      fName = name;
+//      fMatch = match;
+//    }
+//
+//    /*
+//     * (non-Javadoc)
+//     * 
+//     * @see java.lang.Object#toString()
+//     */
+//    public String toString() {
+//      switch (fMatch) {
+//      case UNDEFINED_MATCH:
+//        return fName;
+//      case PATTERN_MATCH:
+//        return "[pattern included] " + fName;
+//      case EXACT_MATCH:
+//        return "[included] " + fName;
+//      }
+//      return fName;
+//    }
+//
+//    /**
+//     * @return Returns the name.
+//     */
+//    public String getName() {
+//      return fName;
+//    }
+//    /* (non-Javadoc)
+//     * @see java.lang.Comparable#compareTo(java.lang.Object)
+//     */
+//    public int compareTo(Object o) {
+//      Include i = (Include)o;
+//      if (fMatch>i.fMatch) {
+//        return 1;
+//      } else if (fMatch<i.fMatch) {
+//        return -1;
+//      }
+//      return fName.compareTo(i.fName);
+//    }
+//  }
 
   private IWorkbenchWindow fWindow;
+
   private PHPEditor fEditor;
+
   private IProject fProject;
 
   public void dispose() {
@@ -55,7 +111,8 @@ public class PHPOpenDeclarationEditorAction extends ActionDelegate implements IE
     if (!selection.isEmpty()) {
       if (selection instanceof TextSelection) {
         action.setEnabled(true);
-      } else if (fWindow.getActivePage() != null && fWindow.getActivePage().getActivePart() != null) {
+      } else if (fWindow.getActivePage() != null
+          && fWindow.getActivePage().getActivePart() != null) {
         //
       }
     }
@@ -74,26 +131,46 @@ public class PHPOpenDeclarationEditorAction extends ActionDelegate implements IE
       fProject = f.getProject();
       //      System.out.println(fProject.toString());
 
-      ITextSelection selection = (ITextSelection) fEditor.getSelectionProvider().getSelection();
-      IDocument doc = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
+      ITextSelection selection = (ITextSelection) fEditor
+          .getSelectionProvider().getSelection();
+      IDocument doc = fEditor.getDocumentProvider().getDocument(
+          fEditor.getEditorInput());
       int pos = selection.getOffset();
-    //  System.out.println(selection.getText());
+      //  System.out.println(selection.getText());
       String word = getPHPIdentifier(doc, pos);
       //      System.out.println(word);
       if (word != null && !word.equals("")) {
-        IdentifierIndexManager indexManager = PHPeclipsePlugin.getDefault().getIndexManager(fProject);
-        List list = indexManager.getLocations(word);
-        if (list != null && list.size() > 0) {
-          String workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString();
+        IdentifierIndexManager indexManager = PHPeclipsePlugin.getDefault()
+            .getIndexManager(fProject);
+        List locationsList = indexManager.getLocations(word);
+        if (locationsList != null && locationsList.size() > 0) {
+
+          String workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot()
+              .getLocation().toString();
           // TODO show all entries of the list in a dialog box
           // at the moment always the first entry will be opened
-          if (list.size() > 1) {
-            ListSelectionDialog listSelectionDialog =
-              new ListSelectionDialog(
-                PHPeclipsePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
-                list,
-                new ListContentProvider(),
-                new LabelProvider(),
+          if (locationsList.size() > 1) {
+            // determine all includes:
+            IncludesScanner includesScanner = new IncludesScanner(fProject,
+                (IFileEditorInput) fEditor.getEditorInput());
+            includesScanner.addFile(f);
+            Set exactIncludeSet = includesScanner.getSet();
+
+            PHPIdentifierLocation includeName;
+            for (int i = 0; i < locationsList.size(); i++) {
+              includeName = (PHPIdentifierLocation) locationsList.get(i);
+              if (exactIncludeSet.contains(includeName.getFilename())) {
+                includeName.setMatch(PHPIdentifierLocation.EXACT_MATCH);
+              } else {
+                includeName.setMatch(PHPIdentifierLocation.UNDEFINED_MATCH);
+              }
+            }
+            Collections.sort(locationsList);
+            
+            ListSelectionDialog listSelectionDialog = new ListSelectionDialog(
+                PHPeclipsePlugin.getDefault().getWorkbench()
+                    .getActiveWorkbenchWindow().getShell(), locationsList,
+                new ListContentProvider(), new LabelProvider(),
                 "Select the resources to open.");
             listSelectionDialog.setTitle("Multiple declarations found");
             if (listSelectionDialog.open() == Window.OK) {
@@ -102,12 +179,15 @@ public class PHPOpenDeclarationEditorAction extends ActionDelegate implements IE
                 try {
                   for (int i = 0; i < locations.length; i++) {
                     PHPIdentifierLocation location = (PHPIdentifierLocation) locations[i];
-                    String filename = workspaceLocation + location.getFilename();
+                    String filename = workspaceLocation
+                        + location.getFilename();
                     //                                 System.out.println(filename);
                     if (location.getOffset() >= 0) {
-                      PHPeclipsePlugin.getDefault().openFileAndGotoOffset(filename, location.getOffset(), word.length());
+                      PHPeclipsePlugin.getDefault().openFileAndGotoOffset(
+                          filename, location.getOffset(), word.length());
                     } else {
-                      PHPeclipsePlugin.getDefault().openFileAndFindString(filename, word);
+                      PHPeclipsePlugin.getDefault().openFileAndFindString(
+                          filename, word);
                     }
                   }
                 } catch (CoreException e) {
@@ -118,13 +198,16 @@ public class PHPOpenDeclarationEditorAction extends ActionDelegate implements IE
             }
           } else {
             try {
-              PHPIdentifierLocation location = (PHPIdentifierLocation) list.get(0);
+              PHPIdentifierLocation location = (PHPIdentifierLocation) locationsList
+                  .get(0);
               String filename = workspaceLocation + location.getFilename();
               //                                       System.out.println(filename);
               if (location.getOffset() >= 0) {
-                PHPeclipsePlugin.getDefault().openFileAndGotoOffset(filename, location.getOffset(), word.length());
+                PHPeclipsePlugin.getDefault().openFileAndGotoOffset(filename,
+                    location.getOffset(), word.length());
               } else {
-                PHPeclipsePlugin.getDefault().openFileAndFindString(filename, word);
+                PHPeclipsePlugin.getDefault().openFileAndFindString(filename,
+                    word);
               }
             } catch (CoreException e) {
               // TODO Auto-generated catch block
@@ -152,4 +235,4 @@ public class PHPOpenDeclarationEditorAction extends ActionDelegate implements IE
     }
     return "";
   }
-}
+}
\ No newline at end of file
index 982d0ef..03810ee 100644 (file)
@@ -630,6 +630,14 @@ public class IdentifierIndexManager {
           // offset information
           identifier = null;
           break;
+        case 'p' :
+          // PHPdoc offset information
+          identifier = null;
+          break;
+        case 'l' :
+          // PHPdoc length information
+          identifier = null;
+          break;
         case 'v' :
           // variable inside a class
           identifier = token.substring(1);
index b374ff5..57886e6 100644 (file)
@@ -3,37 +3,53 @@ package net.sourceforge.phpeclipse.builder;
 import net.sourceforge.phpeclipse.obfuscator.PHPIdentifier;
 
 /**
- *
+ *  
  */
-public class PHPIdentifierLocation extends PHPIdentifier {
+public class PHPIdentifierLocation extends PHPIdentifier implements Comparable {
+  final public static int UNDEFINED_MATCH = 0;
+  final public static int PATTERN_MATCH = 1;
+  final public static int EXACT_MATCH = 2;
+
+  private int fMatch;
+
   private String fClassname;
+
   private String fFilename;
-       private int fOffset;
-       private int fPHPDocLength;
-       private int fPHPDocOffset;
-       private String fUsage;
+
+  private int fOffset;
+
+  private int fPHPDocLength;
+
+  private int fPHPDocOffset;
+
+  private String fUsage;
 
   public PHPIdentifierLocation(String identifier, int type, String filename) {
     this(identifier, type, filename, null);
   }
 
-       public PHPIdentifierLocation(String identifier, int type, String filename, String classname) {
-               super(identifier, type);
-               fFilename = filename;
-               fClassname = classname;
-               fOffset = -1;
-               fPHPDocLength = -1;
-               fPHPDocOffset = -1;
-               fUsage = null;
-       }
-  /* (non-Javadoc)
+  public PHPIdentifierLocation(String identifier, int type, String filename,
+      String classname) {
+    super(identifier, type);
+    fFilename = filename;
+    fClassname = classname;
+    fOffset = -1;
+    fPHPDocLength = -1;
+    fPHPDocOffset = -1;
+    fUsage = null;
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
    * @see java.lang.Object#equals(java.lang.Object)
    */
   public boolean equals(Object obj) {
-               if (!(obj instanceof PHPIdentifierLocation)) {
-                       return false;
-               }
-    return super.equals(obj)&&fFilename.equals(((PHPIdentifierLocation)obj).fFilename);
+    if (!(obj instanceof PHPIdentifierLocation)) {
+      return false;
+    }
+    return super.equals(obj)
+        && fFilename.equals(((PHPIdentifierLocation) obj).fFilename);
   }
 
   /**
@@ -120,11 +136,51 @@ public class PHPIdentifierLocation extends PHPIdentifier {
     fUsage = string;
   }
 
-  /* (non-Javadoc)
+  /*
+   * (non-Javadoc)
+   * 
    * @see java.lang.Object#toString()
    */
   public String toString() {
-    return super.toString()+"\n"+fFilename;
+    String result=null;
+    switch (fMatch) {
+    case UNDEFINED_MATCH:
+      result = " [";
+      break;
+    case PATTERN_MATCH:
+      result = " [pattern include][";
+      break;
+    case EXACT_MATCH:
+      result = " [exact include][";
+      break;
+     default:
+       result = "";
+    }
+    return super.toString() + result + fFilename+"]";
   }
 
-}
+  /* (non-Javadoc)
+   * @see java.lang.Comparable#compareTo(java.lang.Object)
+   */
+  public int compareTo(Object o) {
+    PHPIdentifierLocation i = (PHPIdentifierLocation)o;
+    if (fMatch>i.fMatch) {
+      return -1;
+    } else if (fMatch<i.fMatch) {
+      return 1;
+    }
+    return fFilename.compareTo(i.fFilename);
+  }
+  /**
+   * @return Returns the match.
+   */
+  public int getMatch() {
+    return fMatch;
+  }
+  /**
+   * @param match The match to set.
+   */
+  public void setMatch(int match) {
+    fMatch = match;
+  }
+}
\ No newline at end of file
index b106a93..95f1105 100644 (file)
@@ -31,7 +31,7 @@ public class BasicEditorActionContributor extends BasicJavaEditorActionContribut
        
        protected RetargetAction fRetargetContentAssist;
        protected RetargetTextEditorAction fContentAssist;
-       protected RetargetTextEditorAction fContextInformation;
+//     protected RetargetTextEditorAction fContextInformation;
 //     protected RetargetTextEditorAction fCorrectionAssist;
        private EncodingActionGroup fEncodingActionGroup;
        
@@ -47,8 +47,8 @@ public class BasicEditorActionContributor extends BasicJavaEditorActionContribut
                fContentAssist.setImageDescriptor(PHPUiImages.DESC_CLCL_CODE_ASSIST);
                fContentAssist.setDisabledImageDescriptor(PHPUiImages.DESC_DLCL_CODE_ASSIST);
                
-               fContextInformation= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistContextInformation."); //$NON-NLS-1$
-               fContextInformation.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
+//             fContextInformation= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistContextInformation."); //$NON-NLS-1$
+//             fContextInformation.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
                
 //             fCorrectionAssist= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "CorrectionAssistProposal."); //$NON-NLS-1$
 //             fCorrectionAssist.setActionDefinitionId(PHPEditorActionDefinitionIds.CORRECTION_ASSIST_PROPOSALS);
@@ -68,13 +68,13 @@ public class BasicEditorActionContributor extends BasicJavaEditorActionContribut
                if (editMenu != null) {
                        editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fRetargetContentAssist);
 //                     editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fCorrectionAssist);                        
-                       editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fContextInformation);
+//                     editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fContextInformation);
                }               
        }
        
        /*
         * @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
-        */
+        */ 
        public void setActiveEditor(IEditorPart part) {
                super.setActiveEditor(part);
                                
@@ -83,7 +83,7 @@ public class BasicEditorActionContributor extends BasicJavaEditorActionContribut
                        textEditor= (ITextEditor) part;
                        
                fContentAssist.setAction(getAction(textEditor, "ContentAssistProposal")); //$NON-NLS-1$
-               fContextInformation.setAction(getAction(textEditor, "ContentAssistContextInformation")); //$NON-NLS-1$
+//             fContextInformation.setAction(getAction(textEditor, "ContentAssistContextInformation")); //$NON-NLS-1$
 //             fCorrectionAssist.setAction(getAction(textEditor, "CorrectionAssistProposal")); //$NON-NLS-1$
                
                IActionBars actionBars= getActionBars();
index 805895b..6eea5b8 100644 (file)
@@ -49,12 +49,12 @@ public class CompilationUnitEditorActionContributor
                                getAction(textEditor, "ToggleComment")); //$NON-NLS-1$
                bars.setGlobalActionHandler(PHPdtActionConstants.FORMAT, getAction(
                                textEditor, "Format")); //$NON-NLS-1$
-               bars.setGlobalActionHandler(PHPdtActionConstants.ADD_BLOCK_COMMENT,
-                               getAction(textEditor, "AddBlockComment")); //$NON-NLS-1$
-               bars.setGlobalActionHandler(PHPdtActionConstants.REMOVE_BLOCK_COMMENT,
-                               getAction(textEditor, "RemoveBlockComment")); //$NON-NLS-1$
-               bars.setGlobalActionHandler(PHPdtActionConstants.INDENT, getAction(
-                               textEditor, "Indent")); //$NON-NLS-1$ //$NON-NLS-2$
+//             bars.setGlobalActionHandler(PHPdtActionConstants.ADD_BLOCK_COMMENT,
+//                             getAction(textEditor, "AddBlockComment")); //$NON-NLS-1$
+//             bars.setGlobalActionHandler(PHPdtActionConstants.REMOVE_BLOCK_COMMENT,
+//                             getAction(textEditor, "RemoveBlockComment")); //$NON-NLS-1$
+//             bars.setGlobalActionHandler(PHPdtActionConstants.INDENT, getAction(
+//                             textEditor, "Indent")); //$NON-NLS-1$ //$NON-NLS-2$
 
                if (textEditor != null) {
                        IFile file = null;
index 097261a..b951472 100644 (file)
@@ -14,14 +14,17 @@ package net.sourceforge.phpeclipse.phpeditor;
 
 import net.sourceforge.phpdt.core.ICompilationUnit;
 import net.sourceforge.phpdt.core.IJavaElement;
+import net.sourceforge.phpdt.core.IJavaProject;
 import net.sourceforge.phpdt.core.IMember;
 import net.sourceforge.phpdt.core.IWorkingCopy;
+import net.sourceforge.phpdt.core.JavaCore;
 import net.sourceforge.phpdt.core.JavaModelException;
 import net.sourceforge.phpdt.internal.corext.util.JavaModelUtil;
 import net.sourceforge.phpdt.ui.JavaUI;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 
 import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.jface.action.Action;
 import org.eclipse.swt.SWT;
@@ -365,4 +368,29 @@ public class EditorUtility {
                        return newModifierString;
                return PHPEditorMessages.getFormattedString("EditorUtility.concatModifierStrings", new String[] {modifierString, newModifierString}); //$NON-NLS-1$
        }
+       
+       /**
+        * Returns the Java project for a given editor input or <code>null</code> if no corresponding
+        * Java project exists.
+        * 
+        * @param input the editor input
+        * @return the corresponding Java project
+        * 
+        * @since 3.0
+        */
+       public static IJavaProject getJavaProject(IEditorInput input) {
+               IJavaProject jProject= null;
+               if (input instanceof IFileEditorInput) {
+                       IProject project= ((IFileEditorInput)input).getFile().getProject();
+                       if (project != null) {
+                               jProject= JavaCore.create(project);
+                               if (!jProject.exists())
+                                       jProject= null;
+                       }
+               } 
+//             else if (input instanceof IClassFileEditorInput) {
+//                     jProject= ((IClassFileEditorInput)input).getClassFile().getJavaProject();
+//             }
+               return jProject;
+       }
 }
index a4f0ef5..3da3755 100644 (file)
@@ -21,6 +21,7 @@ import java.util.StringTokenizer;
 
 import net.sourceforge.phpdt.core.ICompilationUnit;
 import net.sourceforge.phpdt.core.IJavaElement;
+import net.sourceforge.phpdt.core.IJavaProject;
 import net.sourceforge.phpdt.core.IMember;
 import net.sourceforge.phpdt.core.ISourceRange;
 import net.sourceforge.phpdt.core.ISourceReference;
@@ -32,6 +33,7 @@ import net.sourceforge.phpdt.internal.ui.text.CustomSourceInformationControl;
 import net.sourceforge.phpdt.internal.ui.text.HTMLTextPresenter;
 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
 import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher;
+import net.sourceforge.phpdt.internal.ui.text.PreferencesAdapter;
 import net.sourceforge.phpdt.internal.ui.viewsupport.IViewPartInputProvider;
 import net.sourceforge.phpdt.ui.IContextMenuConstants;
 import net.sourceforge.phpdt.ui.JavaUI;
@@ -87,6 +89,7 @@ import org.eclipse.jface.text.source.SourceViewerConfiguration;
 import org.eclipse.jface.text.source.projection.ProjectionSupport;
 import org.eclipse.jface.text.source.projection.ProjectionViewer;
 import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.ListenerList;
 import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -128,9 +131,11 @@ import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.actions.ActionContext;
 import org.eclipse.ui.actions.ActionGroup;
 import org.eclipse.ui.editors.text.DefaultEncodingSupport;
+import org.eclipse.ui.editors.text.EditorsUI;
 import org.eclipse.ui.editors.text.IEncodingSupport;
 import org.eclipse.ui.part.IShowInTargetList;
 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
+import org.eclipse.ui.texteditor.ChainedPreferenceStore;
 import org.eclipse.ui.texteditor.DefaultRangeIndicator;
 import org.eclipse.ui.texteditor.IDocumentProvider;
 import org.eclipse.ui.texteditor.IEditorStatusLine;
@@ -186,6 +191,387 @@ public abstract class PHPEditor  extends AbstractDecoratedTextEditor implements
     }
   };
 
+  /**
+        * Adapts an options {@link java.util.Map} to {@link org.eclipse.jface.preference.IPreferenceStore}.
+        * <p>
+        * This preference store is read-only i.e. write access
+        * throws an {@link java.lang.UnsupportedOperationException}.
+        * </p>
+        * 
+        * @since 3.0
+        */
+       private static class OptionsAdapter implements IPreferenceStore {
+
+
+               /**
+                * A property change event filter.
+                */
+               public interface IPropertyChangeEventFilter {
+
+                       /**
+                        * Should the given event be filtered?
+                        * @param event The property change event.
+                        * @return <code>true</code> iff the given event should be filtered.
+                        */
+                       public boolean isFiltered(PropertyChangeEvent event);
+
+               }
+               /**
+                * Property change listener. Listens for events in the options Map and
+                * fires a {@link org.eclipse.jface.util.PropertyChangeEvent}
+                * on this adapter with arguments from the received event.
+                */
+               private class PropertyChangeListener implements IPropertyChangeListener {
+
+                       /**
+                        * {@inheritDoc}
+                        */
+                       public void propertyChange(PropertyChangeEvent event) {
+                               if (getFilter().isFiltered(event))
+                                       return;
+                               
+                               if (event.getNewValue() == null)
+                                       fOptions.remove(event.getProperty());
+                               else
+                                       fOptions.put(event.getProperty(), event.getNewValue());
+                               
+                               firePropertyChangeEvent(event.getProperty(), event.getOldValue(), event.getNewValue());
+                       }
+               }
+
+               /** Listeners on this adapter */
+               private ListenerList fListeners= new ListenerList();
+
+               /** Listener on the adapted options Map */
+               private IPropertyChangeListener fListener= new PropertyChangeListener();
+
+               /** Adapted options Map */
+               private Map fOptions;
+
+               /** Preference store through which events are received. */
+               private IPreferenceStore fMockupPreferenceStore;
+
+               /** Property event filter. */
+               private IPropertyChangeEventFilter fFilter;
+               
+               /**
+                * Initialize with the given options.
+                * 
+                * @param options The options to wrap
+                * @param mockupPreferenceStore the mock-up preference store
+                * @param filter the property change filter
+                */
+               public OptionsAdapter(Map options, IPreferenceStore mockupPreferenceStore, IPropertyChangeEventFilter filter) {
+                       fMockupPreferenceStore= mockupPreferenceStore;
+                       fOptions= options;
+                       setFilter(filter);
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public void addPropertyChangeListener(IPropertyChangeListener listener) {
+                       if (fListeners.size() == 0)
+                               fMockupPreferenceStore.addPropertyChangeListener(fListener);
+                       fListeners.add(listener);
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public void removePropertyChangeListener(IPropertyChangeListener listener) {
+                       fListeners.remove(listener);
+                       if (fListeners.size() == 0)
+                               fMockupPreferenceStore.removePropertyChangeListener(fListener);
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public boolean contains(String name) {
+                       return fOptions.containsKey(name);
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
+                       PropertyChangeEvent event= new PropertyChangeEvent(this, name, oldValue, newValue);
+                       Object[] listeners= fListeners.getListeners();
+                       for (int i= 0; i < listeners.length; i++)
+                               ((IPropertyChangeListener) listeners[i]).propertyChange(event);
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public boolean getBoolean(String name) {
+                       boolean value= BOOLEAN_DEFAULT_DEFAULT;
+                       String s= (String) fOptions.get(name);
+                       if (s != null)
+                               value= s.equals(TRUE);
+                       return value;
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public boolean getDefaultBoolean(String name) {
+                       return BOOLEAN_DEFAULT_DEFAULT;
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public double getDefaultDouble(String name) {
+                       return DOUBLE_DEFAULT_DEFAULT;
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public float getDefaultFloat(String name) {
+                       return FLOAT_DEFAULT_DEFAULT;
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public int getDefaultInt(String name) {
+                       return INT_DEFAULT_DEFAULT;
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public long getDefaultLong(String name) {
+                       return LONG_DEFAULT_DEFAULT;
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public String getDefaultString(String name) {
+                       return STRING_DEFAULT_DEFAULT;
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public double getDouble(String name) {
+                       double value= DOUBLE_DEFAULT_DEFAULT;
+                       String s= (String) fOptions.get(name);
+                       if (s != null) {
+                               try {
+                                       value= new Double(s).doubleValue();
+                               } catch (NumberFormatException e) {
+                               }
+                       }
+                       return value;
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public float getFloat(String name) {
+                       float value= FLOAT_DEFAULT_DEFAULT;
+                       String s= (String) fOptions.get(name);
+                       if (s != null) {
+                               try {
+                                       value= new Float(s).floatValue();
+                               } catch (NumberFormatException e) {
+                               }
+                       }
+                       return value;
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public int getInt(String name) {
+                       int value= INT_DEFAULT_DEFAULT;
+                       String s= (String) fOptions.get(name);
+                       if (s != null) {
+                               try {
+                                       value= new Integer(s).intValue();
+                               } catch (NumberFormatException e) {
+                               }
+                       }
+                       return value;
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public long getLong(String name) {
+                       long value= LONG_DEFAULT_DEFAULT;
+                       String s= (String) fOptions.get(name);
+                       if (s != null) {
+                               try {
+                                       value= new Long(s).longValue();
+                               } catch (NumberFormatException e) {
+                               }
+                       }
+                       return value;
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public String getString(String name) {
+                       String value= (String) fOptions.get(name);
+                       if (value == null)
+                               value= STRING_DEFAULT_DEFAULT;
+                       return value;
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public boolean isDefault(String name) {
+                       return false;
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public boolean needsSaving() {
+                       return !fOptions.isEmpty();
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public void putValue(String name, String value) {
+                       throw new UnsupportedOperationException();
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public void setDefault(String name, double value) {
+                       throw new UnsupportedOperationException();
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public void setDefault(String name, float value) {
+                       throw new UnsupportedOperationException();
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public void setDefault(String name, int value) {
+                       throw new UnsupportedOperationException();
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public void setDefault(String name, long value) {
+                       throw new UnsupportedOperationException();
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public void setDefault(String name, String defaultObject) {
+                       throw new UnsupportedOperationException();
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public void setDefault(String name, boolean value) {
+                       throw new UnsupportedOperationException();
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public void setToDefault(String name) {
+                       throw new UnsupportedOperationException();
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public void setValue(String name, double value) {
+                       throw new UnsupportedOperationException();
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public void setValue(String name, float value) {
+                       throw new UnsupportedOperationException();
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public void setValue(String name, int value) {
+                       throw new UnsupportedOperationException();
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public void setValue(String name, long value) {
+                       throw new UnsupportedOperationException();
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public void setValue(String name, String value) {
+                       throw new UnsupportedOperationException();
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               public void setValue(String name, boolean value) {
+                       throw new UnsupportedOperationException();
+               }
+
+               /**
+                * Returns the adapted options Map.
+                * 
+                * @return Returns the adapted options Map.
+                */
+               public Map getOptions() {
+                       return fOptions;
+               }
+
+               /**
+                * Returns the mock-up preference store, events are received through this preference store.
+                * @return Returns the mock-up preference store.
+                */
+               public IPreferenceStore getMockupPreferenceStore() {
+                       return fMockupPreferenceStore;
+               }
+
+               /**
+                * Set the event filter to the given filter.
+                * 
+                * @param filter The new filter.
+                */
+               public void setFilter(IPropertyChangeEventFilter filter) {
+                       fFilter= filter;
+               }
+               
+               /**
+                * Returns the event filter.
+                * 
+                * @return The event filter.
+                */
+               public IPropertyChangeEventFilter getFilter() {
+                       return fFilter;
+               }
+       }
   /*
   * Link mode.  
   */
@@ -1215,20 +1601,48 @@ public abstract class PHPEditor  extends AbstractDecoratedTextEditor implements
    */
   public PHPEditor() {
     super();
-       JavaTextTools textTools= PHPeclipsePlugin.getDefault().getJavaTextTools();
-       setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools, this)); //, IJavaPartitions.JAVA_PARTITIONING));
-       setRangeIndicator(new DefaultRangeIndicator());
-       IPreferenceStore store= PHPeclipsePlugin.getDefault().getPreferenceStore();
-       setPreferenceStore(store);
-       setKeyBindingScopes(new String[] { "net.sourceforge.phpdt.ui.phpEditorScope" });  //$NON-NLS-1$
-//     fMarkOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
-//     fStickyOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_STICKY_OCCURRENCES);
-    
-       // TODO changed in 3.x ?
-    if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE))
-      fUpdater= new OutlinePageSelectionUpdater();
   }
  
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#initializeKeyBindingScopes()
+        */
+       protected void initializeKeyBindingScopes() {
+               setKeyBindingScopes(new String[] { "net.sourceforge.phpdt.ui.phpEditorScope" });  //$NON-NLS-1$
+       }
+       
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#initializeEditor()
+        */
+       protected void initializeEditor() {
+         //jsurfer old code
+               JavaTextTools textTools= PHPeclipsePlugin.getDefault().getJavaTextTools();
+               setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools, this)); //, IJavaPartitions.JAVA_PARTITIONING));
+               setRangeIndicator(new DefaultRangeIndicator());
+//             IPreferenceStore store= PHPeclipsePlugin.getDefault().getPreferenceStore();
+//             setPreferenceStore(store);
+               IPreferenceStore store= createCombinedPreferenceStore(null);
+               setPreferenceStore(store);
+               
+               // TODO changed in 3.x ?
+           if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE))
+             fUpdater= new OutlinePageSelectionUpdater();
+           // jsurfer end
+           
+//             IPreferenceStore store= createCombinedPreferenceStore(null);
+//             setPreferenceStore(store);
+//             JavaTextTools textTools= PHPeclipsePlugin.getDefault().getJavaTextTools();
+//             setSourceViewerConfiguration(new JavaSourceViewerConfiguration(textTools.getColorManager(), store, this, IJavaPartitions.JAVA_PARTITIONING));
+//             fMarkOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
+//             fStickyOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_STICKY_OCCURRENCES);
+//             fMarkTypeOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_TYPE_OCCURRENCES);
+//             fMarkMethodOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_METHOD_OCCURRENCES);
+//             fMarkConstantOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_CONSTANT_OCCURRENCES);
+//             fMarkFieldOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_FIELD_OCCURRENCES);
+//             fMarkLocalVariableypeOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_LOCAL_VARIABLE_OCCURRENCES);
+//             fMarkExceptionOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_EXCEPTION_OCCURRENCES);
+//             fMarkMethodExitPoints= store.getBoolean(PreferenceConstants.EDITOR_MARK_METHOD_EXIT_POINTS);
+       }
   /*
    * @see org.eclipse.ui.texteditor.AbstractTextEditor#updatePropertyDependentActions()
    */
@@ -2446,6 +2860,14 @@ public abstract class PHPEditor  extends AbstractDecoratedTextEditor implements
 //
 //  }
   /**
+        * Returns the Java element wrapped by this editors input.
+        * 
+        * @return the Java element wrapped by this editors input.
+        * @since 3.0
+        */
+       abstract protected IJavaElement getInputJavaElement();
+
+  /**
     * Jumps to the matching bracket.
     */
   public void gotoMatchingBracket() {
@@ -2670,6 +3092,38 @@ public abstract class PHPEditor  extends AbstractDecoratedTextEditor implements
                
                return viewer;
        }
+       /**
+        * Creates and returns the preference store for this Java editor with the given input.
+        *
+        * @param input The editor input for which to create the preference store
+        * @return the preference store for this editor
+        *
+        * @since 3.0
+        */
+       private IPreferenceStore createCombinedPreferenceStore(IEditorInput input) {
+               List stores= new ArrayList(3);
+
+               IJavaProject project= EditorUtility.getJavaProject(input);
+               if (project != null)
+                       stores.add(new OptionsAdapter(project.getOptions(false), PHPeclipsePlugin.getDefault().getMockupPreferenceStore(), new OptionsAdapter.IPropertyChangeEventFilter() {
+
+                               public boolean isFiltered(PropertyChangeEvent event) {
+                                       IJavaElement inputJavaElement= getInputJavaElement();
+                                       IJavaProject javaProject= inputJavaElement != null ? inputJavaElement.getJavaProject() : null;
+                                       if (javaProject == null)
+                                               return true;
+                                       
+                                       return !javaProject.getProject().equals(event.getSource());
+                               }
+                               
+                       }));
+               
+               stores.add(PHPeclipsePlugin.getDefault().getPreferenceStore());
+               stores.add(new PreferencesAdapter(JavaCore.getPlugin().getPluginPreferences()));
+               stores.add(EditorsUI.getPreferenceStore());
+               
+               return new ChainedPreferenceStore((IPreferenceStore[]) stores.toArray(new IPreferenceStore[stores.size()]));
+       }
          /*
         * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
         */
index 7c3104b..d2dae94 100644 (file)
@@ -21,10 +21,10 @@ Format.label=F&ormat
 Format.tooltip=Format the Selected Text
 Format.description=Format the selected text
 
-Comment.label=Comment@Ctrl+/
+Comment.label=Comment
 Comment.tooltip=Comment selected lines
 
-Uncomment.label=Uncomment@Ctrl+\
+Uncomment.label=Uncomment
 Uncomment.tooltip=Uncomment selected lines
 
 TogglePresentation.label=Change Presentation
@@ -39,6 +39,15 @@ ToggleComment.description=Toggle comment for the selected lines
 ToggleComment.error.title=Toggle Comment
 ToggleComment.error.message=An error occurred while toggling comments.
 
+AddBlockComment.label=Add &Block Comment
+AddBlockComment.tooltip=Enclose the Selection in a Block Comment
+AddBlockComment.description=Encloses the selection with block comment markers
+
+RemoveBlockComment.label=Remove Bloc&k Comment
+RemoveBlockComment.tooltip=Remove Block Comment Markers Enclosing the Caret
+RemoveBlockComment.description=Removes any block comment markers enclosing the caret
+
+
 OutlinePage.segment.title_pattern=position {0}
 
 AutoIndent.error.bad_location_1=JavaAutoIndentStrategy.getAutoIndentString: BadLocationException
index 4c62baf..34ceb6f 100644 (file)
@@ -12,9 +12,7 @@ import net.sourceforge.phpdt.core.ISourceReference;
 import net.sourceforge.phpdt.core.JavaCore;
 import net.sourceforge.phpdt.core.JavaModelException;
 import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
-import net.sourceforge.phpdt.internal.ui.actions.AddBlockCommentAction;
 import net.sourceforge.phpdt.internal.ui.actions.CompositeActionGroup;
-import net.sourceforge.phpdt.internal.ui.actions.RemoveBlockCommentAction;
 import net.sourceforge.phpdt.internal.ui.text.ContentAssistPreference;
 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
 import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher;
@@ -83,6 +81,7 @@ import org.eclipse.ui.texteditor.ContentAssistAction;
 import org.eclipse.ui.texteditor.IDocumentProvider;
 import org.eclipse.ui.texteditor.ITextEditorActionConstants;
 import org.eclipse.ui.texteditor.TextOperationAction;
+
 /*******************************************************************************
  * Copyright (c) 2000, 2002 IBM Corp. and others. All rights reserved. This
  * program and the accompanying materials are made available under the terms of
@@ -96,2091 +95,2173 @@ import org.eclipse.ui.texteditor.TextOperationAction;
  * PHP specific text editor.
  */
 public class PHPUnitEditor extends PHPEditor { //implements
-                                                                                          // IJavaReconcilingListener {
-       interface ITextConverter {
-               void customizeDocumentCommand(IDocument document,
-                               DocumentCommand command);
-       };
-       //  class AdaptedRulerLayout extends Layout {
-       //
-       //    protected int fGap;
-       //    protected AdaptedSourceViewer fAdaptedSourceViewer;
-       //
-       //    protected AdaptedRulerLayout(int gap, AdaptedSourceViewer asv) {
-       //      fGap = gap;
-       //      fAdaptedSourceViewer = asv;
-       //    }
-       //
-       //    protected Point computeSize(Composite composite, int wHint, int hHint,
-       // boolean flushCache) {
-       //      Control[] children = composite.getChildren();
-       //      Point s = children[children.length - 1].computeSize(SWT.DEFAULT,
-       // SWT.DEFAULT, flushCache);
-       //      if (fAdaptedSourceViewer.isVerticalRulerVisible())
-       //        s.x += fAdaptedSourceViewer.getVerticalRuler().getWidth() + fGap;
-       //      return s;
-       //    }
-       //
-       //    protected void layout(Composite composite, boolean flushCache) {
-       //      Rectangle clArea = composite.getClientArea();
-       //      if (fAdaptedSourceViewer.isVerticalRulerVisible()) {
-       //
-       //        StyledText textWidget = fAdaptedSourceViewer.getTextWidget();
-       //        Rectangle trim = textWidget.computeTrim(0, 0, 0, 0);
-       //        int scrollbarHeight = trim.height;
-       //
-       //        IVerticalRuler vr = fAdaptedSourceViewer.getVerticalRuler();
-       //        int vrWidth = vr.getWidth();
-       //
-       //        int orWidth = 0;
-       //        if (fAdaptedSourceViewer.isOverviewRulerVisible()) {
-       //          OverviewRuler or = fAdaptedSourceViewer.getOverviewRuler();
-       //          orWidth = or.getWidth();
-       //          or.getControl().setBounds(clArea.width - orWidth, scrollbarHeight,
-       // orWidth, clArea.height - 3 * scrollbarHeight);
-       //        }
-       //
-       //        textWidget.setBounds(vrWidth + fGap, 0, clArea.width - vrWidth - orWidth
-       // -
-       // 2 * fGap, clArea.height);
-       //        vr.getControl().setBounds(0, 0, vrWidth, clArea.height -
-       // scrollbarHeight);
-       //
-       //      } else {
-       //        StyledText textWidget = fAdaptedSourceViewer.getTextWidget();
-       //        textWidget.setBounds(0, 0, clArea.width, clArea.height);
-       //      }
-       //    }
-       //  };
-       //
-       //  class AdaptedSourceViewer extends SourceViewer { // extends
-       // JavaCorrectionSourceViewer {
-       //
-       //    private List fTextConverters;
-       //
-       //    private OverviewRuler fOverviewRuler;
-       //    private boolean fIsOverviewRulerVisible;
-       //    /** The viewer's overview ruler hovering controller */
-       //    private AbstractHoverInformationControlManager
-       // fOverviewRulerHoveringController;
-       //
-       //    private boolean fIgnoreTextConverters = false;
-       //
-       //    private IVerticalRuler fCachedVerticalRuler;
-       //    private boolean fCachedIsVerticalRulerVisible;
-       //
-       //    public AdaptedSourceViewer(Composite parent, IVerticalRuler ruler, int
-       // styles) {
-       //      super(parent, ruler, styles); //, CompilationUnitEditor.this);
-       //
-       //      fCachedVerticalRuler = ruler;
-       //      fCachedIsVerticalRulerVisible = (ruler != null);
-       //      fOverviewRuler = new OverviewRuler(VERTICAL_RULER_WIDTH);
-       //
-       //      delayedCreateControl(parent, styles);
-       //    }
-       //
-       //    /*
-       //     * @see ISourceViewer#showAnnotations(boolean)
-       //     */
-       //    public void showAnnotations(boolean show) {
-       //      fCachedIsVerticalRulerVisible = (show && fCachedVerticalRuler != null);
-       //      // super.showAnnotations(show);
-       //    }
-       //
-       //    public IContentAssistant getContentAssistant() {
-       //      return fContentAssistant;
-       //    }
-       //
-       //    /*
-       //     * @see ITextOperationTarget#doOperation(int)
-       //     */
-       //    public void doOperation(int operation) {
-       //
-       //      if (getTextWidget() == null)
-       //        return;
-       //
-       //      switch (operation) {
-       //        case CONTENTASSIST_PROPOSALS :
-       //          String msg = fContentAssistant.showPossibleCompletions();
-       //          setStatusLineErrorMessage(msg);
-       //          return;
-       //        case UNDO :
-       //          fIgnoreTextConverters = true;
-       //          break;
-       //        case REDO :
-       //          fIgnoreTextConverters = true;
-       //          break;
-       //      }
-       //
-       //      super.doOperation(operation);
-       //    }
-       //
-       //    public void insertTextConverter(ITextConverter textConverter, int index)
-       // {
-       //      throw new UnsupportedOperationException();
-       //    }
-       //
-       //    public void addTextConverter(ITextConverter textConverter) {
-       //      if (fTextConverters == null) {
-       //        fTextConverters = new ArrayList(1);
-       //        fTextConverters.add(textConverter);
-       //      } else if (!fTextConverters.contains(textConverter))
-       //        fTextConverters.add(textConverter);
-       //    }
-       //
-       //    public void removeTextConverter(ITextConverter textConverter) {
-       //      if (fTextConverters != null) {
-       //        fTextConverters.remove(textConverter);
-       //        if (fTextConverters.size() == 0)
-       //          fTextConverters = null;
-       //      }
-       //    }
-       //
-       //    /*
-       //     * @see TextViewer#customizeDocumentCommand(DocumentCommand)
-       //     */
-       //    protected void customizeDocumentCommand(DocumentCommand command) {
-       //      super.customizeDocumentCommand(command);
-       //      if (!fIgnoreTextConverters && fTextConverters != null) {
-       //        for (Iterator e = fTextConverters.iterator(); e.hasNext();)
-       //           ((ITextConverter) e.next()).customizeDocumentCommand(getDocument(),
-       // command);
-       //      }
-       //      fIgnoreTextConverters = false;
-       //    }
-       //
-       //    public IVerticalRuler getVerticalRuler() {
-       //      return fCachedVerticalRuler;
-       //    }
-       //
-       //    public boolean isVerticalRulerVisible() {
-       //      return fCachedIsVerticalRulerVisible;
-       //    }
-       //
-       //    public OverviewRuler getOverviewRuler() {
-       //      return fOverviewRuler;
-       //    }
-       //
-       //    /*
-       //     * @see TextViewer#createControl(Composite, int)
-       //     */
-       //    protected void createControl(Composite parent, int styles) {
-       //      // do nothing here
-       //    }
-       //
-       //    protected void delayedCreateControl(Composite parent, int styles) {
-       //      //create the viewer
-       //      super.createControl(parent, styles);
-       //
-       //      Control control = getControl();
-       //      if (control instanceof Composite) {
-       //        Composite composite = (Composite) control;
-       //        composite.setLayout(new AdaptedRulerLayout(GAP_SIZE, this));
-       //        fOverviewRuler.createControl(composite, this);
-       //      }
-       //    }
-       //    protected void ensureOverviewHoverManagerInstalled() {
-       //      if (fOverviewRulerHoveringController == null && fAnnotationHover != null
-       // && fHoverControlCreator != null) {
-       //        fOverviewRulerHoveringController =
-       //          new OverviewRulerHoverManager(fOverviewRuler, this, fAnnotationHover,
-       // fHoverControlCreator);
-       //        fOverviewRulerHoveringController.install(fOverviewRuler.getControl());
-       //      }
-       //    }
-       //
-       //    public void hideOverviewRuler() {
-       //      fIsOverviewRulerVisible = false;
-       //      Control control = getControl();
-       //      if (control instanceof Composite) {
-       //        Composite composite = (Composite) control;
-       //        composite.layout();
-       //      }
-       //      if (fOverviewRulerHoveringController != null) {
-       //        fOverviewRulerHoveringController.dispose();
-       //        fOverviewRulerHoveringController = null;
-       //      }
-       //    }
-       //
-       //    public void showOverviewRuler() {
-       //      fIsOverviewRulerVisible = true;
-       //      Control control = getControl();
-       //      if (control instanceof Composite) {
-       //        Composite composite = (Composite) control;
-       //        composite.layout();
-       //      }
-       //      ensureOverviewHoverManagerInstalled();
-       //    }
-       //
-       //    public boolean isOverviewRulerVisible() {
-       //      return fIsOverviewRulerVisible;
-       //    }
-       //
-       //    /*
-       //     * @see ISourceViewer#setDocument(IDocument, IAnnotationModel, int, int)
-       //     */
-       //    public void setDocument(
-       //      IDocument document,
-       //      IAnnotationModel annotationModel,
-       //      int visibleRegionOffset,
-       //      int visibleRegionLength) {
-       //      super.setDocument(document, annotationModel, visibleRegionOffset,
-       // visibleRegionLength);
-       //      fOverviewRuler.setModel(annotationModel);
-       //    }
-       //
-       //    // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
-       //    public void updateIndentationPrefixes() {
-       //      SourceViewerConfiguration configuration = getSourceViewerConfiguration();
-       //      String[] types = configuration.getConfiguredContentTypes(this);
-       //      for (int i = 0; i < types.length; i++) {
-       //        String[] prefixes = configuration.getIndentPrefixes(this, types[i]);
-       //        if (prefixes != null && prefixes.length > 0)
-       //          setIndentPrefixes(prefixes, types[i]);
-       //      }
-       //    }
-       //
-       //    /*
-       //     * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
-       //     */
-       //    public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
-       //      if (WorkbenchHelp.isContextHelpDisplayed())
-       //        return false;
-       //      return super.requestWidgetToken(requester);
-       //    }
-       //
-       //    /*
-       //     * @see
-       // org.eclipse.jface.text.source.ISourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration)
-       //     */
-       //    public void configure(SourceViewerConfiguration configuration) {
-       //      super.configure(configuration);
-       //      // prependAutoEditStrategy(new SmartBracesAutoEditStrategy(this),
-       // IDocument.DEFAULT_CONTENT_TYPE);
-       //    }
-       //
-       //    protected void handleDispose() {
-       //      fOverviewRuler = null;
-       //
-       //      if (fOverviewRulerHoveringController != null) {
-       //        fOverviewRulerHoveringController.dispose();
-       //        fOverviewRulerHoveringController = null;
-       //      }
-       //
-       //      super.handleDispose();
-       //    }
-       //
-       //  };
-       class AdaptedSourceViewer extends JavaSourceViewer {
-               private List fTextConverters;
-               private boolean fIgnoreTextConverters = false;
-               //                      private JavaCorrectionAssistant fCorrectionAssistant;
-               public AdaptedSourceViewer(Composite parent,
-                               IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
-                               boolean showAnnotationsOverview, int styles,
-                               IPreferenceStore store) {
-                       super(parent, verticalRuler, overviewRuler,
-                                       showAnnotationsOverview, styles, store);
-               }
-               //              public AdaptedSourceViewer(Composite parent,
-               //                              IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
-               //                              boolean showAnnotationsOverview, int styles) {
-               //                      super(parent, verticalRuler, overviewRuler,
-               //                                      showAnnotationsOverview, styles);
-               //              }
-               public IContentAssistant getContentAssistant() {
-                       return fContentAssistant;
-               }
-               /*
-                * @see ITextOperationTarget#doOperation(int)
-                */
-               public void doOperation(int operation) {
-                       if (getTextWidget() == null)
-                               return;
-                       switch (operation) {
-                               case CONTENTASSIST_PROPOSALS :
-                                       String msg = fContentAssistant.showPossibleCompletions();
-                                       setStatusLineErrorMessage(msg);
-                                       return;
-                               //                                      case CORRECTIONASSIST_PROPOSALS:
-                               //                                              fCorrectionAssistant.showPossibleCompletions();
-                               //                                              return;
-                               case UNDO :
-                                       fIgnoreTextConverters = true;
-                                       break;
-                               case REDO :
-                                       fIgnoreTextConverters = true;
-                                       break;
-                       }
-                       super.doOperation(operation);
-               }
-               /*
-                * @see ITextOperationTarget#canDoOperation(int)
-                */
-               public boolean canDoOperation(int operation) {
-                       //                              if (operation == CORRECTIONASSIST_PROPOSALS)
-                       //                                      return isEditable();
-                       return super.canDoOperation(operation);
-               }
-               /*
-                * @see TextViewer#handleDispose()
-                */
-               protected void handleDispose() {
-                       //                              if (fCorrectionAssistant != null) {
-                       //                                      fCorrectionAssistant.uninstall();
-                       //                                      fCorrectionAssistant= null;
-                       //                              }
-                       super.handleDispose();
-               }
-               public void insertTextConverter(ITextConverter textConverter, int index) {
-                       throw new UnsupportedOperationException();
-               }
-               public void addTextConverter(ITextConverter textConverter) {
-                       if (fTextConverters == null) {
-                               fTextConverters = new ArrayList(1);
-                               fTextConverters.add(textConverter);
-                       } else if (!fTextConverters.contains(textConverter))
-                               fTextConverters.add(textConverter);
-               }
-               public void removeTextConverter(ITextConverter textConverter) {
-                       if (fTextConverters != null) {
-                               fTextConverters.remove(textConverter);
-                               if (fTextConverters.size() == 0)
-                                       fTextConverters = null;
-                       }
-               }
-               /*
-                * @see TextViewer#customizeDocumentCommand(DocumentCommand)
-                */
-               protected void customizeDocumentCommand(DocumentCommand command) {
-                       super.customizeDocumentCommand(command);
-                       if (!fIgnoreTextConverters && fTextConverters != null) {
-                               for (Iterator e = fTextConverters.iterator(); e.hasNext();)
-                                       ((ITextConverter) e.next()).customizeDocumentCommand(
-                                                       getDocument(), command);
-                       }
-                       fIgnoreTextConverters = false;
-               }
-               // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
-               public void updateIndentationPrefixes() {
-                       SourceViewerConfiguration configuration = getSourceViewerConfiguration();
-                       String[] types = configuration.getConfiguredContentTypes(this);
-                       for (int i = 0; i < types.length; i++) {
-                               String[] prefixes = configuration.getIndentPrefixes(this,
-                                               types[i]);
-                               if (prefixes != null && prefixes.length > 0)
-                                       setIndentPrefixes(prefixes, types[i]);
-                       }
-               }
-               /*
-                * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
-                */
-               public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
-                       if (WorkbenchHelp.isContextHelpDisplayed())
-                               return false;
-                       return super.requestWidgetToken(requester);
-               }
-               /*
-                * @see org.eclipse.jface.text.source.ISourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration)
-                */
-               public void configure(SourceViewerConfiguration configuration) {
-                       super.configure(configuration);
-                       //                              fCorrectionAssistant= new
-                       // JavaCorrectionAssistant(CompilationUnitEditor.this);
-                       //                              fCorrectionAssistant.install(this);
-                       //TODO install SmartBracesAutoEditStrategy
-                       //                              prependAutoEditStrategy(new SmartBracesAutoEditStrategy(this),
-                       // IDocument.DEFAULT_CONTENT_TYPE);
-               }
-       };
-       static class TabConverter implements ITextConverter {
-               private int fTabRatio;
-               private ILineTracker fLineTracker;
-               public TabConverter() {
-               }
-               public void setNumberOfSpacesPerTab(int ratio) {
-                       fTabRatio = ratio;
-               }
-               public void setLineTracker(ILineTracker lineTracker) {
-                       fLineTracker = lineTracker;
-               }
-               private int insertTabString(StringBuffer buffer, int offsetInLine) {
-                       if (fTabRatio == 0)
-                               return 0;
-                       int remainder = offsetInLine % fTabRatio;
-                       remainder = fTabRatio - remainder;
-                       for (int i = 0; i < remainder; i++)
-                               buffer.append(' ');
-                       return remainder;
-               }
-               public void customizeDocumentCommand(IDocument document,
-                               DocumentCommand command) {
-                       String text = command.text;
-                       if (text == null)
-                               return;
-                       int index = text.indexOf('\t');
-                       if (index > -1) {
-                               StringBuffer buffer = new StringBuffer();
-                               fLineTracker.set(command.text);
-                               int lines = fLineTracker.getNumberOfLines();
-                               try {
-                                       for (int i = 0; i < lines; i++) {
-                                               int offset = fLineTracker.getLineOffset(i);
-                                               int endOffset = offset + fLineTracker.getLineLength(i);
-                                               String line = text.substring(offset, endOffset);
-                                               int position = 0;
-                                               if (i == 0) {
-                                                       IRegion firstLine = document
-                                                                       .getLineInformationOfOffset(command.offset);
-                                                       position = command.offset - firstLine.getOffset();
-                                               }
-                                               int length = line.length();
-                                               for (int j = 0; j < length; j++) {
-                                                       char c = line.charAt(j);
-                                                       if (c == '\t') {
-                                                               position += insertTabString(buffer, position);
-                                                       } else {
-                                                               buffer.append(c);
-                                                               ++position;
-                                                       }
-                                               }
-                                       }
-                                       command.text = buffer.toString();
-                               } catch (BadLocationException x) {
-                               }
-                       }
-               }
-       };
-       private static class ExitPolicy implements LinkedPositionUI.ExitPolicy {
-               final char fExitCharacter;
-               public ExitPolicy(char exitCharacter) {
-                       fExitCharacter = exitCharacter;
-               }
-               /*
-                * @see org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionUI.ExitPolicy#doExit(org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionManager,
-                *      org.eclipse.swt.events.VerifyEvent, int, int)
-                */
-               public ExitFlags doExit(LinkedPositionManager manager,
-                               VerifyEvent event, int offset, int length) {
-                       if (event.character == fExitCharacter) {
-                               if (manager.anyPositionIncludes(offset, length))
-                                       return new ExitFlags(LinkedPositionUI.COMMIT
-                                                       | LinkedPositionUI.UPDATE_CARET, false);
-                               else
-                                       return new ExitFlags(LinkedPositionUI.COMMIT, true);
-                       }
-                       switch (event.character) {
-                               case '\b' :
-                                       if (manager.getFirstPosition().length == 0)
-                                               return new ExitFlags(0, false);
-                                       else
-                                               return null;
-                               case '\n' :
-                               case '\r' :
-                                       return new ExitFlags(LinkedPositionUI.COMMIT, true);
-                               default :
-                                       return null;
-                       }
-               }
-       }
-       private static class BracketLevel {
-               int fOffset;
-               int fLength;
-               LinkedPositionManager fManager;
-               LinkedPositionUI fEditor;
-       };
-       private class BracketInserter
-                       implements
-                               VerifyKeyListener,
-                               LinkedPositionUI.ExitListener {
-               private boolean fCloseBracketsPHP = true;
-               private boolean fCloseStringsPHP = true;
-               private boolean fCloseBracketsHTML = true;
-               private boolean fCloseStringsHTML = true;
-               private int fOffset;
-               private int fLength;
-               public void setCloseBracketsPHPEnabled(boolean enabled) {
-                       fCloseBracketsPHP = enabled;
-               }
-               public void setCloseStringsPHPEnabled(boolean enabled) {
-                       fCloseStringsPHP = enabled;
-               }
-               public void setCloseBracketsHTMLEnabled(boolean enabled) {
-                       fCloseBracketsHTML = enabled;
-               }
-               public void setCloseStringsHTMLEnabled(boolean enabled) {
-                       fCloseStringsHTML = enabled;
-               }
-               private boolean hasIdentifierToTheRight(IDocument document, int offset) {
-                       try {
-                               int end = offset;
-                               IRegion endLine = document.getLineInformationOfOffset(end);
-                               int maxEnd = endLine.getOffset() + endLine.getLength();
-                               while (end != maxEnd
-                                               && Character.isWhitespace(document.getChar(end)))
-                                       ++end;
-                               return end != maxEnd
-                                               && Scanner.isPHPIdentifierPart(document.getChar(end));
-                       } catch (BadLocationException e) {
-                               // be conservative
-                               return true;
-                       }
-               }
-               private boolean hasIdentifierToTheLeft(IDocument document, int offset) {
-                       try {
-                               int start = offset;
-                               IRegion startLine = document.getLineInformationOfOffset(start);
-                               int minStart = startLine.getOffset();
-                               while (start != minStart
-                                               && Character.isWhitespace(document.getChar(start - 1)))
-                                       --start;
-                               return start != minStart
-                                               && Scanner.isPHPIdentifierPart(document
-                                                               .getChar(start - 1));
-                       } catch (BadLocationException e) {
-                               return true;
-                       }
-               }
-               private boolean hasCharacterToTheRight(IDocument document, int offset,
-                               char character) {
-                       try {
-                               int end = offset;
-                               IRegion endLine = document.getLineInformationOfOffset(end);
-                               int maxEnd = endLine.getOffset() + endLine.getLength();
-                               while (end != maxEnd
-                                               && Character.isWhitespace(document.getChar(end)))
-                                       ++end;
-                               return end != maxEnd && document.getChar(end) == character;
-                       } catch (BadLocationException e) {
-                               // be conservative
-                               return true;
-                       }
-               }
-               /*
-                * @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent)
-                */
-               public void verifyKey(VerifyEvent event) {
-                       if (!event.doit)
-                               return;
-                       final ISourceViewer sourceViewer = getSourceViewer();
-                       IDocument document = sourceViewer.getDocument();
-                       final Point selection = sourceViewer.getSelectedRange();
-                       final int offset = selection.x;
-                       final int length = selection.y;
-                       try {
-                               ITypedRegion partition = document.getPartition(offset);
-                               String type = partition.getType();
-                               if (type.equals(IPHPPartitions.PHP_PARTITIONING)) {
-                                       switch (event.character) {
-                                               case '(' :
-                                                       if (hasCharacterToTheRight(document, offset
-                                                                       + length, '('))
-                                                               return;
-                                               // fall through
-                                               case '[' :
-                                                       if (!fCloseBracketsPHP)
-                                                               return;
-                                                       if (hasIdentifierToTheRight(document, offset
-                                                                       + length))
-                                                               return;
-                                               // fall through
-                                               case '"' :
-                                                       if (event.character == '"') {
-                                                               if (!fCloseStringsPHP)
-                                                                       return;
-                                                               // changed for statements like echo "" print ""
-                                                               //    if (hasIdentifierToTheLeft(document, offset)
-                                                               // ||
-                                                               // hasIdentifierToTheRight(document, offset +
-                                                               // length))
-                                                               if (hasIdentifierToTheRight(document, offset
-                                                                               + length))
-                                                                       return;
-                                                       }
-                                                       //     ITypedRegion partition=
-                                                       // document.getPartition(offset);
-                                                       //       if (!
-                                                       // IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())
-                                                       // &&
-                                                       // (partition.getOffset() != offset))
-                                                       //         return;
-                                                       final char character = event.character;
-                                                       final char closingCharacter = getPeerCharacter(character);
-                                                       final StringBuffer buffer = new StringBuffer();
-                                                       buffer.append(character);
-                                                       buffer.append(closingCharacter);
-                                                       document.replace(offset, length, buffer.toString());
-                                                       LinkedPositionManager manager = new LinkedPositionManager(
-                                                                       document);
-                                                       manager.addPosition(offset + 1, 0);
-                                                       fOffset = offset;
-                                                       fLength = 2;
-                                                       LinkedPositionUI editor = new LinkedPositionUI(
-                                                                       sourceViewer, manager);
-                                                       editor.setCancelListener(this);
-                                                       editor.setExitPolicy(new ExitPolicy(
-                                                                       closingCharacter));
-                                                       editor.setFinalCaretOffset(offset + 2);
-                                                       editor.enter();
-                                                       IRegion newSelection = editor.getSelectedRegion();
-                                                       sourceViewer.setSelectedRange(newSelection
-                                                                       .getOffset(), newSelection.getLength());
-                                                       event.doit = false;
-                                       }
-                               } else if (type.equals(IPHPPartitions.HTML)
-                                               || type.equals(IDocument.DEFAULT_CONTENT_TYPE)) {
-                                       switch (event.character) {
-                                               case '(' :
-                                                       if (hasCharacterToTheRight(document, offset
-                                                                       + length, '('))
-                                                               return;
-                                               // fall through
-                                               case '[' :
-                                                       if (!fCloseBracketsHTML)
-                                                               return;
-                                                       if (hasIdentifierToTheRight(document, offset
-                                                                       + length))
-                                                               return;
-                                               // fall through
-                                               case '"' :
-                                                       if (event.character == '"') {
-                                                               if (!fCloseStringsHTML)
-                                                                       return;
-                                                               if (hasIdentifierToTheLeft(document, offset)
-                                                                               || hasIdentifierToTheRight(document,
-                                                                                               offset + length))
-                                                                       return;
-                                                       }
-                                                       //     ITypedRegion partition=
-                                                       // document.getPartition(offset);
-                                                       //       if (!
-                                                       // IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())
-                                                       // &&
-                                                       // (partition.getOffset() != offset))
-                                                       //         return;
-                                                       final char character = event.character;
-                                                       final char closingCharacter = getPeerCharacter(character);
-                                                       final StringBuffer buffer = new StringBuffer();
-                                                       buffer.append(character);
-                                                       buffer.append(closingCharacter);
-                                                       document.replace(offset, length, buffer.toString());
-                                                       LinkedPositionManager manager = new LinkedPositionManager(
-                                                                       document);
-                                                       manager.addPosition(offset + 1, 0);
-                                                       fOffset = offset;
-                                                       fLength = 2;
-                                                       LinkedPositionUI editor = new LinkedPositionUI(
-                                                                       sourceViewer, manager);
-                                                       editor.setCancelListener(this);
-                                                       editor.setExitPolicy(new ExitPolicy(
-                                                                       closingCharacter));
-                                                       editor.setFinalCaretOffset(offset + 2);
-                                                       editor.enter();
-                                                       IRegion newSelection = editor.getSelectedRegion();
-                                                       sourceViewer.setSelectedRange(newSelection
-                                                                       .getOffset(), newSelection.getLength());
-                                                       event.doit = false;
-                                       }
-                               }
-                       } catch (BadLocationException e) {
-                       }
-               }
-               /*
-                * @see org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionUI.ExitListener#exit(boolean)
-                */
-               public void exit(boolean accept) {
-                       if (accept)
-                               return;
-                       // remove brackets
-                       try {
-                               final ISourceViewer sourceViewer = getSourceViewer();
-                               IDocument document = sourceViewer.getDocument();
-                               document.replace(fOffset, fLength, null);
-                       } catch (BadLocationException e) {
-                       }
-               }
-       }
-       /** The editor's save policy */
-       protected ISavePolicy fSavePolicy;
-       /**
-        * Listener to annotation model changes that updates the error tick in the
-        * tab image
-        */
-       private JavaEditorErrorTickUpdater fJavaEditorErrorTickUpdater;
-       /** The editor's paint manager */
-       //  private PaintManager fPaintManager;
-       /** The editor's bracket painter */
-       private BracketPainter fBracketPainter;
-       /** The editor's bracket matcher */
-       private PHPPairMatcher fBracketMatcher;
-       /** The editor's line painter */
-       private LinePainter fLinePainter;
-       /** The editor's print margin ruler painter */
-       private PrintMarginPainter fPrintMarginPainter;
-       /** The editor's problem painter */
-       //  private ProblemPainter fProblemPainter;
-       /** The editor's tab converter */
-       private TabConverter fTabConverter;
-       /** History for structure select action */
-       //private SelectionHistory fSelectionHistory;
-       /** The preference property change listener for php core. */
-       //  private IPropertyChangeListener fPropertyChangeListener = new
-       // PropertyChangeListener();
-       /** The remembered java element */
-       private IJavaElement fRememberedElement;
-       /** The remembered selection */
-       private ITextSelection fRememberedSelection;
-       /** The remembered php element offset */
-       private int fRememberedElementOffset;
-       /** The bracket inserter. */
-       private BracketInserter fBracketInserter = new BracketInserter();
-
-       /** The standard action groups added to the menu */
-       private GenerateActionGroup fGenerateActionGroup;
-       private CompositeActionGroup fContextMenuGroup;
-       //  private class PropertyChangeListener implements IPropertyChangeListener {
-       //    /*
-       //     * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
-       //     */
-       //    public void
-       // propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent
-       // event) {
-       //      handlePreferencePropertyChanged(event);
-       //    }
-       //  }
-       /* Preference key for code formatter tab size */
-       private final static String CODE_FORMATTER_TAB_SIZE = JavaCore.FORMATTER_TAB_SIZE;
-       /** Preference key for matching brackets */
-       private final static String MATCHING_BRACKETS = PreferenceConstants.EDITOR_MATCHING_BRACKETS;
-       /** Preference key for matching brackets color */
-       private final static String MATCHING_BRACKETS_COLOR = PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR;
-       /** Preference key for highlighting current line */
-       private final static String CURRENT_LINE = PreferenceConstants.EDITOR_CURRENT_LINE;
-       /** Preference key for highlight color of current line */
-       private final static String CURRENT_LINE_COLOR = PreferenceConstants.EDITOR_CURRENT_LINE_COLOR;
-       /** Preference key for showing print marging ruler */
-       private final static String PRINT_MARGIN = PreferenceConstants.EDITOR_PRINT_MARGIN;
-       /** Preference key for print margin ruler color */
-       private final static String PRINT_MARGIN_COLOR = PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR;
-       /** Preference key for print margin ruler column */
-       private final static String PRINT_MARGIN_COLUMN = PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN;
-       /** Preference key for inserting spaces rather than tabs */
-       private final static String SPACES_FOR_TABS = PreferenceConstants.EDITOR_SPACES_FOR_TABS;
-       /** Preference key for error indication */
-       //  private final static String ERROR_INDICATION =
-       // PreferenceConstants.EDITOR_PROBLEM_INDICATION;
-       /** Preference key for error color */
-       //  private final static String ERROR_INDICATION_COLOR =
-       // PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR;
-       /** Preference key for warning indication */
-       //  private final static String WARNING_INDICATION =
-       // PreferenceConstants.EDITOR_WARNING_INDICATION;
-       /** Preference key for warning color */
-       //  private final static String WARNING_INDICATION_COLOR =
-       // PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR;
-       /** Preference key for task indication */
-       private final static String TASK_INDICATION = PreferenceConstants.EDITOR_TASK_INDICATION;
-       /** Preference key for task color */
-       private final static String TASK_INDICATION_COLOR = PreferenceConstants.EDITOR_TASK_INDICATION_COLOR;
-       /** Preference key for bookmark indication */
-       private final static String BOOKMARK_INDICATION = PreferenceConstants.EDITOR_BOOKMARK_INDICATION;
-       /** Preference key for bookmark color */
-       private final static String BOOKMARK_INDICATION_COLOR = PreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR;
-       /** Preference key for search result indication */
-       private final static String SEARCH_RESULT_INDICATION = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION;
-       /** Preference key for search result color */
-       private final static String SEARCH_RESULT_INDICATION_COLOR = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR;
-       /** Preference key for unknown annotation indication */
-       private final static String UNKNOWN_INDICATION = PreferenceConstants.EDITOR_UNKNOWN_INDICATION;
-       /** Preference key for unknown annotation color */
-       private final static String UNKNOWN_INDICATION_COLOR = PreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR;
-       /** Preference key for linked position color */
-       private final static String LINKED_POSITION_COLOR = PreferenceConstants.EDITOR_LINKED_POSITION_COLOR;
-       /** Preference key for shwoing the overview ruler */
-       private final static String OVERVIEW_RULER = PreferenceConstants.EDITOR_OVERVIEW_RULER;
-       /** Preference key for error indication in overview ruler */
-       private final static String ERROR_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER;
-       /** Preference key for warning indication in overview ruler */
-       private final static String WARNING_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER;
-       /** Preference key for task indication in overview ruler */
-       private final static String TASK_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER;
-       /** Preference key for bookmark indication in overview ruler */
-       private final static String BOOKMARK_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER;
-       /** Preference key for search result indication in overview ruler */
-       private final static String SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER;
-       /** Preference key for unknown annotation indication in overview ruler */
-       private final static String UNKNOWN_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER;
-       /** Preference key for automatically closing strings */
-       private final static String CLOSE_STRINGS_PHP = PreferenceConstants.EDITOR_CLOSE_STRINGS_PHP;
-       /** Preference key for automatically wrapping Java strings */
-       private final static String WRAP_STRINGS = PreferenceConstants.EDITOR_WRAP_STRINGS;
-       /** Preference key for automatically closing brackets and parenthesis */
-       private final static String CLOSE_BRACKETS_PHP = PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP;
-       /** Preference key for automatically closing phpdocs and comments */
-       private final static String CLOSE_JAVADOCS = PreferenceConstants.EDITOR_CLOSE_JAVADOCS;
-       /** Preference key for automatically adding phpdoc tags */
-       private final static String ADD_JAVADOC_TAGS = PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS;
-       /** Preference key for automatically formatting phpdocs */
-       private final static String FORMAT_JAVADOCS = PreferenceConstants.EDITOR_FORMAT_JAVADOCS;
-       /** Preference key for automatically closing strings */
-       private final static String CLOSE_STRINGS_HTML = PreferenceConstants.EDITOR_CLOSE_STRINGS_HTML;
-       /** Preference key for automatically closing brackets and parenthesis */
-       private final static String CLOSE_BRACKETS_HTML = PreferenceConstants.EDITOR_CLOSE_BRACKETS_HTML;
-       /** Preference key for smart paste */
-       private final static String SMART_PASTE = PreferenceConstants.EDITOR_SMART_PASTE;
-       //  private final static class AnnotationInfo {
-       //    public String fColorPreference;
-       //    public String fOverviewRulerPreference;
-       //    public String fEditorPreference;
-       //  };
-       //  private final static Map ANNOTATION_MAP;
-       //  static {
-       //
-       //    AnnotationInfo info;
-       //    ANNOTATION_MAP = new HashMap();
-       //
-       //    info = new AnnotationInfo();
-       //    info.fColorPreference = TASK_INDICATION_COLOR;
-       //    info.fOverviewRulerPreference = TASK_INDICATION_IN_OVERVIEW_RULER;
-       //    info.fEditorPreference = TASK_INDICATION;
-       //    ANNOTATION_MAP.put(AnnotationType.TASK, info);
-       //
-       //    info = new AnnotationInfo();
-       //    info.fColorPreference = ERROR_INDICATION_COLOR;
-       //    info.fOverviewRulerPreference = ERROR_INDICATION_IN_OVERVIEW_RULER;
-       //    info.fEditorPreference = ERROR_INDICATION;
-       //    ANNOTATION_MAP.put(AnnotationType.ERROR, info);
-       //
-       //    info = new AnnotationInfo();
-       //    info.fColorPreference = WARNING_INDICATION_COLOR;
-       //    info.fOverviewRulerPreference = WARNING_INDICATION_IN_OVERVIEW_RULER;
-       //    info.fEditorPreference = WARNING_INDICATION;
-       //    ANNOTATION_MAP.put(AnnotationType.WARNING, info);
-       //
-       //    info = new AnnotationInfo();
-       //    info.fColorPreference = BOOKMARK_INDICATION_COLOR;
-       //    info.fOverviewRulerPreference = BOOKMARK_INDICATION_IN_OVERVIEW_RULER;
-       //    info.fEditorPreference = BOOKMARK_INDICATION;
-       //    ANNOTATION_MAP.put(AnnotationType.BOOKMARK, info);
-       //
-       //    info = new AnnotationInfo();
-       //    info.fColorPreference = SEARCH_RESULT_INDICATION_COLOR;
-       //    info.fOverviewRulerPreference =
-       // SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER;
-       //    info.fEditorPreference = SEARCH_RESULT_INDICATION;
-       //    ANNOTATION_MAP.put(AnnotationType.SEARCH, info);
-       //
-       //    info = new AnnotationInfo();
-       //    info.fColorPreference = UNKNOWN_INDICATION_COLOR;
-       //    info.fOverviewRulerPreference = UNKNOWN_INDICATION_IN_OVERVIEW_RULER;
-       //    info.fEditorPreference = UNKNOWN_INDICATION;
-       //    ANNOTATION_MAP.put(AnnotationType.UNKNOWN, info);
-       //  };
-       //
-       //  private final static AnnotationType[] ANNOTATION_LAYERS =
-       //    new AnnotationType[] {
-       //      AnnotationType.UNKNOWN,
-       //      AnnotationType.BOOKMARK,
-       //      AnnotationType.TASK,
-       //      AnnotationType.SEARCH,
-       //      AnnotationType.WARNING,
-       //      AnnotationType.ERROR };
-       /**
-        * Creates a new php unit editor.
-        */
-       public PHPUnitEditor() {
-               super();
-               setDocumentProvider(PHPeclipsePlugin.getDefault()
-                               .getCompilationUnitDocumentProvider());
-               setEditorContextMenuId("#PHPEditorContext"); //$NON-NLS-1$
-               setRulerContextMenuId("#PHPRulerContext"); //$NON-NLS-1$
-               setOutlinerContextMenuId("#PHPOutlinerContext"); //$NON-NLS-1$
-               // don't set help contextId, we install our own help context
-               fSavePolicy = null;
-               fJavaEditorErrorTickUpdater = new JavaEditorErrorTickUpdater(this);
-       }
-       /*
-        * @see AbstractTextEditor#createActions()
-        */
-       protected void createActions() {
-               super.createActions();
-               Action action;
-               //              Action action= new
-               // TextOperationAction(PHPEditorMessages.getResourceBundle(),
-               // "CorrectionAssistProposal.", this, CORRECTIONASSIST_PROPOSALS);
-               // //$NON-NLS-1$
-               //              action.setActionDefinitionId(PHPEditorActionDefinitionIds.CORRECTION_ASSIST_PROPOSALS);
-               //              setAction("CorrectionAssistProposal", action); //$NON-NLS-1$
-               //              markAsStateDependentAction("CorrectionAssistProposal", true);
-               // //$NON-NLS-1$
-               //// WorkbenchHelp.setHelp(action,
-               // IJavaHelpContextIds.QUICK_FIX_ACTION);
-               action = new ContentAssistAction(PHPEditorMessages.getResourceBundle(),
-                               "ContentAssistProposal.", this); //$NON-NLS-1$
-               action
-                               .setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
-               setAction("ContentAssistProposal", action); //$NON-NLS-1$
-               markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
-               //              WorkbenchHelp.setHelp(action,
-               // IJavaHelpContextIds.CONTENT_ASSIST_ACTION);
-               action = new TextOperationAction(PHPEditorMessages.getResourceBundle(),
-                               "ContentAssistContextInformation.", this,
-                               ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION); //$NON-NLS-1$
-               action
-                               .setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
-               setAction("ContentAssistContextInformation", action); //$NON-NLS-1$
-               markAsStateDependentAction("ContentAssistContextInformation", true); //$NON-NLS-1$
-               //              WorkbenchHelp.setHelp(action,
-               // IJavaHelpContextIds.PARAMETER_HINTS_ACTION);
-               //              action= new
-               // TextOperationAction(PHPEditorMessages.getResourceBundle(),
-               // "ContentAssistCompletePrefix.", this, CONTENTASSIST_COMPLETE_PREFIX);
-               // //$NON-NLS-1$
-               //              action.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_COMPLETE_PREFIX);
-               //              setAction("ContentAssistCompletePrefix", action); //$NON-NLS-1$
-               //              markAsStateDependentAction("ContentAssistCompletePrefix", true);
-               // //$NON-NLS-1$
-               //// WorkbenchHelp.setHelp(action,
-               // IJavaHelpContextIds.PARAMETER_HINTS_ACTION);
-               action = new TextOperationAction(PHPEditorMessages.getResourceBundle(),
-                               "Comment.", this, ITextOperationTarget.PREFIX); //$NON-NLS-1$
-               action.setActionDefinitionId(PHPEditorActionDefinitionIds.COMMENT);
-               setAction("Comment", action); //$NON-NLS-1$
-               markAsStateDependentAction("Comment", true); //$NON-NLS-1$
-               //              WorkbenchHelp.setHelp(action, IJavaHelpContextIds.COMMENT_ACTION);
-               action = new TextOperationAction(PHPEditorMessages.getResourceBundle(),
-                               "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX); //$NON-NLS-1$
-               action.setActionDefinitionId(PHPEditorActionDefinitionIds.UNCOMMENT);
-               setAction("Uncomment", action); //$NON-NLS-1$
-               markAsStateDependentAction("Uncomment", true); //$NON-NLS-1$
-               //              WorkbenchHelp.setHelp(action, IJavaHelpContextIds.UNCOMMENT_ACTION);
-
-               action = new ToggleCommentAction(PHPEditorMessages.getResourceBundle(),
-                               "ToggleComment.", this); //$NON-NLS-1$
-               action
-                               .setActionDefinitionId(PHPEditorActionDefinitionIds.TOGGLE_COMMENT);
-               setAction("ToggleComment", action); //$NON-NLS-1$
-               markAsStateDependentAction("ToggleComment", true); //$NON-NLS-1$
-               //WorkbenchHelp.setHelp(action,
-               // IJavaHelpContextIds.TOGGLE_COMMENT_ACTION);
-               configureToggleCommentAction();
-
-               //    action = new
-               // ToggleCommentAction(PHPEditorMessages.getResourceBundle(),
-               //        "ToggleComment.", this, getSourceViewerConfiguration()
-               //            .getDefaultPrefixes(getSourceViewer(), "")); //$NON-NLS-1$
-               // //$NON-NLS-2$
-               //    action.setActionDefinitionId(PHPEditorActionDefinitionIds.TOGGLE_COMMENT);
-               //    setAction("ToggleComment", action); //$NON-NLS-1$
-               //    markAsStateDependentAction("ToggleComment", true); //$NON-NLS-1$
-               //    // WorkbenchHelp.setHelp(action,
-               //    // IJavaHelpContextIds.TOGGLE_COMMENT_ACTION);
-
-               action = new TextOperationAction(PHPEditorMessages.getResourceBundle(),
-                               "Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$
-               action.setActionDefinitionId(PHPEditorActionDefinitionIds.FORMAT);
-               setAction("Format", action); //$NON-NLS-1$
-               markAsStateDependentAction("Format", true); //$NON-NLS-1$
-               markAsSelectionDependentAction("Format", true); //$NON-NLS-1$           
-               //              WorkbenchHelp.setHelp(action, IJavaHelpContextIds.FORMAT_ACTION);
-
-               action = new AddBlockCommentAction(PHPEditorMessages
-                               .getResourceBundle(), "AddBlockComment.", this); //$NON-NLS-1$
-               action
-                               .setActionDefinitionId(PHPEditorActionDefinitionIds.ADD_BLOCK_COMMENT);
-               setAction("AddBlockComment", action); //$NON-NLS-1$
-               markAsStateDependentAction("AddBlockComment", true); //$NON-NLS-1$
-               markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$          
-               //              WorkbenchHelp.setHelp(action,
-               // IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION);
-               action = new RemoveBlockCommentAction(PHPEditorMessages
-                               .getResourceBundle(), "RemoveBlockComment.", this); //$NON-NLS-1$
-               action
-                               .setActionDefinitionId(PHPEditorActionDefinitionIds.REMOVE_BLOCK_COMMENT);
-               setAction("RemoveBlockComment", action); //$NON-NLS-1$
-               markAsStateDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
-               markAsSelectionDependentAction("RemoveBlockComment", true); //$NON-NLS-1$               
-               //              WorkbenchHelp.setHelp(action,
-               // IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION);
-               //              action= new IndentAction(PHPEditorMessages.getResourceBundle(),
-               // "Indent.", this, false); //$NON-NLS-1$
-               //              action.setActionDefinitionId(PHPEditorActionDefinitionIds.INDENT);
-               //              setAction("Indent", action); //$NON-NLS-1$
-               //              markAsStateDependentAction("Indent", true); //$NON-NLS-1$
-               //              markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$
-               //// WorkbenchHelp.setHelp(action, IJavaHelpContextIds.INDENT_ACTION);
-               //              
-               //              action= new IndentAction(PHPEditorMessages.getResourceBundle(),
-               // "Indent.", this, true); //$NON-NLS-1$
-               //              setAction("IndentOnTab", action); //$NON-NLS-1$
-               //              markAsStateDependentAction("IndentOnTab", true); //$NON-NLS-1$
-               //              markAsSelectionDependentAction("IndentOnTab", true); //$NON-NLS-1$
-               //              
-               if (getPreferenceStore().getBoolean(
-                               PreferenceConstants.EDITOR_SMART_TAB)) {
-                       // don't replace Shift Right - have to make sure their enablement is
-                       // mutually exclusive
-                       //                      removeActionActivationCode(ITextEditorActionConstants.SHIFT_RIGHT);
-                       setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$
-               }
-               fGenerateActionGroup = new GenerateActionGroup(this,
-                               ITextEditorActionConstants.GROUP_EDIT);
-               fActionGroups = new CompositeActionGroup(
-                               new ActionGroup[]{fGenerateActionGroup});
-               //        We have to keep the context menu group separate to have better
-               // control
-               // over positioning
-               fContextMenuGroup = new CompositeActionGroup(
-                               new ActionGroup[]{fGenerateActionGroup});
-               //      rg,
-               //      new LocalHistoryActionGroup(this,
-               // ITextEditorActionConstants.GROUP_EDIT)});
+  // IJavaReconcilingListener {
+  interface ITextConverter {
+    void customizeDocumentCommand(IDocument document, DocumentCommand command);
+  };
 
-       }
-       /*
-        * @see JavaEditor#getElementAt(int)
-        */
-       protected IJavaElement getElementAt(int offset) {
-               return getElementAt(offset, true);
-       }
-       /**
-        * Returns the most narrow element including the given offset. If
-        * <code>reconcile</code> is <code>true</code> the editor's input
-        * element is reconciled in advance. If it is <code>false</code> this
-        * method only returns a result if the editor's input element does not need
-        * to be reconciled.
-        * 
-        * @param offset
-        *            the offset included by the retrieved element
-        * @param reconcile
-        *            <code>true</code> if working copy should be reconciled
-        */
-       protected IJavaElement getElementAt(int offset, boolean reconcile) {
-               IWorkingCopyManager manager = PHPeclipsePlugin.getDefault()
-                               .getWorkingCopyManager();
-               ICompilationUnit unit = manager.getWorkingCopy(getEditorInput());
-               if (unit != null) {
-                       try {
-                               if (reconcile) {
-                                       synchronized (unit) {
-                                               unit.reconcile();
-                                       }
-                                       return unit.getElementAt(offset);
-                               } else if (unit.isConsistent())
-                                       return unit.getElementAt(offset);
-                       } catch (JavaModelException x) {
-                               PHPeclipsePlugin.log(x.getStatus());
-                               // nothing found, be tolerant and go on
-                       }
-               }
-               return null;
-       }
-       /*
-        * @see JavaEditor#getCorrespondingElement(IJavaElement)
-        */
-       protected IJavaElement getCorrespondingElement(IJavaElement element) {
-               try {
-                       return EditorUtility.getWorkingCopy(element, true);
-               } catch (JavaModelException x) {
-                       PHPeclipsePlugin.log(x.getStatus());
-                       // nothing found, be tolerant and go on
-               }
-               return null;
-       }
-       public void createPartControl(Composite parent) {
-               super.createPartControl(parent);
-               //    fPaintManager = new PaintManager(getSourceViewer());
-               LinePainter linePainter;
-               linePainter = new LinePainter(getSourceViewer());
-               linePainter.setHighlightColor(new Color(Display.getCurrent(), 225, 235,
-                               224));
-               //    fPaintManager.addPainter(linePainter);
-               if (isBracketHighlightingEnabled())
-                       startBracketHighlighting();
-               if (isLineHighlightingEnabled())
-                       startLineHighlighting();
-               if (isPrintMarginVisible())
-                       showPrintMargin();
-               //    Iterator e = ANNOTATION_MAP.keySet().iterator();
-               //    while (e.hasNext()) {
-               //      AnnotationType type = (AnnotationType) e.next();
-               //      if (isAnnotationIndicationEnabled(type))
-               //        startAnnotationIndication(type);
-               //    }
-               if (isTabConversionEnabled())
-                       startTabConversion();
-               //    if (isOverviewRulerVisible())
-               //      showOverviewRuler();
-               //
-               //    Preferences preferences =
-               // PHPeclipsePlugin.getDefault().getPluginPreferences();
-               //    preferences.addPropertyChangeListener(fPropertyChangeListener);
-               IPreferenceStore preferenceStore = getPreferenceStore();
-               boolean closeBracketsPHP = preferenceStore
-                               .getBoolean(CLOSE_BRACKETS_PHP);
-               boolean closeStringsPHP = preferenceStore.getBoolean(CLOSE_STRINGS_PHP);
-               boolean closeBracketsHTML = preferenceStore
-                               .getBoolean(CLOSE_BRACKETS_HTML);
-               boolean closeStringsHTML = preferenceStore
-                               .getBoolean(CLOSE_STRINGS_HTML);
-               fBracketInserter.setCloseBracketsPHPEnabled(closeBracketsPHP);
-               fBracketInserter.setCloseStringsPHPEnabled(closeStringsPHP);
-               fBracketInserter.setCloseBracketsHTMLEnabled(closeBracketsHTML);
-               fBracketInserter.setCloseStringsHTMLEnabled(closeStringsHTML);
-               ISourceViewer sourceViewer = getSourceViewer();
-               if (sourceViewer instanceof ITextViewerExtension)
-                       ((ITextViewerExtension) sourceViewer)
-                                       .prependVerifyKeyListener(fBracketInserter);
-       }
-       private static char getPeerCharacter(char character) {
-               switch (character) {
-                       case '(' :
-                               return ')';
-                       case ')' :
-                               return '(';
-                       case '[' :
-                               return ']';
-                       case ']' :
-                               return '[';
-                       case '"' :
-                               return character;
-                       default :
-                               throw new IllegalArgumentException();
-               }
-       }
+  //  class AdaptedRulerLayout extends Layout {
+  //
+  //    protected int fGap;
+  //    protected AdaptedSourceViewer fAdaptedSourceViewer;
+  //
+  //    protected AdaptedRulerLayout(int gap, AdaptedSourceViewer asv) {
+  //      fGap = gap;
+  //      fAdaptedSourceViewer = asv;
+  //    }
+  //
+  //    protected Point computeSize(Composite composite, int wHint, int hHint,
+  // boolean flushCache) {
+  //      Control[] children = composite.getChildren();
+  //      Point s = children[children.length - 1].computeSize(SWT.DEFAULT,
+  // SWT.DEFAULT, flushCache);
+  //      if (fAdaptedSourceViewer.isVerticalRulerVisible())
+  //        s.x += fAdaptedSourceViewer.getVerticalRuler().getWidth() + fGap;
+  //      return s;
+  //    }
+  //
+  //    protected void layout(Composite composite, boolean flushCache) {
+  //      Rectangle clArea = composite.getClientArea();
+  //      if (fAdaptedSourceViewer.isVerticalRulerVisible()) {
+  //
+  //        StyledText textWidget = fAdaptedSourceViewer.getTextWidget();
+  //        Rectangle trim = textWidget.computeTrim(0, 0, 0, 0);
+  //        int scrollbarHeight = trim.height;
+  //
+  //        IVerticalRuler vr = fAdaptedSourceViewer.getVerticalRuler();
+  //        int vrWidth = vr.getWidth();
+  //
+  //        int orWidth = 0;
+  //        if (fAdaptedSourceViewer.isOverviewRulerVisible()) {
+  //          OverviewRuler or = fAdaptedSourceViewer.getOverviewRuler();
+  //          orWidth = or.getWidth();
+  //          or.getControl().setBounds(clArea.width - orWidth, scrollbarHeight,
+  // orWidth, clArea.height - 3 * scrollbarHeight);
+  //        }
+  //
+  //        textWidget.setBounds(vrWidth + fGap, 0, clArea.width - vrWidth - orWidth
+  // -
+  // 2 * fGap, clArea.height);
+  //        vr.getControl().setBounds(0, 0, vrWidth, clArea.height -
+  // scrollbarHeight);
+  //
+  //      } else {
+  //        StyledText textWidget = fAdaptedSourceViewer.getTextWidget();
+  //        textWidget.setBounds(0, 0, clArea.width, clArea.height);
+  //      }
+  //    }
+  //  };
+  //
+  //  class AdaptedSourceViewer extends SourceViewer { // extends
+  // JavaCorrectionSourceViewer {
+  //
+  //    private List fTextConverters;
+  //
+  //    private OverviewRuler fOverviewRuler;
+  //    private boolean fIsOverviewRulerVisible;
+  //    /** The viewer's overview ruler hovering controller */
+  //    private AbstractHoverInformationControlManager
+  // fOverviewRulerHoveringController;
+  //
+  //    private boolean fIgnoreTextConverters = false;
+  //
+  //    private IVerticalRuler fCachedVerticalRuler;
+  //    private boolean fCachedIsVerticalRulerVisible;
+  //
+  //    public AdaptedSourceViewer(Composite parent, IVerticalRuler ruler, int
+  // styles) {
+  //      super(parent, ruler, styles); //, CompilationUnitEditor.this);
+  //
+  //      fCachedVerticalRuler = ruler;
+  //      fCachedIsVerticalRulerVisible = (ruler != null);
+  //      fOverviewRuler = new OverviewRuler(VERTICAL_RULER_WIDTH);
+  //
+  //      delayedCreateControl(parent, styles);
+  //    }
+  //
+  //    /*
+  //     * @see ISourceViewer#showAnnotations(boolean)
+  //     */
+  //    public void showAnnotations(boolean show) {
+  //      fCachedIsVerticalRulerVisible = (show && fCachedVerticalRuler != null);
+  //      // super.showAnnotations(show);
+  //    }
+  //
+  //    public IContentAssistant getContentAssistant() {
+  //      return fContentAssistant;
+  //    }
+  //
+  //    /*
+  //     * @see ITextOperationTarget#doOperation(int)
+  //     */
+  //    public void doOperation(int operation) {
+  //
+  //      if (getTextWidget() == null)
+  //        return;
+  //
+  //      switch (operation) {
+  //        case CONTENTASSIST_PROPOSALS :
+  //          String msg = fContentAssistant.showPossibleCompletions();
+  //          setStatusLineErrorMessage(msg);
+  //          return;
+  //        case UNDO :
+  //          fIgnoreTextConverters = true;
+  //          break;
+  //        case REDO :
+  //          fIgnoreTextConverters = true;
+  //          break;
+  //      }
+  //
+  //      super.doOperation(operation);
+  //    }
+  //
+  //    public void insertTextConverter(ITextConverter textConverter, int index)
+  // {
+  //      throw new UnsupportedOperationException();
+  //    }
+  //
+  //    public void addTextConverter(ITextConverter textConverter) {
+  //      if (fTextConverters == null) {
+  //        fTextConverters = new ArrayList(1);
+  //        fTextConverters.add(textConverter);
+  //      } else if (!fTextConverters.contains(textConverter))
+  //        fTextConverters.add(textConverter);
+  //    }
+  //
+  //    public void removeTextConverter(ITextConverter textConverter) {
+  //      if (fTextConverters != null) {
+  //        fTextConverters.remove(textConverter);
+  //        if (fTextConverters.size() == 0)
+  //          fTextConverters = null;
+  //      }
+  //    }
+  //
+  //    /*
+  //     * @see TextViewer#customizeDocumentCommand(DocumentCommand)
+  //     */
+  //    protected void customizeDocumentCommand(DocumentCommand command) {
+  //      super.customizeDocumentCommand(command);
+  //      if (!fIgnoreTextConverters && fTextConverters != null) {
+  //        for (Iterator e = fTextConverters.iterator(); e.hasNext();)
+  //           ((ITextConverter) e.next()).customizeDocumentCommand(getDocument(),
+  // command);
+  //      }
+  //      fIgnoreTextConverters = false;
+  //    }
+  //
+  //    public IVerticalRuler getVerticalRuler() {
+  //      return fCachedVerticalRuler;
+  //    }
+  //
+  //    public boolean isVerticalRulerVisible() {
+  //      return fCachedIsVerticalRulerVisible;
+  //    }
+  //
+  //    public OverviewRuler getOverviewRuler() {
+  //      return fOverviewRuler;
+  //    }
+  //
+  //    /*
+  //     * @see TextViewer#createControl(Composite, int)
+  //     */
+  //    protected void createControl(Composite parent, int styles) {
+  //      // do nothing here
+  //    }
+  //
+  //    protected void delayedCreateControl(Composite parent, int styles) {
+  //      //create the viewer
+  //      super.createControl(parent, styles);
+  //
+  //      Control control = getControl();
+  //      if (control instanceof Composite) {
+  //        Composite composite = (Composite) control;
+  //        composite.setLayout(new AdaptedRulerLayout(GAP_SIZE, this));
+  //        fOverviewRuler.createControl(composite, this);
+  //      }
+  //    }
+  //    protected void ensureOverviewHoverManagerInstalled() {
+  //      if (fOverviewRulerHoveringController == null && fAnnotationHover != null
+  // && fHoverControlCreator != null) {
+  //        fOverviewRulerHoveringController =
+  //          new OverviewRulerHoverManager(fOverviewRuler, this, fAnnotationHover,
+  // fHoverControlCreator);
+  //        fOverviewRulerHoveringController.install(fOverviewRuler.getControl());
+  //      }
+  //    }
+  //
+  //    public void hideOverviewRuler() {
+  //      fIsOverviewRulerVisible = false;
+  //      Control control = getControl();
+  //      if (control instanceof Composite) {
+  //        Composite composite = (Composite) control;
+  //        composite.layout();
+  //      }
+  //      if (fOverviewRulerHoveringController != null) {
+  //        fOverviewRulerHoveringController.dispose();
+  //        fOverviewRulerHoveringController = null;
+  //      }
+  //    }
+  //
+  //    public void showOverviewRuler() {
+  //      fIsOverviewRulerVisible = true;
+  //      Control control = getControl();
+  //      if (control instanceof Composite) {
+  //        Composite composite = (Composite) control;
+  //        composite.layout();
+  //      }
+  //      ensureOverviewHoverManagerInstalled();
+  //    }
+  //
+  //    public boolean isOverviewRulerVisible() {
+  //      return fIsOverviewRulerVisible;
+  //    }
+  //
+  //    /*
+  //     * @see ISourceViewer#setDocument(IDocument, IAnnotationModel, int, int)
+  //     */
+  //    public void setDocument(
+  //      IDocument document,
+  //      IAnnotationModel annotationModel,
+  //      int visibleRegionOffset,
+  //      int visibleRegionLength) {
+  //      super.setDocument(document, annotationModel, visibleRegionOffset,
+  // visibleRegionLength);
+  //      fOverviewRuler.setModel(annotationModel);
+  //    }
+  //
+  //    // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
+  //    public void updateIndentationPrefixes() {
+  //      SourceViewerConfiguration configuration = getSourceViewerConfiguration();
+  //      String[] types = configuration.getConfiguredContentTypes(this);
+  //      for (int i = 0; i < types.length; i++) {
+  //        String[] prefixes = configuration.getIndentPrefixes(this, types[i]);
+  //        if (prefixes != null && prefixes.length > 0)
+  //          setIndentPrefixes(prefixes, types[i]);
+  //      }
+  //    }
+  //
+  //    /*
+  //     * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
+  //     */
+  //    public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
+  //      if (WorkbenchHelp.isContextHelpDisplayed())
+  //        return false;
+  //      return super.requestWidgetToken(requester);
+  //    }
+  //
+  //    /*
+  //     * @see
+  // org.eclipse.jface.text.source.ISourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration)
+  //     */
+  //    public void configure(SourceViewerConfiguration configuration) {
+  //      super.configure(configuration);
+  //      // prependAutoEditStrategy(new SmartBracesAutoEditStrategy(this),
+  // IDocument.DEFAULT_CONTENT_TYPE);
+  //    }
+  //
+  //    protected void handleDispose() {
+  //      fOverviewRuler = null;
+  //
+  //      if (fOverviewRulerHoveringController != null) {
+  //        fOverviewRulerHoveringController.dispose();
+  //        fOverviewRulerHoveringController = null;
+  //      }
+  //
+  //      super.handleDispose();
+  //    }
+  //
+  //  };
+  class AdaptedSourceViewer extends JavaSourceViewer {
+    private List fTextConverters;
 
-       private void startBracketHighlighting() {
-               if (fBracketPainter == null) {
-                       ISourceViewer sourceViewer = getSourceViewer();
-                       fBracketPainter = new BracketPainter(sourceViewer);
-                       fBracketPainter
-                                       .setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
-                       //      fPaintManager.addPainter(fBracketPainter);
-               }
-       }
-       private void stopBracketHighlighting() {
-               if (fBracketPainter != null) {
-                       //      fPaintManager.removePainter(fBracketPainter);
-                       fBracketPainter.deactivate(true);
-                       fBracketPainter.dispose();
-                       fBracketPainter = null;
-               }
-       }
-       private boolean isBracketHighlightingEnabled() {
-               IPreferenceStore store = getPreferenceStore();
-               return store.getBoolean(MATCHING_BRACKETS);
-       }
-       private void startLineHighlighting() {
-               if (fLinePainter == null) {
-                       ISourceViewer sourceViewer = getSourceViewer();
-                       fLinePainter = new LinePainter(sourceViewer);
-                       fLinePainter.setHighlightColor(getColor(CURRENT_LINE_COLOR));
-                       //      fPaintManager.addPainter(fLinePainter);
-               }
-       }
-       private void stopLineHighlighting() {
-               if (fLinePainter != null) {
-                       //      fPaintManager.removePainter(fLinePainter);
-                       fLinePainter.deactivate(true);
-                       fLinePainter.dispose();
-                       fLinePainter = null;
-               }
-       }
-       private boolean isLineHighlightingEnabled() {
-               IPreferenceStore store = getPreferenceStore();
-               return store.getBoolean(CURRENT_LINE);
-       }
-       private void showPrintMargin() {
-               if (fPrintMarginPainter == null) {
-                       fPrintMarginPainter = new PrintMarginPainter(getSourceViewer());
-                       fPrintMarginPainter
-                                       .setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
-                       fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore()
-                                       .getInt(PRINT_MARGIN_COLUMN));
-                       //      fPaintManager.addPainter(fPrintMarginPainter);
-               }
-       }
-       private void hidePrintMargin() {
-               if (fPrintMarginPainter != null) {
-                       //      fPaintManager.removePainter(fPrintMarginPainter);
-                       fPrintMarginPainter.deactivate(true);
-                       fPrintMarginPainter.dispose();
-                       fPrintMarginPainter = null;
-               }
-       }
-       private boolean isPrintMarginVisible() {
-               IPreferenceStore store = getPreferenceStore();
-               return store.getBoolean(PRINT_MARGIN);
-       }
-       //  private void startAnnotationIndication(AnnotationType annotationType) {
-       //    if (fProblemPainter == null) {
-       //      fProblemPainter = new ProblemPainter(this, getSourceViewer());
-       //// fPaintManager.addPainter(fProblemPainter);
-       //    }
-       //    fProblemPainter.setColor(annotationType, getColor(annotationType));
-       //    fProblemPainter.paintAnnotations(annotationType, true);
-       //    fProblemPainter.paint(IPainter.CONFIGURATION);
-       //  }
-       //
-       //  private void shutdownAnnotationIndication() {
-       //    if (fProblemPainter != null) {
-       //
-       //      if (!fProblemPainter.isPaintingAnnotations()) {
-       //// fPaintManager.removePainter(fProblemPainter);
-       //        fProblemPainter.deactivate(true);
-       //        fProblemPainter.dispose();
-       //        fProblemPainter = null;
-       //      } else {
-       //        fProblemPainter.paint(IPainter.CONFIGURATION);
-       //      }
-       //    }
-       //  }
-       //
-       //  private void stopAnnotationIndication(AnnotationType annotationType) {
-       //    if (fProblemPainter != null) {
-       //      fProblemPainter.paintAnnotations(annotationType, false);
-       //      shutdownAnnotationIndication();
-       //    }
-       //  }
-       //
-       //  private boolean isAnnotationIndicationEnabled(AnnotationType
-       // annotationType) {
-       //    IPreferenceStore store = getPreferenceStore();
-       //    AnnotationInfo info = (AnnotationInfo)
-       // ANNOTATION_MAP.get(annotationType);
-       //    if (info != null)
-       //      return store.getBoolean(info.fEditorPreference);
-       //    return false;
-       //  }
-       //
-       //  private boolean
-       // isAnnotationIndicationInOverviewRulerEnabled(AnnotationType
-       // annotationType) {
-       //    IPreferenceStore store = getPreferenceStore();
-       //    AnnotationInfo info = (AnnotationInfo)
-       // ANNOTATION_MAP.get(annotationType);
-       //    if (info != null)
-       //      return store.getBoolean(info.fOverviewRulerPreference);
-       //    return false;
-       //  }
-       //
-       //  private void showAnnotationIndicationInOverviewRuler(AnnotationType
-       // annotationType, boolean show) {
-       //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
-       //    OverviewRuler ruler = asv.getOverviewRuler();
-       //    if (ruler != null) {
-       //      ruler.setColor(annotationType, getColor(annotationType));
-       //      ruler.showAnnotation(annotationType, show);
-       //      ruler.update();
-       //    }
-       //  }
-       //
-       //  private void setColorInOverviewRuler(AnnotationType annotationType, Color
-       // color) {
-       //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
-       //    OverviewRuler ruler = asv.getOverviewRuler();
-       //    if (ruler != null) {
-       //      ruler.setColor(annotationType, color);
-       //      ruler.update();
-       //    }
-       //  }
-
-       private int getTabSize() {
-               Preferences preferences = PHPeclipsePlugin.getDefault()
-                               .getPluginPreferences();
-               return preferences.getInt(CODE_FORMATTER_TAB_SIZE);
-       }
+    private boolean fIgnoreTextConverters = false;
 
-       private boolean isTabConversionEnabled() {
-               IPreferenceStore store = getPreferenceStore();
-               return store.getBoolean(SPACES_FOR_TABS);
-       }
-       //  private void showOverviewRuler() {
-       //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
-       //    asv.showOverviewRuler();
-       //
-       //    OverviewRuler overviewRuler = asv.getOverviewRuler();
-       //    if (overviewRuler != null) {
-       //      for (int i = 0; i < ANNOTATION_LAYERS.length; i++) {
-       //        AnnotationType type = ANNOTATION_LAYERS[i];
-       //        overviewRuler.setLayer(type, i);
-       //        if (isAnnotationIndicationInOverviewRulerEnabled(type))
-       //          showAnnotationIndicationInOverviewRuler(type, true);
-       //      }
-       //    }
-       //  }
-       //
-       //  private void hideOverviewRuler() {
-       //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
-       //    asv.hideOverviewRuler();
-       //  }
-       //
-       //  private boolean isOverviewRulerVisible() {
-       //    IPreferenceStore store = getPreferenceStore();
-       //    return store.getBoolean(OVERVIEW_RULER);
-       //  }
-       private Color getColor(String key) {
-               RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), key);
-               return getColor(rgb);
-       }
-       private Color getColor(RGB rgb) {
-               JavaTextTools textTools = PHPeclipsePlugin.getDefault()
-                               .getJavaTextTools();
-               return textTools.getColorManager().getColor(rgb);
-       }
-       //  private Color getColor(AnnotationType annotationType) {
-       //    AnnotationInfo info = (AnnotationInfo)
-       // ANNOTATION_MAP.get(annotationType);
-       //    if (info != null)
-       //      return getColor(info.fColorPreference);
-       //    return null;
-       //  }
-       public void dispose() {
-               ISourceViewer sourceViewer = getSourceViewer();
-               if (sourceViewer instanceof ITextViewerExtension)
-                       ((ITextViewerExtension) sourceViewer)
-                                       .removeVerifyKeyListener(fBracketInserter);
-               //    if (fPropertyChangeListener != null) {
-               //      Preferences preferences =
-               // PHPeclipsePlugin.getDefault().getPluginPreferences();
-               //      preferences.removePropertyChangeListener(fPropertyChangeListener);
-               //      fPropertyChangeListener = null;
-               //    }
-               if (fJavaEditorErrorTickUpdater != null) {
-                       fJavaEditorErrorTickUpdater.dispose();
-                       fJavaEditorErrorTickUpdater = null;
-               }
-               //    if (fSelectionHistory != null)
-               //      fSelectionHistory.dispose();
-               //    if (fPaintManager != null) {
-               //      fPaintManager.dispose();
-               //      fPaintManager = null;
-               //    }
-               if (fActionGroups != null) {
-                       fActionGroups.dispose();
-                       fActionGroups = null;
-               }
-               super.dispose();
-       }
-       //  protected AnnotationType getAnnotationType(String preferenceKey) {
-       //    Iterator e = ANNOTATION_MAP.keySet().iterator();
-       //    while (e.hasNext()) {
-       //      AnnotationType type = (AnnotationType) e.next();
-       //      AnnotationInfo info = (AnnotationInfo) ANNOTATION_MAP.get(type);
-       //      if (info != null) {
-       //        if (preferenceKey.equals(info.fColorPreference)
-       //          || preferenceKey.equals(info.fEditorPreference)
-       //          || preferenceKey.equals(info.fOverviewRulerPreference))
-       //          return type;
-       //      }
-       //    }
-       //    return null;
-       //  }
-       /*
-        * @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent)
-        */
-       protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
-               try {
-                       AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
-                       if (asv != null) {
-                               String p = event.getProperty();
-                               if (CLOSE_BRACKETS_PHP.equals(p)) {
-                                       fBracketInserter
-                                                       .setCloseBracketsPHPEnabled(getPreferenceStore()
-                                                                       .getBoolean(p));
-                                       return;
-                               }
-                               if (CLOSE_STRINGS_PHP.equals(p)) {
-                                       fBracketInserter
-                                                       .setCloseStringsPHPEnabled(getPreferenceStore()
-                                                                       .getBoolean(p));
-                                       return;
-                               }
-                               if (CLOSE_BRACKETS_HTML.equals(p)) {
-                                       fBracketInserter
-                                                       .setCloseBracketsHTMLEnabled(getPreferenceStore()
-                                                                       .getBoolean(p));
-                                       return;
-                               }
-                               if (CLOSE_STRINGS_HTML.equals(p)) {
-                                       fBracketInserter
-                                                       .setCloseStringsHTMLEnabled(getPreferenceStore()
-                                                                       .getBoolean(p));
-                                       return;
-                               }
-                               if (SPACES_FOR_TABS.equals(p)) {
-                                       if (isTabConversionEnabled())
-                                               startTabConversion();
-                                       else
-                                               stopTabConversion();
-                                       return;
-                               }
-                               if (MATCHING_BRACKETS.equals(p)) {
-                                       if (isBracketHighlightingEnabled())
-                                               startBracketHighlighting();
-                                       else
-                                               stopBracketHighlighting();
-                                       return;
-                               }
-                               if (MATCHING_BRACKETS_COLOR.equals(p)) {
-                                       if (fBracketPainter != null)
-                                               fBracketPainter
-                                                               .setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
-                                       return;
-                               }
-                               if (CURRENT_LINE.equals(p)) {
-                                       if (isLineHighlightingEnabled())
-                                               startLineHighlighting();
-                                       else
-                                               stopLineHighlighting();
-                                       return;
-                               }
-                               if (CURRENT_LINE_COLOR.equals(p)) {
-                                       if (fLinePainter != null) {
-                                               stopLineHighlighting();
-                                               startLineHighlighting();
-                                       }
-                                       return;
-                               }
-                               if (PRINT_MARGIN.equals(p)) {
-                                       if (isPrintMarginVisible())
-                                               showPrintMargin();
-                                       else
-                                               hidePrintMargin();
-                                       return;
-                               }
-                               if (PRINT_MARGIN_COLOR.equals(p)) {
-                                       if (fPrintMarginPainter != null)
-                                               fPrintMarginPainter
-                                                               .setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
-                                       return;
-                               }
-                               if (PRINT_MARGIN_COLUMN.equals(p)) {
-                                       if (fPrintMarginPainter != null)
-                                               fPrintMarginPainter
-                                                               .setMarginRulerColumn(getPreferenceStore()
-                                                                               .getInt(PRINT_MARGIN_COLUMN));
-                                       return;
-                               }
-                               //        if (OVERVIEW_RULER.equals(p)) {
-                               //          if (isOverviewRulerVisible())
-                               //            showOverviewRuler();
-                               //          else
-                               //            hideOverviewRuler();
-                               //          return;
-                               //        }
-                               //        AnnotationType type = getAnnotationType(p);
-                               //        if (type != null) {
-                               //
-                               //          AnnotationInfo info = (AnnotationInfo)
-                               // ANNOTATION_MAP.get(type);
-                               //          if (info.fColorPreference.equals(p)) {
-                               //            Color color = getColor(type);
-                               //            if (fProblemPainter != null) {
-                               //              fProblemPainter.setColor(type, color);
-                               //              fProblemPainter.paint(IPainter.CONFIGURATION);
-                               //            }
-                               //            setColorInOverviewRuler(type, color);
-                               //            return;
-                               //          }
-                               //
-                               //          if (info.fEditorPreference.equals(p)) {
-                               //            if (isAnnotationIndicationEnabled(type))
-                               //              startAnnotationIndication(type);
-                               //            else
-                               //              stopAnnotationIndication(type);
-                               //            return;
-                               //          }
-                               //
-                               //          if (info.fOverviewRulerPreference.equals(p)) {
-                               //            if (isAnnotationIndicationInOverviewRulerEnabled(type))
-                               //              showAnnotationIndicationInOverviewRuler(type, true);
-                               //            else
-                               //              showAnnotationIndicationInOverviewRuler(type, false);
-                               //            return;
-                               //          }
-                               //        }
-                               IContentAssistant c = asv.getContentAssistant();
-                               if (c instanceof ContentAssistant)
-                                       ContentAssistPreference.changeConfiguration(
-                                                       (ContentAssistant) c, getPreferenceStore(), event);
-                       }
-               } finally {
-                       super.handlePreferenceStoreChanged(event);
-               }
-       }
-       /*
-        * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent)
-        */
-       protected void handlePreferencePropertyChanged(
-                       org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
-               AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
-               if (asv != null) {
-                       String p = event.getProperty();
-                       if (CODE_FORMATTER_TAB_SIZE.equals(p)) {
-                               asv.updateIndentationPrefixes();
-                               if (fTabConverter != null)
-                                       fTabConverter.setNumberOfSpacesPerTab(getTabSize());
-                       }
-               }
-               super.handlePreferencePropertyChanged(event);
-       }
-       /**
-        * Handles a property change event describing a change of the php core's
-        * preferences and updates the preference related editor properties.
-        * 
-        * @param event
-        *            the property change event
-        */
-       //  protected void
-       // handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent
-       // event) {
-       //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
-       //    if (asv != null) {
-       //      String p = event.getProperty();
-       //      if (CODE_FORMATTER_TAB_SIZE.equals(p)) {
-       //        asv.updateIndentationPrefixes();
-       //        if (fTabConverter != null)
-       //          fTabConverter.setNumberOfSpacesPerTab(getTabSize());
-       //      }
-       //    }
-       //  }
-       /*
-        * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#createJavaSourceViewer(org.eclipse.swt.widgets.Composite,
-        *      org.eclipse.jface.text.source.IVerticalRuler,
-        *      org.eclipse.jface.text.source.IOverviewRuler, boolean, int)
-        */
-       protected ISourceViewer createJavaSourceViewer(Composite parent,
-                       IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
-                       boolean isOverviewRulerVisible, int styles, IPreferenceStore store) {
-               return new AdaptedSourceViewer(parent, verticalRuler, overviewRuler,
-                               isOverviewRulerVisible, styles, store);
-       }
-       //  protected ISourceViewer createJavaSourceViewer(Composite parent,
-       // IVerticalRuler ruler, int styles) {
-       //    return new AdaptedSourceViewer(parent, ruler, styles);
-       //  }
-       private boolean isValidSelection(int offset, int length) {
-               IDocumentProvider provider = getDocumentProvider();
-               if (provider != null) {
-                       IDocument document = provider.getDocument(getEditorInput());
-                       if (document != null) {
-                               int end = offset + length;
-                               int documentLength = document.getLength();
-                               return 0 <= offset && offset <= documentLength && 0 <= end
-                                               && end <= documentLength;
-                       }
-               }
-               return false;
-       }
-       /*
-        * @see AbstractTextEditor#canHandleMove(IEditorInput, IEditorInput)
-        */
-       protected boolean canHandleMove(IEditorInput originalElement,
-                       IEditorInput movedElement) {
-               String oldExtension = ""; //$NON-NLS-1$
-               if (originalElement instanceof IFileEditorInput) {
-                       IFile file = ((IFileEditorInput) originalElement).getFile();
-                       if (file != null) {
-                               String ext = file.getFileExtension();
-                               if (ext != null)
-                                       oldExtension = ext;
-                       }
-               }
-               String newExtension = ""; //$NON-NLS-1$
-               if (movedElement instanceof IFileEditorInput) {
-                       IFile file = ((IFileEditorInput) movedElement).getFile();
-                       if (file != null)
-                               newExtension = file.getFileExtension();
-               }
-               return oldExtension.equals(newExtension);
-       }
-       /*
-        * @see AbstractTextEditor#editorContextMenuAboutToShow(IMenuManager)
-        */
-       public void editorContextMenuAboutToShow(IMenuManager menu) {
-               super.editorContextMenuAboutToShow(menu);
-               ActionContext context = new ActionContext(getSelectionProvider()
-                               .getSelection());
-               fContextMenuGroup.setContext(context);
-               fContextMenuGroup.fillContextMenu(menu);
-               fContextMenuGroup.setContext(null);
-       }
-       /*
-        * @see JavaEditor#setOutlinePageInput(JavaOutlinePage, IEditorInput)
-        */
-       protected void setOutlinePageInput(JavaOutlinePage page, IEditorInput input) {
-               if (page != null) {
-                       IWorkingCopyManager manager = PHPeclipsePlugin.getDefault()
-                                       .getWorkingCopyManager();
-                       page.setInput(manager.getWorkingCopy(input));
-               }
-       }
-       /*
-        * @see AbstractTextEditor#performSaveOperation(WorkspaceModifyOperation,
-        *      IProgressMonitor)
-        */
-       //  protected void performSaveOperation(WorkspaceModifyOperation operation,
-       // IProgressMonitor progressMonitor) {
-       //    IDocumentProvider p = getDocumentProvider();
-       //    if (p instanceof PHPDocumentProvider) {
-       //      PHPDocumentProvider cp = (PHPDocumentProvider) p;
-       //      cp.setSavePolicy(fSavePolicy);
-       //    }
-       //
-       //    try {
-       //      super.performSaveOperation(operation, progressMonitor);
-       //    } finally {
-       //      if (p instanceof PHPDocumentProvider) {
-       //        PHPDocumentProvider cp = (PHPDocumentProvider) p;
-       //        cp.setSavePolicy(null);
-       //      }
-       //    }
-       //  }
-       /*
-        * @see AbstractTextEditor#doSave(IProgressMonitor)
-        */
-       public void doSave(IProgressMonitor progressMonitor) {
-
-               IDocumentProvider p = getDocumentProvider();
-               if (p == null) {
-                       // editor has been closed
-                       return;
-               }
-
-               if (p.isDeleted(getEditorInput())) {
-
-                       if (isSaveAsAllowed()) {
-
-                               /*
-                                * 1GEUSSR: ITPUI:ALL - User should never loose changes made in
-                                * the editors. Changed Behavior to make sure that if called
-                                * inside a regular save (because of deletion of input element)
-                                * there is a way to report back to the caller.
-                                */
-                               performSaveAs(progressMonitor);
-
-                       } else {
-
-                               /*
-                                * 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still
-                                * there Missing resources.
-                                */
-                               Shell shell = getSite().getShell();
-                               MessageDialog
-                                               .openError(
-                                                               shell,
-                                                               PHPEditorMessages
-                                                                               .getString("PHPUnitEditor.error.saving.title1"), PHPEditorMessages.getString("PHPUnitEditor.error.saving.message1")); //$NON-NLS-1$ //$NON-NLS-2$
-                       }
-
-               } else {
-
-                       setStatusLineErrorMessage(null);
-
-                       updateState(getEditorInput());
-                       validateState(getEditorInput());
-                       
-                       IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager();
-                       ICompilationUnit unit = manager.getWorkingCopy(getEditorInput());
-
-                       if (unit != null) {
-                               synchronized (unit) {
-                                       performSave(false, progressMonitor);
-                               }
-                       } else
-                               performSave(false, progressMonitor);
-               }
-               ShowExternalPreviewAction a = ShowExternalPreviewAction.getInstance();
-               if (a != null) {
-                       a.refresh();
-               }
-       }
+    //                 private JavaCorrectionAssistant fCorrectionAssistant;
+    public AdaptedSourceViewer(Composite parent, IVerticalRuler verticalRuler,
+        IOverviewRuler overviewRuler, boolean showAnnotationsOverview,
+        int styles, IPreferenceStore store) {
+      super(parent, verticalRuler, overviewRuler, showAnnotationsOverview,
+          styles, store);
+    }
 
-       public boolean isSaveAsAllowed() {
-               return true;
-       }
+    //         public AdaptedSourceViewer(Composite parent,
+    //                         IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
+    //                         boolean showAnnotationsOverview, int styles) {
+    //                 super(parent, verticalRuler, overviewRuler,
+    //                                 showAnnotationsOverview, styles);
+    //         }
+    public IContentAssistant getContentAssistant() {
+      return fContentAssistant;
+    }
 
-       /**
-        * The compilation unit editor implementation of this
-        * <code>AbstractTextEditor</code> method asks the user for the workspace
-        * path of a file resource and saves the document there. See
-        * http://dev.eclipse.org/bugs/show_bug.cgi?id=6295
-        * 
-        * @param progressMonitor
-        *            the progress monitor
-        */
-       protected void performSaveAs(IProgressMonitor progressMonitor) {
-
-               Shell shell = getSite().getShell();
-               IEditorInput input = getEditorInput();
-
-               SaveAsDialog dialog = new SaveAsDialog(shell);
-
-               IFile original = (input instanceof IFileEditorInput)
-                               ? ((IFileEditorInput) input).getFile()
-                               : null;
-               if (original != null)
-                       dialog.setOriginalFile(original);
-
-               dialog.create();
-
-               IDocumentProvider provider = getDocumentProvider();
-               if (provider == null) {
-                       // editor has been programmatically closed while the dialog was open
-                       return;
-               }
-
-               if (provider.isDeleted(input) && original != null) {
-                       String message = PHPEditorMessages
-                                       .getFormattedString(
-                                                       "CompilationUnitEditor.warning.save.delete", new Object[]{original.getName()}); //$NON-NLS-1$
-                       dialog.setErrorMessage(null);
-                       dialog.setMessage(message, IMessageProvider.WARNING);
-               }
-
-               if (dialog.open() == Window.CANCEL) {
-                       if (progressMonitor != null)
-                               progressMonitor.setCanceled(true);
-                       return;
-               }
-
-               IPath filePath = dialog.getResult();
-               if (filePath == null) {
-                       if (progressMonitor != null)
-                               progressMonitor.setCanceled(true);
-                       return;
-               }
-
-               IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
-               IFile file = workspaceRoot.getFile(filePath);
-               final IEditorInput newInput = new FileEditorInput(file);
-
-               boolean success = false;
-               try {
-
-                       provider.aboutToChange(newInput);
-                       getDocumentProvider().saveDocument(progressMonitor, newInput,
-                                       getDocumentProvider().getDocument(getEditorInput()), true);
-                       success = true;
-
-               } catch (CoreException x) {
-                       IStatus status = x.getStatus();
-                       if (status == null || status.getSeverity() != IStatus.CANCEL)
-                               ErrorDialog
-                                               .openError(
-                                                               shell,
-                                                               PHPEditorMessages
-                                                                               .getString("CompilationUnitEditor.error.saving.title2"), PHPEditorMessages.getString("CompilationUnitEditor.error.saving.message2"), x.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$
-               } finally {
-                       provider.changed(newInput);
-                       if (success)
-                               setInput(newInput);
-               }
-
-               if (progressMonitor != null)
-                       progressMonitor.setCanceled(!success);
-       }
+    /*
+     * @see ITextOperationTarget#doOperation(int)
+     */
+    public void doOperation(int operation) {
+      if (getTextWidget() == null)
+        return;
+      switch (operation) {
+      case CONTENTASSIST_PROPOSALS:
+        String msg = fContentAssistant.showPossibleCompletions();
+        setStatusLineErrorMessage(msg);
+        return;
+      //                                       case CORRECTIONASSIST_PROPOSALS:
+      //                                               fCorrectionAssistant.showPossibleCompletions();
+      //                                               return;
+      case UNDO:
+        fIgnoreTextConverters = true;
+        break;
+      case REDO:
+        fIgnoreTextConverters = true;
+        break;
+      }
+      super.doOperation(operation);
+    }
 
-       /*
-        * @see AbstractTextEditor#doSetInput(IEditorInput)
-        */
-       protected void doSetInput(IEditorInput input) throws CoreException {
-               super.doSetInput(input);
-               configureTabConverter();
-               configureToggleCommentAction();
-       }
+    /*
+     * @see ITextOperationTarget#canDoOperation(int)
+     */
+    public boolean canDoOperation(int operation) {
+      //                               if (operation == CORRECTIONASSIST_PROPOSALS)
+      //                                       return isEditable();
+      return super.canDoOperation(operation);
+    }
 
-       //      /*
-       //       * @see
-       // org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#installOverrideIndicator(boolean)
-       //       * @since 3.0
-       //       */
-       //      protected void installOverrideIndicator(boolean waitForReconcilation) {
-       //              IAnnotationModel model=
-       // getDocumentProvider().getAnnotationModel(getEditorInput());
-       //              if (!waitForReconcilation)
-       //                      super.installOverrideIndicator(false);
-       //              else {
-       //                      uninstallOverrideIndicator();
-       //                      IJavaElement inputElement= getInputJavaElement();
-       //                      if (model == null || inputElement == null)
-       //                              return;
-       //                      
-       //                      fOverrideIndicatorManager= new OverrideIndicatorManager(model,
-       // inputElement, null);
-       //                      addReconcileListener(fOverrideIndicatorManager);
-       //              }
-       //      }
-       //      
-       //      /*
-       //       * @see
-       // org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#uninstallOverrideIndicator()
-       //       * @since 3.0
-       //       */
-       //      protected void uninstallOverrideIndicator() {
-       //              if (fOverrideIndicatorManager != null)
-       //                      removeReconcileListener(fOverrideIndicatorManager);
-       //              super.uninstallOverrideIndicator();
-       //      }
-
-       /**
-        * Configures the toggle comment action
-        * 
-        * @since 3.0
-        */
-       private void configureToggleCommentAction() {
-               IAction action = getAction("ToggleComment"); //$NON-NLS-1$
-               if (action instanceof ToggleCommentAction) {
-                       ISourceViewer sourceViewer = getSourceViewer();
-                       SourceViewerConfiguration configuration = getSourceViewerConfiguration();
-                       ((ToggleCommentAction) action).configure(sourceViewer,
-                                       configuration);
-               }
-       }
+    /*
+     * @see TextViewer#handleDispose()
+     */
+    protected void handleDispose() {
+      //                               if (fCorrectionAssistant != null) {
+      //                                       fCorrectionAssistant.uninstall();
+      //                                       fCorrectionAssistant= null;
+      //                               }
+      super.handleDispose();
+    }
 
-       private void configureTabConverter() {
-               if (fTabConverter != null) {
-                       IDocumentProvider provider = getDocumentProvider();
-                       if (provider instanceof PHPDocumentProvider) {
-                               PHPDocumentProvider cup = (PHPDocumentProvider) provider;
-                               fTabConverter.setLineTracker(cup
-                                               .createLineTracker(getEditorInput()));
-                       }
-               }
-       }
+    public void insertTextConverter(ITextConverter textConverter, int index) {
+      throw new UnsupportedOperationException();
+    }
 
-       private void startTabConversion() {
-               if (fTabConverter == null) {
-                       fTabConverter = new TabConverter();
-                       configureTabConverter();
-                       fTabConverter.setNumberOfSpacesPerTab(getTabSize());
-                       AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
-                       asv.addTextConverter(fTabConverter);
-                       // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
-                       asv.updateIndentationPrefixes();
-               }
-       }
+    public void addTextConverter(ITextConverter textConverter) {
+      if (fTextConverters == null) {
+        fTextConverters = new ArrayList(1);
+        fTextConverters.add(textConverter);
+      } else if (!fTextConverters.contains(textConverter))
+        fTextConverters.add(textConverter);
+    }
 
-       private void stopTabConversion() {
-               if (fTabConverter != null) {
-                       AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
-                       asv.removeTextConverter(fTabConverter);
-                       // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
-                       asv.updateIndentationPrefixes();
-                       fTabConverter = null;
-               }
-       }
+    public void removeTextConverter(ITextConverter textConverter) {
+      if (fTextConverters != null) {
+        fTextConverters.remove(textConverter);
+        if (fTextConverters.size() == 0)
+          fTextConverters = null;
+      }
+    }
 
-       /*
-        * @see org.eclipse.ui.texteditor.AbstractTextEditor#performSave(boolean,
-        *      org.eclipse.core.runtime.IProgressMonitor)
-        */
-       protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) {
-               IDocumentProvider p = getDocumentProvider();
-               if (p instanceof PHPDocumentProvider) {
-                       PHPDocumentProvider cp = (PHPDocumentProvider) p;
-                       cp.setSavePolicy(fSavePolicy);
-               }
-               try {
-                       super.performSave(overwrite, progressMonitor);
-               } finally {
-                       if (p instanceof PHPDocumentProvider) {
-                               PHPDocumentProvider cp = (PHPDocumentProvider) p;
-                               cp.setSavePolicy(null);
-                       }
-               }
-       }
-       /*
-        * @see AbstractTextEditor#doSaveAs
-        */
-       public void doSaveAs() {
-               if (askIfNonWorkbenchEncodingIsOk()) {
-                       super.doSaveAs();
-               }
-       }
+    /*
+     * @see TextViewer#customizeDocumentCommand(DocumentCommand)
+     */
+    protected void customizeDocumentCommand(DocumentCommand command) {
+      super.customizeDocumentCommand(command);
+      if (!fIgnoreTextConverters && fTextConverters != null) {
+        for (Iterator e = fTextConverters.iterator(); e.hasNext();)
+          ((ITextConverter) e.next()).customizeDocumentCommand(getDocument(),
+              command);
+      }
+      fIgnoreTextConverters = false;
+    }
 
-       /**
-        * Asks the user if it is ok to store in non-workbench encoding.
-        * 
-        * @return <true>if the user wants to continue
-        */
-       private boolean askIfNonWorkbenchEncodingIsOk() {
-               IDocumentProvider provider = getDocumentProvider();
-               if (provider instanceof IStorageDocumentProvider) {
-                       IEditorInput input = getEditorInput();
-                       IStorageDocumentProvider storageProvider = (IStorageDocumentProvider) provider;
-                       String encoding = storageProvider.getEncoding(input);
-                       String defaultEncoding = storageProvider.getDefaultEncoding();
-                       if (encoding != null && !encoding.equals(defaultEncoding)) {
-                               Shell shell = getSite().getShell();
-                               String title = PHPEditorMessages
-                                               .getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.title"); //$NON-NLS-1$
-                               String msg;
-                               if (input != null)
-                                       msg = MessageFormat
-                                                       .format(
-                                                                       PHPEditorMessages
-                                                                                       .getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.message1"),
-                                                                       new String[]{input.getName(), encoding}); //$NON-NLS-1$
-                               else
-                                       msg = MessageFormat
-                                                       .format(
-                                                                       PHPEditorMessages
-                                                                                       .getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.message2"),
-                                                                       new String[]{encoding}); //$NON-NLS-1$
-                               return MessageDialog.openQuestion(shell, title, msg);
-                       }
-               }
-               return true;
-       }
-       /*
-        * @see IReconcilingParticipant#reconciled()
-        */
-       public void reconciled() {
-               if (synchronizeOutlineOnCursorMove()) {
-                       Shell shell = getSite().getShell();
-                       if (shell != null && !shell.isDisposed()) {
-                               shell.getDisplay().asyncExec(new Runnable() {
-                                       public void run() {
-                                               synchronizeOutlinePageSelection();
-                                       }
-                               });
-                       }
-               }
-       }
+    // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
+    public void updateIndentationPrefixes() {
+      SourceViewerConfiguration configuration = getSourceViewerConfiguration();
+      String[] types = configuration.getConfiguredContentTypes(this);
+      for (int i = 0; i < types.length; i++) {
+        String[] prefixes = configuration.getIndentPrefixes(this, types[i]);
+        if (prefixes != null && prefixes.length > 0)
+          setIndentPrefixes(prefixes, types[i]);
+      }
+    }
 
-       protected void updateStateDependentActions() {
-               super.updateStateDependentActions();
-               fGenerateActionGroup.editorStateChanged();
-       }
+    /*
+     * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
+     */
+    public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
+      if (WorkbenchHelp.isContextHelpDisplayed())
+        return false;
+      return super.requestWidgetToken(requester);
+    }
 
-       private boolean synchronizeOutlineOnCursorMove() {
-               return PreferenceConstants.getPreferenceStore().getBoolean(
-                               PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);
-       }
+    /*
+     * @see org.eclipse.jface.text.source.ISourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration)
+     */
+    public void configure(SourceViewerConfiguration configuration) {
+      super.configure(configuration);
+      //                               fCorrectionAssistant= new
+      // JavaCorrectionAssistant(CompilationUnitEditor.this);
+      //                               fCorrectionAssistant.install(this);
+      //TODO install SmartBracesAutoEditStrategy
+      //                               prependAutoEditStrategy(new SmartBracesAutoEditStrategy(this),
+      // IDocument.DEFAULT_CONTENT_TYPE);
+    }
+  };
 
-       /**
-        * Returns the updated java element for the old java element.
-        */
-       private IJavaElement findElement(IJavaElement element) {
-               if (element == null)
-                       return null;
-               IWorkingCopyManager manager = PHPeclipsePlugin.getDefault()
-                               .getWorkingCopyManager();
-               ICompilationUnit unit = manager.getWorkingCopy(getEditorInput());
-               if (unit != null) {
-                       try {
-                               synchronized (unit) {
-                                       unit.reconcile();
-                               }
-                               IJavaElement[] findings = unit.findElements(element);
-                               if (findings != null && findings.length > 0)
-                                       return findings[0];
-                       } catch (JavaModelException x) {
-                               PHPeclipsePlugin.log(x.getStatus());
-                               // nothing found, be tolerant and go on
-                       }
-               }
-               return null;
-       }
-       /**
-        * Returns the offset of the given Java element.
-        */
-       private int getOffset(IJavaElement element) {
-               if (element instanceof ISourceReference) {
-                       ISourceReference sr = (ISourceReference) element;
-                       try {
-                               ISourceRange srcRange = sr.getSourceRange();
-                               if (srcRange != null)
-                                       return srcRange.getOffset();
-                       } catch (JavaModelException e) {
-                       }
-               }
-               return -1;
-       }
-       /*
-        * @see AbstractTextEditor#rememberSelection()
-        */
-       protected void rememberSelection() {
-               ISelectionProvider sp = getSelectionProvider();
-               fRememberedSelection = (sp == null ? null : (ITextSelection) sp
-                               .getSelection());
-               if (fRememberedSelection != null) {
-                       fRememberedElement = getElementAt(fRememberedSelection.getOffset(),
-                                       true);
-                       fRememberedElementOffset = getOffset(fRememberedElement);
-               }
-       }
-       /*
-        * @see AbstractTextEditor#restoreSelection()
+  static class TabConverter implements ITextConverter {
+    private int fTabRatio;
+
+    private ILineTracker fLineTracker;
+
+    public TabConverter() {
+    }
+
+    public void setNumberOfSpacesPerTab(int ratio) {
+      fTabRatio = ratio;
+    }
+
+    public void setLineTracker(ILineTracker lineTracker) {
+      fLineTracker = lineTracker;
+    }
+
+    private int insertTabString(StringBuffer buffer, int offsetInLine) {
+      if (fTabRatio == 0)
+        return 0;
+      int remainder = offsetInLine % fTabRatio;
+      remainder = fTabRatio - remainder;
+      for (int i = 0; i < remainder; i++)
+        buffer.append(' ');
+      return remainder;
+    }
+
+    public void customizeDocumentCommand(IDocument document,
+        DocumentCommand command) {
+      String text = command.text;
+      if (text == null)
+        return;
+      int index = text.indexOf('\t');
+      if (index > -1) {
+        StringBuffer buffer = new StringBuffer();
+        fLineTracker.set(command.text);
+        int lines = fLineTracker.getNumberOfLines();
+        try {
+          for (int i = 0; i < lines; i++) {
+            int offset = fLineTracker.getLineOffset(i);
+            int endOffset = offset + fLineTracker.getLineLength(i);
+            String line = text.substring(offset, endOffset);
+            int position = 0;
+            if (i == 0) {
+              IRegion firstLine = document
+                  .getLineInformationOfOffset(command.offset);
+              position = command.offset - firstLine.getOffset();
+            }
+            int length = line.length();
+            for (int j = 0; j < length; j++) {
+              char c = line.charAt(j);
+              if (c == '\t') {
+                position += insertTabString(buffer, position);
+              } else {
+                buffer.append(c);
+                ++position;
+              }
+            }
+          }
+          command.text = buffer.toString();
+        } catch (BadLocationException x) {
+        }
+      }
+    }
+  };
+
+  private static class ExitPolicy implements LinkedPositionUI.ExitPolicy {
+    final char fExitCharacter;
+
+    public ExitPolicy(char exitCharacter) {
+      fExitCharacter = exitCharacter;
+    }
+
+    /*
+     * @see org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionUI.ExitPolicy#doExit(org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionManager,
+     *      org.eclipse.swt.events.VerifyEvent, int, int)
+     */
+    public ExitFlags doExit(LinkedPositionManager manager, VerifyEvent event,
+        int offset, int length) {
+      if (event.character == fExitCharacter) {
+        if (manager.anyPositionIncludes(offset, length))
+          return new ExitFlags(LinkedPositionUI.COMMIT
+              | LinkedPositionUI.UPDATE_CARET, false);
+        else
+          return new ExitFlags(LinkedPositionUI.COMMIT, true);
+      }
+      switch (event.character) {
+      case '\b':
+        if (manager.getFirstPosition().length == 0)
+          return new ExitFlags(0, false);
+        else
+          return null;
+      case '\n':
+      case '\r':
+        return new ExitFlags(LinkedPositionUI.COMMIT, true);
+      default:
+        return null;
+      }
+    }
+  }
+
+  private static class BracketLevel {
+    int fOffset;
+
+    int fLength;
+
+    LinkedPositionManager fManager;
+
+    LinkedPositionUI fEditor;
+  };
+
+  private class BracketInserter implements VerifyKeyListener,
+      LinkedPositionUI.ExitListener {
+    private boolean fCloseBracketsPHP = true;
+
+    private boolean fCloseStringsPHP = true;
+
+    private boolean fCloseBracketsHTML = true;
+
+    private boolean fCloseStringsHTML = true;
+
+    private int fOffset;
+
+    private int fLength;
+
+    public void setCloseBracketsPHPEnabled(boolean enabled) {
+      fCloseBracketsPHP = enabled;
+    }
+
+    public void setCloseStringsPHPEnabled(boolean enabled) {
+      fCloseStringsPHP = enabled;
+    }
+
+    public void setCloseBracketsHTMLEnabled(boolean enabled) {
+      fCloseBracketsHTML = enabled;
+    }
+
+    public void setCloseStringsHTMLEnabled(boolean enabled) {
+      fCloseStringsHTML = enabled;
+    }
+
+    private boolean hasIdentifierToTheRight(IDocument document, int offset) {
+      try {
+        int end = offset;
+        IRegion endLine = document.getLineInformationOfOffset(end);
+        int maxEnd = endLine.getOffset() + endLine.getLength();
+        while (end != maxEnd && Character.isWhitespace(document.getChar(end)))
+          ++end;
+        return end != maxEnd
+            && Scanner.isPHPIdentifierPart(document.getChar(end));
+      } catch (BadLocationException e) {
+        // be conservative
+        return true;
+      }
+    }
+
+    private boolean hasIdentifierToTheLeft(IDocument document, int offset) {
+      try {
+        int start = offset;
+        IRegion startLine = document.getLineInformationOfOffset(start);
+        int minStart = startLine.getOffset();
+        while (start != minStart
+            && Character.isWhitespace(document.getChar(start - 1)))
+          --start;
+        return start != minStart
+            && Scanner.isPHPIdentifierPart(document.getChar(start - 1));
+      } catch (BadLocationException e) {
+        return true;
+      }
+    }
+
+    private boolean hasCharacterToTheRight(IDocument document, int offset,
+        char character) {
+      try {
+        int end = offset;
+        IRegion endLine = document.getLineInformationOfOffset(end);
+        int maxEnd = endLine.getOffset() + endLine.getLength();
+        while (end != maxEnd && Character.isWhitespace(document.getChar(end)))
+          ++end;
+        return end != maxEnd && document.getChar(end) == character;
+      } catch (BadLocationException e) {
+        // be conservative
+        return true;
+      }
+    }
+
+    /*
+     * @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent)
+     */
+    public void verifyKey(VerifyEvent event) {
+      if (!event.doit)
+        return;
+      final ISourceViewer sourceViewer = getSourceViewer();
+      IDocument document = sourceViewer.getDocument();
+      final Point selection = sourceViewer.getSelectedRange();
+      final int offset = selection.x;
+      final int length = selection.y;
+      try {
+        ITypedRegion partition = document.getPartition(offset);
+        String type = partition.getType();
+        if (type.equals(IPHPPartitions.PHP_PARTITIONING)) {
+          switch (event.character) {
+          case '(':
+            if (hasCharacterToTheRight(document, offset + length, '('))
+              return;
+          // fall through
+          case '[':
+            if (!fCloseBracketsPHP)
+              return;
+            if (hasIdentifierToTheRight(document, offset + length))
+              return;
+          // fall through
+          case '"':
+            if (event.character == '"') {
+              if (!fCloseStringsPHP)
+                return;
+              // changed for statements like echo "" print ""
+              //    if (hasIdentifierToTheLeft(document, offset)
+              // ||
+              // hasIdentifierToTheRight(document, offset +
+              // length))
+              if (hasIdentifierToTheRight(document, offset + length))
+                return;
+            }
+            //     ITypedRegion partition=
+            // document.getPartition(offset);
+            //       if (!
+            // IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())
+            // &&
+            // (partition.getOffset() != offset))
+            //         return;
+            final char character = event.character;
+            final char closingCharacter = getPeerCharacter(character);
+            final StringBuffer buffer = new StringBuffer();
+            buffer.append(character);
+            buffer.append(closingCharacter);
+            document.replace(offset, length, buffer.toString());
+            LinkedPositionManager manager = new LinkedPositionManager(document);
+            manager.addPosition(offset + 1, 0);
+            fOffset = offset;
+            fLength = 2;
+            LinkedPositionUI editor = new LinkedPositionUI(sourceViewer,
+                manager);
+            editor.setCancelListener(this);
+            editor.setExitPolicy(new ExitPolicy(closingCharacter));
+            editor.setFinalCaretOffset(offset + 2);
+            editor.enter();
+            IRegion newSelection = editor.getSelectedRegion();
+            sourceViewer.setSelectedRange(newSelection.getOffset(),
+                newSelection.getLength());
+            event.doit = false;
+          }
+        } else if (type.equals(IPHPPartitions.HTML)
+            || type.equals(IDocument.DEFAULT_CONTENT_TYPE)) {
+          switch (event.character) {
+          case '(':
+            if (hasCharacterToTheRight(document, offset + length, '('))
+              return;
+          // fall through
+          case '[':
+            if (!fCloseBracketsHTML)
+              return;
+            if (hasIdentifierToTheRight(document, offset + length))
+              return;
+          // fall through
+          case '"':
+            if (event.character == '"') {
+              if (!fCloseStringsHTML)
+                return;
+              if (hasIdentifierToTheLeft(document, offset)
+                  || hasIdentifierToTheRight(document, offset + length))
+                return;
+            }
+            //     ITypedRegion partition=
+            // document.getPartition(offset);
+            //       if (!
+            // IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())
+            // &&
+            // (partition.getOffset() != offset))
+            //         return;
+            final char character = event.character;
+            final char closingCharacter = getPeerCharacter(character);
+            final StringBuffer buffer = new StringBuffer();
+            buffer.append(character);
+            buffer.append(closingCharacter);
+            document.replace(offset, length, buffer.toString());
+            LinkedPositionManager manager = new LinkedPositionManager(document);
+            manager.addPosition(offset + 1, 0);
+            fOffset = offset;
+            fLength = 2;
+            LinkedPositionUI editor = new LinkedPositionUI(sourceViewer,
+                manager);
+            editor.setCancelListener(this);
+            editor.setExitPolicy(new ExitPolicy(closingCharacter));
+            editor.setFinalCaretOffset(offset + 2);
+            editor.enter();
+            IRegion newSelection = editor.getSelectedRegion();
+            sourceViewer.setSelectedRange(newSelection.getOffset(),
+                newSelection.getLength());
+            event.doit = false;
+          }
+        }
+      } catch (BadLocationException e) {
+      }
+    }
+
+    /*
+     * @see org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionUI.ExitListener#exit(boolean)
+     */
+    public void exit(boolean accept) {
+      if (accept)
+        return;
+      // remove brackets
+      try {
+        final ISourceViewer sourceViewer = getSourceViewer();
+        IDocument document = sourceViewer.getDocument();
+        document.replace(fOffset, fLength, null);
+      } catch (BadLocationException e) {
+      }
+    }
+  }
+
+  /** The editor's save policy */
+  protected ISavePolicy fSavePolicy;
+
+  /**
+   * Listener to annotation model changes that updates the error tick in the tab
+   * image
+   */
+  private JavaEditorErrorTickUpdater fJavaEditorErrorTickUpdater;
+
+  /** The editor's paint manager */
+  //  private PaintManager fPaintManager;
+  /** The editor's bracket painter */
+  private BracketPainter fBracketPainter;
+
+  /** The editor's bracket matcher */
+  private PHPPairMatcher fBracketMatcher;
+
+  /** The editor's line painter */
+  private LinePainter fLinePainter;
+
+  /** The editor's print margin ruler painter */
+  private PrintMarginPainter fPrintMarginPainter;
+
+  /** The editor's problem painter */
+  //  private ProblemPainter fProblemPainter;
+  /** The editor's tab converter */
+  private TabConverter fTabConverter;
+
+  /** History for structure select action */
+  //private SelectionHistory fSelectionHistory;
+  /** The preference property change listener for php core. */
+  //  private IPropertyChangeListener fPropertyChangeListener = new
+  // PropertyChangeListener();
+  /** The remembered java element */
+  private IJavaElement fRememberedElement;
+
+  /** The remembered selection */
+  private ITextSelection fRememberedSelection;
+
+  /** The remembered php element offset */
+  private int fRememberedElementOffset;
+
+  /** The bracket inserter. */
+  private BracketInserter fBracketInserter = new BracketInserter();
+
+  /** The standard action groups added to the menu */
+  private GenerateActionGroup fGenerateActionGroup;
+
+  private CompositeActionGroup fContextMenuGroup;
+
+  //  private class PropertyChangeListener implements IPropertyChangeListener {
+  //    /*
+  //     * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
+  //     */
+  //    public void
+  // propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent
+  // event) {
+  //      handlePreferencePropertyChanged(event);
+  //    }
+  //  }
+  /* Preference key for code formatter tab size */
+  private final static String CODE_FORMATTER_TAB_SIZE = JavaCore.FORMATTER_TAB_SIZE;
+
+  /** Preference key for matching brackets */
+  private final static String MATCHING_BRACKETS = PreferenceConstants.EDITOR_MATCHING_BRACKETS;
+
+  /** Preference key for matching brackets color */
+  private final static String MATCHING_BRACKETS_COLOR = PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR;
+
+  /** Preference key for highlighting current line */
+  private final static String CURRENT_LINE = PreferenceConstants.EDITOR_CURRENT_LINE;
+
+  /** Preference key for highlight color of current line */
+  private final static String CURRENT_LINE_COLOR = PreferenceConstants.EDITOR_CURRENT_LINE_COLOR;
+
+  /** Preference key for showing print marging ruler */
+  private final static String PRINT_MARGIN = PreferenceConstants.EDITOR_PRINT_MARGIN;
+
+  /** Preference key for print margin ruler color */
+  private final static String PRINT_MARGIN_COLOR = PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR;
+
+  /** Preference key for print margin ruler column */
+  private final static String PRINT_MARGIN_COLUMN = PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN;
+
+  /** Preference key for inserting spaces rather than tabs */
+  private final static String SPACES_FOR_TABS = PreferenceConstants.EDITOR_SPACES_FOR_TABS;
+
+  /** Preference key for error indication */
+  //  private final static String ERROR_INDICATION =
+  // PreferenceConstants.EDITOR_PROBLEM_INDICATION;
+  /** Preference key for error color */
+  //  private final static String ERROR_INDICATION_COLOR =
+  // PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR;
+  /** Preference key for warning indication */
+  //  private final static String WARNING_INDICATION =
+  // PreferenceConstants.EDITOR_WARNING_INDICATION;
+  /** Preference key for warning color */
+  //  private final static String WARNING_INDICATION_COLOR =
+  // PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR;
+  /** Preference key for task indication */
+  private final static String TASK_INDICATION = PreferenceConstants.EDITOR_TASK_INDICATION;
+
+  /** Preference key for task color */
+  private final static String TASK_INDICATION_COLOR = PreferenceConstants.EDITOR_TASK_INDICATION_COLOR;
+
+  /** Preference key for bookmark indication */
+  private final static String BOOKMARK_INDICATION = PreferenceConstants.EDITOR_BOOKMARK_INDICATION;
+
+  /** Preference key for bookmark color */
+  private final static String BOOKMARK_INDICATION_COLOR = PreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR;
+
+  /** Preference key for search result indication */
+  private final static String SEARCH_RESULT_INDICATION = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION;
+
+  /** Preference key for search result color */
+  private final static String SEARCH_RESULT_INDICATION_COLOR = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR;
+
+  /** Preference key for unknown annotation indication */
+  private final static String UNKNOWN_INDICATION = PreferenceConstants.EDITOR_UNKNOWN_INDICATION;
+
+  /** Preference key for unknown annotation color */
+  private final static String UNKNOWN_INDICATION_COLOR = PreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR;
+
+  /** Preference key for linked position color */
+  private final static String LINKED_POSITION_COLOR = PreferenceConstants.EDITOR_LINKED_POSITION_COLOR;
+
+  /** Preference key for shwoing the overview ruler */
+  private final static String OVERVIEW_RULER = PreferenceConstants.EDITOR_OVERVIEW_RULER;
+
+  /** Preference key for error indication in overview ruler */
+  private final static String ERROR_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER;
+
+  /** Preference key for warning indication in overview ruler */
+  private final static String WARNING_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER;
+
+  /** Preference key for task indication in overview ruler */
+  private final static String TASK_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER;
+
+  /** Preference key for bookmark indication in overview ruler */
+  private final static String BOOKMARK_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER;
+
+  /** Preference key for search result indication in overview ruler */
+  private final static String SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER;
+
+  /** Preference key for unknown annotation indication in overview ruler */
+  private final static String UNKNOWN_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER;
+
+  /** Preference key for automatically closing strings */
+  private final static String CLOSE_STRINGS_PHP = PreferenceConstants.EDITOR_CLOSE_STRINGS_PHP;
+
+  /** Preference key for automatically wrapping Java strings */
+  private final static String WRAP_STRINGS = PreferenceConstants.EDITOR_WRAP_STRINGS;
+
+  /** Preference key for automatically closing brackets and parenthesis */
+  private final static String CLOSE_BRACKETS_PHP = PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP;
+
+  /** Preference key for automatically closing phpdocs and comments */
+  private final static String CLOSE_JAVADOCS = PreferenceConstants.EDITOR_CLOSE_JAVADOCS;
+
+  /** Preference key for automatically adding phpdoc tags */
+  private final static String ADD_JAVADOC_TAGS = PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS;
+
+  /** Preference key for automatically formatting phpdocs */
+  private final static String FORMAT_JAVADOCS = PreferenceConstants.EDITOR_FORMAT_JAVADOCS;
+
+  /** Preference key for automatically closing strings */
+  private final static String CLOSE_STRINGS_HTML = PreferenceConstants.EDITOR_CLOSE_STRINGS_HTML;
+
+  /** Preference key for automatically closing brackets and parenthesis */
+  private final static String CLOSE_BRACKETS_HTML = PreferenceConstants.EDITOR_CLOSE_BRACKETS_HTML;
+
+  /** Preference key for smart paste */
+  private final static String SMART_PASTE = PreferenceConstants.EDITOR_SMART_PASTE;
+
+  //  private final static class AnnotationInfo {
+  //    public String fColorPreference;
+  //    public String fOverviewRulerPreference;
+  //    public String fEditorPreference;
+  //  };
+  //  private final static Map ANNOTATION_MAP;
+  //  static {
+  //
+  //    AnnotationInfo info;
+  //    ANNOTATION_MAP = new HashMap();
+  //
+  //    info = new AnnotationInfo();
+  //    info.fColorPreference = TASK_INDICATION_COLOR;
+  //    info.fOverviewRulerPreference = TASK_INDICATION_IN_OVERVIEW_RULER;
+  //    info.fEditorPreference = TASK_INDICATION;
+  //    ANNOTATION_MAP.put(AnnotationType.TASK, info);
+  //
+  //    info = new AnnotationInfo();
+  //    info.fColorPreference = ERROR_INDICATION_COLOR;
+  //    info.fOverviewRulerPreference = ERROR_INDICATION_IN_OVERVIEW_RULER;
+  //    info.fEditorPreference = ERROR_INDICATION;
+  //    ANNOTATION_MAP.put(AnnotationType.ERROR, info);
+  //
+  //    info = new AnnotationInfo();
+  //    info.fColorPreference = WARNING_INDICATION_COLOR;
+  //    info.fOverviewRulerPreference = WARNING_INDICATION_IN_OVERVIEW_RULER;
+  //    info.fEditorPreference = WARNING_INDICATION;
+  //    ANNOTATION_MAP.put(AnnotationType.WARNING, info);
+  //
+  //    info = new AnnotationInfo();
+  //    info.fColorPreference = BOOKMARK_INDICATION_COLOR;
+  //    info.fOverviewRulerPreference = BOOKMARK_INDICATION_IN_OVERVIEW_RULER;
+  //    info.fEditorPreference = BOOKMARK_INDICATION;
+  //    ANNOTATION_MAP.put(AnnotationType.BOOKMARK, info);
+  //
+  //    info = new AnnotationInfo();
+  //    info.fColorPreference = SEARCH_RESULT_INDICATION_COLOR;
+  //    info.fOverviewRulerPreference =
+  // SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER;
+  //    info.fEditorPreference = SEARCH_RESULT_INDICATION;
+  //    ANNOTATION_MAP.put(AnnotationType.SEARCH, info);
+  //
+  //    info = new AnnotationInfo();
+  //    info.fColorPreference = UNKNOWN_INDICATION_COLOR;
+  //    info.fOverviewRulerPreference = UNKNOWN_INDICATION_IN_OVERVIEW_RULER;
+  //    info.fEditorPreference = UNKNOWN_INDICATION;
+  //    ANNOTATION_MAP.put(AnnotationType.UNKNOWN, info);
+  //  };
+  //
+  //  private final static AnnotationType[] ANNOTATION_LAYERS =
+  //    new AnnotationType[] {
+  //      AnnotationType.UNKNOWN,
+  //      AnnotationType.BOOKMARK,
+  //      AnnotationType.TASK,
+  //      AnnotationType.SEARCH,
+  //      AnnotationType.WARNING,
+  //      AnnotationType.ERROR };
+  /**
+   * Creates a new php unit editor.
+   */
+  public PHPUnitEditor() {
+    super();
+    setDocumentProvider(PHPeclipsePlugin.getDefault()
+        .getCompilationUnitDocumentProvider());
+    setEditorContextMenuId("#PHPEditorContext"); //$NON-NLS-1$
+    setRulerContextMenuId("#PHPRulerContext"); //$NON-NLS-1$
+    setOutlinerContextMenuId("#PHPOutlinerContext"); //$NON-NLS-1$
+    // don't set help contextId, we install our own help context
+    fSavePolicy = null;
+    fJavaEditorErrorTickUpdater = new JavaEditorErrorTickUpdater(this);
+  }
+
+  /*
+   * @see AbstractTextEditor#createActions()
+   */
+  protected void createActions() {
+    super.createActions();
+    Action action;
+    //         Action action= new
+    // TextOperationAction(PHPEditorMessages.getResourceBundle(),
+    // "CorrectionAssistProposal.", this, CORRECTIONASSIST_PROPOSALS);
+    // //$NON-NLS-1$
+    //         action.setActionDefinitionId(PHPEditorActionDefinitionIds.CORRECTION_ASSIST_PROPOSALS);
+    //         setAction("CorrectionAssistProposal", action); //$NON-NLS-1$
+    //         markAsStateDependentAction("CorrectionAssistProposal", true);
+    // //$NON-NLS-1$
+    //// WorkbenchHelp.setHelp(action,
+    // IJavaHelpContextIds.QUICK_FIX_ACTION);
+    action = new ContentAssistAction(PHPEditorMessages.getResourceBundle(),
+        "ContentAssistProposal.", this); //$NON-NLS-1$
+    action
+        .setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+    setAction("ContentAssistProposal", action); //$NON-NLS-1$
+    markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
+    //         WorkbenchHelp.setHelp(action,
+    // IJavaHelpContextIds.CONTENT_ASSIST_ACTION);
+    //         action = new TextOperationAction(PHPEditorMessages.getResourceBundle(),
+    //                         "ContentAssistContextInformation.", this,
+    //                         ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION); //$NON-NLS-1$
+    //         action
+    //                         .setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
+    //         setAction("ContentAssistContextInformation", action); //$NON-NLS-1$
+    //         markAsStateDependentAction("ContentAssistContextInformation", true);
+    // //$NON-NLS-1$
+    //         WorkbenchHelp.setHelp(action,
+    // IJavaHelpContextIds.PARAMETER_HINTS_ACTION);
+    //         action= new
+    // TextOperationAction(PHPEditorMessages.getResourceBundle(),
+    // "ContentAssistCompletePrefix.", this, CONTENTASSIST_COMPLETE_PREFIX);
+    // //$NON-NLS-1$
+    //         action.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_COMPLETE_PREFIX);
+    //         setAction("ContentAssistCompletePrefix", action); //$NON-NLS-1$
+    //         markAsStateDependentAction("ContentAssistCompletePrefix", true);
+    // //$NON-NLS-1$
+    //// WorkbenchHelp.setHelp(action,
+    // IJavaHelpContextIds.PARAMETER_HINTS_ACTION);
+    action = new TextOperationAction(PHPEditorMessages.getResourceBundle(),
+        "Comment.", this, ITextOperationTarget.PREFIX); //$NON-NLS-1$
+    action.setActionDefinitionId(PHPEditorActionDefinitionIds.COMMENT);
+    setAction("Comment", action); //$NON-NLS-1$
+    markAsStateDependentAction("Comment", true); //$NON-NLS-1$
+    //         WorkbenchHelp.setHelp(action, IJavaHelpContextIds.COMMENT_ACTION);
+    action = new TextOperationAction(PHPEditorMessages.getResourceBundle(),
+        "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX); //$NON-NLS-1$
+    action.setActionDefinitionId(PHPEditorActionDefinitionIds.UNCOMMENT);
+    setAction("Uncomment", action); //$NON-NLS-1$
+    markAsStateDependentAction("Uncomment", true); //$NON-NLS-1$
+    //         WorkbenchHelp.setHelp(action, IJavaHelpContextIds.UNCOMMENT_ACTION);
+
+    action = new ToggleCommentAction(PHPEditorMessages.getResourceBundle(),
+        "ToggleComment.", this); //$NON-NLS-1$
+    action.setActionDefinitionId(PHPEditorActionDefinitionIds.TOGGLE_COMMENT);
+    setAction("ToggleComment", action); //$NON-NLS-1$
+    markAsStateDependentAction("ToggleComment", true); //$NON-NLS-1$
+    //WorkbenchHelp.setHelp(action,
+    // IJavaHelpContextIds.TOGGLE_COMMENT_ACTION);
+    configureToggleCommentAction();
+       
+    action = new TextOperationAction(PHPEditorMessages.getResourceBundle(),
+        "Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$
+    action.setActionDefinitionId(PHPEditorActionDefinitionIds.FORMAT);
+    setAction("Format", action); //$NON-NLS-1$
+    markAsStateDependentAction("Format", true); //$NON-NLS-1$
+    markAsSelectionDependentAction("Format", true); //$NON-NLS-1$              
+    //         WorkbenchHelp.setHelp(action, IJavaHelpContextIds.FORMAT_ACTION);
+
+//    action = new AddBlockCommentAction(PHPEditorMessages.getResourceBundle(),
+//        "AddBlockComment.", this); //$NON-NLS-1$
+//    action
+//        .setActionDefinitionId(PHPEditorActionDefinitionIds.ADD_BLOCK_COMMENT);
+//    setAction("AddBlockComment", action); //$NON-NLS-1$
+//    markAsStateDependentAction("AddBlockComment", true); //$NON-NLS-1$
+//    markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$           
+//    //               WorkbenchHelp.setHelp(action,
+//    // IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION);
+//    action = new RemoveBlockCommentAction(
+//        PHPEditorMessages.getResourceBundle(), "RemoveBlockComment.", this); //$NON-NLS-1$
+//    action
+//        .setActionDefinitionId(PHPEditorActionDefinitionIds.REMOVE_BLOCK_COMMENT);
+//    setAction("RemoveBlockComment", action); //$NON-NLS-1$
+//    markAsStateDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
+//    markAsSelectionDependentAction("RemoveBlockComment", true); //$NON-NLS-1$                
+    //         WorkbenchHelp.setHelp(action,
+    // IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION);
+    //         action= new IndentAction(PHPEditorMessages.getResourceBundle(),
+    // "Indent.", this, false); //$NON-NLS-1$
+    //         action.setActionDefinitionId(PHPEditorActionDefinitionIds.INDENT);
+    //         setAction("Indent", action); //$NON-NLS-1$
+    //         markAsStateDependentAction("Indent", true); //$NON-NLS-1$
+    //         markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$
+    //// WorkbenchHelp.setHelp(action, IJavaHelpContextIds.INDENT_ACTION);
+    //         
+    //         action= new IndentAction(PHPEditorMessages.getResourceBundle(),
+    // "Indent.", this, true); //$NON-NLS-1$
+    //         setAction("IndentOnTab", action); //$NON-NLS-1$
+    //         markAsStateDependentAction("IndentOnTab", true); //$NON-NLS-1$
+    //         markAsSelectionDependentAction("IndentOnTab", true); //$NON-NLS-1$
+    //         
+    if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_TAB)) {
+      // don't replace Shift Right - have to make sure their enablement is
+      // mutually exclusive
+      //                       removeActionActivationCode(ITextEditorActionConstants.SHIFT_RIGHT);
+      setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$
+    }
+    fGenerateActionGroup = new GenerateActionGroup(this,
+        ITextEditorActionConstants.GROUP_EDIT);
+    fActionGroups = new CompositeActionGroup(
+        new ActionGroup[] { fGenerateActionGroup });
+    //   We have to keep the context menu group separate to have better
+    // control
+    // over positioning
+    fContextMenuGroup = new CompositeActionGroup(
+        new ActionGroup[] { fGenerateActionGroup });
+    //      rg,
+    //      new LocalHistoryActionGroup(this,
+    // ITextEditorActionConstants.GROUP_EDIT)});
+
+  }
+
+  /*
+   * @see JavaEditor#getElementAt(int)
+   */
+  protected IJavaElement getElementAt(int offset) {
+    return getElementAt(offset, true);
+  }
+
+  /**
+   * Returns the most narrow element including the given offset. If
+   * <code>reconcile</code> is <code>true</code> the editor's input element
+   * is reconciled in advance. If it is <code>false</code> this method only
+   * returns a result if the editor's input element does not need to be
+   * reconciled.
+   * 
+   * @param offset
+   *          the offset included by the retrieved element
+   * @param reconcile
+   *          <code>true</code> if working copy should be reconciled
+   */
+  protected IJavaElement getElementAt(int offset, boolean reconcile) {
+    IWorkingCopyManager manager = PHPeclipsePlugin.getDefault()
+        .getWorkingCopyManager();
+    ICompilationUnit unit = manager.getWorkingCopy(getEditorInput());
+    if (unit != null) {
+      try {
+        if (reconcile) {
+          synchronized (unit) {
+            unit.reconcile();
+          }
+          return unit.getElementAt(offset);
+        } else if (unit.isConsistent())
+          return unit.getElementAt(offset);
+      } catch (JavaModelException x) {
+        PHPeclipsePlugin.log(x.getStatus());
+        // nothing found, be tolerant and go on
+      }
+    }
+    return null;
+  }
+
+  /*
+   * @see JavaEditor#getCorrespondingElement(IJavaElement)
+   */
+  protected IJavaElement getCorrespondingElement(IJavaElement element) {
+    try {
+      return EditorUtility.getWorkingCopy(element, true);
+    } catch (JavaModelException x) {
+      PHPeclipsePlugin.log(x.getStatus());
+      // nothing found, be tolerant and go on
+    }
+    return null;
+  }
+
+  public void createPartControl(Composite parent) {
+    super.createPartControl(parent);
+    //    fPaintManager = new PaintManager(getSourceViewer());
+    LinePainter linePainter;
+    linePainter = new LinePainter(getSourceViewer());
+    linePainter
+        .setHighlightColor(new Color(Display.getCurrent(), 225, 235, 224));
+    //    fPaintManager.addPainter(linePainter);
+    if (isBracketHighlightingEnabled())
+      startBracketHighlighting();
+    if (isLineHighlightingEnabled())
+      startLineHighlighting();
+    if (isPrintMarginVisible())
+      showPrintMargin();
+    //    Iterator e = ANNOTATION_MAP.keySet().iterator();
+    //    while (e.hasNext()) {
+    //      AnnotationType type = (AnnotationType) e.next();
+    //      if (isAnnotationIndicationEnabled(type))
+    //        startAnnotationIndication(type);
+    //    }
+    if (isTabConversionEnabled())
+      startTabConversion();
+    //    if (isOverviewRulerVisible())
+    //      showOverviewRuler();
+    //
+    //    Preferences preferences =
+    // PHPeclipsePlugin.getDefault().getPluginPreferences();
+    //    preferences.addPropertyChangeListener(fPropertyChangeListener);
+    IPreferenceStore preferenceStore = getPreferenceStore();
+    boolean closeBracketsPHP = preferenceStore.getBoolean(CLOSE_BRACKETS_PHP);
+    boolean closeStringsPHP = preferenceStore.getBoolean(CLOSE_STRINGS_PHP);
+    boolean closeBracketsHTML = preferenceStore.getBoolean(CLOSE_BRACKETS_HTML);
+    boolean closeStringsHTML = preferenceStore.getBoolean(CLOSE_STRINGS_HTML);
+    fBracketInserter.setCloseBracketsPHPEnabled(closeBracketsPHP);
+    fBracketInserter.setCloseStringsPHPEnabled(closeStringsPHP);
+    fBracketInserter.setCloseBracketsHTMLEnabled(closeBracketsHTML);
+    fBracketInserter.setCloseStringsHTMLEnabled(closeStringsHTML);
+    ISourceViewer sourceViewer = getSourceViewer();
+    if (sourceViewer instanceof ITextViewerExtension)
+      ((ITextViewerExtension) sourceViewer)
+          .prependVerifyKeyListener(fBracketInserter);
+  }
+
+  private static char getPeerCharacter(char character) {
+    switch (character) {
+    case '(':
+      return ')';
+    case ')':
+      return '(';
+    case '[':
+      return ']';
+    case ']':
+      return '[';
+    case '"':
+      return character;
+    default:
+      throw new IllegalArgumentException();
+    }
+  }
+
+  private void startBracketHighlighting() {
+    if (fBracketPainter == null) {
+      ISourceViewer sourceViewer = getSourceViewer();
+      fBracketPainter = new BracketPainter(sourceViewer);
+      fBracketPainter.setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
+      //      fPaintManager.addPainter(fBracketPainter);
+    }
+  }
+
+  private void stopBracketHighlighting() {
+    if (fBracketPainter != null) {
+      //      fPaintManager.removePainter(fBracketPainter);
+      fBracketPainter.deactivate(true);
+      fBracketPainter.dispose();
+      fBracketPainter = null;
+    }
+  }
+
+  private boolean isBracketHighlightingEnabled() {
+    IPreferenceStore store = getPreferenceStore();
+    return store.getBoolean(MATCHING_BRACKETS);
+  }
+
+  private void startLineHighlighting() {
+    if (fLinePainter == null) {
+      ISourceViewer sourceViewer = getSourceViewer();
+      fLinePainter = new LinePainter(sourceViewer);
+      fLinePainter.setHighlightColor(getColor(CURRENT_LINE_COLOR));
+      //      fPaintManager.addPainter(fLinePainter);
+    }
+  }
+
+  private void stopLineHighlighting() {
+    if (fLinePainter != null) {
+      //      fPaintManager.removePainter(fLinePainter);
+      fLinePainter.deactivate(true);
+      fLinePainter.dispose();
+      fLinePainter = null;
+    }
+  }
+
+  private boolean isLineHighlightingEnabled() {
+    IPreferenceStore store = getPreferenceStore();
+    return store.getBoolean(CURRENT_LINE);
+  }
+
+  private void showPrintMargin() {
+    if (fPrintMarginPainter == null) {
+      fPrintMarginPainter = new PrintMarginPainter(getSourceViewer());
+      fPrintMarginPainter.setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
+      fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(
+          PRINT_MARGIN_COLUMN));
+      //      fPaintManager.addPainter(fPrintMarginPainter);
+    }
+  }
+
+  private void hidePrintMargin() {
+    if (fPrintMarginPainter != null) {
+      //      fPaintManager.removePainter(fPrintMarginPainter);
+      fPrintMarginPainter.deactivate(true);
+      fPrintMarginPainter.dispose();
+      fPrintMarginPainter = null;
+    }
+  }
+
+  private boolean isPrintMarginVisible() {
+    IPreferenceStore store = getPreferenceStore();
+    return store.getBoolean(PRINT_MARGIN);
+  }
+
+  //  private void startAnnotationIndication(AnnotationType annotationType) {
+  //    if (fProblemPainter == null) {
+  //      fProblemPainter = new ProblemPainter(this, getSourceViewer());
+  //// fPaintManager.addPainter(fProblemPainter);
+  //    }
+  //    fProblemPainter.setColor(annotationType, getColor(annotationType));
+  //    fProblemPainter.paintAnnotations(annotationType, true);
+  //    fProblemPainter.paint(IPainter.CONFIGURATION);
+  //  }
+  //
+  //  private void shutdownAnnotationIndication() {
+  //    if (fProblemPainter != null) {
+  //
+  //      if (!fProblemPainter.isPaintingAnnotations()) {
+  //// fPaintManager.removePainter(fProblemPainter);
+  //        fProblemPainter.deactivate(true);
+  //        fProblemPainter.dispose();
+  //        fProblemPainter = null;
+  //      } else {
+  //        fProblemPainter.paint(IPainter.CONFIGURATION);
+  //      }
+  //    }
+  //  }
+  //
+  //  private void stopAnnotationIndication(AnnotationType annotationType) {
+  //    if (fProblemPainter != null) {
+  //      fProblemPainter.paintAnnotations(annotationType, false);
+  //      shutdownAnnotationIndication();
+  //    }
+  //  }
+  //
+  //  private boolean isAnnotationIndicationEnabled(AnnotationType
+  // annotationType) {
+  //    IPreferenceStore store = getPreferenceStore();
+  //    AnnotationInfo info = (AnnotationInfo)
+  // ANNOTATION_MAP.get(annotationType);
+  //    if (info != null)
+  //      return store.getBoolean(info.fEditorPreference);
+  //    return false;
+  //  }
+  //
+  //  private boolean
+  // isAnnotationIndicationInOverviewRulerEnabled(AnnotationType
+  // annotationType) {
+  //    IPreferenceStore store = getPreferenceStore();
+  //    AnnotationInfo info = (AnnotationInfo)
+  // ANNOTATION_MAP.get(annotationType);
+  //    if (info != null)
+  //      return store.getBoolean(info.fOverviewRulerPreference);
+  //    return false;
+  //  }
+  //
+  //  private void showAnnotationIndicationInOverviewRuler(AnnotationType
+  // annotationType, boolean show) {
+  //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
+  //    OverviewRuler ruler = asv.getOverviewRuler();
+  //    if (ruler != null) {
+  //      ruler.setColor(annotationType, getColor(annotationType));
+  //      ruler.showAnnotation(annotationType, show);
+  //      ruler.update();
+  //    }
+  //  }
+  //
+  //  private void setColorInOverviewRuler(AnnotationType annotationType, Color
+  // color) {
+  //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
+  //    OverviewRuler ruler = asv.getOverviewRuler();
+  //    if (ruler != null) {
+  //      ruler.setColor(annotationType, color);
+  //      ruler.update();
+  //    }
+  //  }
+
+  private int getTabSize() {
+    Preferences preferences = PHPeclipsePlugin.getDefault()
+        .getPluginPreferences();
+    return preferences.getInt(CODE_FORMATTER_TAB_SIZE);
+  }
+
+  private boolean isTabConversionEnabled() {
+    IPreferenceStore store = getPreferenceStore();
+    return store.getBoolean(SPACES_FOR_TABS);
+  }
+
+  //  private void showOverviewRuler() {
+  //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
+  //    asv.showOverviewRuler();
+  //
+  //    OverviewRuler overviewRuler = asv.getOverviewRuler();
+  //    if (overviewRuler != null) {
+  //      for (int i = 0; i < ANNOTATION_LAYERS.length; i++) {
+  //        AnnotationType type = ANNOTATION_LAYERS[i];
+  //        overviewRuler.setLayer(type, i);
+  //        if (isAnnotationIndicationInOverviewRulerEnabled(type))
+  //          showAnnotationIndicationInOverviewRuler(type, true);
+  //      }
+  //    }
+  //  }
+  //
+  //  private void hideOverviewRuler() {
+  //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
+  //    asv.hideOverviewRuler();
+  //  }
+  //
+  //  private boolean isOverviewRulerVisible() {
+  //    IPreferenceStore store = getPreferenceStore();
+  //    return store.getBoolean(OVERVIEW_RULER);
+  //  }
+  private Color getColor(String key) {
+    RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), key);
+    return getColor(rgb);
+  }
+
+  private Color getColor(RGB rgb) {
+    JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
+    return textTools.getColorManager().getColor(rgb);
+  }
+
+  //  private Color getColor(AnnotationType annotationType) {
+  //    AnnotationInfo info = (AnnotationInfo)
+  // ANNOTATION_MAP.get(annotationType);
+  //    if (info != null)
+  //      return getColor(info.fColorPreference);
+  //    return null;
+  //  }
+  public void dispose() {
+    ISourceViewer sourceViewer = getSourceViewer();
+    if (sourceViewer instanceof ITextViewerExtension)
+      ((ITextViewerExtension) sourceViewer)
+          .removeVerifyKeyListener(fBracketInserter);
+    //    if (fPropertyChangeListener != null) {
+    //      Preferences preferences =
+    // PHPeclipsePlugin.getDefault().getPluginPreferences();
+    //      preferences.removePropertyChangeListener(fPropertyChangeListener);
+    //      fPropertyChangeListener = null;
+    //    }
+    if (fJavaEditorErrorTickUpdater != null) {
+      fJavaEditorErrorTickUpdater.dispose();
+      fJavaEditorErrorTickUpdater = null;
+    }
+    //    if (fSelectionHistory != null)
+    //      fSelectionHistory.dispose();
+    //    if (fPaintManager != null) {
+    //      fPaintManager.dispose();
+    //      fPaintManager = null;
+    //    }
+    if (fActionGroups != null) {
+      fActionGroups.dispose();
+      fActionGroups = null;
+    }
+    super.dispose();
+  }
+
+  //  protected AnnotationType getAnnotationType(String preferenceKey) {
+  //    Iterator e = ANNOTATION_MAP.keySet().iterator();
+  //    while (e.hasNext()) {
+  //      AnnotationType type = (AnnotationType) e.next();
+  //      AnnotationInfo info = (AnnotationInfo) ANNOTATION_MAP.get(type);
+  //      if (info != null) {
+  //        if (preferenceKey.equals(info.fColorPreference)
+  //          || preferenceKey.equals(info.fEditorPreference)
+  //          || preferenceKey.equals(info.fOverviewRulerPreference))
+  //          return type;
+  //      }
+  //    }
+  //    return null;
+  //  }
+  /*
+   * @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent)
+   */
+  protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
+    try {
+      AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
+      if (asv != null) {
+        String p = event.getProperty();
+        if (CLOSE_BRACKETS_PHP.equals(p)) {
+          fBracketInserter.setCloseBracketsPHPEnabled(getPreferenceStore()
+              .getBoolean(p));
+          return;
+        }
+        if (CLOSE_STRINGS_PHP.equals(p)) {
+          fBracketInserter.setCloseStringsPHPEnabled(getPreferenceStore()
+              .getBoolean(p));
+          return;
+        }
+        if (CLOSE_BRACKETS_HTML.equals(p)) {
+          fBracketInserter.setCloseBracketsHTMLEnabled(getPreferenceStore()
+              .getBoolean(p));
+          return;
+        }
+        if (CLOSE_STRINGS_HTML.equals(p)) {
+          fBracketInserter.setCloseStringsHTMLEnabled(getPreferenceStore()
+              .getBoolean(p));
+          return;
+        }
+        if (SPACES_FOR_TABS.equals(p)) {
+          if (isTabConversionEnabled())
+            startTabConversion();
+          else
+            stopTabConversion();
+          return;
+        }
+        if (MATCHING_BRACKETS.equals(p)) {
+          if (isBracketHighlightingEnabled())
+            startBracketHighlighting();
+          else
+            stopBracketHighlighting();
+          return;
+        }
+        if (MATCHING_BRACKETS_COLOR.equals(p)) {
+          if (fBracketPainter != null)
+            fBracketPainter
+                .setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
+          return;
+        }
+        if (CURRENT_LINE.equals(p)) {
+          if (isLineHighlightingEnabled())
+            startLineHighlighting();
+          else
+            stopLineHighlighting();
+          return;
+        }
+        if (CURRENT_LINE_COLOR.equals(p)) {
+          if (fLinePainter != null) {
+            stopLineHighlighting();
+            startLineHighlighting();
+          }
+          return;
+        }
+        if (PRINT_MARGIN.equals(p)) {
+          if (isPrintMarginVisible())
+            showPrintMargin();
+          else
+            hidePrintMargin();
+          return;
+        }
+        if (PRINT_MARGIN_COLOR.equals(p)) {
+          if (fPrintMarginPainter != null)
+            fPrintMarginPainter
+                .setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
+          return;
+        }
+        if (PRINT_MARGIN_COLUMN.equals(p)) {
+          if (fPrintMarginPainter != null)
+            fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore()
+                .getInt(PRINT_MARGIN_COLUMN));
+          return;
+        }
+        //        if (OVERVIEW_RULER.equals(p)) {
+        //          if (isOverviewRulerVisible())
+        //            showOverviewRuler();
+        //          else
+        //            hideOverviewRuler();
+        //          return;
+        //        }
+        //        AnnotationType type = getAnnotationType(p);
+        //        if (type != null) {
+        //
+        //          AnnotationInfo info = (AnnotationInfo)
+        // ANNOTATION_MAP.get(type);
+        //          if (info.fColorPreference.equals(p)) {
+        //            Color color = getColor(type);
+        //            if (fProblemPainter != null) {
+        //              fProblemPainter.setColor(type, color);
+        //              fProblemPainter.paint(IPainter.CONFIGURATION);
+        //            }
+        //            setColorInOverviewRuler(type, color);
+        //            return;
+        //          }
+        //
+        //          if (info.fEditorPreference.equals(p)) {
+        //            if (isAnnotationIndicationEnabled(type))
+        //              startAnnotationIndication(type);
+        //            else
+        //              stopAnnotationIndication(type);
+        //            return;
+        //          }
+        //
+        //          if (info.fOverviewRulerPreference.equals(p)) {
+        //            if (isAnnotationIndicationInOverviewRulerEnabled(type))
+        //              showAnnotationIndicationInOverviewRuler(type, true);
+        //            else
+        //              showAnnotationIndicationInOverviewRuler(type, false);
+        //            return;
+        //          }
+        //        }
+        IContentAssistant c = asv.getContentAssistant();
+        if (c instanceof ContentAssistant)
+          ContentAssistPreference.changeConfiguration((ContentAssistant) c,
+              getPreferenceStore(), event);
+      }
+    } finally {
+      super.handlePreferenceStoreChanged(event);
+    }
+  }
+
+  /*
+   * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent)
+   */
+  protected void handlePreferencePropertyChanged(
+      org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
+    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
+    if (asv != null) {
+      String p = event.getProperty();
+      if (CODE_FORMATTER_TAB_SIZE.equals(p)) {
+        asv.updateIndentationPrefixes();
+        if (fTabConverter != null)
+          fTabConverter.setNumberOfSpacesPerTab(getTabSize());
+      }
+    }
+    super.handlePreferencePropertyChanged(event);
+  }
+
+  /**
+   * Handles a property change event describing a change of the php core's
+   * preferences and updates the preference related editor properties.
+   * 
+   * @param event
+   *          the property change event
+   */
+  //  protected void
+  // handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent
+  // event) {
+  //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
+  //    if (asv != null) {
+  //      String p = event.getProperty();
+  //      if (CODE_FORMATTER_TAB_SIZE.equals(p)) {
+  //        asv.updateIndentationPrefixes();
+  //        if (fTabConverter != null)
+  //          fTabConverter.setNumberOfSpacesPerTab(getTabSize());
+  //      }
+  //    }
+  //  }
+  /*
+   * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#createJavaSourceViewer(org.eclipse.swt.widgets.Composite,
+   *      org.eclipse.jface.text.source.IVerticalRuler,
+   *      org.eclipse.jface.text.source.IOverviewRuler, boolean, int)
+   */
+  protected ISourceViewer createJavaSourceViewer(Composite parent,
+      IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
+      boolean isOverviewRulerVisible, int styles, IPreferenceStore store) {
+    return new AdaptedSourceViewer(parent, verticalRuler, overviewRuler,
+        isOverviewRulerVisible, styles, store);
+  }
+
+  //  protected ISourceViewer createJavaSourceViewer(Composite parent,
+  // IVerticalRuler ruler, int styles) {
+  //    return new AdaptedSourceViewer(parent, ruler, styles);
+  //  }
+  private boolean isValidSelection(int offset, int length) {
+    IDocumentProvider provider = getDocumentProvider();
+    if (provider != null) {
+      IDocument document = provider.getDocument(getEditorInput());
+      if (document != null) {
+        int end = offset + length;
+        int documentLength = document.getLength();
+        return 0 <= offset && offset <= documentLength && 0 <= end
+            && end <= documentLength;
+      }
+    }
+    return false;
+  }
+
+  /*
+   * @see AbstractTextEditor#canHandleMove(IEditorInput, IEditorInput)
+   */
+  protected boolean canHandleMove(IEditorInput originalElement,
+      IEditorInput movedElement) {
+    String oldExtension = ""; //$NON-NLS-1$
+    if (originalElement instanceof IFileEditorInput) {
+      IFile file = ((IFileEditorInput) originalElement).getFile();
+      if (file != null) {
+        String ext = file.getFileExtension();
+        if (ext != null)
+          oldExtension = ext;
+      }
+    }
+    String newExtension = ""; //$NON-NLS-1$
+    if (movedElement instanceof IFileEditorInput) {
+      IFile file = ((IFileEditorInput) movedElement).getFile();
+      if (file != null)
+        newExtension = file.getFileExtension();
+    }
+    return oldExtension.equals(newExtension);
+  }
+  /*
+        * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#getInputElement()
         */
-       protected void restoreSelection() {
-               try {
-                       if (getSourceViewer() == null || fRememberedSelection == null)
-                               return;
-                       IJavaElement newElement = findElement(fRememberedElement);
-                       int newOffset = getOffset(newElement);
-                       int delta = (newOffset > -1 && fRememberedElementOffset > -1)
-                                       ? newOffset - fRememberedElementOffset
-                                       : 0;
-                       if (isValidSelection(delta + fRememberedSelection.getOffset(),
-                                       fRememberedSelection.getLength()))
-                               selectAndReveal(delta + fRememberedSelection.getOffset(),
-                                               fRememberedSelection.getLength());
-               } finally {
-                       fRememberedSelection = null;
-                       fRememberedElement = null;
-                       fRememberedElementOffset = -1;
-               }
+       protected IJavaElement getInputJavaElement() {
+               return PHPeclipsePlugin.getDefault().getWorkingCopyManager().getWorkingCopy(getEditorInput());
        }
+  /*
+   * @see AbstractTextEditor#editorContextMenuAboutToShow(IMenuManager)
+   */
+  public void editorContextMenuAboutToShow(IMenuManager menu) {
+    super.editorContextMenuAboutToShow(menu);
+    ActionContext context = new ActionContext(getSelectionProvider()
+        .getSelection());
+    fContextMenuGroup.setContext(context);
+    fContextMenuGroup.fillContextMenu(menu);
+    fContextMenuGroup.setContext(null);
+  }
+
+  /*
+   * @see JavaEditor#setOutlinePageInput(JavaOutlinePage, IEditorInput)
+   */
+  protected void setOutlinePageInput(JavaOutlinePage page, IEditorInput input) {
+    if (page != null) {
+      IWorkingCopyManager manager = PHPeclipsePlugin.getDefault()
+          .getWorkingCopyManager();
+      page.setInput(manager.getWorkingCopy(input));
+    }
+  }
+
+  /*
+   * @see AbstractTextEditor#performSaveOperation(WorkspaceModifyOperation,
+   *      IProgressMonitor)
+   */
+  //  protected void performSaveOperation(WorkspaceModifyOperation operation,
+  // IProgressMonitor progressMonitor) {
+  //    IDocumentProvider p = getDocumentProvider();
+  //    if (p instanceof PHPDocumentProvider) {
+  //      PHPDocumentProvider cp = (PHPDocumentProvider) p;
+  //      cp.setSavePolicy(fSavePolicy);
+  //    }
+  //
+  //    try {
+  //      super.performSaveOperation(operation, progressMonitor);
+  //    } finally {
+  //      if (p instanceof PHPDocumentProvider) {
+  //        PHPDocumentProvider cp = (PHPDocumentProvider) p;
+  //        cp.setSavePolicy(null);
+  //      }
+  //    }
+  //  }
+  /*
+   * @see AbstractTextEditor#doSave(IProgressMonitor)
+   */
+  public void doSave(IProgressMonitor progressMonitor) {
+
+    IDocumentProvider p = getDocumentProvider();
+    if (p == null) {
+      // editor has been closed
+      return;
+    }
+
+    if (p.isDeleted(getEditorInput())) {
+
+      if (isSaveAsAllowed()) {
+
+        /*
+         * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the
+         * editors. Changed Behavior to make sure that if called inside a
+         * regular save (because of deletion of input element) there is a way to
+         * report back to the caller.
+         */
+        performSaveAs(progressMonitor);
+
+      } else {
+
+        /*
+         * 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there
+         * Missing resources.
+         */
+        Shell shell = getSite().getShell();
+        MessageDialog
+            .openError(
+                shell,
+                PHPEditorMessages
+                    .getString("PHPUnitEditor.error.saving.title1"), PHPEditorMessages.getString("PHPUnitEditor.error.saving.message1")); //$NON-NLS-1$ //$NON-NLS-2$
+      }
+
+    } else {
+
+      setStatusLineErrorMessage(null);
+
+      updateState(getEditorInput());
+      validateState(getEditorInput());
+
+      IWorkingCopyManager manager = PHPeclipsePlugin.getDefault()
+          .getWorkingCopyManager();
+      ICompilationUnit unit = manager.getWorkingCopy(getEditorInput());
+
+      if (unit != null) {
+        synchronized (unit) {
+          performSave(false, progressMonitor);
+        }
+      } else
+        performSave(false, progressMonitor);
+    }
+    ShowExternalPreviewAction a = ShowExternalPreviewAction.getInstance();
+    if (a != null) {
+      a.refresh();
+    }
+  }
+
+  public boolean isSaveAsAllowed() {
+    return true;
+  }
+
+  /**
+   * The compilation unit editor implementation of this
+   * <code>AbstractTextEditor</code> method asks the user for the workspace
+   * path of a file resource and saves the document there. See
+   * http://dev.eclipse.org/bugs/show_bug.cgi?id=6295
+   * 
+   * @param progressMonitor
+   *          the progress monitor
+   */
+  protected void performSaveAs(IProgressMonitor progressMonitor) {
+
+    Shell shell = getSite().getShell();
+    IEditorInput input = getEditorInput();
+
+    SaveAsDialog dialog = new SaveAsDialog(shell);
+
+    IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input)
+        .getFile()
+        : null;
+    if (original != null)
+      dialog.setOriginalFile(original);
+
+    dialog.create();
+
+    IDocumentProvider provider = getDocumentProvider();
+    if (provider == null) {
+      // editor has been programmatically closed while the dialog was open
+      return;
+    }
+
+    if (provider.isDeleted(input) && original != null) {
+      String message = PHPEditorMessages
+          .getFormattedString(
+              "CompilationUnitEditor.warning.save.delete", new Object[] { original.getName() }); //$NON-NLS-1$
+      dialog.setErrorMessage(null);
+      dialog.setMessage(message, IMessageProvider.WARNING);
+    }
+
+    if (dialog.open() == Window.CANCEL) {
+      if (progressMonitor != null)
+        progressMonitor.setCanceled(true);
+      return;
+    }
+
+    IPath filePath = dialog.getResult();
+    if (filePath == null) {
+      if (progressMonitor != null)
+        progressMonitor.setCanceled(true);
+      return;
+    }
+
+    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+    IFile file = workspaceRoot.getFile(filePath);
+    final IEditorInput newInput = new FileEditorInput(file);
+
+    boolean success = false;
+    try {
+
+      provider.aboutToChange(newInput);
+      getDocumentProvider().saveDocument(progressMonitor, newInput,
+          getDocumentProvider().getDocument(getEditorInput()), true);
+      success = true;
+
+    } catch (CoreException x) {
+      IStatus status = x.getStatus();
+      if (status == null || status.getSeverity() != IStatus.CANCEL)
+        ErrorDialog
+            .openError(
+                shell,
+                PHPEditorMessages
+                    .getString("CompilationUnitEditor.error.saving.title2"), PHPEditorMessages.getString("CompilationUnitEditor.error.saving.message2"), x.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$
+    } finally {
+      provider.changed(newInput);
+      if (success)
+        setInput(newInput);
+    }
+
+    if (progressMonitor != null)
+      progressMonitor.setCanceled(!success);
+  }
+
+  /*
+   * @see AbstractTextEditor#doSetInput(IEditorInput)
+   */
+  protected void doSetInput(IEditorInput input) throws CoreException {
+    super.doSetInput(input);
+    configureTabConverter();
+    configureToggleCommentAction();
+  }
+
+  //   /*
+  //    * @see
+  // org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#installOverrideIndicator(boolean)
+  //    * @since 3.0
+  //    */
+  //   protected void installOverrideIndicator(boolean waitForReconcilation) {
+  //           IAnnotationModel model=
+  // getDocumentProvider().getAnnotationModel(getEditorInput());
+  //           if (!waitForReconcilation)
+  //                   super.installOverrideIndicator(false);
+  //           else {
+  //                   uninstallOverrideIndicator();
+  //                   IJavaElement inputElement= getInputJavaElement();
+  //                   if (model == null || inputElement == null)
+  //                           return;
+  //                   
+  //                   fOverrideIndicatorManager= new OverrideIndicatorManager(model,
+  // inputElement, null);
+  //                   addReconcileListener(fOverrideIndicatorManager);
+  //           }
+  //   }
+  //   
+  //   /*
+  //    * @see
+  // org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#uninstallOverrideIndicator()
+  //    * @since 3.0
+  //    */
+  //   protected void uninstallOverrideIndicator() {
+  //           if (fOverrideIndicatorManager != null)
+  //                   removeReconcileListener(fOverrideIndicatorManager);
+  //           super.uninstallOverrideIndicator();
+  //   }
+
+  /**
+   * Configures the toggle comment action
+   * 
+   * @since 3.0
+   */
+  private void configureToggleCommentAction() {
+    IAction action = getAction("ToggleComment"); //$NON-NLS-1$
+    if (action instanceof ToggleCommentAction) {
+      ISourceViewer sourceViewer = getSourceViewer();
+      SourceViewerConfiguration configuration = getSourceViewerConfiguration();
+      ((ToggleCommentAction) action).configure(sourceViewer, configuration);
+    }
+  }
+
+  private void configureTabConverter() {
+    if (fTabConverter != null) {
+      IDocumentProvider provider = getDocumentProvider();
+      if (provider instanceof PHPDocumentProvider) {
+        PHPDocumentProvider cup = (PHPDocumentProvider) provider;
+        fTabConverter.setLineTracker(cup.createLineTracker(getEditorInput()));
+      }
+    }
+  }
+
+  private void startTabConversion() {
+    if (fTabConverter == null) {
+      fTabConverter = new TabConverter();
+      configureTabConverter();
+      fTabConverter.setNumberOfSpacesPerTab(getTabSize());
+      AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
+      asv.addTextConverter(fTabConverter);
+      // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
+      asv.updateIndentationPrefixes();
+    }
+  }
+
+  private void stopTabConversion() {
+    if (fTabConverter != null) {
+      AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
+      asv.removeTextConverter(fTabConverter);
+      // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
+      asv.updateIndentationPrefixes();
+      fTabConverter = null;
+    }
+  }
+
+  /*
+   * @see org.eclipse.ui.texteditor.AbstractTextEditor#performSave(boolean,
+   *      org.eclipse.core.runtime.IProgressMonitor)
+   */
+  protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) {
+    IDocumentProvider p = getDocumentProvider();
+    if (p instanceof PHPDocumentProvider) {
+      PHPDocumentProvider cp = (PHPDocumentProvider) p;
+      cp.setSavePolicy(fSavePolicy);
+    }
+    try {
+      super.performSave(overwrite, progressMonitor);
+    } finally {
+      if (p instanceof PHPDocumentProvider) {
+        PHPDocumentProvider cp = (PHPDocumentProvider) p;
+        cp.setSavePolicy(null);
+      }
+    }
+  }
+
+  /*
+   * @see AbstractTextEditor#doSaveAs
+   */
+  public void doSaveAs() {
+    if (askIfNonWorkbenchEncodingIsOk()) {
+      super.doSaveAs();
+    }
+  }
+
+  /**
+   * Asks the user if it is ok to store in non-workbench encoding.
+   * 
+   * @return <true>if the user wants to continue
+   */
+  private boolean askIfNonWorkbenchEncodingIsOk() {
+    IDocumentProvider provider = getDocumentProvider();
+    if (provider instanceof IStorageDocumentProvider) {
+      IEditorInput input = getEditorInput();
+      IStorageDocumentProvider storageProvider = (IStorageDocumentProvider) provider;
+      String encoding = storageProvider.getEncoding(input);
+      String defaultEncoding = storageProvider.getDefaultEncoding();
+      if (encoding != null && !encoding.equals(defaultEncoding)) {
+        Shell shell = getSite().getShell();
+        String title = PHPEditorMessages
+            .getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.title"); //$NON-NLS-1$
+        String msg;
+        if (input != null)
+          msg = MessageFormat
+              .format(
+                  PHPEditorMessages
+                      .getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.message1"),
+                  new String[] { input.getName(), encoding }); //$NON-NLS-1$
+        else
+          msg = MessageFormat
+              .format(
+                  PHPEditorMessages
+                      .getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.message2"),
+                  new String[] { encoding }); //$NON-NLS-1$
+        return MessageDialog.openQuestion(shell, title, msg);
+      }
+    }
+    return true;
+  }
+
+  /*
+   * @see IReconcilingParticipant#reconciled()
+   */
+  public void reconciled() {
+    if (synchronizeOutlineOnCursorMove()) {
+      Shell shell = getSite().getShell();
+      if (shell != null && !shell.isDisposed()) {
+        shell.getDisplay().asyncExec(new Runnable() {
+          public void run() {
+            synchronizeOutlinePageSelection();
+          }
+        });
+      }
+    }
+  }
+
+  protected void updateStateDependentActions() {
+    super.updateStateDependentActions();
+    fGenerateActionGroup.editorStateChanged();
+  }
+
+  private boolean synchronizeOutlineOnCursorMove() {
+    return PreferenceConstants.getPreferenceStore().getBoolean(
+        PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);
+  }
+
+  /**
+   * Returns the updated java element for the old java element.
+   */
+  private IJavaElement findElement(IJavaElement element) {
+    if (element == null)
+      return null;
+    IWorkingCopyManager manager = PHPeclipsePlugin.getDefault()
+        .getWorkingCopyManager();
+    ICompilationUnit unit = manager.getWorkingCopy(getEditorInput());
+    if (unit != null) {
+      try {
+        synchronized (unit) {
+          unit.reconcile();
+        }
+        IJavaElement[] findings = unit.findElements(element);
+        if (findings != null && findings.length > 0)
+          return findings[0];
+      } catch (JavaModelException x) {
+        PHPeclipsePlugin.log(x.getStatus());
+        // nothing found, be tolerant and go on
+      }
+    }
+    return null;
+  }
+
+  /**
+   * Returns the offset of the given Java element.
+   */
+  private int getOffset(IJavaElement element) {
+    if (element instanceof ISourceReference) {
+      ISourceReference sr = (ISourceReference) element;
+      try {
+        ISourceRange srcRange = sr.getSourceRange();
+        if (srcRange != null)
+          return srcRange.getOffset();
+      } catch (JavaModelException e) {
+      }
+    }
+    return -1;
+  }
+
+  /*
+   * @see AbstractTextEditor#rememberSelection()
+   */
+  protected void rememberSelection() {
+    ISelectionProvider sp = getSelectionProvider();
+    fRememberedSelection = (sp == null ? null : (ITextSelection) sp
+        .getSelection());
+    if (fRememberedSelection != null) {
+      fRememberedElement = getElementAt(fRememberedSelection.getOffset(), true);
+      fRememberedElementOffset = getOffset(fRememberedElement);
+    }
+  }
+
+  /*
+   * @see AbstractTextEditor#restoreSelection()
+   */
+  protected void restoreSelection() {
+    try {
+      if (getSourceViewer() == null || fRememberedSelection == null)
+        return;
+      IJavaElement newElement = findElement(fRememberedElement);
+      int newOffset = getOffset(newElement);
+      int delta = (newOffset > -1 && fRememberedElementOffset > -1) ? newOffset
+          - fRememberedElementOffset : 0;
+      if (isValidSelection(delta + fRememberedSelection.getOffset(),
+          fRememberedSelection.getLength()))
+        selectAndReveal(delta + fRememberedSelection.getOffset(),
+            fRememberedSelection.getLength());
+    } finally {
+      fRememberedSelection = null;
+      fRememberedElement = null;
+      fRememberedElementOffset = -1;
+    }
+  }
 
-       //      /*
-       //       * @see
-       // org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#aboutToBeReconciled()
-       //       * @since 3.0
-       //       */
-       //      public void aboutToBeReconciled() {
-       //
-       //              // Notify AST provider
-       //              PHPeclipsePlugin.getDefault().getASTProvider().aboutToBeReconciled(getInputJavaElement());
-       //              
-       //              // Notify listeners
-       //              Object[] listeners = fReconcilingListeners.getListeners();
-       //              for (int i = 0, length= listeners.length; i < length; ++i)
-       //                      ((IJavaReconcilingListener)listeners[i]).aboutToBeReconciled();
-       //      }
-       //      
-       //      /*
-       //       * @see
-       // org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#reconciled(CompilationUnit,
-       // boolean, IProgressMonitor)
-       //       * @since 3.0
-       //       */
-       //      public void reconciled(net.sourceforge.phpdt.core.dom.CompilationUnit
-       // ast, boolean forced, IProgressMonitor progressMonitor) {
-       //
-       //              // Always notify AST provider
-       //              PHPeclipsePlugin.getDefault().getASTProvider().reconciled(ast,
-       // getInputJavaElement());
-       //              
-       //              // Notify listeners
-       //              Object[] listeners = fReconcilingListeners.getListeners();
-       //              for (int i = 0, length= listeners.length; i < length; ++i)
-       //                      ((IJavaReconcilingListener)listeners[i]).reconciled(ast, forced,
-       // progressMonitor);
-       //
-       //              // Update Java Outline page selection
-       //              if (!forced && !progressMonitor.isCanceled()) {
-       //                      Shell shell= getSite().getShell();
-       //                      if (shell != null && !shell.isDisposed()) {
-       //                              shell.getDisplay().asyncExec(new Runnable() {
-       //                                      public void run() {
-       //                                              selectionChanged();
-       //                                      }
-       //                              });
-       //                      }
-       //              }
-       //      }
+  //   /*
+  //    * @see
+  // org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#aboutToBeReconciled()
+  //    * @since 3.0
+  //    */
+  //   public void aboutToBeReconciled() {
+  //
+  //           // Notify AST provider
+  //           PHPeclipsePlugin.getDefault().getASTProvider().aboutToBeReconciled(getInputJavaElement());
+  //           
+  //           // Notify listeners
+  //           Object[] listeners = fReconcilingListeners.getListeners();
+  //           for (int i = 0, length= listeners.length; i < length; ++i)
+  //                   ((IJavaReconcilingListener)listeners[i]).aboutToBeReconciled();
+  //   }
+  //   
+  //   /*
+  //    * @see
+  // org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#reconciled(CompilationUnit,
+  // boolean, IProgressMonitor)
+  //    * @since 3.0
+  //    */
+  //   public void reconciled(net.sourceforge.phpdt.core.dom.CompilationUnit
+  // ast, boolean forced, IProgressMonitor progressMonitor) {
+  //
+  //           // Always notify AST provider
+  //           PHPeclipsePlugin.getDefault().getASTProvider().reconciled(ast,
+  // getInputJavaElement());
+  //           
+  //           // Notify listeners
+  //           Object[] listeners = fReconcilingListeners.getListeners();
+  //           for (int i = 0, length= listeners.length; i < length; ++i)
+  //                   ((IJavaReconcilingListener)listeners[i]).reconciled(ast, forced,
+  // progressMonitor);
+  //
+  //           // Update Java Outline page selection
+  //           if (!forced && !progressMonitor.isCanceled()) {
+  //                   Shell shell= getSite().getShell();
+  //                   if (shell != null && !shell.isDisposed()) {
+  //                           shell.getDisplay().asyncExec(new Runnable() {
+  //                                   public void run() {
+  //                                           selectionChanged();
+  //                                   }
+  //                           });
+  //                   }
+  //           }
+  //   }
 }
\ No newline at end of file
index beae245..69f3124 100644 (file)
@@ -10,6 +10,7 @@
  Klaus Hartlage - www.eclipseproject.de
  **********************************************************************/
 package net.sourceforge.phpeclipse.phpeditor.php;
+
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
 import java.sql.ResultSet;
@@ -17,14 +18,25 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 import java.util.SortedMap;
 
+import net.sourceforge.phpdt.core.IBuffer;
 import net.sourceforge.phpdt.core.ICompilationUnit;
+import net.sourceforge.phpdt.core.IJavaProject;
 import net.sourceforge.phpdt.core.JavaModelException;
 import net.sourceforge.phpdt.core.ToolFactory;
 import net.sourceforge.phpdt.core.compiler.ITerminalSymbols;
 import net.sourceforge.phpdt.core.compiler.InvalidInputException;
+import net.sourceforge.phpdt.internal.compiler.IProblemFactory;
+import net.sourceforge.phpdt.internal.compiler.SourceElementParser;
+import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
 import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
+import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblemFactory;
+import net.sourceforge.phpdt.internal.core.CompilationUnit;
+import net.sourceforge.phpdt.internal.core.CompilationUnitStructureRequestor;
+import net.sourceforge.phpdt.internal.core.JavaModelManager;
+import net.sourceforge.phpdt.internal.core.JavaProject;
 import net.sourceforge.phpdt.internal.corext.template.ContextType;
 import net.sourceforge.phpdt.internal.corext.template.ContextTypeRegistry;
 import net.sourceforge.phpdt.internal.corext.template.php.CompilationUnitContextType;
@@ -38,18 +50,16 @@ import net.sourceforge.phpdt.internal.ui.text.template.IdentifierEngine;
 import net.sourceforge.phpdt.internal.ui.text.template.SQLProposal;
 import net.sourceforge.phpdt.internal.ui.text.template.TemplateEngine;
 import net.sourceforge.phpdt.ui.IWorkingCopyManager;
-import net.sourceforge.phpdt.ui.PreferenceConstants;
 import net.sourceforge.phpeclipse.IPreferenceConstants;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.builder.IdentifierIndexManager;
+import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
 import net.sourceforge.phpeclipse.overlaypages.Util;
 import net.sourceforge.phpeclipse.phpeditor.PHPEditor;
 import net.sourceforge.phpeclipse.phpeditor.PHPSyntaxRdr;
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.IRegion;
@@ -63,8 +73,6 @@ import org.eclipse.jface.text.contentassist.IContextInformationExtension;
 import org.eclipse.jface.text.contentassist.IContextInformationPresenter;
 import org.eclipse.jface.text.contentassist.IContextInformationValidator;
 import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IFileEditorInput;
 
@@ -72,6 +80,7 @@ import com.quantum.model.Bookmark;
 import com.quantum.model.BookmarkCollection;
 import com.quantum.model.NotConnectedException;
 import com.quantum.util.connection.ConnectionUtil;
+
 /**
  * Example PHP completion processor.
  */
@@ -80,17 +89,17 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
    * Simple content assist tip closer. The tip is valid in a range of 5
    * characters around its popup location.
    */
-  protected static class Validator
-      implements
-        IContextInformationValidator,
-        IContextInformationPresenter {
+  protected static class Validator implements IContextInformationValidator,
+      IContextInformationPresenter {
     protected int fInstallOffset;
+
     /*
      * @see IContextInformationValidator#isContextInformationValid(int)
      */
     public boolean isContextInformationValid(int offset) {
       return Math.abs(fInstallOffset - offset) < 5;
     }
+
     /*
      * @see IContextInformationValidator#install(IContextInformation,
      *      ITextViewer, int)
@@ -98,6 +107,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
     public void install(IContextInformation info, ITextViewer viewer, int offset) {
       fInstallOffset = offset;
     }
+
     /*
      * @see org.eclipse.jface.text.contentassist.IContextInformationPresenter#updatePresentation(int,
      *      TextPresentation)
@@ -107,99 +117,121 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
       return false;
     }
   };
-  private static class ContextInformationWrapper
-      implements
-        IContextInformation,
-        IContextInformationExtension {
+
+  private static class ContextInformationWrapper implements
+      IContextInformation, IContextInformationExtension {
     private final IContextInformation fContextInformation;
+
     private int fPosition;
+
     public ContextInformationWrapper(IContextInformation contextInformation) {
       fContextInformation = contextInformation;
     }
+
     /*
      * @see IContextInformation#getContextDisplayString()
      */
     public String getContextDisplayString() {
       return fContextInformation.getContextDisplayString();
     }
+
     /*
      * @see IContextInformation#getImage()
      */
     public Image getImage() {
       return fContextInformation.getImage();
     }
+
     /*
      * @see IContextInformation#getInformationDisplayString()
      */
     public String getInformationDisplayString() {
       return fContextInformation.getInformationDisplayString();
     }
+
     /*
      * @see IContextInformationExtension#getContextInformationPosition()
      */
     public int getContextInformationPosition() {
       return fPosition;
     }
+
     public void setContextInformationPosition(int position) {
       fPosition = position;
     }
   };
+
   private class TableName {
     String fTableName;
+
     TableName() {
       fTableName = null;
     }
+
     /**
      * @return Returns the tableName.
      */
     public String getTableName() {
-      if (fTableName==null) {
+      if (fTableName == null) {
         return "<!--no-table-->";
       }
       return fTableName;
     }
+
     /**
-     * @param tableName The tableName to set.
+     * @param tableName
+     *          The tableName to set.
      */
     public void setTableName(String tableName) {
       fTableName = tableName;
     }
   }
+
   private char[] fProposalAutoActivationSet;
+
   protected IContextInformationValidator fValidator = new Validator();
+
   private TemplateEngine fTemplateEngine;
+
   private PHPCompletionProposalComparator fComparator;
+
   private int fNumberOfComputedResults = 0;
+
   private IEditorPart fEditor;
+
   protected IWorkingCopyManager fManager;
+
   public PHPCompletionProcessor(IEditorPart editor) {
-    fEditor= editor;
-    fManager= PHPeclipsePlugin.getDefault().getWorkingCopyManager();
+    fEditor = editor;
+    fManager = PHPeclipsePlugin.getDefault().getWorkingCopyManager();
     ContextType contextType = ContextTypeRegistry.getInstance().getContextType(
         "php"); //$NON-NLS-1$
     if (contextType != null)
       fTemplateEngine = new TemplateEngine(contextType);
     fComparator = new PHPCompletionProposalComparator();
   }
+
   /**
    * Tells this processor to order the proposals alphabetically.
    * 
    * @param order
-   *            <code>true</code> if proposals should be ordered.
+   *          <code>true</code> if proposals should be ordered.
    */
   public void orderProposalsAlphabetically(boolean order) {
     fComparator.setOrderAlphabetically(order);
   }
+
   /**
    * Sets this processor's set of characters triggering the activation of the
    * completion proposal computation.
    * 
    * @param activationSet
-   *            the activation set
+   *          the activation set
    */
   public void setCompletionProposalAutoActivationCharacters(char[] activationSet) {
     fProposalAutoActivationSet = activationSet;
   }
+
   /*
    * (non-Javadoc) Method declared on IContentAssistProcessor
    */
@@ -210,6 +242,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
     return internalComputeCompletionProposals(viewer, documentOffset,
         contextInformationPosition);
   }
+
   private int getLastToken(ITextViewer viewer, int completionPosition,
       PHPUnitContext context, TableName tableName) {
     IDocument document = viewer.getDocument();
@@ -242,7 +275,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
           System.out.println(startText);
         }
         int token = ITerminalSymbols.TokenNameEOF;
-//        token = getLastSQLToken(startText);
+        //        token = getLastSQLToken(startText);
         tableName.setTableName(getLastSQLTableName(startText));
         Scanner scanner = ToolFactory.createScanner(false, false, false);
         scanner.setSource(startText.toCharArray());
@@ -262,45 +295,47 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
         } catch (InvalidInputException e1) {
         }
         switch (lastToken) {
-          case ITerminalSymbols.TokenNameMINUS_GREATER :
-            // dereferencing operator '->' found
-            lastSignificantToken = ITerminalSymbols.TokenNameMINUS_GREATER;
-            if (beforeLastToken == ITerminalSymbols.TokenNameVariable) {
-              lastSignificantToken = ITerminalSymbols.TokenNameVariable;
-            }
-            break;
-          case ITerminalSymbols.TokenNamenew :
-            lastSignificantToken = ITerminalSymbols.TokenNamenew;
-            break;
+        case ITerminalSymbols.TokenNameMINUS_GREATER:
+          // dereferencing operator '->' found
+          lastSignificantToken = ITerminalSymbols.TokenNameMINUS_GREATER;
+          if (beforeLastToken == ITerminalSymbols.TokenNameVariable) {
+            lastSignificantToken = ITerminalSymbols.TokenNameVariable;
+          }
+          break;
+        case ITerminalSymbols.TokenNamenew:
+          lastSignificantToken = ITerminalSymbols.TokenNamenew;
+          break;
         }
       }
     } catch (BadLocationException e) {
     }
     return lastSignificantToken;
   }
-  
+
   String getSQLTableName(String sqlText, int start) {
     int tableNameStart = -1;
-    int currentCharacterPosition = start+1;
+    int currentCharacterPosition = start + 1;
     char ch;
     try {
-      while(true) {
-      ch = sqlText.charAt(currentCharacterPosition++);
-      if (tableNameStart==-1 && Character.isJavaIdentifierStart(ch)) {
-        tableNameStart = currentCharacterPosition-1;
-      } else {
-        if (!Character.isJavaIdentifierPart(ch)) {
-          return sqlText.substring(tableNameStart, currentCharacterPosition-1);
-        } 
-      }
+      while (true) {
+        ch = sqlText.charAt(currentCharacterPosition++);
+        if (tableNameStart == -1 && Character.isJavaIdentifierStart(ch)) {
+          tableNameStart = currentCharacterPosition - 1;
+        } else {
+          if (!Character.isJavaIdentifierPart(ch)) {
+            return sqlText.substring(tableNameStart,
+                currentCharacterPosition - 1);
+          }
+        }
       }
     } catch (IndexOutOfBoundsException e) {
-      if (tableNameStart>=0) {
-        return sqlText.substring(tableNameStart, currentCharacterPosition-1);
+      if (tableNameStart >= 0) {
+        return sqlText.substring(tableNameStart, currentCharacterPosition - 1);
       }
     }
     return "";
   }
+
   private String getLastSQLTableName(String startText) {
     int token;
     // scan for sql identifiers
@@ -328,52 +363,52 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
           if (ident.length() >= 4 && ident.length() <= 6) {
             ident = ident.toLowerCase();
             switch (ident.length()) {
-//              case 3 :
-//                if (ident.equals("set")) {
-//                  //                  System.out.println("set");
-//                  token = ITerminalSymbols.TokenNameSQLset;
-//                  return token;
-//                }
-//                break;
-              case 4 :
-                if (ident.equals("from")) {
-                  //                  System.out.println("from");
-                  token = ITerminalSymbols.TokenNameSQLfrom;
-                  return getSQLTableName(startText, identEnd);
-                } else if (ident.equals("into")) {
-                  //                System.out.println("into");
-                  token = ITerminalSymbols.TokenNameSQLinto;
-                  return getSQLTableName(startText, identEnd);
-                }
-                break;
-//              case 5 :
-//                if (ident.equals("where")) {
-//                  //                  System.out.println("where");
-//                  token = ITerminalSymbols.TokenNameSQLwhere;
-//                  return token;
-//                }
-//                break;
-              case 6 :
-//                if (ident.equals("select")) {
-//                  //                  System.out.println("select");
-//                  token = ITerminalSymbols.TokenNameSQLselect;
-//                  return token;
-//                } else if (ident.equals("insert")) {
-//                  //                  System.out.println("insert");
-//                  token = ITerminalSymbols.TokenNameSQLinsert;
-//                  return token;
-//                } else 
-                if (ident.equals("update")) {
-                  //                  System.out.println("update");
-                  token = ITerminalSymbols.TokenNameSQLupdate;
-                  return getSQLTableName(startText, identEnd);
-                } 
-//                else if (ident.equals("values")) {
-//                  //                System.out.println("values");
-//                  token = ITerminalSymbols.TokenNameSQLvalues;
-//                  return token;
-//                }
-                break;
+            //              case 3 :
+            //                if (ident.equals("set")) {
+            //                  // System.out.println("set");
+            //                  token = ITerminalSymbols.TokenNameSQLset;
+            //                  return token;
+            //                }
+            //                break;
+            case 4:
+              if (ident.equals("from")) {
+                //                  System.out.println("from");
+                token = ITerminalSymbols.TokenNameSQLfrom;
+                return getSQLTableName(startText, identEnd);
+              } else if (ident.equals("into")) {
+                //                System.out.println("into");
+                token = ITerminalSymbols.TokenNameSQLinto;
+                return getSQLTableName(startText, identEnd);
+              }
+              break;
+            //              case 5 :
+            //                if (ident.equals("where")) {
+            //                  // System.out.println("where");
+            //                  token = ITerminalSymbols.TokenNameSQLwhere;
+            //                  return token;
+            //                }
+            //                break;
+            case 6:
+              //                if (ident.equals("select")) {
+              //                  // System.out.println("select");
+              //                  token = ITerminalSymbols.TokenNameSQLselect;
+              //                  return token;
+              //                } else if (ident.equals("insert")) {
+              //                  // System.out.println("insert");
+              //                  token = ITerminalSymbols.TokenNameSQLinsert;
+              //                  return token;
+              //                } else
+              if (ident.equals("update")) {
+                //                  System.out.println("update");
+                token = ITerminalSymbols.TokenNameSQLupdate;
+                return getSQLTableName(startText, identEnd);
+              }
+              //                else if (ident.equals("values")) {
+              //                  // System.out.println("values");
+              //                  token = ITerminalSymbols.TokenNameSQLvalues;
+              //                  return token;
+              //                }
+              break;
             }
           }
           whiteSpace = false;
@@ -387,6 +422,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
     }
     return "<!--no-table-->";
   }
+
   /**
    * Detect the last significant SQL token in the text before the completion
    * 
@@ -419,51 +455,51 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
           if (ident.length() >= 3 && ident.length() <= 6) {
             ident = ident.toLowerCase();
             switch (ident.length()) {
-              case 3 :
-                if (ident.equals("set")) {
-                  //                  System.out.println("set");
-                  token = ITerminalSymbols.TokenNameSQLset;
-                  return token;
-                }
-                break;
-              case 4 :
-                if (ident.equals("from")) {
-                  //                  System.out.println("from");
-                  token = ITerminalSymbols.TokenNameSQLfrom;
-                  //getSQLTableName();
-                  return token;
-                } else if (ident.equals("into")) {
-                  //                System.out.println("into");
-                  token = ITerminalSymbols.TokenNameSQLinto;
-                  return token;
-                }
-                break;
-              case 5 :
-                if (ident.equals("where")) {
-                  //                  System.out.println("where");
-                  token = ITerminalSymbols.TokenNameSQLwhere;
-                  return token;
-                }
-                break;
-              case 6 :
-                if (ident.equals("select")) {
-                  //                  System.out.println("select");
-                  token = ITerminalSymbols.TokenNameSQLselect;
-                  return token;
-                } else if (ident.equals("insert")) {
-                  //                  System.out.println("insert");
-                  token = ITerminalSymbols.TokenNameSQLinsert;
-                  return token;
-                } else if (ident.equals("update")) {
-                  //                  System.out.println("update");
-                  token = ITerminalSymbols.TokenNameSQLupdate;
-                  return token;
-                } else if (ident.equals("values")) {
-                  //                System.out.println("values");
-                  token = ITerminalSymbols.TokenNameSQLvalues;
-                  return token;
-                }
-                break;
+            case 3:
+              if (ident.equals("set")) {
+                //                  System.out.println("set");
+                token = ITerminalSymbols.TokenNameSQLset;
+                return token;
+              }
+              break;
+            case 4:
+              if (ident.equals("from")) {
+                //                  System.out.println("from");
+                token = ITerminalSymbols.TokenNameSQLfrom;
+                //getSQLTableName();
+                return token;
+              } else if (ident.equals("into")) {
+                //                System.out.println("into");
+                token = ITerminalSymbols.TokenNameSQLinto;
+                return token;
+              }
+              break;
+            case 5:
+              if (ident.equals("where")) {
+                //                  System.out.println("where");
+                token = ITerminalSymbols.TokenNameSQLwhere;
+                return token;
+              }
+              break;
+            case 6:
+              if (ident.equals("select")) {
+                //                  System.out.println("select");
+                token = ITerminalSymbols.TokenNameSQLselect;
+                return token;
+              } else if (ident.equals("insert")) {
+                //                  System.out.println("insert");
+                token = ITerminalSymbols.TokenNameSQLinsert;
+                return token;
+              } else if (ident.equals("update")) {
+                //                  System.out.println("update");
+                token = ITerminalSymbols.TokenNameSQLupdate;
+                return token;
+              } else if (ident.equals("values")) {
+                //                System.out.println("values");
+                token = ITerminalSymbols.TokenNameSQLvalues;
+                return token;
+              }
+              break;
             }
           }
           whiteSpace = false;
@@ -477,10 +513,10 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
     }
     return ITerminalSymbols.TokenNameEOF;
   }
+
   private ICompletionProposal[] internalComputeCompletionProposals(
       ITextViewer viewer, int offset, int contextOffset) {
-    ICompilationUnit unit= fManager.getWorkingCopy(fEditor.getEditorInput());
-       System.out.println( unit.toString() );
+
     IDocument document = viewer.getDocument();
     Object[] identifiers = null;
     IFile file = null;
@@ -498,6 +534,61 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
         //        }
       }
     }
+
+    final ICompilationUnit unit = fManager.getWorkingCopy(fEditor
+        .getEditorInput());
+
+    //  get buffer contents
+    final IBuffer buffer;
+    CompilationUnitDeclaration unitDecl=null;
+    try {
+      buffer = unit.getBuffer();
+
+      if (project != null && buffer != null) {
+
+        //     final char[] contents = buffer == null ? null :
+        // buffer.getCharacters();
+        //
+        //     // generate structure and compute syntax problems if needed
+        //     CompilationUnitStructureRequestor requestor = new
+        // CompilationUnitStructureRequestor(this, unitInfo, newElements);
+        //     JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo =
+        // getPerWorkingCopyInfo();
+        //     IJavaProject project = getJavaProject();
+        //     boolean computeProblems =
+        // JavaProject.hasJavaNature(project.getProject()) && perWorkingCopyInfo
+        // != null && perWorkingCopyInfo.isActive();
+        IProblemFactory problemFactory = new DefaultProblemFactory();
+        //     Map options = project.getOptions(true);
+        SourceElementParser parser = new SourceElementParser(null,
+            problemFactory, new CompilerOptions(null));
+        //, true/*report local declarations*/);
+        unitDecl = parser.parseCompletionUnit(
+            new net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit() {
+              public char[] getContents() {
+                return buffer.getCharacters();
+              }
+
+              public char[] getMainTypeName() {
+                return null;
+              }
+
+              public char[][] getPackageName() {
+                return null;
+              }
+
+              public char[] getFileName() {
+                return null;
+              }
+            }, true /* full parse to find local elements */);
+
+      }
+//      System.out.println(unit.toString());
+    } catch (Exception e1) {
+      // TODO Auto-generated catch block
+      e1.printStackTrace();
+    }
+
     ContextType phpContextType = ContextTypeRegistry.getInstance()
         .getContextType("php"); //$NON-NLS-1$
     ((CompilationUnitContextType) phpContextType).setContextParameters(
@@ -576,7 +667,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
               try {
                 Connection connection = bookmark.getConnection();
                 DatabaseMetaData metaData = connection.getMetaData();
-                
+
                 if (metaData != null) {
                   int start = context.getStart();
                   int end = context.getEnd();
@@ -590,7 +681,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
                     isDollarPrefix = true;
                   }
                   IRegion region = new Region(start, end - start);
-                  ResultSet set; 
+                  ResultSet set;
                   if (!isDollarPrefix) {
                     set = metaData.getTables(null, null, prefixWithoutDollar
                         + "%", null);
@@ -618,9 +709,9 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
                     if (tableName != null && tableName.length() > 0
                         && columnName != null && columnName.length() > 0) {
                       if (isDollarPrefix) {
-                        sqlProposal = new SQLProposal(tableName,
-                            "$" + columnName, context, region, viewer,
-                            PHPUiImages.get(PHPUiImages.IMG_COLUMN));
+                        sqlProposal = new SQLProposal(tableName, "$"
+                            + columnName, context, region, viewer, PHPUiImages
+                            .get(PHPUiImages.IMG_COLUMN));
                       } else {
                         sqlProposal = new SQLProposal(tableName, columnName,
                             context, region, viewer, PHPUiImages
@@ -628,7 +719,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
                       }
                       if (tableName.equals(foundSQLTableName)) {
                         sqlProposal.setRelevance(90);
-                      } else if (tableName.indexOf(foundSQLTableName)>=0) {
+                      } else if (tableName.indexOf(foundSQLTableName) >= 0) {
                         sqlProposal.setRelevance(75);
                       }
                       sqlList.add(sqlProposal);
@@ -675,6 +766,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
     }
     return new IPHPCompletionProposal[0];
   }
+
   private int guessContextInformationPosition(ITextViewer viewer, int offset) {
     int contextPosition = offset;
     IDocument document = viewer.getDocument();
@@ -707,6 +799,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
     //    }
     return contextPosition;
   }
+
   /*
    * (non-Javadoc) Method declared on IContentAssistProcessor
    */
@@ -734,6 +827,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
     return (IContextInformation[]) result
         .toArray(new IContextInformation[result.size()]);
   }
+
   private List addContextInformations(ITextViewer viewer, int offset) {
     ICompletionProposal[] proposals = internalComputeCompletionProposals(
         viewer, offset, -1);
@@ -750,6 +844,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
     }
     return result;
   }
+
   /**
    * Order the given proposals.
    */
@@ -757,6 +852,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
     Arrays.sort(proposals, fComparator);
     return proposals;
   }
+
   /*
    * (non-Javadoc) Method declared on IContentAssistProcessor
    */
@@ -764,22 +860,25 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
     return fProposalAutoActivationSet;
     //    return null; // new char[] { '$' };
   }
+
   /*
    * (non-Javadoc) Method declared on IContentAssistProcessor
    */
   public char[] getContextInformationAutoActivationCharacters() {
-    return new char[]{};
+    return new char[] {};
   }
+
   /*
    * (non-Javadoc) Method declared on IContentAssistProcessor
    */
   public IContextInformationValidator getContextInformationValidator() {
     return fValidator;
   }
+
   /*
    * (non-Javadoc) Method declared on IContentAssistProcessor
    */
   public String getErrorMessage() {
     return null;
   }
-}
+}
\ No newline at end of file