Java 类org.eclipse.debug.core.model.IBreakpoint 实例源码

项目:gemoc-studio-modeldebugging    文件:DSLBreakpoint.java   
/**
 * Sets attributes for the given {@link IMarker}.
 * 
 * @param marker
 *            the {@link IMarker}
 * @param resource
 *            the {@link IFile} containing the mode
 * @param instruction
 *            the {@link EObject} representing the instruction
 * @param persistent
 *            should be persisted
 * @throws CoreException
 *             if attributes can't be set
 */
protected void setMarkerAttibutes(final IMarker marker, IFile resource, EObject instruction,
        boolean persistent) throws CoreException {
    final IItemLabelProvider provider = (IItemLabelProvider)ADAPTER_FACTORY.adapt(instruction,
            IItemLabelProvider.class);
    marker.setAttribute(IBreakpoint.ENABLED, true);
    marker.setAttribute(IBreakpoint.PERSISTED, persistent);
    marker.setAttribute(IBreakpoint.ID, getModelIdentifier());
    marker.setAttribute(EValidator.URI_ATTRIBUTE, EcoreUtil.getURI(instruction).toString());
    final String instructionText = provider.getText(instruction);
    marker.setAttribute(IMarker.MESSAGE, "DSL Breakpoint: " + resource.getFullPath() + " ["
            + instructionText + "]");
    try {
        marker.setAttribute(IMAGE_ATTRIBUTE, toAttribute(provider.getImage(instruction)));
    } catch (IOException e) {
        Activator.getDefault().error(e);
    }
    marker.setAttribute(TEXT_ATTRIBUTE, instructionText);
}
项目:gemoc-studio-modeldebugging    文件:DSLDebugTargetAdapter.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.debug.core.IBreakpointListener#breakpointChanged(org.eclipse.debug.core.model.IBreakpoint,
 *      org.eclipse.core.resources.IMarkerDelta)
 */
public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
    if (supportsBreakpoint(breakpoint)) {
        try {
            final URI uri = ((DSLBreakpoint)breakpoint).getURI();
            final IMarker marker = breakpoint.getMarker();
            for (Entry<String, Object> entry : delta.getAttributes().entrySet()) {
                final Object markerValue = marker.getAttribute(entry.getKey());
                final Object deltaValue = entry.getValue();
                if ((markerValue != null && !markerValue.equals(deltaValue)) || (deltaValue != null
                        && !deltaValue.equals(markerValue))) {
                    if (delta.getKind() == IResourceDelta.ADDED) {
                        factory.getDebugger().handleEvent(new ChangeBreakPointRequest(uri, entry.getKey(),
                                (Serializable)deltaValue));
                    } else {
                        factory.getDebugger().handleEvent(new ChangeBreakPointRequest(uri, entry.getKey(),
                                (Serializable)markerValue));
                    }
                }
            }
        } catch (CoreException e) {
            Activator.getDefault().error(e);
        }
    }
}
项目:gemoc-studio-modeldebugging    文件:DSLThreadAdapter.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.debug.core.model.IThread#getBreakpoints()
 */
public IBreakpoint[] getBreakpoints() {
    final List<IBreakpoint> res = new ArrayList<IBreakpoint>();

    if (isSuspended()) {
        final URI instructionUri = EcoreUtil.getURI(getHost().getTopStackFrame().getCurrentInstruction());
        for (IBreakpoint breakpoint : DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(
                getModelIdentifier())) {
            if (breakpoint instanceof DSLBreakpoint
                    && (((DSLBreakpoint)breakpoint).getURI().equals(instructionUri))) {
                res.add(breakpoint);
            }
        }
    }

    return res.toArray(new IBreakpoint[res.size()]);
}
项目:gemoc-studio-modeldebugging    文件:DSLToggleBreakpointsUtils.java   
/**
 * Gets the {@link DSLBreakpoint} for the given {@link EObject instruction}.
 * 
 * @param instruction
 *            the {@link EObject instruction}
 * @return the {@link DSLBreakpoint} for the given {@link EObject instruction} if nay, <code>null</code>
 *         otherwise
 */
