Java 类org.mozilla.javascript.ErrorReporter 实例源码

项目:rhino-android    文件:Bug708801Test.java   
/**
 * Compiles {@code source} and returns the transformed and optimized
 * {@link ScriptNode}
 */
protected ScriptNode compile(CharSequence source) {
    final String mainMethodClassName = "Main";
    final String scriptClassName = "Main";

    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv
            .getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    AstRoot ast = p.parse(source.toString(), "<eval>", 1);
    IRFactory irf = new IRFactory(compilerEnv);
    ScriptNode tree = irf.transformTree(ast);

    Codegen codegen = new Codegen();
    codegen.setMainMethodClass(mainMethodClassName);
    codegen.compileToClassFile(compilerEnv, scriptClassName, tree,
            tree.getEncodedSource(), false);

    return tree;
}
项目:openbravo-brazil    文件:JavaScriptParser.java   
/**
 * @return a tree representation of the parsed JavaScript file
 * @throws IOException
 */
public ScriptOrFnNode parse() throws IOException {

  if (nodeTree == null) {
    Reader reader = new FileReader(jsFile);

    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    ErrorReporter errorReporter = compilerEnv.getErrorReporter();

    Parser parser = new Parser(compilerEnv, errorReporter);

    String sourceURI;

    try {
      sourceURI = jsFile.getCanonicalPath();
    } catch (IOException e) {
      sourceURI = jsFile.toString();
    }

    nodeTree = parser.parse(reader, sourceURI, 1);
  }
  return nodeTree;
}
项目:nexus-public    文件:ClassDefScanner.java   
/**
 * 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();
  }
}
项目:code404    文件:Bug708801Test.java   
/**
 * Compiles {@code source} and returns the transformed and optimized
 * {@link ScriptNode}
 */
protected ScriptNode compile(CharSequence source) {
    final String mainMethodClassName = "Main";
    final String scriptClassName = "Main";

    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv
            .getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    AstRoot ast = p.parse(source.toString(), "<eval>", 1);
    IRFactory irf = new IRFactory(compilerEnv);
    ScriptNode tree = irf.transformTree(ast);

    Codegen codegen = new Codegen();
    codegen.setMainMethodClass(mainMethodClassName);
    codegen.compileToClassFile(compilerEnv, scriptClassName, tree,
            tree.getEncodedSource(), false);

    return tree;
}
项目:rhino-jscover    文件:Bug708801Test.java   
/**
 * Compiles {@code source} and returns the transformed and optimized
 * {@link ScriptNode}
 */
protected ScriptNode compile(CharSequence source) {
    final String mainMethodClassName = "Main";
    final String scriptClassName = "Main";

    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv
            .getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    AstRoot ast = p.parse(source.toString(), "<eval>", 1);
    IRFactory irf = new IRFactory(compilerEnv);
    ScriptNode tree = irf.transformTree(ast);

    Codegen codegen = new Codegen();
    codegen.setMainMethodClass(mainMethodClassName);
    codegen.compileToClassFile(compilerEnv, scriptClassName, tree,
            tree.getEncodedSource(), false);

    return tree;
}
项目:Rhino-Prov-Mod    文件:Bug708801Test.java   
/**
 * Compiles {@code source} and returns the transformed and optimized
 * {@link ScriptNode}
 */
