/**
   * Some specific property filters, to make up for the fact that the enumerable property is not
   * always set correctly.
   *
   * @param descriptor
   * @return
   */
  private boolean shouldFilter(WebkitPropertyDescriptor descriptor) {
    // array fields which are not indexes
    if (isListNonIndex(descriptor)) {
      return true;
    }

    // toString function
    if (descriptor.getValue() != null && descriptor.getValue().isFunction()) {
      if ("toString".equals(descriptor.getName())) {
        return true;
      }
    }

    return false;
  }
  private void createExceptionVariable(WebkitRemoteObject thisObject) {
    DartiumDebugVariable variable =
        new DartiumDebugVariable(
            target, WebkitPropertyDescriptor.createObjectDescriptor(thisObject, "exception"), true);

    variables.add(variable);
  }
 private void createLibraryVariable(WebkitRemoteObject libraryObject) {
   DartiumDebugVariable variable =
       new DartiumDebugVariable(
           target,
           WebkitPropertyDescriptor.createObjectDescriptor(
               libraryObject, DebuggerUtils.TOP_LEVEL_NAME));
   variable.setIsLibraryObject(true);
   variables.add(variable);
 }
  private void collectFields(
      WebkitResult<WebkitPropertyDescriptor[]> results,
      boolean shouldSort,
      boolean collectStatics) {
    boolean gettingStaticFields = false;

    if (!results.isError()) {
      WebkitPropertyDescriptor[] properties = results.getResult();

      if (shouldSort) {
        properties = sort(properties);
      }

      webkitProperties = Arrays.asList(properties);

      for (WebkitPropertyDescriptor descriptor : properties) {
        if (descriptor.isEnumerable()) {
          if (!shouldFilter(descriptor)) {
            DartiumDebugVariable variable = new DartiumDebugVariable(target, descriptor);

            if (parentVariable != null) {
              variable.setParent(parentVariable);
            }

            variables.add(variable);
          }
        } else {
          // Static fields are now shown using the object inspector (Inspect Type...).
          //          if (parentVariable != null && collectStatics) {
          //            if (WebkitPropertyDescriptor.STATIC_FIELDS.equals(descriptor.getName())) {
          //              gettingStaticFields = collectStaticFields(descriptor.getValue(), latch);
          //            }
          //          }
        }
      }
    }

    if (!gettingStaticFields) {
      latch.countDown();
    }
  }
 private boolean isListNonIndex(WebkitPropertyDescriptor descriptor) {
   if (parentVariable != null && parentVariable.isListValue()) {
     try {
       Integer.parseInt(descriptor.getName());
       return false;
     } catch (NumberFormatException nfe) {
       return true;
     }
   } else {
     return false;
   }
 }
  private void collectStaticFieldsResults(
      WebkitResult<WebkitPropertyDescriptor[]> results, CountDownLatch latch) {
    try {
      if (!results.isError()) {
        for (WebkitPropertyDescriptor descriptor : sort(results.getResult())) {
          if (descriptor.isEnumerable()) {
            DartiumDebugVariable variable = new DartiumDebugVariable(target, descriptor);

            variable.setIsStatic(true);

            if (parentVariable != null) {
              variable.setParent(parentVariable);
            }

            variables.add(variable);
          }
        }
      }
    } finally {
      latch.countDown();
    }
  }
 private void createThisVariable(WebkitRemoteObject thisObject) {
   variables.add(
       new DartiumDebugVariable(
           target, WebkitPropertyDescriptor.createObjectDescriptor(thisObject, "this"), true));
 }