analysis

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const FnSetAccountMeta = "set_account_meta"
View Source
const FnSetTxMeta = "set_tx_meta"
View Source
const FnVarOriginBalance = "balance"
View Source
const FnVarOriginGetAmount = "get_amount"
View Source
const FnVarOriginGetAsset = "get_asset"
View Source
const FnVarOriginMeta = "meta"
View Source
const FnVarOriginOverdraft = "overdraft"
View Source
const TypeAccount = "account"
View Source
const TypeAny = "any"
View Source
const TypeAsset = "asset"
View Source
const TypeMonetary = "monetary"
View Source
const TypeNumber = "number"
View Source
const TypePortion = "portion"
View Source
const TypeString = "string"

Variables

View Source
var Builtins = map[string]FnCallResolution{
	FnSetTxMeta: StatementFnCallResolution{
		Params: []string{TypeString, TypeAny},
		Docs:   "set transaction metadata",
	},
	FnSetAccountMeta: StatementFnCallResolution{
		Params: []string{TypeAccount, TypeString, TypeAny},
		Docs:   "set account metadata",
	},
	FnVarOriginMeta: VarOriginFnCallResolution{
		Params: []string{TypeAccount, TypeString},
		Return: TypeAny,
		Docs:   "fetch account metadata",
	},
	FnVarOriginBalance: VarOriginFnCallResolution{
		Params: []string{TypeAccount, TypeAsset},
		Return: TypeMonetary,
		Docs:   "fetch account balance",
	},
	FnVarOriginOverdraft: VarOriginFnCallResolution{
		Params: []string{TypeAccount, TypeAsset},
		Return: TypeMonetary,
		Docs:   "get absolute amount of the overdraft of an account. Returns zero if balance is not negative",
		VersionConstraints: []VersionClause{
			{
				Version:     parser.NewVersionInterpreter(0, 0, 15),
				FeatureFlag: flags.ExperimentalOverdraftFunctionFeatureFlag,
			},
		},
	},
	FnVarOriginGetAsset: VarOriginFnCallResolution{
		Params: []string{TypeMonetary},
		Return: TypeAsset,
		Docs:   "get the asset of the given monetary",
		VersionConstraints: []VersionClause{
			{
				Version:     parser.NewVersionInterpreter(0, 0, 16),
				FeatureFlag: flags.ExperimentalGetAssetFunctionFeatureFlag,
			},
		},
	},
	FnVarOriginGetAmount: VarOriginFnCallResolution{
		Params: []string{TypeMonetary},
		Return: TypeNumber,
		Docs:   "get the amount of the given monetary",
		VersionConstraints: []VersionClause{
			{
				Version:     parser.NewVersionInterpreter(0, 0, 16),
				FeatureFlag: flags.ExperimentalGetAmountFunctionFeatureFlag,
			},
		},
	},
}

Functions

func SeverityToAnsiString

func SeverityToAnsiString(s Severity) string

func SeverityToString added in v0.0.20

func SeverityToString(s Severity) string

func TypeToString added in v0.0.20

func TypeToString(r Type) string

func Unify added in v0.0.20

func Unify(t1 Type, t2 Type) (ok bool)

Types

type AssetMismatch added in v0.0.20

type AssetMismatch struct {
	Expected string
	Got      string
}

func (AssetMismatch) Message added in v0.0.20

func (e AssetMismatch) Message() string

func (AssetMismatch) Severity added in v0.0.20

func (AssetMismatch) Severity() Severity

type BadAllotmentSum

type BadAllotmentSum struct {
	Sum big.Rat
}

func (BadAllotmentSum) Message

func (e BadAllotmentSum) Message() string

func (BadAllotmentSum) Severity

func (BadAllotmentSum) Severity() Severity

type BadArity

type BadArity struct {
	Expected int
	Actual   int
}

func (BadArity) Message

func (e BadArity) Message() string

func (BadArity) Severity

func (BadArity) Severity() Severity

type BuiltinFnHover

type BuiltinFnHover struct {
	Range   parser.Range
	Node    *parser.FnCall
	Context BuiltinFnHoverContext
}

type BuiltinFnHoverContext

