replaced a lot of deprecated code; if someone runs into a commit conflict afterwards...
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.ui / src / net / sourceforge / phpdt / internal / debug / ui / actions / ToggleBreakpointAdapter.java
index f898f61..dfdc1ea 100644 (file)
@@ -1,10 +1,10 @@
 /*******************************************************************************
  * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials 
+ * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Common Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/cpl-v10.html
- * 
+ *
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *******************************************************************************/
@@ -24,13 +24,10 @@ import net.sourceforge.phpdt.core.Signature;
 import net.sourceforge.phpdt.debug.core.PHPDebugModel;
 import net.sourceforge.phpdt.internal.debug.core.breakpoints.PHPLineBreakpoint;
 import net.sourceforge.phpdt.internal.debug.ui.PHPDebugUiPlugin;
-import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
-
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.internal.ui.actions.ActionMessages;
 import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.ITextSelection;
@@ -45,11 +42,11 @@ import org.eclipse.ui.texteditor.ITextEditor;
 
 /**
  * Toggles a line breakpoint in a Java editor.
- * 
+ *
  * @since 3.0
  */
 public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
-               
+
        protected void report(String message, IWorkbenchPart part) {
                IEditorStatusLine statusLine= (IEditorStatusLine) part.getAdapter(IEditorStatusLine.class);
                if (statusLine != null) {
@@ -58,12 +55,12 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
                        } else {
                                statusLine.setMessage(true, null, null);
                        }
-               }               
+               }
                if (message != null && PHPDebugUiPlugin.getActiveWorkbenchShell() != null) {
                        PHPDebugUiPlugin.getActiveWorkbenchShell().getDisplay().beep();
                }
        }
-       
+
 //     protected IType getType(ITextSelection selection) {
 //             IMember member= ActionDelegateHelper.getDefault().getCurrentMember(selection);
 //             IType type= null;
@@ -82,8 +79,8 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
 //                     PHPDebugUiPlugin.log(e);
 //             }
 //             return type;
-//     }       
-       
+//     }
+
        /* (non-Javadoc)
         * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleLineBreakpoints(IWorkbenchPart, ISelection)
         */
@@ -118,7 +115,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
 //                                             }
 //                                     }
 //                             }
-                       
+
 //                             String typeName= null;
                                IResource resource;
                                PHPLineBreakpoint breakpoint= null;
@@ -130,12 +127,12 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
                                        }
 //                             } else {
 //                                     typeName= type.getFullyQualifiedName();
-//                                     PHPLineBreakpoint breakpoint=PHPDebugModel.lineBreakpointExists(lineNumber);    
-//                                     if (breakpoint==null)   
+//                                     PHPLineBreakpoint breakpoint=PHPDebugModel.lineBreakpointExists(lineNumber);
+//                                     if (breakpoint==null)
 //                                             PHPDebugModel.createLineBreakpoint(getFile(), lineNumber, 0, true, null);
 //                                     else
-//                                             DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true );   
-//                                     
+//                                             DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true );
+//
                                        PHPLineBreakpoint existingBreakpoint= PHPDebugModel.lineBreakpointExists(lineNumber); //typeName, lineNumber);
                                        if (existingBreakpoint != null) {
                                                DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(existingBreakpoint, true);
@@ -259,7 +256,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
 //             }
                return false;
        }
