Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 16572 Details for
Bug 80654
[breakpoints] Breakpoint location verification
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Ant UI patch to provide the start of breakpoint location verification
antui.txt (text/plain), 7.29 KB, created by
Darin Swanson
on 2004-12-13 23:37:45 EST
(
hide
)
Description:
Ant UI patch to provide the start of breakpoint location verification
Filename:
MIME Type:
Creator:
Darin Swanson
Created:
2004-12-13 23:37:45 EST
Size:
7.29 KB
patch
obsolete
>Index: Ant Editor/org/eclipse/ant/internal/ui/editor/actions/AntEditorActionMessages.properties >=================================================================== >RCS file: /home/eclipse/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/actions/AntEditorActionMessages.properties,v >retrieving revision 1.5 >diff -u -r1.5 AntEditorActionMessages.properties >--- Ant Editor/org/eclipse/ant/internal/ui/editor/actions/AntEditorActionMessages.properties 9 Dec 2004 00:49:16 -0000 1.5 >+++ Ant Editor/org/eclipse/ant/internal/ui/editor/actions/AntEditorActionMessages.properties 14 Dec 2004 04:35:23 -0000 >@@ -18,6 +18,7 @@ > > TogglePresentation.label=Show Source of Selected Element Only > TogglePresentation.tooltip=Show Source of Selected Element Only >+ToggleLineBreakpointAction.0=Breakpoint cannot be set at the given position > > Projection.Toggle.label= &Enable Folding > Projection.Toggle.tooltip= Toggles Folding >Index: Ant Editor/org/eclipse/ant/internal/ui/editor/actions/ToggleLineBreakpointAction.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/actions/ToggleLineBreakpointAction.java,v >retrieving revision 1.1 >diff -u -r1.1 ToggleLineBreakpointAction.java >--- Ant Editor/org/eclipse/ant/internal/ui/editor/actions/ToggleLineBreakpointAction.java 15 Nov 2004 16:06:34 -0000 1.1 >+++ Ant Editor/org/eclipse/ant/internal/ui/editor/actions/ToggleLineBreakpointAction.java 14 Dec 2004 04:35:23 -0000 >@@ -12,12 +12,20 @@ > > import org.eclipse.ant.internal.ui.debug.IAntDebugConstants; > import org.eclipse.ant.internal.ui.debug.model.AntLineBreakpoint; >+import org.eclipse.ant.internal.ui.editor.AntEditor; >+import org.eclipse.ant.internal.ui.model.AntElementNode; >+import org.eclipse.ant.internal.ui.model.AntModel; >+import org.eclipse.ant.internal.ui.model.AntTaskNode; > import org.eclipse.core.resources.IResource; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.debug.core.DebugPlugin; > import org.eclipse.debug.core.model.IBreakpoint; > import org.eclipse.debug.core.model.ILineBreakpoint; > import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; >+import org.eclipse.jface.action.IStatusLineManager; >+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.swt.widgets.Display; >@@ -33,22 +41,30 @@ > */ > public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException { > ITextSelection textSelection = (ITextSelection) selection; >- int lineNumber = textSelection.getStartLine(); > IEditorPart editorPart = (IEditorPart)part; > IEditorInput editorInput = editorPart.getEditorInput(); >+ > IResource resource= null; > if (editorInput instanceof IFileEditorInput) { > resource= ((IFileEditorInput)editorInput).getFile(); > } > if (resource == null) { > Display.getCurrent().beep(); >+ return; >+ } >+ >+ int lineNumber= getLineNumber(editorPart, textSelection); >+ if (lineNumber == -1) { >+ IStatusLineManager statusLine = editorPart.getEditorSite().getActionBars().getStatusLineManager(); >+ statusLine.setErrorMessage(AntEditorActionMessages.getString("ToggleLineBreakpointAction.0")); //$NON-NLS-1$ >+ Display.getCurrent().beep(); >+ return; > } > IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL); > for (int i = 0; i < breakpoints.length; i++) { > IBreakpoint breakpoint = breakpoints[i]; > if (resource.equals(breakpoint.getMarker().getResource())) { > if (((ILineBreakpoint)breakpoint).getLineNumber() == (lineNumber + 1)) { >- // remove > breakpoint.delete(); > return; > } >@@ -59,6 +75,48 @@ > DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(lineBreakpoint); > } > >+ private int getLineNumber(IEditorPart editorPart, ITextSelection textSelection) { >+ int lineNumber= textSelection.getStartLine(); >+ if (editorPart instanceof AntEditor) { >+ AntEditor editor= (AntEditor) editorPart; >+ AntModel model= editor.getAntModel(); >+ IDocument doc= editor.getDocumentProvider().getDocument(editor.getEditorInput()); >+ lineNumber= getValidLineNumberFromModel(model, doc, lineNumber); >+ >+ } >+ return lineNumber; >+ } >+ >+ private int getValidLineNumberFromModel(AntModel model, IDocument doc, int lineNumber) { >+ try { >+ AntElementNode node= model.getNode(doc.getLineOffset(lineNumber), false); >+ if (node == null) { >+ return -1; >+ } >+ if (node instanceof AntTaskNode) { >+ //TODO return the last line of the task >+ return doc.getLineOfOffset(node.getOffset());// + node.getLength()); >+ } >+ IRegion lineInfo; >+ try { >+ lineInfo= doc.getLineInformation(lineNumber); >+ } catch (BadLocationException e) { >+ return lineNumber; >+ } >+ int startOffset= lineInfo.getOffset(); >+ int endOffset= startOffset + lineInfo.getLength(); >+ >+ node= node.getNode(startOffset, endOffset); >+ if (node instanceof AntTaskNode) { >+ //TODO return the last line of the task >+ return doc.getLineOfOffset(node.getOffset());// + node.getLength()); >+ } >+ return getValidLineNumberFromModel(model, doc, lineNumber + 1); >+ } catch (BadLocationException e) { >+ return lineNumber; >+ } >+ } >+ > /* (non-Javadoc) > * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) > */ >Index: Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementNode.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementNode.java,v >retrieving revision 1.6 >diff -u -r1.6 AntElementNode.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementNode.java 26 Oct 2004 01:44:17 -0000 1.6 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementNode.java 14 Dec 2004 04:35:24 -0000 >@@ -471,6 +471,34 @@ > return null; > } > >+ /** >+ * Returns the node with the narrowest source range that is fully contained between >+ * the start and end offset. >+ * It may be this node or one of its children or <code>null</code> if the range is not in the source range of this node. >+ * @param startOffset The start offset >+ * @param endOffset The end offset >+ * @return the node that includes the range in its source range or <code>null</code> >+ */ >+ public AntElementNode getNode(int startOffset, int endOffset) { >+ if (fChildNodes != null) { >+ for (Iterator iter = fChildNodes.iterator(); iter.hasNext(); ) { >+ AntElementNode node = (AntElementNode) iter.next(); >+ AntElementNode containingNode= node.getNode(startOffset, endOffset); >+ if (containingNode != null) { >+ return containingNode; >+ } >+ } >+ } >+ if (fLength == -1 && fOffset <= startOffset && !isExternal()) { //this is still an open element >+ return this; >+ } >+ if (startOffset <= fOffset && (fOffset + fLength - 2) <= endOffset) { >+ return this; >+ } >+ >+ return null; >+ } >+ > public Image getImage() { > int flags = 0; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 80654
: 16572