gocode

package
v0.0.0-...-f078915 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: BSD-3-Clause Imports: 5 Imported by: 1

README

gocode

import "github.com/blueprint-uservices/blueprint/plugins/golang/gocode"

Package gocode defines basic structs used by IRNodes to describe Golang types, variables, funcs, constructors, and service interfaces.

Index

func IsBasicType

func IsBasicType(name string) bool

Reports whether name is a basic type (e.g. "bool", "string", "int32", "float32", "rune", etc.)

func IsBuiltinPackage

func IsBuiltinPackage(packageName string) bool

Reports whether packageName is a builtin (e.g. "os", "context")

func NameOf

func NameOf[T any]() string

Returns the unqualified shortname for type T

type AnyType

The 'any' type which is just interface{}

type AnyType struct {
    TypeName
}

func (*AnyType) Equals
func (t *AnyType) Equals(other TypeName) bool

func (*AnyType) IsTypeName
func (t *AnyType) IsTypeName()

func (*AnyType) String
func (t *AnyType) String() string

type BasicType

Primitive types that don't need import statements

type BasicType struct {
    TypeName
    Name string
}

func (*BasicType) Equals
func (t *BasicType) Equals(other TypeName) bool

func (*BasicType) IsTypeName
func (t *BasicType) IsTypeName()

func (*BasicType) String
func (t *BasicType) String() string

type Chan

Bidirectional Channel, e.g. chan string, chan *MyType

type Chan struct {
    TypeName
    ChanOf TypeName
}

func (*Chan) Equals
func (t *Chan) Equals(other TypeName) bool

func (*Chan) IsTypeName
func (t *Chan) IsTypeName()

func (*Chan) String
func (t *Chan) String() string

type Constructor

type Constructor struct {
    Func
    Package string
}

type Ellipsis

Ellipsis type used in function arguments, e.g. ...string

type Ellipsis struct {
    TypeName
    EllipsisOf TypeName // Elipsis of TypeName
}

func (*Ellipsis) Equals
func (t *Ellipsis) Equals(other TypeName) bool

func (*Ellipsis) IsTypeName
func (t *Ellipsis) IsTypeName()

func (*Ellipsis) String
func (t *Ellipsis) String() string

type Func

type Func struct {
    service.Method
    Name      string
    Arguments []Variable
    Returns   []Variable
}

func (*Func) AddArgument
func (f *Func) AddArgument(variable Variable)

func (*Func) AddRetVar
func (f *Func) AddRetVar(variable Variable)

func (Func) Equals
func (f Func) Equals(g Func) bool

func (*Func) GetArguments
func (f *Func) GetArguments() []service.Variable

func (*Func) GetName
func (f *Func) GetName() string

func (*Func) GetReturns
func (f *Func) GetReturns() []service.Variable

func (Func) String
func (f Func) String() string

type FuncType

A function signature. For now Blueprint doesn't support

functions in service method declarations, so we don't
bother unravelling and representing the function
declaration here
type FuncType struct {
    TypeName
}

func (*FuncType) Equals
func (t *FuncType) Equals(other TypeName) bool

func (*FuncType) IsTypeName
func (t *FuncType) IsTypeName()

func (*FuncType) String
func (t *FuncType) String() string

type GenericType

A struct with generics. For now blueprint doesn't support generics in service declarations

type GenericType struct {
    TypeName
    BaseType  TypeName
    TypeParam TypeName
}

func (*GenericType) Equals
func (t *GenericType) Equals(other TypeName) bool

func (*GenericType) IsTypeName
func (t *GenericType) IsTypeName()

func (*GenericType) String
func (t *GenericType) String() string

type GenericTypeParam

The type parameter of a generic struct or func

type GenericTypeParam struct {
    TypeName
    ParamName string
}

func (*GenericTypeParam) Equals
func (t *GenericTypeParam) Equals(other TypeName) bool

func (*GenericTypeParam) IsTypeName
func (t *GenericTypeParam) IsTypeName()

func (*GenericTypeParam) String
func (t *GenericTypeParam) String() string

type InterfaceType

An interface of any kind. For now Blueprint doesn't support

interfaces in service method declarations, so we don't
bother unravelling and representing the interface
declaration here
type InterfaceType struct {
    TypeName
}

