lang

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeLineCommenter

func MakeLineCommenter(commentMarker string) core.Commenter

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

func PrintNodes

func PrintNodes(n map[string]*sitter.Node) string

func WriteAST

func WriteAST(node *sitter.Node, out io.Writer) error

Types

type ASTWriter

type ASTWriter struct {
	// contains filtered or unexported fields
}

func (*ASTWriter) Err

func (w *ASTWriter) Err() error

func (*ASTWriter) WriteAST

func (w *ASTWriter) WriteAST()

type CommentPreprocessor

type CommentPreprocessor func(comment string) string

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

type FindAllCommentBlocksExpected struct {
	Comment string
	Node    string
}

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()
}

Jump to

Keyboard shortcuts

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