|
@@ -9,13 +9,15 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
type (
|
|
type (
|
|
- // TypeAlias、 TypeStruct
|
|
|
|
|
|
+ // TypeExpr describes an expression for TypeAlias and TypeStruct
|
|
TypeExpr interface {
|
|
TypeExpr interface {
|
|
Doc() []Expr
|
|
Doc() []Expr
|
|
Format() error
|
|
Format() error
|
|
Equal(v interface{}) bool
|
|
Equal(v interface{}) bool
|
|
NameExpr() Expr
|
|
NameExpr() Expr
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // TypeAlias describes alias ast for api syatax
|
|
TypeAlias struct {
|
|
TypeAlias struct {
|
|
Name Expr
|
|
Name Expr
|
|
Assign Expr
|
|
Assign Expr
|
|
@@ -24,6 +26,7 @@ type (
|
|
CommentExpr Expr
|
|
CommentExpr Expr
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // TypeStruct describes structure ast for api syatax
|
|
TypeStruct struct {
|
|
TypeStruct struct {
|
|
Name Expr
|
|
Name Expr
|
|
Struct Expr
|
|
Struct Expr
|
|
@@ -33,6 +36,7 @@ type (
|
|
Fields []*TypeField
|
|
Fields []*TypeField
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // TypeField describes field ast for api syntax
|
|
TypeField struct {
|
|
TypeField struct {
|
|
IsAnonymous bool
|
|
IsAnonymous bool
|
|
// Name is nil if IsAnonymous
|
|
// Name is nil if IsAnonymous
|
|
@@ -43,6 +47,7 @@ type (
|
|
CommentExpr Expr
|
|
CommentExpr Expr
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // DataType describes datatype for api syntax, the default implementation expressions are
|
|
// Literal, Interface, Map, Array, Time, Pointer
|
|
// Literal, Interface, Map, Array, Time, Pointer
|
|
DataType interface {
|
|
DataType interface {
|
|
Expr() Expr
|
|
Expr() Expr
|
|
@@ -51,15 +56,18 @@ type (
|
|
IsNotNil() bool
|
|
IsNotNil() bool
|
|
}
|
|
}
|
|
|
|
|
|
- // int, bool, Foo,...
|
|
|
|
|
|
+ // Literal describes the basic types of golang, non-reference types,
|
|
|
|
+ // such as int, bool, Foo,...
|
|
Literal struct {
|
|
Literal struct {
|
|
Literal Expr
|
|
Literal Expr
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Interface describes the interface type of golang,Its fixed value is interface{}
|
|
Interface struct {
|
|
Interface struct {
|
|
Literal Expr
|
|
Literal Expr
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Map describes the map ast for api syntax
|
|
Map struct {
|
|
Map struct {
|
|
MapExpr Expr
|
|
MapExpr Expr
|
|
Map Expr
|
|
Map Expr
|
|
@@ -69,6 +77,7 @@ type (
|
|
Value DataType
|
|
Value DataType
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Array describes the slice ast for api syntax
|
|
Array struct {
|
|
Array struct {
|
|
ArrayExpr Expr
|
|
ArrayExpr Expr
|
|
LBrack Expr
|
|
LBrack Expr
|
|
@@ -76,10 +85,12 @@ type (
|
|
Literal DataType
|
|
Literal DataType
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Time describes the time ast for api syntax
|
|
Time struct {
|
|
Time struct {
|
|
Literal Expr
|
|
Literal Expr
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Pointer describes the pointer ast for api syntax
|
|
Pointer struct {
|
|
Pointer struct {
|
|
PointerExpr Expr
|
|
PointerExpr Expr
|
|
Star Expr
|
|
Star Expr
|
|
@@ -87,6 +98,7 @@ type (
|
|
}
|
|
}
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+// VisitTypeSpec implements from api.BaseApiParserVisitor
|
|
func (v *ApiVisitor) VisitTypeSpec(ctx *api.TypeSpecContext) interface{} {
|
|
func (v *ApiVisitor) VisitTypeSpec(ctx *api.TypeSpecContext) interface{} {
|
|
if ctx.TypeLit() != nil {
|
|
if ctx.TypeLit() != nil {
|
|
return []TypeExpr{ctx.TypeLit().Accept(v).(TypeExpr)}
|
|
return []TypeExpr{ctx.TypeLit().Accept(v).(TypeExpr)}
|
|
@@ -94,6 +106,7 @@ func (v *ApiVisitor) VisitTypeSpec(ctx *api.TypeSpecContext) interface{} {
|
|
return ctx.TypeBlock().Accept(v)
|
|
return ctx.TypeBlock().Accept(v)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// VisitTypeLit implements from api.BaseApiParserVisitor
|
|
func (v *ApiVisitor) VisitTypeLit(ctx *api.TypeLitContext) interface{} {
|
|
func (v *ApiVisitor) VisitTypeLit(ctx *api.TypeLitContext) interface{} {
|
|
typeLit := ctx.TypeLitBody().Accept(v)
|
|
typeLit := ctx.TypeLitBody().Accept(v)
|
|
alias, ok := typeLit.(*TypeAlias)
|
|
alias, ok := typeLit.(*TypeAlias)
|
|
@@ -109,6 +122,7 @@ func (v *ApiVisitor) VisitTypeLit(ctx *api.TypeLitContext) interface{} {
|
|
return typeLit
|
|
return typeLit
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// VisitTypeBlock implements from api.BaseApiParserVisitor
|
|
func (v *ApiVisitor) VisitTypeBlock(ctx *api.TypeBlockContext) interface{} {
|
|
func (v *ApiVisitor) VisitTypeBlock(ctx *api.TypeBlockContext) interface{} {
|
|
list := ctx.AllTypeBlockBody()
|
|
list := ctx.AllTypeBlockBody()
|
|
var types []TypeExpr
|
|
var types []TypeExpr
|
|
@@ -119,6 +133,7 @@ func (v *ApiVisitor) VisitTypeBlock(ctx *api.TypeBlockContext) interface{} {
|
|
return types
|
|
return types
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// VisitTypeLitBody implements from api.BaseApiParserVisitor
|
|
func (v *ApiVisitor) VisitTypeLitBody(ctx *api.TypeLitBodyContext) interface{} {
|
|
func (v *ApiVisitor) VisitTypeLitBody(ctx *api.TypeLitBodyContext) interface{} {
|
|
if ctx.TypeAlias() != nil {
|
|
if ctx.TypeAlias() != nil {
|
|
return ctx.TypeAlias().Accept(v)
|
|
return ctx.TypeAlias().Accept(v)
|
|
@@ -126,6 +141,7 @@ func (v *ApiVisitor) VisitTypeLitBody(ctx *api.TypeLitBodyContext) interface{} {
|
|
return ctx.TypeStruct().Accept(v)
|
|
return ctx.TypeStruct().Accept(v)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// VisitTypeBlockBody implements from api.BaseApiParserVisitor
|
|
func (v *ApiVisitor) VisitTypeBlockBody(ctx *api.TypeBlockBodyContext) interface{} {
|
|
func (v *ApiVisitor) VisitTypeBlockBody(ctx *api.TypeBlockBodyContext) interface{} {
|
|
if ctx.TypeBlockAlias() != nil {
|
|
if ctx.TypeBlockAlias() != nil {
|
|
return ctx.TypeBlockAlias().Accept(v).(*TypeAlias)
|
|
return ctx.TypeBlockAlias().Accept(v).(*TypeAlias)
|
|
@@ -133,6 +149,7 @@ func (v *ApiVisitor) VisitTypeBlockBody(ctx *api.TypeBlockBodyContext) interface
|
|
return ctx.TypeBlockStruct().Accept(v).(*TypeStruct)
|
|
return ctx.TypeBlockStruct().Accept(v).(*TypeStruct)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// VisitTypeStruct implements from api.BaseApiParserVisitor
|
|
func (v *ApiVisitor) VisitTypeStruct(ctx *api.TypeStructContext) interface{} {
|
|
func (v *ApiVisitor) VisitTypeStruct(ctx *api.TypeStructContext) interface{} {
|
|
var st TypeStruct
|
|
var st TypeStruct
|
|
st.Name = v.newExprWithToken(ctx.GetStructName())
|
|
st.Name = v.newExprWithToken(ctx.GetStructName())
|
|
@@ -168,6 +185,7 @@ func (v *ApiVisitor) VisitTypeStruct(ctx *api.TypeStructContext) interface{} {
|
|
return &st
|
|
return &st
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// VisitTypeBlockStruct implements from api.BaseApiParserVisitor
|
|
func (v *ApiVisitor) VisitTypeBlockStruct(ctx *api.TypeBlockStructContext) interface{} {
|
|
func (v *ApiVisitor) VisitTypeBlockStruct(ctx *api.TypeBlockStructContext) interface{} {
|
|
var st TypeStruct
|
|
var st TypeStruct
|
|
st.Name = v.newExprWithToken(ctx.GetStructName())
|
|
st.Name = v.newExprWithToken(ctx.GetStructName())
|
|
@@ -200,6 +218,7 @@ func (v *ApiVisitor) VisitTypeBlockStruct(ctx *api.TypeBlockStructContext) inter
|
|
return &st
|
|
return &st
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// VisitTypeBlockAlias implements from api.BaseApiParserVisitor
|
|
func (v *ApiVisitor) VisitTypeBlockAlias(ctx *api.TypeBlockAliasContext) interface{} {
|
|
func (v *ApiVisitor) VisitTypeBlockAlias(ctx *api.TypeBlockAliasContext) interface{} {
|
|
var alias TypeAlias
|
|
var alias TypeAlias
|
|
alias.Name = v.newExprWithToken(ctx.GetAlias())
|
|
alias.Name = v.newExprWithToken(ctx.GetAlias())
|
|
@@ -212,6 +231,7 @@ func (v *ApiVisitor) VisitTypeBlockAlias(ctx *api.TypeBlockAliasContext) interfa
|
|
return &alias
|
|
return &alias
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// VisitTypeAlias implements from api.BaseApiParserVisitor
|
|
func (v *ApiVisitor) VisitTypeAlias(ctx *api.TypeAliasContext) interface{} {
|
|
func (v *ApiVisitor) VisitTypeAlias(ctx *api.TypeAliasContext) interface{} {
|
|
var alias TypeAlias
|
|
var alias TypeAlias
|
|
alias.Name = v.newExprWithToken(ctx.GetAlias())
|
|
alias.Name = v.newExprWithToken(ctx.GetAlias())
|
|
@@ -224,6 +244,7 @@ func (v *ApiVisitor) VisitTypeAlias(ctx *api.TypeAliasContext) interface{} {
|
|
return &alias
|
|
return &alias
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// VisitField implements from api.BaseApiParserVisitor
|
|
func (v *ApiVisitor) VisitField(ctx *api.FieldContext) interface{} {
|
|
func (v *ApiVisitor) VisitField(ctx *api.FieldContext) interface{} {
|
|
iAnonymousFiled := ctx.AnonymousFiled()
|
|
iAnonymousFiled := ctx.AnonymousFiled()
|
|
iNormalFieldContext := ctx.NormalField()
|
|
iNormalFieldContext := ctx.NormalField()
|
|
@@ -236,6 +257,7 @@ func (v *ApiVisitor) VisitField(ctx *api.FieldContext) interface{} {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// VisitNormalField implements from api.BaseApiParserVisitor
|
|
func (v *ApiVisitor) VisitNormalField(ctx *api.NormalFieldContext) interface{} {
|
|
func (v *ApiVisitor) VisitNormalField(ctx *api.NormalFieldContext) interface{} {
|
|
var field TypeField
|
|
var field TypeField
|
|
field.Name = v.newExprWithToken(ctx.GetFieldName())
|
|
field.Name = v.newExprWithToken(ctx.GetFieldName())
|
|
@@ -259,6 +281,7 @@ func (v *ApiVisitor) VisitNormalField(ctx *api.NormalFieldContext) interface{} {
|
|
return &field
|
|
return &field
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// VisitAnonymousFiled implements from api.BaseApiParserVisitor
|
|
func (v *ApiVisitor) VisitAnonymousFiled(ctx *api.AnonymousFiledContext) interface{} {
|
|
func (v *ApiVisitor) VisitAnonymousFiled(ctx *api.AnonymousFiledContext) interface{} {
|
|
start := ctx.GetStart()
|
|
start := ctx.GetStart()
|
|
stop := ctx.GetStop()
|
|
stop := ctx.GetStop()
|
|
@@ -282,6 +305,7 @@ func (v *ApiVisitor) VisitAnonymousFiled(ctx *api.AnonymousFiledContext) interfa
|
|
return &field
|
|
return &field
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// VisitDataType implements from api.BaseApiParserVisitor
|
|
func (v *ApiVisitor) VisitDataType(ctx *api.DataTypeContext) interface{} {
|
|
func (v *ApiVisitor) VisitDataType(ctx *api.DataTypeContext) interface{} {
|
|
if ctx.ID() != nil {
|
|
if ctx.ID() != nil {
|
|
idExpr := v.newExprWithTerminalNode(ctx.ID())
|
|
idExpr := v.newExprWithTerminalNode(ctx.ID())
|
|
@@ -310,6 +334,7 @@ func (v *ApiVisitor) VisitDataType(ctx *api.DataTypeContext) interface{} {
|
|
return ctx.TypeStruct().Accept(v)
|
|
return ctx.TypeStruct().Accept(v)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// VisitPointerType implements from api.BaseApiParserVisitor
|
|
func (v *ApiVisitor) VisitPointerType(ctx *api.PointerTypeContext) interface{} {
|
|
func (v *ApiVisitor) VisitPointerType(ctx *api.PointerTypeContext) interface{} {
|
|
nameExpr := v.newExprWithTerminalNode(ctx.ID())
|
|
nameExpr := v.newExprWithTerminalNode(ctx.ID())
|
|
v.exportCheck(nameExpr)
|
|
v.exportCheck(nameExpr)
|
|
@@ -320,6 +345,7 @@ func (v *ApiVisitor) VisitPointerType(ctx *api.PointerTypeContext) interface{} {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// VisitMapType implements from api.BaseApiParserVisitor
|
|
func (v *ApiVisitor) VisitMapType(ctx *api.MapTypeContext) interface{} {
|
|
func (v *ApiVisitor) VisitMapType(ctx *api.MapTypeContext) interface{} {
|
|
return &Map{
|
|
return &Map{
|
|
MapExpr: v.newExprWithText(ctx.GetText(), ctx.GetMapToken().GetLine(), ctx.GetMapToken().GetColumn(),
|
|
MapExpr: v.newExprWithText(ctx.GetText(), ctx.GetMapToken().GetLine(), ctx.GetMapToken().GetColumn(),
|
|
@@ -332,6 +358,7 @@ func (v *ApiVisitor) VisitMapType(ctx *api.MapTypeContext) interface{} {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// VisitArrayType implements from api.BaseApiParserVisitor
|
|
func (v *ApiVisitor) VisitArrayType(ctx *api.ArrayTypeContext) interface{} {
|
|
func (v *ApiVisitor) VisitArrayType(ctx *api.ArrayTypeContext) interface{} {
|
|
return &Array{
|
|
return &Array{
|
|
ArrayExpr: v.newExprWithText(ctx.GetText(), ctx.GetLbrack().GetLine(), ctx.GetLbrack().GetColumn(), ctx.GetLbrack().GetStart(), ctx.DataType().GetStop().GetStop()),
|
|
ArrayExpr: v.newExprWithText(ctx.GetText(), ctx.GetLbrack().GetLine(), ctx.GetLbrack().GetColumn(), ctx.GetLbrack().GetStart(), ctx.DataType().GetStop().GetStop()),
|
|
@@ -341,22 +368,27 @@ func (v *ApiVisitor) VisitArrayType(ctx *api.ArrayTypeContext) interface{} {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// NameExpr returns the expression string of TypeAlias
|
|
func (a *TypeAlias) NameExpr() Expr {
|
|
func (a *TypeAlias) NameExpr() Expr {
|
|
return a.Name
|
|
return a.Name
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Doc returns the document of TypeAlias, like // some text
|
|
func (a *TypeAlias) Doc() []Expr {
|
|
func (a *TypeAlias) Doc() []Expr {
|
|
return a.DocExpr
|
|
return a.DocExpr
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Comment returns the comment of TypeAlias, like // some text
|
|
func (a *TypeAlias) Comment() Expr {
|
|
func (a *TypeAlias) Comment() Expr {
|
|
return a.CommentExpr
|
|
return a.CommentExpr
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Format provides a formatter for api command, now nothing to do
|
|
func (a *TypeAlias) Format() error {
|
|
func (a *TypeAlias) Format() error {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Equal compares whether the element literals in two TypeAlias are equal
|
|
func (a *TypeAlias) Equal(v interface{}) bool {
|
|
func (a *TypeAlias) Equal(v interface{}) bool {
|
|
if v == nil {
|
|
if v == nil {
|
|
return false
|
|
return false
|
|
@@ -378,15 +410,18 @@ func (a *TypeAlias) Equal(v interface{}) bool {
|
|
return EqualDoc(a, alias)
|
|
return EqualDoc(a, alias)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Expr returns the expression string of Literal
|
|
func (l *Literal) Expr() Expr {
|
|
func (l *Literal) Expr() Expr {
|
|
return l.Literal
|
|
return l.Literal
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Format provides a formatter for api command, now nothing to do
|
|
func (l *Literal) Format() error {
|
|
func (l *Literal) Format() error {
|
|
// todo
|
|
// todo
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Equal compares whether the element literals in two Literal are equal
|
|
func (l *Literal) Equal(dt DataType) bool {
|
|
func (l *Literal) Equal(dt DataType) bool {
|
|
if dt == nil {
|
|
if dt == nil {
|
|
return false
|
|
return false
|
|
@@ -400,19 +435,23 @@ func (l *Literal) Equal(dt DataType) bool {
|
|
return l.Literal.Equal(v.Literal)
|
|
return l.Literal.Equal(v.Literal)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// IsNotNil returns whether the instance is nil or not
|
|
func (l *Literal) IsNotNil() bool {
|
|
func (l *Literal) IsNotNil() bool {
|
|
return l != nil
|
|
return l != nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Expr returns the expression string of Interface
|
|
func (i *Interface) Expr() Expr {
|
|
func (i *Interface) Expr() Expr {
|
|
return i.Literal
|
|
return i.Literal
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Format provides a formatter for api command, now nothing to do
|
|
func (i *Interface) Format() error {
|
|
func (i *Interface) Format() error {
|
|
// todo
|
|
// todo
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Equal compares whether the element literals in two Interface are equal
|
|
func (i *Interface) Equal(dt DataType) bool {
|
|
func (i *Interface) Equal(dt DataType) bool {
|
|
if dt == nil {
|
|
if dt == nil {
|
|
return false
|
|
return false
|
|
@@ -426,19 +465,23 @@ func (i *Interface) Equal(dt DataType) bool {
|
|
return i.Literal.Equal(v.Literal)
|
|
return i.Literal.Equal(v.Literal)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// IsNotNil returns whether the instance is nil or not
|
|
func (i *Interface) IsNotNil() bool {
|
|
func (i *Interface) IsNotNil() bool {
|
|
return i != nil
|
|
return i != nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Expr returns the expression string of Map
|
|
func (m *Map) Expr() Expr {
|
|
func (m *Map) Expr() Expr {
|
|
return m.MapExpr
|
|
return m.MapExpr
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Format provides a formatter for api command, now nothing to do
|
|
func (m *Map) Format() error {
|
|
func (m *Map) Format() error {
|
|
// todo
|
|
// todo
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Equal compares whether the element literals in two Map are equal
|
|
func (m *Map) Equal(dt DataType) bool {
|
|
func (m *Map) Equal(dt DataType) bool {
|
|
if dt == nil {
|
|
if dt == nil {
|
|
return false
|
|
return false
|
|
@@ -464,19 +507,23 @@ func (m *Map) Equal(dt DataType) bool {
|
|
return m.Map.Equal(v.Map)
|
|
return m.Map.Equal(v.Map)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// IsNotNil returns whether the instance is nil or not
|
|
func (m *Map) IsNotNil() bool {
|
|
func (m *Map) IsNotNil() bool {
|
|
return m != nil
|
|
return m != nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Expr returns the expression string of Array
|
|
func (a *Array) Expr() Expr {
|
|
func (a *Array) Expr() Expr {
|
|
return a.ArrayExpr
|
|
return a.ArrayExpr
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Format provides a formatter for api command, now nothing to do
|
|
func (a *Array) Format() error {
|
|
func (a *Array) Format() error {
|
|
// todo
|
|
// todo
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Equal compares whether the element literals in two Array are equal
|
|
func (a *Array) Equal(dt DataType) bool {
|
|
func (a *Array) Equal(dt DataType) bool {
|
|
if dt == nil {
|
|
if dt == nil {
|
|
return false
|
|
return false
|
|
@@ -494,19 +541,23 @@ func (a *Array) Equal(dt DataType) bool {
|
|
return a.Literal.Equal(v.Literal)
|
|
return a.Literal.Equal(v.Literal)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// IsNotNil returns whether the instance is nil or not
|
|
func (a *Array) IsNotNil() bool {
|
|
func (a *Array) IsNotNil() bool {
|
|
return a != nil
|
|
return a != nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Expr returns the expression string of Time
|
|
func (t *Time) Expr() Expr {
|
|
func (t *Time) Expr() Expr {
|
|
return t.Literal
|
|
return t.Literal
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Format provides a formatter for api command, now nothing to do
|
|
func (t *Time) Format() error {
|
|
func (t *Time) Format() error {
|
|
// todo
|
|
// todo
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Equal compares whether the element literals in two Time are equal
|
|
func (t *Time) Equal(dt DataType) bool {
|
|
func (t *Time) Equal(dt DataType) bool {
|
|
if dt == nil {
|
|
if dt == nil {
|
|
return false
|
|
return false
|
|
@@ -520,18 +571,22 @@ func (t *Time) Equal(dt DataType) bool {
|
|
return t.Literal.Equal(v.Literal)
|
|
return t.Literal.Equal(v.Literal)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// IsNotNil returns whether the instance is nil or not
|
|
func (t *Time) IsNotNil() bool {
|
|
func (t *Time) IsNotNil() bool {
|
|
return t != nil
|
|
return t != nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Expr returns the expression string of Pointer
|
|
func (p *Pointer) Expr() Expr {
|
|
func (p *Pointer) Expr() Expr {
|
|
return p.PointerExpr
|
|
return p.PointerExpr
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Format provides a formatter for api command, now nothing to do
|
|
func (p *Pointer) Format() error {
|
|
func (p *Pointer) Format() error {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Equal compares whether the element literals in two Pointer are equal
|
|
func (p *Pointer) Equal(dt DataType) bool {
|
|
func (p *Pointer) Equal(dt DataType) bool {
|
|
if dt == nil {
|
|
if dt == nil {
|
|
return false
|
|
return false
|
|
@@ -553,14 +608,17 @@ func (p *Pointer) Equal(dt DataType) bool {
|
|
return p.Name.Equal(v.Name)
|
|
return p.Name.Equal(v.Name)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// IsNotNil returns whether the instance is nil or not
|
|
func (p *Pointer) IsNotNil() bool {
|
|
func (p *Pointer) IsNotNil() bool {
|
|
return p != nil
|
|
return p != nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// NameExpr returns the expression string of TypeStruct
|
|
func (s *TypeStruct) NameExpr() Expr {
|
|
func (s *TypeStruct) NameExpr() Expr {
|
|
return s.Name
|
|
return s.Name
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Equal compares whether the element literals in two TypeStruct are equal
|
|
func (s *TypeStruct) Equal(dt interface{}) bool {
|
|
func (s *TypeStruct) Equal(dt interface{}) bool {
|
|
if dt == nil {
|
|
if dt == nil {
|
|
return false
|
|
return false
|
|
@@ -621,15 +679,18 @@ func (s *TypeStruct) Equal(dt interface{}) bool {
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Doc returns the document of TypeStruct, like // some text
|
|
func (s *TypeStruct) Doc() []Expr {
|
|
func (s *TypeStruct) Doc() []Expr {
|
|
return s.DocExpr
|
|
return s.DocExpr
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Format provides a formatter for api command, now nothing to do
|
|
func (s *TypeStruct) Format() error {
|
|
func (s *TypeStruct) Format() error {
|
|
// todo
|
|
// todo
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Equal compares whether the element literals in two TypeField are equal
|
|
func (t *TypeField) Equal(v interface{}) bool {
|
|
func (t *TypeField) Equal(v interface{}) bool {
|
|
if v == nil {
|
|
if v == nil {
|
|
return false
|
|
return false
|
|
@@ -663,14 +724,17 @@ func (t *TypeField) Equal(v interface{}) bool {
|
|
return EqualDoc(t, f)
|
|
return EqualDoc(t, f)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Doc returns the document of TypeField, like // some text
|
|
func (t *TypeField) Doc() []Expr {
|
|
func (t *TypeField) Doc() []Expr {
|
|
return t.DocExpr
|
|
return t.DocExpr
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Comment returns the comment of TypeField, like // some text
|
|
func (t *TypeField) Comment() Expr {
|
|
func (t *TypeField) Comment() Expr {
|
|
return t.CommentExpr
|
|
return t.CommentExpr
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Format provides a formatter for api command, now nothing to do
|
|
func (t *TypeField) Format() error {
|
|
func (t *TypeField) Format() error {
|
|
// todo
|
|
// todo
|
|
return nil
|
|
return nil
|