Documentation
¶
Index ¶
Constants ¶
const CallQueries = `` /* 159-byte string literal not displayed */
CallQueries captures direct function and method call sites in JavaScript. Matches:
- plain calls: foo()
- method/selector calls: obj.method()
const ImportQueries = `
(import_statement
source: (string
(string_fragment) @path)) @import
`
ImportQueries contains tree-sitter query patterns for JavaScript import extraction. Matches import_statement nodes:
- side-effect import: import 'mod' → path="mod", alias=""
- default import: import X from 'mod' → path="mod", alias=""
- named imports: import { A, B } from 'mod' → path="mod", alias=""
- namespace import: import * as ns from 'mod' → path="mod", alias=""
Each match yields only a @path capture (the string_fragment of the module specifier). Aliases (the locally-bound name) are not captured; alias is always "". To add alias support, extend this query with @alias captures per import form.
const JSXCallQueries = CallQueries + `
(jsx_opening_element
name: (identifier) @callee) @call
(jsx_self_closing_element
name: (identifier) @callee) @call
`
JSXCallQueries extends CallQueries with JSX element patterns for JSX files. Matches everything CallQueries matches, plus:
- JSX opening elements: <MyComponent prop={x}>
- JSX self-closing elements: <MyComponent />
Note: lowercase-initial JSX identifiers (native HTML tags such as <div>, <span>, <input>) are filtered out at runtime in runCallQuery so that only user-defined component names (PascalCase / uppercase-initial) are recorded as call references.
These patterns are intentionally separated from CallQueries because jsx_opening_element and jsx_self_closing_element are only valid node types in the JSX-enabled JavaScript grammar — compiling them against the plain JavaScript grammar may produce a query compilation error depending on the grammar version.
const Queries = `` /* 715-byte string literal not displayed */
Queries contains tree-sitter query patterns for JavaScript symbol extraction. Covers: function declarations, generator functions (function* foo), var/let/const assignments, class declarations, methods (including static/async), object shorthand methods, export default function/class, and module.exports.x = function() assignments.
const RefQueries = `` /* 137-byte string literal not displayed */
RefQueries captures identifiers used as values (not called directly) in:
- object/array literal properties: { handler: myFn }
- variable declarators: const f = myFn / let f = myFn / var f = myFn
- assignment expressions: f = myFn
Combined with CallQueries in ExtractCalls so functions passed as values are recorded as "used" and do not appear as dead code.
Variables ¶
var Extensions = []string{".js", ".jsx", ".mjs", ".cjs"}
Extensions lists all file extensions handled by the JavaScript grammar.
var Language = tree_sitter.NewLanguage(tree_sitter_javascript.Language())
Language is the single shared tree-sitter language instance for JavaScript. It is allocated once and reused across all extensions.
Functions ¶
This section is empty.
Types ¶
This section is empty.