Class ProtoContext


  • public class ProtoContext
    extends Object
    Proto context is a holder for proto file and related infrastructure - symbol tables, extension registry, etc.
    Author:
    Kostiantyn Shchepanovskyi
    • Constructor Detail

      • ProtoContext

        public ProtoContext​(String filename)
        Create new empty context instance for a given filename.
    • Method Detail

      • peek

        public <T> T peek​(Class<T> declarationClass)
        Peek an element from a declaration stack. Used by parse listeners.
      • push

        public void push​(Object declaration)
        Push an element to a declaration stack. Used by parse listeners.
      • pop

        public <T> T pop​(Class<T> declarationClass)
        Pop an element from from a declaration stack. Used by parse listeners.
      • register

        public <T extends Type & Element> void register​(String fullyQualifiedName,
                                                        T type)
        Register user type in symbol table. Full name should start with ".".
      • getProto

        public Proto getProto()
      • resolve

        public <T extends Type> T resolve​(String typeName,
                                          Class<T> clazz)
        Resolve a type declaration by it's name using this proto context.
      • resolve

        public <T extends Type> T resolve​(Class<T> typeClass,
                                          String fullyQualifiedName)
        Resolve a type declaration by it's fully-qualified name using this proto context.
      • resolve

        public Type resolve​(String fullyQualifiedName)
        Resolve a type declaration by it's fully-qualified name using this proto context.
      • isInitialized

        public boolean isInitialized()
      • setInitialized

        public void setInitialized​(boolean initialized)
      • addImport

        public void addImport​(ProtoContext importedProto)
      • addPublicImport

        public void addPublicImport​(ProtoContext importedProto)
      • getFileReader

        public FileReader getFileReader()
      • setFileReader

        public void setFileReader​(FileReader fileReader)