func (*InterfaceType) Equals
func (t *InterfaceType) Equals(other TypeName) bool

func (*InterfaceType) IsTypeName
func (t *InterfaceType) IsTypeName()

func (*InterfaceType) String
func (t *InterfaceType) String() string

type Map

Map type, e.g. map[string]context.Context

type Map struct {
    TypeName
    KeyType   TypeName
    ValueType TypeName
}

func (*Map) Equals
func (t *Map) Equals(other TypeName) bool

func (*Map) IsTypeName
func (t *Map) IsTypeName()

func (*Map) String
func (m *Map) String() string

type Pointer

Pointer to a type, e.g. *string, *MyType, *context.Context

type Pointer struct {
    TypeName
    PointerTo TypeName // Pointer to TypeName
}

func (*Pointer) Equals
func (t *Pointer) Equals(other TypeName) bool

func (*Pointer) IsTypeName
func (t *Pointer) IsTypeName()

func (*Pointer) String
func (t *Pointer) String() string

type ReceiveChan

Receive-only Channel, e.g. <-chan string, <-chan *MyType

type ReceiveChan struct {
    TypeName
    ReceiveType TypeName
}

func (*ReceiveChan) Equals
func (t *ReceiveChan) Equals(other TypeName) bool

func (*ReceiveChan) IsTypeName
func (t *ReceiveChan) IsTypeName()

func (*ReceiveChan) String
func (t *ReceiveChan) String() string

type SendChan

Send-only Channel, e.g. chan<- string, chan<- *MyType

type SendChan struct {
    TypeName
    SendType TypeName
}

func (*SendChan) Equals
func (t *SendChan) Equals(other TypeName) bool

func (*SendChan) IsTypeName
func (t *SendChan) IsTypeName()

func (*SendChan) String
func (t *SendChan) String() string

type ServiceInterface

Implements service.ServiceInterface

type ServiceInterface struct {
    UserType // Has a Name and a Source location
    BaseName string
    Methods  map[string]Func
}

func CopyServiceInterface
func CopyServiceInterface(name string, pkg string, s *ServiceInterface) *ServiceInterface

func (*ServiceInterface) AddMethod
func (s *ServiceInterface) AddMethod(f Func)

func (*ServiceInterface) Contains
func (i *ServiceInterface) Contains(j *ServiceInterface) bool

Reports whether all of the methods in j exist on interface i

func (*ServiceInterface) GetMethods
func (s *ServiceInterface) GetMethods() []service.Method

func (*ServiceInterface) GetName
func (s *ServiceInterface) GetName() string

func (*ServiceInterface) String
func (i *ServiceInterface) String() string

type Slice

A slice or fixed-size array, e.g. []byte

type Slice struct {
    TypeName
    SliceOf TypeName // Slice of TypeName
}

func (*Slice) Equals
func (t *Slice) Equals(other TypeName) bool

func (*Slice) IsTypeName
func (t *Slice) IsTypeName()

func (*Slice) String
func (t *Slice) String() string

type StructType

An inline struct of any kind. For now Blueprint doesn't

support inline structs in service method declarations, so
we don't bother unravelling and representing the struct here
type StructType struct {
    TypeName
}

func (*StructType) Equals
func (t *StructType) Equals(other TypeName) bool

func (*StructType) IsTypeName
func (t *StructType) IsTypeName()

func (*StructType) String
func (t *StructType) String() string

type TypeName

A type name is the fully qualified name of a type that you use when declaring a variable, including possible imports and go.mod requires

type TypeName interface {
    String() string
    Equals(other TypeName) bool
    IsTypeName()
}

func TypeOf
func TypeOf[T any]() TypeName

Returns a UserType for type T,

type UserType

A type that is declared in a module, thus requiring an import statement and a

go.mod requires statement
type UserType struct {
    TypeName
    Package string
    Name    string // Name of the type within the package
}

func (*UserType) Equals
func (t *UserType) Equals(other TypeName) bool

func (*UserType) IsTypeName
func (t *UserType) IsTypeName()

func (*UserType) String
func (t *UserType) String() string

type Variable

type Variable struct {
    service.Variable
    Name string
    Type TypeName
}

func (*Variable) GetName
func (v *Variable) GetName() string

func (*Variable) GetType
func (v *Variable) GetType() string

