ast

package
v0.30.4 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckOption added in v0.30.1

func CheckOption(bearer OptionsBearer, optName string) *optChecker

func Equal

func Equal(x, y Unique) bool

Equal проверка равенства нод Unique

func FieldIndex

func FieldIndex(f Field) int

FieldIndex возвращает индекс поля

func FieldName

func FieldName(f Field) string

FieldName возвращает название поля

func GetFieldKey

func GetFieldKey(k Unique, fieldAddr interface{}) string

GetFieldKey получает ключ для поля данного k

func GetUnique

func GetUnique(k Unique) string

GetUnique получает ключ для данного k

func IsErrorTypeNotFound

func IsErrorTypeNotFound(err error) bool

IsErrorTypeNotFound проверка, что данная ошибка является обёрткой для ErrorTypeNotFound

func SamePrimitive

func SamePrimitive(x, y Type) bool

SamePrimitive проверка равенства примитивных типов

func SetUnique

func SetUnique(k Unique, ctx UniqueContext)

SetUnique устанавливает уникальное в рамках UniqueContext значение для данного Unique

Types

type Any

type Any struct {
	File *File
	// contains filtered or unexported fields
}

Any представление типа golang.protobuf.Any

func (*Any) GetFullName added in v0.30.3

func (*Any) GetFullName() string

func (*Any) GetName added in v0.30.3

func (*Any) GetName() string

type ArrayOption

type ArrayOption struct {
	Value []OptionValue
	// contains filtered or unexported fields
}

ArrayOption branch of OptionValue

type Bool

type Bool struct {
	// contains filtered or unexported fields
}

Bool представление булевского типа

func (*Bool) GetFullName added in v0.30.3

func (*Bool) GetFullName() string

func (*Bool) GetName added in v0.30.3

func (*Bool) GetName() string

type BoolOption

type BoolOption struct {
	Value bool
	// contains filtered or unexported fields
}

BoolOption branch of OptionValue

func (*BoolOption) GetValue added in v0.30.2

func (o *BoolOption) GetValue() interface{}

func (*BoolOption) String

func (o *BoolOption) String() string

type Bytes

type Bytes struct {
	// contains filtered or unexported fields
}

Bytes представление типа bytes

func (*Bytes) GetFullName added in v0.30.3

func (*Bytes) GetFullName() string

func (*Bytes) GetName added in v0.30.3

func (*Bytes) GetName() string

type Comment

type Comment struct {
	Value string
	Lines []string
	// contains filtered or unexported fields
}

Comment представление комментария

func (*Comment) GetLines added in v0.30.1

func (c *Comment) GetLines() []string

func (*Comment) GetValue added in v0.30.1

func (c *Comment) GetValue() string

type Commented added in v0.30.1

type Commented interface {
	GetComment() *Comment
}

type Compound added in v0.30.1

type Compound interface {
	Named
	GetParentMsg() *Message
}

Compound типы, входящие в состав других типов.

type EmbeddedOption

type EmbeddedOption struct {
	Value string
	// contains filtered or unexported fields
}

EmbeddedOption представление встроенной опции

func (*EmbeddedOption) GetValue added in v0.30.1

func (o *EmbeddedOption) GetValue() interface{}

type Enum

type Enum struct {
	File      *File
	ParentMsg *Message

	Name    string
	Comment *Comment
	Options []*Option
	Values  []*EnumValue
	// contains filtered or unexported fields
}

Enum представление типа enum

func (*Enum) GetComment added in v0.30.1

func (e *Enum) GetComment() *Comment

func (*Enum) GetFullName added in v0.30.3

func (e *Enum) GetFullName() string

func (*Enum) GetName

func (e *Enum) GetName() string

func (*Enum) String

func (e *Enum) String() string

Enum референс-имя перечисления, включает в себя название пакета, имена родительских сообщений, в пространстве имён которых оно определено.

type EnumOption

