compile

package
v1.25.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: MIT Imports: 11 Imported by: 44

Documentation

Overview

Package compile provides specifications for the types and services defined in a Thrift file.

Files are parsed using the Compile method, which will return a Module that contains the types and services defined in the Thrift file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Annotations

type Annotations map[string]string

Annotations maps annotations

type ArgsSpec

type ArgsSpec FieldGroup

ArgsSpec contains information about a Function's arguments.

func (as ArgsSpec) Link(scope Scope) error

Link resolves references made by the ArgsSpec.

type BinarySpec

type BinarySpec struct {
	Annotations Annotations
	// contains filtered or unexported fields
}

BinarySpec is the TypeSpec for binary types in a Thrift file.

func (*BinarySpec) ForEachTypeReference added in v0.4.0

func (*BinarySpec) ForEachTypeReference(func(TypeSpec) error) error

ForEachTypeReference is a no-op for primitives.

func (t *BinarySpec) Link(Scope) (TypeSpec, error)

Link is a no-op for primitives.

func (*BinarySpec) ThriftAnnotations added in v0.5.0

func (t *BinarySpec) ThriftAnnotations() Annotations

ThriftAnnotations returns the Thrift annotations specified with the reference to this type.

func (BinarySpec) ThriftFile added in v0.4.0

func (BinarySpec) ThriftFile() string

func (*BinarySpec) ThriftName added in v0.4.0

func (*BinarySpec) ThriftName() string

ThriftName returns "binary".

func (*BinarySpec) TypeCode added in v0.4.0

func (*BinarySpec) TypeCode() wire.Type

TypeCode returns TBinary.

type BoolSpec

type BoolSpec struct {
	Annotations Annotations
	// contains filtered or unexported fields
}

BoolSpec is the TypeSpec for bool types in a Thrift file.

func (*BoolSpec) ForEachTypeReference added in v0.4.0

func (*BoolSpec) ForEachTypeReference(func(TypeSpec) error) error

ForEachTypeReference is a no-op for primitives.

func (t *BoolSpec) Link(Scope) (TypeSpec, error)

Link is a no-op for primitives.

func (*BoolSpec) ThriftAnnotations added in v0.5.0

func (t *BoolSpec) ThriftAnnotations() Annotations

ThriftAnnotations returns the Thrift annotations specified with the reference to this type.

func (BoolSpec) ThriftFile added in v0.4.0

func (BoolSpec) ThriftFile() string

func (*BoolSpec) ThriftName added in v0.4.0

func (*BoolSpec) ThriftName() string

ThriftName returns "bool".

func (*BoolSpec) TypeCode added in v0.4.0

func (*BoolSpec) TypeCode() wire.Type

TypeCode returns TBool.

type ConstReference

type ConstReference struct {
	Target *Constant
}

ConstReference represents a reference to a 'const' declared in the Thrift file.

func (c ConstReference) Link(scope Scope, t TypeSpec) (ConstantValue, error)

Link for ConstReference.

type Constant

type Constant struct {
	Name  string
	File  string
	Doc   string
	Type  TypeSpec
	Value ConstantValue
	// contains filtered or unexported fields
}

Constant represents a single named constant value from the Thrift file.

func (c *Constant) Link(scope Scope) (err error)

Link resolves any references made by the constant.

func (*Constant) String

func (c *Constant) String() string

type ConstantBool

type ConstantBool bool

ConstantBool represents a boolean constant from the Thrift file.

func (c ConstantBool) Link(scope Scope, t TypeSpec) (ConstantValue, error)

Link for ConstantBool

type ConstantDouble

type ConstantDouble float64

ConstantDouble represents a double constant from the Thrift file.

func (c ConstantDouble) Link(scope Scope, t TypeSpec) (ConstantValue, error)

Link for ConstantDouble.

type ConstantInt

type ConstantInt int64

ConstantInt represents an integer constant from the Thrift file.