protected DSLBreakpoint getBreakpoint(EObject instruction) {
    DSLBreakpoint res = null;

    IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager()
            .getBreakpoints(identifier);
    final URI instructionURI = EcoreUtil.getURI(instruction);
    for (IBreakpoint breakpoint : breakpoints) {
        if (breakpoint instanceof DSLBreakpoint && ((DSLBreakpoint)breakpoint).getURI() != null
                && ((DSLBreakpoint)breakpoint).getURI().equals(instructionURI)) {
            res = (DSLBreakpoint)breakpoint;
            break;
        }
    }

    return res;
}
项目:gemoc-studio-modeldebugging    文件:DSLLabelDecorator.java   
/**
 * Fires {@link LabelProviderChangedEvent} for the given {@link DSLBreakpoint}.
 * 
 * @param breakpoint
 *            the {@link DSLBreakpoint}
 */
protected void fireLabelProviderChanged(IBreakpoint breakpoint) {
    if (resourceSet != null) {
        final Object instruction = getElement(resourceSet, (DSLBreakpoint)breakpoint);
        if (instruction != null) {
            final LabelProviderChangedEvent event = new LabelProviderChangedEvent(this, instruction);
            Display.getDefault().asyncExec(new Runnable() {

                /**
                 * {@inheritDoc}
                 * 
                 * @see java.lang.Runnable#run()
                 */
                public void run() {
                    fireLabelProviderChanged(event);
                }
            });
        }
    }
}
项目:dsp4e    文件:DSPDebugTarget.java   
/**
 * When the breakpoint manager disables, remove all registered breakpoints
 * requests from the VM. When it enables, reinstall them.
 */
