Refactory
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpeclipse / phpeditor / PHPUnitEditor.java
index e0e5151..d330b73 100644 (file)
@@ -26,7 +26,7 @@ import net.sourceforge.phpdt.internal.ui.text.ContentAssistPreference;
 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
 import net.sourceforge.phpdt.internal.ui.text.JavaHeuristicScanner;
 import net.sourceforge.phpdt.internal.ui.text.JavaIndenter;
-import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher;
+//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;
@@ -58,7 +58,7 @@ import org.eclipse.jface.dialogs.ErrorDialog;
 import org.eclipse.jface.dialogs.IMessageProvider;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
+//import org.eclipse.jface.preference.PreferenceConverter;
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.DocumentCommand;
 import org.eclipse.jface.text.IAutoEditStrategy;
@@ -77,7 +77,9 @@ import org.eclipse.jface.text.source.IOverviewRuler;
 import org.eclipse.jface.text.source.ISourceViewer;
 import org.eclipse.jface.text.source.IVerticalRuler;
 import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.jface.util.ListenerList;
+//incastrix
+//import org.eclipse.jface.util.ListenerList;
+import org.eclipse.core.runtime.ListenerList;
 import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.jface.window.Window;
 import org.eclipse.swt.SWT;
@@ -960,15 +962,15 @@ public class PHPUnitEditor extends PHPEditor { // implements
                }
        }
 
-       private static class BracketLevel {
-               int fOffset;
-
-               int fLength;
-
-               LinkedPositionManager fManager;
-
-               LinkedPositionUI fEditor;
-       };
+//     private static class BracketLevel {
+//             int fOffset;
+//
+//             int fLength;
+//
+//             LinkedPositionManager fManager;
+//
+//             LinkedPositionUI fEditor;
+//     };
 
        private class BracketInserter implements VerifyKeyListener,
                        LinkedPositionUI.ExitListener {
@@ -1010,21 +1012,21 @@ public class PHPUnitEditor extends PHPEditor { // implements
                        }
                }
 