type EnumOption struct {
	Value *EnumValue
	// contains filtered or unexported fields
}

EnumOption представление опций типа Enum

func (*EnumOption) GetValue added in v0.30.1

func (o *EnumOption) GetValue() interface{}

type EnumValue

type EnumValue struct {
	Name    string
	Comment *Comment
	Integer int
	Options []*Option
	// contains filtered or unexported fields
}

EnumValue представление поля для Enum-а

func (*EnumValue) GetComment added in v0.30.1

func (e *EnumValue) GetComment() *Comment

func (*EnumValue) GetFullName added in v0.30.3

func (e *EnumValue) GetFullName() string

func (*EnumValue) GetName

func (e *EnumValue) GetName() string

type ErrorPackageMissingFiles

type ErrorPackageMissingFiles struct{}

ErrorPackageMissingFiles ошибка указывающая на отсутствие proto-файлов в пакете

func (ErrorPackageMissingFiles) Error

type ErrorTypeNotFound

type ErrorTypeNotFound string

ErrorTypeNotFound ошибка возвращаемая если тип не был найден

func (ErrorTypeNotFound) Error

func (e ErrorTypeNotFound) Error() string

type Extension

type Extension struct {
	File      *File
	ParentMsg *Message

	Name   string
	Fields []*ExtensionField
	Types  []Type
	// contains filtered or unexported fields
}

Extension представление extension

func MessageToExtension

func MessageToExtension(msg *Message) *Extension

MessageToExtension копирует Message в Extension с сохранением всей информации

type ExtensionField

type ExtensionField struct {
	Name     string
	Sequence int
	Type     Type
	Options  []*Option
	// contains filtered or unexported fields
}

ExtensionField представление поля extension-а

type Field

type Field interface {
	Unique
	Named
	Commented
	OptionsBearer
	// contains filtered or unexported methods
}

Field представление сущности являющейся полем сообщения. Это может быть как непосредственно поле, так и ветвь oneof-а

type File

type File struct {
	Name    string
	Package string
	Syntax  string

	Imports    []*Import
	Types      []Type
	Extensions []*Extension
	Services   []*Service
	Options    []*Option

	GoPath string
	GoPkg  string
	// contains filtered or unexported fields
}

File представление для файла

func (*File) Enum

func (f *File) Enum(name string) (*Enum, error)

Enum поиск перечисления по имени Возвращает ошибку ErrorTypeNotFound если такой тип с таким именем не найден.

func (*File) GetOptions added in v0.30.1

func (f *File) GetOptions() []*Option

func (*File) Message

func (f *File) Message(name string) (*Message, error)

Message поиск структуры по имени. Возвращает ошибку ErrorTypeNotFound если такой тип с таким именем не найден.

func (*File) ScanTypes

func (f *File) ScanTypes(inspector func(typ Type) bool)

ScanTypes пробежка по типам данного пакета

func (*File) Service

func (f *File) Service(name string) *Service

Service поиск сервиса по имени

func (*File) Type

func (f *File) Type(name string) Type

Type поиск типа по имени.

type FileManager

type FileManager interface {
	// Create возвращаем пару writer и функцию закрытия файла вместо одного io.WriteClose для удобства в тестах
	// Плюс, этот интерфейс будет использоваться только внутри приложения
	Create(name string) (writer io.Writer, closer func() error, err error)
}

FileManager работа с записываемыми файлами

func NewFileManager

func NewFileManager(root string) FileManager

NewFileManager реализация управления файлами на уровне файловой системы

type Fixed32

type Fixed32 struct {
	// contains filtered or unexported fields
}

Fixed32 представление типа fixed32

func (*Fixed32) GetFullName added in v0.30.3

func (*Fixed32) GetFullName() string

func (*Fixed32) GetName added in v0.30.3

func (*Fixed32) GetName() string

type Fixed64

type Fixed64 struct {
	// contains filtered or unexported fields
}

Fixed64 представление типа fixed64

