Documentation ¶
Index ¶
- func MakeLineCommenter(commentMarker string) core.Commenter
- func NewCapabilityFinder(sitterQuery string, preprocessor CommentPreprocessor) core.CapabilityFinder
- func PrintCapabilities(caps core.AnnotationMap, out io.Writer) error
- func PrintNodes(n map[string]*sitter.Node) string
- func WriteAST(node *sitter.Node, out io.Writer) error
- type ASTWriter
- type CommentPreprocessor
- type FindAllCommentBlocksExpected
- type FindAllCommentBlocksTestCase
- type TestRunner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeLineCommenter ¶
func NewCapabilityFinder ¶
func NewCapabilityFinder(sitterQuery string, preprocessor CommentPreprocessor) core.CapabilityFinder
NewCapabilityFinder creates a struct that you can use to find capabilities (annotations) within a source file.
To do this, you provide a `sitterQuery` that looks for comments nodes that contain the `klotho::` annotations, as well as a preprocessor that runs over each of those nodes.
If a source file contains multiple comment nodes in a row (as identified by having equal `.Type()`s), those comments will be preprocessed individually, but then merged into a single annotation.
func PrintCapabilities ¶
func PrintCapabilities(caps core.AnnotationMap, out io.Writer) error
Types ¶
type CommentPreprocessor ¶
CommentPreprocessor edits a given comment string.
Its input is the current comment string. Its output is what the comment string should be instead; this can just be the input string, if no edits are necessary. Empty strings are *not* treated specially: they just look like an empty comment.
func CompositePreprocessor ¶
func CompositePreprocessor(preprocessors ...CommentPreprocessor) CommentPreprocessor
func RegexpRemovePreprocessor ¶
func RegexpRemovePreprocessor(pattern string) CommentPreprocessor
RegexpRemovePreprocessor returns a preprocessor powered by a regexp that removes all matches.
The comment will be amended via `regexp.MustCompile(pattern).ReplaceAllString(comment, "")`. The preprocessor will always combine comment blocks.
type FindAllCommentBlocksExpected ¶
func FindAllCommentBlocksForTest ¶
func FindAllCommentBlocksForTest(language core.SourceLanguage, source string) ([]FindAllCommentBlocksExpected, error)
type FindAllCommentBlocksTestCase ¶
type FindAllCommentBlocksTestCase struct { Name string Source string Want []FindAllCommentBlocksExpected }
type TestRunner ¶
type TestRunner interface {
Run()
}