func (*Variable) String
func (v *Variable) String() string

Generated by gomarkdoc

Documentation

Overview

Package gocode defines basic structs used by IRNodes to describe Golang types, variables, funcs, constructors, and service interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBasicType

func IsBasicType(name string) bool

Reports whether name is a basic type (e.g. "bool", "string", "int32", "float32", "rune", etc.)

func IsBuiltinPackage

func IsBuiltinPackage(packageName string) bool

Reports whether packageName is a builtin (e.g. "os", "context")

func NameOf

func NameOf[T any]() string

Returns the unqualified shortname for type T

Types

type AnyType

type AnyType struct {
	TypeName
}

The 'any' type which is just interface{}

func (*AnyType) Equals

func (t *AnyType) Equals(other TypeName) bool

func (*AnyType) IsTypeName

func (t *AnyType) IsTypeName()

func (*AnyType) String

func (t *AnyType) String() string

type BasicType

type BasicType struct {
	TypeName
	Name string
}

Primitive types that don't need import statements

func (*BasicType) Equals

func (t *BasicType) Equals(other TypeName) bool

func (*BasicType) IsTypeName

func (t *BasicType) IsTypeName()

func (*BasicType) String

func (t *BasicType) String() string

type Chan

type Chan struct {
	TypeName
	ChanOf TypeName
}

Bidirectional Channel, e.g. chan string, chan *MyType

func (*Chan) Equals

func (t *Chan) Equals(other TypeName) bool

func (*Chan) IsTypeName

func (t *Chan) IsTypeName()

func (*Chan) String

func (t *Chan) String() string

type Constructor

type Constructor struct {
	Func
	Package string
}

type Ellipsis

type Ellipsis struct {
	TypeName
	EllipsisOf TypeName // Elipsis of TypeName
}

Ellipsis type used in function arguments, e.g. ...string

func (*Ellipsis) Equals

func (t *Ellipsis) Equals(other TypeName) bool

func (*Ellipsis) IsTypeName

func (t *Ellipsis) IsTypeName()

func (*Ellipsis) String

func (t *Ellipsis) String() string

type Func

type Func struct {
	service.Method
	Name      string
	Arguments []Variable
	Returns   []Variable
}

func (*Func) AddArgument

func (f *Func) AddArgument(variable Variable)

func (*Func) AddRetVar

func (f *Func) AddRetVar(variable Variable)

func (Func) Equals

func (f Func) Equals(g Func) bool

func (*Func) GetArguments

func (f *Func) GetArguments() []service.Variable

func (*Func) GetName

func (f *Func) GetName() string

func (*Func) GetReturns

func (f *Func) GetReturns() []service.Variable

func (Func) String

func (f Func) String() string

type FuncType

type FuncType struct {
	TypeName
}

A function signature. For now Blueprint doesn't support functions in service method declarations, so we don't bother unravelling and representing the function declaration here

func (*FuncType) Equals

func (t *FuncType) Equals(other TypeName) bool

func (*FuncType) IsTypeName

func (t *FuncType) IsTypeName()

func (*FuncType) String

func (t *FuncType) String() string

type GenericType

type GenericType struct {
	TypeName
	BaseType  TypeName
	TypeParam TypeName
}

A struct with generics. For now blueprint doesn't support generics in service declarations

func (*GenericType) Equals

func (t *GenericType) Equals(other TypeName) bool

func (*GenericType) IsTypeName

func (t *GenericType) IsTypeName()

func (*GenericType) String

func (t *GenericType) String() string

type GenericTypeParam

type GenericTypeParam struct {
	TypeName
	ParamName string
}

The type parameter of a generic struct or func

func (*GenericTypeParam) Equals

func (t *GenericTypeParam) Equals(other TypeName) bool

func (*GenericTypeParam) IsTypeName

func (t *GenericTypeParam) IsTypeName()

func (*GenericTypeParam) String

func (t *GenericTypeParam) String() string

type InterfaceType

type InterfaceType struct {
	TypeName
}

An interface of any kind. For now Blueprint doesn't support interfaces in service method declarations, so we don't bother unravelling and representing the interface declaration here

func (*InterfaceType) Equals

func (t *InterfaceType) Equals(other TypeName) bool