func (*Fixed64) GetFullName added in v0.30.3

func (*Fixed64) GetFullName() string

func (*Fixed64) GetName added in v0.30.3

func (*Fixed64) GetName() string

type Float32

type Float32 struct {
	// contains filtered or unexported fields
}

Float32 представление типа float

func (*Float32) GetFullName added in v0.30.3

func (*Float32) GetFullName() string

func (*Float32) GetName added in v0.30.3

func (*Float32) GetName() string

type Float64

type Float64 struct {
	// contains filtered or unexported fields
}

Float64 представление типа double

func (*Float64) GetFullName added in v0.30.3

func (*Float64) GetFullName() string

func (*Float64) GetName added in v0.30.3

func (*Float64) GetName() string

type FloatOption

type FloatOption struct {
	Value float64
	// contains filtered or unexported fields
}

FloatOption branch of OptionValue

func (*FloatOption) GetValue added in v0.30.1

func (o *FloatOption) GetValue() interface{}

func (*FloatOption) String

func (o *FloatOption) String() string

type Hashable

type Hashable interface {
	ScalarNode
	// contains filtered or unexported methods
}

Hashable типы могущие являться ключами словарей

type Import

type Import struct {
	Path string
	File *File
	// contains filtered or unexported fields
}

Import представление для импортов

type Int32

type Int32 struct {
	// contains filtered or unexported fields
}

Int32 представление типа int32

func (*Int32) GetFullName added in v0.30.3

func (*Int32) GetFullName() string

func (*Int32) GetName added in v0.30.3

func (*Int32) GetName() string

type Int64

type Int64 struct {
	// contains filtered or unexported fields
}

Int64 представление типа int64

func (*Int64) GetFullName added in v0.30.3

func (*Int64) GetFullName() string

func (*Int64) GetName added in v0.30.3

func (*Int64) GetName() string

type IntOption

type IntOption struct {
	Value int64
	// contains filtered or unexported fields
}

IntOption branch of OptionValue

func (*IntOption) GetValue added in v0.30.1

func (o *IntOption) GetValue() interface{}

func (*IntOption) String

func (o *IntOption) String() string

type Map

type Map struct {
	KeyType   Hashable
	ValueType Type
	// contains filtered or unexported fields
}

Map представление типа map<KeyType, ValueType>

type MapOption

type MapOption struct {
	Value map[string]OptionValue
	// contains filtered or unexported fields
}

MapOption branch of OptionValue

type Message

type Message struct {
	File      *File
	ParentMsg *Message

	Name    string
	Comment *Comment
	Fields  []*MessageField
	Types   []Type
	Options []*Option
	// contains filtered or unexported fields
}

Message представление message

func (*Message) AllFields

func (m *Message) AllFields() []Field

AllFields возвращает поля и ветви oneof данного сообщения единым списком

func (*Message) Enum

func (m *Message) Enum(name string) (*Enum, error)

Enum поиск вложенного перечисления по имени. Возвращает ошибку ErrorTypeNotFound если такой тип с таким именем не найден.

func (*Message) Field

func (m *Message) Field(name string) *MessageField

Field возвращает поле мессаджа по имени. Не производит нормализации по oneof-ам.

func (*Message) FieldOneof

func (m *Message) FieldOneof(name string) Field

FieldOneof возвращает поле мессаджа по имени, при этом залезает, если нужно, внутрь oneof-а

func (*Message) GetComment added in v0.30.1

func (m *Message) GetComment() *Comment

func (*Message) GetFullName added in v0.30.3

func (m *Message) GetFullName() string

func (*Message) GetName

func (m *Message) GetName() string

func (*Message) GetOptions added in v0.30.1

func (m *Message) GetOptions() []*Option

func (*Message) GetParentMsg

func (m *Message) GetParentMsg() *Message

func (*Message) Message

func (m *Message) Message(name string) (*Message, error)

