javascript

package
v0.0.0-...-b8e9622 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package javascript parses .js / .jsx / .mjs / .cjs source files.

Implementation note: TypeScript is a syntactic superset of JavaScript, and tree-sitter-typescript ships both the TS and TSX grammars. We therefore delegate parsing to internal/parse/typescript so plain JS goes through the TS grammar (which happily accepts type-free input) and JSX goes through the TSX grammar — same span set, no extra dependency, no grammar drift between the two adapters.

The package exists as its own seam so discover/builder can tag JS files with Language="javascript" and a future native tree-sitter JavaScript grammar swap touches one file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser implements parse.Parser for JavaScript family extensions.

func New

func New() *Parser

New returns a stateless JS parser. Cheap to construct.

func (*Parser) Language

func (p *Parser) Language() string

Language returns the tag stored on each Chunk produced from a JS file. The discover layer assigns the same tag based on extension; this method is what parse.Parser callers ask when they need the language name as a string.

func (*Parser) Parse

func (p *Parser) Parse(file string, src []byte) ([]cparse.SymbolSpan, error)

Parse delegates to the TS parser. The TS adapter inspects the file extension to pick TS vs TSX grammar, and we already taught it to route .jsx through TSX — so .js / .mjs / .cjs end up on the TS grammar and .jsx on the TSX grammar, both with the same span extraction logic.

Jump to

Keyboard shortcuts

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