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

项目:openbravo-brazil    文件:JavaScriptAPIChecker.java   
/**
 * Checks the parsed file against the API Map.
 * 
 * @param p
 *          an instance of {@link JavaScriptParser} to get the tree representation of it
 * @param jsFileName
 *          the JavaScript file name that is being checked
 * @throws IOException
 */
private void checkJS(JavaScriptParser p, String jsFileName) throws IOException {
  ScriptOrFnNode nodeTree = p.parse();
  for (Node cursor = nodeTree.getFirstChild(); cursor != null; cursor = cursor.getNext()) {
    StringBuffer sb = new StringBuffer();
    if (cursor.getType() == Token.FUNCTION) {
      int fnIndex = cursor.getExistingIntProp(Node.FUNCTION_PROP);
      FunctionNode fn = nodeTree.getFunctionNode(fnIndex);
      sb.append("FUNCTION: " + fn.getFunctionName());
    } else if (cursor.getType() == Token.VAR) {
      Node vn = cursor.getFirstChild();
      sb.append("VAR: " + vn.getString());

    }
    apiMap.remove(jsFileName + sb);
  }
}
项目: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;
}
项目: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;
}