Package com.google.gxp.compiler.alerts

Examples of com.google.gxp.compiler.alerts.AlertSetBuilder


    this.baseServiceDirectory = Preconditions.checkNotNull(baseServiceDirectory);
  }

  public BoundTree apply(ReparentedTree reparentedTree) {
    Set<Callable> requirements = Sets.newHashSet();
    AlertSetBuilder alertSetBuilder = new AlertSetBuilder(reparentedTree.getAlerts());

    Root oldRoot = reparentedTree.getRoot();
    ServiceDirectory serviceDirectory =
        new ScopedServiceDirectory(alertSetBuilder,
                                   baseServiceDirectory,
                                   oldRoot.getName().getPackageName(),
                                   oldRoot.getImports());

    Root newRoot = oldRoot.acceptVisitor(
        new Visitor(alertSetBuilder, schemaFactory, serviceDirectory, requirements));

    return new BoundTree(reparentedTree.getSourcePosition(), alertSetBuilder.buildAndClear(),
                         newRoot, requirements);
  }
View Full Code Here


  /**
   * Executes compilation and returns the @code Alert}s generated by
   * compile as an {@link AlertSet}
   */
  public AlertSet call() {
    AlertSetBuilder alertSetBuilder = new AlertSetBuilder();
    call(alertSetBuilder);
    return alertSetBuilder.buildAndClear();
  }
View Full Code Here