protected ScriptNode compile(CharSequence source) {
    final String mainMethodClassName = "Main";
    final String scriptClassName = "Main";

    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv
            .getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    AstRoot ast = p.parse(source.toString(), "<eval>", 1);
    IRFactory irf = new IRFactory(compilerEnv);
    ScriptNode tree = irf.transformTree(ast);

    Codegen codegen = new Codegen();
    codegen.setMainMethodClass(mainMethodClassName);
    codegen.compileToClassFile(compilerEnv, scriptClassName, tree,
            tree.getEncodedSource(), false);

    return tree;
}
项目:RSTALanguageSupport    文件:JavaScriptParser.java   
/**
 * 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;
}
项目:rhino-android    文件:Bug689314Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:rhino-android    文件:Bug688021Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:rhino-android    文件:Bug688018Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:rhino-android    文件:Bug687669Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:rhino-android    文件:Bug688023Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:rhino-android    文件:Bug689308Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:code404    文件:Bug689314Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:code404    文件:Bug688021Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:code404    文件:Bug688018Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:code404    文件:Bug687669Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:code404    文件:Bug689308Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:OpenSPIFe    文件:AbstractFormulaParsingThing.java   
protected static AstRoot parseIntoTree(String formula) {
    Context cx = Context.enter();

    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();

    Parser parser = new Parser(compilerEnv, compilationErrorReporter);
    AstRoot tree = parser.parse(formula, "(formula being checked by unit-checker)", 0);
    Context.exit();
    return tree;
}
项目:rhino-jscover    文件:Bug689314Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:rhino-jscover    文件:Bug688021Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:rhino-jscover    文件:Bug688018Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:rhino-jscover    文件:Bug687669Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:rhino-jscover    文件:Bug688023Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:rhino-jscover    文件:Bug689308Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:astor    文件:Bug689314Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:astor    文件:Bug688021Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:astor    文件:Bug688018Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:astor    文件:Bug687669Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:astor    文件:Bug689308Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:Rhino-Prov-Mod    文件:Bug689314Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:Rhino-Prov-Mod    文件:Bug688021Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:Rhino-Prov-Mod    文件:Bug688018Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:Rhino-Prov-Mod    文件:Bug687669Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:Rhino-Prov-Mod    文件:Bug688023Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:Rhino-Prov-Mod    文件:Bug689308Test.java   
private AstRoot parse(CharSequence cs) {
    CompilerEnvirons compilerEnv = new CompilerEnvirons();
    compilerEnv.initFromContext(cx);
    ErrorReporter compilationErrorReporter = compilerEnv.getErrorReporter();
    Parser p = new Parser(compilerEnv, compilationErrorReporter);
    return p.parse(cs.toString(), "<eval>", 1);
}
项目:geokettle-2.0    文件:ScriptValuesModDialog.java   
public static ScriptOrFnNode parseVariables(Context cx, Scriptable scope, String source, String sourceName, int lineno, Object securityDomain){
    // Interpreter compiler = new Interpreter();
    CompilerEnvirons evn = new CompilerEnvirons();
    //evn.setLanguageVersion(Context.VERSION_1_5);
    evn.setOptimizationLevel(-1);
    evn.setGeneratingSource(true);
    evn.setGenerateDebugInfo(true);
    ErrorReporter errorReporter = new ToolErrorReporter(false);
    Parser p = new Parser(evn, errorReporter);
    ScriptOrFnNode tree = p.parse(source, "",0); // IOException
       new NodeTransformer().transform(tree);
    //Script result = (Script)compiler.compile(scope, evn, tree, p.getEncodedSource(),false, null);
    return tree;
}
项目:read-open-source-code    文件:ScriptDialog.java   
public static ScriptOrFnNode parseVariables(Context cx, Scriptable scope, String source, String sourceName, int lineno, Object securityDomain){
    // Interpreter compiler = new Interpreter();
    CompilerEnvirons evn = new CompilerEnvirons();
    //evn.setLanguageVersion(Context.VERSION_1_5);
    evn.setOptimizationLevel(-1);
    evn.setGeneratingSource(true);
    evn.setGenerateDebugInfo(true);
    ErrorReporter errorReporter = new ToolErrorReporter(false);
    Parser p = new Parser(evn, errorReporter);
    ScriptOrFnNode tree = p.parse(source, "",0); // IOException
       new NodeTransformer().transform(tree);
    //Script result = (Script)compiler.compile(scope, evn, tree, p.getEncodedSource(),false, null);
    return tree;
}
项目:read-open-source-code    文件:ScriptValuesModDialog.java   
public static ScriptOrFnNode parseVariables(Context cx, Scriptable scope, String source, String sourceName, int lineno, Object securityDomain){
    // Interpreter compiler = new Interpreter();
    CompilerEnvirons evn = new CompilerEnvirons();
    //evn.setLanguageVersion(Context.VERSION_1_5);
    evn.setOptimizationLevel(-1);
    evn.setGeneratingSource(true);
    evn.setGenerateDebugInfo(true);
    ErrorReporter errorReporter = new ToolErrorReporter(false);
    Parser p = new Parser(evn, errorReporter);
    ScriptOrFnNode tree = p.parse(source, "",0); // IOException
       new NodeTransformer().transform(tree);
    //Script result = (Script)compiler.compile(scope, evn, tree, p.getEncodedSource(),false, null);
    return tree;
}
项目:jooby    文件:YuiJs.java   
@Override
public String process(final String filename, final String source, final Config conf)
    throws Exception {
  ErrorReporter reporter = reporter(log, filename, name());
  JavaScriptCompressor compressor = new JavaScriptCompressor(new StringReader(source), reporter);
  StringWriter out = new StringWriter();
  compressor.compress(out, get("linebreakpos"), get("munge"), get("verbose"),
      get("preserve-semi"), get("disable-optimizations"));
  return out.toString();
}