@Override
public void breakpointManagerEnablementChanged(boolean enabled) {
    try {
        IBreakpoint[] breakpoints = getBreakpointManager().getBreakpoints(getModelIdentifier());
        for (IBreakpoint breakpoint : breakpoints) {
            if (supportsBreakpoint(breakpoint)) {
                if (enabled) {
                    addBreakpointToMap(breakpoint);
                } else {
                    deleteBreakpointFromMap(breakpoint);
                }
            }
        }
        sendBreakpoints();
    } catch (CoreException e) {
        // TODO
        e.printStackTrace();
    }
}
项目:dsp4e    文件:DSPDebugTarget.java   
private void addBreakpointToMap(IBreakpoint breakpoint) throws CoreException {
    Assert.isTrue(supportsBreakpoint(breakpoint) && breakpoint instanceof ILineBreakpoint);
    if (breakpoint instanceof ILineBreakpoint) {
        ILineBreakpoint lineBreakpoint = (ILineBreakpoint) breakpoint;
        IResource resource = lineBreakpoint.getMarker().getResource();
        IPath location = resource.getLocation();
        String path = location.toOSString();
        String name = location.lastSegment();
        int lineNumber = lineBreakpoint.getLineNumber();

        Source source = new Source().setName(name).setPath(path);

        List<SourceBreakpoint> sourceBreakpoints = targetBreakpoints.computeIfAbsent(source,
                s -> new ArrayList<>());
        sourceBreakpoints.add(new SourceBreakpoint().setLine(lineNumber));
    }
}
项目:dsp4e    文件:DSPDebugTarget.java   
private void deleteBreakpointFromMap(IBreakpoint breakpoint) throws CoreException {
    Assert.isTrue(supportsBreakpoint(breakpoint) && breakpoint instanceof ILineBreakpoint);
    if (breakpoint instanceof ILineBreakpoint) {
        ILineBreakpoint lineBreakpoint = (ILineBreakpoint) breakpoint;
        IResource resource = lineBreakpoint.getMarker().getResource();
        IPath location = resource.getLocation();
        String path = location.toOSString();
        String name = location.lastSegment();
        int lineNumber = lineBreakpoint.getLineNumber();
        for (Entry<Source, List<SourceBreakpoint>> entry : targetBreakpoints.entrySet()) {
            Source source = entry.getKey();
            if (Objects.equals(name, source.name) && Objects.equals(path, source.path)) {
                List<SourceBreakpoint> bps = entry.getValue();
                for (Iterator<SourceBreakpoint> iterator = bps.iterator(); iterator.hasNext();) {
                    SourceBreakpoint sourceBreakpoint = (SourceBreakpoint) iterator.next();
                    if (Objects.equals(lineNumber, sourceBreakpoint.line)) {
                        iterator.remove();
                    }
                }
            }
        }
    }
}
项目:dsp4e    文件:DSPBreakpointAdapter.java   
@Override
public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
    ITextEditor textEditor = getEditor(part);
    if (textEditor != null) {
        IResource resource = textEditor.getEditorInput().getAdapter(IResource.class);
        ITextSelection textSelection = (ITextSelection) selection;
        int lineNumber = textSelection.getStartLine();
        IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager()
                .getBreakpoints(DSPPlugin.ID_DSP_DEBUG_MODEL);
        for (int i = 0; i < breakpoints.length; i++) {
            IBreakpoint breakpoint = breakpoints[i];
            if (breakpoint instanceof ILineBreakpoint && resource.equals(breakpoint.getMarker().getResource())) {
                if (((ILineBreakpoint) breakpoint).getLineNumber() == (lineNumber + 1)) {
                    // remove
                    breakpoint.delete();
                    return;
                }
            }
        }
        // create line breakpoint (doc line numbers start at 0)
        DSPLineBreakpoint lineBreakpoint = new DSPLineBreakpoint(resource, lineNumber + 1);
        DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(lineBreakpoint);
    }
}
项目:visuflow-plugin    文件:JimpleBreakpointManager.java   
private IMarker createJimpleMarker(IMarker marker) throws CoreException {
    String project = (String) marker.getAttribute("Jimple.project");
    String file = (String) marker.getAttribute("Jimple.file");
    IFile jimpleFile = getFile(project, file);

    IMarker jimpleMarker = null;
    IMarker[] markers = jimpleFile.findMarkers(IBreakpoint.BREAKPOINT_MARKER, true, IResource.DEPTH_INFINITE);
    if(markers != null) {
        List<IMarker> jimpleBreakpoints = filterJimpleChildBreakpoints(Arrays.asList(markers));
        if(!jimpleBreakpoints.isEmpty()) {
            jimpleMarker = jimpleBreakpoints.get(0);
        } else {
            jimpleMarker = jimpleFile.createMarker(IBreakpoint.BREAKPOINT_MARKER);
        }
    } else {
        jimpleMarker = jimpleFile.createMarker(IBreakpoint.BREAKPOINT_MARKER);
    }

    jimpleMarker.setAttribute(IMarker.LINE_NUMBER, marker.getAttribute("Jimple." + IMarker.LINE_NUMBER));
    jimpleMarker.setAttribute("Jimple.unit.charStart", marker.getAttribute("Jimple.unit.charStart"));
    jimpleMarker.setAttribute("Jimple.unit.charEnd", marker.getAttribute("Jimple.unit.charEnd"));
    jimpleMarker.setAttribute("Jimple.unit.fqn", marker.getAttribute("Jimple.unit.fqn"));
    jimpleMarker.setAttribute("Jimple.project", marker.getAttribute("Jimple.project"));
    jimpleMarker.setAttribute("Jimple.file", marker.getAttribute("Jimple.file"));
    return jimpleMarker;
}
项目:typescript.java    文件:ToggleBreakpointAdapter.java   
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);
}
项目:typescript.java    文件:ToggleBreakpointAdapter.java   
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;
}
项目:monto-eclipse    文件:MontoDebugTarget.java   
private MontoLineBreakpoint findEclipseLineBreakpoint(Breakpoint breakpoint) {
  if (breakpoint != null) {
    IBreakpoint[] eclipseBreakpoints =
        DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(Activator.PLUGIN_ID);

    for (IBreakpoint eclipseBreakpoint : eclipseBreakpoints) {
      if (eclipseBreakpoint instanceof MontoLineBreakpoint) {
        MontoLineBreakpoint eclipseMontoBreakpoint = (MontoLineBreakpoint) eclipseBreakpoint;
        try {
          if (eclipseMontoBreakpoint.getSource().equals(breakpoint.getSource())
              && eclipseMontoBreakpoint.getLineNumber() == breakpoint.getLineNumber()) {
            return eclipseMontoBreakpoint;
          }
        } catch (DebugException ignored) {
        }
      }
    }
  }
  return null;
}
项目:brainfuck    文件:BfDebugTarget.java   
@Override
public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
    if (this.isTerminated()) {
        return;
    }
    try {
        if (breakpoint instanceof BfWatchpoint) {
            BfWatchpoint wp = (BfWatchpoint) breakpoint;
            this.process.getInterpreter().removeWatchpoint(wp);
        }
        BfBreakpoint bp = this.getValidBreakpoint(breakpoint);
        if (bp == null) {
            return;
        }
        int location = bp.getCharStart();
        this.process.getInterpreter().removeBreakpoint(location);
        this.removeInstalledBreakpoint(bp);
    }
    catch (CoreException ex) {
        DbgActivator.getDefault().logError("Breakpoint could not be added", ex);
    }
}
项目:chromedevtools    文件:ChromiumLineBreakpoint.java   
/**
 * Constructs a line breakpoint on the given resource at the given line number
 * (line number is 1-based).
 *
 * @param resource file on which to set the breakpoint
 * @param lineNumber 1-based line number of the breakpoint
 * @throws CoreException if unable to create the breakpoint
 */