Message поиск подструктуры по имени. Возвращает ошибку ErrorTypeNotFound если такой тип с таким именем не найден.

func (*Message) ScanTypes

func (m *Message) ScanTypes(inspector func(typ Type) bool)

ScanTypes пробежка по внутренним типам данной структуры

func (*Message) String

func (m *Message) String() string

String референс-имя сообщения, включает в себя название пакета, имена родительских сообщений, в пространстве имён которых оно определено.

func (*Message) Type

func (m *Message) Type(name string) Type

Type поиск подтипа по имени

type MessageField

type MessageField struct {
	Name     string
	Comment  *Comment
	Sequence int
	Type     Type
	Options  []*Option
	// contains filtered or unexported fields
}

MessageField представление поля message-а

func (*MessageField) GetComment added in v0.30.1

func (m *MessageField) GetComment() *Comment

func (*MessageField) GetFullName added in v0.30.3

func (m *MessageField) GetFullName() string

func (*MessageField) GetName added in v0.30.1

func (m *MessageField) GetName() string

func (*MessageField) GetOptions added in v0.30.1

func (m *MessageField) GetOptions() []*Option

type Method

type Method struct {
	File    *File
	Service *Service

	Name    string
	Comment *Comment
	Input   Type
	Output  Type

	Options []*Option
	// contains filtered or unexported fields
}

Method представление для метода

func (*Method) GetComment added in v0.30.1

func (m *Method) GetComment() *Comment

func (*Method) GetFullName added in v0.30.3

func (m *Method) GetFullName() string

func (*Method) GetMethodType added in v0.30.4

func (m *Method) GetMethodType() MethodType

GetMethodType возвращает тип метода.

func (*Method) GetName

func (m *Method) GetName() string

func (*Method) GetOptions added in v0.30.1

func (m *Method) GetOptions() []*Option

func (*Method) InputMessage

func (m *Method) InputMessage() *Message

InputMessage возвращает структуру запроса (минуя оборачивающий Stream, если нужно)

func (*Method) OutputMessage

func (m *Method) OutputMessage() *Message

OutputMessage аналогично InputMessage, возвращает структуру ответа, при необходимости снимая stream

type MethodType added in v0.30.4

type MethodType byte

MethodType тип метода: унарный, входящий/исходящий/двунаправленный потоковый.

const (
	Unary MethodType
	InputStream
	OutputStream
	BidirectionalStream
)

Типы методов.

type Named

type Named interface {
	GetName() string
	GetFullName() string
}

Named типы имеющие имя.

type Node

type Node interface {
	Unique
	// contains filtered or unexported methods
}

Node представление базовой ноды

type OneOf

type OneOf struct {
	ParentMsg *Message

	Name     string
	Branches []*OneOfBranch
	// contains filtered or unexported fields
}

OneOf представление для oneof поля message-а

func (*OneOf) GetFullName added in v0.30.3

func (o *OneOf) GetFullName() string

func (*OneOf) GetName

func (o *OneOf) GetName() string

func (*OneOf) GetParentMsg

func (o *OneOf) GetParentMsg() *Message

func (*OneOf) String added in v0.30.3

func (m *OneOf) String() string

String референс-имя сообщения, включает в себя название пакета, имена родительских сообщений, в пространстве имён которых оно определено.

type OneOfBranch

type OneOfBranch struct {
	Name     string
	Comment  *Comment
	Type     Type
	ParentOO *OneOf
	Sequence int
	Options  []*Option
	// contains filtered or unexported fields
}

OneOfBranch представление для ветви

func (*OneOfBranch) GetComment added in v0.30.1

func (o *OneOfBranch) GetComment() *Comment

func (*OneOfBranch) GetFullName added in v0.30.3

func (o *OneOfBranch) GetFullName() string

func (*OneOfBranch) GetName

func (o *OneOfBranch) GetName() string

func (*OneOfBranch) GetOptions added in v0.30.1

