bufimagemodify

package
v0.54.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: Apache-2.0 Imports: 14 Imported by: 2

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 CsharpNamespace

func CsharpNamespace(sweeper Sweeper) Modifier

CsharpNamespace returns a Modifier that sets the csharp_namespace file option according to the package name. It is set to the package name with each package sub-name capitalized.

func GoPackage

func GoPackage(
	sweeper Sweeper,
	defaultImportPathPrefix string,
	except []bufmodule.ModuleIdentity,
	override map[bufmodule.ModuleIdentity]string,
) (Modifier, error)

GoPackage returns a Modifier that sets the go_package file option according to the given defaultImportPathPrefix, exceptions, and overrides.

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 JavaStringCheckUtf8

func JavaStringCheckUtf8(sweeper Sweeper, value bool) Modifier

JavaStringCheckUtf8 returns a Modifier that sets the java_string_check_utf8 file option according to the given value.

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 ObjcClassPrefix

func ObjcClassPrefix(sweeper Sweeper) Modifier

ObjcClassPrefix returns a Modifier that sets the objc_class_prefix file option according to the package name. It is set to the uppercase first letter of each package sub-name, not including the package version, with the following rules:

  • If the resulting abbreviation is 2 characters, add "X".
  • If the resulting abbreviation is 1 character, add "XX".
  • If the resulting abbreviation is "GPB", change it to "GPX". "GPB" is reserved by Google for the Protocol Buffers implementation.

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.

func PhpMetadataNamespace

func PhpMetadataNamespace(sweeper Sweeper) Modifier

PhpMetadataNamespace returns a Modifier that sets the php_metadata_namespace file option according to the package name. It appends "\\GPBMetadata" to the heuristic used by PhpNamespace.

func PhpNamespace

func PhpNamespace(sweeper Sweeper) Modifier

PhpNamespace returns a Modifier that sets the php_namespace file option according to the package name. It is set to the package name with each package sub-name capitalized and each "." replaced with "\\".

func RubyPackage

func RubyPackage(sweeper Sweeper) Modifier

RubyPackage returns a Modifier that sets the ruby_package file option according to the given packagePrefix. It is set to the package name with each package sub-name capitalized and each "." replaced with "::".

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