plugin

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package plugin implements a plugin layer for component statements. Exports the required interface that must be implemented by plugins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComponentStmt

type ComponentStmt interface {
	// Generated code for calling. It can be ast.AssignStmt or  ast.ExprStmt
	Stmt() ast.Stmt

	// Varaiables are used for calling with type.
	InputFields() []*ast.Field

	// Result variables for a component.
	OutputFields() []*ast.Field

	// Statements are called after a component statement.
	ErrStmt() *ast.BlockStmt

	// Component name
	Name() string
}

ComponentStmt interface is used by a plugin

type Context

type Context interface {
	FindInputByType(ast.Expr) *ast.Field
	AddInput(ast.Expr) *ast.Field
	OutputList() []*ast.Field
}

Context interface uses for searching variable in stack of variables and adding a new input to a component function

type Plugin

type Plugin interface {

	// Imports which are added if plugins are used
	Imports() []string

	// Hook for adding new statements before calling a component statement.
	//
	// Second argument - component name
	//
	// Third argument - result of calling InputFields()
	Before(Context, string, []*ast.Field) []ast.Stmt

	// Hook for adding new statements after calling a component statement.
	//
	// Second argument - component name
	//
	// Third argument - result of calling OutputFields()
	Success(Context, string, []*ast.Field) []ast.Stmt

	// Hook for changing a component statement and failure component statements.
	// Return value is a mark - code changed or not. If code has changes then imports are added.
	Change(Context, ComponentStmt) bool
}

Plugin interface that must be implemented by plugins

Jump to

Keyboard shortcuts

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