@Override public Object[] getAllIds() { if (this == thePrototypeInstance) return super.getAllIds(); return collectIds(); } }
@Override public Object[] getAllIds() { if (this == thePrototypeInstance) return super.getAllIds(); return collectIds(); } }
@Override public int complete(final String buffer, final int cursor, final List<CharSequence> candidates) { final String expr = buffer.substring(buffer.lastIndexOf(' ') + 1); final int dot = expr.lastIndexOf('.') + 1; if (dot > 1) { final String var = expr.substring(0, dot - 1); final String prefix = expr.substring(dot); final Object value = get(var, Repl.this); if (value != NOT_FOUND) { if (value instanceof ScriptableObject) { final Object[] ids = ScriptableObject.class.cast(value).getAllIds(); Arrays.sort(ids); for (final Object id : ids) { if (id instanceof String && String.class.cast(id).startsWith(prefix)) { candidates.add(String.class.cast(id)); } } } if (!candidates.isEmpty()) { return dot; } } } return buffer.length(); } }
@Override public int complete(final String buffer, final int cursor, final List<CharSequence> candidates) { final String expr = buffer.substring(buffer.lastIndexOf(' ') + 1); final int dot = expr.lastIndexOf('.') + 1; if (dot > 1) { final String var = expr.substring(0, dot - 1); final String prefix = expr.substring(dot); final Object value = get(var, Repl.this); if (value != NOT_FOUND) { if (value instanceof ScriptableObject) { final Object[] ids = ScriptableObject.class.cast(value).getAllIds(); Arrays.sort(ids); for (final Object id : ids) { if (id instanceof String && String.class.cast(id).startsWith(prefix)) { candidates.add(String.class.cast(id)); } } } if (!candidates.isEmpty()) { return dot; } } } return buffer.length(); } }
? ((ScriptableObject)obj).getAllIds() : obj.getIds(); String lastPart = names[names.length-1];
? ((ScriptableObject)obj).getAllIds() : obj.getIds(); String lastPart = names[names.length-1];
private static void encode(final StringBuilder s, final ScriptableObject object, final int depth) { s.append('{'); final Object[] ids = object.getAllIds(); if (ids.length > 0) { if (depth > -1) {
private static void encode(final StringBuilder s, final ScriptableObject object, final int depth) { s.append('{'); final Object[] ids = object.getAllIds(); if (ids.length > 0) { if (depth > -1) {
@Override public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { NativeObject newGlobal = new NativeObject(); if (args.length == 1) { ScriptableObject initialContents = (ScriptableObject) args[0]; for (Object o : initialContents.getAllIds()) { String s = (String) o; ScriptableObject.putProperty(newGlobal, s, ScriptableObject.getProperty(initialContents, s)); } } return newGlobal; } }
public String[] getPropertyNames(Object obj) { Context.enter(); try { Object[] ids; if (obj instanceof ScriptableObject) { ids = ((ScriptableObject)obj).getAllIds(); } else { ids = ((Scriptable)obj).getIds(); } String[] result = new String[ids.length]; for (int i = 0; i < result.length; i++) { result[i] = (String)ids[i]; } return result; } finally { Context.exit(); } }
private void findCandidatesInScriptable(Scriptable object, String prefix, List<CharSequence> candidates) { //Gets the candidates related to the current context (last object whose name is complete) Object[] ids = object instanceof ScriptableObject ? ((ScriptableObject) object).getAllIds() : object.getIds(); if (ids != null) { if (logger.isDebugEnabled()) { logger.debug("Ids: {}", Arrays.asList(ids)); } addCandidatesFromScriptable(ids, object, prefix, candidates); logger.debug("Candidates after 1st round: {}", candidates); } if (object.getPrototype() != null && object.getPrototype().getIds() != null) { if (logger.isDebugEnabled()) { logger.debug("Prototype ids: {}", Arrays.asList(object.getPrototype().getIds())); } addCandidatesFromScriptable(object.getPrototype().getIds(), object.getPrototype(), prefix, candidates); logger.debug("Candidates after 2nd round (object prototype): {}", candidates); } }
Object[] ids = obj.getAllIds(); for (int i = 0; i < ids.length; i++) { ids[i] = ScriptRuntime.toString(ids[i]); for (Object name: obj.getAllIds()) { Object configurable = obj.getOwnPropertyDescriptor(cx, name).get("configurable"); if (Boolean.TRUE.equals(configurable)) for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (Boolean.TRUE.equals(desc.get("configurable"))) ScriptableObject obj = ensureScriptableObject(arg); for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (Boolean.TRUE.equals(desc.get("configurable"))) { ScriptableObject obj = ensureScriptableObject(arg); for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (isDataDescriptor(desc) && Boolean.TRUE.equals(desc.get("writable")))
Object[] ids = obj.getAllIds(); for (int i = 0; i < ids.length; i++) { ids[i] = ScriptRuntime.toString(ids[i]); for (Object name: obj.getAllIds()) { Object configurable = obj.getOwnPropertyDescriptor(cx, name).get("configurable"); if (Boolean.TRUE.equals(configurable)) for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (Boolean.TRUE.equals(desc.get("configurable"))) ScriptableObject obj = ensureScriptableObject(arg); for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (Boolean.TRUE.equals(desc.get("configurable"))) { ScriptableObject obj = ensureScriptableObject(arg); for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (isDataDescriptor(desc) && Boolean.TRUE.equals(desc.get("writable")))
Object[] ids = obj.getAllIds(); for (int i = 0; i < ids.length; i++) { ids[i] = ScriptRuntime.toString(ids[i]); for (Object name: obj.getAllIds()) { Object configurable = obj.getOwnPropertyDescriptor(cx, name).get("configurable"); if (Boolean.TRUE.equals(configurable)) for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (Boolean.TRUE.equals(desc.get("configurable"))) ScriptableObject obj = ensureScriptableObject(arg); for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (Boolean.TRUE.equals(desc.get("configurable"))) { ScriptableObject obj = ensureScriptableObject(arg); for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (isDataDescriptor(desc) && Boolean.TRUE.equals(desc.get("writable")))
Object[] ids = obj.getAllIds(); for (int i = 0; i < ids.length; i++) { ids[i] = ScriptRuntime.toString(ids[i]); for (Object name: obj.getAllIds()) { Object configurable = obj.getOwnPropertyDescriptor(cx, name).get("configurable"); if (Boolean.TRUE.equals(configurable)) for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (Boolean.TRUE.equals(desc.get("configurable"))) ScriptableObject obj = ensureScriptableObject(arg); for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (Boolean.TRUE.equals(desc.get("configurable"))) { ScriptableObject obj = ensureScriptableObject(arg); for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (isDataDescriptor(desc) && Boolean.TRUE.equals(desc.get("writable")))