Fixed ?
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPUnitEditor.java
index 6755004..6cb6318 100644 (file)
@@ -2,11 +2,14 @@ package net.sourceforge.phpeclipse.phpeditor;
 
 import java.text.MessageFormat;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 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;
@@ -20,6 +23,7 @@ import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
 import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher;
 import net.sourceforge.phpdt.internal.ui.text.SmartBackspaceManager;
 import net.sourceforge.phpdt.internal.ui.text.SmartSemicolonAutoEditStrategy;
+import net.sourceforge.phpdt.internal.ui.text.comment.CommentFormattingContext;
 import net.sourceforge.phpdt.internal.ui.text.java.IJavaReconcilingListener;
 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager;
 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI;
@@ -60,6 +64,8 @@ import org.eclipse.jface.text.ITypedRegion;
 import org.eclipse.jface.text.IWidgetTokenKeeper;
 import org.eclipse.jface.text.contentassist.ContentAssistant;
 import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.formatter.FormattingContextProperties;
+import org.eclipse.jface.text.formatter.IFormattingContext;
 import org.eclipse.jface.text.source.IOverviewRuler;
 import org.eclipse.jface.text.source.ISourceViewer;
 import org.eclipse.jface.text.source.IVerticalRuler;
@@ -110,25 +116,162 @@ public class PHPUnitEditor extends PHPEditor { //implements
     void customizeDocumentCommand(IDocument document, DocumentCommand command);
   };
 
+  //  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);
+  //// }
+  //    public void configure(SourceViewerConfiguration configuration) {
+  //           super.configure(configuration);
+  //// fCorrectionAssistant= new JavaCorrectionAssistant(CompilationUnitEditor.this);
+  //// fCorrectionAssistant.install(this);
+  //           IAutoEditStrategy smartSemi= new SmartSemicolonAutoEditStrategy(IPHPPartitions.PHP_PARTITIONING);
+  //           prependAutoEditStrategy(smartSemi, IDocument.DEFAULT_CONTENT_TYPE);
+  //           prependAutoEditStrategy(smartSemi, IPHPPartitions.PHP_STRING_DQ);
+  //           prependAutoEditStrategy(smartSemi, IPHPPartitions.PHP_STRING_SQ);
+  //// prependAutoEditStrategy(smartSemi, IPHPPartitions.JAVA_CHARACTER);
+  //   }
+  //  };
   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);
+//    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;
     }
@@ -137,23 +280,31 @@ public class PHPUnitEditor extends PHPEditor { //implements
      * @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 CORRECTIONASSIST_PROPOSALS:
+//        msg = fCorrectionAssistant.showPossibleCompletions();
+//        setStatusLineErrorMessage(msg);
+//        return;
       case UNDO:
         fIgnoreTextConverters = true;
-        break;
+        super.doOperation(operation);
+        fIgnoreTextConverters = false;
+        return;
       case REDO:
         fIgnoreTextConverters = true;
-        break;
+        super.doOperation(operation);
+        fIgnoreTextConverters = false;
+        return;
       }
+
       super.doOperation(operation);
     }
 
