org.eclipse.debug.core.model.IBreakpoint Java Examples

The following examples show how to use org.eclipse.debug.core.model.IBreakpoint. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScriptDebugTarget.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void breakpointRemoved( IBreakpoint breakpoint, IMarkerDelta delta )
{
	if ( !supportsBreakpoint( breakpoint ) )
	{
		return;
	}

	JsLineBreakPoint point = new JsLineBreakPoint( ( (ScriptLineBreakpoint) breakpoint ).getSubName( ),
			( (ScriptLineBreakpoint) breakpoint ).getScriptLineNumber( ) );
	if ( breakPoints.contains( point ) )
	{
		breakPoints.remove( point );
		try
		{
			reportVM.removeBreakPoint( point );
		}
		catch ( VMException e )
		{
			logger.warning( e.getMessage( ) );
		}
	}
}
 
Example #2
Source File: EnableDisableBreakpointRulerAction.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run() {

    final IBreakpoint breakpoint = getBreakpoint();
    if (breakpoint != null) {
        new Job("Enabling / Disabling Breakpoint") { //$NON-NLS-1$
            @Override
            protected IStatus run(IProgressMonitor monitor) {
                try {
                    breakpoint.setEnabled(!breakpoint.isEnabled());
                    return Status.OK_STATUS;
                } catch (final CoreException e) {
                    Display.getDefault().asyncExec(new Runnable() {
                        @Override
                        public void run() {
                            ErrorDialog.openError(getTextEditor().getEditorSite().getShell(),
                                    "Enabling/disabling breakpoints",
                                    "Exceptions occurred enabling disabling the breakpoint", e.getStatus());
                        }
                    });
                }
                return Status.CANCEL_STATUS;
            }
        }.schedule();
    }
}
 
Example #3
Source File: EnableDisableBreakpointRulerAction.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void update() {
    IBreakpoint breakpoint = getBreakpointFromLastLineOfActivityInCurrentEditor();
    setBreakpoint(breakpoint);
    if (breakpoint == null) {
        setEnabled(false);
        setText("&Disable Breakpoint");
    } else {
        setEnabled(true);
        try {
            boolean enabled = breakpoint.isEnabled();
            setText(enabled ? "&Disable Breakpoint" : "&Enable Breakpoint");
        } catch (CoreException ce) {
            PydevDebugPlugin.log(IStatus.ERROR, ce.getLocalizedMessage(), ce);
        }
    }
}
 
Example #4
Source File: AbstractBreakpointRulerAction.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @return the breakpoint in the line the user clicked last or null if there is no such breakpoint.
 */
protected IBreakpoint getBreakpointFromLastLineOfActivityInCurrentEditor() {
    List<IBreakpoint> breakpoints = getBreakpointsFromCurrentFile(true);
    int size = breakpoints.size();
    if (size == 0) {
        return null;

    } else if (size == 1) {
        return breakpoints.get(0);

    } else if (size > 1) {
        Log.log("Did not expect more than one breakpoint in the current line. Returning first.");
        return breakpoints.get(0);

    } else {
        Log.log("Unexpected condition!");
        return null;
    }
}
 
Example #5
Source File: ScriptDebugTarget.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void breakpointChanged( IBreakpoint breakpoint, IMarkerDelta delta )
{
	if ( !supportsBreakpoint( breakpoint ) )
	{
		return;
	}
	try
	{
		if ( breakpoint.isEnabled( ) )
		{
			breakpointAdded( breakpoint );
		}
		else
		{
			breakpointRemoved( breakpoint, null );
		}
	}
	catch ( CoreException e )
	{

	}
}
 
Example #6
Source File: ToggleBreakpointAdapter.java    From typescript.java with MIT License 6 votes vote down vote up
IBreakpoint lineBreakpointExists(IResource resource, int linenumber) {
	IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(JavaScriptDebugModel.MODEL_ID);
	IJavaScriptLineBreakpoint breakpoint = null;
	for (int i = 0; i < breakpoints.length; i++) {
		if(breakpoints[i] instanceof IJavaScriptLineBreakpoint) {
			breakpoint = (IJavaScriptLineBreakpoint) breakpoints[i];
			try {
				if(IJavaScriptLineBreakpoint.MARKER_ID.equals(breakpoint.getMarker().getType()) &&
					resource.equals(breakpoint.getMarker().getResource()) &&
					linenumber == breakpoint.getLineNumber()) {
					return breakpoint;
				}
			} catch (CoreException e) {}
		}
	}
	return null;
}
 
