Examples of JsProgram


Examples of com.google.gwt.dev.js.ast.JsProgram

  private List<JsStatement> parse(List<JsStatement> expected, boolean compact)
      throws Exception {
    TextOutput text = new DefaultTextOutput(compact);
    JsVisitor generator = new JsSourceGenerationVisitor(text);
    generator.acceptList(expected);
    return JsParser.parse(SourceOrigin.UNKNOWN, new JsProgram().getScope(),
        new StringReader(text.toString()));
  }
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsProgram

    assertEquals("function(){if(b){}}", parse("function() {if(b){}}"));
  }

  private String parse(String js) throws Exception {
    List<JsStatement> statements = JsParser.parse(SourceOrigin.UNKNOWN,
        new JsProgram().getScope(), new StringReader(js));
    TextOutput text = new DefaultTextOutput(true);
    JsVisitor generator = new JsToStringGenerationVisitor(text);
    generator.acceptList(statements);
    return text.toString();
  }
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsProgram

    parse("foo();\nbar;\n}").error("test.js(3): syntax error\n> }\n> -^");
  }

  private Result parse(String js) {
    try {
      JsProgram program = new JsProgram();
      SourceInfo rootSourceInfo = program.createSourceInfo(1, "test.js");
      JsBlock block = program.getGlobalBlock();
      JsParser.parseInto(rootSourceInfo, program.getScope(), block,
          new StringReader(js));
      return new Result(block);
    } catch (IOException e) {
      throw new RuntimeException("Unexpected error reading in-memory stream", e);
    } catch (JsParserException e) {
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsProgram

  public void testEmptyMethod() throws Exception {
    recordFileNamesProp.setValue("true");
    recordLineNumbersProp.setValue("true");

    JsProgram program = compileClass(
        "package test;",
        "public class EntryPoint {",
        "  public static void onModuleLoad() {",
        "  }",
        "}");
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsProgram

  public void testCallWithNoArguments() throws Exception {
    recordFileNamesProp.setValue("true");
    recordLineNumbersProp.setValue("true");

    JsProgram program = compileClass(
        "package test;",
        "public class EntryPoint {",
        "  static void foo() {}",
        "  public static void onModuleLoad() {",
        "    foo();",
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsProgram

            "  public static String inlineable() { return Object.class.getName(); }",
            "}");
      }
    };

    JsProgram program = compileClass(new Resource[]{someClassJavaResource},
        "package test;",
        "public class EntryPoint {",
        "  public static void onModuleLoad() {",
        "    String b = SomeClass.inlineable();",
        "  }",
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsProgram

  public void testCallWithArguments() throws Exception {
    recordFileNamesProp.setValue("true");
    recordLineNumbersProp.setValue("true");

    JsProgram program = compileClass(
        "package test;",
        "public class EntryPoint {",
        "  static void foo(int x) {}",
        "  public static void onModuleLoad() {",
        "    foo(123);",
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsProgram

  public void testSimpleThrow() throws Exception {
    recordFileNamesProp.setValue("true");
    recordLineNumbersProp.setValue("true");

    JsProgram program = compileClass(
        "package test;",
        "public class EntryPoint {",
        "  public static void onModuleLoad() {",
        "    throw new RuntimeException();",
        "  }",
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsProgram

  public void testThrowWithInlineMethodCall() throws Exception {
    recordFileNamesProp.setValue("true");
    recordLineNumbersProp.setValue("true");
    inline = true;

    JsProgram program = compileClass(
        "package test;",
        "public class EntryPoint {",
        "  static Object thing = \"hello\";",
        "  private static String message() { return thing", // line 4
        "    .toString(); }",
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsProgram

  public void testThrowWithChainedMethodCall() throws Exception {
    recordFileNamesProp.setValue("true");
    recordLineNumbersProp.setValue("true");
    inline = true;

    JsProgram program = compileClass(
        "package test;",
        "public class EntryPoint {",
        "  static Factory factory;",
        "  static Factory getFactory() {",
        "    return factory;", // line 5
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.