func (*InterfaceType) IsTypeName

func (t *InterfaceType) IsTypeName()

func (*InterfaceType) String

func (t *InterfaceType) String() string

type Map

type Map struct {
	TypeName
	KeyType   TypeName
	ValueType TypeName
}

Map type, e.g. map[string]context.Context

func (*Map) Equals

func (t *Map) Equals(other TypeName) bool

func (*Map) IsTypeName

func (t *Map) IsTypeName()

func (*Map) String

func (m *Map) String() string

type Pointer

type Pointer struct {
	TypeName
	PointerTo TypeName // Pointer to TypeName
}

Pointer to a type, e.g. *string, *MyType, *context.Context

func (*Pointer) Equals

func (t *Pointer) Equals(other TypeName) bool

func (*Pointer) IsTypeName

func (t *Pointer) IsTypeName()

func (*Pointer) String

func (t *Pointer) String() string

type ReceiveChan

type ReceiveChan struct {
	TypeName
	ReceiveType TypeName
}

Receive-only Channel, e.g. <-chan string, <-chan *MyType

func (*ReceiveChan) Equals

func (t *ReceiveChan) Equals(other TypeName) bool

func (*ReceiveChan) IsTypeName

func (t *ReceiveChan) IsTypeName()

func (*ReceiveChan) String

func (t *ReceiveChan) String() string

type SendChan

type SendChan struct {
	TypeName
	SendType TypeName
}

Send-only Channel, e.g. chan<- string, chan<- *MyType

func (*SendChan) Equals

func (t *SendChan) Equals(other TypeName) bool

func (*SendChan) IsTypeName

func (t *SendChan) IsTypeName()

func (*SendChan) String

func (t *SendChan) String() string

type ServiceInterface

type ServiceInterface struct {
	UserType // Has a Name and a Source location
	BaseName string
	Methods  map[string]Func
}

Implements service.ServiceInterface

func CopyServiceInterface

func CopyServiceInterface(name string, pkg string, s *ServiceInterface) *ServiceInterface

func (*ServiceInterface) AddMethod

func (s *ServiceInterface) AddMethod(f Func)

func (*ServiceInterface) Contains

func (i *ServiceInterface) Contains(j *ServiceInterface) bool

Reports whether all of the methods in j exist on interface i

func (*ServiceInterface) GetMethods

func (s *ServiceInterface) GetMethods() []service.Method

func (*ServiceInterface) GetName

func (s *ServiceInterface) GetName() string

func (*ServiceInterface) String

func (i *ServiceInterface) String() string

type Slice

type Slice struct {
	TypeName
	SliceOf TypeName // Slice of TypeName
}

A slice or fixed-size array, e.g. []byte

func (*Slice) Equals

func (t *Slice) Equals(other TypeName) bool

func (*Slice) IsTypeName

func (t *Slice) IsTypeName()

func (*Slice) String

func (t *Slice) String() string

type StructType

type StructType struct {
	TypeName
}

An inline struct of any kind. For now Blueprint doesn't support inline structs in service method declarations, so we don't bother unravelling and representing the struct here

func (*StructType) Equals

func (t *StructType) Equals(other TypeName) bool

func (*StructType) IsTypeName

func (t *StructType) IsTypeName()

func (*StructType) String

func (t *StructType) String() string

type TypeName

type TypeName interface {
	String() string
	Equals(other TypeName) bool
	IsTypeName()
}

A type name is the fully qualified name of a type that you use when declaring a variable, including possible imports and go.mod requires

func TypeOf

func TypeOf[T any]() TypeName

Returns a UserType for type T,

type UserType

type UserType struct {
	TypeName
	Package string
	Name    string // Name of the type within the package
}

A type that is declared in a module, thus requiring an import statement and a go.mod requires statement

func (*UserType) Equals

func (t *UserType) Equals(other TypeName) bool

func (*UserType) IsTypeName

func (t *UserType) IsTypeName()

func (*UserType) String

func (t *UserType) String() string

type Variable

type Variable struct {
	service.Variable
	Name string
	Type TypeName
}

func (*Variable) GetName

func (v *Variable) GetName() string

func (*Variable) GetType

func (v *Variable) GetType() string

func (*Variable) String

func (v *Variable) String() string

Jump to

Keyboard shortcuts

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