本文整理汇总了Java中org.mozilla.javascript.CompilerEnvirons.setErrorReporter方法的典型用法代码示例。如果您正苦于以下问题:Java CompilerEnvirons.setErrorReporter方法的具体用法?Java CompilerEnvirons.setErrorReporter怎么用?Java CompilerEnvirons.setErrorReporter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mozilla.javascript.CompilerEnvirons
的用法示例。
在下文中一共展示了CompilerEnvirons.setErrorReporter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.mozilla.javascript.CompilerEnvirons; //导入方法依赖的package包/类
private AstRoot parse(String string, boolean jsdoc) {
CompilerEnvirons environment = new CompilerEnvirons();
TestErrorReporter testErrorReporter = new TestErrorReporter(null, null);
environment.setErrorReporter(testErrorReporter);
environment.setRecordingComments(true);
environment.setRecordingLocalJsDocComments(jsdoc);
Parser p = new Parser(environment, testErrorReporter);
AstRoot script = p.parse(string, null, 0);
assertTrue(testErrorReporter.hasEncounteredAllErrors());
assertTrue(testErrorReporter.hasEncounteredAllWarnings());
return script;
}
示例2: parseAsReader
import org.mozilla.javascript.CompilerEnvirons; //导入方法依赖的package包/类
private AstRoot parseAsReader(String string) throws IOException {
CompilerEnvirons environment = new CompilerEnvirons();
TestErrorReporter testErrorReporter = new TestErrorReporter(null, null);
environment.setErrorReporter(testErrorReporter);
environment.setRecordingComments(true);
environment.setRecordingLocalJsDocComments(true);
Parser p = new Parser(environment, testErrorReporter);
AstRoot script = p.parse(new StringReader(string), null, 0);
assertTrue(testErrorReporter.hasEncounteredAllErrors());
assertTrue(testErrorReporter.hasEncounteredAllWarnings());
return script;
}
示例3: scan
import org.mozilla.javascript.CompilerEnvirons; //导入方法依赖的package包/类
/**
* Scan the given file for class definitions and accumulate dependencies.
*/
private void scan(final File source) throws IOException {
log.debug("Scanning: " + source);
ErrorReporter errorReporter = new LogErrorReporter(log);
CompilerEnvirons env = new CompilerEnvirons();
env.setErrorReporter(errorReporter);
Parser parser = new Parser(env, errorReporter);
Reader reader = new BufferedReader(new FileReader(source));
try {
AstRoot root = parser.parse(reader, source.getAbsolutePath(), 0);
DependencyAccumulator visitor = new DependencyAccumulator(source);
root.visit(visitor);
// complain if no def was found in this source
if (visitor.current == null) {
log.warn("No class definition was found while processing: " + source);
}
}
finally {
reader.close();
}
}
示例4: createCompilerEnvironment
import org.mozilla.javascript.CompilerEnvirons; //导入方法依赖的package包/类
/**
* Creates options for Rhino based off of the user's preferences.
*
* @param errorHandler The container for errors found while parsing.
* @return The properties for the JS compiler to use.
*/
public static CompilerEnvirons createCompilerEnvironment(ErrorReporter
errorHandler, JavaScriptLanguageSupport langSupport) {
CompilerEnvirons env = new CompilerEnvirons();
env.setErrorReporter(errorHandler);
env.setIdeMode(true);
env.setRecordingComments(true);
env.setRecordingLocalJsDocComments(true);
env.setRecoverFromErrors(true);
if(langSupport != null) {
env.setXmlAvailable(langSupport.isXmlAvailable());
env.setStrictMode(langSupport.isStrictMode());
int version = langSupport.getLanguageVersion();
if (version > 0) {
Logger.log("[JavaScriptParser]: JS language version set to: " + version);
env.setLanguageVersion(version);
}
}
return env;
}