use of org.eclipse.debug.core.model.IBreakpoint in project webtools.sourceediting by eclipse.
the class BreakpointRulerAction method getBreakpoints.
protected IBreakpoint[] getBreakpoints(IMarker[] markers) {
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
List breakpoints = new ArrayList(markers.length);
for (int i = 0; i < markers.length; i++) {
IBreakpoint breakpoint = manager.getBreakpoint(markers[i]);
if (breakpoint != null) {
breakpoints.add(breakpoint);
}
}
return (IBreakpoint[]) breakpoints.toArray(new IBreakpoint[0]);
}
use of org.eclipse.debug.core.model.IBreakpoint in project webtools.sourceediting by eclipse.
the class ToggleBreakpointAction method removeBreakpoints.
protected void removeBreakpoints(int lineNumber) {
IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] breakpoints = getBreakpoints(getMarkers());
for (int i = 0; i < breakpoints.length; i++) {
try {
breakpointManager.removeBreakpoint(breakpoints[i], true);
} catch (CoreException e) {
Logger.logException(e);
}
}
}
use of org.eclipse.debug.core.model.IBreakpoint in project webtools.sourceediting by eclipse.
the class JavaStratumBreakpointProvider method addBreakpoint.
public IStatus addBreakpoint(IDocument document, IEditorInput input, int editorLineNumber, int offset) throws CoreException {
// check if there is a valid position to set breakpoint
int pos = getValidPosition(document, editorLineNumber);
IStatus status = null;
if (pos >= 0) {
IResource res = getResourceFromInput(input);
if (res != null) {
String path = null;
// $NON-NLS-1$
IBreakpoint point = JDIDebugModel.createStratumBreakpoint(res, "JSP", res.getName(), path, getClassPattern(res), editorLineNumber, pos, pos, 0, true, null);
if (point == null) {
// $NON-NLS-1$
status = new Status(IStatus.ERROR, JSPUIPlugin.ID, IStatus.ERROR, "unsupported input type", null);
}
} else if (input instanceof IStorageEditorInput) {
// For non-resources, use the workspace root and a coordinated
// attribute that is used to
// prevent unwanted (breakpoint) markers from being loaded
// into the editors.
res = ResourcesPlugin.getWorkspace().getRoot();
String id = input.getName();
if (input instanceof IStorageEditorInput && ((IStorageEditorInput) input).getStorage() != null && ((IStorageEditorInput) input).getStorage().getFullPath() != null) {
id = ((IStorageEditorInput) input).getStorage().getFullPath().toString();
}
Map attributes = new HashMap();
attributes.put(StructuredResourceMarkerAnnotationModel.SECONDARY_ID_KEY, id);
String path = null;
// $NON-NLS-1$
IBreakpoint point = JDIDebugModel.createStratumBreakpoint(res, "JSP", input.getName(), path, getClassPattern(res), editorLineNumber, pos, pos, 0, true, attributes);
if (point == null) {
// $NON-NLS-1$
status = new Status(IStatus.ERROR, JSPUIPlugin.ID, IStatus.ERROR, "unsupported input type", null);
}
}
} else {
status = new Status(IStatus.INFO, JSPUIPlugin.ID, IStatus.INFO, JSPUIMessages.BreakpointNotAllowed, null);
}
if (status == null) {
status = new Status(IStatus.OK, JSPUIPlugin.ID, IStatus.OK, JSPUIMessages.OK, null);
}
return status;
}
use of org.eclipse.debug.core.model.IBreakpoint in project liferay-ide by liferay.
the class FMDebugTarget method addRemoteBreakpoints.
public void addRemoteBreakpoints(final Debugger debugger, final IBreakpoint[] bps) throws RemoteException {
final List<Breakpoint> remoteBps = new ArrayList<Breakpoint>();
for (IBreakpoint bp : bps) {
final int line = bp.getMarker().getAttribute(IMarker.LINE_NUMBER, -1);
final String templateName = bp.getMarker().getAttribute(ILRDebugConstants.FM_TEMPLATE_NAME, null);
final String remoteTemplateName = createRemoteTemplateName(templateName);
if (!CoreUtil.isNullOrEmpty(remoteTemplateName) && line > -1) {
remoteBps.add(new Breakpoint(remoteTemplateName, line));
}
}
final Job job = new Job("add remote breakpoints") {
@Override
protected IStatus run(IProgressMonitor monitor) {
IStatus retval = null;
for (Breakpoint bp : remoteBps) {
try {
debugger.addBreakpoint(bp);
} catch (RemoteException e) {
retval = PortalCore.createErrorStatus(NLS.bind("Could not add remote breakpoint: {0}:{1}", new Object[] { bp.getTemplateName(), bp.getLine() }), e);
if (retval != Status.OK_STATUS) {
PortalCore.logError(retval.getMessage());
}
}
}
return Status.OK_STATUS;
}
};
job.schedule();
}
use of org.eclipse.debug.core.model.IBreakpoint in project liferay-ide by liferay.
the class FMDebugTarget method step.
/*
* Since current fm debugger doens't have native stepping we must emulate stepping with following steps.
*
* 1. Starting at the current stopped line, continue going down the template file to find a
* suitable line to stop, ie, a addBreakpoint() that doesn't throw an exception.
* 2. For the next line if there is already a breakpoint, simply call resume(),
* 3. If there is no breakpoint already installed, add another one to the next line if that line has a valid
* breakpoint location, then resume().
* 4. Once the next breakpoint is hit, we need to remove the previously added step breakpoint
*/
@SuppressWarnings({ "rawtypes" })
void step(FMThread thread) throws DebugException {
int currentLineNumber = -1;
String templateName = null;
Breakpoint existingStepBp = null;
final IBreakpoint[] breakpoints = thread.getBreakpoints();
if (breakpoints.length > 0) {
try {
ILineBreakpoint bp = (ILineBreakpoint) breakpoints[0];
currentLineNumber = bp.getLineNumber();
templateName = bp.getMarker().getAttribute(ILRDebugConstants.FM_TEMPLATE_NAME, "");
} catch (CoreException e) {
PortalCore.logError("Could not get breakpoint information.", e);
}
} else {
existingStepBp = thread.getStepBreakpoint();
currentLineNumber = existingStepBp.getLine();
templateName = existingStepBp.getTemplateName();
}
if (currentLineNumber > -1 && templateName != null) {
final String remoteTemplateName = createRemoteTemplateName(templateName);
int stepLine = currentLineNumber + 1;
Breakpoint existingBp = null;
Debugger debugCli = getDebuggerClient();
try {
List remoteBps = debugCli.getBreakpoints(remoteTemplateName);
for (Iterator i = remoteBps.iterator(); i.hasNext(); ) {
Breakpoint remoteBp = (Breakpoint) i.next();
if (remoteBp.getLine() == stepLine) {
existingBp = remoteBp;
break;
}
}
if (existingBp == null) {
boolean addedRemote = false;
while (!addedRemote) {
Breakpoint newBp = new Breakpoint(remoteTemplateName, stepLine++);
try {
debugCli.addBreakpoint(newBp);
} catch (RemoteException e) {
// we except to get some remote exceptions if the next line is invalid breakpoint location
}
List updatedRemoteBps = debugCli.getBreakpoints(remoteTemplateName);
if (// our new remote bp was sucessfully added
updatedRemoteBps.size() == remoteBps.size() + 1) {
addedRemote = true;
thread.setStepBreakpoint(newBp);
thread.setStepping(true);
fireResumeEvent(DebugEvent.RESUME);
if (existingStepBp != null) {
debugCli.removeBreakpoint(existingStepBp);
}
thread.getEnvironment().resume();
}
}
} else {
// the next line already has a remote breakpoint installed so lets clear our "step" breakpoint
thread.setStepBreakpoint(null);
thread.setStepping(false);
fireResumeEvent(DebugEvent.RESUME);
if (existingStepBp != null) {
debugCli.removeBreakpoint(existingStepBp);
}
thread.getEnvironment().resume();
}
} catch (RemoteException e) {
PortalCore.logError("Unable to check remote breakpoints", e);
}
} else {
PortalCore.logError("Unable to step because of missing lineNumber or templateName information.");
}
}
Aggregations