Documentation ¶
Index ¶
- func CommentGroupToJSON(group *ast.CommentGroup) json.RawMessage
- func CommentToJSON(c *ast.Comment) json.RawMessage
- func ImportDeclarationsToJSON(fset *token.FileSet, decls []ImportDeclaration) json.RawMessage
- func ImportDelarationToJSON(fset *token.FileSet, id ImportDeclaration) json.RawMessage
- func ImportGroupToJSON(fset *token.FileSet, isg ImportGroup) json.RawMessage
- func MergeDocComments(groups []*ast.CommentGroup) *ast.CommentGroup
- type ImportDeclaration
- type ImportGroup
- type ImportTransform
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommentGroupToJSON ¶
func CommentGroupToJSON(group *ast.CommentGroup) json.RawMessage
func CommentToJSON ¶
func CommentToJSON(c *ast.Comment) json.RawMessage
func ImportDeclarationsToJSON ¶
func ImportDeclarationsToJSON(fset *token.FileSet, decls []ImportDeclaration) json.RawMessage
func ImportDelarationToJSON ¶
func ImportDelarationToJSON(fset *token.FileSet, id ImportDeclaration) json.RawMessage
func ImportGroupToJSON ¶
func ImportGroupToJSON(fset *token.FileSet, isg ImportGroup) json.RawMessage
func MergeDocComments ¶
func MergeDocComments(groups []*ast.CommentGroup) *ast.CommentGroup
MergeDocComments returns multiple doc comment groups merged into one.
Types ¶
type ImportDeclaration ¶
type ImportDeclaration struct { // LeadingComments comments that are floating above this declaration, // in the middle of import blocks. LeadingComments []*ast.CommentGroup // DetachedComments are comments that are floating inside this declaration // unattached to specs (typically after the last import spec in a group). DetachedComments []*ast.CommentGroup // Doc is the doc comment for this import declaration. Doc *ast.CommentGroup // ImportGroups contains the list of underlying ast.ImportSpec-s. ImportGroups []ImportGroup }
ImportDeclaration represents a single import block. (i.e. the contents of the `import` statement)
func MergeDeclarations ¶
func MergeDeclarations(decls []ImportDeclaration) ImportDeclaration
MergeDeclarations returns two or more ImportDeclarations merged together by appending import groups and comment sections together.
type ImportGroup ¶
type ImportGroup struct { Doc *ast.CommentGroup Specs []*ast.ImportSpec }
ImportGroup maps to set of consecutive import specs delimited by whitespace and potentially having a doc comment.
This type is the powerhouse of this package, allowing easy operation on sets of imports, delimited by whitespace.
Contained within an ImportDeclaration.
func MergeGroups ¶
func MergeGroups(groups []ImportGroup) ImportGroup
MergeGroups returns two or more ImportGroups merged together by appending their import specs and comments together and.
type ImportTransform ¶
type ImportTransform func(decls []ImportDeclaration) []ImportDeclaration
ImportTransform is a function that allows reordering merging and splitting existing []ImportDeclaration obtained from source.