bufimagemodify

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// DefaultJavaMultipleFilesValue is the default value for the java_multiple_files modifier.
	DefaultJavaMultipleFilesValue = true

	// JavaMultipleFilesID is the ID of the java_multiple_files modifier.
	JavaMultipleFilesID = "JAVA_MULTIPLE_FILES"
)
View Source
const (
	// DefaultJavaPackagePrefix is the default java_package prefix used in the java_package modifier.
	DefaultJavaPackagePrefix = "com"

	// JavaPackageID is the ID of the java_package modifier.
	JavaPackageID = "JAVA_PACKAGE"
)
View Source
const CcEnableArenasID = "CC_ENABLE_ARENAS"

CcEnableArenasID is the ID of the cc_enable_arenas modifier.

View Source
const CsharpNamespaceID = "CSHARP_NAMESPACE"

CsharpNamespaceID is the ID of the csharp_namespace modifier.

View Source
const GoPackageID = "GO_PACKAGE"

GoPackageID is the ID of the go_package modifier.

View Source
const JavaOuterClassNameID = "JAVA_OUTER_CLASSNAME"

JavaOuterClassNameID is the ID for the java_outer_classname modifier.

View Source
const JavaStringCheckUtf8ID = "JAVA_STRING_CHECK_UTF8"

JavaStringCheckUtf8ID is the ID of the java_string_check_utf8 modifier.

View Source
const ObjcClassPrefixID = "OBJC_CLASS_PREFIX"

ObjcClassPrefixID is the ID of the objc_class_prefix modifier.

View Source
const OptimizeForID = "OPTIMIZE_FOR"

OptimizeForID is the ID for the optimize_for modifier.

View Source
const PhpMetadataNamespaceID = "PHP_METADATA_NAMESPACE"

PhpMetadataNamespaceID is the ID of the php_metadata_namespace modifier.

View Source
const PhpNamespaceID = "PHP_NAMESPACE"

PhpNamespaceID is the ID of the php_namespace modifier.

View Source
const RubyPackageID = "RUBY_PACKAGE"

RubyPackageID is the ID of the ruby_package modifier.

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(
	logger *zap.Logger,
	sweeper Sweeper,
	value bool,
	overrides map[string]string,
) (Modifier, error)

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(
	logger *zap.Logger,
	sweeper Sweeper,
	overrides map[string]string,
) 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(
	logger *zap.Logger,
	sweeper Sweeper,
	defaultImportPathPrefix string,
	except []bufmoduleref.ModuleIdentity,
	moduleOverrides map[bufmoduleref.ModuleIdentity]string,
	overrides map[string]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(
	logger *zap.Logger,
	sweeper Sweeper,
	value bool,
	overrides map[string]string,
) (Modifier, error)

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(
	logger *zap.Logger,
	sweeper Sweeper,
	overrides map[string]string,
) 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(
	logger *zap.Logger,
	sweeper Sweeper,
	defaultPrefix string,
	except []bufmoduleref.ModuleIdentity,
	moduleOverrides map[bufmoduleref.ModuleIdentity]string,
	overrides map[string]string,
) (Modifier, error)

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

func JavaStringCheckUtf8

func JavaStringCheckUtf8(
	logger *zap.Logger,
	sweeper Sweeper,
	value bool,
	overrides map[string]string,
) (Modifier, error)

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(
	logger *zap.Logger,
	sweeper Sweeper,
	overrides map[string]string,
) 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(
	logger *zap.Logger,
	sweeper Sweeper,
	value descriptorpb.FileOptions_OptimizeMode,
	overrides map[string]string,
) (Modifier, error)

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(
	logger *zap.Logger,
	sweeper Sweeper,
	overrides map[string]string,
) 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(
	logger *zap.Logger,
	sweeper Sweeper,
	overrides map[string]string,
) 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(
	logger *zap.Logger,
	sweeper Sweeper,
	overrides map[string]string,
) 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