func (o *OneOfBranch) GetOptions() []*Option

type Option

type Option struct {
	Name      string
	Value     OptionValue
	Extension *Extension
	// contains filtered or unexported fields
}

Option опция

func FieldOptions

func FieldOptions(f Field) []*Option

FieldOptions возвращает опции поля

func (*Option) GetFullName added in v0.30.3

func (o *Option) GetFullName() string

func (*Option) GetName

func (o *Option) GetName() string

type OptionValue

type OptionValue interface {
	Unique
	// contains filtered or unexported methods
}

OptionValue значение опции

type Optional

type Optional struct {
	Type Type
	// contains filtered or unexported fields
}

Optional представление для опциональных полей

type OptionsBearer added in v0.30.1

type OptionsBearer interface {
	GetOptions() []*Option
}

OptionsBearer типы, которые могут содержать proto-опции.

type Package

type Package struct {
	// contains filtered or unexported fields
}

Package представление пакета прото-файлов. Данная структура введена скорее для удобства, т.к. понятия пакет в смысле группа файлов с одинаковым именем package в protobuf нет — файлы не попадают на трансляцию автоматически, а добавляются туда вручную, при трансляции они могут попасть в различные целевые каталоги и т.д.

func NewPackage

func NewPackage(files []*File) (*Package, error)

NewPackage конструктор пакета прото-файлов. Если список files пуст возвращается ошибка ErrorPackageMissingFiles

func (*Package) Enum

func (s *Package) Enum(name string) (*Enum, error)

Enum поиск перечисления по имени Возвращает ошибку ast.ErrorTypeNotFound если такой тип с таким именем не найден.

func (*Package) File

func (s *Package) File(name string) (*File, error)

File отдать файл с данным именем. Функция path.Split вызванная на имени файла должна возвращать только пустое значение dir.

Правильные названия файлов при вызове: error_codes.proto, marker.proto, atlas Неправильные названия файлов: atlas/atlas.proto, /atlas.proto

func (*Package) Files

func (s *Package) Files() []*File

Files получить все файлы текущего пакета

func (*Package) GoPkg

func (s *Package) GoPkg() string

GoPkg go-пакета

func (*Package) Message

func (s *Package) Message(name string) (*Message, error)

Message поиск структуры по имени. Возвращает ошибку ast.ErrorTypeNotFound если такой тип с таким именем не найден.

func (*Package) Pkg

func (s *Package) Pkg() string

Pkg имя proto-пакета

func (*Package) ScanTypes

func (s *Package) ScanTypes(inspector func(p Type) bool)

ScanTypes пробежка по всем типам пакета, включая и вложенные

func (*Package) Service

func (s *Package) Service(name string) *Service

Service поиск сервиса с данным именем в пространстве имён пакета

func (*Package) Services

func (s *Package) Services() []*Service

Services получить все сервисы текущего пакета

func (*Package) Type

func (s *Package) Type(name string) Type

Type поиск типа с данным именем в корневом пространстве имён пакета

func (*Package) Types

func (s *Package) Types() []Type

Types получить все типы текущего пакета лежащие в корне пакета

type Printer

type Printer struct {
	// contains filtered or unexported fields
}

Printer печать файлов

func NewPrinter

func NewPrinter(fm FileManager) *Printer

NewPrinter конструктор принтера файлов

func (*Printer) Plan

func (p *Printer) Plan(f *File)

Plan добавить файл в план печати

func (*Printer) Print

func (p *Printer) Print(file *File) error

Print печать файла и всех его зависимостей

type Repeated

type Repeated struct {
	Type Type
	// contains filtered or unexported fields
}

Repeated представление для полей с repeeated

type ScalarNode

type ScalarNode interface {
	Type
	// contains filtered or unexported methods
}

ScalarNode скалярные типы

type Service

type Service struct {
	File *File

	Name    string
	Comment *Comment
	Methods []*Method
	Options []*Option
	// contains filtered or unexported fields
}

