Package com.google.gxp.compiler.base

Examples of com.google.gxp.compiler.base.Template


                           List<ThrowsDeclaration> throwsDeclarations,
                           List<Parameter> parameters,
                           List<FormalTypeParameter> formalTypeParameters,
                           Expression content) {
    Constructor constructor = Constructor.empty(pos, "<gxp:template>");
    return new Template(pos, "<gxp:template>", fqTemplateName(dottedName),
                        schema, Collections.<JavaAnnotation>emptyList(), constructor, imports,
                        Collections.<ImplementsDeclaration>emptyList(),
                        throwsDeclarations,
                        parameters, formalTypeParameters,
                        content);
View Full Code Here


  public SourcePosition pos() {
    return POS;
  }

  public void testCollapse(Expression input, Expression expected) {
    Template root = template("bar.Baz",
                             htmlSchema(),
                             Collections.<Import>emptyList(),
                             Collections.<ThrowsDeclaration>emptyList(),
                             Collections.<Parameter>emptyList(),
                             Collections.<FormalTypeParameter>emptyList(),
                             collapse(input, null, null));
    BoundTree inTree = new BoundTree(pos(), AlertSet.EMPTY, root,
                                     Collections.<Callable>emptySet());
    SpaceCollapsedTree outTree = COLLAPSER.apply(inTree);
    Root newRoot = outTree.getRoot();
    assertTrue(newRoot + " is not a Template",
               newRoot instanceof Template);
    Template newTemplate = (Template)newRoot;
    assertEquals(expected, newTemplate.getContent());
  }
View Full Code Here

*/
public class SerializabilityTest extends GxpcTestCase {
  public void testCallables() throws Exception {
    SourcePosition pos = pos();

    Template template1 = template(pos, "com.google.foo.Bar", schema("text/html"),
                                  Collections.<Import>emptyList(),
                                  Collections.<ThrowsDeclaration>emptyList(),
                                  Collections.<Parameter>emptyList(),
                                  Collections.<FormalTypeParameter>emptyList(),
                                  str("foo"));

    Template template2 = template(pos, "com.google.foo.Bar", schema("text/html"),
                                  Collections.<Import>emptyList(),
                                  Collections.<ThrowsDeclaration>emptyList(),
                                  Collections.<Parameter>emptyList(),
                                  Collections.<FormalTypeParameter>emptyList(),
                                  str("foo"));

    Interface iface1 = iface(pos, "com.google.foo.Bar", schema("text/html"),
                             Collections.<Import>emptyList(),
                             Collections.<ThrowsDeclaration>emptyList(),
                             Collections.<Parameter>emptyList(),
                             Collections.<FormalTypeParameter>emptyList());

    Interface iface2 = iface(pos, "com.google.foo.Bar", schema("text/html"),
                             Collections.<Import>emptyList(),
                             Collections.<ThrowsDeclaration>emptyList(),
                             Collections.<Parameter>emptyList(),
                             Collections.<FormalTypeParameter>emptyList());

    assertSerializes(template1.getCallable(), template2.getCallable());
    assertSerializes(template1.getInstanceCallable(), template2.getInstanceCallable());
    assertSerializes(iface1.getCallable(), iface2.getCallable());
    assertSerializes(iface1.getInstanceCallable(), iface2.getInstanceCallable());
    assertSerializes(iface1.getImplementable(), iface2.getImplementable());
  }
View Full Code Here

      List<Parameter> parameters = nodeParts.getParameters();
      List<FormalTypeParameter> formalTypeParameters = nodeParts.getFormalTypeParameters();
      Expression content = getCollapsableContent(attrMap);

      if (contentType != null) {
        output.accumulate(new Template(node,
                                       name,
                                       contentType.getSchema(),
                                       javaAnnotations,
                                       constructor,
                                       imports,
View Full Code Here

        }
      }

      @Override
      public Template visitTemplate(Template template) {
        Template result = super.visitTemplate(template);
        if (!schema.allows(result.getContent().getSchema())) {
          throw new AssertionError();
        }
        return result;
      }
View Full Code Here

    ParsedElement template = template(NO_ATTRS);
    expectedAlerts.add(new MissingAttributeError(template, "name"));
    IfExpandedTree parseTree = tree(template);
    ReparentedTree output = reparent(parseTree);
    assertOneRoot(output);
    Template root = getTemplate(output.getRoot());
    assertEquals(TEMPLATE_NAME.toString(), root.getName().toString());
    assertEquals(0, root.getImports().size());
    assertEquals(0, root.getParameters().size());
    assertEmptyValue(root.getContent());
  }
View Full Code Here

  public void testNamedTemplate() throws Exception {
    IfExpandedTree parseTree = tree(template(list(attr("name", "pkg.Test"))));
    ReparentedTree output = reparent(parseTree);
    assertOneRoot(output);
    Template root = getTemplate(output.getRoot());
    assertEquals(TEMPLATE_NAME, root.getName());
    assertEquals(0, root.getImports().size());
    assertEquals(0, root.getParameters().size());
    assertEmptyValue(root.getContent());
  }
View Full Code Here

    ParsedElement template = template(list(attr("name", "pkg.Test"), spaz));
    expectedAlerts.add(new UnknownAttributeError(template, spaz));
    IfExpandedTree parseTree = tree(template);
    ReparentedTree output = reparent(parseTree);
    assertOneRoot(output);
    Template root = getTemplate(output.getRoot());
    assertEquals(TEMPLATE_NAME, root.getName());
    assertEquals(0, root.getImports().size());
    assertEquals(0, root.getParameters().size());
    assertEmptyValue(root.getContent());
  }
View Full Code Here

                      imp(list(attr("class", "com.google.Foo"))),
                      imp(list(attr("package", "com.google.bar"))),
                      imp(list(attr("class", "com.google.Baz")))));
    ReparentedTree output = reparent(parseTree);
    assertOneRoot(output);
    Template root = getTemplate(output.getRoot());
    assertEquals(TEMPLATE_NAME, root.getName());
    List<Import> imports = root.getImports();
    assertEquals(3, imports.size());
    assertEquals(templateName("com.google.Foo"),
                 ((ClassImport) imports.get(0)).getClassName());
    assertEquals("com.google.bar",
                 ((PackageImport) imports.get(1)).getPackageName());
    assertEquals(templateName("com.google.Baz"),
                 ((ClassImport) imports.get(2)).getClassName());
    assertEquals(0, root.getParameters().size());
    assertEmptyValue(root.getContent());
  }
View Full Code Here

                      imp(list(attr("package", "com.google.bar"))),
                      imp(list(attr("class", "com.google.Baz")))));
    ReparentedTree output = reparent(parseTree);
    expectedAlerts.add(new BadNodePlacementError(textNode, badImp));
    assertOneRoot(output);
    Template root = getTemplate(output.getRoot());
    assertEquals(TEMPLATE_NAME, root.getName());
    List<Import> imports = root.getImports();
    assertEquals(3, imports.size());
    assertEquals(templateName("com.google.Foo"),
                 ((ClassImport) imports.get(0)).getClassName());
    assertEquals("com.google.bar",
                 ((PackageImport) imports.get(1)).getPackageName());
    assertEquals(templateName("com.google.Baz"),
                 ((ClassImport) imports.get(2)).getClassName());
    assertEquals(0, root.getParameters().size());
    assertEmptyValue(root.getContent());
  }
View Full Code Here

TOP

Related Classes of com.google.gxp.compiler.base.Template

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.