Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsgibly2007-06-11 12:26:31 +0000
committersgibly2007-06-11 12:26:31 +0000
commitcb83dc54342071edc384e4bf75da815512184b3f (patch)
treedb82c343cc63368dfaa47430544afa87149a8b5d
parent29811be5f659e6a6a003caf72b64e5bfac723740 (diff)
downloadorg.eclipse.pdt-cb83dc54342071edc384e4bf75da815512184b3f.tar.gz
org.eclipse.pdt-cb83dc54342071edc384e4bf75da815512184b3f.tar.xz
org.eclipse.pdt-cb83dc54342071edc384e4bf75da815512184b3f.zip
Fixed bug #191848 - Run>Run to Line - still enabled after a debug session run - clicking it yields errors.v20070611
Enable the Run To Line action only when the ISuspendResume target is in a suspend state. Change to line #118. All the rest is formatting.
-rw-r--r--plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/breakpoint/adapter/PHPRunToLineAdapter.java233
1 files changed, 113 insertions, 120 deletions
diff --git a/plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/breakpoint/adapter/PHPRunToLineAdapter.java b/plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/breakpoint/adapter/PHPRunToLineAdapter.java
index cfc136c40..16f4f2351 100644
--- a/plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/breakpoint/adapter/PHPRunToLineAdapter.java
+++ b/plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/breakpoint/adapter/PHPRunToLineAdapter.java
@@ -11,23 +11,14 @@
package org.eclipse.php.internal.debug.ui.breakpoint.adapter;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.*;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.ISuspendResume;
import org.eclipse.debug.ui.actions.IRunToLineTarget;
import org.eclipse.debug.ui.actions.RunToLineHandler;
-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.text.ITypedRegion;
+import org.eclipse.jface.text.*;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.php.internal.core.documentModel.partitioner.PHPPartitionTypes;
import org.eclipse.php.internal.core.documentModel.partitioner.PHPStructuredTextPartitioner;
import org.eclipse.php.internal.debug.core.IPHPConstants;
import org.eclipse.php.internal.debug.core.model.PHPDebugElement;
@@ -47,26 +38,26 @@ import org.eclipse.ui.texteditor.ITextEditor;
*/
public class PHPRunToLineAdapter implements IRunToLineTarget {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.ui.actions.IRunToLineTarget#runToLine(org.eclipse.ui.IWorkbenchPart,
- * org.eclipse.jface.viewers.ISelection,
- * org.eclipse.debug.core.model.ISuspendResume)
- */
- public void runToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) throws CoreException {
- IEditorPart editorPart = (IEditorPart) part;
- IEditorInput input = editorPart.getEditorInput();
- String errorMessage = null;
- if (input == null) {
- errorMessage = PHPDebugUIMessages.PHPRunToLineAdapter_0;
- } else {
- ITextEditor textEditor = (ITextEditor) editorPart;
- IDocument document = textEditor.getDocumentProvider().getDocument(input);
- if (document == null) {
- errorMessage = PHPDebugUIMessages.PHPRunToLineAdapter_1;
- } else {
- ITextSelection textSelection = (ITextSelection) selection;
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.actions.IRunToLineTarget#runToLine(org.eclipse.ui.IWorkbenchPart,
+ * org.eclipse.jface.viewers.ISelection,
+ * org.eclipse.debug.core.model.ISuspendResume)
+ */
+ public void runToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) throws CoreException {
+ IEditorPart editorPart = (IEditorPart) part;
+ IEditorInput input = editorPart.getEditorInput();
+ String errorMessage = null;
+ if (input == null) {
+ errorMessage = PHPDebugUIMessages.PHPRunToLineAdapter_0;
+ } else {
+ ITextEditor textEditor = (ITextEditor) editorPart;
+ IDocument document = textEditor.getDocumentProvider().getDocument(input);
+ if (document == null) {
+ errorMessage = PHPDebugUIMessages.PHPRunToLineAdapter_1;
+ } else {
+ ITextSelection textSelection = (ITextSelection) selection;
int lineNumber = 0;
try {
@@ -92,104 +83,106 @@ public class PHPRunToLineAdapter implements IRunToLineTarget {
}
}
if (lineNumber > 0) {
- if (getValidPosition(document, lineNumber) != -1) {
- if (target instanceof IAdaptable) {
- IDebugTarget debugTarget = (IDebugTarget) ((IAdaptable) target).getAdapter(IDebugTarget.class);
- if (debugTarget != null) {
- IFile file = getFile(textEditor);
- IBreakpoint breakpoint = new PHPRunToLineBreakpoint(file, lineNumber);
- RunToLineHandler handler = new RunToLineHandler(debugTarget, target, breakpoint);
- handler.run(new NullProgressMonitor());
- return;
- }
- }
- } else {
- errorMessage = PHPDebugUIMessages.PHPRunToLineAdapter_2;
- }
- } else {
- errorMessage = PHPDebugUIMessages.PHPRunToLineAdapter_2;
- }
- }
- }
- throw new CoreException(new Status(IStatus.ERROR, PHPDebugUIPlugin.getID(), IPHPConstants.INTERNAL_ERROR, errorMessage, null));
- }
+ if (getValidPosition(document, lineNumber) != -1) {
+ if (target instanceof IAdaptable) {
+ IDebugTarget debugTarget = (IDebugTarget) ((IAdaptable) target).getAdapter(IDebugTarget.class);
+ if (debugTarget != null) {
+ IFile file = getFile(textEditor);
+ IBreakpoint breakpoint = new PHPRunToLineBreakpoint(file, lineNumber);
+ RunToLineHandler handler = new RunToLineHandler(debugTarget, target, breakpoint);
+ handler.run(new NullProgressMonitor());
+ return;
+ }
+ }
+ } else {
+ errorMessage = PHPDebugUIMessages.PHPRunToLineAdapter_2;
+ }
+ } else {
+ errorMessage = PHPDebugUIMessages.PHPRunToLineAdapter_2;
+ }
+ }
+ }
+ throw new CoreException(new Status(IStatus.ERROR, PHPDebugUIPlugin.getID(), IPHPConstants.INTERNAL_ERROR, errorMessage, null));
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.ui.actions.IRunToLineTarget#canRunToLine(org.eclipse.ui.IWorkbenchPart,
- * org.eclipse.jface.viewers.ISelection,
- * org.eclipse.debug.core.model.ISuspendResume)
- */
- public boolean canRunToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) {
- if (target instanceof PHPDebugElement)
- return true;
- return false;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.debug.ui.actions.IRunToLineTarget#canRunToLine(org.eclipse.ui.IWorkbenchPart,
+ * org.eclipse.jface.viewers.ISelection,
+ * org.eclipse.debug.core.model.ISuspendResume)
+ */
+ public boolean canRunToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) {
+ if (target instanceof PHPDebugElement) {
+ // allow running to the line only when the target is suspended.
+ return target.isSuspended();
+ }
+ return false;
+ }
- /**
- * The file input for the TextEditor
- *
- * @return the IFile that this strategy is operating on
- */
- protected IFile getFile(ITextEditor textEditor) {
- if (textEditor == null)
- return null;
- IEditorInput input = textEditor.getEditorInput();
- if (!(input instanceof IFileEditorInput))
- return null;
- return ((IFileEditorInput) input).getFile();
- }
+ /**
+ * The file input for the TextEditor
+ *
+ * @return the IFile that this strategy is operating on
+ */
+ protected IFile getFile(ITextEditor textEditor) {
+ if (textEditor == null)
+ return null;
+ IEditorInput input = textEditor.getEditorInput();
+ if (!(input instanceof IFileEditorInput))
+ return null;
+ return ((IFileEditorInput) input).getFile();
+ }
- /**
- * Finds a valid position somewhere on lineNumber in document, idoc, where a
- * breakpoint can be set and returns that position. -1 is returned if a
- * position could not be found.
- *
- * @param idoc
- * @param editorLineNumber
- * @return position to set breakpoint or -1 if no position could be found
- */
- private int getValidPosition(IDocument idoc, int editorLineNumber) {
- int result = -1;
- if (idoc != null) {
+ /**
+ * Finds a valid position somewhere on lineNumber in document, idoc, where a
+ * breakpoint can be set and returns that position. -1 is returned if a
+ * position could not be found.
+ *
+ * @param idoc
+ * @param editorLineNumber
+ * @return position to set breakpoint or -1 if no position could be found
+ */
+ private int getValidPosition(IDocument idoc, int editorLineNumber) {
+ int result = -1;
+ if (idoc != null) {
- int startOffset = 0;
- int endOffset = 0;
- try {
- IRegion line = idoc.getLineInformation(editorLineNumber - 1);
- startOffset = line.getOffset();
- endOffset = Math.max(line.getOffset(), line.getOffset() + line.getLength());
+ int startOffset = 0;
+ int endOffset = 0;
+ try {
+ IRegion line = idoc.getLineInformation(editorLineNumber - 1);
+ startOffset = line.getOffset();
+ endOffset = Math.max(line.getOffset(), line.getOffset() + line.getLength());
- String lineText = idoc.get(startOffset, endOffset - startOffset).trim();
+ String lineText = idoc.get(startOffset, endOffset - startOffset).trim();
- // blank lines or lines with only an open PHP
- // tags cannot have a breakpoint
+ // blank lines or lines with only an open PHP
+ // tags cannot have a breakpoint
- if (lineText.equals("") || lineText.equals("<%") || //$NON-NLS-1$ //$NON-NLS-2$
- lineText.equals("%>") || lineText.equals("<?php") || lineText.equals("?>") || (lineText.trim()).startsWith("//")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- result = -1;
- } else {
+ if (lineText.equals("") || lineText.equals("<%") || //$NON-NLS-1$ //$NON-NLS-2$
+ lineText.equals("%>") || lineText.equals("<?php") || lineText.equals("?>") || (lineText.trim()).startsWith("//")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ result = -1;
+ } else {
- // get all partitions for current line
- ITypedRegion[] partitions = null;
+ // get all partitions for current line
+ ITypedRegion[] partitions = null;
- partitions = idoc.computePartitioning(startOffset, endOffset - startOffset);
+ partitions = idoc.computePartitioning(startOffset, endOffset - startOffset);
- for (int i = 0; i < partitions.length; ++i) {
- String type = partitions[i].getType();
- // if found PHP
- // return that position
- if (PHPStructuredTextPartitioner.isPHPPartitionType(type)) {
- result = partitions[i].getOffset();
- }
- }
- }
- } catch (BadLocationException e) {
- result = -1;
- }
- }
+ for (int i = 0; i < partitions.length; ++i) {
+ String type = partitions[i].getType();
+ // if found PHP
+ // return that position
+ if (PHPStructuredTextPartitioner.isPHPPartitionType(type)) {
+ result = partitions[i].getOffset();
+ }
+ }
+ }
+ } catch (BadLocationException e) {
+ result = -1;
+ }
+ }
- return result;
- }
+ return result;
+ }
}

Back to the top