-       
+
        protected IMethod[] getMethods(IStructuredSelection selection) {
                if (selection.isEmpty()) {
                        return new IMethod[0];
@@ -269,7 +266,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
                        while (iterator.hasNext()) {
                                Object thing = iterator.next();
                                try {
-                                       if (thing instanceof IMethod && !Flags.isAbstract(((IMethod)thing).getFlags())) {       
+                                       if (thing instanceof IMethod && !Flags.isAbstract(((IMethod)thing).getFlags())) {
                                                methods.add(thing);
                                        }
                                } catch (JavaModelException e) {
@@ -278,7 +275,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
                        return (IMethod[]) methods.toArray(new IMethod[methods.size()]);
                }
        }
-       
+
 //     protected IField[] getFields(IStructuredSelection selection) {
 //             if (selection.isEmpty()) {
 //                     return new IField[0];
@@ -287,7 +284,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
 //                     Iterator iterator = selection.iterator();
 //                     while (iterator.hasNext()) {
 //                             Object thing = iterator.next();
-//                             if (thing instanceof IField) {  
+//                             if (thing instanceof IField) {
 //                                     fields.add(thing);
 //                             } else if (thing instanceof IJavaFieldVariable) {
 //                                     IField field= getField((IJavaFieldVariable) thing);
@@ -298,7 +295,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
 //                     }
 //                     return (IField[]) fields.toArray(new IField[fields.size()]);
 //             }
-//     }       
+//     }
 
        /* (non-Javadoc)
         * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
@@ -364,27 +361,27 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
 //                     }
 //             }
        }
-       
+
        public static String resolveMethodSignature(IType type, String methodSignature) throws JavaModelException {
                String[] parameterTypes= Signature.getParameterTypes(methodSignature);
                int length= length= parameterTypes.length;
                String[] resolvedParameterTypes= new String[length];
-               
+
                for (int i = 0; i < length; i++) {
                        resolvedParameterTypes[i]= resolveType(type, parameterTypes[i]);
                        if (resolvedParameterTypes[i] == null) {
                                return null;
                        }
                }
-               
+
                String resolvedReturnType= resolveType(type, Signature.getReturnType(methodSignature));
                if (resolvedReturnType == null) {
                        return null;
                }
-                               
+
                return Signature.createMethodSignature(resolvedParameterTypes, resolvedReturnType);
        }
-       
+
        private static String resolveType(IType type, String typeSignature) throws JavaModelException {
 //             int count= Signature.getArrayCount(typeSignature);
 //             String elementTypeSignature= Signature.getElementType(typeSignature);
@@ -402,8 +399,8 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
 //             String resolvedElementTypeSignature= Signature.createTypeSignature(resolvedElementTypeName, true).replace('.', '/');
 //             return Signature.createArraySignature(resolvedElementTypeSignature, count);
                return "";
-       }       
-       
+       }
+
        protected static IResource getResource(IEditorPart editor) {
                IResource resource;
                IEditorInput editorInput = editor.getEditorInput();
@@ -414,10 +411,10 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
                }
                return resource;
        }
-       
+
        /**
         * Returns a handle to the specified method or <code>null</code> if none.
-        * 
+        *
         * @param editorPart the editor containing the method
         * @param typeName
         * @param methodName
@@ -445,7 +442,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
                }
                return null;
        }
-       
+
 //     protected IJavaBreakpoint getBreakpoint(IMember element) {
 //             IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
 //             IBreakpoint[] breakpoints= breakpointManager.getBreakpoints(JDIDebugModel.getPluginIdentifier());
@@ -494,7 +491,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
 //                                             JDIDebugUIPlugin.log(e);
 //                                     }
 //                             }
-//                     }                       
+//                     }
 //             }
 //             return null;
 //     }
@@ -507,7 +504,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
 //             return (breakpointField.getElementName().equals(watchpoint.getFieldName()) &&
 //             breakpointField.getDeclaringType().getFullyQualifiedName().equals(watchpoint.getTypeName()));
 //     }
-//     
+//
 //     protected CompilationUnit parseCompilationUnit(ITextEditor editor) {
 //             IEditorInput editorInput = editor.getEditorInput();
 //             IDocument document= editor.getDocumentProvider().getDocument(editorInput);
@@ -515,7 +512,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
 //             parser.setSource(document.get().toCharArray());
 //             return (CompilationUnit) parser.createAST(null);
 //     }
-       
+
        /* (non-Javadoc)
         * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
         */
@@ -528,11 +525,11 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
 //             }
                return false;
        }
-       
+
        /**
         * Returns a selection of the member in the given text selection,
         * or the original selection if none.
-        *    
+        *
         * @param part
         * @param selection
         * @return a structured selection of the member in the given text selection,
@@ -572,7 +569,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
 //     }
 
        /**
-        * Returns a list of matching types (IType - Java model) that correspond to the 
+        * Returns a list of matching types (IType - Java model) that correspond to the
         * declaring type (ReferenceType - JDI model) of the given variable.
         */
 //     protected static List searchForDeclaringType(IJavaFieldVariable variable) {
@@ -581,7 +578,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
 //             if (launch == null) {
 //                     return types;
 //             }
-//             
+//
 //             ILaunchConfiguration configuration= launch.getLaunchConfiguration();
 //             IJavaProject[] javaProjects = null;
 //             IWorkspace workspace= ResourcesPlugin.getWorkspace();
@@ -624,13 +621,13 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
 //             ArrayList typeRefsFound= new ArrayList(3);
 //             ITypeNameRequestor requestor= new TypeInfoRequestor(typeRefsFound);
 //             try {
-//                     engine.searchAllTypeNames( 
-//                             getPackage(declaringType), 
-//                             getTypeName(declaringType), 
-//                             SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE, 
-//                             IJavaSearchConstants.CLASS, 
-//                             scope, 
-//                             requestor, 
+//                     engine.searchAllTypeNames(
+//                             getPackage(declaringType),
+//                             getTypeName(declaringType),
+//                             SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE,
+//                             IJavaSearchConstants.CLASS,
+//                             scope,
+//                             requestor,
 //                             IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
 //                             null);
 //             } catch (JavaModelException x) {
@@ -649,10 +646,10 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
 //             }
 //             return types;
 //     }
-       
+
        /**
         * Returns the package name of the given fully qualified type name.
-        * The package name is assumed to be the dot-separated prefix of the 
+        * The package name is assumed to be the dot-separated prefix of the
         * type name.
         */
 //     protected static char[] getPackage(String fullyQualifiedName) {
@@ -662,10 +659,10 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
 //             }
 //             return fullyQualifiedName.substring(0, index).toCharArray();
 //     }
-//     
+//
 //     /**
 //      * Returns a simple type name from the given fully qualified type name.
-//      * The type name is assumed to be the last contiguous segment of the 
+//      * The type name is assumed to be the last contiguous segment of the
 //      * fullyQualifiedName not containing a '.' or '$'
 //      */
 //     protected static char[] getTypeName(String fullyQualifiedName) {
@@ -677,7 +674,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
 //             }
 //             return typeName.toCharArray();
 //     }
-//     
+//
 //     /**
 //      * Return the associated IField (Java model) for the given
 //      * IJavaFieldVariable (JDI model)
@@ -701,5 +698,5 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
 //                     }
 //             }
 //             return null;
-//     }       
+//     }
 }