sourcecode

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

This package defines source code entities - abstractions that end-user (a programmer) operates on. For convenience these structures have json tags. This is not clean architecture but it's very handy for LSP.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrModNotFound    = errors.New("module not found")
	ErrPkgNotFound    = fmt.Errorf("package not found")
	ErrImportNotFound = errors.New("import not found")
	ErrFileNotFound   = errors.New("file not found")
	ErrEntityNotPub   = errors.New("entity is not public")
)
View Source
var ErrEntityNotFound = errors.New("entity not found")

Functions

This section is empty.

Types

type ArrayBypassConnection added in v0.6.3

type ArrayBypassConnection struct {
	SenderOutport  PortAddr `json:"senderOutport,omitempty"`
	ReceiverInport PortAddr `json:"receiverOutport,omitempty"`
}

type Build

type Build struct {
	EntryModRef ModuleRef            `json:"entryModRef,omitempty"`
	Modules     map[ModuleRef]Module `json:"modules,omitempty"`
}

type Component

type Component struct {
	Directives map[Directive][]string `json:"directives,omitempty"`
	Interface  `json:"interface,omitempty"`
	Nodes      map[string]Node `json:"nodes,omitempty"`
	Net        []Connection    `json:"net,omitempty"`
	Meta       Meta            `json:"meta,omitempty"`
}

type Connection

type Connection struct {
	Normal      *NormalConnection      `json:"normal,omitempty"`
	ArrayBypass *ArrayBypassConnection `json:"arrayBypass,omitempty"`
	Meta        Meta                   `json:"meta,omitempty"`
}

type ConnectionReceiver

type ConnectionReceiver struct {
	PortAddr  PortAddr                `json:"portAddr,omitempty"`
	Selectors ConnectionSideSelectors `json:"selectors,omitempty"`
	Meta      Meta                    `json:"meta,omitempty"`
}

func (ConnectionReceiver) String

func (r ConnectionReceiver) String() string

type ConnectionReceiverSide

type ConnectionReceiverSide struct {
	DeferredConnections []Connection         `json:"deferredConnections,omitempty"`
	Receivers           []ConnectionReceiver `json:"receivers,omitempty"`
}

type ConnectionSenderSide

type ConnectionSenderSide struct {
	PortAddr  *PortAddr `json:"portAddr,omitempty"`
	Const     *Const    `json:"literal,omitempty"`
	Selectors []string  `json:"selectors,omitempty"`
	Meta      Meta      `json:"meta,omitempty"`
}

ConnectionSenderSide unlike ReceiverConnectionSide could refer to constant.

func (ConnectionSenderSide) String

func (s ConnectionSenderSide) String() string

type ConnectionSideSelectors

type ConnectionSideSelectors []string

func (ConnectionSideSelectors) String

func (c ConnectionSideSelectors) String() string

type Const

type Const struct {
	Ref     *EntityRef `json:"ref,omitempty"`
	Message *Message   `json:"value,omitempty"`
	Meta    Meta       `json:"meta,omitempty"`
}

func (Const) String added in v0.8.0

func (c Const) String() string

type Directive

type Directive string

type Entity

type Entity struct {
	IsPublic  bool       `json:"exported,omitempty"`
	Kind      EntityKind `json:"kind,omitempty"`
	Const     Const      `json:"const,omitempty"`
	Type      ts.Def     `json:"type,omitempty"`
	Interface Interface  `json:"interface,omitempty"`
	Component Component  `json:"component,omitempty"`
}

func (Entity) Meta

func (e Entity) Meta() *Meta

type EntityKind

type EntityKind string // It's handy to transmit strings enum instead of digital
const (
	ComponentEntity EntityKind = "component_entity"
	ConstEntity     EntityKind = "const_entity"
	TypeEntity      EntityKind = "type_entity"
	InterfaceEntity EntityKind = "interface_entity"
)

type EntityRef

type EntityRef struct {
	Pkg  string `json:"pkg,omitempty"`
	Name string `json:"name,omitempty"`
	Meta Meta   `json:"meta,omitempty"`
}

func (EntityRef) String

func (e EntityRef) String() string

type EnumMessage added in v0.8.0

type EnumMessage struct {
	EnumRef    EntityRef
	MemberName string
}

type File

type File struct {
	Imports  map[string]Import `json:"imports,omitempty"`
	Entities map[string]Entity `json:"entities,omitempty"`
}

type IO

type IO struct {
	In  map[string]Port `json:"in,omitempty"`
	Out map[string]Port `json:"out,omitempty"`
}

type Import

type Import struct {
	Module  string `json:"moduleName,omitempty"`
	Package string `json:"pkgName,omitempty"`
}

