public Object execute(final ExecutionEvent event) throws ExecutionException {
    final ISelection selection =
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection();

    if (selection instanceof ITreeSelection) {

      final Object firstElement = ((ITreeSelection) selection).getFirstElement();

      if (firstElement instanceof ErlFunction) {
        final ErlFunction function = (ErlFunction) firstElement;
        final TracePattern tracePattern = new TracePattern(true);
        tracePattern.setFunctionName(function.getFunctionName());
        tracePattern.setModuleName(function.getModule().getModuleName());
        TraceBackend.getInstance().removeTracePattern(tracePattern);
      }
    }
    return null;
  }
Exemplo n.º 2
0
 private void setFunctionTracePatterns() {
   for (final TracePattern tracePattern : tracePatterns) {
     if (tracePattern.isEnabled()) {
       final String function = tracePattern.isLocal() ? FUN_TPL : FUN_TP;
       try {
         OtpErlangObject matchSpec = null;
         if (tracePattern.getMatchSpec().getMsObject() != null) {
           matchSpec = tracePattern.getMatchSpec().getMsObject();
         } else {
           matchSpec = new OtpErlangList();
         }
         if (tracePattern.getArity() < 0) {
           tracerBackend.call(
               Constants.TTB_MODULE,
               function,
               "aax",
               tracePattern.getModuleName(),
               tracePattern.getFunctionName(),
               matchSpec);
         } else {
           tracerBackend.call(
               Constants.TTB_MODULE,
               function,
               "aaxx",
               tracePattern.getModuleName(),
               tracePattern.getFunctionName(),
               new OtpErlangInt(tracePattern.getArity()),
               matchSpec);
         }
       } catch (final RpcException e) {
         ErlLogger.error("Could not add pattern: " + e.getMessage());
       }
     }
   }
 }