Package com.google.gxp.compiler.alerts.common

Examples of com.google.gxp.compiler.alerts.common.ProgressAlert


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

      MessageBundle messageBundle = Util.bundleMessages(alertSink, messages);
      PropertiesBundleWriter pbw = new PropertiesBundleWriter(messageBundle);
      try {
        Writer writer = propertiesFile.openWriter(Charsets.US_ASCII);
        try {
          pbw.write(writer);
        } finally {
          writer.close();
        }
      } catch (UnmappableCharacterException uce) {
        // These are caused by coding errors, not user error.
        throw new AssertionError(uce);
      } catch (IOException iox) {
        alertSink.add(new IOError(propertiesFile, iox));
      }
      alertSink.add(new ProgressAlert(outputPosition, "Generate finished"));
    }
  }
View Full Code Here


   * Generates output for the specified {@code CompilationUnit} in the
   * specified {@code OutputLanguage}.
   */
  void execute(AlertSink alertSink, AlertPolicy alertPolicy) {
    SourcePosition outputPosition = new SourcePosition(outputFileRef);
    alertSink.add(new ProgressAlert(outputPosition, "Generating"));
    CodeGenerator codeGenerator =
        codeGeneratorFactory.getCodeGenerator(language, compilationUnit);

    AlertCounter counter = new AlertCounter(alertSink, alertPolicy);

    StringBuilder sb = new StringBuilder();
    try {
      codeGenerator.generateCode(sb, counter);

      if (counter.getErrorCount() == 0) {
        Writer writer = outputFileRef.openWriter(Charsets.US_ASCII);
        try {
          writer.write(sb.toString());
        } finally {
          writer.close();
        }
      }
    } catch (UnmappableCharacterException uce) {
      // These are caused by coding errors, not user error.
      throw new AssertionError(uce);
    } catch (IOException iox) {
      FileRef sourceFileRef = compilationUnit.getSourceFileRef();
      alertSink.add(new IOError(sourceFileRef, iox));
    }
    alertSink.add(new ProgressAlert(outputPosition, "Generate finished"));
  }
View Full Code Here

TOP

Related Classes of com.google.gxp.compiler.alerts.common.ProgressAlert

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.