public ChromiumLineBreakpoint(final IResource resource, final int lineNumber,
    final String modelId) throws CoreException {
  IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
    public void run(IProgressMonitor monitor) throws CoreException {
      IMarker marker = resource.createMarker(ChromiumDebugPlugin.BP_MARKER);
      setMarker(marker);
      marker.setAttribute(IBreakpoint.ENABLED, Boolean.TRUE);
      marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
      marker.setAttribute(IBreakpoint.ID, modelId);
      marker.setAttribute(IMarker.MESSAGE, NLS.bind(
          Messages.JsLineBreakpoint_MessageMarkerFormat, resource.getName(), lineNumber));
    }
  };
  run(getMarkerRule(resource), runnable);
}
项目:chromedevtools    文件:LineBreakpointAdapter.java   
public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection)
    throws CoreException {
  ITextEditor textEditor = getEditor(part);
  if (textEditor != null) {
    IResource resource = (IResource) textEditor.getEditorInput().getAdapter(IResource.class);
    ITextSelection textSelection = (ITextSelection) selection;
    int lineNumber = textSelection.getStartLine();
    IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(
        getDebugModelId());
    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;
        }
      }
    }

    // Line numbers start with 0 in V8, with 1 in Eclipse.
    ChromiumLineBreakpoint lineBreakpoint = new ChromiumLineBreakpoint(resource, lineNumber + 1,
        getDebugModelId());
    DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(lineBreakpoint);
  }
}
项目:chromedevtools    文件:VProjectWorkspaceBridge.java   
public Collection<? extends IBreakpoint> handleBreakpointsHit(
    Collection<? extends Breakpoint> sdkBreakpoints) {
  if (sdkBreakpoints.isEmpty()) {
    return Collections.emptyList();
  }

  Collection<IBreakpoint> uiBreakpoints = new ArrayList<IBreakpoint>(sdkBreakpoints.size());

  for (Breakpoint sdkBreakpoint : sdkBreakpoints) {
    ChromiumLineBreakpoint uiBreakpoint = getMap().getUiBreakpoint(sdkBreakpoint);
    if (uiBreakpoint != null) {
      try {
        uiBreakpoint.silentlyResetIgnoreCount(); // reset ignore count as we've hit it
      } catch (CoreException e) {
        ChromiumDebugPlugin.log(new Exception("Failed to reset breakpoint ignore count", e));
      }

      uiBreakpoints.add(uiBreakpoint);
    }
  }
  return uiBreakpoints;
}
项目:chromedevtools    文件:VProjectWorkspaceBridge.java   
public Collection<? extends IBreakpoint> getHitBreakpoints(boolean isUncaught) {
  List<ChromiumExceptionBreakpoint> result = new ArrayList<ChromiumExceptionBreakpoint>(2);
  synchronized (this) {
    for (FakeSdkBreakpoint sdkBreakpoint : breakpoints) {
      if (!isUncaught && !sdkBreakpoint.includeCaught) {
        continue;
      }
      ChromiumExceptionBreakpoint uiBreakpoint = getMap().getUiBreakpoint(sdkBreakpoint);
      if (uiBreakpoint == null) {
        continue;
      }
      result.add(uiBreakpoint);
    }
  }
  return result;
}
项目:chromedevtools    文件:JsBreakpointPropertiesAction.java   
private Runnable createRunnable(ISelection selection) {
  if (selection instanceof IStructuredSelection == false) {
    return null;
  }
  IStructuredSelection structuredSelection = (IStructuredSelection) selection;
  if (structuredSelection.size() != 1) {
    return null;
  }
  Object element = structuredSelection.getFirstElement();
  if (element instanceof IBreakpoint == false) {
    return null;
  }
  final IBreakpoint breakpoint = (IBreakpoint) element;
  if (!isCorrectType(breakpoint)) {
    return null;
  }

  return new Runnable() {
    public void run() {
      runAction(breakpoint, site);
    }
  };
}
项目:chromedevtools    文件:JsDebugModelPresentation.java   
public String getEditorId(IEditorInput input, Object element) {
  IFile file;
  if (element instanceof IFile) {
    file = (IFile) element;
  } else if (element instanceof IBreakpoint) {
      IBreakpoint breakpoint = (IBreakpoint) element;
      IResource resource = breakpoint.getMarker().getResource();
      // Can the breakpoint resource be folder or project? Better check for it.
    if (resource instanceof IFile == false) {
      return null;
    }
    file = (IFile) resource;
  } else {
    return null;
  }

  // Pick the editor based on the file extension, taking user preferences into account.
  try {
    return IDE.getEditorDescriptor(file).getId();
  } catch (PartInitException e) {
    // TODO(peter.rybin): should it really be the default case?
    // There might be no virtual project.
    return JsEditor.EDITOR_ID;
  }
}
项目:ModelDebugging    文件:DSLBreakpoint.java   
/**
 * Sets attributes for the given {@link IMarker}.
 * 
 * @param marker
 *            the {@link IMarker}
 * @param resource
 *            the {@link IFile} containing the mode
 * @param instruction
 *            the {@link EObject} representing the instruction
 * @param persistent
 *            should be persisted
 * @throws CoreException
 *             if attributes can't be set
 */
