context

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdviceContext

type AdviceContext interface {
	AspectContext

	// Child creates a child of this context using the supplied node, property
	// name and index.
	Child(dst.Node, string, int) AdviceContext

	// ReplaceNode replaces the current AST node with the supplied one.
	ReplaceNode(dst.Node)

	// ParseSource parses Go source code from the provided bytes and returns a
	// *dst.File value.
	ParseSource([]byte) (*dst.File, error)

	// AddImport records a new synthetic import on this context.
	AddImport(path string, alias string) bool

	// AddLink records a new link-time requirement on this context.
	AddLink(string) bool
}

type AspectContext

type AspectContext interface {
	// Node returns the node represented by this context. Upon entering a join
	// point, this is the node being inspected. Upon entering advice, this is the
	// node being advised.
	Node() dst.Node

	// Parent returns an AspectContext representing the current node's parent.
	// Returns nil if the current node is the root of the AST (usually true of
	// the *dst.File node).
	Parent() AspectContext

	// Config loops up the node chain to find a value for the provided
	// configuration key.
	Config(string) (string, bool)

	// File provides direct access to the AST file containing the current node.
	File() *dst.File

	// ImportPath returns the import path for the package containing this node.
	ImportPath() string

	// Package returns the name of the package containing this node.
	Package() string
}

type NodeChain

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

func (*NodeChain) Child

func (n *NodeChain) Child(cursor *dstutil.Cursor) *NodeChain

func (*NodeChain) Config

func (n *NodeChain) Config(name string) (string, bool)

func (*NodeChain) Context

func (n *NodeChain) Context(
	cursor *dstutil.Cursor,
	importPath string,
	file *dst.File,
	refMap *typed.ReferenceMap,
	sourceParser SourceParser,
) *context

func (*NodeChain) Index

func (n *NodeChain) Index() string

func (*NodeChain) Node

func (n *NodeChain) Node() dst.Node

func (*NodeChain) Parent

func (n *NodeChain) Parent() *NodeChain

func (*NodeChain) PropertyName

func (n *NodeChain) PropertyName() string

func (*NodeChain) SetConfig

func (n *NodeChain) SetConfig(val map[string]string)

type SourceParser

type SourceParser interface {
	Parse(any) (*dst.File, error)
}

Jump to

Keyboard shortcuts

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