func (c ConstantInt) Link(scope Scope, t TypeSpec) (ConstantValue, error)

Link for ConstantInt.

type ConstantList

type ConstantList []ConstantValue

ConstantList represents a list of constant values from the Thrift file.

func (c ConstantList) Link(scope Scope, t TypeSpec) (ConstantValue, error)

Link for ConstantList.

type ConstantMap

type ConstantMap []ConstantValuePair

ConstantMap represents a map literal from the Thrift file.

func (c ConstantMap) Link(scope Scope, t TypeSpec) (ConstantValue, error)

Link for ConstantMap.

type ConstantSet

type ConstantSet []ConstantValue

ConstantSet represents a set of constant values from the Thrift file.

func (c ConstantSet) Link(scope Scope, t TypeSpec) (ConstantValue, error)

Link for ConstantSet.

type ConstantString

type ConstantString string

ConstantString represents a string constant from the Thrift file.

func (c ConstantString) Link(scope Scope, t TypeSpec) (ConstantValue, error)

Link for ConstantString.

type ConstantStruct

type ConstantStruct struct {
	Fields map[string]ConstantValue
}

ConstantStruct represents a struct literal from the Thrift file.

func (c *ConstantStruct) Link(scope Scope, t TypeSpec) (ConstantValue, error)

Link for ConstantStruct

type ConstantValue

type ConstantValue interface {
	// Link the constant value with the given scope, casting it to the given
	// type if necessary.
	Link(scope Scope, t TypeSpec) (ConstantValue, error)
}

ConstantValue represents a compiled constant value or a reference to one.

type ConstantValuePair

type ConstantValuePair struct {
	Key, Value ConstantValue
}

ConstantValuePair represents a key-value pair of ConstantValues in a constant map.

type DoubleSpec

type DoubleSpec struct {
	Annotations Annotations
	// contains filtered or unexported fields
}

DoubleSpec is the TypeSpec for double types in a Thrift file.

func (*DoubleSpec) ForEachTypeReference added in v0.4.0

func (*DoubleSpec) ForEachTypeReference(func(TypeSpec) error) error

ForEachTypeReference is a no-op for primitives.

func (t *DoubleSpec) Link(Scope) (TypeSpec, error)

Link is a no-op for primitives.

func (*DoubleSpec) ThriftAnnotations added in v0.5.0

func (t *DoubleSpec) ThriftAnnotations() Annotations

ThriftAnnotations returns the Thrift annotations specified with the reference to this type.

func (DoubleSpec) ThriftFile added in v0.4.0

func (DoubleSpec) ThriftFile() string

func (*DoubleSpec) ThriftName added in v0.4.0

func (*DoubleSpec) ThriftName() string

ThriftName returns "double".

func (*DoubleSpec) TypeCode added in v0.4.0

func (*DoubleSpec) TypeCode() wire.Type

TypeCode returns TDouble.

type EnumItem

type EnumItem struct {
	Name        string
	Value       int32
	Annotations Annotations
	Doc         string
}

EnumItem is a single item inside an enum.

func (*EnumItem) ThriftAnnotations added in v0.5.0

func (e *EnumItem) ThriftAnnotations() Annotations

ThriftAnnotations returns all associated annotations.

func (*EnumItem) ThriftName added in v0.5.0

func (e *EnumItem) ThriftName() string

ThriftName for EnumItem

type EnumItemReference

type EnumItemReference struct {
	Enum *EnumSpec
	Item *EnumItem
}

EnumItemReference represents a reference to an item of an enum defined in the THrift file.

func (e EnumItemReference) Link(scope Scope, t TypeSpec) (ConstantValue, error)

Link for EnumItemReference.

type EnumSpec

type EnumSpec struct {
	Name        string
	File        string
	Items       []EnumItem
	Annotations Annotations
	Doc         string
}

EnumSpec represents an enum defined in the Thrift file.

func (*EnumSpec) ForEachTypeReference