protected void setMarkerAttibutes(final IMarker marker, IFile resource, EObject instruction,
        boolean persistent) throws CoreException {
    final IItemLabelProvider provider = (IItemLabelProvider)ADAPTER_FACTORY.adapt(instruction,
            IItemLabelProvider.class);
    marker.setAttribute(IBreakpoint.ENABLED, true);
    marker.setAttribute(IBreakpoint.PERSISTED, persistent);
    marker.setAttribute(IBreakpoint.ID, getModelIdentifier());
    marker.setAttribute(EValidator.URI_ATTRIBUTE, EcoreUtil.getURI(instruction).toString());
    final String instructionText = provider.getText(instruction);
    marker.setAttribute(IMarker.MESSAGE, "DSL Breakpoint: " + resource.getFullPath() + " ["
            + instructionText + "]");
    try {
        marker.setAttribute(IMAGE_ATTRIBUTE, toAttribute(provider.getImage(instruction)));
    } catch (IOException e) {
        Activator.getDefault().error(e);
    }
    marker.setAttribute(TEXT_ATTRIBUTE, instructionText);
}
项目:ModelDebugging    文件:DSLDebugTargetAdapter.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.debug.core.IBreakpointListener#breakpointChanged(org.eclipse.debug.core.model.IBreakpoint,
 *      org.eclipse.core.resources.IMarkerDelta)
 */
