bufimagemodify

package
v0.43.3-0...-9926edd Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoPackageImportPathForFile

func GoPackageImportPathForFile(imageFile bufimage.ImageFile, importPathPrefix string) string

GoPackageImportPathForFile returns the go_package import path for the given ImageFile. If the package contains a version suffix, and if there are more than two components, concatenate the final two components. Otherwise, we exclude the ';' separator and adopt the default behavior from the import path.

For example, an ImageFile with `package acme.weather.v1;` will include `;weatherv1` in the `go_package` declaration so that the generated package is named as such.

Types

type Modifier

type Modifier interface {
	// Modify modifies the Image.
	Modify(context.Context, bufimage.Image) error
}

Modifier modifies Images.

func CcEnableArenas

func CcEnableArenas(sweeper Sweeper, value bool) Modifier

CcEnableArenas returns a Modifier that sets the cc_enable_arenas file option to the given value in all of the files contained in the Image.

func GoPackage

func GoPackage(sweeper Sweeper, importPathPrefix string) (Modifier, error)

GoPackage returns a Modifier that sets the go_package file option according to the given importPathPrefix.

func JavaMultipleFiles

func JavaMultipleFiles(sweeper Sweeper, value bool) Modifier

JavaMultipleFiles returns a Modifier that sets the java_multiple_files file option to the given value in all of the files contained in the Image.

func JavaOuterClassname

func JavaOuterClassname(sweeper Sweeper) Modifier

JavaOuterClassname returns a Modifier that sets the java_outer_classname file option in all of the files contained in the Image based on the PascalCase of their filename.

func JavaPackage

func JavaPackage(sweeper Sweeper, packagePrefix string) (Modifier, error)

JavaPackage returns a Modifier that sets the java_package file option according to the given packagePrefix.

func Merge

func Merge(left Modifier, right Modifier) Modifier

Merge merges the given modifiers together so that they are run in the order they are provided. This is particularly useful for constructing a modifier from its initial 'nil' value.

var modifier Modifier
if config.JavaMultipleFiles {
  modifier = Merge(modifier, JavaMultipleFiles)
}

func NewMultiModifier

func NewMultiModifier(modifiers ...Modifier) Modifier

NewMultiModifier returns a new Modifier for the given Modifiers.

func OptimizeFor

func OptimizeFor(sweeper Sweeper, value descriptorpb.FileOptions_OptimizeMode) Modifier

OptimizeFor returns a Modifier that sets the optimize_for file option to the given value in all of the files contained in the Image.

type ModifierFunc

type ModifierFunc func(context.Context, bufimage.Image) error

ModifierFunc is a convenience type that implements the Modifier interface.

func (ModifierFunc) Modify

func (m ModifierFunc) Modify(ctx context.Context, image bufimage.Image) error

Modify invokes the ModifierFunc with the given context and image.

type Sweeper

type Sweeper interface {
	// Sweep implements the ModifierFunc signature so that the Sweeper
	// can be used as a Modifier.
	Sweep(context.Context, bufimage.Image) error
	// contains filtered or unexported methods
}

Sweeper is used to mark-and-sweep SourceCodeInfo_Locations from images.

func NewFileOptionSweeper

func NewFileOptionSweeper() Sweeper

NewFileOptionSweeper constructs a new file option Sweeper that removes the SourceCodeInfo_Locations associated with the marks.

Jump to

Keyboard shortcuts

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