func (e *EnumSpec) ForEachTypeReference(func(TypeSpec) error) error

ForEachTypeReference for EnumSpec

func (e *EnumSpec) Link(scope Scope) (TypeSpec, error)

Link resolves any references made by the Enum.

func (*EnumSpec) LookupItem

func (e *EnumSpec) LookupItem(name string) (*EnumItem, bool)

LookupItem retrieves the item with the given name from the enum.

Returns true or false indicating whether the result is valid or not.

func (*EnumSpec) ThriftAnnotations added in v0.5.0

func (e *EnumSpec) ThriftAnnotations() Annotations

ThriftAnnotations returns all associated annotations.

func (*EnumSpec) ThriftFile

func (e *EnumSpec) ThriftFile() string

ThriftFile for EnumSpec

func (*EnumSpec) ThriftName

func (e *EnumSpec) ThriftName() string

ThriftName for EnumSpec

func (*EnumSpec) TypeCode

func (e *EnumSpec) TypeCode() wire.Type

TypeCode for EnumSpec.

Enums are represented as i32 over the wire.

type FS

type FS interface {
	// Read reads the file named by filename and returns the contents.
	// See: https://golang.org/pkg/io/ioutil/#ReadFile
	Read(filename string) ([]byte, error)
	// Abs returns an absolute representation of path.
	// See: https://golang.org/pkg/path/filepath/#Abs
	Abs(p string) (string, error)
}

FS is used by the compiler to interact with the filesystem.

type FieldGroup

type FieldGroup []*FieldSpec

FieldGroup represents a collection of fields for struct-like types.

func (FieldGroup) FindByName

func (fg FieldGroup) FindByName(name string) (*FieldSpec, error)

FindByName retrieves the FieldSpec for the field with the given name.

func (FieldGroup) ForEachTypeReference

func (fg FieldGroup) ForEachTypeReference(f func(TypeSpec) error) error

ForEachTypeReference applies the given function on each TypeSpec in the FieldGroup.

func (fg FieldGroup) Link(scope Scope) error

Link resolves references made by fields inside the FieldGroup.

type FieldSpec

type FieldSpec struct {
	ID          int16
	Name        string
	Type        TypeSpec
	Required    bool
	Doc         string
	Default     ConstantValue
	Annotations Annotations
}

FieldSpec represents a single field of a struct or parameter list.

func (f *FieldSpec) Link(scope Scope) (err error)

Link links together any references made by the FieldSpec.

func (*FieldSpec) ThriftAnnotations added in v0.5.0

func (f *FieldSpec) ThriftAnnotations() Annotations

ThriftAnnotations returns all associated annotations.

func (*FieldSpec) ThriftName

func (f *FieldSpec) ThriftName() string

ThriftName is the name of the FieldSpec as it appears in the Thrift file.

type FunctionSpec

type FunctionSpec struct {
	Name        string
	ArgsSpec    ArgsSpec
	ResultSpec  *ResultSpec // nil if OneWay is true
	OneWay      bool
	Annotations Annotations
	// contains filtered or unexported fields
}

FunctionSpec is a single function inside a Service.

func (*FunctionSpec) CallType

func (f *FunctionSpec) CallType() wire.EnvelopeType

CallType returns the envelope type that is used when making enveloped requests for this function.

func (f *FunctionSpec) Link(scope Scope) error

Link resolves any references made by the given function.

func (*FunctionSpec) MethodName

func (f *FunctionSpec) MethodName() string

MethodName returns the method name for this function.

type I16Spec

type I16Spec struct {
	Annotations Annotations
	// contains filtered or unexported fields
}

I16Spec is the TypeSpec for i16 types in a Thrift file.

func (*I16Spec) ForEachTypeReference added in v0.4.0

func (*I16Spec) ForEachTypeReference(func(TypeSpec) error) error

ForEachTypeReference is a no-op for primitives.

