writeback

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatBuffer added in v0.2.0

func FormatBuffer(content []byte, filePath string) []byte

FormatBuffer formats source code in-memory based on file extension. Go files use gofumpt; HCL/Terraform files use hclwrite.Format. Python files use ruff (preferred) or black. TypeScript/JavaScript files use prettier. Returns the formatted buffer, or the original buffer unchanged if the file type has no formatter or formatting fails.

func LanguageForPath added in v0.2.0

func LanguageForPath(filePath string) *sitter.Language

LanguageForPath maps file extensions to tree-sitter languages. Single source of truth — used by Validate, ASTErrors, and ingest.ReExtractContext.

func Splice

func Splice(origin graph.SourceOrigin, newContent []byte) error

Splice replaces the byte range identified by origin with newContent in the source file. The write is atomic: content is written to a temp file first, then renamed.

func Validate added in v0.2.0

func Validate(content []byte, filePath string) error

Validate parses content with tree-sitter and returns an error if the AST contains syntax errors. Files with no known tree-sitter language pass through without validation (returns nil).

Types

type ValidationError added in v0.2.0

type ValidationError struct {
	FilePath string
	Line     uint32 // 0-indexed
	Column   uint32 // 0-indexed
	Message  string
}

ValidationError contains structured information about a syntax error.

func ASTErrors added in v0.2.0

func ASTErrors(content []byte, filePath string) []ValidationError

ASTErrors returns all ERROR node locations in the content for diagnostic reporting. Returns nil if no errors or unknown language.

func (*ValidationError) Error added in v0.2.0

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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