-               private boolean hasIdentifierToTheLeft(IDocument document, int offset) {
-                       try {
-                               int start = offset;
-                               IRegion startLine = document.getLineInformationOfOffset(start);
-                               int minStart = startLine.getOffset();
-                               while (start != minStart
-                                               && Character.isWhitespace(document.getChar(start - 1)))
-                                       --start;
-                               return start != minStart
-                                               && Scanner.isPHPIdentifierPart(document
-                                                               .getChar(start - 1));
-                       } catch (BadLocationException e) {
-                               return true;
-                       }
-               }
+//             private boolean hasIdentifierToTheLeft(IDocument document, int offset) {
+//                     try {
+//                             int start = offset;
+//                             IRegion startLine = document.getLineInformationOfOffset(start);
+//                             int minStart = startLine.getOffset();
+//                             while (start != minStart
+//                                             && Character.isWhitespace(document.getChar(start - 1)))
+//                                     --start;
+//                             return start != minStart
+//                                             && Scanner.isPHPIdentifierPart(document
+//                                                             .getChar(start - 1));
+//                     } catch (BadLocationException e) {
+//                             return true;
+//                     }
+//             }
 
                private boolean hasCharacterToTheLeft(IDocument document, int offset,
                                char character) {
@@ -1257,7 +1259,7 @@ public class PHPUnitEditor extends PHPEditor { // implements
        /** The editor's bracket painter */
        // private BracketPainter fBracketPainter;
        /** The editor's bracket matcher */
-       private PHPPairMatcher fBracketMatcher;
+       //private PHPPairMatcher fBracketMatcher;
 
        /** The editor's line painter */
        // private LinePainter fLinePainter;
@@ -1274,7 +1276,7 @@ public class PHPUnitEditor extends PHPEditor { // implements
        // private IPropertyChangeListener fPropertyChangeListener = new
        // PropertyChangeListener();
        /** The remembered java element */
-       private IJavaElement fRememberedElement;
+       //private IJavaElement fRememberedElement;
 
        /**
         * The remembered selection.
@@ -1284,7 +1286,7 @@ public class PHPUnitEditor extends PHPEditor { // implements
        private RememberedSelection fRememberedSelection = new RememberedSelection();
 
        /** The remembered php element offset */
-       private int fRememberedElementOffset;
+       //private int fRememberedElementOffset;
 
        /** The bracket inserter. */
        private BracketInserter fBracketInserter = new BracketInserter();
@@ -1344,52 +1346,52 @@ public class PHPUnitEditor extends PHPEditor { // implements
        // private final static String WARNING_INDICATION_COLOR =
        // PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR;
        /** Preference key for task indication */
-       private final static String TASK_INDICATION = PreferenceConstants.EDITOR_TASK_INDICATION;
+       //private final static String TASK_INDICATION = PreferenceConstants.EDITOR_TASK_INDICATION;
 
        /** Preference key for task color */
-       private final static String TASK_INDICATION_COLOR = PreferenceConstants.EDITOR_TASK_INDICATION_COLOR;
+       //private final static String TASK_INDICATION_COLOR = PreferenceConstants.EDITOR_TASK_INDICATION_COLOR;
 
        /** Preference key for bookmark indication */
-       private final static String BOOKMARK_INDICATION = PreferenceConstants.EDITOR_BOOKMARK_INDICATION;
+       //private final static String BOOKMARK_INDICATION = PreferenceConstants.EDITOR_BOOKMARK_INDICATION;
 
        /** Preference key for bookmark color */
-       private final static String BOOKMARK_INDICATION_COLOR = PreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR;
+       //private final static String BOOKMARK_INDICATION_COLOR = PreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR;
 
        /** Preference key for search result indication */
-       private final static String SEARCH_RESULT_INDICATION = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION;
+       //private final static String SEARCH_RESULT_INDICATION = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION;
 
        /** Preference key for search result color */
-       private final static String SEARCH_RESULT_INDICATION_COLOR = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR;
+       //private final static String SEARCH_RESULT_INDICATION_COLOR = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR;
 
        /** Preference key for unknown annotation indication */
-       private final static String UNKNOWN_INDICATION = PreferenceConstants.EDITOR_UNKNOWN_INDICATION;
+       //private final static String UNKNOWN_INDICATION = PreferenceConstants.EDITOR_UNKNOWN_INDICATION;
 
        /** Preference key for unknown annotation color */
-       private final static String UNKNOWN_INDICATION_COLOR = PreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR;
+       //private final static String UNKNOWN_INDICATION_COLOR = PreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR;
 
        /** Preference key for linked position color */
-       private final static String LINKED_POSITION_COLOR = PreferenceConstants.EDITOR_LINKED_POSITION_COLOR;
+       //private final static String LINKED_POSITION_COLOR = PreferenceConstants.EDITOR_LINKED_POSITION_COLOR;
 
        /** Preference key for shwoing the overview ruler */
-       private final static String OVERVIEW_RULER = PreferenceConstants.EDITOR_OVERVIEW_RULER;
+       //private final static String OVERVIEW_RULER = PreferenceConstants.EDITOR_OVERVIEW_RULER;
 
        /** Preference key for error indication in overview ruler */
-       private final static String ERROR_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER;
+       //private final static String ERROR_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER;
 
        /** Preference key for warning indication in overview ruler */
-       private final static String WARNING_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER;
+       //private final static String WARNING_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER;
 
        /** Preference key for task indication in overview ruler */
-       private final static String TASK_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER;
+       //private final static String TASK_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER;
 
        /** Preference key for bookmark indication in overview ruler */
-       private final static String BOOKMARK_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER;
+       //private final static String BOOKMARK_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER;
 
        /** Preference key for search result indication in overview ruler */
-       private final static String SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER;
+       //private final static String SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER;
 
        /** Preference key for unknown annotation indication in overview ruler */
-       private final static String UNKNOWN_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER;
+       //private final static String UNKNOWN_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER;
 
        /** Preference key for automatically closing double quoted strings */
        private final static String CLOSE_STRINGS_DQ_PHP = PreferenceConstants.EDITOR_CLOSE_STRINGS_DQ_PHP;
@@ -1404,22 +1406,22 @@ public class PHPUnitEditor extends PHPEditor { // implements
        private final static String CLOSE_BRACKETS_PHP = PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP;
 
        /** Preference key for automatically closing phpdocs and comments */
-       private final static String CLOSE_JAVADOCS = PreferenceConstants.EDITOR_CLOSE_JAVADOCS;
+       //private final static String CLOSE_JAVADOCS = PreferenceConstants.EDITOR_CLOSE_JAVADOCS;
 
        /** Preference key for automatically adding phpdoc tags */
-       private final static String ADD_JAVADOC_TAGS = PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS;
+       //private final static String ADD_JAVADOC_TAGS = PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS;
 
        /** Preference key for automatically formatting phpdocs */
        // private final static String FORMAT_JAVADOCS =
        // PreferenceConstants.EDITOR_FORMAT_JAVADOCS;
        /** Preference key for automatically closing strings */
-       private final static String CLOSE_STRINGS_HTML = PreferenceConstants.EDITOR_CLOSE_STRINGS_HTML;
+       //private final static String CLOSE_STRINGS_HTML = PreferenceConstants.EDITOR_CLOSE_STRINGS_HTML;
 
        /** Preference key for automatically closing brackets and parenthesis */
-       private final static String CLOSE_BRACKETS_HTML = PreferenceConstants.EDITOR_CLOSE_BRACKETS_HTML;
+       //private final static String CLOSE_BRACKETS_HTML = PreferenceConstants.EDITOR_CLOSE_BRACKETS_HTML;
 
        /** Preference key for smart paste */
-       private final static String SMART_PASTE = PreferenceConstants.EDITOR_SMART_PASTE;
+       //private final static String SMART_PASTE = PreferenceConstants.EDITOR_SMART_PASTE;
 
        // private final static class AnnotationInfo {
        // public String fColorPreference;
@@ -1882,10 +1884,10 @@ public class PHPUnitEditor extends PHPEditor { // implements
                return store.getBoolean(SPACES_FOR_TABS);
        }
 
-       private Color getColor(String key) {
-               RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), key);
-               return getColor(rgb);
-       }
+//     private Color getColor(String key) {
+//             RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), key);
+//             return getColor(rgb);
+//     }
 
        private Color getColor(RGB rgb) {
                JavaTextTools textTools = WebUI.getDefault()
@@ -2119,19 +2121,19 @@ public class PHPUnitEditor extends PHPEditor { // implements
        // IVerticalRuler ruler, int styles) {
        // return new AdaptedSourceViewer(parent, ruler, styles);
        // }
-       private boolean isValidSelection(int offset, int length) {
-               IDocumentProvider provider = getDocumentProvider();
-               if (provider != null) {
-                       IDocument document = provider.getDocument(getEditorInput());
-                       if (document != null) {
-                               int end = offset + length;
-                               int documentLength = document.getLength();
-                               return 0 <= offset && offset <= documentLength && 0 <= end
-                                               && end <= documentLength;
-                       }
-               }
-               return false;
-       }
+//     private boolean isValidSelection(int offset, int length) {
+//             IDocumentProvider provider = getDocumentProvider();
+//             if (provider != null) {
+//                     IDocument document = provider.getDocument(getEditorInput());
+//                     if (document != null) {
+//                             int end = offset + length;
+//                             int documentLength = document.getLength();
+//                             return 0 <= offset && offset <= documentLength && 0 <= end
+//                                             && end <= documentLength;
+//                     }
+//             }
+//             return false;
+//     }
 
        /*
         * @see net.sourceforge.phpdt.internal.ui.javaeditor.JavaEditor#getInputElement()
@@ -2561,43 +2563,43 @@ public class PHPUnitEditor extends PHPEditor { // implements
        /**
         * Returns the updated java element for the old java element.
         */
-       private IJavaElement findElement(IJavaElement element) {
-               if (element == null)
-                       return null;
-               IWorkingCopyManager manager = WebUI.getDefault()
-                               .getWorkingCopyManager();
-               ICompilationUnit unit = manager.getWorkingCopy(getEditorInput());
-               if (unit != null) {
-                       try {
-                               synchronized (unit) {
-                                       unit.reconcile();
-                               }
-                               IJavaElement[] findings = unit.findElements(element);
-                               if (findings != null && findings.length > 0)
-                                       return findings[0];
-                       } catch (JavaModelException x) {
-                               PHPeclipsePlugin.log(x.getStatus());
-                               // nothing found, be tolerant and go on
-                       }
-               }
-               return null;
-       }
+//     private IJavaElement findElement(IJavaElement element) {
+//             if (element == null)
+//                     return null;
+//             IWorkingCopyManager manager = WebUI.getDefault()
+//                             .getWorkingCopyManager();
+//             ICompilationUnit unit = manager.getWorkingCopy(getEditorInput());
+//             if (unit != null) {
+//                     try {
+//                             synchronized (unit) {
+//                                     unit.reconcile();
+//                             }
+//                             IJavaElement[] findings = unit.findElements(element);
+//                             if (findings != null && findings.length > 0)
+//                                     return findings[0];
+//                     } catch (JavaModelException x) {
+//                             PHPeclipsePlugin.log(x.getStatus());
+//                             // nothing found, be tolerant and go on
+//                     }
+//             }
+//             return null;
+//     }
 
        /**
         * Returns the offset of the given Java element.
         */
-       private int getOffset(IJavaElement element) {
-               if (element instanceof ISourceReference) {
-                       ISourceReference sr = (ISourceReference) element;
-                       try {
-                               ISourceRange srcRange = sr.getSourceRange();
-                               if (srcRange != null)
-                                       return srcRange.getOffset();
-                       } catch (JavaModelException e) {
-                       }
-               }
-               return -1;
-       }
+//     private int getOffset(IJavaElement element) {
+//             if (element instanceof ISourceReference) {
+//                     ISourceReference sr = (ISourceReference) element;
+//                     try {
+//                             ISourceRange srcRange = sr.getSourceRange();
+//                             if (srcRange != null)
+//                                     return srcRange.getOffset();
+//                     } catch (JavaModelException e) {
+//                     }
+//             }
+//             return -1;
+//     }
 
        /*
         * @see AbstractTextEditor#restoreSelection()