func (t *I16Spec) Link(Scope) (TypeSpec, error)

Link is a no-op for primitives.

func (*I16Spec) ThriftAnnotations added in v0.5.0

func (t *I16Spec) ThriftAnnotations() Annotations

ThriftAnnotations returns the Thrift annotations specified with the reference to this type.

func (I16Spec) ThriftFile added in v0.4.0

func (I16Spec) ThriftFile() string

func (*I16Spec) ThriftName added in v0.4.0

func (*I16Spec) ThriftName() string

ThriftName returns "i16".

func (*I16Spec) TypeCode added in v0.4.0

func (*I16Spec) TypeCode() wire.Type

TypeCode returns TI16.

type I32Spec

type I32Spec struct {
	Annotations Annotations
	// contains filtered or unexported fields
}

I32Spec is the TypeSpec for i32 types in a Thrift file.

func (*I32Spec) ForEachTypeReference added in v0.4.0

func (*I32Spec) ForEachTypeReference(func(TypeSpec) error) error

ForEachTypeReference is a no-op for primitives.

func (t *I32Spec) Link(Scope) (TypeSpec, error)

Link is a no-op for primitives.

func (*I32Spec) ThriftAnnotations added in v0.5.0

func (t *I32Spec) ThriftAnnotations() Annotations

ThriftAnnotations returns the Thrift annotations specified with the reference to this type.

func (I32Spec) ThriftFile added in v0.4.0

func (I32Spec) ThriftFile() string

func (*I32Spec) ThriftName added in v0.4.0

func (*I32Spec) ThriftName() string

ThriftName returns "i32".

func (*I32Spec) TypeCode added in v0.4.0

func (*I32Spec) TypeCode() wire.Type

TypeCode returns TI32.

type I64Spec

type I64Spec struct {
	Annotations Annotations
	// contains filtered or unexported fields
}

I64Spec is the TypeSpec for i64 types in a Thrift file.

func (*I64Spec) ForEachTypeReference added in v0.4.0

func (*I64Spec) ForEachTypeReference(func(TypeSpec) error) error

ForEachTypeReference is a no-op for primitives.

func (t *I64Spec) Link(Scope) (TypeSpec, error)

Link is a no-op for primitives.

func (*I64Spec) ThriftAnnotations added in v0.5.0

func (t *I64Spec) ThriftAnnotations() Annotations

ThriftAnnotations returns the Thrift annotations specified with the reference to this type.

func (I64Spec) ThriftFile added in v0.4.0

func (I64Spec) ThriftFile() string

func (*I64Spec) ThriftName added in v0.4.0

func (*I64Spec) ThriftName() string

ThriftName returns "i64".

func (*I64Spec) TypeCode added in v0.4.0

func (*I64Spec) TypeCode() wire.Type

TypeCode returns TI64.

type I8Spec

type I8Spec struct {
	Annotations Annotations
	// contains filtered or unexported fields
}

I8Spec is the TypeSpec for i8/byte types in a Thrift file.

func (*I8Spec) ForEachTypeReference added in v0.4.0

func (*I8Spec) ForEachTypeReference(func(TypeSpec) error) error

ForEachTypeReference is a no-op for primitives.

func (t *I8Spec) Link(Scope) (TypeSpec, error)

Link is a no-op for primitives.

func (*I8Spec) ThriftAnnotations added in v0.5.0

func (t *I8Spec) ThriftAnnotations() Annotations

ThriftAnnotations returns the Thrift annotations specified with the reference to this type.

func (I8Spec) ThriftFile added in v0.4.0

func (I8Spec) ThriftFile() string

func (*I8Spec) ThriftName added in v0.4.0

func (*I8Spec) ThriftName() string

ThriftName returns "byte".

func (*I8Spec) TypeCode added in v0.4.0

func (*I8Spec) TypeCode() wire.Type

TypeCode returns TI8.

type IncludedModule

