Package org.mozilla.javascript

Examples of org.mozilla.javascript.Parser$ConditionData


            }

            public void error(String message, String sourceName, int line, String lineSource, int lineOffset) {
            }
        });
        return new Parser(env);
    }
View Full Code Here


*/
public class JavascriptParsingTest extends TestCase {

  public void testThatParsingIsPossible() throws Exception {
    String js = "function a() {};";
    Parser parser = new Parser();
    AstRoot ast = parser.parse(js, "source.js", 1);
    assertEquals("a", ((FunctionNode)ast.getFirstChild()).getFunctionName().getIdentifier());
  }
View Full Code Here

  }

  public void testParseComplexStuff() throws Exception {
    Reader source = new InputStreamReader(
        this.getClass().getResourceAsStream("browser_debug.js"));
    Parser parser = new Parser();
    AstRoot ast = parser.parse(source, "browser_debug.js", 1);
    String debugString = ast.debugPrint();
    assertTrue(debugString.contains("getRequiresAndProvides"));
    assertTrue(debugString.contains("ARRAYLIT"));
  }
View Full Code Here

  }

  public List<AstRoot> getAsts() throws IOException {
    List<AstRoot> asts = new LinkedList<AstRoot>();
    for (Map.Entry<String, Reader> file : files.entrySet()) {
      Parser parser = new Parser();
      asts.add(parser.parse(file.getValue(), file.getKey(), 1));
    }
    return asts;
  }
View Full Code Here

   *
   */
  public WinkParser() {
    compilerEnv = new CompilerEnvirons();
    errorReporter = compilerEnv.getErrorReporter();
    parser = new Parser(compilerEnv, errorReporter);
    jsFiles = Common.newArrayList(1);
  }
View Full Code Here

public class JQueryScanner {

  public JQueryScanner(FileReader in) {
    final ErrorReporter reporter = new ToolErrorReporter(true);
    final CompilerEnvirons env = new CompilerEnvirons();
    final Parser parser = new Parser(env, reporter);

    try {
      parser.parse(in, null, 0);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

   * @throws Exception
   *           压缩过程中的错误
   */
  public void compress(Reader reader, Writer writer, boolean keepLineno,
      int mode) throws Exception {
    Parser parser = new Parser(new CompilerEnvirons(), reporter);
    ScriptOrFnNode root = parser.parse(reader, null, 1);

    Environment env = new Environment(keepLineno, mode);
    GlobalScope globalScope = new GlobalScope();
    StatementList statements = new StatementList();
    Node node = root.getFirstChild();
View Full Code Here

    Query newQuery = new Query();
    if(condition)
      newQuery.conditionFunction = queryFunction;
    newQuery.source = oldQuery.source;
    newQuery.subObjectId = oldQuery.subObjectId;
    Parser p = new Parser(compilerEnvirons, compilerEnvirons.getErrorReporter());
        ScriptOrFnNode tree;
        tree = p.parse("(" + queryStr + ")", "jsonpath-sub-expression", 0);
        Node functionBody = tree.getFunctionNode(0).getFirstChild();
        Node returnNode = functionBody.getFirstChild();
        if(returnNode.getType() != Token.RETURN){
          returnNode = returnNode.getFirstChild().getFirstChild().getFirstChild();
        }
View Full Code Here

        environment.setErrorReporter(testErrorReporter);

        environment.setRecordingComments(true);
        environment.setRecordingLocalJsDocComments(jsdoc);

        Parser p = new Parser(environment, testErrorReporter);
        AstRoot script = null;
        try {
          script = p.parse(string, null, 0);
        } catch (EvaluatorException e) {
          if (errors == null) {
            // EvaluationExceptions should not occur when we aren't expecting
            // errors.
            throw e;
View Full Code Here

        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;
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.Parser$ConditionData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.