Ejemplo n.º 1
0
  @Override
  public ProductMessage onVersionMessage(List<Message> messages) throws ParseException {
    VersionMessage version = Messages.getVersionMessage(messages);
    if (!version.getLanguage().equals(JAVA)) {
      throw new IllegalArgumentException("wrong language in version message");
    }
    ProductMessage ast = Messages.getProductMessage(messages, AST, JAVA);
    if (!ast.getLanguage().equals(JAVA)) {
      throw new IllegalArgumentException("wrong language in ast product message");
    }
    NonTerminal root = (NonTerminal) ASTs.decode(ast);

    OutlineTrimmer trimmer = new OutlineTrimmer();
    root.accept(trimmer);

    return new ProductMessage(
        version.getVersionId(),
        new LongKey(1),
        version.getSource(),
        OUTLINE,
        JAVA,
        Outlines.encode(trimmer.getConverted()),
        new ProductDependency(ast));
  }