X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/actions/ToggleBreakpointAdapter.java b/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/actions/ToggleBreakpointAdapter.java index 45c59bc..dfdc1ea 100644 --- a/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/actions/ToggleBreakpointAdapter.java +++ b/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/actions/ToggleBreakpointAdapter.java @@ -1,65 +1,38 @@ /******************************************************************************* * 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 *******************************************************************************/ package net.sourceforge.phpdt.internal.debug.ui.actions; 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.Flags; import net.sourceforge.phpdt.core.ICompilationUnit; -import net.sourceforge.phpdt.core.IField; import net.sourceforge.phpdt.core.IJavaElement; -import net.sourceforge.phpdt.core.IJavaProject; -import net.sourceforge.phpdt.core.IMember; import net.sourceforge.phpdt.core.IMethod; -import net.sourceforge.phpdt.core.ISourceRange; import net.sourceforge.phpdt.core.IType; -import net.sourceforge.phpdt.core.JavaCore; import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.Signature; -import net.sourceforge.phpdt.core.dom.CompilationUnit; -import net.sourceforge.phpdt.core.search.IJavaSearchConstants; -import net.sourceforge.phpdt.core.search.ITypeNameRequestor; 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 net.sourceforge.phpdt.ui.IWorkingCopyManager; -import net.sourceforge.phpdt.ui.JavaUI; - -import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.IBreakpointManager; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.model.IBreakpoint; -import org.eclipse.debug.internal.ui.actions.ActionMessages; import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; -import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; @@ -69,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) { @@ -82,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; @@ -106,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) */ @@ -142,7 +115,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget { // } // } // } - + // String typeName= null; IResource resource; PHPLineBreakpoint breakpoint= null; @@ -154,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); @@ -170,7 +143,8 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget { // } // new BreakpointLocationVerifierJob(document, breakpoint, lineNumber, typeName, type, resource, (IEditorStatusLine) editorPart.getAdapter(IEditorStatusLine.class)).schedule(); } catch (CoreException ce) { - ExceptionHandler.handle(ce, ActionMessages.getString("ManageBreakpointActionDelegate.error.title1"), ActionMessages.getString("ManageBreakpointActionDelegate.error.message1")); //$NON-NLS-1$ //$NON-NLS-2$ + // TODO: no message in ActionMessages + //ExceptionHandler.handle(ce, ActionMessages.getString("ManageBreakpointActionDelegate.error.title1"), ActionMessages.getString("ManageBreakpointActionDelegate.error.message1")); //$NON-NLS-1$ //$NON-NLS-2$ return; } } @@ -274,14 +248,15 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget { * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleMethodBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) */ public boolean canToggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) { - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; - return getMethods(ss).length > 0; - } else { - return selection instanceof ITextSelection; - } +// if (selection instanceof IStructuredSelection) { +// IStructuredSelection ss = (IStructuredSelection) selection; +// return getMethods(ss).length > 0; +// } else { +// return selection instanceof ITextSelection; +// } + return false; } - + protected IMethod[] getMethods(IStructuredSelection selection) { if (selection.isEmpty()) { return new IMethod[0]; @@ -291,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) { @@ -300,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]; @@ -309,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); @@ -320,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) @@ -386,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); @@ -424,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(); @@ -436,10 +411,10 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget { } return resource; } - + /** * Returns a handle to the specified method or null if none. - * + * * @param editorPart the editor containing the method * @param typeName * @param methodName @@ -467,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()); @@ -516,7 +491,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget { // JDIDebugUIPlugin.log(e); // } // } -// } +// } // } // return null; // } @@ -529,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); @@ -537,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) */ @@ -550,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, @@ -594,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) { @@ -603,7 +578,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget { // if (launch == null) { // return types; // } -// +// // ILaunchConfiguration configuration= launch.getLaunchConfiguration(); // IJavaProject[] javaProjects = null; // IWorkspace workspace= ResourcesPlugin.getWorkspace(); @@ -646,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) { @@ -671,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) { @@ -684,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) { @@ -699,7 +674,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget { // } // return typeName.toCharArray(); // } -// +// // /** // * Return the associated IField (Java model) for the given // * IJavaFieldVariable (JDI model) @@ -723,5 +698,5 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget { // } // } // return null; -// } +// } }