public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
    if (supportsBreakpoint(breakpoint)) {
        try {
            final URI uri = ((DSLBreakpoint)breakpoint).getURI();
            final IMarker marker = breakpoint.getMarker();
            for (Entry<String, Object> entry : delta.getAttributes().entrySet()) {
                final Object markerValue = marker.getAttribute(entry.getKey());
                final Object deltaValue = entry.getValue();
                if ((markerValue != null && !markerValue.equals(deltaValue)) || (deltaValue != null
                        && !deltaValue.equals(markerValue))) {
                    if (delta.getKind() == IResourceDelta.ADDED) {
                        factory.getDebugger().handleEvent(new ChangeBreakPointRequest(uri, entry.getKey(),
                                (Serializable)deltaValue));
                    } else {
                        factory.getDebugger().handleEvent(new ChangeBreakPointRequest(uri, entry.getKey(),
                                (Serializable)markerValue));
                    }
                }
            }
        } catch (CoreException e) {
            Activator.getDefault().error(e);
        }
    }
}
项目:ModelDebugging    文件:DSLThreadAdapter.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.debug.core.model.IThread#getBreakpoints()
 */
public IBreakpoint[] getBreakpoints() {
    final List<IBreakpoint> res = new ArrayList<IBreakpoint>();

    if (isSuspended()) {
        final URI instructionUri = EcoreUtil.getURI(getHost().getTopStackFrame().getCurrentInstruction());
        for (IBreakpoint breakpoint : DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(
                getModelIdentifier())) {
            if (breakpoint instanceof DSLBreakpoint
                    && (((DSLBreakpoint)breakpoint).getURI().equals(instructionUri))) {
                res.add(breakpoint);
            }
        }
    }

    return res.toArray(new IBreakpoint[res.size()]);
}
项目:ModelDebugging    文件:DSLToggleBreakpointsUtils.java   
/**
 * Gets the {@link DSLBreakpoint} for the given {@link EObject instruction}.
 * 
 * @param instruction
 *            the {@link EObject instruction}
 * @return the {@link DSLBreakpoint} for the given {@link EObject instruction} if nay, <code>null</code>
 *         otherwise
 */
protected DSLBreakpoint getBreakpoint(EObject instruction) {
    DSLBreakpoint res = null;

    IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager()
            .getBreakpoints(identifier);
    final URI instructionURI = EcoreUtil.getURI(instruction);
    for (IBreakpoint breakpoint : breakpoints) {
        if (breakpoint instanceof DSLBreakpoint && ((DSLBreakpoint)breakpoint).getURI() != null
                && ((DSLBreakpoint)breakpoint).getURI().equals(instructionURI)) {
            res = (DSLBreakpoint)breakpoint;
            break;
        }
    }

    return res;
}
项目:ModelDebugging    文件:DSLLabelDecorator.java   
/**
 * Fires {@link LabelProviderChangedEvent} for the given {@link DSLBreakpoint}.
 * 
 * @param breakpoint
 *            the {@link DSLBreakpoint}
 */
