Package com.google.collide.client.code.debugging.DebuggerApiTypes

Examples of com.google.collide.client.code.debugging.DebuggerApiTypes.RemoteObject


        || "Infinity".equals(description)
        || "-Infinity".equals(description);
  }

  public static RemoteObject createRemoteObject(final String value) {
    return new RemoteObject() {

      @Override
      public String getDescription() {
        return value;
      }
View Full Code Here


        }
      } else if (response.getNewName() == null) {
        // The property was removed.
        removeRemoteObjectNode(child);
      } else {
        RemoteObject newValue =
            response.isValueChanged() ? response.getValue() : child.getRemoteObject();
        RemoteObjectNode newChild =
            new RemoteObjectNode.Builder(response.getNewName(), newValue, child).build();

        // We could be replacing onto an existing child. If so, delete it first.
View Full Code Here

    if (root == null) {
      return;
    }

    String expression = response.getExpression();
    RemoteObject result = response.getResult();

    JsonArray<RemoteObjectNode> children = root.getChildren();
    for (int i = 0, n = children.size(); i < n; ++i) {
      RemoteObjectNode child = children.get(i);
      if (!child.isTransient() && child.getName().equals(expression)) {
View Full Code Here

    JsonArray<Scope> scopeChain = callFrame.getScopeChain();
    for (int i = 0, n = scopeChain.size(); i < n; ++i) {
      Scope scope = scopeChain.get(i);
      String name = StringUtils.capitalizeFirstLetter(scope.getType().toString());
      RemoteObject remoteObject = scope.getObject();

      RemoteObjectNode.Builder scopeNodeBuilder = new RemoteObjectNode.Builder(name, remoteObject)
          .setOrderIndex(i)
          .setWritable(false)
          .setDeletable(false)
View Full Code Here

    }
    return "";
  }

  private static String getPropertyValueAsString(RemoteObjectNode node) {
    RemoteObject remoteObject = node.getRemoteObject();
    if (remoteObject == null) {
      return "";
    }
    if (node.wasThrown()) {
      return "[Exception: " + remoteObject.getDescription() + "]";
    }
    if (node.isTransient()) {
      // Just put some UI difference for the transient objects.
      return "";
    }
    if (RemoteObjectType.STRING.equals(remoteObject.getType())) {
      return "\""
          + LINE_BREAK_REGEXP.replace(remoteObject.getDescription(), LINE_BREAK_SUBSTITUTE)
          + "\"";
    }
    return remoteObject.getDescription();
  }
View Full Code Here

        boolean isError = evaluationResponse.isError()
            || evaluationParsedResponse == null
            || evaluationParsedResponse.wasThrown()
            || evaluationParsedResponse.getResult() == null;

        final RemoteObject evaluationResult = isError ? null : evaluationParsedResponse.getResult();

        Jso params = Jso.create();
        if (!isError && DebuggerApiUtils.isNonFiniteNumber(evaluationResult)) {
          params.addField("functionDeclaration", "function(a) {"
              + "  this[a] = " + evaluationResult.getDescription() + ";"
              + "  return this[a];"
              + "}");
          params.addField("objectId", remoteObjectId.toString());

          JsonArray<Jso> arguments = JsonCollections.createArray();
          arguments.add(Jso.create());
          arguments.get(0).addField("value", propertyName);

          params.addField("arguments", arguments);
        } else if (!isError) {
          params.addField("functionDeclaration", "function(a, b) { this[a] = b; return this[a]; }");
          params.addField("objectId", remoteObjectId.toString());

          JsonArray<Jso> arguments = JsonCollections.createArray();
          arguments.add(Jso.create());
          arguments.add(Jso.create());
          arguments.get(0).addField("value", propertyName);

          if (evaluationResult.getObjectId() == null) {
            if (!DebuggerApiUtils.addPrimitiveJsoField(
                arguments.get(1), "value", evaluationResult)) {
              isError = true;
            }
          } else {
            arguments.get(1).addField("objectId", evaluationResult.getObjectId().toString());
          }

          params.addField("arguments", arguments);
        }

        if (isError) {
          // We do not know the property value. Just dispatch the error event.
          OnRemoteObjectPropertyChanged parsedResponse =
              DebuggerChromeApiUtils.createOnEditRemoteObjectPropertyResponse(
                  remoteObjectId, propertyName, null, true);
          dispatchOnRemoteObjectPropertyChanged(sessionId, parsedResponse);
          return;
        }

        sendCustomEvent(sessionId, METHOD_RUNTIME_CALL_FUNCTION_ON, params, new Callback() {
          @Override
          public void run(ExtensionResponse response) {
            RemoteObject newValue =
                DebuggerChromeApiUtils.parseCallFunctionOnResult(response.result());
            boolean isError = response.isError()
                || newValue == null
                || !DebuggerApiUtils.equal(evaluationResult, newValue);
            OnRemoteObjectPropertyChanged parsedResponse =
View Full Code Here

  public String getModuleName() {
    return "com.google.collide.client.TestCode";
  }

  public void testAddPrimitiveJsoFieldForNumber() {
    final RemoteObject remoteNumber = new RemoteObjectImpl("123", RemoteObjectType.NUMBER);

    Jso jso = Jso.create();
    assertTrue(DebuggerApiUtils.addPrimitiveJsoField(jso, "key", remoteNumber));

    String serializedJso = Jso.serialize(jso);
View Full Code Here

    String serializedJso = Jso.serialize(jso);
    assertEquals("{\"key1\":true,\"key2\":false}", serializedJso);
  }

  public void testAddPrimitiveJsoFieldForString() {
    final RemoteObject empty = new RemoteObjectImpl("", RemoteObjectType.STRING);
    final RemoteObject nonEmpty = new RemoteObjectImpl("abc", RemoteObjectType.STRING);

    Jso jso = Jso.create();
    assertTrue(DebuggerApiUtils.addPrimitiveJsoField(jso, "key1", empty));
    assertTrue(DebuggerApiUtils.addPrimitiveJsoField(jso, "key2", nonEmpty));
View Full Code Here

    assertTrue(jso.hasOwnProperty("key"));
    assertEquals("{}", serializedJso);
  }

  public void testCastToBooleanForNumber() {
    final RemoteObject zero = new RemoteObjectImpl("0", RemoteObjectType.NUMBER);
    final RemoteObject nonZero = new RemoteObjectImpl("123", RemoteObjectType.NUMBER);
    assertFalse("Zero should cast to false", DebuggerApiUtils.castToBoolean(zero));
    assertTrue("Non-zero should cast to true", DebuggerApiUtils.castToBoolean(nonZero));
  }
View Full Code Here

    assertTrue(DebuggerApiUtils.castToBoolean(BOOLEAN_TRUE_REMOTE_OBJECT));
    assertFalse(DebuggerApiUtils.castToBoolean(BOOLEAN_FALSE_REMOTE_OBJECT));
  }

  public void testCastToBooleanForString() {
    final RemoteObject empty = new RemoteObjectImpl("", RemoteObjectType.STRING);
    final RemoteObject nonEmpty = new RemoteObjectImpl("abc", RemoteObjectType.STRING);
    assertFalse("Empty string should cast to false", DebuggerApiUtils.castToBoolean(empty));
    assertTrue("Non-empty string should cast to true", DebuggerApiUtils.castToBoolean(nonEmpty));
  }
View Full Code Here

TOP

Related Classes of com.google.collide.client.code.debugging.DebuggerApiTypes.RemoteObject

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.