Package com.google.gxp.compiler.fs

Examples of com.google.gxp.compiler.fs.FileRef


    assertAlert(new DuplicateParameterNameError(pos(3,1), "id"));
    assertNoUnexpectedAlerts();
  }

  public void testBundle_requiredAttribute() throws Exception {
    FileRef callee = createFile("callee",
                                "<gxp:param name='bundle' gxp:type='bundle' from-element='img'/>");
    FileRef caller = createFile("caller",
                                "<call:callee />");
    compileFiles(callee, caller);
    assertAlert(new MissingAttributeError(pos(2, 1), "<call:callee>", "alt"));
    assertNoUnexpectedAlerts();
View Full Code Here


    assertAlert(new RequiredAttributeHasCondError(pos(2, 1), "<call:callee>", "alt"));
    assertNoUnexpectedAlerts();
  }

  public void testCall_conflictingAttrs() throws Exception {
    FileRef callee = createFile("callee",
                                "<gxp:param name='bundle' gxp:type='bundle'",
                                "           from-element='div' />");

    // test duplicate between standard and bundle
    FileRef caller = createFile("caller",
                                "<gxp:param name='bundle' gxp:type='bundle'",
                                "           from-element='div' />",
                                "<call:callee id='x' gxp:bundles='bundle'/>");
    compileFiles(callee, caller);
    assertAlert(new DuplicateAttributeError(pos(4, 1), "<call:callee>", "bundle", "id"));
View Full Code Here

    assertAlert(new DuplicateAttributeError(pos(4, 1), "<call:callee>", "bundle", "id"));
    assertNoUnexpectedAlerts();
  }

  public void testCall_invalidBundle() throws Exception {
    FileRef callee = createFile("callee",
                                "<gxp:param name='bundle' gxp:type='bundle'",
                                "           from-element='div' />");

    // test no gxp:param with that name
    FileRef caller = createFile("caller",
                                "<call:callee gxp:bundles='bundle'/>");
    compileFiles(callee, caller);
    assertAlert(new InvalidAttrBundleError(pos(2, 1), "<call:callee>", "bundle"));
    assertNoUnexpectedAlerts();
View Full Code Here

    assertAlert(new InvalidAttrBundleError(pos(3, 1), "<call:callee>", "bundle"));
    assertNoUnexpectedAlerts();
  }

  public void testCall_unknownAttribute() throws Exception {
    FileRef callee = createFile("callee",
                                "<gxp:param name='bundle' gxp:type='bundle'",
                                "           from-element='div'",
                                "           exclude='align' />");

    FileRef caller = createFile("caller",
                                "<gxp:param name='bundle' gxp:type='bundle'",
                                "           from-element='div' />",
                                "<call:callee gxp:bundles='bundle' />");

    compileFiles(callee, caller);
View Full Code Here

    assertAlert(new UnknownAttributeError("<call:callee>", pos(4,1), "align"));
    assertNoUnexpectedAlerts();
  }

  public void testCall_mismatchedValidators() throws Exception {
    FileRef callee = createFile("callee",
                                "<gxp:param name='bundle' gxp:type='bundle'",
                                "           from-element='div' />");

    FileRef caller = createFile(
        "caller",
        "<gxp:param name='bundle' gxp:type='bundle' from-element='td'",
        "    exclude='abbr,axis,bgcolor,char,charoff,colspan,",
        "             headers,height,nowrap,rowspan,scope,valign,width' />",
        "<call:callee gxp:bundles='bundle' />");
View Full Code Here

* Tests of proper error reporting by the GXP compiler relating to {@code
* Schema}s.
*/
public class SchemaErrorTest extends BaseTestCase {
  public void testSchema_duplicateContentTypes() throws Exception {
    FileRef schema1 = createSchemaFile(
        "schema1",
        "<schema name='schema1'",
        "        namespace='http://google.com/gxp/schema1'",
        "        content-type='text/xml'",
        "        java-type='com.google.gxp.base.GxpClosure'>",
        "</schema>");
    FileRef schema2 = createSchemaFile(
        "schema2",
        "<schema name='schema2'",
        "        namespace='http://google.com/gxp/schema2'",
        "        content-type='text/xml'",
        "        java-type='com.google.gxp.base.GxpClosure'>",
View Full Code Here

                      Iterable<OutputLanguage> outputLanguages,
                      Predicate<FileRef> allowedOutputPredicate) {
    Set<CompilationUnit> extractMessagesFrom = Sets.newHashSet();
    List<CompilationTask> sourceNotChanged = Lists.newArrayList();
    for (CompilationUnit cUnit : getCompilationUnits()) {
      FileRef sourceFileRef = cUnit.getSourceFileRef();
      SourcePosition sourcePosition = new SourcePosition(sourceFileRef);

      for (OutputLanguage language : outputLanguages) {
        String suffix = language.getSuffix(compilationVersion);
        FileRef outputFileRef = sourceFileRef.removeExtension().addSuffix(suffix);

        if (allowedOutputPredicate.apply(outputFileRef)) {
          extractMessagesFrom.add(cUnit);
          CompilationTask task =
              new CompilationTask(cUnit, codeGeneratorFactory, language,
                                  outputFileRef);
          // if the output file does not exist (last modified = 0) or if the source has been
          // modified since the last time that the output has been generated, or if the source has
          // changed, then we need to recompile the target
          if (outputFileRef.getLastModified() < sourceFileRef.getLastModified()
              || manager.sourceChanged(task)) {
            task.execute(alertSink, alertPolicy);
          } else {
            alertSink.add(new ProgressAlert(sourcePosition, "Skipped (source unchanged)"));
            sourceNotChanged.add(task);
          }
        } else {
          alertSink.add(new ProgressAlert(sourcePosition, "Skipped (output supressed)"));
        }
      }
    }

    // For each task we didn't execute, check to see if any of the interfaces
    // it depends on have changed (which could happen as a result of
    // recompiling one of the things it depends on).
    // TODO(laurence): see whether it's possible to combine these two loops by
    // having usedInterfacesChanged not change its value.
    for (CompilationTask task : sourceNotChanged) {
      if (manager.usedInterfacesChanged(task)) {
        FileRef sourceFileRef = task.getCompilationUnit().getSourceFileRef();
        SourcePosition sourcePosition = new SourcePosition(sourceFileRef);
        alertSink.add(new ProgressAlert(sourcePosition, "Reconsidered; callees have changed"));
        task.execute(alertSink, alertPolicy);
      }
    }
View Full Code Here

                                               "'cpp:delimiter' attribute"));
    assertNoUnexpectedAlerts();
  }

  public void testCall_NullAndLanguageAttribute() throws Exception {
    FileRef callee = createFile("callee", "<gxp:param name='s' type='String' />");
    FileRef caller = createFile("caller", "<call:callee s='foo' java:s='bar' />");
    compileFiles(callee, caller);
    assertAlert(new MultiValueAttributeError(pos(2,1), "<call:callee>", "'java:s' attribute"));
    assertNoUnexpectedAlerts();
  }
View Full Code Here

    assertAlert(new MultiValueAttributeError(pos(2,1), "<call:callee>", "'java:s' attribute"));
    assertNoUnexpectedAlerts();
  }

  public void testCall_JavaAndCppAttribute() throws Exception {
    FileRef callee = createFile("callee", "<gxp:param name='s' type='String' />");
    FileRef caller = createFile("caller", "<call:callee cpp:s='foo' java:s='bar' />");
    compileFiles(callee, caller);
    assertAlert(new MissingExpressionError(pos(2,1), "'s' attribute", "JavaScript"));
    assertNoUnexpectedAlerts();
  }
View Full Code Here

      i++;
      if (dotPhases.contains(phase)) {
        String suffix = String.format(".%02d.%s.dot", i,
                                      phase.name().toLowerCase().replace("_", "-"));
        for (CompilationUnit compilationUnit : compilationUnits) {
          FileRef fileRef = compilationUnit.getSourceFileRef().removeExtension().addSuffix(suffix);
          try {
            Writer writer = fileRef.openWriter(Charsets.US_ASCII);
            try {
              DotWriter out = new DotWriter(writer);
              GraphRenderer<Object> renderer =
                  new ReflectiveGraphRenderer(phase.name().toLowerCase());
              renderer.renderGraph(out, phase.getForest(compilationUnit).getChildren());
View Full Code Here

TOP

Related Classes of com.google.gxp.compiler.fs.FileRef

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.