type BuiltinFnHoverContext = uint
const (
	OriginContext BuiltinFnHoverContext = iota
	StatementContext
)

type CheckResult

type CheckResult struct {
	DeclaredVars map[string]parser.VarDeclaration

	Diagnostics []Diagnostic
	Program     parser.Program
	// contains filtered or unexported fields
}

func CheckProgram

func CheckProgram(program parser.Program) CheckResult

func CheckSource

func CheckSource(source string) CheckResult

func (CheckResult) GetErrorsCount

func (r CheckResult) GetErrorsCount() int

func (*CheckResult) GetExprType added in v0.0.20

func (r *CheckResult) GetExprType(expr parser.ValueExpr) Type

func (*CheckResult) GetSymbols

func (r *CheckResult) GetSymbols() []DocumentSymbol

results are sorted by start position

func (*CheckResult) GetVarDeclType added in v0.0.20

func (r *CheckResult) GetVarDeclType(decl parser.VarDeclaration) Type

func (CheckResult) GetWarningsCount

func (r CheckResult) GetWarningsCount() int

func (CheckResult) ResolveBuiltinFn

func (r CheckResult) ResolveBuiltinFn(v *parser.FnCallIdentifier) FnCallResolution

func (CheckResult) ResolveVar

func (r CheckResult) ResolveVar(v *parser.Variable) *parser.VarDeclaration

type Diagnostic

type Diagnostic struct {
	Range parser.Range
	Kind  DiagnosticKind
	Id    int32
}

type DiagnosticKind

type DiagnosticKind interface {
	Message() string
	Severity() Severity
}

type DivByZero added in v0.0.11

type DivByZero struct {
	Sum big.Rat
}

func (DivByZero) Message added in v0.0.11

func (e DivByZero) Message() string

func (DivByZero) Severity added in v0.0.11

func (DivByZero) Severity() Severity

type DocumentSymbol

type DocumentSymbol struct {
	Name           string
	Detail         string
	Range          parser.Range
	SelectionRange parser.Range
	Kind           DocumentSymbolKind
}

type DuplicateVariable

type DuplicateVariable struct {
	Name string
}

func (DuplicateVariable) Message

func (e DuplicateVariable) Message() string

func (DuplicateVariable) Severity

func (DuplicateVariable) Severity() Severity

type EmptiedAccount

type EmptiedAccount struct {
	Name string
}

func (EmptiedAccount) Message

func (e EmptiedAccount) Message() string

func (EmptiedAccount) Severity

func (EmptiedAccount) Severity() Severity

type ExperimentalFeature added in v0.0.16

type ExperimentalFeature struct {
	Name string
}

func (ExperimentalFeature) Message added in v0.0.16

func (e ExperimentalFeature) Message() string

func (ExperimentalFeature) Severity added in v0.0.16

func (ExperimentalFeature) Severity() Severity

type FixedPortionVariable

type FixedPortionVariable struct {
	Value big.Rat
}

func (FixedPortionVariable) Message

func (e FixedPortionVariable) Message() string

func (FixedPortionVariable) Severity

func (FixedPortionVariable) Severity() Severity

type FnCallResolution

type FnCallResolution interface {
	ContextName() string
	GetParams() []string
	// contains filtered or unexported methods
}

type GotoDefinitionResult

type GotoDefinitionResult struct {
	Range parser.Range
}

func GotoDefinition

func GotoDefinition(program parser.Program, position parser.Position, checkResult CheckResult) *GotoDefinitionResult

type Hover

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

func HoverOn

func HoverOn(program parser.Program, position parser.Position) Hover

type InvalidType

type InvalidType struct {
	Name string
}

func (InvalidType) Message

func (e InvalidType) Message() string

TODO evaluate suggestion using Levenshtein distance

func (InvalidType) Severity

func (InvalidType) Severity() Severity

type InvalidUnboundedAccount

type InvalidUnboundedAccount struct{}

func (InvalidUnboundedAccount) Message

func (e InvalidUnboundedAccount) Message() string

func (InvalidUnboundedAccount) Severity

func (InvalidUnboundedAccount) Severity() Severity

type InvalidWorldOverdraft

type InvalidWorldOverdraft struct{}

func (InvalidWorldOverdraft) Message