type IncludedModule struct {
	Name   string
	Module *Module
}

IncludedModule represents an included module in the Thrift file.

The name of the IncludedModule is the name under which the module is exposed in the Thrift file which included it. This is usually the same as the Module name except when our custom include-as syntax is used.

type ListSpec

type ListSpec struct {
	ValueSpec   TypeSpec
	Annotations Annotations
	// contains filtered or unexported fields
}

ListSpec represents lists of values of the same type.

func (*ListSpec) ForEachTypeReference

func (l *ListSpec) ForEachTypeReference(f func(TypeSpec) error) error

ForEachTypeReference for ListSpec

func (l *ListSpec) Link(scope Scope) (TypeSpec, error)

Link resolves the type references in the ListSpec.

func (*ListSpec) ThriftAnnotations added in v0.5.0

func (l *ListSpec) ThriftAnnotations() Annotations

ThriftAnnotations returns all associated annotations.

func (ListSpec) ThriftFile

func (ListSpec) ThriftFile() string

func (*ListSpec) ThriftName

func (l *ListSpec) ThriftName() string

ThriftName for ListSpec

func (*ListSpec) TypeCode

func (l *ListSpec) TypeCode() wire.Type

TypeCode for ListSpec

type MapSpec

type MapSpec struct {
	KeySpec, ValueSpec TypeSpec
	Annotations        Annotations
	// contains filtered or unexported fields
}

MapSpec represents a key-value mapping between two types.

func (*MapSpec) ForEachTypeReference

func (m *MapSpec) ForEachTypeReference(f func(TypeSpec) error) error

ForEachTypeReference for MapSpec

func (m *MapSpec) Link(scope Scope) (TypeSpec, error)

Link resolves the type references in the MapSpec.

func (*MapSpec) ThriftAnnotations added in v0.5.0

func (m *MapSpec) ThriftAnnotations() Annotations

ThriftAnnotations returns all associated annotations.

func (MapSpec) ThriftFile

func (MapSpec) ThriftFile() string

func (*MapSpec) ThriftName

func (m *MapSpec) ThriftName() string

ThriftName for MapSpec

func (*MapSpec) TypeCode

func (m *MapSpec) TypeCode() wire.Type

TypeCode for MapSpec

type Module

type Module struct {
	Name       string
	ThriftPath string

	Includes  map[string]*IncludedModule
	Constants map[string]*Constant
	Types     map[string]TypeSpec
	Services  map[string]*ServiceSpec

	Raw []byte // The raw IDL input.
}

Module represents a compiled Thrift module. It contains all information about all known types, constants, services, and includes from the Thrift file.

ThriftPath is the absolute path to the Thrift file from which this module was compiled. All includes made by the Thrift file are relative to that path.

The module name is usually just the basename of the ThriftPath.

func Compile

func Compile(path string, opts ...Option) (*Module, error)

Compile parses and compiles the Thrift file at the given path and any other Thrift file it includes.

func (*Module) GetName

func (m *Module) GetName() string

GetName for Module

func (*Module) LookupConstant

func (m *Module) LookupConstant(name string) (*Constant, error)

LookupConstant for Module.

func (*Module) LookupInclude

func (m *Module) LookupInclude(name string) (Scope, error)

LookupInclude for Module.

func (*Module) LookupService

func (m *Module) LookupService(name string) (*ServiceSpec, error)

LookupService for Module.

func (*Module) LookupType

func (m *Module) LookupType(name string) (TypeSpec, error)

LookupType for Module.

func (*Module) Walk

func (m *Module) Walk(f func(*Module) error) error

Walk the module tree starting at the given module. This module and all its direct and transitive dependencies will be visited exactly once in an unspecified order. The walk will stop on the first error returned by `f`.

type NamedEntity added in v0.5.0

type NamedEntity interface {
	// ThriftName is the name of the type as it appears in the Thrift file.
	ThriftName() string

	// ThriftAnnotations is the map of all associated annotations from the Thrift file.
	ThriftAnnotations() Annotations
}

