code

package
v3.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	Text   string
	Source string
	Line   int
	Offset int
	Scope  string
	// Strip records, for each line of Text, how many bytes were taken off the
	// front of the matching Source line. An alert's column is meaningful in
	// Text; putting it back in Source means adding this.
	//
	// Empty for a comment that was never dedented, in which case the caller
	// falls back to measuring the source line itself.
	//
	// Not serialised: this is bookkeeping for putting an alert back where it
	// came from, not part of what a comment is.
	Strip []int `json:"-"`
}

Comment represents an in-code comment (line or block).

func GetComments

func GetComments(source []byte, lang *Language) ([]Comment, error)

GetComments returns all comments in the given source code.

func (Comment) StripAt added in v3.17.0

func (c Comment) StripAt(line int) (int, bool)

StripAt returns what came off the front of a line, 1-based as alerts are.

type Language

type Language struct {
	Delims *regexp.Regexp
	Parser *sitter.Language
	// Prefix matches a block comment's per-line decoration -- the ` *` that
	// starts each line of a JSDoc or Javadoc block.
	//
	// This is not the same thing as Cutset. Decoration is noise of a known
	// width that has to come off for the body to be valid markup; indentation
	// is meaningful and only its common part comes off. Conflating them is why
	// a cutset of " *" cannot work: `*` is both the decoration and Markdown's
	// list and emphasis marker, so a cutset wide enough to remove the noise
	// also eats a list.
	//
	// The match is blanked rather than deleted, which keeps every column where
	// it was and leaves the dedent below to remove the whitespace it becomes.
	Prefix  *regexp.Regexp
	Queries []core.Scope
	Cutset  string
	Padding padding
}

Language represents a supported programming language.

NOTE: What about haskell, less, perl, php, powershell, r, sass, swift?

func C

func C() *Language

func CSS

func CSS() *Language

func Cpp

func Cpp() *Language

func GetLanguageFromExt

func GetLanguageFromExt(ext string) (*Language, error)

GetLanguageFromExt returns a Language based on the given file extension.

func Go

func Go() *Language

func Java added in v3.13.0

func Java() *Language

func JavaScript

func JavaScript() *Language

func Julia added in v3.7.1

func Julia() *Language

func Protobuf

func Protobuf() *Language

func Python

func Python() *Language

func Ruby

func Ruby() *Language

func Rust

func Rust() *Language

func Tsx

func Tsx() *Language

func TypeScript

func TypeScript() *Language

func YAML

func YAML() *Language

type QueryEngine

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

func NewQueryEngine

func NewQueryEngine(tree *sitter.Tree, lang *Language) *QueryEngine

Jump to

Keyboard shortcuts

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