use of com.oracle.truffle.tools.chromeinspector.types.RemoteObject.TypeMark in project graal by oracle.
the class InspectorRuntime method getProperties.
@Override
public Params getProperties(String objectId, boolean ownProperties, boolean accessorPropertiesOnly, boolean generatePreview) throws CommandProcessException {
if (objectId == null) {
throw new CommandProcessException("An objectId required.");
}
RemoteObject object = context.getRemoteObjectsHandler().getRemote(objectId);
String objectGroup = context.getRemoteObjectsHandler().getObjectGroupOf(objectId);
JSONObject json = new JSONObject();
if (object != null) {
DebugValue value = object.getDebugValue();
RemoteObject.IndexRange indexRange = object.getIndexRange();
try {
if (value != null) {
context.executeInSuspendThread(new SuspendThreadExecutable<Void>() {
@Override
public Void executeCommand() throws CommandProcessException {
TypeMark typeMark = object.getTypeMark();
if (typeMark != null) {
switch(typeMark) {
case MAP_ENTRIES:
putMapEntries(json, value, indexRange, generatePreview, objectGroup);
break;
case MAP_ENTRY:
putMapEntry(json, value, generatePreview, objectGroup);
break;
default:
throw new CommandProcessException("Unknown type mark " + typeMark);
}
return null;
}
Collection<DebugValue> properties = null;
if (!value.hasHashEntries()) {
properties = value.getProperties();
}
if (properties == null) {
properties = Collections.emptyList();
} else if (indexRange != null && indexRange.isNamed()) {
List<DebugValue> list = new ArrayList<>(properties);
properties = list.subList(indexRange.start(), indexRange.end());
}
Collection<DebugValue> array;
if (!value.isArray()) {
array = Collections.emptyList();
} else if (indexRange != null && !indexRange.isNamed()) {
List<DebugValue> arr = value.getArray();
array = arr.subList(indexRange.start(), indexRange.end());
} else {
array = value.getArray();
}
putResultProperties(json, value, properties, array, generatePreview, objectGroup);
return null;
}
@Override
public Void processException(DebugException ex) {
fillExceptionDetails(json, ex);
return null;
}
});
} else {
final DebugScope scope = object.getScope();
context.executeInSuspendThread(new SuspendThreadExecutable<Void>() {
@Override
public Void executeCommand() throws CommandProcessException {
Collection<DebugValue> properties = new ArrayList<>();
DebugValue scopeReceiver = object.getScopeReceiver();
if (scopeReceiver != null) {
properties.add(scopeReceiver);
}
for (DebugValue p : scope.getDeclaredValues()) {
properties.add(p);
}
putResultProperties(json, null, properties, Collections.emptyList(), generatePreview, objectGroup);
return null;
}
@Override
public Void processException(DebugException ex) {
fillExceptionDetails(json, ex);
return null;
}
});
}
} catch (NoSuspendedThreadException ex) {
// Not suspended, no properties
json.put("result", new JSONArray());
}
}
return new Params(json);
}
Aggregations