1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-02 22:05:44 +02:00

Fix for bug 84187: "Toggle Watchpoint" and "Toggle Method Breakpoint" don't work with C editor. ICWatchpoint should extend ILineBreakpoint to allow watchpoints to be shown in editors.

This commit is contained in:
Mikhail Khodjaiants 2005-02-03 19:59:03 +00:00
parent 83c9192837
commit cb63ddc65b
6 changed files with 74 additions and 49 deletions

View file

@ -1,3 +1,9 @@
2005-02-03 Mikhail Khodjaiants
Fix for bug 84187: "Toggle Watchpoint" and "Toggle Method Breakpoint" don't work with C editor.
ICWatchpoint should extend ILineBreakpoint to allow watchpoints to be shown in editors.
* ICWatchpoint.java
* CWatchpoint.java
2005-02-03 Mikhail Khodjaiants 2005-02-03 Mikhail Khodjaiants
Fix for bug 84187: "Toggle Watchpoint" and "Toggle Method Breakpoint" don't work with C editor. Fix for bug 84187: "Toggle Watchpoint" and "Toggle Method Breakpoint" don't work with C editor.
* CDIDebugModel.java * CDIDebugModel.java

View file

@ -11,11 +11,12 @@
package org.eclipse.cdt.debug.core.model; package org.eclipse.cdt.debug.core.model;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.model.ILineBreakpoint;
/** /**
* A watchpoint specific to the C/C++ debug model. * A watchpoint specific to the C/C++ debug model.
*/ */
public interface ICWatchpoint extends ICBreakpoint { public interface ICWatchpoint extends ICBreakpoint, ILineBreakpoint {
/** /**
* Watchpoint attribute storing the expression associated with this * Watchpoint attribute storing the expression associated with this

View file

@ -12,8 +12,8 @@ package org.eclipse.cdt.debug.internal.core.breakpoints;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.debug.core.model.ICWatchpoint; import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -37,28 +37,22 @@ public class CWatchpoint extends CBreakpoint implements ICWatchpoint {
super( resource, getMarkerType(), attributes, add ); super( resource, getMarkerType(), attributes, add );
} }
/* /* (non-Javadoc)
* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICWatchpoint#isWriteType()
*
* @see org.eclipse.cdt.debug.core.ICWatchpoint#isWriteType()
*/ */
public boolean isWriteType() throws CoreException { public boolean isWriteType() throws CoreException {
return ensureMarker().getAttribute( WRITE, true ); return ensureMarker().getAttribute( WRITE, true );
} }
/* /* (non-Javadoc)
* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICWatchpoint#isReadType()
*
* @see org.eclipse.cdt.debug.core.ICWatchpoint#isReadType()
*/ */
public boolean isReadType() throws CoreException { public boolean isReadType() throws CoreException {
return ensureMarker().getAttribute( READ, false ); return ensureMarker().getAttribute( READ, false );
} }
/* /* (non-Javadoc)
* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICWatchpoint#getExpression()
*
* @see org.eclipse.cdt.debug.core.ICWatchpoint#getExpression()
*/ */
public String getExpression() throws CoreException { public String getExpression() throws CoreException {
return ensureMarker().getAttribute( EXPRESSION, "" ); //$NON-NLS-1$ return ensureMarker().getAttribute( EXPRESSION, "" ); //$NON-NLS-1$
@ -71,9 +65,7 @@ public class CWatchpoint extends CBreakpoint implements ICWatchpoint {
return C_WATCHPOINT; return C_WATCHPOINT;
} }
/* /* (non-Javadoc)
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage() * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage()
*/ */
protected String getMarkerMessage() throws CoreException { protected String getMarkerMessage() throws CoreException {
@ -99,4 +91,25 @@ public class CWatchpoint extends CBreakpoint implements ICWatchpoint {
sb.append( getConditionText() ); sb.append( getConditionText() );
return sb.toString(); return sb.toString();
} }
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.ILineBreakpoint#getLineNumber()
*/
public int getLineNumber() throws CoreException {
return ensureMarker().getAttribute( IMarker.LINE_NUMBER, -1 );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.ILineBreakpoint#getCharStart()
*/
public int getCharStart() throws CoreException {
return ensureMarker().getAttribute( IMarker.CHAR_START, -1 );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.ILineBreakpoint#getCharEnd()
*/
public int getCharEnd() throws CoreException {
return ensureMarker().getAttribute( IMarker.CHAR_END, -1 );
}
} }

View file

@ -1,3 +1,9 @@
2005-02-03 Mikhail Khodjaiants
Fix for bug 84187: "Toggle Watchpoint" and "Toggle Method Breakpoint" don't work with C editor.
ICWatchpoint should extend ILineBreakpoint to allow watchpoints to be shown in editors.
* AbstractBreakpointRulerAction.java
* CBreakpointPropertyPage.java
2005-02-02 Mikhail Khodjaiants 2005-02-02 Mikhail Khodjaiants
The "INTERNAL_ERROR" constant has been moved from ICDebugUIConstants to IInternalCDebugUIConstants. The "INTERNAL_ERROR" constant has been moved from ICDebugUIConstants to IInternalCDebugUIConstants.
* IInternalCDebugUIConstants.java * IInternalCDebugUIConstants.java

View file

@ -11,13 +11,12 @@
package org.eclipse.cdt.debug.internal.ui.actions; package org.eclipse.cdt.debug.internal.ui.actions;
import java.util.Iterator; import java.util.Iterator;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView; import org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.model.ILineBreakpoint;
import org.eclipse.jface.action.Action; import org.eclipse.jface.action.Action;
import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
@ -47,10 +46,10 @@ public abstract class AbstractBreakpointRulerAction extends Action implements IU
IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints( CDebugCorePlugin.getUniqueIdentifier() ); IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints( CDebugCorePlugin.getUniqueIdentifier() );
for( int i = 0; i < breakpoints.length; i++ ) { for( int i = 0; i < breakpoints.length; i++ ) {
IBreakpoint breakpoint = breakpoints[i]; IBreakpoint breakpoint = breakpoints[i];
if ( breakpoint instanceof ICLineBreakpoint ) { if ( breakpoint instanceof ILineBreakpoint ) {
ICLineBreakpoint cBreakpoint = (ICLineBreakpoint)breakpoint; ILineBreakpoint lineBreakpoint = (ILineBreakpoint)breakpoint;
if ( breakpointAtRulerLine( cBreakpoint ) ) { if ( breakpointAtRulerLine( lineBreakpoint ) ) {
return cBreakpoint; return lineBreakpoint;
} }
} }
} }
@ -80,13 +79,13 @@ public abstract class AbstractBreakpointRulerAction extends Action implements IU
fBreakpoint = breakpoint; fBreakpoint = breakpoint;
} }
protected boolean breakpointAtRulerLine( ICLineBreakpoint cBreakpoint ) { protected boolean breakpointAtRulerLine( ILineBreakpoint cBreakpoint ) {
int lineNumber = getBreakpointLine( cBreakpoint ); int lineNumber = getBreakpointLine( cBreakpoint );
int rulerLine = getInfo().getLineOfLastMouseButtonActivity(); int rulerLine = getInfo().getLineOfLastMouseButtonActivity();
return ( rulerLine == lineNumber ); return ( rulerLine == lineNumber );
} }
private int getBreakpointLine( ICLineBreakpoint breakpoint ) { private int getBreakpointLine( ILineBreakpoint breakpoint ) {
if ( getTargetPart() instanceof ISaveablePart && ((ISaveablePart)getTargetPart()).isDirty() ) { if ( getTargetPart() instanceof ISaveablePart && ((ISaveablePart)getTargetPart()).isDirty() ) {
try { try {
return breakpoint.getLineNumber(); return breakpoint.getLineNumber();
@ -112,7 +111,7 @@ public abstract class AbstractBreakpointRulerAction extends Action implements IU
return -1; return -1;
} }
private Position getBreakpointPosition( ICLineBreakpoint breakpoint ) { private Position getBreakpointPosition( ILineBreakpoint breakpoint ) {
IAnnotationModel model = getAnnotationModel(); IAnnotationModel model = getAnnotationModel();
if ( model != null ) { if ( model != null ) {
Iterator it = model.getAnnotationIterator(); Iterator it = model.getAnnotationIterator();

View file

@ -301,6 +301,29 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
addField( createLabelEditor( getFieldEditorParent(), PropertyPageMessages.getString( "CBreakpointPropertyPage.5" ), address ) ); //$NON-NLS-1$ addField( createLabelEditor( getFieldEditorParent(), PropertyPageMessages.getString( "CBreakpointPropertyPage.5" ), address ) ); //$NON-NLS-1$
} }
} }
else if ( breakpoint instanceof ICWatchpoint ) {
ICWatchpoint watchpoint = (ICWatchpoint)breakpoint;
String type = ""; //$NON-NLS-1$
String expression = ""; //$NON-NLS-1$
try {
if ( watchpoint.isReadType() && !watchpoint.isWriteType() )
type = PropertyPageMessages.getString( "CBreakpointPropertyPage.11" ); //$NON-NLS-1$
else if ( !watchpoint.isReadType() && watchpoint.isWriteType() )
type = PropertyPageMessages.getString( "CBreakpointPropertyPage.12" ); //$NON-NLS-1$
else
type = PropertyPageMessages.getString( "CBreakpointPropertyPage.13" ); //$NON-NLS-1$
expression = watchpoint.getExpression();
}
catch( CoreException ce ) {
CDebugUIPlugin.log( ce );
}
addField( createLabelEditor( getFieldEditorParent(), PropertyPageMessages.getString( "CBreakpointPropertyPage.18" ), type ) ); //$NON-NLS-1$
String projectName = breakpoint.getMarker().getResource().getLocation().toOSString();
if ( projectName != null ) {
addField( createLabelEditor( getFieldEditorParent(), PropertyPageMessages.getString( "CBreakpointPropertyPage.10" ), projectName ) ); //$NON-NLS-1$
}
addField( createLabelEditor( getFieldEditorParent(), PropertyPageMessages.getString( "CBreakpointPropertyPage.14" ), expression ) ); //$NON-NLS-1$
}
else if ( breakpoint instanceof ILineBreakpoint ) { else if ( breakpoint instanceof ILineBreakpoint ) {
addField( createLabelEditor( getFieldEditorParent(), PropertyPageMessages.getString( "CBreakpointPropertyPage.18" ), PropertyPageMessages.getString( "CBreakpointPropertyPage.8" ) ) ); //$NON-NLS-1$//$NON-NLS-2$ addField( createLabelEditor( getFieldEditorParent(), PropertyPageMessages.getString( "CBreakpointPropertyPage.18" ), PropertyPageMessages.getString( "CBreakpointPropertyPage.8" ) ) ); //$NON-NLS-1$//$NON-NLS-2$
String fileName = null; String fileName = null;
@ -327,29 +350,6 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
addField( createLabelEditor( getFieldEditorParent(), PropertyPageMessages.getString( "CBreakpointPropertyPage.9" ), lineNumber.toString() ) ); //$NON-NLS-1$ addField( createLabelEditor( getFieldEditorParent(), PropertyPageMessages.getString( "CBreakpointPropertyPage.9" ), lineNumber.toString() ) ); //$NON-NLS-1$
} }
} }
else if ( breakpoint instanceof ICWatchpoint ) {
ICWatchpoint watchpoint = (ICWatchpoint)breakpoint;
String type = ""; //$NON-NLS-1$
String expression = ""; //$NON-NLS-1$
try {
if ( watchpoint.isReadType() && !watchpoint.isWriteType() )
type = PropertyPageMessages.getString( "CBreakpointPropertyPage.11" ); //$NON-NLS-1$
else if ( !watchpoint.isReadType() && watchpoint.isWriteType() )
type = PropertyPageMessages.getString( "CBreakpointPropertyPage.12" ); //$NON-NLS-1$
else
type = PropertyPageMessages.getString( "CBreakpointPropertyPage.13" ); //$NON-NLS-1$
expression = watchpoint.getExpression();
}
catch( CoreException ce ) {
CDebugUIPlugin.log( ce );
}
addField( createLabelEditor( getFieldEditorParent(), PropertyPageMessages.getString( "CBreakpointPropertyPage.18" ), type ) ); //$NON-NLS-1$
String projectName = breakpoint.getMarker().getResource().getLocation().toOSString();
if ( projectName != null ) {
addField( createLabelEditor( getFieldEditorParent(), PropertyPageMessages.getString( "CBreakpointPropertyPage.10" ), projectName ) ); //$NON-NLS-1$
}
addField( createLabelEditor( getFieldEditorParent(), PropertyPageMessages.getString( "CBreakpointPropertyPage.14" ), expression ) ); //$NON-NLS-1$
}
} }
protected void createEnabledField( Composite parent ) { protected void createEnabledField( Composite parent ) {