protected void fireLabelProviderChanged(IBreakpoint breakpoint) {
    if (resourceSet != null) {
        final Object instruction = getElement(resourceSet, (DSLBreakpoint)breakpoint);
        if (instruction != null) {
            final LabelProviderChangedEvent event = new LabelProviderChangedEvent(this, instruction);
            Display.getDefault().asyncExec(new Runnable() {

                /**
                 * {@inheritDoc}
                 * 
                 * @see java.lang.Runnable#run()
                 */
                public void run() {
                    fireLabelProviderChanged(event);
                }
            });
        }
    }
}
项目:watchdog    文件:BreakpointClassifier.java   
/**
 * Classifies the breakpoint type of the given breakpoint by analyzing its
 * class name.
 * 
 * WARNING: Do not change the ordering of the if-statements if you don't
 * have to!
 */
public static BreakpointType classify(IBreakpoint breakpoint) {
    if (breakpoint instanceof IJavaWatchpoint) {
        return BreakpointType.FIELD;
    } else if (breakpoint instanceof IJavaMethodBreakpoint) {
        return BreakpointType.METHOD;
    } else if (breakpoint instanceof IJavaClassPrepareBreakpoint) {
        return BreakpointType.CLASS;
    } else if (breakpoint instanceof IJavaLineBreakpoint) {
        return BreakpointType.LINE;
    } else if (breakpoint instanceof IJavaExceptionBreakpoint) {
        return BreakpointType.EXCEPTION;
    } else {
        return BreakpointType.UNDEFINED;
    }
}
项目:birt    文件:ScriptDebugTarget.java   
public void breakpointChanged( IBreakpoint breakpoint, IMarkerDelta delta )
{
    if ( !supportsBreakpoint( breakpoint ) )
    {
        return;
    }
    try
    {
        if ( breakpoint.isEnabled( ) )
        {
            breakpointAdded( breakpoint );
        }
        else
        {
            breakpointRemoved( breakpoint, null );
        }
    }
    catch ( CoreException e )
    {

    }
}
项目:birt    文件:ScriptDebugTarget.java   
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( ) );
        }
    }
}
项目:Pydev    文件:AbstractBreakpointRulerAction.java   
/**
 * @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;
    }
}
项目:Pydev    文件:EnableDisableBreakpointRulerAction.java   
@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);
        }
    }
}
项目:Pydev    文件:EnableDisableBreakpointRulerAction.java   
@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();
    }
}
项目:EclipseTracer    文件:ToggleTrackingActionDelegate.java   
@Override
public void run() {
    IBreakpoint breakpoint = getBreakpoint();
    if (fBreakpoint != null) {
        AbstractBreakpoint watchPoint = wpMgr.getBreakpoint(breakpoint);            
        if (watchPoint != null) {
            watchPoint.setTrackingActive(!watchPoint.isTrackingActive());
        }
        else if (fBreakpoint instanceof IJavaWatchpoint){
            wpMgr.createWatchpoint((IJavaWatchpoint)fBreakpoint, true);
        }
        else if (fBreakpoint instanceof IJavaLineBreakpoint){
            wpMgr.createBreakpoint((IJavaLineBreakpoint)fBreakpoint, true);
        }
    }
}
项目:gemoc-studio-modeldebugging    文件:DSLEclipseDebugIntegration.java   
/**
 * Initializes {@link DSLEclipseDebugIntegration#SUPPORTED_TYPES}.
 * 
 * @return the {@link Set} of
 *         {@link org.eclipse.emf.common.notify.AdapterFactory#isFactoryForType(Object) supported
 *         types}.
 */
