generator

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GeneratorName of this generator
	GeneratorName = "protoc-gen-bean"
	// DefaultIndent for tab or space
	DefaultIndent = "    "
)
View Source
const (
	FlavorKotlin = iota
	FlavorJava
)

Variables

This section is empty.

Functions

func CamelCase

func CamelCase(s string) string

CamelCase returns the CamelCased name.

func CamelCaseSlice

func CamelCaseSlice(elem []string) string

CamelCaseSlice is like CamelCase, but the argument is a slice of strings to be joined with "_".

Types

type Descriptor

type Descriptor struct {
	*descriptor.DescriptorProto
	// contains filtered or unexported fields
}

Descriptor represents a protocol buffer message.

func (*Descriptor) File

func (c *Descriptor) File() *FileDescriptor

func (*Descriptor) JavaImportPath

func (c *Descriptor) JavaImportPath() JavaImportPath

JavaImportPath is the import path of the Java package containing the type.

func (*Descriptor) TypeName

func (d *Descriptor) TypeName() []string

TypeName returns the elements of the dotted type name. The package name is not part of this name.

type EnumDescriptor

type EnumDescriptor struct {
	*descriptor.EnumDescriptorProto
	// contains filtered or unexported fields
}

EnumDescriptor describes an enum. If it's at top level, its parent will be nil. Otherwise it will be the descriptor of the message in which it is defined.

func (*EnumDescriptor) File

func (c *EnumDescriptor) File() *FileDescriptor

func (*EnumDescriptor) JavaImportPath

func (c *EnumDescriptor) JavaImportPath() JavaImportPath

JavaImportPath is the import path of the Java package containing the type.

func (*EnumDescriptor) TypeName

func (e *EnumDescriptor) TypeName() (s []string)

TypeName returns the elements of the dotted type name. The package name is not part of this name.

type FileDescriptor

type FileDescriptor struct {
	*descriptor.FileDescriptorProto
	// contains filtered or unexported fields
}

FileDescriptor describes an protocol buffer descriptor file (.proto). It includes slices of all the messages and enums defined within it. Those slices are constructed by WrapTypes.

func (*FileDescriptor) VarName

func (d *FileDescriptor) VarName() string

VarName is the variable name we'll use in the generated code to refer to the compressed bytes of this descriptor. It is not exported, so it is only valid inside the generated package.

type Generator

type Generator struct {
	*bytes.Buffer

	Request  *plugin.CodeGeneratorRequest  // The input.
	Response *plugin.CodeGeneratorResponse // The output.

	Param map[string]string // Command-line parameters.

	ValueObjectPackage string // Java value object output package
	NoTime             bool   // DO NOT generate timestamp in header
	// contains filtered or unexported fields
}

Generator is the type whose methods generate the output, stored in the associated response structure.

func New

func New() *Generator

New creates a new generator and allocates the request and response protobufs.

func (*Generator) BuildTypeNameMap

func (g *Generator) BuildTypeNameMap()

BuildTypeNameMap builds the map from fully qualified type names to object. The key names for the map come from the input data, which puts a period at the beginning. It should be called after SetPackageNames and before GenerateAllFiles.

func (*Generator) CommandLineParameters

func (g *Generator) CommandLineParameters(parameter string)

CommandLineParameters breaks the comma-separated list of key=value pairs in the parameter (a member of the request protobuf) into a key/value map. It then sets file name mappings defined by those entries.

func (*Generator) Error

func (g *Generator) Error(err error, msgs ...string)

Error reports a problem, including an error, and exits the program.

func (*Generator) Fail

func (g *Generator) Fail(msgs ...string)

Fail reports a problem and exits the program.

func (*Generator) GenerateAllFiles

func (g *Generator) GenerateAllFiles()

GenerateAllFiles generates the output for all the files we're outputting.

func (*Generator) In

func (g *Generator) In()

In Indents the output one tab stop.

func (*Generator) Newline added in v0.2.3

func (g *Generator) Newline()

func (*Generator) ObjectNamed added in v0.2.3

func (g *Generator) ObjectNamed(typeName string) Object

ObjectNamed given fully-qualified input type name as it appears in the input data, returns the descriptor for the message or enum with that name

func (*Generator) Out

func (g *Generator) Out()

Out outdents the output one tab stop.

func (*Generator) P

func (g *Generator) P(str ...interface{})

P prints the arguments to the generated output. It handles strings and int32s, plus handling indirections because they may be *string, etc. Any inputs of type AnnotatedAtoms may emit annotations in a .meta file in addition to outputting the atoms themselves (if g.annotateCode is true).

func (*Generator) PrintComments

func (g *Generator) PrintComments(path string) bool

PrintComments prints any comments from the source .proto file. The path is a comma-separated list of integers. It returns an indication of whether any comments were printed. See descriptor.proto for its format.

func (*Generator) WrapTypes

func (g *Generator) WrapTypes()

WrapTypes walks the incoming data, wrapping DescriptorProtos, EnumDescriptorProtos and FileDescriptorProtos into file-referenced objects within the Generator. It also creates the list of files to generate and so should be called before GenerateAllFiles.

type ImportedDescriptor

type ImportedDescriptor struct {
	// contains filtered or unexported fields
}

ImportedDescriptor describes a type that has been publicly imported from another file.

func (*ImportedDescriptor) File

func (c *ImportedDescriptor) File() *FileDescriptor

func (*ImportedDescriptor) JavaImportPath

func (c *ImportedDescriptor) JavaImportPath() JavaImportPath

JavaImportPath is the import path of the Java package containing the type.

func (*ImportedDescriptor) TypeName

func (id *ImportedDescriptor) TypeName() []string

type JavaImportPath

type JavaImportPath string

A JavaImportPath is the import path of a Java package. e.g., "com.google.genproto.protobuf".

func (JavaImportPath) String

func (p JavaImportPath) String() string

type JavaPackageName

type JavaPackageName string

A JavaPackageName is the name of a Java package. e.g., "com.google.protobuf".

type Object

type Object interface {
	JavaImportPath() JavaImportPath
	TypeName() []string
	File() *FileDescriptor
}

Object is an interface abstracting the abilities shared by enums, messages, extensions and imported objects.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL