language

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package language adapts each supported source language to a common shape: its file extensions, its tree-sitter grammar, and the small set of node kinds the parser and taint walker need to recognize (a function, a call, an assignment, a string literal)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUnsupportedSource

func IsUnsupportedSource(ext string) bool

IsUnsupportedSource reports whether lowercased ext is a known source-language extension whose missing adapter creates a coverage gap. Unrelated extensions also lack adapters but return false.

Types

type Adapter

type Adapter struct {
	ID         ID
	Extensions []string // includes the leading dot
	Grammar    Grammar
	// contains filtered or unexported fields
}

Adapter is everything the source pipeline needs for one language

func All

func All() []*Adapter

All returns every supported language's adapter, sorted by ID. Every adapter is always returned, even one whose grammar fails to load: callers must report that as a coverage skip, never drop the language silently.

func ByID

func ByID(id ID) *Adapter

ByID returns the adapter for id, or nil

func ForExt

func ForExt(ext string) *Adapter

ForExt returns the adapter that owns extension ext (including the dot), or nil if no language claims it

func (*Adapter) HasQuery

func (a *Adapter) HasQuery(name string) bool

HasQuery reports whether a query file exists for this language, for optional queries such as decorators

func (*Adapter) Language

func (a *Adapter) Language() (lang *sitter.Language, err error)

Language returns the compiled tree-sitter language, loading it on first use. A grammar that fails to load (or panics, which the C bindings can do on a malformed pointer) reports err instead of taking the process down.

func (*Adapter) Query

func (a *Adapter) Query(name string) (*sitter.Query, error)

Query compiles (and caches) the named query file for this language. name is the file's basename without extension, for example "symbols"

type Grammar

type Grammar struct {
	FunctionKinds []string // function/method definitions
	ClassKinds    []string // class definitions; empty for languages with none
	CallKinds     []string // call-shaped expressions (includes constructors)
	AssignKinds   []string // assignment and declaration-with-initializer nodes
	StringKinds   []string // string literal node kinds
	MemberKinds   []string // member/attribute/field access expressions
	ReturnKinds   []string
	ForKinds      []string // loop constructs, used for "registration in a loop"
}

Grammar is the node-kind vocabulary the parser and the taint walker use to recognize a construct without caring which grammar produced it

type ID

type ID string

ID names one of the supported languages. It is also the query directory name under internal/source/queries.

const (
	Go         ID = "go"
	Python     ID = "python"
	JavaScript ID = "javascript"
	TypeScript ID = "typescript"
	Java       ID = "java"
	Rust       ID = "rust"
)

Jump to

Keyboard shortcuts

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