Package org.eclipse.jdt.internal.debug.eval

Examples of org.eclipse.jdt.internal.debug.eval.EvaluationResult


      // don't queue explicit evaluation if the thread is all ready
      // performing an evaluation.
      if (thread.isSuspended() && ((JDIThread) thread).isInvokingMethod()
          || thread.isPerformingEvaluation()
          && evaluationDetail == DebugEvent.EVALUATION) {
        EvaluationResult result = new EvaluationResult(this,
            expression.getSnippet(), thread);
        result.addError(EvaluationEngineMessages.ASTEvaluationEngine_Cannot_perform_nested_evaluations);
        listener.evaluationComplete(result);
        return;
      }
      thread.queueRunnable(new EvalRunnable(
          (InstructionSequence) expression, thread, context,
View Full Code Here


        }
        buf.append(" Hit Breakpoints: "); //$NON-NLS-1$
        buf.append(fHitBreakpoints);
        JDIDebugOptions.trace(buf.toString());
      }
      EvaluationResult result = new EvaluationResult(
          ASTEvaluationEngine.this, fExpression.getSnippet(), fThread);
      if (fExpression.hasErrors()) {
        String[] errors = fExpression.getErrorMessages();
        for (String error : errors) {
          result.addError(error);
        }
        evaluationFinished(result);
        if (JDIDebugOptions.DEBUG_AST_EVAL) {
          StringBuffer buf = new StringBuffer();
          buf.append("\tErrors: "); //$NON-NLS-1$
          for (int i = 0; i < errors.length; i++) {
            if (i > 0) {
              buf.append('\n');
            }
            buf.append("\t\t"); //$NON-NLS-1$
            buf.append(errors[i]);
          }
          JDIDebugOptions.trace(buf.toString());
        }
        return;
      }
      final Interpreter interpreter = new Interpreter(fExpression,
          fContext);

      class EvaluationRunnable implements IEvaluationRunnable, ITerminate {

        CoreException fException;
        boolean fTerminated = false;

        public void run(IJavaThread jt, IProgressMonitor pm) {
          EventFilter filter = new EventFilter();
          try {
            DebugPlugin.getDefault().addDebugEventFilter(filter);
            interpreter.execute();
          } catch (CoreException exception) {
            fException = exception;
            if (fEvaluationDetail == DebugEvent.EVALUATION
                && exception.getStatus().getException() instanceof InvocationException) {
              // print the stack trace for the exception if an
              // *explicit* evaluation
              InvocationException invocationException = (InvocationException) exception
                  .getStatus().getException();
              ObjectReference exObject = invocationException
                  .exception();
              IJavaObject modelObject = (IJavaObject) JDIValue
                  .createValue(
                      (JDIDebugTarget) getDebugTarget(),
                      exObject);
              try {
                modelObject
                    .sendMessage(
                        "printStackTrace", "()V", null, jt, false); //$NON-NLS-1$ //$NON-NLS-2$
              } catch (DebugException e) {
                // unable to print stack trace
              }
            }
          } finally {
            DebugPlugin.getDefault().removeDebugEventFilter(filter);
          }
        }

        public void terminate() {
          fTerminated = true;
          interpreter.stop();
        }

        public boolean canTerminate() {
          return true;
        }

        public boolean isTerminated() {
          return false;
        }

        public CoreException getException() {
          return fException;
        }
      }

      EvaluationRunnable er = new EvaluationRunnable();
      CoreException exception = null;
      long start = System.currentTimeMillis();
      try {
        fThread.runEvaluation(er, null, fEvaluationDetail,
            fHitBreakpoints);
      } catch (DebugException e) {
        exception = e;
      }
      long end = System.currentTimeMillis();

      IJavaValue value = interpreter.getResult();

      if (exception == null) {
        exception = er.getException();
      }

      result.setTerminated(er.fTerminated);
      if (exception != null) {
        if (JDIDebugOptions.DEBUG_AST_EVAL) {
          StringBuffer buf = new StringBuffer();
          buf.append("\tException: "); //$NON-NLS-1$
          buf.append(exception.toString());
          JDIDebugOptions.trace(buf.toString());
        }
        if (exception instanceof DebugException) {
          result.setException((DebugException) exception);
        } else {
          result.setException(new DebugException(exception
              .getStatus()));
        }
      } else {
        if (value != null) {
          result.setValue(value);
          if (JDIDebugOptions.DEBUG_AST_EVAL) {
            StringBuffer buf = new StringBuffer();
            buf.append("\tResult: "); //$NON-NLS-1$
            buf.append(value);
            JDIDebugOptions.trace(buf.toString());
          }
        } else {
          result.addError(EvaluationEngineMessages.ASTEvaluationEngine_An_unknown_error_occurred_during_evaluation);
        }
      }

      if (JDIDebugOptions.DEBUG_AST_EVAL) {
        StringBuffer buf = new StringBuffer();
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.debug.eval.EvaluationResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.