project

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Caller         Declaration
	Callee         Declaration
	File           *File
	Node           *parser.Node
	Kind           CallKind
	ArgumentOffset int
	// contains filtered or unexported fields
}

func (Call) FieldRange

func (c Call) FieldRange(name string) source.Range

func (Call) Key

func (c Call) Key() NodeKey

func (Call) PointerNode

func (c Call) PointerNode() *parser.Node

func (Call) PointerNodeIn

func (c Call) PointerNodeIn(model *walk.Model) *parser.Node

func (Call) Valid

func (c Call) Valid() bool

type CallGraph

type CallGraph struct {
	Functions   []Declaration
	Calls       []Call
	AsyncCalls  []Call
	EntryPoints []EntryPoint
	// contains filtered or unexported fields
}

func (*CallGraph) AsyncIncoming

func (g *CallGraph) AsyncIncoming(function Declaration) []Call

func (*CallGraph) AsyncOutgoing

func (g *CallGraph) AsyncOutgoing(function Declaration) []Call

func (*CallGraph) Outgoing

func (g *CallGraph) Outgoing(function Declaration) []Call

func (*CallGraph) RecursiveComponents

func (g *CallGraph) RecursiveComponents() [][]Declaration

type CallKind

type CallKind uint8
const (
	CallDirect CallKind = iota
	CallDynamic
	CallTimer
)

type Declaration

type Declaration struct {
	Name   string
	Kind   semantic.SymbolKind
	File   *File
	Node   *parser.Node
	Symbol *semantic.Symbol
	// contains filtered or unexported fields
}

func (Declaration) Ambiguous

func (d Declaration) Ambiguous() bool

func (Declaration) Constant

func (d Declaration) Constant() bool

func (Declaration) End

func (d Declaration) End() int

func (Declaration) FieldRange

func (d Declaration) FieldRange(name string) source.Range

func (Declaration) FieldText

func (d Declaration) FieldText(name string) string

func (Declaration) FunctionParameters

func (d Declaration) FunctionParameters() []FunctionParameter

func (Declaration) HasError

func (d Declaration) HasError() bool

func (Declaration) HasField

func (d Declaration) HasField(name string) bool

func (Declaration) HasToken

func (d Declaration) HasToken(kind token.Kind) bool

func (Declaration) Key

func (d Declaration) Key() NodeKey

func (Declaration) NameRange

func (d Declaration) NameRange() source.Range

func (Declaration) NodeKind

func (d Declaration) NodeKind() parser.Kind

func (Declaration) PointerNode

func (d Declaration) PointerNode() *parser.Node

func (Declaration) PointerNodeIn

func (d Declaration) PointerNodeIn(model *walk.Model) *parser.Node

func (Declaration) Range

func (d Declaration) Range() source.Range

func (Declaration) SingleReturnCallName added in v1.2.1

func (d Declaration) SingleReturnCallName() (string, bool)

SingleReturnCallName identifies wrappers that return one direct call.

func (Declaration) Start

func (d Declaration) Start() int

func (Declaration) Tags

func (d Declaration) Tags() []string

func (Declaration) Valid

func (d Declaration) Valid() bool

type DuplicateFunction

type DuplicateFunction struct {
	Name   string
	First  Declaration
	Second Declaration
	Owner  *File
}

type DuplicateGlobal

type DuplicateGlobal struct {
	Name   string
	First  Declaration
	Second Declaration
	Owner  *File
}

type EntryKind

type EntryKind uint8
const (
	EntryCallback EntryKind = iota
	EntryMain
)

type EntryPoint

type EntryPoint struct {
	Function Declaration
	Kind     EntryKind
}

type ExpansionOrigin

type ExpansionOrigin struct {
	File  *File
	Span  token.Span
	Macro string
}

type Feature

type Feature uint16
const (
	FeatureDefinedNames Feature = 1 << iota
	FeatureDuplicates
	FeatureConflicts
	FeatureIncludeCycles
	FeatureIncludeIssues
	FeatureReferences
	FeatureUnusedIncludes
	FeatureCallGraph
	FeatureRuntimeCalls
	FeatureFunctionEffects
	FeatureTrivia
)

type Features

type Features uint16

func AllFeatures

func AllFeatures() Features

func NewFeatures

func NewFeatures(features ...Feature) Features

func NewFeaturesFromSet

func NewFeaturesFromSet(features Features) Features

func (Features) Has

func (f Features) Has(feature Feature) bool

type File

type File struct {
	Path              string
	Source            []byte
	Parsed            *parser.File
	CompactParsed     *parser.CompactFile
	Walk              *walk.Model
	CompactWalk       *walk.CompactModel
	Syntax            *cst.Model
	Semantic          *semantic.Model
	CompactSemantic   *semantic.CompactModel
	ExpandedSource    []byte
	ExpandedParsed    *parser.File
	ExpandedWalk      *walk.Model
	ExpandedSemantic  *semantic.Model
	ExpansionComplete bool
	Includes          []*Include
	Provided          bool
	// contains filtered or unexported fields
}

func (*File) HasParseErrors

func (f *File) HasParseErrors() bool

func (*File) LineTable

func (f *File) LineTable() *source.LineTable