NamedEntity is any Thrift entity with a name and annotations. Not all entities are TypeSpecs.

type Option

type Option func(*compiler)

Option represents a compiler option.

func Filesystem

func Filesystem(fs FS) Option

Filesystem controls how the Thrift compiler accesses the filesystem.

func NonStrict

func NonStrict() Option

NonStrict disables strict validation of the Thrift file. This allows struct fields which are not marked as optional or required.

type ResultSpec

type ResultSpec struct {
	ReturnType TypeSpec
	Exceptions FieldGroup
}

ResultSpec contains information about a Function's result type.

func (rs *ResultSpec) Link(scope Scope) (err error)

Link resolves any references made by the return type or exceptions in the ResultSpec.

type Scope

type Scope interface {
	// GetName retrieves gets this scope.
	GetName() string

	// Retrieve a type defined in this scope.
	LookupType(name string) (TypeSpec, error)

	// Retrieve a service defined in this scope.
	LookupService(name string) (*ServiceSpec, error)

	// Retrieve a constant defined in this scope.
	LookupConstant(name string) (*Constant, error)

	// Retrieve an included scope.
	LookupInclude(name string) (Scope, error)
}

Scope represents a queryable compilation scope.

All Lookup methods must only return types defined in this scope. References to items defined in included modules will be resolved by the caller.

func EmptyScope

func EmptyScope(name string) Scope

EmptyScope returns a Scope that fails all lookups.

type ServiceSpec

type ServiceSpec struct {
	Name        string
	File        string
	Parent      *ServiceSpec
	Functions   map[string]*FunctionSpec
	Annotations Annotations
	// contains filtered or unexported fields
}

ServiceSpec is a collection of named functions.

func (s *ServiceSpec) Link(scope Scope) error

Link resolves any references made by the given service.

func (*ServiceSpec) ThriftFile

func (s *ServiceSpec) ThriftFile() string

ThriftFile is the Thrift file in which this service was defined.

type SetSpec

type SetSpec struct {
	ValueSpec   TypeSpec
	Annotations Annotations
	// contains filtered or unexported fields
}

SetSpec represents sets of values of the same type.

func (*SetSpec) ForEachTypeReference

func (s *SetSpec) ForEachTypeReference(f func(TypeSpec) error) error

ForEachTypeReference for SetSpec

func (s *SetSpec) Link(scope Scope) (TypeSpec, error)

Link resolves the type references in the SetSpec.

func (*SetSpec) ThriftAnnotations added in v0.5.0

func (s *SetSpec) ThriftAnnotations() Annotations

ThriftAnnotations returns all associated annotations.

func (SetSpec) ThriftFile

func (SetSpec) ThriftFile() string

func (*SetSpec) ThriftName

func (s *SetSpec) ThriftName() string

ThriftName for SetSpec.

func (*SetSpec) TypeCode

func (s *SetSpec) TypeCode() wire.Type

TypeCode for SetSpec

type StringSpec

type StringSpec struct {
	Annotations Annotations
	// contains filtered or unexported fields
}

StringSpec is the TypeSpec for string types in a Thrift file.

func (*StringSpec) ForEachTypeReference added in v0.4.0

func (*StringSpec) ForEachTypeReference(func(TypeSpec) error) error

ForEachTypeReference is a no-op for primitives.

func (t *StringSpec) Link(Scope) (TypeSpec, error)

Link is a no-op for primitives.

func (*StringSpec) ThriftAnnotations added in v0.5.0

func (t *StringSpec) ThriftAnnotations() Annotations

ThriftAnnotations returns the Thrift annotations specified with the reference to this type.

func (StringSpec) ThriftFile added in v0.4.0

func (StringSpec) ThriftFile() string

func (*StringSpec) ThriftName added in v0.4.0

func (*StringSpec) ThriftName() string

