Documentation
¶
Overview ¶
Package validate exposes tree-sitter syntax validation for external consumers.
This is the public API for mache's AST validation. It supports Go, Python, JavaScript, TypeScript, SQL, HCL, YAML, and Rust via tree-sitter grammars.
Usage:
err := validate.File("path/to/file.go")
errors := validate.FileErrors("path/to/file.go")
err := validate.Content([]byte("package main"), "main.go")
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Content ¶
Content parses content with tree-sitter for the language inferred from filePath's extension. Returns nil if the AST is clean or the language is unknown (pass-through).
func SupportedExtension ¶
SupportedExtension returns true if the file extension is recognized by the tree-sitter grammar set.
Types ¶
type ValidationError ¶
type ValidationError = writeback.ValidationError
ValidationError contains structured information about a syntax error.
func ContentErrors ¶
func ContentErrors(content []byte, filePath string) []ValidationError
ContentErrors returns all AST error locations for diagnostic reporting. Returns nil if no errors or unknown language.
func FileErrors ¶
func FileErrors(filePath string) []ValidationError
FileErrors reads a file from disk and returns all AST error locations.