Example #7
Source File: ToggleBreakpointAdapter.java    From typescript.java with MIT License 6 votes vote down vote up
void addBreakpoint(IResource resource, IDocument document, int linenumber) throws CoreException {
	IBreakpoint bp = lineBreakpointExists(resource, linenumber);
	if(bp != null) {
		DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(bp, true);
	}
	int charstart = -1, charend = -1;
	try {
		IRegion line = document.getLineInformation(linenumber - 1);
		charstart = line.getOffset();
		charend = charstart + line.getLength();
	}
	catch (BadLocationException ble) {}
	HashMap<String, String> attributes = new HashMap<String, String>();
	attributes.put(IJavaScriptBreakpoint.TYPE_NAME, null);
	attributes.put(IJavaScriptBreakpoint.SCRIPT_PATH, resource.getFullPath().makeAbsolute().toString());
	attributes.put(IJavaScriptBreakpoint.ELEMENT_HANDLE, null);
	JavaScriptDebugModel.createLineBreakpoint(resource, linenumber, charstart, charend, attributes, true);
}
 
Example #8
Source File: XbaseBreakpointDetailPaneFactory.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Set<String> getDetailPaneTypes(IStructuredSelection selection) {
	prioritizer.prioritizeXbaseOverJdt();
	if (selection.size() == 1) {
		Object selectedElement = selection.getFirstElement();
		if (selectedElement instanceof IBreakpoint) {
			IBreakpoint b = (IBreakpoint) selectedElement;
			try {
				Object sourceUri = b.getMarker().getAttribute(StratumBreakpointAdapterFactory.ORG_ECLIPSE_XTEXT_XBASE_SOURCE_URI);
				if (sourceUri != null) {
					return Collections.singleton(XBASE_DETAIL_PANE);
				}
			} catch (CoreException e) {}
		}
	}
	return Collections.emptySet();
}
 
Example #9
Source File: ScriptDebugTarget.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public boolean supportsBreakpoint( IBreakpoint breakpoint )
{
	if (!(breakpoint instanceof ScriptLineBreakpoint))
	{
		return false;
	}
	String str = ( (ScriptLineBreakpoint) breakpoint ).getFileName( );
	if (str == null || str.length( ) == 0)
	{
		return false;
	}
	return  str.equals( getFileName( ) );
}
 
Example #10
Source File: PyThread.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IBreakpoint[] getBreakpoints() {
    // should return breakpoint that caused this thread to suspend
    // not implementing this seems to cause no harm
    PyBreakpoint[] breaks = new PyBreakpoint[0];
    return breaks;
}
 
Example #11
Source File: AbstractDebugTarget.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Called when a breakpoint is changed.
 * E.g.:
 *  - When line numbers change in the file
 *  - When the manager decides to enable/disable all existing markers
 *  - When the breakpoint properties (hit condition) are edited
 */
@Override
public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
    if (breakpoint instanceof PyBreakpoint) {
        breakpointRemoved(breakpoint, null);
        breakpointAdded(breakpoint);
    }
}
 
Example #12
Source File: AbstractDebugTarget.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Removes an existing breakpoint from the debug target.
 */
@Override
public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
    if (breakpoint instanceof PyBreakpoint) {
        PyBreakpoint b = (PyBreakpoint) breakpoint;
        if (currentBreakpointsAdded.contains(b.breakpointId)) {
            currentBreakpointsAdded.remove(b.breakpointId);
            RemoveBreakpointCommand cmd = new RemoveBreakpointCommand(this, b.breakpointId, b.getFile(),
                    b.getType());
            this.postCommand(cmd);
        }
    }
}
 
Example #13
Source File: AbstractDebugTarget.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds a breakpoint if it's enabled.
 */