func (e InvalidWorldOverdraft) Message() string

func (InvalidWorldOverdraft) Severity

func (InvalidWorldOverdraft) Severity() Severity

type NoAllotmentInSendAll

type NoAllotmentInSendAll struct{}

func (NoAllotmentInSendAll) Message

func (e NoAllotmentInSendAll) Message() string

func (NoAllotmentInSendAll) Severity

func (NoAllotmentInSendAll) Severity() Severity

type Parsing

type Parsing struct {
	Description string
}

func (Parsing) Message

func (e Parsing) Message() string

func (Parsing) Severity

func (Parsing) Severity() Severity

type RedundantRemaining

type RedundantRemaining struct{}

func (RedundantRemaining) Message

func (e RedundantRemaining) Message() string

func (RedundantRemaining) Severity

func (RedundantRemaining) Severity() Severity

type RemainingIsNotLast

type RemainingIsNotLast struct{}

func (RemainingIsNotLast) Message

func (e RemainingIsNotLast) Message() string

func (RemainingIsNotLast) Severity

func (RemainingIsNotLast) Severity() Severity

type Severity

type Severity = byte
const (
	ErrorSeverity Severity
	WarningSeverity
	Information
	Hint
)

!important! keep in sync with LSP specs https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnosticSeverity

type StatementFnCallResolution

type StatementFnCallResolution struct {
	Params []string
	Docs   string
}

func (StatementFnCallResolution) ContextName

func (StatementFnCallResolution) ContextName() string

func (StatementFnCallResolution) GetParams

func (r StatementFnCallResolution) GetParams() []string

type TAsset added in v0.0.20

type TAsset string

func (*TAsset) Resolve added in v0.0.20

func (a *TAsset) Resolve() Type

type TVar added in v0.0.20

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

func (*TVar) Resolve added in v0.0.20

func (t *TVar) Resolve() Type

type Type added in v0.0.20

type Type interface {
	Resolve() Type
}

type TypeMismatch

type TypeMismatch struct {
	Expected string
	Got      string
}

func (TypeMismatch) Message

func (e TypeMismatch) Message() string

func (TypeMismatch) Severity

func (TypeMismatch) Severity() Severity

type UnboundVariable

type UnboundVariable struct {
	Name string
	Type string
}

func (UnboundVariable) Message

func (e UnboundVariable) Message() string

TODO evaluate suggestion using Levenshtein distance

func (UnboundVariable) Severity

func (UnboundVariable) Severity() Severity

type UnboundedAccountIsNotLast

type UnboundedAccountIsNotLast struct{}

func (UnboundedAccountIsNotLast) Message

func (e UnboundedAccountIsNotLast) Message() string

func (UnboundedAccountIsNotLast) Severity

type UnknownFunction

type UnknownFunction struct {
	Name string
}

func (UnknownFunction) Message

func (e UnknownFunction) Message() string

func (UnknownFunction) Severity

func (UnknownFunction) Severity() Severity

type UnusedVar

type UnusedVar struct {
	Name string
}

func (UnusedVar) Message

func (e UnusedVar) Message() string

func (UnusedVar) Severity

func (UnusedVar) Severity() Severity

type VarOriginFnCallResolution

type VarOriginFnCallResolution struct {
	Params             []string
	Docs               string
	Return             string
	VersionConstraints []VersionClause
}

func (VarOriginFnCallResolution) ContextName

func (VarOriginFnCallResolution) ContextName() string

func (VarOriginFnCallResolution) GetParams

func (r VarOriginFnCallResolution) GetParams() []string

type VariableHover

type VariableHover struct {
	parser.Range
	Node *parser.Variable
}

type VersionClause added in v0.0.16

type VersionClause struct {
	Version     parser.Version
	FeatureFlag flags.FeatureFlag
}

type VersionMismatch added in v0.0.16

type VersionMismatch struct {
	RequiredVersion parser.Version
	GotVersion      parser.Version
}

func (VersionMismatch) Message added in v0.0.16

func (e VersionMismatch) Message() string

func (VersionMismatch) Severity added in v0.0.16

func (VersionMismatch) Severity() Severity

Jump to

Keyboard shortcuts

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