pass

package
v0.0.0-...-0137c81 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package pass provides a visitor framework for source code analysis and transformation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASTPass

type ASTPass interface {
	FodderElement(ASTPass, *ast.FodderElement, Context)
	Fodder(ASTPass, *ast.Fodder, Context)
	ForSpec(ASTPass, *ast.ForSpec, Context)
	Parameters(ASTPass, *ast.Fodder, *[]ast.Parameter, *ast.Fodder, Context)
	Arguments(ASTPass, *ast.Fodder, *ast.Arguments, *ast.Fodder, Context)
	FieldParams(ASTPass, *ast.ObjectField, Context)
	ObjectField(ASTPass, *ast.ObjectField, Context)
	ObjectFields(ASTPass, *ast.ObjectFields, Context)

	Apply(ASTPass, *ast.Apply, Context)
	ApplyBrace(ASTPass, *ast.ApplyBrace, Context)
	Array(ASTPass, *ast.Array, Context)
	ArrayComp(ASTPass, *ast.ArrayComp, Context)
	Assert(ASTPass, *ast.Assert, Context)
	Binary(ASTPass, *ast.Binary, Context)
	Conditional(ASTPass, *ast.Conditional, Context)
	Dollar(ASTPass, *ast.Dollar, Context)
	Error(ASTPass, *ast.Error, Context)
	Function(ASTPass, *ast.Function, Context)
	Import(ASTPass, *ast.Import, Context)
	ImportStr(ASTPass, *ast.ImportStr, Context)
	ImportBin(ASTPass, *ast.ImportBin, Context)
	Index(ASTPass, *ast.Index, Context)
	Slice(ASTPass, *ast.Slice, Context)
	Local(ASTPass, *ast.Local, Context)
	LiteralBoolean(ASTPass, *ast.LiteralBoolean, Context)
	LiteralNull(ASTPass, *ast.LiteralNull, Context)
	LiteralNumber(ASTPass, *ast.LiteralNumber, Context)
	LiteralString(ASTPass, *ast.LiteralString, Context)
	Object(ASTPass, *ast.Object, Context)
	ObjectComp(ASTPass, *ast.ObjectComp, Context)
	Parens(ASTPass, *ast.Parens, Context)
	Self(ASTPass, *ast.Self, Context)
	SuperIndex(ASTPass, *ast.SuperIndex, Context)
	InSuper(ASTPass, *ast.InSuper, Context)
	Unary(ASTPass, *ast.Unary, Context)
	Var(ASTPass, *ast.Var, Context)

	Visit(ASTPass, *ast.Node, Context)
	BaseContext(ASTPass) Context
	File(ASTPass, *ast.Node, *ast.Fodder)
}

ASTPass is an interface for a pass that transforms the AST in some way.

type Base

type Base struct {
}

Base implements basic traversal so other passes can extend it.

func (*Base) Apply

func (*Base) Apply(p ASTPass, node *ast.Apply, ctx Context)

Apply traverses that kind of node

func (*Base) ApplyBrace

func (*Base) ApplyBrace(p ASTPass, node *ast.ApplyBrace, ctx Context)

ApplyBrace traverses that kind of node

func (*Base) Arguments

func (*Base) Arguments(p ASTPass, l *ast.Fodder, args *ast.Arguments, r *ast.Fodder, ctx Context)

Arguments traverses the list of arguments

func (*Base) Array

func (*Base) Array(p ASTPass, node *ast.Array, ctx Context)

Array traverses that kind of node

func (*Base) ArrayComp

func (*Base) ArrayComp(p ASTPass, node *ast.ArrayComp, ctx Context)

ArrayComp traverses that kind of node

func (*Base) Assert

func (*Base) Assert(p ASTPass, node *ast.Assert, ctx Context)

Assert traverses that kind of node

func (*Base) BaseContext

func (*Base) BaseContext(ASTPass) Context

BaseContext just returns nil.

func (*Base) Binary

func (*Base) Binary(p ASTPass, node *ast.Binary, ctx Context)

Binary traverses that kind of node

func (*Base) Conditional

func (*Base) Conditional(p ASTPass, node *ast.Conditional, ctx Context)

Conditional traverses that kind of node

func (*Base) Dollar

func (*Base) Dollar(p ASTPass, node *ast.Dollar, ctx Context)

Dollar cannot descend any further

func (*Base) Error

func (*Base) Error(p ASTPass, node *ast.Error, ctx Context)

