use of org.mozilla.javascript.ast.ErrorCollector in project hackpad by dropbox.
the class CompilerEnvirons method ideEnvirons.
/**
* Returns a {@code CompilerEnvirons} suitable for using Rhino
* in an IDE environment. Most features are enabled by default.
* The {@link ErrorReporter} is set to an {@link ErrorCollector}.
*/
public static CompilerEnvirons ideEnvirons() {
CompilerEnvirons env = new CompilerEnvirons();
env.setRecoverFromErrors(true);
env.setRecordingComments(true);
env.setStrictMode(true);
env.setWarnTrailingComma(true);
env.setLanguageVersion(170);
env.setReservedKeywordAsIdentifier(true);
env.setIdeMode(true);
env.setErrorReporter(new ErrorCollector());
return env;
}
use of org.mozilla.javascript.ast.ErrorCollector in project pmd by pmd.
the class EcmascriptParser method parseEcmascript.
protected AstRoot parseEcmascript(final String sourceCode, final List<ParseProblem> parseProblems) throws ParseException {
final CompilerEnvirons compilerEnvirons = new CompilerEnvirons();
compilerEnvirons.setRecordingComments(parserOptions.isRecordingComments());
compilerEnvirons.setRecordingLocalJsDocComments(parserOptions.isRecordingLocalJsDocComments());
compilerEnvirons.setLanguageVersion(parserOptions.getRhinoLanguageVersion().getVersion());
// Scope's don't appear to get set right without this
compilerEnvirons.setIdeMode(true);
compilerEnvirons.setWarnTrailingComma(true);
// see bug #1150 "EmptyExpression" for valid statements!
compilerEnvirons.setReservedKeywordAsIdentifier(true);
// TODO We should do something with Rhino errors...
final ErrorCollector errorCollector = new ErrorCollector();
final Parser parser = new Parser(compilerEnvirons, errorCollector);
// TODO Fix hardcode
final String sourceURI = "unknown";
final int beginLineno = 1;
AstRoot astRoot = parser.parse(sourceCode, sourceURI, beginLineno);
parseProblems.addAll(errorCollector.getErrors());
return astRoot;
}
use of org.mozilla.javascript.ast.ErrorCollector in project HL4A by HL4A.
the class CompilerEnvirons method ideEnvirons.
/**
* Returns a {@code CompilerEnvirons} suitable for using Rhino
* in an IDE environment. Most features are enabled by default.
* The {@link ErrorReporter} is set to an {@link ErrorCollector}.
*/
public static CompilerEnvirons ideEnvirons() {
CompilerEnvirons env = new CompilerEnvirons();
env.setRecoverFromErrors(true);
env.setRecordingComments(true);
env.setStrictMode(true);
env.setWarnTrailingComma(true);
env.setLanguageVersion(170);
env.setReservedKeywordAsIdentifier(true);
env.setIdeMode(true);
env.setErrorReporter(new ErrorCollector());
return env;
}
Aggregations