func (*File) PointerWalk

func (f *File) PointerWalk(parsed *parser.File) *walk.Model

type FunctionEffects

type FunctionEffects struct {
	Complete          bool
	Pure              bool
	ReadsGlobals      []Declaration
	WritesGlobals     []Declaration
	MutatedParameters []int
	Calls             []Declaration
}

type FunctionParameter

type FunctionParameter struct {
	Tags     []string
	Variadic bool
	Known    bool
}

type Include

type Include struct {
	Node       *parser.Node
	Path       string
	Resolved   *File
	Candidates []string
	Optional   bool
	Uncertain  bool
	// contains filtered or unexported fields
}

func (*Include) PathRange

func (i *Include) PathRange() source.Range

func (*Include) Range

func (i *Include) Range() source.Range

func (*Include) Start

func (i *Include) Start() int

func (*Include) Valid

func (i *Include) Valid() bool

type IncludeCycle

type IncludeCycle struct {
	Owner *File
	Edges []IncludeEdge
}

type IncludeEdge

type IncludeEdge struct {
	From    *File
	Include *Include
	To      *File
}

type IncludeIssue

type IncludeIssue struct {
	Owner   *File
	File    *File
	Include *Include
}

type Model

type Model struct {
	Files        []*File
	Units        []*Unit
	Declarations map[string][]Declaration
	CallGraph    *CallGraph
	// contains filtered or unexported fields
}

func Build

func Build(sources []Source, options Options) (*Model, error)

func BuildContext added in v1.4.0

func BuildContext(ctx context.Context, sources []Source, options Options) (*Model, error)

BuildContext builds a project model and stops when ctx is cancelled.

func (*Model) AmbiguousIncludes

func (m *Model) AmbiguousIncludes() []IncludeIssue

func (*Model) ConflictingIncludeSymbols

func (m *Model) ConflictingIncludeSymbols() []SymbolConflict

func (*Model) DefinesName

func (m *Model) DefinesName(name string) bool

func (*Model) DuplicateFunctions

func (m *Model) DuplicateFunctions() []DuplicateFunction

func (*Model) DuplicateGlobals

func (m *Model) DuplicateGlobals() []DuplicateGlobal

func (*Model) DuplicateIncludes

func (m *Model) DuplicateIncludes() []IncludeIssue

func (*Model) Eval

func (m *Model) Eval(file *File, node *parser.Node) (int64, bool)

func (*Model) ExpansionOrigins

func (m *Model) ExpansionOrigins(file *File, node *parser.Node) []ExpansionOrigin

func (*Model) ExpressionTag

func (m *Model) ExpressionTag(file *File, node *parser.Node) (string, bool)

func (*Model) ExpressionTags

func (m *Model) ExpressionTags(file *File, node *parser.Node) []string

func (*Model) File

func (m *Model) File(path string) *File

func (*Model) FunctionEffects

func (m *Model) FunctionEffects(function Declaration) (FunctionEffects, bool)

func (*Model) FunctionVariants

func (m *Model) FunctionVariants(file *File, node *parser.Node) []Declaration

func (*Model) FunctionVariantsNamed added in v1.2.1

func (m *Model) FunctionVariantsNamed(file *File, name string) []Declaration

FunctionVariantsNamed returns callable variants visible from file.

func (*Model) InProgram

func (m *Model) InProgram(file *File) bool

func (*Model) IncludeCycles

func (m *Model) IncludeCycles() []IncludeCycle

func (*Model) Includes

func (m *Model) Includes() []IncludeIssue

func (*Model) MissingIncludes

func (m *Model) MissingIncludes() []IncludeIssue

func (*Model) References

func (m *Model) References(declaration Declaration) []Reference

func (*Model) ReleaseIncludeTokens

func (m *Model) ReleaseIncludeTokens(files []*File)

func (*Model) Resolve

func (m *Model) Resolve(file *File, node *parser.Node) (Declaration, bool)

func (*Model) UnusedIncludes

func (m *Model) UnusedIncludes() []IncludeIssue

type NodeKey

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

type Options

type Options struct {
	WorkingDir      string
	IncludePaths    []string
	Defines         []string
	DefinesComplete bool
	ReleaseExpanded bool
	ReleaseIncludes bool
	Features        *Features
	ParseCache      *ParseCache
	ObserveTiming   func(TimingEvent)
	RootTokens      []token.Token
}

type ParseCache

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

func NewParseCache

func NewParseCache() *ParseCache

type Reference

type Reference struct {
	File *File
	Node *parser.Node
	Kind semantic.ReferenceKind
	// contains filtered or unexported fields
}

type Source

type Source struct {
	Path    string
	Content []byte
}

type SymbolConflict

type SymbolConflict struct {
	Name   string
	First  Declaration
	Second Declaration
	Owner  *File
}

type TimingEvent

type TimingEvent struct {
	Stage    TimingStage
	Duration time.Duration
}

type TimingStage

type TimingStage string
const (
	TimingParse      TimingStage = "parse"
	TimingPreprocess TimingStage = "preprocess"
	TimingSemantic   TimingStage = "semantic"
)

type Unit

type Unit struct {
	Root  *File
	Files []*File
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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