Documentation
¶
Overview ¶
Package tsextract is the per-language tree-sitter extraction provider for TypeScript and JavaScript. A single provider serves both languages per CONTEXT.md Claude's Discretion — the syntax overlap is large and TS-only constructs are captured via query alternation rather than two providers.
Provider claims .ts, .tsx, .js, .jsx, .mjs, .cjs. Internally the provider holds two compiled queries (typescript and tsx grammars) and dispatches based on file extension. Pure JS files run through the typescript grammar — TypeScript is a strict syntactic superset of JavaScript so this is safe (TS-only constructs simply don't appear in .js source).
Index ¶
- func NewProvider(grammars *treesitter.GrammarRegistry) extract.Provider
- type Provider
- func (p *Provider) Extensions() []string
- func (p *Provider) Extract(ctx context.Context, source []byte, file extract.SourceFile) (*extract.ExtractedFile, error)
- func (p *Provider) Language() string
- func (p *Provider) Queries() string
- func (p *Provider) SupportsLSPEnrichment() bool
- func (p *Provider) TreeSitterLanguage() *tree_sitter.Language
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewProvider ¶
func NewProvider(grammars *treesitter.GrammarRegistry) extract.Provider
NewProvider compiles the embedded queries against both the typescript and tsx grammars. Panics on missing grammar or query-compile failure.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is the concrete TS+JS extraction provider.
func (*Provider) Extensions ¶
func (*Provider) Extract ¶
func (p *Provider) Extract(ctx context.Context, source []byte, file extract.SourceFile) (*extract.ExtractedFile, error)
Extract parses source bytes using the appropriate grammar (tsx for .tsx / .jsx, typescript otherwise) and returns an ExtractedFile.
func (*Provider) SupportsLSPEnrichment ¶
func (*Provider) TreeSitterLanguage ¶
func (p *Provider) TreeSitterLanguage() *tree_sitter.Language