/** * Change the current error reporter. * * @return the previous error reporter * @see org.mozilla.javascript.ErrorReporter */ public final ErrorReporter setErrorReporter(ErrorReporter reporter) { if (sealed) onSealedMutation(); if (reporter == null) throw new IllegalArgumentException(); ErrorReporter old = getErrorReporter(); if (reporter == old) { return old; } Object listeners = propertyListeners; if (listeners != null) { firePropertyChangeImpl(listeners, errorReporterProperty, old, reporter); } this.errorReporter = reporter; return old; }
/** * Change the current error reporter. * * @return the previous error reporter * @see org.mozilla.javascript.ErrorReporter */ public final ErrorReporter setErrorReporter(ErrorReporter reporter) { if (sealed) onSealedMutation(); if (reporter == null) throw new IllegalArgumentException(); ErrorReporter old = getErrorReporter(); if (reporter == old) { return old; } Object listeners = propertyListeners; if (listeners != null) { firePropertyChangeImpl(listeners, errorReporterProperty, old, reporter); } this.errorReporter = reporter; return old; }
private static Script compile(Context cx, String source) { int[] linep = { 0 }; String filename = Context.getSourcePositionFromStack(linep); if (filename == null) { filename = "<Script object>"; linep[0] = 1; } ErrorReporter reporter; reporter = DefaultErrorReporter.forEval(cx.getErrorReporter()); return cx.compileString(source, null, reporter, filename, linep[0], null); }
private static Script compile(Context cx, String source) { int[] linep = { 0 }; String filename = Context.getSourcePositionFromStack(linep); if (filename == null) { filename = "<Script object>"; linep[0] = 1; } ErrorReporter reporter; reporter = DefaultErrorReporter.forEval(cx.getErrorReporter()); return cx.compileString(source, null, reporter, filename, linep[0], null); }
private static Script compile(Context cx, String source) { int[] linep = { 0 }; String filename = Context.getSourcePositionFromStack(linep); if (filename == null) { filename = "<Script object>"; linep[0] = 1; } ErrorReporter reporter; reporter = DefaultErrorReporter.forEval(cx.getErrorReporter()); return cx.compileString(source, null, reporter, filename, linep[0], null); }
private static Script compile(Context cx, String source) { int[] linep = { 0 }; String filename = Context.getSourcePositionFromStack(linep); if (filename == null) { filename = "<Script object>"; linep[0] = 1; } ErrorReporter reporter; reporter = DefaultErrorReporter.forEval(cx.getErrorReporter()); return cx.compileString(source, null, reporter, filename, linep[0], null); }
private static Script compile(Context cx, String source) { int[] linep = { 0 }; String filename = Context.getSourcePositionFromStack(linep); if (filename == null) { filename = "<Script object>"; linep[0] = 1; } ErrorReporter reporter; reporter = DefaultErrorReporter.forEval(cx.getErrorReporter()); return cx.compileString(source, null, reporter, filename, linep[0], null); }
private static Script compile(Context cx, String source) { int[] linep = { 0 }; String filename = Context.getSourcePositionFromStack(linep); if (filename == null) { filename = "<Script object>"; linep[0] = 1; } ErrorReporter reporter; reporter = DefaultErrorReporter.forEval(cx.getErrorReporter()); return cx.compileString(source, null, reporter, filename, linep[0], null); }
public static void warn(Context cx, Scriptable thisObj, Object[] args, Function funObj) { String message = Context.toString( args[ 0 ] ); int line = (int) Context.toNumber( args[ 1 ] ); String source = Context.toString( args[ 2 ] ); int column = (int) Context.toNumber( args[ 3 ] ); cx.getErrorReporter().warning( message, null, line, source, column ); }
/** * Report a warning using the error reporter for the current thread. * * @param message the warning message to report * @param sourceName a string describing the source, such as a filename * @param lineno the starting line number * @param lineSource the text of the line (may be null) * @param lineOffset the offset into lineSource where problem was detected * @see org.mozilla.javascript.ErrorReporter */ public static void reportWarning(String message, String sourceName, int lineno, String lineSource, int lineOffset) { Context cx = Context.getContext(); if (cx.hasFeature(FEATURE_WARNING_AS_ERROR)) reportError(message, sourceName, lineno, lineSource, lineOffset); else cx.getErrorReporter().warning(message, sourceName, lineno, lineSource, lineOffset); }
/** * Report a warning using the error reporter for the current thread. * * @param message the warning message to report * @param sourceName a string describing the source, such as a filename * @param lineno the starting line number * @param lineSource the text of the line (may be null) * @param lineOffset the offset into lineSource where problem was detected * @see org.mozilla.javascript.ErrorReporter */ public static void reportWarning(String message, String sourceName, int lineno, String lineSource, int lineOffset) { Context cx = Context.getContext(); if (cx.hasFeature(FEATURE_WARNING_AS_ERROR)) reportError(message, sourceName, lineno, lineSource, lineOffset); else cx.getErrorReporter().warning(message, sourceName, lineno, lineSource, lineOffset); }
public static void processFileNoThrow(Context cx, Scriptable scope, String filename) { try { processFile(cx, scope, filename); } catch (IOException ioex) { Context.reportError(ToolErrorReporter.getMessage( "msg.couldnt.read.source", filename, ioex.getMessage())); exitCode = EXITCODE_FILE_NOT_FOUND; } catch (RhinoException rex) { ToolErrorReporter.reportException( cx.getErrorReporter(), rex); exitCode = EXITCODE_RUNTIME_ERROR; } catch (VirtualMachineError ex) { // Treat StackOverflow and OutOfMemory as runtime errors ex.printStackTrace(); String msg = ToolErrorReporter.getMessage( "msg.uncaughtJSException", ex.toString()); Context.reportError(msg); exitCode = EXITCODE_RUNTIME_ERROR; } }
public static void processFileNoThrow(Context cx, Scriptable scope, String filename) { try { processFile(cx, scope, filename); } catch (IOException ioex) { Context.reportError(ToolErrorReporter.getMessage( "msg.couldnt.read.source", filename, ioex.getMessage())); exitCode = EXITCODE_FILE_NOT_FOUND; } catch (RhinoException rex) { ToolErrorReporter.reportException( cx.getErrorReporter(), rex); exitCode = EXITCODE_RUNTIME_ERROR; } catch (VirtualMachineError ex) { // Treat StackOverflow and OutOfMemory as runtime errors ex.printStackTrace(); String msg = ToolErrorReporter.getMessage( "msg.uncaughtJSException", ex.toString()); Context.reportError(msg); exitCode = EXITCODE_RUNTIME_ERROR; } }
static void evalInlineScript(Context cx, String scriptText) { try { Script script = cx.compileString(scriptText, "<command>", 1, null); if (script != null) { script.exec(cx, getShellScope()); } } catch (RhinoException rex) { ToolErrorReporter.reportException( cx.getErrorReporter(), rex); exitCode = EXITCODE_RUNTIME_ERROR; } catch (VirtualMachineError ex) { // Treat StackOverflow and OutOfMemory as runtime errors ex.printStackTrace(); String msg = ToolErrorReporter.getMessage( "msg.uncaughtJSException", ex.toString()); Context.reportError(msg); exitCode = EXITCODE_RUNTIME_ERROR; } }
static void evalInlineScript(Context cx, String scriptText) { try { Script script = cx.compileString(scriptText, "<command>", 1, null); if (script != null) { script.exec(cx, getShellScope()); } } catch (RhinoException rex) { ToolErrorReporter.reportException( cx.getErrorReporter(), rex); exitCode = EXITCODE_RUNTIME_ERROR; } catch (VirtualMachineError ex) { // Treat StackOverflow and OutOfMemory as runtime errors ex.printStackTrace(); String msg = ToolErrorReporter.getMessage( "msg.uncaughtJSException", ex.toString()); Context.reportError(msg); exitCode = EXITCODE_RUNTIME_ERROR; } }
public void initFromContext(Context cx) { setErrorReporter(cx.getErrorReporter()); this.languageVersion = cx.getLanguageVersion(); useDynamicScope = cx.compileFunctionsWithDynamicScopeFlag; generateDebugInfo = (!cx.isGeneratingDebugChanged() || cx.isGeneratingDebug()); reservedKeywordAsIdentifier = cx.hasFeature(Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER); allowMemberExprAsFunctionName = cx.hasFeature(Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME); strictMode = cx.hasFeature(Context.FEATURE_STRICT_MODE); warningAsError = cx.hasFeature(Context.FEATURE_WARNING_AS_ERROR); xmlAvailable = cx.hasFeature(Context.FEATURE_E4X); optimizationLevel = cx.getOptimizationLevel(); generatingSource = cx.isGeneratingSource(); activationNames = cx.activationNames; }
public void initFromContext(Context cx) { setErrorReporter(cx.getErrorReporter()); languageVersion = cx.getLanguageVersion(); generateDebugInfo = (!cx.isGeneratingDebugChanged() || cx.isGeneratingDebug()); reservedKeywordAsIdentifier = cx.hasFeature(Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER); allowMemberExprAsFunctionName = cx.hasFeature(Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME); strictMode = cx.hasFeature(Context.FEATURE_STRICT_MODE); warningAsError = cx.hasFeature(Context.FEATURE_WARNING_AS_ERROR); xmlAvailable = cx.hasFeature(Context.FEATURE_E4X); optimizationLevel = cx.getOptimizationLevel(); generatingSource = cx.isGeneratingSource(); activationNames = cx.activationNames; // Observer code generation in compiled code : generateObserverCount = cx.generateObserverCount; }
public void initFromContext(Context cx) { setErrorReporter(cx.getErrorReporter()); languageVersion = cx.getLanguageVersion(); generateDebugInfo = (!cx.isGeneratingDebugChanged() || cx.isGeneratingDebug()); reservedKeywordAsIdentifier = cx.hasFeature(Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER); allowMemberExprAsFunctionName = cx.hasFeature(Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME); strictMode = cx.hasFeature(Context.FEATURE_STRICT_MODE); warningAsError = cx.hasFeature(Context.FEATURE_WARNING_AS_ERROR); xmlAvailable = cx.hasFeature(Context.FEATURE_E4X); optimizationLevel = cx.getOptimizationLevel(); generatingSource = cx.isGeneratingSource(); activationNames = cx.activationNames; // Observer code generation in compiled code : generateObserverCount = cx.generateObserverCount; }
public void initFromContext(Context cx) { setErrorReporter(cx.getErrorReporter()); this.languageVersion = cx.getLanguageVersion(); useDynamicScope = cx.compileFunctionsWithDynamicScopeFlag; generateDebugInfo = (!cx.isGeneratingDebugChanged() || cx.isGeneratingDebug()); reservedKeywordAsIdentifier = cx.hasFeature(Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER); allowMemberExprAsFunctionName = cx.hasFeature(Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME); strictMode = cx.hasFeature(Context.FEATURE_STRICT_MODE); warningAsError = cx.hasFeature(Context.FEATURE_WARNING_AS_ERROR); xmlAvailable = cx.hasFeature(Context.FEATURE_E4X); optimizationLevel = cx.getOptimizationLevel(); generatingSource = cx.isGeneratingSource(); activationNames = cx.activationNames; // Observer code generation in compiled code : generateObserverCount = cx.generateObserverCount; }
public void initFromContext(Context cx) { setErrorReporter(cx.getErrorReporter()); languageVersion = cx.getLanguageVersion(); generateDebugInfo = (!cx.isGeneratingDebugChanged() || cx.isGeneratingDebug()); reservedKeywordAsIdentifier = cx.hasFeature(Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER); allowMemberExprAsFunctionName = cx.hasFeature(Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME); strictMode = cx.hasFeature(Context.FEATURE_STRICT_MODE); warningAsError = cx.hasFeature(Context.FEATURE_WARNING_AS_ERROR); xmlAvailable = cx.hasFeature(Context.FEATURE_E4X); optimizationLevel = cx.getOptimizationLevel(); generatingSource = cx.isGeneratingSource(); activationNames = cx.activationNames; // Observer code generation in compiled code : generateObserverCount = cx.generateObserverCount; }