ast

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2023 License: Apache-2.0 Imports: 5 Imported by: 5

Documentation

Index

Constants

View Source
const Indent = "  "

Variables

View Source
var ErrBadIdent = errors.New("typescript idents must contain only alphanumeric characters")

Functions

This section is empty.

Types

type AssignExpr

type AssignExpr struct {
	Name  Ident
	Value Expr
}

func (AssignExpr) String

func (a AssignExpr) String() string

type BasicType

type BasicType struct {
	Expr Expr
}

func (BasicType) String

func (b BasicType) String() string

type BinaryExpr

type BinaryExpr struct {
	Op   string
	X, Y Expr
}

func (BinaryExpr) String

func (b BinaryExpr) String() string

type Brack

type Brack string
const (
	RoundBrack  Brack = "()"
	SquareBrack Brack = "[]"
	CurlyBrack  Brack = "{}"
)

type Comment added in v0.1.0

type Comment struct {
	Text string // text of comment, excluding '\n' for //-style
	Pos  CommentPosition
}

func (Comment) String added in v0.1.0

func (c Comment) String() string

type CommentPosition added in v0.1.0

type CommentPosition int

CommentPosition indicates the position at which a comment should be printed, relative to its associated Node.

const (
	// CommentAbove places a comment on a new line above the associated Node,
	// preserving indentation.
	CommentAbove CommentPosition = iota
	// CommentInline places a comment inline following the associated Node.
	CommentInline
	// CommentBelow places a comment after the associated Node, on a new line,
	// preserving indentation.
	CommentBelow
)

type Commenter added in v0.1.0

type Commenter interface {
	Comments() []Comment
}

type Decl

type Decl interface {
	Node
	// contains filtered or unexported methods
}

type EOL

type EOL string
const (
	EOLNone      EOL = ""
	EOLComma     EOL = `,`
	EOLSemicolon EOL = `;`
)

type EnumType

type EnumType struct {
	Elems []Expr
}

func (EnumType) String

func (e EnumType) String() string

type ExportKeyword added in v0.1.0

type ExportKeyword struct {
	Decl        Decl
	Default     bool
	CommentList []Comment
}

func (ExportKeyword) Comments added in v0.1.0

func (e ExportKeyword) Comments() []Comment

func (ExportKeyword) String added in v0.1.0

func (e ExportKeyword) String() string

type ExportNamespace added in v0.1.0

type ExportNamespace struct {
	AsName      string
	From        Str
	CommentList []Comment
}

func (ExportNamespace) Comments added in v0.1.1

func (e ExportNamespace) Comments() []Comment

func (ExportNamespace) String added in v0.1.0

func (e ExportNamespace) String() string

type ExportSet added in v0.1.1

type ExportSet struct {
	TypeOnly    bool
	Exports     Idents
	From        Str
	CommentList []Comment
}

func (ExportSet) Comments added in v0.1.1

func (e ExportSet) Comments() []Comment

func (ExportSet) String added in v0.1.1

func (e ExportSet) String() string

type Expr

type Expr interface {
	Node
	// contains filtered or unexported methods
}

func None

func None() Expr

type File

type File struct {
	// file-level doc. Printed first at start of file, if non-nil
	Doc     *Comment
	Imports []ImportSpec
	Nodes   []Decl
}

func (File) String

func (f File) String() string

type Ident

type Ident struct {
	Name string

	// TODO: factor out into asStmt?
	As string
}

func (Ident) String

func (i Ident) String() string

func (Ident) Validate added in v0.0.3

func (i Ident) Validate() error

type Idents

type Idents []Ident

func (Idents) Strings

func (i Idents) Strings() []string

type ImportSpec

type ImportSpec struct {
	TypeOnly bool
	Imports  Idents
	// Only used for the namespace-form import, when Imports is empty
	AsName      string
	From        Str
	CommentList []Comment
}

func (ImportSpec) Comments added in v0.1.1

func (i ImportSpec) Comments() []Comment

func (ImportSpec) String

func (i ImportSpec) String() string

type IndexExpr

type IndexExpr struct {
	Expr  Expr
	Index Expr
}

func (IndexExpr) String

func (i IndexExpr) String() string

type InterfaceType

type InterfaceType struct {
	Elems   []KeyValueExpr
	Extends []Expr
}

func (InterfaceType) String

func (i InterfaceType) String() string

type KeyValueExpr

type KeyValueExpr struct {
	Key         Expr
	Value       Expr
	CommentList []Comment
}

func (KeyValueExpr) Comments added in v0.1.0

func (k KeyValueExpr) Comments() []Comment

func (KeyValueExpr) String

func (k KeyValueExpr) String() string

type ListExpr

type ListExpr struct {
	Expr
}

ListExpr represents lists in type definitions, like string[].

func (ListExpr) String

func (l ListExpr) String() string

type ListLit

type ListLit struct {
	Elems []Expr
}

func (ListLit) String

func (l ListLit) String() string

type Names

type Names struct {
	Brack
	Idents
}

func (Names) String

func (n Names) String() string

type Node

type Node interface {
	fmt.Stringer
}

type Num

type Num struct {
	N   interface{}
	Fmt string
}

func (Num) String

func (n Num) String() string

type ObjectLit

type ObjectLit struct {
	Comment []Comment
	Elems   []KeyValueExpr
	IsType  bool
	IsMap   bool
	// contains filtered or unexported fields
}

func (ObjectLit) Comments added in v0.1.0

func (o ObjectLit) Comments() []Comment

func (ObjectLit) String

func (o ObjectLit) String() string

type ParenExpr added in v0.0.3

type ParenExpr struct {
	Expr Expr
}

func (ParenExpr) String added in v0.0.3

func (p ParenExpr) String() string

type Quot

type Quot string
const (
	SingleQuot Quot = `'`
	DoubleQuot Quot = `"`
	BTickQuot  Quot = "`"
)

type Raw

type Raw struct {
	Data string
}

func (Raw) String

func (r Raw) String() string

type SelectorExpr

type SelectorExpr struct {
	Expr Expr
	Sel  Ident
}

func (SelectorExpr) String

func (s SelectorExpr) String() string

type Str

type Str struct {
	Quot
	Value string
}

func (Str) String

func (s Str) String() string

type Type

type Type interface {
	Node
	// contains filtered or unexported methods
}

type TypeDecl

type TypeDecl struct {
	Name        Ident
	Type        Type
	CommentList []Comment
	Export      bool
}

func (TypeDecl) Comments added in v0.1.0

func (t TypeDecl) Comments() []Comment

func (TypeDecl) String

func (t TypeDecl) String() string

type TypeTransformExpr

type TypeTransformExpr struct {
	Transform string // e.g. "Partial"
	Expr      Expr
}

func (TypeTransformExpr) String

func (tt TypeTransformExpr) String() string

type UnaryExpr

type UnaryExpr struct {
	Op   string // operator
	Expr Expr   // operand
}

func (UnaryExpr) String

func (u UnaryExpr) String() string

type VarDecl

type VarDecl struct {
	Tok string

	Names
	Type        Expr
	Value       Expr
	CommentList []Comment
	Export      bool
}

func (VarDecl) Comments added in v0.1.0

func (v VarDecl) Comments() []Comment

func (VarDecl) String

func (v VarDecl) String() string

Jump to

Keyboard shortcuts

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