Documentation
¶
Index ¶
- func ConvertBindingPatternToAssignmentPattern(emitContext *printer.EmitContext, element *ast.BindingPattern) *ast.Expression
- func ConvertVariableDeclarationToAssignmentExpression(emitContext *printer.EmitContext, element *ast.VariableDeclaration) *ast.Expression
- func ExtractModifiers(emitContext *printer.EmitContext, modifiers *ast.ModifierList, ...) *ast.ModifierList
- func FindSuperStatementIndexPath(statements []*ast.Statement, start int) []int
- func GetNonAssignmentOperatorForCompoundAssignment(kind ast.Kind) ast.Kind
- func GetSuperCallFromStatement(statement *ast.Statement) *ast.Node
- func IsExportName(emitContext *printer.EmitContext, name *ast.IdentifierNode) bool
- func IsGeneratedIdentifier(emitContext *printer.EmitContext, name *ast.IdentifierNode) bool
- func IsHelperName(emitContext *printer.EmitContext, name *ast.IdentifierNode) bool
- func IsIdentifierReference(name *ast.IdentifierNode, parent *ast.Node) bool
- func IsLocalName(emitContext *printer.EmitContext, name *ast.IdentifierNode) bool
- func IsOriginalNodeSingleLine(emitContext *printer.EmitContext, node *ast.Node) bool
- func IsSimpleCopiableExpression(expression *ast.Expression) bool
- func IsSimpleInlineableExpression(expression *ast.Expression) bool
- func MoveRangePastDecorators(node *ast.Node) core.TextRange
- func MoveRangePastModifiers(node *ast.Node) core.TextRange
- func SingleOrMany(nodes []*ast.Node, factory *printer.NodeFactory) *ast.Node
- type TransformOptions
- type Transformer
- func (tx *Transformer) EmitContext() *printer.EmitContext
- func (tx *Transformer) Factory() *printer.NodeFactory
- func (tx *Transformer) NewTransformer(visit func(node *ast.Node) *ast.Node, emitContext *printer.EmitContext) *Transformer
- func (tx *Transformer) TransformSourceFile(file *ast.SourceFile) *ast.SourceFile
- func (tx *Transformer) Visitor() *ast.NodeVisitor
- type TransformerFactory
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 FindSuperStatementIndexPath ¶
FindSuperStatementIndexPath finds a path of indices to a statement containing a `super()` call.
func GetNonAssignmentOperatorForCompoundAssignment ¶
GetNonAssignmentOperatorForCompoundAssignment returns the non-assignment operator for a compound assignment.
func GetSuperCallFromStatement ¶
GetSuperCallFromStatement extracts the super() call expression from an expression statement, if any.
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 MoveRangePastDecorators ¶
MoveRangePastDecorators returns a text range that starts past any decorators on the node.
func MoveRangePastModifiers ¶
MoveRangePastModifiers returns a text range that starts past any modifiers on the node.
func SingleOrMany ¶
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