private static Set<Object> initSupportedTypes() {
final Set<Object> res = new HashSet<Object>();

res.add(IThread.class);
res.add(IDebugTarget.class);
res.add(IStackFrame.class);
res.add(IVariable.class);
res.add(IBreakpoint.class);

return res;
}
项目:gemoc-studio-modeldebugging    文件:DSLBreakpoint.java   
@Override
public void setMarker(IMarker marker) throws CoreException {
    super.setMarker(marker);
    try {
        identifier = (String)getMarker().getAttribute(IBreakpoint.ID);
        String attribute = (String)getMarker().getAttribute(EValidator.URI_ATTRIBUTE);
        if (attribute != null) {
            instructionUri = URI.createURI(attribute, true);
        }
    } catch (CoreException e) {
        Activator.getDefault().error(e);
    }

}
项目:gemoc-studio-modeldebugging    文件:DSLDebugTargetAdapter.java   
/**
 * Starts the debugger with a {@link StartRequest}.
 */
public void start() {
    // register as a breakpoint listener
    DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);

    // add current break points
    IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(
            getModelIdentifier());
    for (IBreakpoint breakpoint : breakpoints) {
        breakpointAdded(breakpoint);
    }
    factory.getDebugger().handleEvent(new StartRequest());
}
项目:gemoc-studio-modeldebugging    文件:DSLDebugTargetAdapter.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.debug.core.IBreakpointListener#breakpointRemoved(org.eclipse.debug.core.model.IBreakpoint,
 *      org.eclipse.core.resources.IMarkerDelta)
 */
public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
    if (supportsBreakpoint(breakpoint)) {
        try {
            if (breakpoint.isEnabled()) {
                // TODO EMF representation of breakpoints ?
                final URI uri = ((DSLBreakpoint)breakpoint).getURI();
                factory.getDebugger().handleEvent(new RemoveBreakpointRequest(uri));
            }
        } catch (CoreException e) {
            Activator.getDefault().error(e);
        }
    }
}
项目:gemoc-studio-modeldebugging    文件:AbstractDSLDebugger.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.gemoc.dsl.debug.ide.IDSLDebugger#shouldBreak(org.eclipse.emf.ecore.EObject)
 */
public boolean shouldBreak(EObject instruction) {
    final boolean res;

    res = getBreakpointAttributes(instruction, IBreakpoint.ENABLED) == Boolean.TRUE;

    return res;
}
项目:gemoc-studio-modeldebugging    文件:AbstractDSLDebuggerServices.java   
/**
 * Installs this {@link IBreakpointListener}.
 */
public void install() {
    DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);
    for (IBreakpoint breakpoint : DebugPlugin.getDefault().getBreakpointManager().getBreakpoints()) {
        if (breakpoint instanceof DSLBreakpoint) {
            addBreakpoint((DSLBreakpoint)breakpoint);
        }
    }
}
项目:gemoc-studio-modeldebugging    文件:AbstractDSLDebuggerServices.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.debug.core.IBreakpointListener#breakpointAdded(org.eclipse.debug.core.model.IBreakpoint)
 */
public void breakpointAdded(IBreakpoint breakpoint) {
    if (breakpoint instanceof DSLBreakpoint) {
        addBreakpoint((DSLBreakpoint)breakpoint);
        final DSLBreakpoint dslBreakpoint = (DSLBreakpoint)breakpoint;
        final Set<URI> instructionURIs = new HashSet<URI>();
        instructionURIs.add(dslBreakpoint.getURI());
        notifySirius(instructionURIs, dslBreakpoint.getModelIdentifier());
    }
}
项目:gemoc-studio-modeldebugging    文件:AbstractDSLDebuggerServices.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.debug.core.IBreakpointListener#breakpointRemoved(org.eclipse.debug.core.model.IBreakpoint,
 *      org.eclipse.core.resources.IMarkerDelta)
 */
public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
    if (breakpoint instanceof DSLBreakpoint) {
        removeBreakpoint((DSLBreakpoint)breakpoint);
        final DSLBreakpoint dslBreakpoint = (DSLBreakpoint)breakpoint;
        final Set<URI> instructionURIs = new HashSet<URI>();
        instructionURIs.add(dslBreakpoint.getURI());
        notifySirius(instructionURIs, dslBreakpoint.getModelIdentifier());
    }
}