Error traverses that kind of node

func (*Base) FieldParams

func (*Base) FieldParams(p ASTPass, field *ast.ObjectField, ctx Context)

FieldParams is factored out of ObjectField

func (*Base) File

func (*Base) File(p ASTPass, node *ast.Node, finalFodder *ast.Fodder)

File processes a whole Jsonnet file

func (*Base) Fodder

func (*Base) Fodder(p ASTPass, fodder *ast.Fodder, ctx Context)

Fodder traverses fodder

func (*Base) FodderElement

func (*Base) FodderElement(p ASTPass, element *ast.FodderElement, ctx Context)

FodderElement cannot descend any further

func (*Base) ForSpec

func (*Base) ForSpec(p ASTPass, forSpec *ast.ForSpec, ctx Context)

ForSpec traverses a ForSpec

func (*Base) Function

func (*Base) Function(p ASTPass, node *ast.Function, ctx Context)

Function traverses that kind of node

func (*Base) Import

func (*Base) Import(p ASTPass, node *ast.Import, ctx Context)

Import traverses that kind of node

func (*Base) ImportBin

func (*Base) ImportBin(p ASTPass, node *ast.ImportBin, ctx Context)

ImportBin traverses that kind of node

func (*Base) ImportStr

func (*Base) ImportStr(p ASTPass, node *ast.ImportStr, ctx Context)

ImportStr traverses that kind of node

func (*Base) InSuper

func (*Base) InSuper(p ASTPass, node *ast.InSuper, ctx Context)

InSuper traverses that kind of node

func (*Base) Index

func (*Base) Index(p ASTPass, node *ast.Index, ctx Context)

Index traverses that kind of node

func (*Base) LiteralBoolean

func (*Base) LiteralBoolean(p ASTPass, node *ast.LiteralBoolean, ctx Context)

LiteralBoolean cannot descend any further

func (*Base) LiteralNull

func (*Base) LiteralNull(p ASTPass, node *ast.LiteralNull, ctx Context)

LiteralNull cannot descend any further

func (*Base) LiteralNumber

func (*Base) LiteralNumber(p ASTPass, node *ast.LiteralNumber, ctx Context)

LiteralNumber cannot descend any further

func (*Base) LiteralString

func (*Base) LiteralString(p ASTPass, node *ast.LiteralString, ctx Context)

LiteralString cannot descend any further

func (*Base) Local

func (*Base) Local(p ASTPass, node *ast.Local, ctx Context)

Local traverses that kind of node

func (*Base) Object

func (*Base) Object(p ASTPass, node *ast.Object, ctx Context)

Object traverses that kind of node

func (*Base) ObjectComp

func (*Base) ObjectComp(p ASTPass, node *ast.ObjectComp, ctx Context)

ObjectComp traverses that kind of node

func (*Base) ObjectField

func (*Base) ObjectField(p ASTPass, field *ast.ObjectField, ctx Context)

ObjectField traverses a single field

func (*Base) ObjectFields

func (*Base) ObjectFields(p ASTPass, fields *ast.ObjectFields, ctx Context)

ObjectFields traverses object fields

func (*Base) Parameters

func (*Base) Parameters(p ASTPass, l *ast.Fodder, params *[]ast.Parameter, r *ast.Fodder, ctx Context)

Parameters traverses the list of parameters

func (*Base) Parens

func (*Base) Parens(p ASTPass, node *ast.Parens, ctx Context)

Parens traverses that kind of node

func (*Base) Self

func (*Base) Self(p ASTPass, node *ast.Self, ctx Context)

Self cannot descend any further

func (*Base) Slice

func (*Base) Slice(p ASTPass, node *ast.Slice, ctx Context)

Slice traverses that kind of node

func (*Base) SuperIndex

func (*Base) SuperIndex(p ASTPass, node *ast.SuperIndex, ctx Context)

SuperIndex traverses that kind of node

func (*Base) Unary

func (*Base) Unary(p ASTPass, node *ast.Unary, ctx Context)

Unary traverses that kind of node

func (*Base) Var

func (*Base) Var(p ASTPass, node *ast.Var, ctx Context)

Var cannot descend any further

func (*Base) Visit

func (*Base) Visit(p ASTPass, node *ast.Node, ctx Context)

Visit traverses into an arbitrary node type

type Context

type Context interface{}

Context can be used to provide context when visting child expressions.

Jump to

Keyboard shortcuts

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