diff options
author | Mikhail Khodjaiants | 2004-11-26 19:35:20 +0000 |
---|---|---|
committer | Mikhail Khodjaiants | 2004-11-26 19:35:20 +0000 |
commit | 2fae41e058a014d38cbcfdf9c12803cb9541a0e3 (patch) | |
tree | ea797d77f14615e367f607c1fb5df29da17b8a2d /debug | |
parent | 68a0d1be46e1e264d1c21e2db9311b1c8c343c67 (diff) | |
download | org.eclipse.cdt-2fae41e058a014d38cbcfdf9c12803cb9541a0e3.tar.gz org.eclipse.cdt-2fae41e058a014d38cbcfdf9c12803cb9541a0e3.tar.xz org.eclipse.cdt-2fae41e058a014d38cbcfdf9c12803cb9541a0e3.zip |
Do not use "void" if parameter's list is empty when constructing a function or method name for function breakpoints. Name mapping should be done on the implementation level.
Fix for bug 79452: Unable to set a breakpoint on a class method.
Diffstat (limited to 'debug')
-rw-r--r-- | debug/org.eclipse.cdt.debug.ui/ChangeLog | 10 | ||||
-rw-r--r-- | debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java | 62 |
2 files changed, 48 insertions, 24 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index 77fb19dd50f..fba63132346 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,13 @@ +2004-11-26 Mikhail Khodjaiants
+ Do not use "void" if parameter's list is empty when constructing a function or
+ method name for function breakpoints. Name mapping should be done on the implementation level.
+ * ToggleBreakpointAdapter.java
+
+2004-11-25 Mikhail Khodjaiants
+ Fix for bug 79452: Unable to set a breakpoint on a class method.
+ * plugin.xml
+ * ToggleBreakpointAdapter.java
+
2004-11-25 Mikhail Khodjaiants
Replaced the "breakpointRemoved" method of ICBreakpointListener by the "breakpointsRemoved"
method that accepts multiple breakpoints.
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java index 43fefac5b97..bd5894ef543 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java @@ -12,8 +12,11 @@ package org.eclipse.cdt.debug.internal.ui.actions; import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.model.CModelException; +import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.IDeclaration; import org.eclipse.cdt.core.model.IFunction; +import org.eclipse.cdt.core.model.IFunctionDeclaration; +import org.eclipse.cdt.core.model.IMethod; import org.eclipse.cdt.core.model.ISourceRange; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.IVariable; @@ -161,11 +164,11 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget { public void toggleMethodBreakpoints( IWorkbenchPart part, ISelection selection ) throws CoreException { if ( selection instanceof IStructuredSelection ) { IStructuredSelection ss = (IStructuredSelection)selection; - if ( ss.size() == 1 && ss.getFirstElement() instanceof IFunction ) { - IFunction function = (IFunction)ss.getFirstElement(); - String sourceHandle = getSourceHandle( function ); - IResource resource = getElementResource( function ); - String functionName = getFunctionName( function ); + if ( ss.size() == 1 && (ss.getFirstElement() instanceof IFunction || ss.getFirstElement() instanceof IMethod) ) { + IDeclaration declaration = (IDeclaration)ss.getFirstElement(); + String sourceHandle = getSourceHandle( declaration ); + IResource resource = getElementResource( declaration ); + String functionName = ( declaration instanceof IFunction ) ? getFunctionName( (IFunction)declaration ) : getMethodName( (IMethod)declaration ); ICFunctionBreakpoint breakpoint = CDIDebugModel.functionBreakpointExists( sourceHandle, resource, functionName ); if ( breakpoint != null ) { DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true ); @@ -175,7 +178,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget { int charStart = -1; int charEnd = -1; try { - ISourceRange sourceRange = function.getSourceRange(); + ISourceRange sourceRange = declaration.getSourceRange(); if ( sourceRange != null ) { charStart = sourceRange.getStartPos(); charEnd = charStart + sourceRange.getLength(); @@ -201,8 +204,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget { true ); } } - } - + } } /* (non-Javadoc) @@ -212,7 +214,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget { if ( selection instanceof IStructuredSelection ) { IStructuredSelection ss = (IStructuredSelection)selection; if ( ss.size() == 1 ) { - return ( ss.getFirstElement() instanceof IFunction ); + return ( ss.getFirstElement() instanceof IFunction || ss.getFirstElement() instanceof IMethod ); } } return false; @@ -381,25 +383,37 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget { private String getFunctionName( IFunction function ) { String functionName = function.getElementName(); StringBuffer name = new StringBuffer( functionName ); - //?????? - if ( functionName.indexOf( "::" ) != -1 && functionName.indexOf( '(' ) == -1 ) { //$NON-NLS-1$ - String[] params = function.getParameterTypes(); - name.append( '(' ); - if ( params.length == 0 ) { - name.append( "void" ); //$NON-NLS-1$ - } - else { - for( int i = 0; i < params.length; ++i ) { - name.append( params[i] ); - if ( i != params.length - 1 ) - name.append( ',' ); - } - } - name.append( ')' ); + ITranslationUnit tu = function.getTranslationUnit(); + if ( tu != null && tu.isCXXLanguage() ) { + appendParameters( name, function ); + } + return name.toString(); + } + + private String getMethodName( IMethod method ) { + StringBuffer name = new StringBuffer(); + String methodName = method.getElementName(); + ICElement parent = method.getParent(); + while ( parent != null && ( parent.getElementType() == ICElement.C_NAMESPACE || parent.getElementType() == ICElement.C_CLASS ) ) { + name.append( parent.getElementName() ).append( "::" ); //$NON-NLS-1$ + parent = parent.getParent(); } + name.append( methodName ); + appendParameters( name, method ); return name.toString(); } + private void appendParameters( StringBuffer sb, IFunctionDeclaration fd ) { + String[] params = fd.getParameterTypes(); + sb.append( '(' ); + for( int i = 0; i < params.length; ++i ) { + sb.append( params[i] ); + if ( i != params.length - 1 ) + sb.append( ',' ); + } + sb.append( ')' ); + } + private String getVariableName( IVariable variable ) { return variable.getElementName(); } |