Documentation ¶
Index ¶
- Constants
- func DuplicateStmtError(pos token.Position, msg string) error
- func Fprint(w io.Writer, x interface{}, f FieldFilter) error
- func NotNilFilter(_ string, v reflect.Value) bool
- func Print(x interface{}) error
- func SyntaxError(pos token.Position, format string, v ...interface{}) error
- type AST
- type AnyDataType
- func (t *AnyDataType) CanEqual() bool
- func (t *AnyDataType) CommentGroup() (head, leading CommentGroup)
- func (t *AnyDataType) ContainsStruct() bool
- func (t *AnyDataType) End() token.Position
- func (t *AnyDataType) Format(prefix ...string) string
- func (t *AnyDataType) HasHeadCommentGroup() bool
- func (t *AnyDataType) HasLeadingCommentGroup() bool
- func (t *AnyDataType) Pos() token.Position
- func (t *AnyDataType) RawText() string
- type ArrayDataType
- func (t *ArrayDataType) CanEqual() bool
- func (t *ArrayDataType) CommentGroup() (head, leading CommentGroup)
- func (t *ArrayDataType) ContainsStruct() bool
- func (t *ArrayDataType) End() token.Position
- func (t *ArrayDataType) Format(prefix ...string) string
- func (t *ArrayDataType) HasHeadCommentGroup() bool
- func (t *ArrayDataType) HasLeadingCommentGroup() bool
- func (t *ArrayDataType) Pos() token.Position
- func (t *ArrayDataType) RawText() string
- type AtDocGroupStmt
- func (a *AtDocGroupStmt) CommentGroup() (head, leading CommentGroup)
- func (a *AtDocGroupStmt) End() token.Position
- func (a *AtDocGroupStmt) Format(prefix ...string) string
- func (a *AtDocGroupStmt) HasHeadCommentGroup() bool
- func (a *AtDocGroupStmt) HasLeadingCommentGroup() bool
- func (a *AtDocGroupStmt) Pos() token.Position
- type AtDocLiteralStmt
- func (a *AtDocLiteralStmt) CommentGroup() (head, leading CommentGroup)
- func (a *AtDocLiteralStmt) End() token.Position
- func (a *AtDocLiteralStmt) Format(prefix ...string) string
- func (a *AtDocLiteralStmt) HasHeadCommentGroup() bool
- func (a *AtDocLiteralStmt) HasLeadingCommentGroup() bool
- func (a *AtDocLiteralStmt) Pos() token.Position
- type AtDocStmt
- type AtHandlerStmt
- func (a *AtHandlerStmt) CommentGroup() (head, leading CommentGroup)
- func (a *AtHandlerStmt) End() token.Position
- func (a *AtHandlerStmt) Format(prefix ...string) string
- func (a *AtHandlerStmt) HasHeadCommentGroup() bool
- func (a *AtHandlerStmt) HasLeadingCommentGroup() bool
- func (a *AtHandlerStmt) Pos() token.Position
- type AtServerStmt
- func (a *AtServerStmt) CommentGroup() (head, leading CommentGroup)
- func (a *AtServerStmt) End() token.Position
- func (a *AtServerStmt) Format(prefix ...string) string
- func (a *AtServerStmt) HasHeadCommentGroup() bool
- func (a *AtServerStmt) HasLeadingCommentGroup() bool
- func (a *AtServerStmt) Pos() token.Position
- type BaseDataType
- func (t *BaseDataType) CanEqual() bool
- func (t *BaseDataType) CommentGroup() (head, leading CommentGroup)
- func (t *BaseDataType) ContainsStruct() bool
- func (t *BaseDataType) End() token.Position
- func (t *BaseDataType) Format(prefix ...string) string
- func (t *BaseDataType) HasHeadCommentGroup() bool
- func (t *BaseDataType) HasLeadingCommentGroup() bool
- func (t *BaseDataType) Pos() token.Position
- func (t *BaseDataType) RawText() string
- type BodyExpr
- type BodyStmt
- type CommentGroup
- type CommentStmt
- func (c *CommentStmt) CommentGroup() (head, leading CommentGroup)
- func (c *CommentStmt) End() token.Position
- func (c *CommentStmt) Format(prefix ...string) string
- func (c *CommentStmt) HasHeadCommentGroup() bool
- func (c *CommentStmt) HasLeadingCommentGroup() bool
- func (c *CommentStmt) Pos() token.Position
- type DataType
- type ElemExpr
- func (e *ElemExpr) CommentGroup() (head, leading CommentGroup)
- func (e *ElemExpr) End() token.Position
- func (e *ElemExpr) Format(prefix ...string) string
- func (e *ElemExpr) HasHeadCommentGroup() bool
- func (e *ElemExpr) HasLeadingCommentGroup() bool
- func (e *ElemExpr) IsAnonymous() bool
- func (e *ElemExpr) Pos() token.Position
- type ElemExprList
- type Expr
- type FieldFilter
- type ImportGroupStmt
- func (i *ImportGroupStmt) CommentGroup() (head, leading CommentGroup)
- func (i *ImportGroupStmt) End() token.Position
- func (i *ImportGroupStmt) Format(prefix ...string) string
- func (i *ImportGroupStmt) HasHeadCommentGroup() bool
- func (i *ImportGroupStmt) HasLeadingCommentGroup() bool
- func (i *ImportGroupStmt) Pos() token.Position
- type ImportLiteralStmt
- func (i *ImportLiteralStmt) CommentGroup() (head, leading CommentGroup)
- func (i *ImportLiteralStmt) End() token.Position
- func (i *ImportLiteralStmt) Format(prefix ...string) (result string)
- func (i *ImportLiteralStmt) HasHeadCommentGroup() bool
- func (i *ImportLiteralStmt) HasLeadingCommentGroup() bool
- func (i *ImportLiteralStmt) Pos() token.Position
- type ImportStmt
- type InfoStmt
- type InterfaceDataType
- func (t *InterfaceDataType) CanEqual() bool
- func (t *InterfaceDataType) CommentGroup() (head, leading CommentGroup)
- func (t *InterfaceDataType) ContainsStruct() bool
- func (t *InterfaceDataType) End() token.Position
- func (t *InterfaceDataType) Format(prefix ...string) string
- func (t *InterfaceDataType) HasHeadCommentGroup() bool
- func (t *InterfaceDataType) HasLeadingCommentGroup() bool
- func (t *InterfaceDataType) Pos() token.Position
- func (t *InterfaceDataType) RawText() string
- type KVExpr
- type MapDataType
- func (t *MapDataType) CanEqual() bool
- func (t *MapDataType) CommentGroup() (head, leading CommentGroup)
- func (t *MapDataType) ContainsStruct() bool
- func (t *MapDataType) End() token.Position
- func (t *MapDataType) Format(prefix ...string) string
- func (t *MapDataType) HasHeadCommentGroup() bool
- func (t *MapDataType) HasLeadingCommentGroup() bool
- func (t *MapDataType) Pos() token.Position
- func (t *MapDataType) RawText() string
- type Node
- type Option
- type PathExpr
- type PointerDataType
- func (t *PointerDataType) CanEqual() bool
- func (t *PointerDataType) CommentGroup() (head, leading CommentGroup)
- func (t *PointerDataType) ContainsStruct() bool
- func (t *PointerDataType) End() token.Position
- func (t *PointerDataType) Format(prefix ...string) string
- func (t *PointerDataType) HasHeadCommentGroup() bool
- func (t *PointerDataType) HasLeadingCommentGroup() bool
- func (t *PointerDataType) Pos() token.Position
- func (t *PointerDataType) RawText() string
- type RouteStmt
- type ServiceItemStmt
- func (s *ServiceItemStmt) CommentGroup() (head, leading CommentGroup)
- func (s *ServiceItemStmt) End() token.Position
- func (s *ServiceItemStmt) Format(prefix ...string) string
- func (s *ServiceItemStmt) HasHeadCommentGroup() bool
- func (s *ServiceItemStmt) HasLeadingCommentGroup() bool
- func (s *ServiceItemStmt) Pos() token.Position
- type ServiceNameExpr
- func (s *ServiceNameExpr) CommentGroup() (head, leading CommentGroup)
- func (s *ServiceNameExpr) End() token.Position
- func (s *ServiceNameExpr) Format(...string) string
- func (s *ServiceNameExpr) HasHeadCommentGroup() bool
- func (s *ServiceNameExpr) HasLeadingCommentGroup() bool
- func (s *ServiceNameExpr) Pos() token.Position
- type ServiceStmt
- func (s *ServiceStmt) CommentGroup() (head, leading CommentGroup)
- func (s *ServiceStmt) End() token.Position
- func (s *ServiceStmt) Format(prefix ...string) string
- func (s *ServiceStmt) HasHeadCommentGroup() bool
- func (s *ServiceStmt) HasLeadingCommentGroup() bool
- func (s *ServiceStmt) Pos() token.Position
- type SliceDataType
- func (t *SliceDataType) CanEqual() bool
- func (t *SliceDataType) CommentGroup() (head, leading CommentGroup)
- func (t *SliceDataType) ContainsStruct() bool
- func (t *SliceDataType) End() token.Position
- func (t *SliceDataType) Format(prefix ...string) string
- func (t *SliceDataType) HasHeadCommentGroup() bool
- func (t *SliceDataType) HasLeadingCommentGroup() bool
- func (t *SliceDataType) Pos() token.Position
- func (t *SliceDataType) RawText() string
- type Stmt
- type StructDataType
- func (t *StructDataType) CanEqual() bool
- func (t *StructDataType) CommentGroup() (head, leading CommentGroup)
- func (t *StructDataType) ContainsStruct() bool
- func (t *StructDataType) End() token.Position
- func (t *StructDataType) Format(prefix ...string) string
- func (t *StructDataType) HasHeadCommentGroup() bool
- func (t *StructDataType) HasLeadingCommentGroup() bool
- func (t *StructDataType) Pos() token.Position
- func (t *StructDataType) RawText() string
- type SyntaxStmt
- func (s *SyntaxStmt) CommentGroup() (head, leading CommentGroup)
- func (s *SyntaxStmt) End() token.Position
- func (s *SyntaxStmt) Format(prefix ...string) string
- func (s *SyntaxStmt) HasHeadCommentGroup() bool
- func (s *SyntaxStmt) HasLeadingCommentGroup() bool
- func (s *SyntaxStmt) Pos() token.Position
- type TokenNode
- func (t *TokenNode) CommentGroup() (head, leading CommentGroup)
- func (t *TokenNode) End() token.Position
- func (t *TokenNode) Equal(s string) bool
- func (t *TokenNode) Format(prefix ...string) string
- func (t *TokenNode) HasHeadCommentGroup() bool
- func (t *TokenNode) HasLeadingCommentGroup() bool
- func (t *TokenNode) IsEmptyString() bool
- func (t *TokenNode) IsZeroString() bool
- func (t *TokenNode) PeekFirstHeadComment() *CommentStmt
- func (t *TokenNode) PeekFirstLeadingComment() *CommentStmt
- func (t *TokenNode) Pos() token.Position
- func (t *TokenNode) SetLeadingCommentGroup(cg CommentGroup)
- type TypeExpr
- type TypeGroupStmt
- func (t *TypeGroupStmt) CommentGroup() (head, leading CommentGroup)
- func (t *TypeGroupStmt) End() token.Position
- func (t *TypeGroupStmt) Format(prefix ...string) string
- func (t *TypeGroupStmt) HasHeadCommentGroup() bool
- func (t *TypeGroupStmt) HasLeadingCommentGroup() bool
- func (t *TypeGroupStmt) Pos() token.Position
- type TypeLiteralStmt
- func (t *TypeLiteralStmt) CommentGroup() (head, leading CommentGroup)
- func (t *TypeLiteralStmt) End() token.Position
- func (t *TypeLiteralStmt) Format(prefix ...string) string
- func (t *TypeLiteralStmt) HasHeadCommentGroup() bool
- func (t *TypeLiteralStmt) HasLeadingCommentGroup() bool
- func (t *TypeLiteralStmt) Pos() token.Position
- type TypeStmt
- type WriteMode
- type Writer
Constants ¶
const ( NilIndent = "" WhiteSpace = " " Indent = "\t" NewLine = "\n" )
Variables ¶
This section is empty.
Functions ¶
func DuplicateStmtError ¶
DuplicateStmtError represents a duplicate statement error.
func Fprint ¶
func Fprint(w io.Writer, x interface{}, f FieldFilter) error
Fprint prints the value of x to the writer w.
func NotNilFilter ¶
NotNilFilter returns true for field values that are not nil, it returns false otherwise.
Types ¶
type AST ¶
AST represents a parsed API file.
func (*AST) FormatForUnitTest ¶
FormatForUnitTest formats the AST for unit test.
type AnyDataType ¶
type AnyDataType struct { // Any is the any token node. Any *TokenNode // contains filtered or unexported fields }
AnyDataType is the any data type.
func (*AnyDataType) CanEqual ¶
func (t *AnyDataType) CanEqual() bool
func (*AnyDataType) CommentGroup ¶
func (t *AnyDataType) CommentGroup() (head, leading CommentGroup)
func (*AnyDataType) ContainsStruct ¶
func (t *AnyDataType) ContainsStruct() bool
func (*AnyDataType) End ¶
func (t *AnyDataType) End() token.Position
func (*AnyDataType) Format ¶
func (t *AnyDataType) Format(prefix ...string) string
func (*AnyDataType) HasHeadCommentGroup ¶
func (t *AnyDataType) HasHeadCommentGroup() bool
func (*AnyDataType) HasLeadingCommentGroup ¶
func (t *AnyDataType) HasLeadingCommentGroup() bool
func (*AnyDataType) Pos ¶
func (t *AnyDataType) Pos() token.Position
func (*AnyDataType) RawText ¶
func (t *AnyDataType) RawText() string
type ArrayDataType ¶
type ArrayDataType struct { // LB is the left bracket token node. LBrack *TokenNode // Len is the array length. Length *TokenNode // RB is the right bracket token node. RBrack *TokenNode // DataType is the array data type. DataType DataType // contains filtered or unexported fields }
ArrayDataType is the array data type.
func (*ArrayDataType) CanEqual ¶
func (t *ArrayDataType) CanEqual() bool
func (*ArrayDataType) CommentGroup ¶
func (t *ArrayDataType) CommentGroup() (head, leading CommentGroup)
func (*ArrayDataType) ContainsStruct ¶
func (t *ArrayDataType) ContainsStruct() bool
func (*ArrayDataType) End ¶
func (t *ArrayDataType) End() token.Position
func (*ArrayDataType) Format ¶
func (t *ArrayDataType) Format(prefix ...string) string
func (*ArrayDataType) HasHeadCommentGroup ¶
func (t *ArrayDataType) HasHeadCommentGroup() bool
func (*ArrayDataType) HasLeadingCommentGroup ¶
func (t *ArrayDataType) HasLeadingCommentGroup() bool
func (*ArrayDataType) Pos ¶
func (t *ArrayDataType) Pos() token.Position
func (*ArrayDataType) RawText ¶
func (t *ArrayDataType) RawText() string
type AtDocGroupStmt ¶
type AtDocGroupStmt struct { AtDoc *TokenNode LParen *TokenNode Values []*KVExpr RParen *TokenNode }
func (*AtDocGroupStmt) CommentGroup ¶
func (a *AtDocGroupStmt) CommentGroup() (head, leading CommentGroup)
func (*AtDocGroupStmt) End ¶
func (a *AtDocGroupStmt) End() token.Position
func (*AtDocGroupStmt) Format ¶
func (a *AtDocGroupStmt) Format(prefix ...string) string
func (*AtDocGroupStmt) HasHeadCommentGroup ¶
func (a *AtDocGroupStmt) HasHeadCommentGroup() bool
func (*AtDocGroupStmt) HasLeadingCommentGroup ¶
func (a *AtDocGroupStmt) HasLeadingCommentGroup() bool
func (*AtDocGroupStmt) Pos ¶
func (a *AtDocGroupStmt) Pos() token.Position
type AtDocLiteralStmt ¶
func (*AtDocLiteralStmt) CommentGroup ¶
func (a *AtDocLiteralStmt) CommentGroup() (head, leading CommentGroup)
func (*AtDocLiteralStmt) End ¶
func (a *AtDocLiteralStmt) End() token.Position
func (*AtDocLiteralStmt) Format ¶
func (a *AtDocLiteralStmt) Format(prefix ...string) string
func (*AtDocLiteralStmt) HasHeadCommentGroup ¶
func (a *AtDocLiteralStmt) HasHeadCommentGroup() bool
func (*AtDocLiteralStmt) HasLeadingCommentGroup ¶
func (a *AtDocLiteralStmt) HasLeadingCommentGroup() bool
func (*AtDocLiteralStmt) Pos ¶
func (a *AtDocLiteralStmt) Pos() token.Position
type AtHandlerStmt ¶
func (*AtHandlerStmt) CommentGroup ¶
func (a *AtHandlerStmt) CommentGroup() (head, leading CommentGroup)
func (*AtHandlerStmt) End ¶
func (a *AtHandlerStmt) End() token.Position
func (*AtHandlerStmt) Format ¶
func (a *AtHandlerStmt) Format(prefix ...string) string
func (*AtHandlerStmt) HasHeadCommentGroup ¶
func (a *AtHandlerStmt) HasHeadCommentGroup() bool
func (*AtHandlerStmt) HasLeadingCommentGroup ¶
func (a *AtHandlerStmt) HasLeadingCommentGroup() bool
func (*AtHandlerStmt) Pos ¶
func (a *AtHandlerStmt) Pos() token.Position
type AtServerStmt ¶
type AtServerStmt struct { // AtServer is the @server token. AtServer *TokenNode // LParen is the left parenthesis token. LParen *TokenNode // Values is the key-value pairs. Values []*KVExpr // RParen is the right parenthesis token. RParen *TokenNode }
AtServerStmt represents @server statement.
func (*AtServerStmt) CommentGroup ¶
func (a *AtServerStmt) CommentGroup() (head, leading CommentGroup)
func (*AtServerStmt) End ¶
func (a *AtServerStmt) End() token.Position
func (*AtServerStmt) Format ¶
func (a *AtServerStmt) Format(prefix ...string) string
func (*AtServerStmt) HasHeadCommentGroup ¶
func (a *AtServerStmt) HasHeadCommentGroup() bool
func (*AtServerStmt) HasLeadingCommentGroup ¶
func (a *AtServerStmt) HasLeadingCommentGroup() bool
func (*AtServerStmt) Pos ¶
func (a *AtServerStmt) Pos() token.Position
type BaseDataType ¶
type BaseDataType struct { // Base is the base token node. Base *TokenNode // contains filtered or unexported fields }
BaseDataType is a common id type which contains bool, uint8, uint16, uint32, uint64, int8, int16, int32, int64, float32, float64, complex64, complex128, string, int, uint, uintptr, byte, rune, any.
func (*BaseDataType) CanEqual ¶
func (t *BaseDataType) CanEqual() bool
func (*BaseDataType) CommentGroup ¶
func (t *BaseDataType) CommentGroup() (head, leading CommentGroup)
func (*BaseDataType) ContainsStruct ¶
func (t *BaseDataType) ContainsStruct() bool
func (*BaseDataType) End ¶
func (t *BaseDataType) End() token.Position
func (*BaseDataType) Format ¶
func (t *BaseDataType) Format(prefix ...string) string
func (*BaseDataType) HasHeadCommentGroup ¶
func (t *BaseDataType) HasHeadCommentGroup() bool
func (*BaseDataType) HasLeadingCommentGroup ¶
func (t *BaseDataType) HasLeadingCommentGroup() bool
func (*BaseDataType) Pos ¶
func (t *BaseDataType) Pos() token.Position
func (*BaseDataType) RawText ¶
func (t *BaseDataType) RawText() string
type BodyExpr ¶
func (*BodyExpr) CommentGroup ¶
func (e *BodyExpr) CommentGroup() (head, leading CommentGroup)
func (*BodyExpr) HasHeadCommentGroup ¶
func (*BodyExpr) HasLeadingCommentGroup ¶
type BodyStmt ¶
func (*BodyStmt) CommentGroup ¶
func (b *BodyStmt) CommentGroup() (head, leading CommentGroup)
func (*BodyStmt) HasHeadCommentGroup ¶
func (*BodyStmt) HasLeadingCommentGroup ¶
type CommentGroup ¶
type CommentGroup []*CommentStmt
CommentGroup represents a list of comments.
func (CommentGroup) Join ¶
func (cg CommentGroup) Join(sep string) string
Join joins the comments with the given separator.
func (CommentGroup) List ¶
func (cg CommentGroup) List() []string
List returns the list of comments.
func (CommentGroup) String ¶
func (cg CommentGroup) String() string
String joins and returns the comment text.
func (CommentGroup) Valid ¶
func (cg CommentGroup) Valid() bool
Valid returns true if the comment is valid.
type CommentStmt ¶
CommentStmt represents a comment statement.
func (*CommentStmt) CommentGroup ¶
func (c *CommentStmt) CommentGroup() (head, leading CommentGroup)
func (*CommentStmt) End ¶
func (c *CommentStmt) End() token.Position
func (*CommentStmt) Format ¶
func (c *CommentStmt) Format(prefix ...string) string
func (*CommentStmt) HasHeadCommentGroup ¶
func (c *CommentStmt) HasHeadCommentGroup() bool
func (*CommentStmt) HasLeadingCommentGroup ¶
func (c *CommentStmt) HasLeadingCommentGroup() bool
func (*CommentStmt) Pos ¶
func (c *CommentStmt) Pos() token.Position
type DataType ¶
type DataType interface { Expr // CanEqual returns true if the data type can be equal. CanEqual() bool // ContainsStruct returns true if the data type contains struct. ContainsStruct() bool // RawText returns the raw text of the data type. RawText() string // contains filtered or unexported methods }
DataType represents the data type.
type ElemExpr ¶
type ElemExpr struct { // Name is the field element name. Name []*TokenNode // DataType is the field data type. DataType DataType // Tag is the field tag. Tag *TokenNode }
ElemExpr is the element expression.
func (*ElemExpr) CommentGroup ¶
func (e *ElemExpr) CommentGroup() (head, leading CommentGroup)
func (*ElemExpr) HasHeadCommentGroup ¶
func (*ElemExpr) HasLeadingCommentGroup ¶
func (*ElemExpr) IsAnonymous ¶
IsAnonymous returns true if the element is anonymous.
type Expr ¶
type Expr interface { Node // contains filtered or unexported methods }
Expr represents an expression in the AST.
type FieldFilter ¶
A FieldFilter may be provided to Fprint to control the output.
type ImportGroupStmt ¶
type ImportGroupStmt struct { // Import is the import token. Import *TokenNode // LParen is the left parenthesis token. LParen *TokenNode // Values is the import values. Values []*TokenNode // RParen is the right parenthesis token. RParen *TokenNode }
func (*ImportGroupStmt) CommentGroup ¶
func (i *ImportGroupStmt) CommentGroup() (head, leading CommentGroup)
func (*ImportGroupStmt) End ¶
func (i *ImportGroupStmt) End() token.Position
func (*ImportGroupStmt) Format ¶
func (i *ImportGroupStmt) Format(prefix ...string) string
func (*ImportGroupStmt) HasHeadCommentGroup ¶
func (i *ImportGroupStmt) HasHeadCommentGroup() bool
func (*ImportGroupStmt) HasLeadingCommentGroup ¶
func (i *ImportGroupStmt) HasLeadingCommentGroup() bool
func (*ImportGroupStmt) Pos ¶
func (i *ImportGroupStmt) Pos() token.Position
type ImportLiteralStmt ¶
type ImportLiteralStmt struct { // Import is the import token. Import *TokenNode // Value is the import value. Value *TokenNode }
ImportLiteralStmt represents an import literal statement.
func (*ImportLiteralStmt) CommentGroup ¶
func (i *ImportLiteralStmt) CommentGroup() (head, leading CommentGroup)
func (*ImportLiteralStmt) End ¶
func (i *ImportLiteralStmt) End() token.Position
func (*ImportLiteralStmt) Format ¶
func (i *ImportLiteralStmt) Format(prefix ...string) (result string)
func (*ImportLiteralStmt) HasHeadCommentGroup ¶
func (i *ImportLiteralStmt) HasHeadCommentGroup() bool
func (*ImportLiteralStmt) HasLeadingCommentGroup ¶
func (i *ImportLiteralStmt) HasLeadingCommentGroup() bool
func (*ImportLiteralStmt) Pos ¶
func (i *ImportLiteralStmt) Pos() token.Position
type ImportStmt ¶
type ImportStmt interface { Stmt // contains filtered or unexported methods }
ImportStmt represents an import statement.
type InfoStmt ¶
type InfoStmt struct { // Info is the info keyword. Info *TokenNode // LParen is the left parenthesis. LParen *TokenNode // Values is the info values. Values []*KVExpr // RParen is the right parenthesis. RParen *TokenNode }
InfoStmt is the info statement.
func (*InfoStmt) CommentGroup ¶
func (i *InfoStmt) CommentGroup() (head, leading CommentGroup)
func (*InfoStmt) HasHeadCommentGroup ¶
func (*InfoStmt) HasLeadingCommentGroup ¶
type InterfaceDataType ¶
type InterfaceDataType struct { // Interface is the interface token node. Interface *TokenNode // contains filtered or unexported fields }
InterfaceDataType is the interface data type.
func (*InterfaceDataType) CanEqual ¶
func (t *InterfaceDataType) CanEqual() bool
func (*InterfaceDataType) CommentGroup ¶
func (t *InterfaceDataType) CommentGroup() (head, leading CommentGroup)
func (*InterfaceDataType) ContainsStruct ¶
func (t *InterfaceDataType) ContainsStruct() bool
func (*InterfaceDataType) End ¶
func (t *InterfaceDataType) End() token.Position
func (*InterfaceDataType) Format ¶
func (t *InterfaceDataType) Format(prefix ...string) string
func (*InterfaceDataType) HasHeadCommentGroup ¶
func (t *InterfaceDataType) HasHeadCommentGroup() bool
func (*InterfaceDataType) HasLeadingCommentGroup ¶
func (t *InterfaceDataType) HasLeadingCommentGroup() bool
func (*InterfaceDataType) Pos ¶
func (t *InterfaceDataType) Pos() token.Position
func (*InterfaceDataType) RawText ¶
func (t *InterfaceDataType) RawText() string
type KVExpr ¶
type KVExpr struct { // Key is the key of the key value expression. Key *TokenNode // Value is the value of the key value expression. Value *TokenNode }
KVExpr is a key value expression.
func (*KVExpr) CommentGroup ¶
func (i *KVExpr) CommentGroup() (head, leading CommentGroup)
func (*KVExpr) HasHeadCommentGroup ¶
func (*KVExpr) HasLeadingCommentGroup ¶
type MapDataType ¶
type MapDataType struct { // Map is the map token node. Map *TokenNode // Lbrack is the left bracket token node. LBrack *TokenNode // Key is the map key data type. Key DataType // Rbrack is the right bracket token node. RBrack *TokenNode // Value is the map value data type. Value DataType // contains filtered or unexported fields }
MapDataType is the map data type.
func (*MapDataType) CanEqual ¶
func (t *MapDataType) CanEqual() bool
func (*MapDataType) CommentGroup ¶
func (t *MapDataType) CommentGroup() (head, leading CommentGroup)
func (*MapDataType) ContainsStruct ¶
func (t *MapDataType) ContainsStruct() bool
func (*MapDataType) End ¶
func (t *MapDataType) End() token.Position
func (*MapDataType) Format ¶
func (t *MapDataType) Format(prefix ...string) string
func (*MapDataType) HasHeadCommentGroup ¶
func (t *MapDataType) HasHeadCommentGroup() bool
func (*MapDataType) HasLeadingCommentGroup ¶
func (t *MapDataType) HasLeadingCommentGroup() bool
func (*MapDataType) Pos ¶
func (t *MapDataType) Pos() token.Position
func (*MapDataType) RawText ¶
func (t *MapDataType) RawText() string
type Node ¶
type Node interface { // Pos returns the position of the first character belonging to the node. Pos() token.Position // End returns the position of the first character immediately after the node. End() token.Position // Format returns the node's text after format. Format(...string) string // HasHeadCommentGroup returns true if the node has head comment group. HasHeadCommentGroup() bool // HasLeadingCommentGroup returns true if the node has leading comment group. HasLeadingCommentGroup() bool // CommentGroup returns the node's head comment group and leading comment group. CommentGroup() (head, leading CommentGroup) }
Node represents a node in the AST.
type PathExpr ¶
type PathExpr struct {
Value *TokenNode
}
func (*PathExpr) CommentGroup ¶
func (p *PathExpr) CommentGroup() (head, leading CommentGroup)
func (*PathExpr) HasHeadCommentGroup ¶
func (*PathExpr) HasLeadingCommentGroup ¶
type PointerDataType ¶
type PointerDataType struct { // Star is the star token node. Star *TokenNode // DataType is the pointer data type. DataType DataType // contains filtered or unexported fields }
PointerDataType is the pointer data type.
func (*PointerDataType) CanEqual ¶
func (t *PointerDataType) CanEqual() bool
func (*PointerDataType) CommentGroup ¶
func (t *PointerDataType) CommentGroup() (head, leading CommentGroup)
func (*PointerDataType) ContainsStruct ¶
func (t *PointerDataType) ContainsStruct() bool
func (*PointerDataType) End ¶
func (t *PointerDataType) End() token.Position
func (*PointerDataType) Format ¶
func (t *PointerDataType) Format(prefix ...string) string
func (*PointerDataType) HasHeadCommentGroup ¶
func (t *PointerDataType) HasHeadCommentGroup() bool
func (*PointerDataType) HasLeadingCommentGroup ¶
func (t *PointerDataType) HasLeadingCommentGroup() bool
func (*PointerDataType) Pos ¶
func (t *PointerDataType) Pos() token.Position
func (*PointerDataType) RawText ¶
func (t *PointerDataType) RawText() string
type RouteStmt ¶
type RouteStmt struct { Method *TokenNode Path *PathExpr Request *BodyStmt Returns *TokenNode Response *BodyStmt }
func (*RouteStmt) CommentGroup ¶
func (r *RouteStmt) CommentGroup() (head, leading CommentGroup)
func (*RouteStmt) HasHeadCommentGroup ¶
func (*RouteStmt) HasLeadingCommentGroup ¶
type ServiceItemStmt ¶
type ServiceItemStmt struct { AtDoc AtDocStmt AtHandler *AtHandlerStmt Route *RouteStmt }
func (*ServiceItemStmt) CommentGroup ¶
func (s *ServiceItemStmt) CommentGroup() (head, leading CommentGroup)
func (*ServiceItemStmt) End ¶
func (s *ServiceItemStmt) End() token.Position
func (*ServiceItemStmt) Format ¶
func (s *ServiceItemStmt) Format(prefix ...string) string
func (*ServiceItemStmt) HasHeadCommentGroup ¶
func (s *ServiceItemStmt) HasHeadCommentGroup() bool
func (*ServiceItemStmt) HasLeadingCommentGroup ¶
func (s *ServiceItemStmt) HasLeadingCommentGroup() bool
func (*ServiceItemStmt) Pos ¶
func (s *ServiceItemStmt) Pos() token.Position
type ServiceNameExpr ¶
type ServiceNameExpr struct {
Name *TokenNode
}
func (*ServiceNameExpr) CommentGroup ¶
func (s *ServiceNameExpr) CommentGroup() (head, leading CommentGroup)
func (*ServiceNameExpr) End ¶
func (s *ServiceNameExpr) End() token.Position
func (*ServiceNameExpr) Format ¶
func (s *ServiceNameExpr) Format(...string) string
func (*ServiceNameExpr) HasHeadCommentGroup ¶
func (s *ServiceNameExpr) HasHeadCommentGroup() bool
func (*ServiceNameExpr) HasLeadingCommentGroup ¶
func (s *ServiceNameExpr) HasLeadingCommentGroup() bool
func (*ServiceNameExpr) Pos ¶
func (s *ServiceNameExpr) Pos() token.Position
type ServiceStmt ¶
type ServiceStmt struct { AtServerStmt *AtServerStmt Service *TokenNode Name *ServiceNameExpr LBrace *TokenNode Routes []*ServiceItemStmt RBrace *TokenNode }
func (*ServiceStmt) CommentGroup ¶
func (s *ServiceStmt) CommentGroup() (head, leading CommentGroup)
func (*ServiceStmt) End ¶
func (s *ServiceStmt) End() token.Position
func (*ServiceStmt) Format ¶
func (s *ServiceStmt) Format(prefix ...string) string
func (*ServiceStmt) HasHeadCommentGroup ¶
func (s *ServiceStmt) HasHeadCommentGroup() bool
func (*ServiceStmt) HasLeadingCommentGroup ¶
func (s *ServiceStmt) HasLeadingCommentGroup() bool
func (*ServiceStmt) Pos ¶
func (s *ServiceStmt) Pos() token.Position
type SliceDataType ¶
type SliceDataType struct { // Lbrack is the left bracket token node. LBrack *TokenNode // Rbrack is the right bracket token node. RBrack *TokenNode // DataType is the slice data type. DataType DataType // contains filtered or unexported fields }
SliceDataType is the slice data type.
func (*SliceDataType) CanEqual ¶
func (t *SliceDataType) CanEqual() bool
func (*SliceDataType) CommentGroup ¶
func (t *SliceDataType) CommentGroup() (head, leading CommentGroup)
func (*SliceDataType) ContainsStruct ¶
func (t *SliceDataType) ContainsStruct() bool
func (*SliceDataType) End ¶
func (t *SliceDataType) End() token.Position
func (*SliceDataType) Format ¶
func (t *SliceDataType) Format(prefix ...string) string
func (*SliceDataType) HasHeadCommentGroup ¶
func (t *SliceDataType) HasHeadCommentGroup() bool
func (*SliceDataType) HasLeadingCommentGroup ¶
func (t *SliceDataType) HasLeadingCommentGroup() bool
func (*SliceDataType) Pos ¶
func (t *SliceDataType) Pos() token.Position
func (*SliceDataType) RawText ¶
func (t *SliceDataType) RawText() string
type Stmt ¶
type Stmt interface { Node // contains filtered or unexported methods }
Stmt represents a statement in the AST.
type StructDataType ¶
type StructDataType struct { // Lbrace is the left brace token node. LBrace *TokenNode // Elements is the structure elements. Elements ElemExprList // Rbrace is the right brace token node. RBrace *TokenNode // contains filtered or unexported fields }
StructDataType is the structure data type.
func (*StructDataType) CanEqual ¶
func (t *StructDataType) CanEqual() bool
func (*StructDataType) CommentGroup ¶
func (t *StructDataType) CommentGroup() (head, leading CommentGroup)
func (*StructDataType) ContainsStruct ¶
func (t *StructDataType) ContainsStruct() bool
func (*StructDataType) End ¶
func (t *StructDataType) End() token.Position
func (*StructDataType) Format ¶
func (t *StructDataType) Format(prefix ...string) string
func (*StructDataType) HasHeadCommentGroup ¶
func (t *StructDataType) HasHeadCommentGroup() bool
func (*StructDataType) HasLeadingCommentGroup ¶
func (t *StructDataType) HasLeadingCommentGroup() bool
func (*StructDataType) Pos ¶
func (t *StructDataType) Pos() token.Position
func (*StructDataType) RawText ¶
func (t *StructDataType) RawText() string
type SyntaxStmt ¶
type SyntaxStmt struct { // Syntax is the syntax token. Syntax *TokenNode // Assign is the assign token. Assign *TokenNode // Value is the syntax value. Value *TokenNode }
SyntaxStmt represents a syntax statement.
func (*SyntaxStmt) CommentGroup ¶
func (s *SyntaxStmt) CommentGroup() (head, leading CommentGroup)
func (*SyntaxStmt) End ¶
func (s *SyntaxStmt) End() token.Position
func (*SyntaxStmt) Format ¶
func (s *SyntaxStmt) Format(prefix ...string) string
func (*SyntaxStmt) HasHeadCommentGroup ¶
func (s *SyntaxStmt) HasHeadCommentGroup() bool
func (*SyntaxStmt) HasLeadingCommentGroup ¶
func (s *SyntaxStmt) HasLeadingCommentGroup() bool
func (*SyntaxStmt) Pos ¶
func (s *SyntaxStmt) Pos() token.Position
type TokenNode ¶
type TokenNode struct { // HeadCommentGroup are the comments in prev lines. HeadCommentGroup CommentGroup // Token is the token of the node. Token token.Token // LeadingCommentGroup are the tail comments in same line. LeadingCommentGroup CommentGroup // contains filtered or unexported fields }
TokenNode represents a token node in the AST.
func NewTokenNode ¶
NewTokenNode creates and returns a new TokenNode.
func (*TokenNode) CommentGroup ¶
func (t *TokenNode) CommentGroup() (head, leading CommentGroup)
func (*TokenNode) HasHeadCommentGroup ¶
func (*TokenNode) HasLeadingCommentGroup ¶
func (*TokenNode) IsEmptyString ¶
IsEmptyString returns true if the node is empty string.
func (*TokenNode) IsZeroString ¶
IsZeroString returns true if the node is zero string.
func (*TokenNode) PeekFirstHeadComment ¶
func (t *TokenNode) PeekFirstHeadComment() *CommentStmt
PeekFirstHeadComment returns the first head comment of the node.
func (*TokenNode) PeekFirstLeadingComment ¶
func (t *TokenNode) PeekFirstLeadingComment() *CommentStmt
PeekFirstLeadingComment returns the first leading comment of the node.
func (*TokenNode) SetLeadingCommentGroup ¶
func (t *TokenNode) SetLeadingCommentGroup(cg CommentGroup)
SetLeadingCommentGroup sets the node's leading comment group.
type TypeExpr ¶
type TypeExpr struct { // Name is the type name. Name *TokenNode // Assign is the assign operator. Assign *TokenNode // DataType is the data type. DataType DataType }
TypeExpr is the type expression.
func (*TypeExpr) CommentGroup ¶
func (e *TypeExpr) CommentGroup() (head, leading CommentGroup)
func (*TypeExpr) HasHeadCommentGroup ¶
func (*TypeExpr) HasLeadingCommentGroup ¶
type TypeGroupStmt ¶
type TypeGroupStmt struct { // Type is the type keyword. Type *TokenNode // LParen is the left parenthesis. LParen *TokenNode // ExprList is the type expression list. ExprList []*TypeExpr // RParen is the right parenthesis. RParen *TokenNode }
TypeGroupStmt is the type statement for type group.
func (*TypeGroupStmt) CommentGroup ¶
func (t *TypeGroupStmt) CommentGroup() (head, leading CommentGroup)
func (*TypeGroupStmt) End ¶
func (t *TypeGroupStmt) End() token.Position
func (*TypeGroupStmt) Format ¶
func (t *TypeGroupStmt) Format(prefix ...string) string
func (*TypeGroupStmt) HasHeadCommentGroup ¶
func (t *TypeGroupStmt) HasHeadCommentGroup() bool
func (*TypeGroupStmt) HasLeadingCommentGroup ¶
func (t *TypeGroupStmt) HasLeadingCommentGroup() bool
func (*TypeGroupStmt) Pos ¶
func (t *TypeGroupStmt) Pos() token.Position
type TypeLiteralStmt ¶
type TypeLiteralStmt struct { // Type is the type keyword. Type *TokenNode // Expr is the type expression. Expr *TypeExpr }
TypeLiteralStmt is the type statement for type literal.
func (*TypeLiteralStmt) CommentGroup ¶
func (t *TypeLiteralStmt) CommentGroup() (head, leading CommentGroup)
func (*TypeLiteralStmt) End ¶
func (t *TypeLiteralStmt) End() token.Position
func (*TypeLiteralStmt) Format ¶
func (t *TypeLiteralStmt) Format(prefix ...string) string
func (*TypeLiteralStmt) HasHeadCommentGroup ¶
func (t *TypeLiteralStmt) HasHeadCommentGroup() bool
func (*TypeLiteralStmt) HasLeadingCommentGroup ¶
func (t *TypeLiteralStmt) HasLeadingCommentGroup() bool
func (*TypeLiteralStmt) Pos ¶
func (t *TypeLiteralStmt) Pos() token.Position
type TypeStmt ¶
type TypeStmt interface { Stmt // contains filtered or unexported methods }
TypeStmt is the interface for type statement.
type WriteMode ¶
type WriteMode int
WriteMode is the mode of writing.
const ( // ModeAuto is the default mode, which will automatically //determine whether to write a newline. ModeAuto WriteMode // ModeExpectInSameLine will write in the same line. ModeExpectInSameLine )