format

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Indent = "    "
)

Variables

View Source
var BadNodeError = errors.New("syntax error")

Functions

func EqualsAfterFormat

func EqualsAfterFormat(doc1, doc2 string) error

FormatedEquals is used to judge if documents has been changed after formated implementation: ignore all space charactor to compare two strings

func FormatDocument

func FormatDocument(doc *parser.Document) (string, error)

func MustFormat

func MustFormat(tplText string, formatter any) string

func MustFormatAnnotation

func MustFormatAnnotation(anno *parser.Annotation, isLast bool) string

func MustFormatAnnotations

func MustFormatAnnotations(annotations *parser.Annotations) string

func MustFormatCPPInclude

func MustFormatCPPInclude(inc *parser.CPPInclude) string

func MustFormatComments

func MustFormatComments(comments []*parser.Comment, indent string) string

TODO(jpf): 多行注释,换行上还需要优化 MustFormatComments formats comments return string doesn't include '\n' end of line

func MustFormatConst

func MustFormatConst(cst *parser.Const) string

func MustFormatConstValue

func MustFormatConstValue(cv *parser.ConstValue) string

func MustFormatEndLineComments

func MustFormatEndLineComments(comments []*parser.Comment, indent string) string

func MustFormatEnum

func MustFormatEnum(enum *parser.Enum) string

func MustFormatEnumValue

func MustFormatEnumValue(enumValue *parser.EnumValue, indent string) string

TODO(jpf): comments

func MustFormatEnumValues

func MustFormatEnumValues(values []*parser.EnumValue, indent string) string

func MustFormatException

func MustFormatException(excep *parser.Exception) string

func MustFormatField

func MustFormatField(field *parser.Field, space string, indent string) string

func MustFormatFieldType

func MustFormatFieldType(ft *parser.FieldType) string

func MustFormatFields

func MustFormatFields(fields []*parser.Field, indent string) string

func MustFormatFunction

func MustFormatFunction(fn *parser.Function, indent string) string

func MustFormatFunctions

func MustFormatFunctions(fns []*parser.Function, indent string) string

func MustFormatIdentifier

func MustFormatIdentifier(id *parser.Identifier) string

func MustFormatInclude

func MustFormatInclude(inc *parser.Include) string

func MustFormatKeyword

func MustFormatKeyword(kw parser.Keyword) string

func MustFormatLiteral

func MustFormatLiteral(l *parser.Literal) string

func MustFormatNamespace

func MustFormatNamespace(ns *parser.Namespace) string

func MustFormatOneLineFields

func MustFormatOneLineFields(fields []*parser.Field) string

func MustFormatService

func MustFormatService(svc *parser.Service) string

func MustFormatStruct

func MustFormatStruct(st *parser.Struct) string

func MustFormatThrows

func MustFormatThrows(throws *parser.Throws) string

func MustFormatTypeName

func MustFormatTypeName(tn *parser.TypeName) string

func MustFormatTypedef

func MustFormatTypedef(td *parser.Typedef) string

func MustFormatUnion

func MustFormatUnion(union *parser.Union) string

Types

type ConstFormatter

type ConstFormatter struct {
	Comments        string
	Const           string
	Type            string
	Name            string
	Annotations     string
	Equal           string
	Value           string
	ListSeparator   string
	EndLineComments string
}

type EnumFormatter

type EnumFormatter struct {
	Comments        string
	Enum            string
	Identifier      string
	LCUR            string
	EnumValues      string
	RCUR            string
	Annotations     string
	EndLineComments string
}

type ExceptionFormatter

type ExceptionFormatter struct {
	Comments        string
	Exception       string
	Identifier      string
	LCUR            string
	Fields          string
	RCUR            string
	Annotations     string
	EndLineComments string
}

type FunctionFormatter

type FunctionFormatter struct {
	Oneway          string
	FunctionType    string
	Identifier      string
	LPAR            string
	Args            string
	RPAR            string
	Throws          string
	Annotations     string
	ListSeparator   string
	EndLineComments string
}

type IncludeFormatter

type IncludeFormatter struct {
	Comments        string
	Include         string
	Path            string
	EndLineComments string
}

type NamespaceFormatter

type NamespaceFormatter struct {
	Comments        string
	Namespace       string
	Language        string
	Name            string
	Annotations     string
	EndLineComments string
}

type ServiceFormatter

type ServiceFormatter struct {
	Comments        string
	Service         string
	Identifier      string
	LCUR            string
	Functions       string
	RCUR            string
	Annotations     string
	EndLineComments string
}

type StructFormatter

type StructFormatter struct {
	Comments        string
	Struct          string
	Identifier      string
	LCUR            string
	Fields          string
	RCUR            string
	Annotations     string
	EndLineComments string
}

type ThrowFormatter

type ThrowFormatter struct {
	Throw  string
	LPAR   string
	Fields string
	RPAR   string
}

type TypedefFormatter

type TypedefFormatter struct {
	Comments        string
	Typedef         string
	Type            string
	Name            string
	Annotations     string
	EndLineComments string
}

type UnionFormatter

type UnionFormatter struct {
	Comments        string
	Union           string
	Identifier      string
	LCUR            string
	Fields          string
	RCUR            string
	Annotations     string
	EndLineComments string
}

Jump to

Keyboard shortcuts

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