/*
   * (non-Javadoc)
   *
   * @see org.eclipse.e4.languages.javascript.jsdi.ThreadReference#frames()
   */
  public synchronized List frames() {
    if (!suspended || status == THREAD_STATUS_ZOMBIE) return Collections.EMPTY_LIST;

    if (frames != null) return frames;

    Request request = new Request(JSONConstants.FRAMES);
    request.getArguments().put(JSONConstants.THREAD_ID, threadId);
    try {
      Response response = vm.sendRequest(request, 30000);
      List frameIds = (List) response.getBody().get(JSONConstants.FRAMES);
      if (frameIds.isEmpty()) {
        frames = Collections.EMPTY_LIST;
        return frames;
      }
      frames = new ArrayList();
      for (Iterator iterator = frameIds.iterator(); iterator.hasNext(); ) {
        Long frameId = new Long(((Number) iterator.next()).longValue());
        StackFrameReferenceImpl frame = createStackFrame(frameId);
        frames.add(frame);
      }
    } catch (DisconnectException e) {
      e.printStackTrace();
    } catch (TimeoutException e) {
      e.printStackTrace();
    }
    return frames;
  }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.e4.languages.javascript.jsdi.ThreadReference#suspend()
  */
 public void suspend() {
   if (status == THREAD_STATUS_ZOMBIE) {
     return;
   }
   Request request = new Request(JSONConstants.SUSPEND);
   request.getArguments().put(JSONConstants.THREAD_ID, threadId);
   try {
     vm.sendRequest(request, 30000);
   } catch (DisconnectException e) {
     e.printStackTrace();
   } catch (TimeoutException e) {
     e.printStackTrace();
   }
 }
 /**
  * Sends a request to make a new {@link StackFrameReference} in the current debugger. Returns a
  * new {@link StackFrameReference} on success, <code>null</code> on failure
  *
  * @param frameId
  * @return a new {@link StackFrameReference} or <code>null</code>
  */
 private StackFrameReferenceImpl createStackFrame(Long frameId) {
   Request request = new Request(JSONConstants.FRAME);
   request.getArguments().put(JSONConstants.THREAD_ID, threadId);
   request.getArguments().put(JSONConstants.FRAME_ID, frameId);
   try {
     Response response = vm.sendRequest(request, 30000);
     Map jsonFrame = (Map) response.getBody().get(JSONConstants.FRAME);
     return new StackFrameReferenceImpl(vm, jsonFrame);
   } catch (DisconnectException e) {
     e.printStackTrace();
   } catch (TimeoutException e) {
     e.printStackTrace();
   }
   return null;
 }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.e4.languages.javascript.jsdi.ThreadReference#resume()
  */
 public synchronized void resume() {
   if (status == THREAD_STATUS_ZOMBIE) {
     return;
   }
   Request request = new Request(JSONConstants.CONTINUE);
   request.getArguments().put(JSONConstants.THREAD_ID, threadId);
   if (step != null) {
     request.getArguments().put(JSONConstants.STEP, step);
   }
   try {
     Response response = vm.sendRequest(request, 30000);
     if (response.isSuccess()) {
       step = null;
       frames = null;
       suspended = false;
       atBreakpoint = false;
     }
   } catch (DisconnectException e) {
     e.printStackTrace();
   } catch (TimeoutException e) {
     e.printStackTrace();
   }
 }