@@ -161,20 +312,22 @@ public class PHPUnitEditor extends PHPEditor { //implements
      * @see ITextOperationTarget#canDoOperation(int)
      */
     public boolean canDoOperation(int operation) {
-      //                               if (operation == CORRECTIONASSIST_PROPOSALS)
-      //                                       return isEditable();
+//      if (operation == CORRECTIONASSIST_PROPOSALS)
+//        return isEditable();
+
       return super.canDoOperation(operation);
     }
 
     /*
-     * @see TextViewer#handleDispose()
+     * @see org.eclipse.jface.text.source.ISourceViewerExtension2#unconfigure()
+     * @since 3.0
      */
-    protected void handleDispose() {
-      //                               if (fCorrectionAssistant != null) {
-      //                                       fCorrectionAssistant.uninstall();
-      //                                       fCorrectionAssistant= null;
-      //                               }
-      super.handleDispose();
+    public void unconfigure() {
+//      if (fCorrectionAssistant != null) {
+//        fCorrectionAssistant.uninstall();
+//        fCorrectionAssistant = null;
+//      }
+      super.unconfigure();
     }
 
     public void insertTextConverter(ITextConverter textConverter, int index) {
@@ -204,10 +357,8 @@ public class PHPUnitEditor extends PHPEditor { //implements
       super.customizeDocumentCommand(command);
       if (!fIgnoreTextConverters && fTextConverters != null) {
         for (Iterator e = fTextConverters.iterator(); e.hasNext();)
-          ((ITextConverter) e.next()).customizeDocumentCommand(getDocument(),
-              command);
+          ((ITextConverter) e.next()).customizeDocumentCommand(getDocument(), command);
       }
-      fIgnoreTextConverters = false;
     }
 
     // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
@@ -230,381 +381,417 @@ public class PHPUnitEditor extends PHPEditor { //implements
       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);
-//    }
+    /*
+     * @see IWidgetTokenOwnerExtension#requestWidgetToken(IWidgetTokenKeeper, int)
+     * @since 3.0
+     */
+    public boolean requestWidgetToken(IWidgetTokenKeeper requester, int priority) {
+      if (WorkbenchHelp.isContextHelpDisplayed())
+        return false;
+      return super.requestWidgetToken(requester, priority);
+    }
+
+    /*
+     * @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);
-               IAutoEditStrategy smartSemi= new SmartSemicolonAutoEditStrategy(IPHPPartitions.PHP_PARTITIONING);
-               prependAutoEditStrategy(smartSemi, IDocument.DEFAULT_CONTENT_TYPE);
-               prependAutoEditStrategy(smartSemi, IPHPPartitions.PHP_STRING_DQ);
-               prependAutoEditStrategy(smartSemi, IPHPPartitions.PHP_STRING_SQ);
-//             prependAutoEditStrategy(smartSemi, IPHPPartitions.JAVA_CHARACTER);
-       }
-  };
+      super.configure(configuration);
+//      fCorrectionAssistant = new JavaCorrectionAssistant(CompilationUnitEditor.this);
+//      fCorrectionAssistant.install(this);
+      IAutoEditStrategy smartSemi = new SmartSemicolonAutoEditStrategy(IPHPPartitions.PHP_PARTITIONING);
+      prependAutoEditStrategy(smartSemi, IDocument.DEFAULT_CONTENT_TYPE);
+      prependAutoEditStrategy(smartSemi, IPHPPartitions.PHP_STRING_DQ);
+      prependAutoEditStrategy(smartSemi, IPHPPartitions.PHP_STRING_SQ);
+    }
+
+    /*
+     * @see org.eclipse.jface.text.source.SourceViewer#createFormattingContext()
+     * @since 3.0
+     */
+    public IFormattingContext createFormattingContext() {
+      IFormattingContext context = new CommentFormattingContext();
+
+      Map preferences;
+      IJavaElement inputJavaElement = getInputJavaElement();
+      IJavaProject javaProject = inputJavaElement != null ? inputJavaElement.getJavaProject() : null;
+      if (javaProject == null)
+        preferences = new HashMap(JavaCore.getOptions());
+      else
+        preferences = new HashMap(javaProject.getOptions(true));
+
+      context.storeToMap(PreferenceConstants.getPreferenceStore(), preferences, false);
+      context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, preferences);
+
+      return context;
+    }
+  }
+
+  /**
+   * Remembers data related to the current selection to be able to restore it later.
+   * 
+   * @since 3.0
+   */
+  private class RememberedSelection {
+    /** The remembered selection start. */
+    private RememberedOffset fStartOffset = new RememberedOffset();
+
+    /** The remembered selection end. */
+    private RememberedOffset fEndOffset = new RememberedOffset();
+
+    /**
+     * Remember current selection.
+     */
+    public void remember() {
+      /*
+       * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52257 This method may be called inside an async call posted to the UI thread,
+       * so protect against intermediate disposal of the editor.
+       */
+      ISourceViewer viewer = getSourceViewer();
+      if (viewer != null) {
+        IRegion selection = getSignedSelection(viewer);
+        int startOffset = selection.getOffset();
+        int endOffset = startOffset + selection.getLength();
+
+        fStartOffset.setOffset(startOffset);
+        fEndOffset.setOffset(endOffset);
+      }
+    }
+
+    /**
+     * Restore remembered selection.
+     */
+    public void restore() {
+      /*
+       * https://bugs.eclipse.org/bugs/show_bug.cgi?id=52257 This method may be called inside an async call posted to the UI thread,
+       * so protect against intermediate disposal of the editor.
+       */
+      if (getSourceViewer() == null)
+        return;
+
+      try {
+
+        int startOffset, endOffset;
+        int revealStartOffset, revealEndOffset;
+        if (showsHighlightRangeOnly()) {
+          IJavaElement newStartElement = fStartOffset.getElement();
+          startOffset = fStartOffset.getRememberedOffset(newStartElement);
+          revealStartOffset = fStartOffset.getRevealOffset(newStartElement, startOffset);
+          if (revealStartOffset == -1)
+            startOffset = -1;
+
+          IJavaElement newEndElement = fEndOffset.getElement();
+          endOffset = fEndOffset.getRememberedOffset(newEndElement);
+          revealEndOffset = fEndOffset.getRevealOffset(newEndElement, endOffset);
+          if (revealEndOffset == -1)
+            endOffset = -1;
+        } else {
+          startOffset = fStartOffset.getOffset();
+          revealStartOffset = startOffset;
+          endOffset = fEndOffset.getOffset();
+          revealEndOffset = endOffset;
+        }
+
+        if (startOffset == -1) {
+          startOffset = endOffset; // fallback to caret offset
+          revealStartOffset = revealEndOffset;
+        }
+
+        if (endOffset == -1) {
+          endOffset = startOffset; // fallback to other offset
+          revealEndOffset = revealStartOffset;
+        }
+
+        IJavaElement element;
+        if (endOffset == -1) {
+          // fallback to element selection
+          element = fEndOffset.getElement();
+          if (element == null)
+            element = fStartOffset.getElement();
+          if (element != null)
+            setSelection(element);
+          return;
+        }
+
+        if (isValidSelection(revealStartOffset, revealEndOffset - revealStartOffset)
+            && isValidSelection(startOffset, endOffset - startOffset))
+          selectAndReveal(startOffset, endOffset - startOffset, revealStartOffset, revealEndOffset - revealStartOffset);
+      } finally {
+        fStartOffset.clear();
+        fEndOffset.clear();
+      }
+    }
+
+    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;
+    }
+
+  }
+
   /**
-        * Remembers data related to the current selection to be able to
-        * restore it later.
-        * 
-        * @since 3.0
-        */
-       private class RememberedSelection {
-               /** The remembered selection start. */
-               private RememberedOffset fStartOffset= new RememberedOffset();
-               /** The remembered selection end. */
-               private RememberedOffset fEndOffset= new RememberedOffset();
-
-               /**
-                * Remember current selection.
-                */
-               public void remember() {
-                       /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=52257
-                        * This method may be called inside an async call posted
-                        * to the UI thread, so protect against intermediate disposal
-                        * of the editor. 
-                        */
-                       ISourceViewer viewer= getSourceViewer();
-                       if (viewer != null) {
-                               IRegion selection= getSignedSelection(viewer);
-                               int startOffset= selection.getOffset();
-                               int endOffset= startOffset + selection.getLength();
-                               
-                               fStartOffset.setOffset(startOffset);
-                               fEndOffset.setOffset(endOffset);
-                       }
-               }
-
-               /**
-                * Restore remembered selection.
-                */
-               public void restore() {
-                       /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=52257
-                        * This method may be called inside an async call posted
-                        * to the UI thread, so protect against intermediate disposal
-                        * of the editor.
-                        */
-                       if (getSourceViewer() == null)
-                               return;
-                       
-                       try {
-                               
-                               int startOffset, endOffset;
-                               int revealStartOffset, revealEndOffset; 
-                               if (showsHighlightRangeOnly()) {
-                                       IJavaElement newStartElement= fStartOffset.getElement();
-                                       startOffset= fStartOffset.getRememberedOffset(newStartElement);
-                                       revealStartOffset= fStartOffset.getRevealOffset(newStartElement, startOffset);
-                                       if (revealStartOffset == -1)
-                                               startOffset= -1;
-                                       
-                                       IJavaElement newEndElement= fEndOffset.getElement();
-                                       endOffset= fEndOffset.getRememberedOffset(newEndElement);
-                                       revealEndOffset= fEndOffset.getRevealOffset(newEndElement, endOffset);
-                                       if (revealEndOffset == -1)
-                                               endOffset= -1;
-                               } else {
-                                       startOffset= fStartOffset.getOffset();
-                                       revealStartOffset= startOffset;
-                                       endOffset= fEndOffset.getOffset();
-                                       revealEndOffset= endOffset;
-                               }
-                               
-                               if (startOffset == -1) {
-                                       startOffset= endOffset; // fallback to caret offset
-                                       revealStartOffset= revealEndOffset;
-                               }
-                               
-                               if (endOffset == -1) {
-                                       endOffset= startOffset; // fallback to other offset
-                                       revealEndOffset= revealStartOffset;
-                               }
-                               
-                               IJavaElement element;
-                               if (endOffset == -1) {
-                                        // fallback to element selection
-                                       element= fEndOffset.getElement();
-                                       if (element == null)
-                                               element= fStartOffset.getElement();
-                                       if (element != null)
-                                               setSelection(element);
-                                       return;
-                               }
-                                                       
-                               if (isValidSelection(revealStartOffset, revealEndOffset - revealStartOffset) && isValidSelection(startOffset, endOffset - startOffset))
-                                       selectAndReveal(startOffset, endOffset - startOffset, revealStartOffset, revealEndOffset - revealStartOffset);
-                       } finally {
-                               fStartOffset.clear();
-                               fEndOffset.clear();
-                       }
-               }
-
-               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;
-               }
-               
-       }
-
-       /**
-        * Remembers additional data for a given
-        * offset to be able restore it later.
-        * 
-        * @since 3.0
-        */
-       private class RememberedOffset {
-               /** Remembered line for the given offset */
-               private int fLine;
-               /** Remembered column for the given offset*/
-               private int fColumn;
-               /** Remembered Java element for the given offset*/
-               private IJavaElement fElement;
-               /** Remembered Java element line for the given offset*/
-               private int fElementLine;
-               
-               /**
-                * Store visual properties of the given offset.  
-                * 
-                * @param offset Offset in the document
-                */
-               public void setOffset(int offset) {
-                       try {
-                               IDocument document= getSourceViewer().getDocument();
-                               fLine= document.getLineOfOffset(offset);
-                               fColumn= offset - document.getLineOffset(fLine);
-                               fElement= getElementAt(offset, true);
-
-                               fElementLine= -1;
-                               if (fElement instanceof IMember) {
-                                       ISourceRange range= ((IMember) fElement).getNameRange();
-                                       if (range != null)
-                                               fElementLine= document.getLineOfOffset(range.getOffset());
-                               }
-                               if (fElementLine == -1)
-                                       fElementLine= document.getLineOfOffset(getOffset(fElement));
-                       } catch (BadLocationException e) {
-                               // should not happen
-                               PHPeclipsePlugin.log(e);
-                               clear();
-                       } catch (JavaModelException e) {
-                               // should not happen
-                         PHPeclipsePlugin.log(e.getStatus());
-                               clear();
-                       }
-               }
-
-               /**
-                * Return offset recomputed from stored visual properties.  
-                * 
-                * @return Offset in the document
-                */
-               public int getOffset() {
-                       IJavaElement newElement= getElement();
-                       
-                       int offset= getRememberedOffset(newElement);
-                       
-                       if (offset != -1 && !containsOffset(newElement, offset) && (offset == 0 || !containsOffset(newElement, offset - 1)))
-                               return -1;
-                       
-                       return offset;
-               }
-               
-               /**
-                * Return offset recomputed from stored visual properties.  
-                * 
-                * @param newElement Enclosing element
-                * @return Offset in the document
-                */
-               public int getRememberedOffset(IJavaElement newElement) {
-                       try {
-                               if (newElement == null)
-                                       return -1;
-                               
-                               IDocument document= getSourceViewer().getDocument();
-                               int newElementLine= -1;
-                               if (newElement instanceof IMember) {
-                                       ISourceRange range= ((IMember) newElement).getNameRange();
-                                       if (range != null)
-                                               newElementLine= document.getLineOfOffset(range.getOffset());
-                               }
-                               if (newElementLine == -1)
-                                       newElementLine= document.getLineOfOffset(getOffset(newElement));
-                               if (newElementLine == -1)
-                                       return -1;
-
-                               int newLine= fLine + newElementLine - fElementLine;
-                               if (newLine < 0 || newLine >= document.getNumberOfLines())
-                                       return -1;
-                               int maxColumn= document.getLineLength(newLine);
-                               String lineDelimiter= document.getLineDelimiter(newLine);
-                               if (lineDelimiter != null)
-                                       maxColumn= maxColumn - lineDelimiter.length();
-                               int offset;
-                               if (fColumn > maxColumn)
-                                       offset= document.getLineOffset(newLine) + maxColumn;
-                               else
-                                       offset= document.getLineOffset(newLine) + fColumn;
-
-                               return offset;
-                       } catch (BadLocationException e) {
-                               // should not happen
-                         PHPeclipsePlugin.log(e);
-                               return -1;
-                       } catch (JavaModelException e) {
-                               // should not happen
-                         PHPeclipsePlugin.log(e.getStatus());
-                               return -1;
-                       }
-               }
-               
-               /**
-                * Returns the offset used to reveal the given element based on the given selection offset.
-                * @param element the element
-                * @param offset the selection offset
-                * @return the offset to reveal the given element based on the given selection offset
-                */
-               public int getRevealOffset(IJavaElement element, int offset) {
-                       if (element == null || offset == -1)
-                               return -1;
-
-                       if (containsOffset(element, offset)) {
-                               if (offset > 0) {
-                                       IJavaElement alternateElement= getElementAt(offset, false);
-                                       if (element.getHandleIdentifier().equals(alternateElement.getParent().getHandleIdentifier()))
-                                               return offset - 1; // Solves test case 2 from https://bugs.eclipse.org/bugs/show_bug.cgi?id=47727#c3
-                               }
-                               return offset;
-                       } else if (offset > 0 && containsOffset(element, offset - 1))
-                               return offset - 1; // Solves test case 1 from https://bugs.eclipse.org/bugs/show_bug.cgi?id=47727#c3
-                       
-                       return -1;
-               }
-
-               /**
-                * Return Java element recomputed from stored visual properties.  
-                * 
-                * @return Java element
-                */
-               public IJavaElement getElement() {
-                       if (fElement == null)
-                               return null;
-                       
-                       return findElement(fElement);
-               }
-
-               /**
-                * Clears the stored position 
-                */
-               public void clear() {
-                       fLine= -1;
-                       fColumn= -1;
-                       fElement= null;
-                       fElementLine= -1;
-               }
-               
-               /**
-                * Does the given Java element contain the given offset?
-                * @param element Java element
-                * @param offset Offset
-                * @return <code>true</code> iff the Java element contains the offset
-                */
-               private boolean containsOffset(IJavaElement element, int offset) {
-                       int elementOffset= getOffset(element);
-                       int elementLength= getLength(element);
-                       return (elementOffset > -1 && elementLength > -1) ? (offset >= elementOffset && offset < elementOffset + elementLength) : false;
-               }
-               /**
-                * Returns the offset of the given Java element.
-                * 
-                * @param element       Java element
-                * @return 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;      
-               }
-               
-               /**
-                * Returns the length of the given Java element.
-                * 
-                * @param element       Java element
-                * @return Length of the given Java element
-                */
-               private int getLength(IJavaElement element) {
-                       if (element instanceof ISourceReference) {
-                               ISourceReference sr= (ISourceReference) element;
-                               try {
-                                       ISourceRange srcRange= sr.getSourceRange();
-                                       if (srcRange != null)
-                                               return srcRange.getLength();
-                               } catch (JavaModelException e) {
-                               }
-                       }
-                       return -1;      
-               }
-               
-               /**
-                * Returns the updated java element for the old java element.
-                * 
-                * @param element Old Java element
-                * @return Updated 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(ICompilationUnit.NO_AST, false, null, null);
-                                               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;
-               }
-               
-       }
-       
+   * Remembers additional data for a given offset to be able restore it later.
+   * 
+   * @since 3.0
+   */
+  private class RememberedOffset {
+    /** Remembered line for the given offset */
+    private int fLine;
+
+    /** Remembered column for the given offset */
+    private int fColumn;
+
+    /** Remembered Java element for the given offset */
+    private IJavaElement fElement;
+
+    /** Remembered Java element line for the given offset */
+    private int fElementLine;
+
+    /**
+     * Store visual properties of the given offset.
+     * 
+     * @param offset
+     *          Offset in the document
+     */
+    public void setOffset(int offset) {
+      try {
+        IDocument document = getSourceViewer().getDocument();
+        fLine = document.getLineOfOffset(offset);
+        fColumn = offset - document.getLineOffset(fLine);
+        fElement = getElementAt(offset, true);
+
+        fElementLine = -1;
+        if (fElement instanceof IMember) {
+          ISourceRange range = ((IMember) fElement).getNameRange();
+          if (range != null)
+            fElementLine = document.getLineOfOffset(range.getOffset());
+        }
+        if (fElementLine == -1)
+          fElementLine = document.getLineOfOffset(getOffset(fElement));
+      } catch (BadLocationException e) {
+        // should not happen
+        PHPeclipsePlugin.log(e);
+        clear();
+      } catch (JavaModelException e) {
+        // should not happen
+        PHPeclipsePlugin.log(e.getStatus());
+        clear();
+      }
+    }
+
+    /**
+     * Return offset recomputed from stored visual properties.
+     * 
+     * @return Offset in the document
+     */
+    public int getOffset() {
+      IJavaElement newElement = getElement();
+
+      int offset = getRememberedOffset(newElement);
+
+      if (offset != -1 && !containsOffset(newElement, offset) && (offset == 0 || !containsOffset(newElement, offset - 1)))
+        return -1;
+
+      return offset;
+    }
+
+    /**
+     * Return offset recomputed from stored visual properties.
+     * 
+     * @param newElement
+     *          Enclosing element
+     * @return Offset in the document
+     */
+    public int getRememberedOffset(IJavaElement newElement) {
+      try {
+        if (newElement == null)
+          return -1;
+
+        IDocument document = getSourceViewer().getDocument();
+        int newElementLine = -1;
+        if (newElement instanceof IMember) {
+          ISourceRange range = ((IMember) newElement).getNameRange();
+          if (range != null)
+            newElementLine = document.getLineOfOffset(range.getOffset());
+        }
+        if (newElementLine == -1)
+          newElementLine = document.getLineOfOffset(getOffset(newElement));
+        if (newElementLine == -1)
+          return -1;
+
+        int newLine = fLine + newElementLine - fElementLine;
+        if (newLine < 0 || newLine >= document.getNumberOfLines())
+          return -1;
+        int maxColumn = document.getLineLength(newLine);
+        String lineDelimiter = document.getLineDelimiter(newLine);
+        if (lineDelimiter != null)
+          maxColumn = maxColumn - lineDelimiter.length();
+        int offset;
+        if (fColumn > maxColumn)
+          offset = document.getLineOffset(newLine) + maxColumn;
+        else
+          offset = document.getLineOffset(newLine) + fColumn;
+
+        return offset;
+      } catch (BadLocationException e) {
+        // should not happen
+        PHPeclipsePlugin.log(e);
+        return -1;
+      } catch (JavaModelException e) {
+        // should not happen
+        PHPeclipsePlugin.log(e.getStatus());
+        return -1;
+      }
+    }
+
+    /**
+     * Returns the offset used to reveal the given element based on the given selection offset.
+     * 
+     * @param element
+     *          the element
+     * @param offset
+     *          the selection offset
+     * @return the offset to reveal the given element based on the given selection offset
+     */
+    public int getRevealOffset(IJavaElement element, int offset) {
+      if (element == null || offset == -1)
+        return -1;
+
+      if (containsOffset(element, offset)) {
+        if (offset > 0) {
+          IJavaElement alternateElement = getElementAt(offset, false);
+          if (element.getHandleIdentifier().equals(alternateElement.getParent().getHandleIdentifier()))
+            return offset - 1; // Solves test case 2 from https://bugs.eclipse.org/bugs/show_bug.cgi?id=47727#c3
+        }
+        return offset;
+      } else if (offset > 0 && containsOffset(element, offset - 1))
+        return offset - 1; // Solves test case 1 from https://bugs.eclipse.org/bugs/show_bug.cgi?id=47727#c3
+
+      return -1;
+    }
+
+    /**
+     * Return Java element recomputed from stored visual properties.
+     * 
+     * @return Java element
+     */
+    public IJavaElement getElement() {
+      if (fElement == null)
+        return null;
+
+      return findElement(fElement);
+    }
+
+    /**
+     * Clears the stored position
+     */
+    public void clear() {
+      fLine = -1;
+      fColumn = -1;
+      fElement = null;
+      fElementLine = -1;
+    }
+
+    /**
+     * Does the given Java element contain the given offset?
+     * 
+     * @param element
+     *          Java element
+     * @param offset
+     *          Offset
+     * @return <code>true</code> iff the Java element contains the offset
+     */
+    private boolean containsOffset(IJavaElement element, int offset) {
+      int elementOffset = getOffset(element);
+      int elementLength = getLength(element);
+      return (elementOffset > -1 && elementLength > -1) ? (offset >= elementOffset && offset < elementOffset + elementLength)
+          : false;
+    }
+
+    /**
+     * Returns the offset of the given Java element.
+     * 
+     * @param element
+     *          Java element
+     * @return 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;
+    }
+
+    /**
+     * Returns the length of the given Java element.
+     * 
+     * @param element
+     *          Java element
+     * @return Length of the given Java element
+     */
+    private int getLength(IJavaElement element) {
+      if (element instanceof ISourceReference) {
+        ISourceReference sr = (ISourceReference) element;
+        try {
+          ISourceRange srcRange = sr.getSourceRange();
+          if (srcRange != null)
+            return srcRange.getLength();
+        } catch (JavaModelException e) {
+        }
+      }
+      return -1;
+    }
+
+    /**
+     * Returns the updated java element for the old java element.
+     * 
+     * @param element
+     *          Old Java element
+     * @return Updated 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(ICompilationUnit.NO_AST, false, null, null);
+            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;
+    }
+
+  }
+
   static class TabConverter implements ITextConverter {
     private int fTabRatio;
 
@@ -631,8 +818,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
       return remainder;
     }
 
-    public void customizeDocumentCommand(IDocument document,
-        DocumentCommand command) {
+    public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
       String text = command.text;
       if (text == null)
         return;
@@ -648,8 +834,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
             String line = text.substring(offset, endOffset);
             int position = 0;
             if (i == 0) {
-              IRegion firstLine = document
-                  .getLineInformationOfOffset(command.offset);
+              IRegion firstLine = document.getLineInformationOfOffset(command.offset);
               position = command.offset - firstLine.getOffset();
             }
             int length = line.length();
@@ -681,12 +866,10 @@ public class PHPUnitEditor extends PHPEditor { //implements
      * @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) {
+    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);
+          return new ExitFlags(LinkedPositionUI.COMMIT | LinkedPositionUI.UPDATE_CARET, false);
         else
           return new ExitFlags(LinkedPositionUI.COMMIT, true);
       }
@@ -715,12 +898,13 @@ public class PHPUnitEditor extends PHPEditor { //implements
     LinkedPositionUI fEditor;
   };
 
-  private class BracketInserter implements VerifyKeyListener,
-      LinkedPositionUI.ExitListener {
+  private class BracketInserter implements VerifyKeyListener, LinkedPositionUI.ExitListener {
     private boolean fCloseBracketsPHP = true;
 
     private boolean fCloseStringsPHPDQ = true;
+
     private boolean fCloseStringsPHPSQ = true;
+
     private boolean fCloseBracketsHTML = true;
 
     private boolean fCloseStringsHTML = true;
@@ -736,9 +920,11 @@ public class PHPUnitEditor extends PHPEditor { //implements
     public void setCloseStringsPHPDQEnabled(boolean enabled) {
       fCloseStringsPHPDQ = enabled;
     }
+
     public void setCloseStringsPHPSQEnabled(boolean enabled) {
       fCloseStringsPHPSQ = enabled;
     }
+
     public void setCloseBracketsHTMLEnabled(boolean enabled) {
       fCloseBracketsHTML = enabled;
     }
@@ -754,8 +940,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
         int maxEnd = endLine.getOffset() + endLine.getLength();
         while (end != maxEnd && Character.isWhitespace(document.getChar(end)))
           ++end;
-        return end != maxEnd
-            && Scanner.isPHPIdentifierPart(document.getChar(end));
+        return end != maxEnd && Scanner.isPHPIdentifierPart(document.getChar(end));
       } catch (BadLocationException e) {
         // be conservative
         return true;
@@ -767,18 +952,15 @@ public class PHPUnitEditor extends PHPEditor { //implements
         int start = offset;
         IRegion startLine = document.getLineInformationOfOffset(start);
         int minStart = startLine.getOffset();
-        while (start != minStart
-            && Character.isWhitespace(document.getChar(start - 1)))
+        while (start != minStart && Character.isWhitespace(document.getChar(start - 1)))
           --start;
-        return start != minStart
-            && Scanner.isPHPIdentifierPart(document.getChar(start - 1));
+        return start != minStart && Scanner.isPHPIdentifierPart(document.getChar(start - 1));
       } catch (BadLocationException e) {
         return true;
       }
     }
 
-    private boolean hasCharacterToTheRight(IDocument document, int offset,
-        char character) {
+    private boolean hasCharacterToTheRight(IDocument document, int offset, char character) {
       try {
         int end = offset;
         IRegion endLine = document.getLineInformationOfOffset(end);
@@ -806,8 +988,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
       try {
         ITypedRegion partition = document.getPartition(offset);
         String type = partition.getType();
-        if (type.equals(IPHPPartitions.PHP_PARTITIONING)
-            || type.equals(IDocument.DEFAULT_CONTENT_TYPE)) {
+        if (type.equals(IPHPPartitions.PHP_PARTITIONING) || type.equals(IDocument.DEFAULT_CONTENT_TYPE)) {
           // you will get IDocument.DEFAULT_CONTENT_TYPE for both PHP and HTML area
           switch (event.character) {
           case '(':
@@ -849,18 +1030,16 @@ public class PHPUnitEditor extends PHPEditor { //implements
             managerDQ.addPosition(offset + 1, 0);
             fOffset = offset;
             fLength = 2;
-            LinkedPositionUI editorDQ = new LinkedPositionUI(sourceViewer,
-                managerDQ);
+            LinkedPositionUI editorDQ = new LinkedPositionUI(sourceViewer, managerDQ);
             editorDQ.setCancelListener(this);
             editorDQ.setExitPolicy(new ExitPolicy(closingCharacterDQ));
             editorDQ.setFinalCaretOffset(offset + 2);
             editorDQ.enter();
             IRegion newSelectionDQ = editorDQ.getSelectedRegion();
-            sourceViewer.setSelectedRange(newSelectionDQ.getOffset(),
-                newSelectionDQ.getLength());
+            sourceViewer.setSelectedRange(newSelectionDQ.getOffset(), newSelectionDQ.getLength());
             event.doit = false;
             break;
-//          fall through
+          //          fall through
           case '\'':
             if (event.character == '\'') {
               if (!fCloseStringsPHPSQ)
@@ -890,67 +1069,65 @@ public class PHPUnitEditor extends PHPEditor { //implements
             managerSQ.addPosition(offset + 1, 0);
             fOffset = offset;
             fLength = 2;
-            LinkedPositionUI editorSQ = new LinkedPositionUI(sourceViewer,
-                managerSQ);
+            LinkedPositionUI editorSQ = new LinkedPositionUI(sourceViewer, managerSQ);
             editorSQ.setCancelListener(this);
             editorSQ.setExitPolicy(new ExitPolicy(closingCharacterSQ));
             editorSQ.setFinalCaretOffset(offset + 2);
             editorSQ.enter();
             IRegion newSelectionSQ = editorSQ.getSelectedRegion();
-            sourceViewer.setSelectedRange(newSelectionSQ.getOffset(),
-                newSelectionSQ.getLength());
+            sourceViewer.setSelectedRange(newSelectionSQ.getOffset(), newSelectionSQ.getLength());
             event.doit = false;
           }
         }
-//        } else if (type.equals(IPHPPartitions.HTML)) {
-//          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;
-//          }
-//        }
+        //        } else if (type.equals(IPHPPartitions.HTML)) {
+        //          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) {
       }
     }
@@ -975,8 +1152,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
   protected ISavePolicy fSavePolicy;
 
   /**
-   * Listener to annotation model changes that updates the error tick in the tab
-   * image
+   * Listener to annotation model changes that updates the error tick in the tab image
    */
   private JavaEditorErrorTickUpdater fJavaEditorErrorTickUpdater;
 
@@ -1008,11 +1184,11 @@ public class PHPUnitEditor extends PHPEditor { //implements
   private IJavaElement fRememberedElement;
 
   /**
-        * The remembered selection.
-        * @since 3.0
-        */
- private RememberedSelection fRememberedSelection= new RememberedSelection();
-       
+   * The remembered selection.
+   * 
+   * @since 3.0
+   */
+  private RememberedSelection fRememberedSelection = new RememberedSelection();
 
   /** The remembered php element offset */
   private int fRememberedElementOffset;
@@ -1124,6 +1300,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
   /** Preference key for automatically closing double quoted strings */
   private final static String CLOSE_STRINGS_DQ_PHP = PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP;
+
   /** Preference key for automatically closing single quoted strings */
   private final static String CLOSE_STRINGS_SQ_PHP = PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP;
 
@@ -1211,26 +1388,25 @@ public class PHPUnitEditor extends PHPEditor { //implements
   /**
    * Creates a new php unit editor.
    */
-  
+
   /**
-        * Reconciling listeners.
-        * @since 3.0
-        */
-       private ListenerList fReconcilingListeners= new ListenerList();
-
-       /**
-        * Mutex for the reconciler. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=63898
-        * for a description of the problem.
-        * <p>
-        * TODO remove once the underlying problem is solved.
-        * </p>
-        */
-       private final Object fReconcilerLock= new Object();
-  
+   * Reconciling listeners.
+   * 
+   * @since 3.0
+   */
+  private ListenerList fReconcilingListeners = new ListenerList();
+
+  /**
+   * Mutex for the reconciler. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=63898 for a description of the problem.
+   * <p>
+   * TODO remove once the underlying problem is solved.
+   * </p>
+   */
+  private final Object fReconcilerLock = new Object();
+
   public PHPUnitEditor() {
     super();
-    setDocumentProvider(PHPeclipsePlugin.getDefault()
-        .getCompilationUnitDocumentProvider());
+    setDocumentProvider(PHPeclipsePlugin.getDefault().getCompilationUnitDocumentProvider());
     setEditorContextMenuId("#PHPEditorContext"); //$NON-NLS-1$
     setRulerContextMenuId("#PHPRulerContext"); //$NON-NLS-1$
     setOutlinerContextMenuId("#PHPOutlinerContext"); //$NON-NLS-1$
@@ -1255,10 +1431,8 @@ public class PHPUnitEditor extends PHPEditor { //implements
     // //$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);
+    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,
@@ -1283,52 +1457,48 @@ public class PHPUnitEditor extends PHPEditor { //implements
     // //$NON-NLS-1$
     //// WorkbenchHelp.setHelp(action,
     // IJavaHelpContextIds.PARAMETER_HINTS_ACTION);
-    action = new TextOperationAction(PHPEditorMessages.getResourceBundle(),
-        "Comment.", this, ITextOperationTarget.PREFIX); //$NON-NLS-1$
+    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 = 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 = 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 = 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$                
+    //    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(),
@@ -1351,15 +1521,12 @@ public class PHPUnitEditor extends PHPEditor { //implements
       //                       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 });
+    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 });
+    fContextMenuGroup = new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup });
     //      rg,
     //      new LocalHistoryActionGroup(this,
     // ITextEditorActionConstants.GROUP_EDIT)});
@@ -1374,11 +1541,9 @@ public class PHPUnitEditor extends PHPEditor { //implements
   }
 
   /**
-   * 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.
+   * 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
@@ -1386,8 +1551,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
    *          <code>true</code> if working copy should be reconciled
    */
   protected IJavaElement getElementAt(int offset, boolean reconcile) {
-    IWorkingCopyManager manager = PHPeclipsePlugin.getDefault()
-        .getWorkingCopyManager();
+    IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager();
     ICompilationUnit unit = manager.getWorkingCopy(getEditorInput());
     if (unit != null) {
       try {
@@ -1424,8 +1588,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
     //    fPaintManager = new PaintManager(getSourceViewer());
     LinePainter linePainter;
     linePainter = new LinePainter(getSourceViewer());
-    linePainter
-        .setHighlightColor(new Color(Display.getCurrent(), 225, 235, 224));
+    linePainter.setHighlightColor(new Color(Display.getCurrent(), 225, 235, 224));
     //    fPaintManager.addPainter(linePainter);
     if (isBracketHighlightingEnabled())
       startBracketHighlighting();
@@ -1460,8 +1623,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
     fBracketInserter.setCloseStringsHTMLEnabled(closeStringsHTML);
     ISourceViewer sourceViewer = getSourceViewer();
     if (sourceViewer instanceof ITextViewerExtension)
-      ((ITextViewerExtension) sourceViewer)
-          .prependVerifyKeyListener(fBracketInserter);
+      ((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter);
   }
 
   private static char getPeerCharacter(char character) {
@@ -1533,8 +1695,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
     if (fPrintMarginPainter == null) {
       fPrintMarginPainter = new PrintMarginPainter(getSourceViewer());
       fPrintMarginPainter.setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
-      fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(
-          PRINT_MARGIN_COLUMN));
+      fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(PRINT_MARGIN_COLUMN));
       //      fPaintManager.addPainter(fPrintMarginPainter);
     }
   }
@@ -1627,8 +1788,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
   //  }
 
   private int getTabSize() {
-    Preferences preferences = PHPeclipsePlugin.getDefault()
-        .getPluginPreferences();
+    Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
     return preferences.getInt(CODE_FORMATTER_TAB_SIZE);
   }
 
@@ -1681,8 +1841,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
   public void dispose() {
     ISourceViewer sourceViewer = getSourceViewer();
     if (sourceViewer instanceof ITextViewerExtension)
-      ((ITextViewerExtension) sourceViewer)
-          .removeVerifyKeyListener(fBracketInserter);
+      ((ITextViewerExtension) sourceViewer).removeVerifyKeyListener(fBracketInserter);
     //    if (fPropertyChangeListener != null) {
     //      Preferences preferences =
     // PHPeclipsePlugin.getDefault().getPluginPreferences();
@@ -1729,28 +1888,23 @@ public class PHPUnitEditor extends PHPEditor { //implements
       if (asv != null) {
         String p = event.getProperty();
         if (CLOSE_BRACKETS_PHP.equals(p)) {
-          fBracketInserter.setCloseBracketsPHPEnabled(getPreferenceStore()
-              .getBoolean(p));
+          fBracketInserter.setCloseBracketsPHPEnabled(getPreferenceStore().getBoolean(p));
           return;
         }
         if (CLOSE_STRINGS_DQ_PHP.equals(p)) {
-          fBracketInserter.setCloseStringsPHPDQEnabled(getPreferenceStore()
-              .getBoolean(p));
+          fBracketInserter.setCloseStringsPHPDQEnabled(getPreferenceStore().getBoolean(p));
           return;
         }
         if (CLOSE_STRINGS_SQ_PHP.equals(p)) {
-          fBracketInserter.setCloseStringsPHPSQEnabled(getPreferenceStore()
-              .getBoolean(p));
+          fBracketInserter.setCloseStringsPHPSQEnabled(getPreferenceStore().getBoolean(p));
           return;
         }
         if (CLOSE_BRACKETS_HTML.equals(p)) {
-          fBracketInserter.setCloseBracketsHTMLEnabled(getPreferenceStore()
-              .getBoolean(p));
+          fBracketInserter.setCloseBracketsHTMLEnabled(getPreferenceStore().getBoolean(p));
           return;
         }
         if (CLOSE_STRINGS_HTML.equals(p)) {
-          fBracketInserter.setCloseStringsHTMLEnabled(getPreferenceStore()
-              .getBoolean(p));
+          fBracketInserter.setCloseStringsHTMLEnabled(getPreferenceStore().getBoolean(p));
           return;
         }
         if (SPACES_FOR_TABS.equals(p)) {
@@ -1769,8 +1923,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
         }
         if (MATCHING_BRACKETS_COLOR.equals(p)) {
           if (fBracketPainter != null)
-            fBracketPainter
-                .setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
+            fBracketPainter.setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
           return;
         }
         if (CURRENT_LINE.equals(p)) {
@@ -1796,14 +1949,12 @@ public class PHPUnitEditor extends PHPEditor { //implements
         }
         if (PRINT_MARGIN_COLOR.equals(p)) {
           if (fPrintMarginPainter != null)
-            fPrintMarginPainter
-                .setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
+            fPrintMarginPainter.setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
           return;
         }
         if (PRINT_MARGIN_COLUMN.equals(p)) {
           if (fPrintMarginPainter != null)
-            fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore()
-                .getInt(PRINT_MARGIN_COLUMN));
+            fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(PRINT_MARGIN_COLUMN));
           return;
         }
         //        if (OVERVIEW_RULER.equals(p)) {
@@ -1846,8 +1997,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
         //        }
         IContentAssistant c = asv.getContentAssistant();
         if (c instanceof ContentAssistant)
-          ContentAssistPreference.changeConfiguration((ContentAssistant) c,
-              getPreferenceStore(), event);
+          ContentAssistPreference.changeConfiguration((ContentAssistant) c, getPreferenceStore(), event);
       }
     } finally {
       super.handlePreferenceStoreChanged(event);
@@ -1857,8 +2007,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
   /*
    * @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) {
+  protected void handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
     AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
     if (asv != null) {
       String p = event.getProperty();
@@ -1872,8 +2021,8 @@ public class PHPUnitEditor extends PHPEditor { //implements
   }
 
   /**
-   * Handles a property change event describing a change of the php core's
-   * preferences and updates the preference related editor properties.
+   * 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
@@ -1893,14 +2042,11 @@ public class PHPUnitEditor extends PHPEditor { //implements
   //  }
   /*
    * @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)
+   *      org.eclipse.jface.text.source.IVerticalRuler, org.eclipse.jface.text.source.IOverviewRuler, boolean, int)
    */
-  protected ISourceViewer createJavaSourceViewer(Composite parent,
-      IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
+  protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
       boolean isOverviewRulerVisible, int styles, IPreferenceStore store) {
-    return new AdaptedSourceViewer(parent, verticalRuler, overviewRuler,
-        isOverviewRulerVisible, styles, store);
+    return new AdaptedSourceViewer(parent, verticalRuler, overviewRuler, isOverviewRulerVisible, styles, store);
   }
 
   //  protected ISourceViewer createJavaSourceViewer(Composite parent,
@@ -1914,26 +2060,25 @@ public class PHPUnitEditor extends PHPEditor { //implements
       if (document != null) {
         int end = offset + length;
         int documentLength = document.getLength();
-        return 0 <= offset && offset <= documentLength && 0 <= end
-            && end <= documentLength;
+        return 0 <= offset && offset <= documentLength && 0 <= end && end <= documentLength;
       }
     }
     return false;
   }
 
   /*
-        * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#getInputElement()
-        */
-       protected IJavaElement getInputJavaElement() {
-               return PHPeclipsePlugin.getDefault().getWorkingCopyManager().getWorkingCopy(getEditorInput());
-       }
+   * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#getInputElement()
+   */
+  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());
+    ActionContext context = new ActionContext(getSelectionProvider().getSelection());
     fContextMenuGroup.setContext(context);
     fContextMenuGroup.fillContextMenu(menu);
     fContextMenuGroup.setContext(null);
@@ -1944,16 +2089,13 @@ public class PHPUnitEditor extends PHPEditor { //implements
    */
   protected void setOutlinePageInput(JavaOutlinePage page, IEditorInput input) {
     if (page != null) {
-      IWorkingCopyManager manager = PHPeclipsePlugin.getDefault()
-          .getWorkingCopyManager();
+      IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager();
       page.setInput(manager.getWorkingCopy(input));
     }
   }
-  
 
   /*
-   * @see AbstractTextEditor#performSaveOperation(WorkspaceModifyOperation,
-   *      IProgressMonitor)
+   * @see AbstractTextEditor#performSaveOperation(WorkspaceModifyOperation, IProgressMonitor)
    */
   //  protected void performSaveOperation(WorkspaceModifyOperation operation,
   // IProgressMonitor progressMonitor) {
@@ -1988,25 +2130,21 @@ public class PHPUnitEditor extends PHPEditor { //implements
       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.
+         * 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.
+         * 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$
+                PHPEditorMessages.getString("PHPUnitEditor.error.saving.title1"), PHPEditorMessages.getString("PHPUnitEditor.error.saving.message1")); //$NON-NLS-1$ //$NON-NLS-2$
       }
 
     } else {
@@ -2016,8 +2154,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
       updateState(getEditorInput());
       validateState(getEditorInput());
 
-      IWorkingCopyManager manager = PHPeclipsePlugin.getDefault()
-          .getWorkingCopyManager();
+      IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager();
       ICompilationUnit unit = manager.getWorkingCopy(getEditorInput());
 
       if (unit != null) {
@@ -2034,10 +2171,8 @@ public class PHPUnitEditor extends PHPEditor { //implements
   }
 
   /**
-   * 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
+   * 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
@@ -2049,9 +2184,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
     SaveAsDialog dialog = new SaveAsDialog(shell);
 
-    IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input)
-        .getFile()
-        : null;
+    IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null;
     if (original != null)
       dialog.setOriginalFile(original);
 
@@ -2064,9 +2197,8 @@ public class PHPUnitEditor extends PHPEditor { //implements
     }
 
     if (provider.isDeleted(input) && original != null) {
-      String message = PHPEditorMessages
-          .getFormattedString(
-              "CompilationUnitEditor.warning.save.delete", new Object[] { original.getName() }); //$NON-NLS-1$
+      String message = PHPEditorMessages.getFormattedString(
+          "CompilationUnitEditor.warning.save.delete", new Object[] { original.getName() }); //$NON-NLS-1$
       dialog.setErrorMessage(null);
       dialog.setMessage(message, IMessageProvider.WARNING);
     }
@@ -2092,8 +2224,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
     try {
 
       provider.aboutToChange(newInput);
-      getDocumentProvider().saveDocument(progressMonitor, newInput,
-          getDocumentProvider().getDocument(getEditorInput()), true);
+      getDocumentProvider().saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true);
       success = true;
 
     } catch (CoreException x) {
@@ -2102,8 +2233,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
         ErrorDialog
             .openError(
                 shell,
-                PHPEditorMessages
-                    .getString("CompilationUnitEditor.error.saving.title2"), PHPEditorMessages.getString("CompilationUnitEditor.error.saving.message2"), x.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$
+                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)
@@ -2203,8 +2333,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
   }
 
   /*
-   * @see org.eclipse.ui.texteditor.AbstractTextEditor#performSave(boolean,
-   *      org.eclipse.core.runtime.IProgressMonitor)
+   * @see org.eclipse.ui.texteditor.AbstractTextEditor#performSave(boolean, org.eclipse.core.runtime.IProgressMonitor)
    */
   protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) {
     IDocumentProvider p = getDocumentProvider();
@@ -2245,72 +2374,64 @@ public class PHPUnitEditor extends PHPEditor { //implements
       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 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$
+          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$
+          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 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(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(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();
+          }
+        });
+      }
+    }
+  }
 
   private boolean synchronizeOutlineOnCursorMove() {
-    return PreferenceConstants.getPreferenceStore().getBoolean(
-        PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);
+    return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);
   }
 
   /**
@@ -2319,8 +2440,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
   private IJavaElement findElement(IJavaElement element) {
     if (element == null)
       return null;
-    IWorkingCopyManager manager = PHPeclipsePlugin.getDefault()
-        .getWorkingCopyManager();
+    IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager();
     ICompilationUnit unit = manager.getWorkingCopy(getEditorInput());
     if (unit != null) {
       try {
@@ -2354,150 +2474,150 @@ public class PHPUnitEditor extends PHPEditor { //implements
     return -1;
   }
 
-  
-
   /*
    * @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;
-//    }
-//  }
+  //  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;
+  //    }
+  //  }
+  /**
+   * Tells whether this is the active editor in the active page.
+   * 
+   * @return <code>true</code> if this is the active editor in the active page
+   * @see IWorkbenchPage#getActiveEditor();
+   */
+  protected final boolean isActiveEditor() {
+    IWorkbenchWindow window = getSite().getWorkbenchWindow();
+    IWorkbenchPage page = window.getActivePage();
+    if (page == null)
+      return false;
+    IEditorPart activeEditor = page.getActiveEditor();
+    return activeEditor != null && activeEditor.equals(this);
+  }
 
   /**
-        * Tells whether this is the active editor in the active page.
-        *
-        * @return <code>true</code> if this is the active editor in the active page
-        * @see IWorkbenchPage#getActiveEditor();
-        */
-       protected final boolean isActiveEditor() {
-               IWorkbenchWindow window= getSite().getWorkbenchWindow();
-               IWorkbenchPage page= window.getActivePage();
-               if (page == null)
-                       return false;
-               IEditorPart activeEditor= page.getActiveEditor();
-               return activeEditor != null && activeEditor.equals(this);
-       }
-       
-       /**
-        * Adds the given listener.
-        * Has no effect if an identical listener was not already registered.
-        * 
-        * @param listener      The reconcile listener to be added
-        * @since 3.0
-        */
-       final void addReconcileListener(IJavaReconcilingListener listener) {
-               synchronized (fReconcilingListeners) {
-                       fReconcilingListeners.add(listener);
-               }
-       }
-       
-       /**
-        * Removes the given listener.
-        * Has no effect if an identical listener was not already registered.
-        * 
-        * @param listener      the reconcile listener to be removed
-        * @since 3.0
-        */
-       final void removeReconcileListener(IJavaReconcilingListener listener) {
-               synchronized (fReconcilingListeners) {
-                       fReconcilingListeners.remove(listener);
-               }
-       }
-               
-       protected void updateStateDependentActions() {
-               super.updateStateDependentActions();
-               fGenerateActionGroup.editorStateChanged();
-       }
-       
-       /*
-        * @see AbstractTextEditor#rememberSelection()
-        */
-       protected void rememberSelection() {
-               fRememberedSelection.remember();
-       }
-       
-       /*
-        * @see AbstractTextEditor#restoreSelection()
-        */
-       protected void restoreSelection() {
-               fRememberedSelection.restore();
-       }
-       
-       /*
-        * @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.ui.texteditor.AbstractDecoratedTextEditor#isPrefQuickDiffAlwaysOn()
-        */
-       protected boolean isPrefQuickDiffAlwaysOn() {
-               // reestablishes the behaviour from AbstractDecoratedTextEditor which was hacked by JavaEditor
-               // to disable the change bar for the class file (attached source) java editor.
-               IPreferenceStore store= getPreferenceStore();
-               return store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON);
-       }
-       
-       /*
-        * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#getAdapter(java.lang.Class)
-        */
-       public Object getAdapter(Class required) {
-               if (SmartBackspaceManager.class.equals(required)) {
-                       if (getSourceViewer() instanceof JavaSourceViewer) {
-                               return ((JavaSourceViewer) getSourceViewer()).getBackspaceManager();
-                       }
-               }
-
-               return super.getAdapter(required);
-       }
+   * Adds the given listener. Has no effect if an identical listener was not already registered.
+   * 
+   * @param listener
+   *          The reconcile listener to be added
+   * @since 3.0
+   */
+  final void addReconcileListener(IJavaReconcilingListener listener) {
+    synchronized (fReconcilingListeners) {
+      fReconcilingListeners.add(listener);
+    }
+  }
+
   /**
-        * Returns the mutex for the reconciler. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=63898
-        * for a description of the problem.
-        * <p>
-        * TODO remove once the underlying problem is solved.
-        * </p>
-        * @return the lock reconcilers may use to synchronize on
-        */
-       public Object getReconcilerLock() {
-               return fReconcilerLock;
-       }
-       
-  /* (non-Javadoc)
+   * Removes the given listener. Has no effect if an identical listener was not already registered.
+   * 
+   * @param listener
+   *          the reconcile listener to be removed
+   * @since 3.0
+   */
+  final void removeReconcileListener(IJavaReconcilingListener listener) {
+    synchronized (fReconcilingListeners) {
+      fReconcilingListeners.remove(listener);
+    }
+  }
+
+  protected void updateStateDependentActions() {
+    super.updateStateDependentActions();
+    fGenerateActionGroup.editorStateChanged();
+  }
+
+  /*
+   * @see AbstractTextEditor#rememberSelection()
+   */
+  protected void rememberSelection() {
+    fRememberedSelection.remember();
+  }
+
+  /*
+   * @see AbstractTextEditor#restoreSelection()
+   */
+  protected void restoreSelection() {
+    fRememberedSelection.restore();
+  }
+
+  /*
+   * @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.ui.texteditor.AbstractDecoratedTextEditor#isPrefQuickDiffAlwaysOn()
+   */
+  protected boolean isPrefQuickDiffAlwaysOn() {
+    // reestablishes the behaviour from AbstractDecoratedTextEditor which was hacked by JavaEditor
+    // to disable the change bar for the class file (attached source) java editor.
+    IPreferenceStore store = getPreferenceStore();
+    return store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON);
+  }
+
+  /*
+   * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#getAdapter(java.lang.Class)
+   */
+  public Object getAdapter(Class required) {
+    if (SmartBackspaceManager.class.equals(required)) {
+      if (getSourceViewer() instanceof JavaSourceViewer) {
+        return ((JavaSourceViewer) getSourceViewer()).getBackspaceManager();
+      }
+    }
+
+    return super.getAdapter(required);
+  }
+
+  /**
+   * Returns the mutex for the reconciler. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=63898 for a description of the problem.
+   * <p>
+   * TODO remove once the underlying problem is solved.
+   * </p>
+   * 
+   * @return the lock reconcilers may use to synchronize on
+   */
+  public Object getReconcilerLock() {
+    return fReconcilerLock;
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
    * @see org.eclipse.ui.texteditor.AbstractTextEditor#editorSaved()
    */
   protected void editorSaved() {