@Override
public void breakpointAdded(IBreakpoint breakpoint) {
    try {
        if (breakpoint instanceof PyBreakpoint) {
            PyBreakpoint b = (PyBreakpoint) breakpoint;
            if (b.isEnabled() && !shouldSkipBreakpoints()) {
                String condition = null;
                if (b.isConditionEnabled()) {
                    condition = b.getCondition();
                    if (condition != null) {
                        condition = StringUtils.replaceAll(condition, "\n",
                                "@_@NEW_LINE_CHAR@_@");
                        condition = StringUtils.replaceAll(condition, "\t",
                                "@_@TAB_CHAR@_@");
                    }
                }
                String file2 = b.getFile();
                Object line = b.getLine();
                if (file2 == null || line == null) {
                    Log.log("Trying to add breakpoint with invalid file: " + file2 + " or line: " + line);
                } else {
                    this.currentBreakpointsAdded.add(b.breakpointId);
                    SetBreakpointCommand cmd = new SetBreakpointCommand(this, b.breakpointId, file2, line,
                            condition, b.getFunctionName(), b.getType());
                    this.postCommand(cmd);
                }
            }
        }
    } catch (CoreException e) {
        Log.log(e);
    }
}
 
Example #14
Source File: ScriptDebugTarget.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void installDeferredBreakpoints( )
{
	IBreakpoint[] breakpoints = DebugPlugin.getDefault( )
			.getBreakpointManager( )
			.getBreakpoints( IScriptConstants.SCRIPT_DEBUG_MODEL );
	for ( int i = 0; i < breakpoints.length; i++ )
	{
		breakpointAdded( breakpoints[i] );
	}
}
 
Example #15
Source File: AbstractBreakpointRulerAction.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
protected List<IBreakpoint> getBreakpointsFromCurrentFile(boolean onlyIncludeLastLineActivity) {
    List<Tuple<IMarker, IBreakpoint>> markersAndBreakpointsFromEditorResource = getMarkersAndBreakpointsFromEditorResource(
            getResourceForDebugMarkers(), getDocument(), getExternalFileEditorInput(), getInfo()
                    .getLineOfLastMouseButtonActivity(), onlyIncludeLastLineActivity, getAnnotationModel());

    int size = markersAndBreakpointsFromEditorResource.size();
    ArrayList<IBreakpoint> r = new ArrayList<IBreakpoint>(size);
    for (int i = 0; i < size; i++) {
        r.add(markersAndBreakpointsFromEditorResource.get(i).o2);
    }
    return r;
}
 
Example #16
Source File: ScriptDebugThread.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public IBreakpoint[] getBreakpoints( )
{
	if ( fBreakpoints == null )
	{
		return new IBreakpoint[0];
	}
	return fBreakpoints;
}
 
Example #17
Source File: SortMembersCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static boolean containsRelevantMarkers(IFile file) throws CoreException {
	IMarker[] bookmarks= file.findMarkers(IMarker.BOOKMARK, true, IResource.DEPTH_INFINITE);
	if (bookmarks.length != 0)
		return true;

	IMarker[] tasks= file.findMarkers(IMarker.TASK, true, IResource.DEPTH_INFINITE);
	if (tasks.length != 0)
		return true;

	IMarker[] breakpoints= file.findMarkers(IBreakpoint.BREAKPOINT_MARKER, true, IResource.DEPTH_INFINITE);
	if (breakpoints.length != 0)
		return true;

	return false;
}
 
Example #18
Source File: AbstractBreakpointRulerAction.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public static List<IMarker> getMarkersFromEditorResource(IResource resource, IDocument document,
        IEditorInput externalFileEditorInput, int lastLineActivity, boolean onlyIncludeLastLineActivity,
        IAnnotationModel annotationModel) {
    List<Tuple<IMarker, IBreakpoint>> markersAndBreakpointsFromEditorResource = getMarkersAndBreakpointsFromEditorResource(
            resource, document, externalFileEditorInput, lastLineActivity, onlyIncludeLastLineActivity,
            annotationModel);

    int size = markersAndBreakpointsFromEditorResource.size();
    ArrayList<IMarker> r = new ArrayList<IMarker>(size);
    for (int i = 0; i < size; i++) {
        r.add(markersAndBreakpointsFromEditorResource.get(i).o1);
    }
    return r;
}
 
Example #19
Source File: PythonBreakpointPropertiesRulerAction.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void update() {
    IBreakpoint breakpoint = getBreakpointFromLastLineOfActivityInCurrentEditor();
    if (breakpoint == null || !(breakpoint instanceof PyBreakpoint)) {
        setBreakpoint(null);
        setEnabled(false);
    } else {
        setBreakpoint(breakpoint);
        setEnabled(true);
    }
    setText("Breakpoint &Properties...");
}
 