Service представление для сервисов

func (*Service) GetComment added in v0.30.1

func (s *Service) GetComment() *Comment

func (*Service) GetFullName added in v0.30.3

func (s *Service) GetFullName() string

func (*Service) GetName

func (s *Service) GetName() string

func (*Service) GetOptions added in v0.30.1

func (s *Service) GetOptions() []*Option

func (*Service) Method

func (s *Service) Method(name string) *Method

Method поиск метода по имени

type Sfixed32

type Sfixed32 struct {
	// contains filtered or unexported fields
}

Sfixed32 представление для типа sfixed32

func (*Sfixed32) GetFullName added in v0.30.3

func (*Sfixed32) GetFullName() string

func (*Sfixed32) GetName added in v0.30.3

func (*Sfixed32) GetName() string

type Sfixed64

type Sfixed64 struct {
	// contains filtered or unexported fields
}

Sfixed64 представление для типа sfixed64

func (*Sfixed64) GetFullName added in v0.30.3

func (*Sfixed64) GetFullName() string

func (*Sfixed64) GetName added in v0.30.3

func (*Sfixed64) GetName() string

type Sint32

type Sint32 struct {
	// contains filtered or unexported fields
}

Sint32 представление для типа sint32

func (*Sint32) GetFullName added in v0.30.3

func (*Sint32) GetFullName() string

func (*Sint32) GetName added in v0.30.3

func (*Sint32) GetName() string

type Sint64

type Sint64 struct {
	// contains filtered or unexported fields
}

Sint64 представление типа sint64

func (*Sint64) GetFullName added in v0.30.3

func (*Sint64) GetFullName() string

func (*Sint64) GetName added in v0.30.3

func (*Sint64) GetName() string

type Stream

type Stream struct {
	Type Type
	// contains filtered or unexported fields
}

Stream представление для stream-аргументов и возвращаемых значений метода

type String

type String struct {
	// contains filtered or unexported fields
}

String представление для стрового типа

func (*String) GetFullName added in v0.30.3

func (*String) GetFullName() string

func (*String) GetName added in v0.30.3

func (*String) GetName() string

type StringOption

type StringOption struct {
	Value string
	// contains filtered or unexported fields
}

StringOption branch of OptionValue

func (*StringOption) GetValue added in v0.30.1

func (o *StringOption) GetValue() interface{}

func (*StringOption) String

func (o *StringOption) String() string

type Type

type Type interface {
	Node
	// contains filtered or unexported methods
}

Type представление типа

func FieldType

func FieldType(f Field) Type

FieldType возвращает тип поля

type Uint32

type Uint32 struct {
	// contains filtered or unexported fields
}

Uint32 представление для типа uint32

func (*Uint32) GetFullName added in v0.30.3

func (*Uint32) GetFullName() string

func (*Uint32) GetName added in v0.30.3

func (*Uint32) GetName() string

type Uint64

type Uint64 struct {
	// contains filtered or unexported fields
}

Uint64 представление для типа uint64

func (*Uint64) GetFullName added in v0.30.3

func (*Uint64) GetFullName() string

func (*Uint64) GetName added in v0.30.3

func (*Uint64) GetName() string

type UintOption

type UintOption struct {
	Value uint64
	// contains filtered or unexported fields
}

UintOption branch of OptionValue

func (*UintOption) GetValue added in v0.30.1

func (o *UintOption) GetValue() interface{}

func (*UintOption) String

func (o *UintOption) String() string

type Unique

type Unique interface {
	// contains filtered or unexported methods
}

Unique интерфейс для уникализации инстансов в AST привязывающий к данному объекту некое уникальное для контекстного множества значение

type UniqueContext

type UniqueContext map[string]struct{}

UniqueContext контекст для создания уникальных значений

type Valuable added in v0.30.1

type Valuable interface {
	GetValue() interface{}
}

Valuable типы имеющие значение.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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