Documentation
¶
Overview ¶
Package tsanalyzer implements the lang.Language interface for TypeScript (and .tsx). It is blank-imported from cmd/diffguard/main.go so TypeScript gets registered at process start.
One file per concern, mirroring the Go and Rust analyzers:
- tsanalyzer.go -- Language + init()/Register + detector
- parse.go -- tree-sitter setup, CST helpers, grammar pick
- sizes.go -- FunctionExtractor
- complexity.go -- ComplexityCalculator + ComplexityScorer
- deps.go -- ImportResolver
- mutation_generate.go-- MutantGenerator
- mutation_apply.go -- MutantApplier
- mutation_annotate.go-- AnnotationScanner
- testrunner.go -- TestRunner (wraps vitest/jest/npm test)
Unlike the Go analyzer, TypeScript requires two tree-sitter grammars: one for `.ts` (typescript) and one for `.tsx` (tsx). The two grammars are nearly identical for our purposes (node kinds like `if_statement`, `function_declaration`, etc. are shared) but the parser input has to match the extension — the tsx grammar accepts JSX syntax, the plain typescript grammar rejects it.
Index ¶
- type Language
- func (*Language) AnnotationScanner() lang.AnnotationScanner
- func (*Language) ComplexityCalculator() lang.ComplexityCalculator
- func (*Language) ComplexityScorer() lang.ComplexityScorer
- func (*Language) DeadCodeDetector() lang.DeadCodeDetector
- func (*Language) FileFilter() lang.FileFilter
- func (*Language) FunctionExtractor() lang.FunctionExtractor
- func (*Language) ImportResolver() lang.ImportResolver
- func (*Language) MutantApplier() lang.MutantApplier
- func (*Language) MutantGenerator() lang.MutantGenerator
- func (*Language) Name() string
- func (*Language) TestRunner() lang.TestRunner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Language ¶
type Language struct{}
Language is the TypeScript implementation of lang.Language. Like the Go and Rust analyzers, it holds no state; sub-component impls are stateless.
func (*Language) AnnotationScanner ¶
func (*Language) AnnotationScanner() lang.AnnotationScanner
func (*Language) ComplexityCalculator ¶
func (*Language) ComplexityCalculator() lang.ComplexityCalculator
Sub-component accessors. Stateless impls return fresh zero-value structs.
func (*Language) ComplexityScorer ¶
func (*Language) ComplexityScorer() lang.ComplexityScorer
func (*Language) DeadCodeDetector ¶
func (*Language) DeadCodeDetector() lang.DeadCodeDetector
func (*Language) FileFilter ¶
func (*Language) FileFilter() lang.FileFilter
FileFilter returns the TypeScript-specific file selection rules used by the diff parser: .ts and .tsx extensions; anything matching our test suffix list OR sitting under a __tests__ / __mocks__ segment counts as a test file. We deliberately exclude .js / .jsx / .mjs / .cjs — JS-only repos are out of scope for this analyzer (the detector backs that choice up by only firing when at least one .ts/.tsx file is present).
func (*Language) FunctionExtractor ¶
func (*Language) FunctionExtractor() lang.FunctionExtractor
func (*Language) ImportResolver ¶
func (*Language) ImportResolver() lang.ImportResolver
func (*Language) MutantApplier ¶
func (*Language) MutantApplier() lang.MutantApplier
func (*Language) MutantGenerator ¶
func (*Language) MutantGenerator() lang.MutantGenerator
func (*Language) Name ¶
Name returns the canonical language identifier used by the registry and by report section suffixes.
func (*Language) TestRunner ¶
func (*Language) TestRunner() lang.TestRunner