Example #20
Source File: LocalAppEngineServerLaunchConfigurationDelegate.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
@Override
public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {}
 
Example #21
Source File: LocalAppEngineServerLaunchConfigurationDelegate.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
@Override
public void breakpointAdded(IBreakpoint breakpoint) {}
 
Example #22
Source File: AbstractBreakpointRulerAction.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
protected void setBreakpoint(IBreakpoint breakpoint) {
    fBreakpoint = breakpoint;
}
 
Example #23
Source File: AbstractBreakpointRulerAction.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
protected IBreakpoint getBreakpoint() {
    return fBreakpoint;
}
 
Example #24
Source File: AbstractBreakpointRulerAction.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @param resource may be the file open in the editor or the workspace root (if it is an external file)
 * @param document is the document opened in the editor
 * @param externalFileEditorInput is not-null if this is an external file
 * @param info is the vertical ruler info (only used if this is not an external file)
 * @param onlyIncludeLastLineActivity if only the markers that are in the last mouse-click should be included
 *
 * @return the markers that correspond to the markers from the current editor.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public static List<Tuple<IMarker, IBreakpoint>> getMarkersAndBreakpointsFromEditorResource(IResource resource,
        IDocument document, IEditorInput externalFileEditorInput, int lastLineActivity,
        boolean onlyIncludeLastLineActivity, IAnnotationModel annotationModel) {
    List<Tuple<IMarker, IBreakpoint>> breakpoints = new ArrayList<Tuple<IMarker, IBreakpoint>>();

    try {
        List<IMarker> markers = new ArrayList<IMarker>();
        boolean isExternalFile = false;

        markers.addAll(Arrays.asList(resource.findMarkers(PyBreakpoint.PY_BREAK_MARKER, true,
                IResource.DEPTH_INFINITE)));
        markers.addAll(Arrays.asList(resource.findMarkers(PyBreakpoint.PY_CONDITIONAL_BREAK_MARKER, true,
                IResource.DEPTH_INFINITE)));
        markers.addAll(Arrays.asList(resource.findMarkers(PyBreakpoint.DJANGO_BREAK_MARKER, true,
                IResource.DEPTH_INFINITE)));

        if (!(resource instanceof IFile)) {
            //it was created from an external file
            isExternalFile = true;
        }

        IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
        for (IMarker marker : markers) {
            if (marker == null) {
                continue;
            }
            IBreakpoint breakpoint = breakpointManager.getBreakpoint(marker);
            if (breakpoint != null && breakpointManager.isRegistered(breakpoint)) {
                Position pos = PyMarkerUIUtils.getMarkerPosition(document, marker, annotationModel);

                if (!isExternalFile) {
                    if (!onlyIncludeLastLineActivity) {
                        breakpoints.add(new Tuple(marker, breakpoint));
                    } else if (includesRulerLine(pos, document, lastLineActivity)) {
                        breakpoints.add(new Tuple(marker, breakpoint));
                    }
                } else {

                    if (isInSameExternalEditor(marker, externalFileEditorInput)) {
                        if (!onlyIncludeLastLineActivity) {
                            breakpoints.add(new Tuple(marker, breakpoint));
                        } else if (includesRulerLine(pos, document, lastLineActivity)) {
                            breakpoints.add(new Tuple(marker, breakpoint));
                        }
                    }
                }
            }
        }
    } catch (CoreException x) {
        PydevDebugPlugin.log(IStatus.ERROR, "Unexpected getMarkers error (recovered properly)", x);
    }
    return breakpoints;
}
 
Example #25
Source File: LocalAppEngineServerLaunchConfigurationDelegate.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
@Override
public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {}
 
Example #26
Source File: PyEditBreakpointSync.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
    updateAnnotations();
}
 
Example #27
Source File: PyEditBreakpointSync.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
}
 
Example #28
Source File: PyEditBreakpointSync.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void breakpointAdded(IBreakpoint breakpoint) {
    updateAnnotations();
}
 
Example #29
Source File: AbstractDebugTarget.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @return true if the given breakpoint is supported by this target
 */
@Override
public boolean supportsBreakpoint(IBreakpoint breakpoint) {
    return breakpoint instanceof PyBreakpoint;
}
 
Example #30
Source File: LocalAppEngineServerLaunchConfigurationDelegate.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
@Override
public boolean supportsBreakpoint(IBreakpoint breakpoint) {
  return false;
}