Package org.mozilla.javascript.ast

Examples of org.mozilla.javascript.ast.AstRoot.toSource()


        astRoot.visitAll(branchInstrumentor);
        branchInstrumentor.postProcess();

        context = Context.enter();
        scope = context.initStandardObjects();
        String source = branchObjectHeader + header + branchInstrumentor.getJsLineInitialization() + astRoot.toSource();
        //System.out.println("--------------------------------------");
        //System.out.println("source = " + source);

        return context.evaluateString(scope, source, "test.js", 1, null);
    }
View Full Code Here


        if (includeBranchCoverage) {
            branchInstrumentor.setAstRoot(astRoot);
            astRoot.visitAll(branchInstrumentor);
            branchInstrumentor.postProcess();
        }
        return astRoot.toSource();
    }

    protected String getJsLineInitialization(String fileName, SortedSet<Integer> validLines) {
        fileName = fileName.replace("\\", "\\\\").replace("'", "\\'");
        StringBuilder sb = new StringBuilder(format("if (! _$jscoverage['%s']) {\n", fileName));
View Full Code Here

        CompilerEnvirons compilerEnv = new CompilerEnvirons();
        compilerEnv.setLanguageVersion(180);
        Parser parser = new Parser(compilerEnv);
        AstRoot astRoot = parser.parse(new StringReader(source), null, 1);
        astRoot.visitAll(new InstrumentVisitor());
        System.out.println(astRoot.toSource());
//        System.out.println("****************************");
//
//        source = "label:{\nx++;\nwhile (x) {\n  if (x) {\n    continue label;\n  }\n}}";
//        parser = new Parser();
//        astRoot = parser.parse(new StringReader(source), null, 1);
View Full Code Here

        CompilerEnvirons compilerEnv = new CompilerEnvirons();
        compilerEnv.setLanguageVersion(180);
//        compilerEnv.setStrictMode(false);
        Parser parser = new Parser(compilerEnv);
        AstRoot astRoot = parser.parse(new StringReader(source), null, 1);
        System.out.println(astRoot.toSource());
    }
}
View Full Code Here

    {
        CompilerEnvirons env = new CompilerEnvirons();
        env.setLanguageVersion(Context.VERSION_1_7);
        Parser parser = new Parser(env);
        AstRoot root = parser.parse(source, null, 0);
        Assert.assertEquals(expectedOutput, root.toSource());
    }

    /**
     * Tests that var declaration AST nodes is properly decompiled.
     */
 
View Full Code Here

      modifier.finish(ast);

      /* clean up */
      Context.exit();
      return ast.toSource();
    } catch (RhinoException re) {
      System.err.println(re.getMessage()
              + "Unable to instrument. This might be a JSON response sent"
              + " with the wrong Content-Type or a syntax error.");

View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.