ThriftName returns "string".

func (*StringSpec) TypeCode added in v0.4.0

func (*StringSpec) TypeCode() wire.Type

TypeCode returns TBinary since Thrift strings are sent as binary over the wire.

type StructSpec

type StructSpec struct {
	Name        string
	File        string
	Type        ast.StructureType
	Fields      FieldGroup
	Doc         string
	Annotations Annotations
	// contains filtered or unexported fields
}

StructSpec represents a structure defined in the Thrift file.

func (*StructSpec) ForEachTypeReference

func (s *StructSpec) ForEachTypeReference(f func(TypeSpec) error) error

ForEachTypeReference for StructSpec

func (*StructSpec) IsExceptionType

func (s *StructSpec) IsExceptionType() bool

IsExceptionType returns true if the StructSpec represents an exception declaration.

func (s *StructSpec) Link(scope Scope) (TypeSpec, error)

Link links together all references in the StructSpec.

func (*StructSpec) ThriftAnnotations added in v0.5.0

func (s *StructSpec) ThriftAnnotations() Annotations

ThriftAnnotations returns all associated annotations.

func (*StructSpec) ThriftFile

func (s *StructSpec) ThriftFile() string

ThriftFile of the StructSpec.

func (*StructSpec) ThriftName

func (s *StructSpec) ThriftName() string

ThriftName of the StructSpec.

func (*StructSpec) TypeCode

func (s *StructSpec) TypeCode() wire.Type

TypeCode for structs.

type TypeSpec

type TypeSpec interface {
	NamedEntity

	// Link resolves references to other types in this TypeSpecs to actual
	// TypeSpecs from the given Scope.
	Link(scope Scope) (TypeSpec, error)

	// TypeCode is the wire-level Thrift Type associated with this Type.
	TypeCode() wire.Type

	// ThriftFile is the path to the Thrift file in which this TypeSpec was
	// defined. This may be an empty string if this type is a native Thrift
	// type.
	ThriftFile() string

	// Applies the given function to each TypeSpec referenced by this
	// TypeSpec. This function MUST NOT be automatically called recursively on
	// the TypeSpecs referenced by the child TypeSpecs. The decision to make
	// that call is up to the caller of this function.
	//
	// Returns the first error returned by the function call or nil.
	ForEachTypeReference(func(TypeSpec) error) error
}

TypeSpec contains information about Thrift types.

func RootTypeSpec

func RootTypeSpec(s TypeSpec) TypeSpec

RootTypeSpec returns the TypeSpec that the given linked TypeSpec points to.

For most types, this is the type itself. For Typedefs, it is the root TypeSpec of the Typedef's target.

type TypedefSpec

type TypedefSpec struct {
	Name        string
	File        string
	Target      TypeSpec
	Annotations Annotations
	Doc         string
	// contains filtered or unexported fields
}

TypedefSpec represents an alias to another type in the Thrift file.

func (*TypedefSpec) ForEachTypeReference

func (t *TypedefSpec) ForEachTypeReference(f func(TypeSpec) error) error

ForEachTypeReference for TypedefSpec

func (t *TypedefSpec) Link(scope Scope) (TypeSpec, error)

Link links the Target TypeSpec for this typedef in the given scope.

func (*TypedefSpec) ThriftAnnotations added in v0.5.0

func (t *TypedefSpec) ThriftAnnotations() Annotations

ThriftAnnotations returns all associated annotations.

func (*TypedefSpec) ThriftFile

func (t *TypedefSpec) ThriftFile() string

ThriftFile for TypedefSpec.

func (*TypedefSpec) ThriftName

func (t *TypedefSpec) ThriftName() string

ThriftName is the name of the typedef as it appears in the Thrift file.

func (*TypedefSpec) TypeCode

func (t *TypedefSpec) TypeCode() wire.Type

TypeCode gets the wire type for the typedef.

Jump to

Keyboard shortcuts

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