Documentation ¶
Overview ¶
Package parser parses a thrift IDL file with its dependencies into an abstract syntax tree. The acceptable IDL grammar is defined in the 'thrift.peg' file.
Index ¶
- Constants
- Variables
- func CircleDetect(ast *Thrift) string
- func DetectKeyword(t *Thrift) (warnings []string)
- func Pretty(pretty bool) func(*ThriftIDL) error
- func Size(size int) func(*ThriftIDL) error
- func Typename2TypeID(name string) uint8
- type Annotation
- type Annotations
- type Category
- func (p Category) IsBaseType() bool
- func (p Category) IsBinary() bool
- func (p Category) IsBool() bool
- func (p Category) IsByte() bool
- func (p Category) IsConstant() bool
- func (p Category) IsContainerType() bool
- func (p Category) IsDouble() bool
- func (p Category) IsEnum() bool
- func (p Category) IsException() bool
- func (p Category) IsI16() bool
- func (p Category) IsI32() bool
- func (p Category) IsI64() bool
- func (p Category) IsList() bool
- func (p Category) IsMap() bool
- func (p Category) IsService() bool
- func (p Category) IsSet() bool
- func (p Category) IsString() bool
- func (p Category) IsStruct() bool
- func (p Category) IsStructLike() bool
- func (p Category) IsTypedef() bool
- func (p Category) IsUnion() bool
- func (p *Category) Scan(value interface{}) (err error)
- func (p Category) String() string
- func (p *Category) Value() (driver.Value, error)
- type ConstType
- type ConstTypedValue
- func (p *ConstTypedValue) CountSetFieldsConstTypedValue() int
- func (p *ConstTypedValue) GetDouble() (v float64)
- func (p *ConstTypedValue) GetIdentifier() (v string)
- func (p *ConstTypedValue) GetInt() (v int64)
- func (p *ConstTypedValue) GetList() (v []*ConstValue)
- func (p *ConstTypedValue) GetLiteral() (v string)
- func (p *ConstTypedValue) GetMap() (v []*MapConstValue)
- func (p *ConstTypedValue) IsSetDouble() bool
- func (p *ConstTypedValue) IsSetIdentifier() bool
- func (p *ConstTypedValue) IsSetInt() bool
- func (p *ConstTypedValue) IsSetList() bool
- func (p *ConstTypedValue) IsSetLiteral() bool
- func (p *ConstTypedValue) IsSetMap() bool
- func (p *ConstTypedValue) String() string
- type ConstValue
- type ConstValueExtra
- type Constant
- func (p *Constant) GetAnnotations() (v Annotations)
- func (p *Constant) GetName() (v string)
- func (p *Constant) GetReservedComments() (v string)
- func (p *Constant) GetType() (v *Type)
- func (p *Constant) GetValue() (v *ConstValue)
- func (p *Constant) IsSetType() bool
- func (p *Constant) IsSetValue() bool
- func (p *Constant) String() string
- type Enum
- type EnumValue
- type Field
- func (p *Field) GetAnnotations() (v Annotations)
- func (p *Field) GetDefault() (v *ConstValue)
- func (p *Field) GetID() (v int32)
- func (p *Field) GetName() (v string)
- func (p *Field) GetRequiredness() (v FieldType)
- func (p *Field) GetReservedComments() (v string)
- func (p *Field) GetType() (v *Type)
- func (p *Field) IsSetDefault() bool
- func (p *Field) IsSetType() bool
- func (p *Field) String() string
- type FieldType
- type Function
- func (p *Function) ForEachArgument(f func(v *Field) bool)
- func (p *Function) ForEachThrow(f func(v *Field) bool)
- func (p *Function) GetAnnotations() (v Annotations)
- func (p *Function) GetArguments() (v []*Field)
- func (p *Function) GetFunctionType() (v *Type)
- func (p *Function) GetName() (v string)
- func (p *Function) GetOneway() (v bool)
- func (p *Function) GetReservedComments() (v string)
- func (p *Function) GetThrows() (v []*Field)
- func (p *Function) GetVoid() (v bool)
- func (p *Function) IsSetFunctionType() bool
- func (p *Function) String() string
- type Include
- type MapConstValue
- type Namespace
- type Reference
- type Service
- func (s *Service) ForEachFunction(f func(v *Function) bool)
- func (p *Service) GetAnnotations() (v Annotations)
- func (p *Service) GetExtends() (v string)
- func (p *Service) GetFunctions() (v []*Function)
- func (p *Service) GetName() (v string)
- func (p *Service) GetReference() (v *Reference)
- func (p *Service) GetReservedComments() (v string)
- func (p *Service) IsSetReference() bool
- func (p *Service) String() string
- type StructLike
- func (s *StructLike) ForEachField(f func(v *Field) bool)
- func (p *StructLike) GetAnnotations() (v Annotations)
- func (p *StructLike) GetCategory() (v string)
- func (s *StructLike) GetField(name string) (*Field, bool)
- func (p *StructLike) GetFields() (v []*Field)
- func (p *StructLike) GetName() (v string)
- func (p *StructLike) GetReservedComments() (v string)
- func (p *StructLike) String() string
- type Thrift
- func (t *Thrift) DepthFirstSearch() chan *Thrift
- func (t *Thrift) ForEachConstant(f func(v *Constant) bool)
- func (t *Thrift) ForEachEnum(f func(v *Enum) bool)
- func (t *Thrift) ForEachException(f func(v *StructLike) bool)
- func (t *Thrift) ForEachInclude(f func(v *Include) bool)
- func (t *Thrift) ForEachNamepace(f func(v *Namespace) bool)
- func (t *Thrift) ForEachService(f func(v *Service) bool)
- func (t *Thrift) ForEachStruct(f func(v *StructLike) bool)
- func (t *Thrift) ForEachStructLike(f func(v *StructLike) bool)
- func (t *Thrift) ForEachTypedef(f func(v *Typedef) bool)
- func (t *Thrift) ForEachUnion(f func(v *StructLike) bool)
- func (t *Thrift) GetConstant(name string) (*Constant, bool)
- func (p *Thrift) GetConstants() (v []*Constant)
- func (p *Thrift) GetCppIncludes() (v []string)
- func (t *Thrift) GetEnum(name string) (*Enum, bool)
- func (p *Thrift) GetEnums() (v []*Enum)
- func (t *Thrift) GetException(name string) (*StructLike, bool)
- func (p *Thrift) GetExceptions() (v []*StructLike)
- func (p *Thrift) GetFilename() (v string)
- func (p *Thrift) GetIncludes() (v []*Include)
- func (p *Thrift) GetName2Category() (v map[string]Category)
- func (t *Thrift) GetNamespace(lang string) (ns string, found bool)
- func (t *Thrift) GetNamespaceOrReferenceName(lang string) string
- func (p *Thrift) GetNamespaces() (v []*Namespace)
- func (t *Thrift) GetReference(refname string) (*Thrift, bool)
- func (t *Thrift) GetService(name string) (*Service, bool)
- func (p *Thrift) GetServices() (v []*Service)
- func (t *Thrift) GetStruct(name string) (*StructLike, bool)
- func (t *Thrift) GetStructLikes() (ss []*StructLike)
- func (p *Thrift) GetStructs() (v []*StructLike)
- func (t *Thrift) GetTypedef(alias string) (*Typedef, bool)
- func (p *Thrift) GetTypedefs() (v []*Typedef)
- func (t *Thrift) GetUnion(name string) (*StructLike, bool)
- func (p *Thrift) GetUnions() (v []*StructLike)
- func (p *Thrift) String() string
- type ThriftIDL
- func (t *ThriftIDL) AST() *node32
- func (t *ThriftIDL) Add(rule pegRule, begin, end, index uint32)
- func (p *ThriftIDL) Init(options ...func(*ThriftIDL) error) error
- func (p *ThriftIDL) Parse(rule ...int) error
- func (t *ThriftIDL) PrettyPrintSyntaxTree(buffer string)
- func (t *ThriftIDL) Print()
- func (p *ThriftIDL) PrintSyntaxTree()
- func (p *ThriftIDL) Reset()
- func (p *ThriftIDL) SprintSyntaxTree() string
- func (t *ThriftIDL) Tokens() []token32
- func (t *ThriftIDL) Trim(length uint32)
- func (p *ThriftIDL) WriteSyntaxTree(w io.Writer)
- type Type
- func (p *Type) GetAnnotations() (v Annotations)
- func (p *Type) GetCategory() (v Category)
- func (p *Type) GetCppType() (v string)
- func (p *Type) GetIsTypedef() (v bool)
- func (p *Type) GetKeyType() (v *Type)
- func (p *Type) GetName() (v string)
- func (p *Type) GetReference() (v *Reference)
- func (p *Type) GetValueType() (v *Type)
- func (p *Type) IsSetIsTypedef() bool
- func (p *Type) IsSetKeyType() bool
- func (p *Type) IsSetReference() bool
- func (p *Type) IsSetValueType() bool
- func (t *Type) String() string
- type Typedef
Constants ¶
const ( STOP = 0 VOID = 1 BOOL = 2 BYTE = 3 I08 = 3 DOUBLE = 4 I16 = 6 I32 = 8 I64 = 10 STRING = 11 UTF7 = 11 STRUCT = 12 MAP = 13 SET = 14 LIST = 15 UTF8 = 16 UTF16 = 17 BINARY = 18 UNKNOWN = 255 )
TType constants in the Thrift protocol.
const NOTSET = -999999
NOTSET is a value to express 'not set'.
Variables ¶
var ConstTypedValue_Double_DEFAULT float64
var ConstTypedValue_Identifier_DEFAULT string
var ConstTypedValue_Int_DEFAULT int64
var ConstTypedValue_List_DEFAULT []*ConstValue
var ConstTypedValue_Literal_DEFAULT string
var ConstTypedValue_Map_DEFAULT []*MapConstValue
var Include_Used_DEFAULT bool
var Type_IsTypedef_DEFAULT bool
Functions ¶
func CircleDetect ¶
CircleDetect detects whether there is an include circle and return a string representing the loop. When no include circle is found, it returns an empty string.
func DetectKeyword ¶
DetectKeyword detects if there is any identifier using a reserved word in common programming languages.
func Typename2TypeID ¶
Typename2TypeID converts a TypeID name to its value.
Types ¶
type Annotation ¶
type Annotation struct { Key string `thrift:"Key,1" json:"Key"` Values []string `thrift:"Values,2" json:"Values"` }
func NewAnnotation ¶
func NewAnnotation() *Annotation
func (*Annotation) GetKey ¶
func (p *Annotation) GetKey() (v string)
func (*Annotation) GetValues ¶
func (p *Annotation) GetValues() (v []string)
func (*Annotation) String ¶
func (p *Annotation) String() string
type Annotations ¶
type Annotations []*Annotation
func (*Annotations) Append ¶
func (a *Annotations) Append(key, value string)
Append append key value pair to Annotation slice.
func (*Annotations) Get ¶
func (a *Annotations) Get(key string) []string
Get return annotations values.
func (*Annotations) ILocValueByKey ¶
func (a *Annotations) ILocValueByKey(key string, idx int) string
ILocValueByKey return annotation value by key and index.
type Category ¶
type Category int64
const ( Category_Constant Category = 0 Category_Bool Category = 1 Category_Byte Category = 2 Category_I16 Category = 3 Category_I32 Category = 4 Category_I64 Category = 5 Category_Double Category = 6 Category_String Category = 7 Category_Binary Category = 8 Category_Map Category = 9 Category_List Category = 10 Category_Set Category = 11 Category_Enum Category = 12 Category_Struct Category = 13 Category_Union Category = 14 Category_Exception Category = 15 Category_Typedef Category = 16 Category_Service Category = 17 )
func CategoryFromString ¶
func CategoryPtr ¶
func (Category) IsBaseType ¶
IsBaseType tells if the category is one of the basetypes.
func (Category) IsConstant ¶
IsConstant tells if the category is constant.
func (Category) IsContainerType ¶
IsContainerType tells if the category is one of the container types.
func (Category) IsException ¶
IsException tells if the category is exception.
func (Category) IsStructLike ¶
IsStructLike tells if the category is a struct-like.
type ConstTypedValue ¶
type ConstTypedValue struct { Double *float64 `thrift:"Double,1,optional" json:"Double,omitempty"` Int *int64 `thrift:"Int,2,optional" json:"Int,omitempty"` Literal *string `thrift:"Literal,3,optional" json:"Literal,omitempty"` Identifier *string `thrift:"Identifier,4,optional" json:"Identifier,omitempty"` List []*ConstValue `thrift:"List,5,optional" json:"List,omitempty"` Map []*MapConstValue `thrift:"Map,6,optional" json:"Map,omitempty"` }
var ConstValue_TypedValue_DEFAULT *ConstTypedValue
func NewConstTypedValue ¶
func NewConstTypedValue() *ConstTypedValue
func (*ConstTypedValue) CountSetFieldsConstTypedValue ¶
func (p *ConstTypedValue) CountSetFieldsConstTypedValue() int
func (*ConstTypedValue) GetDouble ¶
func (p *ConstTypedValue) GetDouble() (v float64)
func (*ConstTypedValue) GetIdentifier ¶
func (p *ConstTypedValue) GetIdentifier() (v string)
func (*ConstTypedValue) GetInt ¶
func (p *ConstTypedValue) GetInt() (v int64)
func (*ConstTypedValue) GetList ¶
func (p *ConstTypedValue) GetList() (v []*ConstValue)
func (*ConstTypedValue) GetLiteral ¶
func (p *ConstTypedValue) GetLiteral() (v string)
func (*ConstTypedValue) GetMap ¶
func (p *ConstTypedValue) GetMap() (v []*MapConstValue)
func (*ConstTypedValue) IsSetDouble ¶
func (p *ConstTypedValue) IsSetDouble() bool
func (*ConstTypedValue) IsSetIdentifier ¶
func (p *ConstTypedValue) IsSetIdentifier() bool
func (*ConstTypedValue) IsSetInt ¶
func (p *ConstTypedValue) IsSetInt() bool
func (*ConstTypedValue) IsSetList ¶
func (p *ConstTypedValue) IsSetList() bool
func (*ConstTypedValue) IsSetLiteral ¶
func (p *ConstTypedValue) IsSetLiteral() bool
func (*ConstTypedValue) IsSetMap ¶
func (p *ConstTypedValue) IsSetMap() bool
func (*ConstTypedValue) String ¶
func (p *ConstTypedValue) String() string
type ConstValue ¶
type ConstValue struct { Type ConstType `thrift:"Type,1" json:"Type"` TypedValue *ConstTypedValue `thrift:"TypedValue,2,optional" json:"TypedValue,omitempty"` Extra *ConstValueExtra `thrift:"Extra,3,optional" json:"Extra,omitempty"` }
var Constant_Value_DEFAULT *ConstValue
var Field_Default_DEFAULT *ConstValue
var MapConstValue_Key_DEFAULT *ConstValue
var MapConstValue_Value_DEFAULT *ConstValue
func NewConstValue ¶
func NewConstValue() *ConstValue
func (*ConstValue) GetExtra ¶
func (p *ConstValue) GetExtra() (v *ConstValueExtra)
func (*ConstValue) GetType ¶
func (p *ConstValue) GetType() (v ConstType)
func (*ConstValue) GetTypedValue ¶
func (p *ConstValue) GetTypedValue() (v *ConstTypedValue)
func (*ConstValue) IsSetExtra ¶
func (p *ConstValue) IsSetExtra() bool
func (*ConstValue) IsSetTypedValue ¶
func (p *ConstValue) IsSetTypedValue() bool
func (*ConstValue) String ¶
func (t *ConstValue) String() string
type ConstValueExtra ¶
type ConstValueExtra struct { IsEnum bool `thrift:"IsEnum,1" json:"IsEnum"` Index int32 `thrift:"Index,2" json:"Index"` Name string `thrift:"Name,3" json:"Name"` Sel string `thrift:"Sel,4" json:"Sel"` }
var ConstValue_Extra_DEFAULT *ConstValueExtra
func NewConstValueExtra ¶
func NewConstValueExtra() *ConstValueExtra
func (*ConstValueExtra) GetIndex ¶
func (p *ConstValueExtra) GetIndex() (v int32)
func (*ConstValueExtra) GetIsEnum ¶
func (p *ConstValueExtra) GetIsEnum() (v bool)
func (*ConstValueExtra) GetName ¶
func (p *ConstValueExtra) GetName() (v string)
func (*ConstValueExtra) GetSel ¶
func (p *ConstValueExtra) GetSel() (v string)
func (*ConstValueExtra) String ¶
func (p *ConstValueExtra) String() string
type Constant ¶
type Constant struct { Name string `thrift:"Name,1" json:"Name"` Type *Type `thrift:"Type,2,optional" json:"Type,omitempty"` Value *ConstValue `thrift:"Value,3,optional" json:"Value,omitempty"` Annotations Annotations `thrift:"Annotations,4" json:"Annotations"` ReservedComments string `thrift:"ReservedComments,5" json:"ReservedComments"` }
func NewConstant ¶
func NewConstant() *Constant
func (*Constant) GetAnnotations ¶
func (p *Constant) GetAnnotations() (v Annotations)
func (*Constant) GetReservedComments ¶
func (*Constant) GetValue ¶
func (p *Constant) GetValue() (v *ConstValue)
func (*Constant) IsSetValue ¶
type Enum ¶
type Enum struct { Name string `thrift:"Name,1" json:"Name"` Values []*EnumValue `thrift:"Values,2" json:"Values"` Annotations Annotations `thrift:"Annotations,3" json:"Annotations"` ReservedComments string `thrift:"ReservedComments,4" json:"ReservedComments"` }
func (*Enum) GetAnnotations ¶
func (p *Enum) GetAnnotations() (v Annotations)
func (*Enum) GetReservedComments ¶
type EnumValue ¶
type EnumValue struct { Name string `thrift:"Name,1" json:"Name"` Value int64 `thrift:"Value,2" json:"Value"` Annotations Annotations `thrift:"Annotations,3" json:"Annotations"` ReservedComments string `thrift:"ReservedComments,4" json:"ReservedComments"` }
func NewEnumValue ¶
func NewEnumValue() *EnumValue
func (*EnumValue) GetAnnotations ¶
func (p *EnumValue) GetAnnotations() (v Annotations)
func (*EnumValue) GetReservedComments ¶
type Field ¶
type Field struct { ID int32 `thrift:"ID,1" json:"ID"` Name string `thrift:"Name,2" json:"Name"` Requiredness FieldType `thrift:"Requiredness,3" json:"Requiredness"` Type *Type `thrift:"Type,4" json:"Type"` Default *ConstValue `thrift:"Default,5,optional" json:"Default,omitempty"` Annotations Annotations `thrift:"Annotations,6" json:"Annotations"` ReservedComments string `thrift:"ReservedComments,7" json:"ReservedComments"` }
func (*Field) GetAnnotations ¶
func (p *Field) GetAnnotations() (v Annotations)
func (*Field) GetDefault ¶
func (p *Field) GetDefault() (v *ConstValue)
func (*Field) GetRequiredness ¶
func (*Field) GetReservedComments ¶
func (*Field) IsSetDefault ¶
type FieldType ¶
type FieldType int64
func FieldTypeFromString ¶
func FieldTypePtr ¶
func (FieldType) IsOptional ¶
IsOptional tells whether a field type is optional.
func (FieldType) IsRequired ¶
IsRequired tells whether a field type is required.
type Function ¶
type Function struct { Name string `thrift:"Name,1" json:"Name"` Oneway bool `thrift:"Oneway,2" json:"Oneway"` Void bool `thrift:"Void,3" json:"Void"` FunctionType *Type `thrift:"FunctionType,4,optional" json:"FunctionType,omitempty"` Arguments []*Field `thrift:"Arguments,5" json:"Arguments"` Throws []*Field `thrift:"Throws,6" json:"Throws"` Annotations Annotations `thrift:"Annotations,7" json:"Annotations"` ReservedComments string `thrift:"ReservedComments,8" json:"ReservedComments"` }
func NewFunction ¶
func NewFunction() *Function
func (*Function) ForEachArgument ¶
ForEachArgument calls f on each argument of the current function.
func (*Function) ForEachThrow ¶
ForEachThrow calls f on each throw of the current function.
func (*Function) GetAnnotations ¶
func (p *Function) GetAnnotations() (v Annotations)
func (*Function) GetArguments ¶
func (*Function) GetFunctionType ¶
func (*Function) GetReservedComments ¶
func (*Function) IsSetFunctionType ¶
type Include ¶
type Include struct { Path string `thrift:"Path,1" json:"Path"` Reference *Thrift `thrift:"Reference,2,optional" json:"Reference,omitempty"` Used *bool `thrift:"Used,3,optional" json:"Used,omitempty"` }
func NewInclude ¶
func NewInclude() *Include
func (*Include) GetReference ¶
func (*Include) IsSetReference ¶
type MapConstValue ¶
type MapConstValue struct { Key *ConstValue `thrift:"Key,1,optional" json:"Key,omitempty"` Value *ConstValue `thrift:"Value,2,optional" json:"Value,omitempty"` }
func NewMapConstValue ¶
func NewMapConstValue() *MapConstValue
func (*MapConstValue) GetKey ¶
func (p *MapConstValue) GetKey() (v *ConstValue)
func (*MapConstValue) GetValue ¶
func (p *MapConstValue) GetValue() (v *ConstValue)
func (*MapConstValue) IsSetKey ¶
func (p *MapConstValue) IsSetKey() bool
func (*MapConstValue) IsSetValue ¶
func (p *MapConstValue) IsSetValue() bool
func (*MapConstValue) String ¶
func (p *MapConstValue) String() string
type Namespace ¶
type Namespace struct { Language string `thrift:"Language,1" json:"Language"` Name string `thrift:"Name,2" json:"Name"` Annotations Annotations `thrift:"Annotations,3" json:"Annotations"` }
func NewNamespace ¶
func NewNamespace() *Namespace
func (*Namespace) GetAnnotations ¶
func (p *Namespace) GetAnnotations() (v Annotations)
func (*Namespace) GetLanguage ¶
type Reference ¶
type Reference struct { Name string `thrift:"Name,1" json:"Name"` Index int32 `thrift:"Index,2" json:"Index"` }
var Service_Reference_DEFAULT *Reference
var Type_Reference_DEFAULT *Reference
func NewReference ¶
func NewReference() *Reference
type Service ¶
type Service struct { Name string `thrift:"Name,1" json:"Name"` Extends string `thrift:"Extends,2" json:"Extends"` Functions []*Function `thrift:"Functions,3" json:"Functions"` Annotations Annotations `thrift:"Annotations,4" json:"Annotations"` Reference *Reference `thrift:"Reference,5,optional" json:"Reference,omitempty"` ReservedComments string `thrift:"ReservedComments,6" json:"ReservedComments"` }
func NewService ¶
func NewService() *Service
func (*Service) ForEachFunction ¶
ForEachFunction calls f on each function in the current service.
func (*Service) GetAnnotations ¶
func (p *Service) GetAnnotations() (v Annotations)
func (*Service) GetExtends ¶
func (*Service) GetFunctions ¶
func (*Service) GetReference ¶
func (*Service) GetReservedComments ¶
func (*Service) IsSetReference ¶
type StructLike ¶
type StructLike struct { Category string `thrift:"Category,1" json:"Category"` Name string `thrift:"Name,2" json:"Name"` Fields []*Field `thrift:"Fields,3" json:"Fields"` Annotations Annotations `thrift:"Annotations,4" json:"Annotations"` ReservedComments string `thrift:"ReservedComments,5" json:"ReservedComments"` }
func NewStructLike ¶
func NewStructLike() *StructLike
func (*StructLike) ForEachField ¶
func (s *StructLike) ForEachField(f func(v *Field) bool)
ForEachField calls f on each field of the current struct-like.
func (*StructLike) GetAnnotations ¶
func (p *StructLike) GetAnnotations() (v Annotations)
func (*StructLike) GetCategory ¶
func (p *StructLike) GetCategory() (v string)
func (*StructLike) GetField ¶
func (s *StructLike) GetField(name string) (*Field, bool)
GetField returns a field of the struct-like that matches the name.
func (*StructLike) GetFields ¶
func (p *StructLike) GetFields() (v []*Field)
func (*StructLike) GetName ¶
func (p *StructLike) GetName() (v string)
func (*StructLike) GetReservedComments ¶
func (p *StructLike) GetReservedComments() (v string)
func (*StructLike) String ¶
func (p *StructLike) String() string
type Thrift ¶
type Thrift struct { Filename string `thrift:"Filename,1" json:"Filename"` Includes []*Include `thrift:"Includes,2" json:"Includes"` CppIncludes []string `thrift:"CppIncludes,3" json:"CppIncludes"` Namespaces []*Namespace `thrift:"Namespaces,4" json:"Namespaces"` Typedefs []*Typedef `thrift:"Typedefs,5" json:"Typedefs"` Constants []*Constant `thrift:"Constants,6" json:"Constants"` Enums []*Enum `thrift:"Enums,7" json:"Enums"` Structs []*StructLike `thrift:"Structs,8" json:"Structs"` Unions []*StructLike `thrift:"Unions,9" json:"Unions"` Exceptions []*StructLike `thrift:"Exceptions,10" json:"Exceptions"` Services []*Service `thrift:"Services,11" json:"Services"` Name2Category map[string]Category `thrift:"Name2Category,12" json:"Name2Category"` }
var Include_Reference_DEFAULT *Thrift
func ParseBatchString ¶
func ParseBatchString(mainIDLFilePath string, IDLFileContentMap map[string]string, includeDirs []string) (*Thrift, error)
ParseBatchString parses a group of string content and returns an AST. IDLContent is a map, which's key is IDLPath and value is IDL content.
func ParseFile ¶
ParseFile parses a thrift file and returns an AST. If recursive is true, then the include IDLs are parsed recursively as well.
func ParseString ¶
ParseString parses the thrift file path and file content then return an AST.
func (*Thrift) DepthFirstSearch ¶
DepthFirstSearch returns a channal providing Thrift ASTs in a depth-first order without duplication. Unparsed references will be ignored.
func (*Thrift) ForEachConstant ¶
ForEachConstant calls f on each constant in the current AST.
func (*Thrift) ForEachEnum ¶
ForEachEnum calls f on each enum in the current AST.
func (*Thrift) ForEachException ¶
func (t *Thrift) ForEachException(f func(v *StructLike) bool)
ForEachException calls f on each exception in the current AST.
func (*Thrift) ForEachInclude ¶
ForEachInclude calls f on each include of the current AST.
func (*Thrift) ForEachNamepace ¶
ForEachNamepace calls f on each namespace of the current AST.
func (*Thrift) ForEachService ¶
ForEachService calls f on each service in the current AST.
func (*Thrift) ForEachStruct ¶
func (t *Thrift) ForEachStruct(f func(v *StructLike) bool)
ForEachStruct calls f on each struct in the current AST.
func (*Thrift) ForEachStructLike ¶
func (t *Thrift) ForEachStructLike(f func(v *StructLike) bool)
ForEachStructLike calls f on each struct-like in the current AST.
func (*Thrift) ForEachTypedef ¶
ForEachTypedef calls f on each typedef in the current AST.
func (*Thrift) ForEachUnion ¶
func (t *Thrift) ForEachUnion(f func(v *StructLike) bool)
ForEachUnion calls f on each union in the current AST.
func (*Thrift) GetConstant ¶
GetConstant returns a Constant node that mathces the name.
func (*Thrift) GetConstants ¶
func (*Thrift) GetCppIncludes ¶
func (*Thrift) GetException ¶
func (t *Thrift) GetException(name string) (*StructLike, bool)
GetException returns an Exception that matches the name.
func (*Thrift) GetExceptions ¶
func (p *Thrift) GetExceptions() (v []*StructLike)
func (*Thrift) GetFilename ¶
func (*Thrift) GetIncludes ¶
func (*Thrift) GetName2Category ¶
func (*Thrift) GetNamespace ¶
GetNamespace returns a namespace for the language. When both "*" and the language have a namespace defined, the latter is preferred.
func (*Thrift) GetNamespaceOrReferenceName ¶
GetNamespaceOrReferenceName returns a namespace for the language. If the namespace is not defined, then the base name without extension of the IDL will be returned.
func (*Thrift) GetNamespaces ¶
func (*Thrift) GetReference ¶
GetReference return a AST that matches the given name. References should be initialized before calling this method.
func (*Thrift) GetService ¶
GetService returns a Service node that matches the name.
func (*Thrift) GetServices ¶
func (*Thrift) GetStruct ¶
func (t *Thrift) GetStruct(name string) (*StructLike, bool)
GetStruct returns a Struct node that matches the name.
func (*Thrift) GetStructLikes ¶
func (t *Thrift) GetStructLikes() (ss []*StructLike)
GetStructLikes returns all struct-like definitions in the AST.
func (*Thrift) GetStructs ¶
func (p *Thrift) GetStructs() (v []*StructLike)
func (*Thrift) GetTypedef ¶
GetTypedef returns a Typedef node that matches the alias name.
func (*Thrift) GetTypedefs ¶
func (*Thrift) GetUnion ¶
func (t *Thrift) GetUnion(name string) (*StructLike, bool)
GetUnion returns a Union node that matches the name.
func (*Thrift) GetUnions ¶
func (p *Thrift) GetUnions() (v []*StructLike)
type ThriftIDL ¶
func (*ThriftIDL) PrettyPrintSyntaxTree ¶
func (t *ThriftIDL) PrettyPrintSyntaxTree(buffer string)
func (*ThriftIDL) PrintSyntaxTree ¶
func (p *ThriftIDL) PrintSyntaxTree()
func (*ThriftIDL) SprintSyntaxTree ¶
func (*ThriftIDL) WriteSyntaxTree ¶
type Type ¶
type Type struct { Name string `thrift:"Name,1" json:"Name"` KeyType *Type `thrift:"KeyType,2,optional" json:"KeyType,omitempty"` ValueType *Type `thrift:"ValueType,3,optional" json:"ValueType,omitempty"` CppType string `thrift:"CppType,4" json:"CppType"` Annotations Annotations `thrift:"Annotations,5" json:"Annotations"` Category Category `thrift:"Category,6" json:"Category"` Reference *Reference `thrift:"Reference,7,optional" json:"Reference,omitempty"` IsTypedef *bool `thrift:"IsTypedef,8,optional" json:"IsTypedef,omitempty"` }
var Constant_Type_DEFAULT *Type
var Field_Type_DEFAULT *Type
var Function_FunctionType_DEFAULT *Type
var Type_KeyType_DEFAULT *Type
var Type_ValueType_DEFAULT *Type
var Typedef_Type_DEFAULT *Type
func (*Type) GetAnnotations ¶
func (p *Type) GetAnnotations() (v Annotations)
func (*Type) GetCategory ¶
func (*Type) GetCppType ¶
func (*Type) GetIsTypedef ¶
func (*Type) GetKeyType ¶
func (*Type) GetReference ¶
func (*Type) GetValueType ¶
func (*Type) IsSetIsTypedef ¶
func (*Type) IsSetKeyType ¶
func (*Type) IsSetReference ¶
func (*Type) IsSetValueType ¶
type Typedef ¶
type Typedef struct { Type *Type `thrift:"Type,1,optional" json:"Type,omitempty"` Alias string `thrift:"Alias,2" json:"Alias"` Annotations Annotations `thrift:"Annotations,3" json:"Annotations"` ReservedComments string `thrift:"ReservedComments,4" json:"ReservedComments"` }
func NewTypedef ¶
func NewTypedef() *Typedef
func (*Typedef) GetAnnotations ¶
func (p *Typedef) GetAnnotations() (v Annotations)