type Interface

type Interface struct {
	TypeParams TypeParams `json:"typeParams,omitempty"`
	IO         IO         `json:"io,omitempty,"`
	Meta       Meta       `json:"meta,omitempty"`
}

type Location

type Location struct {
	ModRef   ModuleRef
	PkgName  string
	FileName string
}

func (Location) String

func (l Location) String() string

type Message

type Message struct {
	TypeExpr    ts.Expr          `json:"typeExpr,omitempty"`
	Bool        *bool            `json:"bool,omitempty"`
	Int         *int             `json:"int,omitempty"`
	Float       *float64         `json:"float,omitempty"`
	Str         *string          `json:"str,omitempty"`
	List        []Const          `json:"vec,omitempty"`
	MapOrStruct map[string]Const `json:"map,omitempty"`
	Enum        *EnumMessage     `json:"enum,omitempty"`
	Meta        Meta             `json:"meta,omitempty"`
}

func (Message) String

func (m Message) String() string

type Meta

type Meta struct {
	Text  string   `json:"text,omitempty"`
	Start Position `json:"start,omitempty"`
	Stop  Position `json:"stop,omitempty"`
}

Meta keeps info about original text related to the structured object

type Module

type Module struct {
	Manifest ModuleManifest     `json:"manifest,omitempty"`
	Packages map[string]Package `json:"packages,omitempty"`
}

func (Module) Entity

func (mod Module) Entity(entityRef EntityRef) (entity Entity, filename string, err error)

func (Module) Files

func (mod Module) Files(f func(file File, pkgName, fileName string))

type ModuleManifest

type ModuleManifest struct {
	LanguageVersion string               `json:"neva,omitempty" yaml:"neva,omitempty"`
	Deps            map[string]ModuleRef `json:"deps,omitempty" yaml:"deps,omitempty"`
}

type ModuleRef

type ModuleRef struct {
	Path    string `json:"path,omitempty"`
	Version string `json:"version,omitempty"`
}

func (ModuleRef) String

func (m ModuleRef) String() string

type Node

type Node struct {
	Directives map[Directive][]string `json:"directives,omitempty"`
	EntityRef  EntityRef              `json:"entityRef,omitempty"`
	TypeArgs   TypeArgs               `json:"typeArgs,omitempty"`
	Deps       map[string]Node        `json:"componentDi,omitempty"`
	Meta       Meta                   `json:"meta,omitempty"`
}

func (Node) String

func (n Node) String() string

type NormalConnection added in v0.6.3

type NormalConnection struct {
	SenderSide   ConnectionSenderSide   `json:"senderSide,omitempty"`
	ReceiverSide ConnectionReceiverSide `json:"receiverSide,omitempty"`
}

type Package

type Package map[string]File

func (Package) Entities

func (p Package) Entities(f func(entity Entity, entityName string, fileName string) error) error

func (Package) Entity

func (p Package) Entity(entityName string) (entity Entity, filename string, ok bool)

Just like program's Entity

type Port

type Port struct {
	TypeExpr ts.Expr `json:"typeExpr,omitempty"`
	IsArray  bool    `json:"isArray,omitempty"`
	Meta     Meta    `json:"meta,omitempty"`
}

type PortAddr

type PortAddr struct {
	Node string `json:"node,omitempty"`
	Port string `json:"port,omitempty"`
	Idx  *uint8 `json:"idx,omitempty"`
	Meta Meta   `json:"meta,omitempty"`
}

func (PortAddr) String

func (p PortAddr) String() string

type Position

type Position struct {
	Line   int `json:"line,omitempty"`
	Column int `json:"column,omitempty"`
}

func (Position) String

func (p Position) String() string

type Scope

type Scope struct {
	Location Location
	Build    Build
}

func (Scope) Entity

func (s Scope) Entity(entityRef EntityRef) (Entity, Location, error)

func (Scope) GetType

func (s Scope) GetType(ref fmt.Stringer) (ts.Def, ts.Scope, error)

func (Scope) IsTopType

func (s Scope) IsTopType(expr ts.Expr) bool

func (Scope) WithLocation

func (s Scope) WithLocation(location Location) Scope

type TypeArgs

type TypeArgs []ts.Expr

func (TypeArgs) String

func (t TypeArgs) String() string

type TypeParams

type TypeParams struct {
	Params []ts.Param `json:"params,omitempty"`
	Meta   Meta       `json:"meta,omitempty"`
}

func (TypeParams) String

func (t TypeParams) String() string

func (TypeParams) ToFrame added in v0.4.0

func (t TypeParams) ToFrame() map[string]ts.Def

Jump to

Keyboard shortcuts

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