Class PluginProtoCompiler

java.lang.Object
io.protostuff.compiler.STCodeGenerator
io.protostuff.compiler.PluginProtoCompiler
All Implemented Interfaces:
ProtoCompiler

public class PluginProtoCompiler extends STCodeGenerator
A plugin proto compiler whose output relies on the 'output' param configured in ProtoModule. The output param should point to a StringTemplate resource (file, url, or from classpath).
  • Field Details

    • CHECK_FILENAME_PLACEHOLDER

      protected static final boolean CHECK_FILENAME_PLACEHOLDER
      To enable, specify -Dppc.check_filename_placeholder=true
    • GROUP_RESOLVER

      public static final PluginProtoCompiler.GroupResolver GROUP_RESOLVER
    • __resolver

      private static PluginProtoCompiler.GroupResolver __resolver
    • module

      public final ProtoModule module
    • group

      public final org.antlr.stringtemplate.StringTemplateGroup group
    • enumBlockTemplate

      public final org.antlr.stringtemplate.StringTemplate enumBlockTemplate
    • messageBlockTemplate

      public final org.antlr.stringtemplate.StringTemplate messageBlockTemplate
    • protoBlockTemplate

      public final org.antlr.stringtemplate.StringTemplate protoBlockTemplate
    • serviceBlockTemplate

      public final org.antlr.stringtemplate.StringTemplate serviceBlockTemplate
    • javaOutput

      public final boolean javaOutput
    • fileExtension

      public final String fileExtension
    • outputName

      public final String outputName
    • outputPrefix

      public final String outputPrefix
    • outputSuffix

      public final String outputSuffix
  • Constructor Details

    • PluginProtoCompiler

      public PluginProtoCompiler(ProtoModule module, String stgLocation)
    • PluginProtoCompiler

      public PluginProtoCompiler(ProtoModule module, String stgLocation, boolean checkFilenamePlaceHolder)
    • PluginProtoCompiler

      public PluginProtoCompiler(ProtoModule module, boolean checkFilenamePlaceHolder, org.antlr.stringtemplate.StringTemplateGroup group)
  • Method Details

    • setGroupResolver

      public static void setGroupResolver(PluginProtoCompiler.GroupResolver resolver)
    • getTemplateFrom

      public static org.antlr.stringtemplate.StringTemplate getTemplateFrom(org.antlr.stringtemplate.StringTemplateGroup group, String template)
      Returns null if template is not found.
    • getOutputName

      static String getOutputName(String resource)
      Returns "foo" from "path/to/foo.java.stg"
    • getFileExtension

      public static String getFileExtension(String resource)
      Get the file extension of the provided stg resource.
    • resolveSTG

      public static org.antlr.stringtemplate.StringTemplateGroup resolveSTG(String stgLocation)
      Finds the stg resource.
    • resolveFileName

      public String resolveFileName(String name)
    • compile

      public void compile(ProtoModule module, Proto proto) throws IOException
      Specified by:
      compile in class STCodeGenerator
      Throws:
      IOException
    • compileServiceBlock

      private void compileServiceBlock(ProtoModule module, Service service, String packageName, String fileName, org.antlr.stringtemplate.StringTemplate serviceBlockTemplate) throws IOException
      Throws:
      IOException
    • compileServiceBlockTo

      public static void compileServiceBlockTo(Writer writer, ProtoModule module, Service service, org.antlr.stringtemplate.StringTemplate serviceBlockTemplate) throws IOException
      Throws:
      IOException
    • compileEnumBlock

      public static void compileEnumBlock(ProtoModule module, EnumGroup eg, String packageName, String fileName, org.antlr.stringtemplate.StringTemplate enumBlockTemplate) throws IOException
      Throws:
      IOException
    • compileEnumBlockTo

      public static void compileEnumBlockTo(Writer writer, ProtoModule module, EnumGroup eg, org.antlr.stringtemplate.StringTemplate enumBlockTemplate) throws IOException
      Throws:
      IOException
    • compileMessageBlock

      public static void compileMessageBlock(ProtoModule module, Message message, String packageName, String fileName, org.antlr.stringtemplate.StringTemplate messageBlockTemplate) throws IOException
      Throws:
      IOException
    • compileMessageBlockTo

      public static void compileMessageBlockTo(Writer writer, ProtoModule module, Message message, org.antlr.stringtemplate.StringTemplate messageBlockTemplate) throws IOException
      Throws:
      IOException
    • compileProtoBlock

      public void compileProtoBlock(ProtoModule module, Proto proto, String packageName, org.antlr.stringtemplate.StringTemplate protoBlockTemplate) throws IOException
      Throws:
      IOException