Package com.google.javascript.jscomp

Examples of com.google.javascript.jscomp.Compiler


        + "  var a = 'str';\n"
        + "};\n"
        + "function after_foo() {\n"
        + "  'bar';\n"
        + "}\n";
    Compiler compiler = createCompiler();
    String testCode = "var loc = 'str';";
    compileTestCode(compiler, testCode, "");
    Node root = getScriptRoot(compiler);
    RefasterJsScanner scanner = createScanner(compiler, template);
    Match match = new Match(root.getFirstChild(), new NodeMetadata(compiler));
View Full Code Here


        + "  loc.href = 'str';\n"
        + "};\n"
        + "function after_foo() {\n"
        + "  foo();\n"
        + "}\n";
    Compiler compiler = createCompiler();
    String preamble = "var loc = new Location();";
    String testCode = "loc.href = 'str';";
    compileTestCode(compiler, preamble + testCode, externs);
    Node root = getScriptRoot(compiler);
    RefasterJsScanner scanner = createScanner(compiler, template);
View Full Code Here

        + " * @param {FooType} foo\n"
        + " */\n"
        + "function after_foo(foo) {\n"
        + "  foo.baz();\n"
        + "}\n";
    Compiler compiler = createCompiler();
    String preamble = "var obj = new FooType();\n";
    String testCode = preamble + "obj.bar();";
    compileTestCode(compiler, testCode, externs);
    Node root = getScriptRoot(compiler);
    RefasterJsScanner scanner = createScanner(compiler, template);
View Full Code Here

        + "  foo.bar();\n"
        + "  foo.baz();\n"
        + "};\n"
        + "function after_foo() {\n"
        + "}\n";
    Compiler compiler = createCompiler();
    String preamble = "var obj = new FooType();\n";
    String postamble = "var someOtherCode = 3;\n";
    String testCode = ""
        + preamble
        + "obj.bar();\n"
View Full Code Here

        new CodeReplacement(preamble.length() + "obj.bar();\n".length(), "obj.baz();".length(), ""),
        iterator.next());
  }

  private Compiler createCompiler() {
    return new Compiler();
  }
View Full Code Here

  @Test
  public void testInsertBefore() {
    String before = "var someRandomCode = {};";
    String after = "/** some comment */\ngoog.foo();";
    Compiler compiler = getCompiler(before + after);
    Node root = compileToScriptRoot(compiler);
    Node newNode = IR.exprResult(IR.call(
        IR.getprop(IR.name("goog2"), IR.string("get")),
        IR.string("service")));
    SuggestedFix fix = new SuggestedFix.Builder()
View Full Code Here

  }

  @Test
  public void testDelete() {
    String input = "var foo = new Bar();";
    Compiler compiler = getCompiler(input);
    Node root = compileToScriptRoot(compiler);
    SuggestedFix fix = new SuggestedFix.Builder()
        .delete(root.getFirstChild())
        .build();
    CodeReplacement replacement = new CodeReplacement(0, input.length(), "");
View Full Code Here

  }

  @Test
  public void testRenameStringKey() {
    String input = "var obj = {foo: 'bar'};";
    Compiler compiler = getCompiler(input);
    Node root = compileToScriptRoot(compiler);
    Node node = root.getFirstChild().getFirstChild().getFirstChild()
        .getFirstChild();
    SuggestedFix fix = new SuggestedFix.Builder()
        .rename(node, "fooBar")
View Full Code Here

  }

  @Test
  public void testRenameProperty_justPropertyName() {
    String input = "obj.test.property";
    Compiler compiler = getCompiler(input);
    Node root = compileToScriptRoot(compiler);
    SuggestedFix fix = new SuggestedFix.Builder()
        .rename(root.getFirstChild().getFirstChild(), "renamedProperty")
        .build();
    CodeReplacement replacement = new CodeReplacement(9, "property".length(), "renamedProperty");
View Full Code Here

  }

  @Test
  public void testRenameProperty_entireName() {
    String input = "obj.test.property";
    Compiler compiler = getCompiler(input);
    Node root = compileToScriptRoot(compiler);
    SuggestedFix fix = new SuggestedFix.Builder()
        .rename(root.getFirstChild().getFirstChild(), "renamedProperty", true)
        .build();
    CodeReplacement replacement = new CodeReplacement(0, input.length(), "renamedProperty");
View Full Code Here

TOP

Related Classes of com.google.javascript.jscomp.Compiler

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.