locations

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: Apache-2.0 Imports: 6 Imported by: 41

Documentation

Overview

Package locations provides functions to get the location of a particular part of a descriptor, allowing Problems to be attached to just a descriptor's name, type, etc.. This allows for better auto-replacement functionality in code review tools.

All functions in this package accept a descriptor and return a protobuf SourceCodeInfo_Location object, which can be passed directly to the Location property on Problem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DescriptorName

DescriptorName returns the precise location for a descriptor's name.

This works for any descriptor, regardless of type (message, field, etc.).

func FieldBehavior

FieldBehavior returns the precise location for a field's field_behavior annotation.

func FieldLabel

FieldLabel returns the precise location for a field's label.

func FieldOption

FieldOption returns the precise location for the given extension defintion on the given field. This is useful for writing rules against custom extensions.

Example: locations.FieldOption(field, fieldbehaviorpb.E_FieldBehavior)

func FieldResourceReference

func FieldResourceReference(f protoreflect.FieldDescriptor) *dpb.SourceCodeInfo_Location

FieldResourceReference returns the precise location for a field's resource reference annotation.

func FieldType

FieldType returns the precise location for a field's type.

func FileCCEnableArenas

FileCCEnableArenas returns the location of the `cc_enable_arenas` option.

func FileCsharpNamespace

FileCsharpNamespace returns the location of the csharp_namespace file option in a file descriptor.

If the location can not be found (for example, because there is no csharp_namespace option), it returns nil.

func FileImport

FileImport returns the location of the import on the given `index`, or `nil` if no import with such `index` is found.

func FileJavaPackage

FileJavaPackage returns the location of the java_package file option in a file descriptor.

If the location can not be found (for example, because there is no java_package option), it returns nil.

func FilePackage

FilePackage returns the location of the package definition in a file descriptor.

If the location can not be found (for example, because there is no package statement), it returns nil.

func FilePhpNamespace

FilePhpNamespace returns the location of the php_namespace file option in a file descriptor.

If the location can not be found (for example, because there is no php_namespace option), it returns nil.

func FileResourceDefinition

func FileResourceDefinition(f protoreflect.FileDescriptor, index int) *dpb.SourceCodeInfo_Location

FileResourceDefinition returns the precise location of the `google.api.resource_definition` annotation.

func FileRubyPackage

FileRubyPackage returns the location of the ruby_package file option in a file descriptor.

If the location can not be found (for example, because there is no ruby_package option), it returns nil.

func FileSyntax

FileSyntax returns the location of the syntax definition in a file descriptor.

If the location can not be found (for example, because there is no syntax statement), it returns nil.

func MessageResource

MessageResource returns the precise location of the `google.api.resource` annotation.

func MethodHTTPRule

MethodHTTPRule returns the precise location of the method's `google.api.http` rule, if any.

func MethodOperationInfo

MethodOperationInfo returns the precise location of the method's `google.longrunning.operation_info` annotation, if any.

func MethodOption

func MethodOption(m protoreflect.MethodDescriptor, fieldNumber int) *dpb.SourceCodeInfo_Location

MethodOption returns the precise location of the method's option with the given field number, if any.

func MethodRequestType

MethodRequestType returns the precise location of the method's input type.

func MethodResponseType

MethodResponseType returns the precise location of the method's output type.

func MethodSignature

func MethodSignature(m protoreflect.MethodDescriptor, index int) *dpb.SourceCodeInfo_Location

MethodSignature returns the precise location of the method's `google.api.method_signature` annotation, if any.

Types

This section is empty.

Jump to

Keyboard shortcuts

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