transformers

package
v0.0.0-...-94ae2f2 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertBindingPatternToAssignmentPattern

func ConvertBindingPatternToAssignmentPattern(emitContext *printer.EmitContext, element *ast.BindingPattern) *ast.Expression

func ConvertVariableDeclarationToAssignmentExpression

func ConvertVariableDeclarationToAssignmentExpression(emitContext *printer.EmitContext, element *ast.VariableDeclaration) *ast.Expression

func ExtractModifiers

func ExtractModifiers(emitContext *printer.EmitContext, modifiers *ast.ModifierList, allowed ast.ModifierFlags) *ast.ModifierList

func IsExportName

func IsExportName(emitContext *printer.EmitContext, name *ast.IdentifierNode) bool

func IsGeneratedIdentifier

func IsGeneratedIdentifier(emitContext *printer.EmitContext, name *ast.IdentifierNode) bool

func IsHelperName

func IsHelperName(emitContext *printer.EmitContext, name *ast.IdentifierNode) bool

func IsIdentifierReference

func IsIdentifierReference(name *ast.IdentifierNode, parent *ast.Node) bool

func IsLocalName

func IsLocalName(emitContext *printer.EmitContext, name *ast.IdentifierNode) bool

func IsOriginalNodeSingleLine

func IsOriginalNodeSingleLine(emitContext *printer.EmitContext, node *ast.Node) bool

func IsSimpleCopiableExpression

func IsSimpleCopiableExpression(expression *ast.Expression) bool

Used in the module transformer to check if an expression is reasonably without sideeffect,

and thus better to copy into multiple places rather than to cache in a temporary variable
- this is mostly subjective beyond the requirement that the expression not be sideeffecting

Also used by the logical assignment downleveling transform to skip temp variables when they're not needed.

func IsSimpleInlineableExpression

func IsSimpleInlineableExpression(expression *ast.Expression) bool

*

  • A simple inlinable expression is an expression which can be copied into multiple locations
  • without risk of repeating any sideeffects and whose value could not possibly change between
  • any such locations

func SingleOrMany

func SingleOrMany(nodes []*ast.Node, factory *printer.NodeFactory) *ast.Node

Types

type TransformOptions

type TransformOptions struct {
	Context                   *printer.EmitContext
	CompilerOptions           *core.CompilerOptions
	Resolver                  binder.ReferenceResolver
	EmitResolver              printer.EmitResolver
	GetEmitModuleFormatOfFile func(file ast.HasFileName) core.ModuleKind
}

type Transformer

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

func (*Transformer) EmitContext

func (tx *Transformer) EmitContext() *printer.EmitContext

func (*Transformer) Factory

func (tx *Transformer) Factory() *printer.NodeFactory

func (*Transformer) NewTransformer

func (tx *Transformer) NewTransformer(visit func(node *ast.Node) *ast.Node, emitContext *printer.EmitContext) *Transformer

func (*Transformer) TransformSourceFile

func (tx *Transformer) TransformSourceFile(file *ast.SourceFile) *ast.SourceFile

func (*Transformer) Visitor

func (tx *Transformer) Visitor() *ast.NodeVisitor

type TransformerFactory

type TransformerFactory = func(opt *TransformOptions) *Transformer

func Chain

func Chain(transforms ...TransformerFactory) TransformerFactory

Chains transforms in left-to-right order, running them one at a time in order (as opposed to interleaved at each node) - the resulting combined transform only operates on SourceFile nodes

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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