/** * Return the version of jslint in use. */ public String getEdition() { return (String) lintFunc.get("edition", lintFunc); }
public Object get(int index, Scriptable start) { return this.delegate.get(index, start); }
public Object get(String name, Scriptable start) { return this.delegate.get(name, start); }
public Object get(String name, Scriptable start) { return this.delegate.get(name, start); }
public Object get(int index, Scriptable start) { return this.delegate.get(index, start); }
public Object get(String name, Scriptable start) { return this.delegate.get(name, start); }
public Object get(int index, Scriptable start) { return this.delegate.get(index, start); }
private List<Issue> readErrors(String systemId) { ArrayList<Issue> issues = new ArrayList<Issue>(); Scriptable errors = (Scriptable) lintFunc.get("errors", lintFunc); int count = Util.intValue("length", errors); for (int i = 0; i < count; i++) { Scriptable err = (Scriptable) errors.get(i, errors); // JSLINT spits out a null when it cannot proceed. // TODO Should probably turn i-1th issue into a "fatal". if (err != null) { issues.add(IssueBuilder.fromJavaScript(systemId, err)); } } return issues; }
private List<Error> lint(Context cx, Scriptable scope, String source, String options) { List<Error> errors = new ArrayList<Error>(); Function jsHintFunction = (Function) scope.get("JSHINT", scope); Object jsHintOptions = options == null ? null : cx.evaluateString(scope, "options = " + options, null, 1, null); jsHintFunction.call(cx, scope, scope, new Object[] { source, jsHintOptions }); @SuppressWarnings("unchecked") List<Map<String, ?>> jsErrors = (List<Map<String, ?>>) jsHintFunction.get("errors", jsHintFunction); for (Map<String, ?> jsError : jsErrors) { if (jsError != null) { errors.add(toError(jsError)); } } return errors; }
private static void js_captureStackTrace(Context cx, Scriptable thisObj, Object[] args) { ScriptableObject obj = (ScriptableObject)ScriptRuntime.toObjectOrNull(cx, args[0], thisObj); Function func = null; if (args.length > 1) { func = (Function)ScriptRuntime.toObjectOrNull(cx, args[1], thisObj); } // Create a new error that will have the correct prototype so we can re-use "getStackTrace" NativeError err = (NativeError)cx.newObject(thisObj, "Error"); // Wire it up so that it will have an actual exception with a stack trace err.setStackProvider(new EvaluatorException("[object Object]")); // Figure out if they passed a function used to hide part of the stack if (func != null) { Object funcName = func.get("name", func); if ((funcName != null) && !Undefined.instance.equals(funcName)) { err.associateValue(STACK_HIDE_KEY, Context.toString(funcName)); } } // Define a property on the specified object to get that stack // that delegates to our new error. Build the stack trace lazily // using the "getStack" code from NativeError. obj.defineProperty("stack", err, ERROR_DELEGATE_GET_STACK, ERROR_DELEGATE_SET_STACK, 0); }