* into {@code ValidatedCall}s. ({@code OutputElement}s aren't modified.)
*/
public class Validator implements Function<EscapedTree, ValidatedTree> {

  public ValidatedTree apply(EscapedTree tree) {
    AlertSetBuilder alertSetBuilder = new AlertSetBuilder(tree.getAlerts());
    Root root = tree.getRoot().acceptVisitor(new Visitor(alertSetBuilder));

    return new ValidatedTree(tree.getSourcePosition(), alertSetBuilder.buildAndClear(), root);
  }
View Full Code Here

* nodes for the start and end tags.
*/
public class ContentFlattener implements Function<ValidatedTree, ContentFlattenedTree> {

  public ContentFlattenedTree apply(ValidatedTree tree) {
    AlertSetBuilder alertSetBuilder = new AlertSetBuilder(tree.getAlerts());
    Root root = tree.getRoot().acceptVisitor(new Visitor(alertSetBuilder));

    return new ContentFlattenedTree(tree.getSourcePosition(), alertSetBuilder.buildAndClear(),
                                    root);
  }
View Full Code Here

public class NamespaceSetTest extends TestCase {
  private final NamespaceSet nsSet =
      new NamespaceSet(BuiltinSchemaFactory.INSTANCE);

  public void testExactMappings() throws Exception {
    AlertSetBuilder alertSetBuilder = new AlertSetBuilder();
    SourcePosition sourcePosition = new SourcePosition("<test>");
    assertTrue(nsSet.get(alertSetBuilder, sourcePosition,
                         "http://google.com/2001/gxp")
               instanceof GxpNamespace);
    assertTrue(alertSetBuilder.buildAndClear().isEmpty());
    assertTrue(nsSet.get(alertSetBuilder, sourcePosition,
                         "http://google.com/2001/gxp/expressions")
               instanceof ExprNamespace);
    assertTrue(alertSetBuilder.buildAndClear().isEmpty());
    assertTrue(nsSet.get(alertSetBuilder, sourcePosition,
                         "http://google.com/2001/gxp/call")
               instanceof CallNamespace);
    assertTrue(alertSetBuilder.buildAndClear().isEmpty());
    assertTrue(nsSet.get(alertSetBuilder, sourcePosition,
                         "http://www.w3.org/1999/xhtml")
               instanceof OutputNamespace);
    assertTrue(alertSetBuilder.buildAndClear().isEmpty());
  }
View Full Code Here

               instanceof OutputNamespace);
    assertTrue(alertSetBuilder.buildAndClear().isEmpty());
  }

  public void testFailedMapping() throws Exception {
    AlertSetBuilder alertSetBuilder = new AlertSetBuilder();
    nsSet.get(alertSetBuilder, new SourcePosition("<test>"),
              "http://google.com/i/dont/exist");
    Alert alert = Iterables.getOnlyElement(alertSetBuilder.buildAndClear());
    assertTrue(alert instanceof UnknownNamespaceError);
  }
View Full Code Here

  private String generateCode(String gxpSource, AlertSet expectedAlerts,
                              OutputLanguage outputLanguage)
      throws Exception {

    // Generate the code
    AlertSetBuilder builder = new AlertSetBuilder();

    testCodeGenPath(gxpSource, filterAlertSink(builder), outputLanguage);

    // Validate the list of (non-info) alerts)
    assertEquals(expectedAlerts, builder.buildAndClear());

    // Get output.
    String outputSystemFilename =
        "inmemory/gxp/test/Main" + outputLanguage.getSuffix(0);
    String code = getCodeFor(outputSystemFilename);
View Full Code Here

  }

  public void testCompletelyBrokenInput() throws Exception {
    // we just want to make sure that this doesn't throw an exception
    for (OutputLanguage outputLanguage : OutputLanguage.values()) {
      AlertSetBuilder builder = new AlertSetBuilder();
      testCodeGenPath("<foo>", builder, outputLanguage);
      assertFalse(builder.buildAndClear().isEmpty());
      // TODO(laurence): also test that Alerts look reasonable?
    }
  }
View Full Code Here

    String javaFilename = "inmemory/gxp/test/Main.java";
    String xmbFilename = "inmemory/gxp/test/Main.xmb";

    // Generate the code
    AlertSetBuilder javaBuilder = new AlertSetBuilder();


    testCodeGenPath(gxpSource, filterAlertSink(javaBuilder),
                    OutputLanguage.JAVA);
    try {
      getCodeFor(javaFilename);
      fail("Exception expected");
    } catch (IOException expected) {
      // expected
    }

    AlertSet javaAlertSet = javaBuilder.buildAndClear();

    AlertSetBuilder xmbBuilder = new AlertSetBuilder();
    testCodeGenPath(gxpSource, filterAlertSink(xmbBuilder), OutputLanguage.XMB);
    try {
      getCodeFor(xmbFilename);
      fail("Exception expected");
    } catch (IOException expected) {
      // expected
    }

    AlertSet xmbAlertSet = xmbBuilder.buildAndClear();

    assertEquals(javaAlertSet, xmbAlertSet);

    AlertSetBuilder dualLanguageBuilder = new AlertSetBuilder();
    testCodeGenPath(gxpSource, filterAlertSink(dualLanguageBuilder),
                    OutputLanguage.JAVA, OutputLanguage.XMB);

    try {
      getCodeFor(javaFilename);
      fail("Exception expected");
    } catch (IOException expected) {
      // expected
    }

    try {
      getCodeFor(xmbFilename);
      fail("Exception expected");
    } catch (IOException expected) {
      // expected
    }
    assertEquals(dualLanguageBuilder.buildAndClear(), javaAlertSet);
  }
View Full Code Here

* {@code gxp:ph} attributes.
*/
public class PlaceholderInserter implements Function<SpaceCollapsedTree, PlaceholderInsertedTree> {

  public PlaceholderInsertedTree apply(SpaceCollapsedTree tree) {
    AlertSetBuilder alertSetBuilder = new AlertSetBuilder(tree.getAlerts());
    Root root = tree.getRoot().acceptVisitor(new Visitor(alertSetBuilder));

    return new PlaceholderInsertedTree(tree.getSourcePosition(), alertSetBuilder.buildAndClear(),
                                       root);
  }
View Full Code Here

TOP

Related Classes of com.google.gxp.compiler.alerts.AlertSetBuilder

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.