本文整理了Java中org.mozilla.javascript.Context.getErrorReporter()
方法的一些代码示例,展示了Context.getErrorReporter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getErrorReporter()
方法的具体详情如下:
包路径:org.mozilla.javascript.Context
类名称:Context
方法名:getErrorReporter
[英]Get the current error reporter.
[中]获取当前错误报告程序。
代码示例来源:origin: rhino/js
/**
* 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;
}
代码示例来源:origin: geogebra/geogebra
/**
* 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;
}
代码示例来源:origin: rhino/js
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);
}
代码示例来源:origin: ro.isdc.wro4j/rhino
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);
}
代码示例来源:origin: geogebra/geogebra
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);
}
代码示例来源:origin: io.apigee/rhino
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);
}
代码示例来源:origin: com.github.tntim96/rhino
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);
}
代码示例来源:origin: com.sun.phobos/phobos-rhino
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);
}
代码示例来源:origin: org.zkoss.maven/yuicompressor-maven-plugin-zk
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 );
}
代码示例来源:origin: rhino/js
/**
* 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);
}
代码示例来源:origin: io.apigee/rhino
/**
* 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);
}
代码示例来源:origin: ro.isdc.wro4j/rhino
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;
}
}
代码示例来源:origin: com.github.tntim96/rhino
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;
}
}
代码示例来源:origin: ro.isdc.wro4j/rhino
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;
}
}
代码示例来源:origin: com.github.tntim96/rhino
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;
}
}
代码示例来源:origin: com.sun.phobos/phobos-rhino
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;
}
代码示例来源:origin: io.apigee/rhino
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;
}
代码示例来源:origin: com.github.tntim96/rhino
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;
}
代码示例来源:origin: rhino/js
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;
}
代码示例来源:origin: geogebra/geogebra
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;
}
内容来源于网络,如有侵权,请联系作者删除!