Package com.google.gxp.compiler.alerts

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


                      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);
      }
    }

    // Optionally write out a java properties file that contains
    // strings extracted from <gxp:msg>s
    if (propertiesFile != null && !extractMessagesFrom.isEmpty()) {
      SourcePosition outputPosition = new SourcePosition(propertiesFile);
      alertSink.add(new ProgressAlert(outputPosition, "Generating"));

      List<ExtractedMessage> messages = Lists.newArrayList();
      for (CompilationUnit cUnit : extractMessagesFrom) {
        messages.addAll(cUnit.getMessageExtractedTree().getMessages());
View Full Code Here


    inputStream.close();
    return eventHandler.getSchema();
  }

  public static Schema getSchema(FileRef input, AlertSink alertSink) {
    SourcePosition pos = new SourcePosition(input);
    try {
      return Preconditions.checkNotNull(INSTANCE.parse(input));
    } catch (SAXException saxException) {
      alertSink.add(new SaxAlert(pos, Severity.ERROR, saxException));
      return null;
View Full Code Here

     */
    private SourcePosition getSourcePosition() {
      // Lines and columns start at 1. A value of 0 means we don't know, so in
      // that case just use the whole file as the position.
      if ((lineNumber > 0) && (columnNumber > 0)) {
        return new SourcePosition(source, lineNumber, columnNumber);
      } else {
        return new SourcePosition(source);
      }
    }
View Full Code Here

  private Schema addNonMarkupSchema(String name, String contentType, Schema msgSchema,
                                    String cppType, String cppAppender, String cppImport,
                                    String javaType, String javaAppender, String javaImport,
                                    String javaScriptType, String javaScriptImport) {
    Schema schema = new Schema(new SourcePosition(name), "<schema>",
                               name, "", contentType, false, contentType, null,
                               cppType, cppAppender, ImmutableList.of(cppImport),
                               javaType, javaAppender, ImmutableList.of(javaImport),
                               javaScriptType, ImmutableList.of(javaScriptImport),
                               ImmutableList.<ElementBuilder>of(), ImmutableList.<SchemaRef>of(),
View Full Code Here

  // used to synthesize unique (but somewhat deterministic) source positions.
  private int counter = 0;

  public SourcePosition pos() {
    counter++;
    return new SourcePosition("TEST" + counter, counter, counter);
  }
View Full Code Here

  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,
View Full Code Here

    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

  public void testList() throws Exception {
    assertContentsInOrder(list(1, 2, 3), 1, 2, 3);
  }

  public void testPos() throws Exception {
    SourcePosition pos1 = pos();
    SourcePosition pos2 = pos();
    assertNotEqual(pos1, pos2);
    assertNotEqual(pos1.getSourceName(), pos2.getSourceName());
    assertNotEqual(pos1.getLine(), pos2.getLine());
    assertNotEqual(pos1.getColumn(), pos2.getColumn());
  }
View Full Code Here

/**
* Tests of serializability.
*/
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(),
View Full Code Here

    assertSerializes(schema("text/css"),   schema("text/css"));
    assertSerializes(schema("text/html"),  schema("text/html"));
  }

  public void testTypes() throws Exception {
    SourcePosition pos = pos();

    assertSerializes(booleanType(pos),
                     booleanType(pos));

    assertSerializes(bundleType(pos, schema("text/html"), "div", "class"),
View Full Code Here

TOP

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

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.