@kreuzberg/tree-sitter-language-pack 1.9.0-rc.21 → 1.9.0-rc.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +343 -343
- package/package.json +9 -9
- package/ts-pack-core-node.darwin-arm64.node +0 -0
- package/ts-pack-core-node.darwin-x64.node +0 -0
- package/ts-pack-core-node.linux-arm64-gnu.node +0 -0
- package/ts-pack-core-node.linux-x64-gnu.node +0 -0
- package/ts-pack-core-node.win32-arm64-msvc.node +0 -0
- package/ts-pack-core-node.win32-x64-msvc.node +0 -0
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This file is auto-generated by alef — DO NOT EDIT.
|
|
2
|
-
// alef:hash:
|
|
2
|
+
// alef:hash:26098882d3a3a5372a6c2cbd4117bdc84a45bcf67208d6d26e0c28fe239748f2
|
|
3
3
|
// To regenerate: alef generate
|
|
4
4
|
// To verify freshness: alef verify --exit-code
|
|
5
5
|
/* eslint-disable */
|
|
@@ -217,41 +217,41 @@ export declare function init(config?: PackConfig | undefined | null): void;
|
|
|
217
217
|
|
|
218
218
|
/** A byte range — start (inclusive) to end (exclusive). */
|
|
219
219
|
export interface ByteRange {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
220
|
+
/** Inclusive start byte offset. */
|
|
221
|
+
readonly start: number
|
|
222
|
+
/** Exclusive end byte offset. */
|
|
223
|
+
readonly end: number
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
/** Metadata for a single chunk of source code. */
|
|
227
227
|
export interface ChunkContext {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
228
|
+
readonly language?: string
|
|
229
|
+
readonly chunkIndex?: number
|
|
230
|
+
readonly totalChunks?: number
|
|
231
|
+
readonly nodeTypes?: Array<string>
|
|
232
|
+
readonly contextPath?: Array<string>
|
|
233
|
+
readonly symbolsDefined?: Array<string>
|
|
234
|
+
readonly comments?: Array<CommentInfo>
|
|
235
|
+
readonly docstrings?: Array<DocstringInfo>
|
|
236
|
+
readonly hasErrorNodes?: boolean
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
/** A chunk of source code with rich metadata. */
|
|
240
240
|
export interface CodeChunk {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
241
|
+
readonly content?: string
|
|
242
|
+
readonly startByte?: number
|
|
243
|
+
readonly endByte?: number
|
|
244
|
+
readonly startLine?: number
|
|
245
|
+
readonly endLine?: number
|
|
246
|
+
readonly metadata?: ChunkContext
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
/** A comment extracted from source code. */
|
|
250
250
|
export interface CommentInfo {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
251
|
+
readonly text?: string
|
|
252
|
+
readonly kind?: CommentKind
|
|
253
|
+
readonly span?: Span
|
|
254
|
+
readonly associatedNode?: string
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
/**
|
|
@@ -261,16 +261,16 @@ export interface CommentInfo {
|
|
|
261
261
|
* and documentation comments.
|
|
262
262
|
*/
|
|
263
263
|
export declare enum CommentKind {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
264
|
+
Line = "Line",
|
|
265
|
+
Block = "Block",
|
|
266
|
+
Doc = "Doc",
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
/** A diagnostic (syntax error, missing node, etc.) from parsing. */
|
|
270
270
|
export interface Diagnostic {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
271
|
+
readonly message?: string
|
|
272
|
+
readonly severity?: DiagnosticSeverity
|
|
273
|
+
readonly span?: Span
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
/**
|
|
@@ -280,16 +280,16 @@ export interface Diagnostic {
|
|
|
280
280
|
* found in the syntax tree.
|
|
281
281
|
*/
|
|
282
282
|
export declare enum DiagnosticSeverity {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
283
|
+
Error = "Error",
|
|
284
|
+
Warning = "Warning",
|
|
285
|
+
Info = "Info",
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
/** A section within a docstring (e.g., Args, Returns, Raises). */
|
|
289
289
|
export interface DocSection {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
290
|
+
readonly kind?: string
|
|
291
|
+
readonly name?: string
|
|
292
|
+
readonly description?: string
|
|
293
293
|
}
|
|
294
294
|
|
|
295
295
|
/**
|
|
@@ -299,58 +299,58 @@ export interface DocSection {
|
|
|
299
299
|
* (e.g., Python triple-quoted strings, JSDoc, Rustdoc `///` comments).
|
|
300
300
|
*/
|
|
301
301
|
export declare enum DocstringFormat {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
302
|
+
PythonTripleQuote = "PythonTripleQuote",
|
|
303
|
+
JSDoc = "JSDoc",
|
|
304
|
+
Rustdoc = "Rustdoc",
|
|
305
|
+
GoDoc = "GoDoc",
|
|
306
|
+
JavaDoc = "JavaDoc",
|
|
307
|
+
Other = "Other",
|
|
308
308
|
}
|
|
309
309
|
|
|
310
310
|
/** A docstring extracted from source code. */
|
|
311
311
|
export interface DocstringInfo {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
312
|
+
readonly text?: string
|
|
313
|
+
readonly format?: DocstringFormat
|
|
314
|
+
readonly span?: Span
|
|
315
|
+
readonly associatedItem?: string
|
|
316
|
+
readonly parsedSections?: Array<DocSection>
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
/** Manages downloading and caching of pre-built parser shared libraries. */
|
|
320
320
|
export declare class DownloadManager {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
321
|
+
/** Create a new download manager for the given version. */
|
|
322
|
+
static new(version: string): DownloadManager
|
|
323
|
+
/** List languages that are already downloaded and cached. */
|
|
324
|
+
installedLanguages(): Array<string>
|
|
325
|
+
/**
|
|
326
|
+
* Download the platform bundle and extract every library file it contains.
|
|
327
|
+
*
|
|
328
|
+
* Unlike [`ensure_languages`], this does not check the manifest language list
|
|
329
|
+
* against archive contents — it simply extracts all `.so`/`.dylib`/`.dll` files
|
|
330
|
+
* from the bundle. Languages in the manifest that are missing from the archive
|
|
331
|
+
* are silently ignored rather than returning an error.
|
|
332
|
+
*
|
|
333
|
+
* Returns the number of library files extracted (including those already cached).
|
|
334
|
+
*/
|
|
335
|
+
downloadAllBestEffort(): number
|
|
336
|
+
/**
|
|
337
|
+
* Remove all cached parser libraries.
|
|
338
|
+
*
|
|
339
|
+
* Acquires the cross-process lock so `clean_cache` cannot race a concurrent
|
|
340
|
+
* downloader (avoids Windows sharing-violation errors against an in-flight
|
|
341
|
+
* bundle write). The `.download.lock` file itself is **not** removed — it is
|
|
342
|
+
* permanent infrastructure; deleting it could allow a concurrent process that
|
|
343
|
+
* already opened the file to continue holding a stale lock handle while a new
|
|
344
|
+
* process opens a fresh inode, breaking the mutual-exclusion guarantee.
|
|
345
|
+
*/
|
|
346
|
+
cleanCache(): void
|
|
347
347
|
}
|
|
348
348
|
|
|
349
349
|
/** An export statement extracted from source code. */
|
|
350
350
|
export interface ExportInfo {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
351
|
+
readonly name?: string
|
|
352
|
+
readonly kind?: ExportKind
|
|
353
|
+
readonly span?: Span
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
/**
|
|
@@ -359,30 +359,30 @@ export interface ExportInfo {
|
|
|
359
359
|
* Covers named exports, default exports, and re-exports from other modules.
|
|
360
360
|
*/
|
|
361
361
|
export declare enum ExportKind {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
362
|
+
Named = "Named",
|
|
363
|
+
Default = "Default",
|
|
364
|
+
ReExport = "ReExport",
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
/** Aggregate metrics for a source file. */
|
|
368
368
|
export interface FileMetrics {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
369
|
+
readonly totalLines?: number
|
|
370
|
+
readonly codeLines?: number
|
|
371
|
+
readonly commentLines?: number
|
|
372
|
+
readonly blankLines?: number
|
|
373
|
+
readonly totalBytes?: number
|
|
374
|
+
readonly nodeCount?: number
|
|
375
|
+
readonly errorCount?: number
|
|
376
|
+
readonly maxDepth?: number
|
|
377
377
|
}
|
|
378
378
|
|
|
379
379
|
/** An import statement extracted from source code. */
|
|
380
380
|
export interface ImportInfo {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
381
|
+
readonly source?: string
|
|
382
|
+
readonly items?: Array<string>
|
|
383
|
+
readonly alias?: string
|
|
384
|
+
readonly isWildcard?: boolean
|
|
385
|
+
readonly span?: Span
|
|
386
386
|
}
|
|
387
387
|
|
|
388
388
|
/**
|
|
@@ -394,65 +394,65 @@ export interface ImportInfo {
|
|
|
394
394
|
* (`get_language`, `available_languages`, etc.).
|
|
395
395
|
*/
|
|
396
396
|
export declare class LanguageRegistry {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
397
|
+
/**
|
|
398
|
+
* Create a new registry populated with all statically compiled languages.
|
|
399
|
+
*
|
|
400
|
+
* When the `dynamic-loading` feature is enabled, the registry also knows
|
|
401
|
+
* about dynamically loadable grammars and will load them on demand.
|
|
402
|
+
*/
|
|
403
|
+
static new(): LanguageRegistry
|
|
404
|
+
/**
|
|
405
|
+
* Get a tree-sitter [`Language`] by name.
|
|
406
|
+
*
|
|
407
|
+
* Resolves aliases (e.g., `"shell"` -> `"bash"`, `"makefile"` -> `"make"`),
|
|
408
|
+
* then looks up the language in the static table. When the `dynamic-loading`
|
|
409
|
+
* feature is enabled, falls back to loading a shared library on demand.
|
|
410
|
+
* @throws Returns [`Error::LanguageNotFound`] if the name (after alias resolution)
|
|
411
|
+
* does not match any known grammar.
|
|
412
|
+
*/
|
|
413
|
+
getLanguage(name: string): Language
|
|
414
|
+
/**
|
|
415
|
+
* List all available language names, sorted and deduplicated.
|
|
416
|
+
*
|
|
417
|
+
* Includes statically compiled languages, dynamically loadable languages
|
|
418
|
+
* (if the `dynamic-loading` feature is enabled), and all configured aliases.
|
|
419
|
+
*/
|
|
420
|
+
availableLanguages(): Array<string>
|
|
421
|
+
/**
|
|
422
|
+
* Check whether a parser is statically compiled into this build.
|
|
423
|
+
*
|
|
424
|
+
* Returns `true` only when the grammar was compiled in at build time
|
|
425
|
+
* (i.e. it appears in the `STATIC_LANGUAGES` table). This is independent
|
|
426
|
+
* of the extension-to-language mapping: `detect_language_from_extension`
|
|
427
|
+
* consults the static ext table for all 306 grammars regardless of which
|
|
428
|
+
* parsers are compiled in.
|
|
429
|
+
*
|
|
430
|
+
* Use this when you need to distinguish "we know the language name" from
|
|
431
|
+
* "we can actually parse files in that language right now".
|
|
432
|
+
*
|
|
433
|
+
* ```no_run
|
|
434
|
+
* use tree_sitter_language_pack::{detect_language_from_extension, LanguageRegistry};
|
|
435
|
+
*
|
|
436
|
+
* let registry = LanguageRegistry::new();
|
|
437
|
+
* // Extension detection uses the static table — independent of compiled parsers.
|
|
438
|
+
* let lang = detect_language_from_extension("feature"); // always returns Some("gherkin")
|
|
439
|
+
* // Parser availability depends on which grammars were compiled in.
|
|
440
|
+
* let can_parse = lang.map(|name| registry.has_parser(name)).unwrap_or(false);
|
|
441
|
+
* ```
|
|
442
|
+
*/
|
|
443
|
+
hasParser(name: string): boolean
|
|
444
|
+
/**
|
|
445
|
+
* Check whether a language is available by name or alias.
|
|
446
|
+
*
|
|
447
|
+
* Returns `true` if the language can be loaded, either from the static
|
|
448
|
+
* table or from a dynamic library on disk.
|
|
449
|
+
*/
|
|
450
|
+
hasLanguage(name: string): boolean
|
|
451
|
+
/** Return the total number of available languages (including aliases). */
|
|
452
|
+
languageCount(): number
|
|
453
|
+
/** Parse source code and extract file intelligence based on config in a single pass. */
|
|
454
|
+
process(source: string, config?: ProcessConfig | undefined | null): ProcessResult
|
|
455
|
+
static default(): LanguageRegistry
|
|
456
456
|
}
|
|
457
457
|
|
|
458
458
|
/**
|
|
@@ -462,58 +462,58 @@ export declare class LanguageRegistry {
|
|
|
462
462
|
* regardless of how the tree is moved or stored at the FFI boundary.
|
|
463
463
|
*/
|
|
464
464
|
export declare class Node {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
465
|
+
clone(): Node
|
|
466
|
+
/** Return the node's kind name (e.g. `"function_definition"`). */
|
|
467
|
+
kind(): string
|
|
468
|
+
/**
|
|
469
|
+
* Return the node's numeric kind ID.
|
|
470
|
+
*
|
|
471
|
+
* Tree-sitter assigns a stable `u16` ID to every node kind in a grammar
|
|
472
|
+
* (e.g. `"function_definition" → 42`). Comparing `kind_id()` is cheaper
|
|
473
|
+
* than comparing the string [`kind()`](Self::kind) in tight AST loops.
|
|
474
|
+
*/
|
|
475
|
+
kindId(): number
|
|
476
|
+
/** Return the inclusive start byte offset of this node. */
|
|
477
|
+
startByte(): number
|
|
478
|
+
/** Return the exclusive end byte offset of this node. */
|
|
479
|
+
endByte(): number
|
|
480
|
+
/**
|
|
481
|
+
* Return the node's byte range as a [`ByteRange`].
|
|
482
|
+
*
|
|
483
|
+
* Callers should slice their own source bytes — this is a zero-copy
|
|
484
|
+
* text accessor.
|
|
485
|
+
*/
|
|
486
|
+
byteRange(): ByteRange
|
|
487
|
+
/** Return the start [`Point`] (row, column). */
|
|
488
|
+
startPosition(): Point
|
|
489
|
+
/** Return the end [`Point`] (row, column). */
|
|
490
|
+
endPosition(): Point
|
|
491
|
+
/** True when this node is named (not punctuation/whitespace). */
|
|
492
|
+
isNamed(): boolean
|
|
493
|
+
/** True when this is an error node. */
|
|
494
|
+
isError(): boolean
|
|
495
|
+
/** True when this is a missing-token node. */
|
|
496
|
+
isMissing(): boolean
|
|
497
|
+
/** True when this is an "extra" node (e.g. a comment). */
|
|
498
|
+
isExtra(): boolean
|
|
499
|
+
/** True when this node or any descendant is an error. */
|
|
500
|
+
hasError(): boolean
|
|
501
|
+
/** Return this node's parent, if any. */
|
|
502
|
+
parent(): Node | null
|
|
503
|
+
/** Return the i-th child of this node, if any. */
|
|
504
|
+
child(index: number): Node | null
|
|
505
|
+
/** Total number of children (including unnamed). */
|
|
506
|
+
childCount(): number
|
|
507
|
+
/** Return the i-th named child of this node, if any. */
|
|
508
|
+
namedChild(index: number): Node | null
|
|
509
|
+
/** Number of named children of this node. */
|
|
510
|
+
namedChildCount(): number
|
|
511
|
+
/** Look up a child by its grammar-defined field name. */
|
|
512
|
+
childByFieldName(name: string): Node | null
|
|
513
|
+
/** Return the S-expression form of this node's subtree. */
|
|
514
|
+
toSexp(): string
|
|
515
|
+
/** Return a [`TreeCursor`] positioned at this node. */
|
|
516
|
+
walk(): TreeCursor
|
|
517
517
|
}
|
|
518
518
|
|
|
519
519
|
/**
|
|
@@ -524,63 +524,63 @@ export declare class Node {
|
|
|
524
524
|
* or passed as a dict/object from language bindings.
|
|
525
525
|
*/
|
|
526
526
|
export interface PackConfig {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
527
|
+
/**
|
|
528
|
+
* Override default cache directory.
|
|
529
|
+
*
|
|
530
|
+
* Default: `~/.cache/tree-sitter-language-pack/v{version}/libs/`
|
|
531
|
+
*/
|
|
532
|
+
readonly cacheDir?: string
|
|
533
|
+
/**
|
|
534
|
+
* Languages to pre-download on init.
|
|
535
|
+
*
|
|
536
|
+
* Each entry is a language name (e.g. `"python"`, `"rust"`).
|
|
537
|
+
*/
|
|
538
|
+
readonly languages?: Array<string>
|
|
539
|
+
/** Language groups to pre-download (e.g. `"web"`, `"systems"`, `"scripting"`). */
|
|
540
|
+
readonly groups?: Array<string>
|
|
541
541
|
}
|
|
542
542
|
|
|
543
543
|
/** A tree-sitter parser configured for one language at a time. */
|
|
544
544
|
export declare class Parser {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
545
|
+
/**
|
|
546
|
+
* Construct a new parser with no language set.
|
|
547
|
+
*
|
|
548
|
+
* Call [`Parser::set_language`] before parsing.
|
|
549
|
+
*/
|
|
550
|
+
static new(): Parser
|
|
551
|
+
/**
|
|
552
|
+
* Configure the parser to use the language identified by name (e.g. `"python"`).
|
|
553
|
+
*
|
|
554
|
+
* Resolves the language through the global registry — auto-downloading
|
|
555
|
+
* if necessary, when the `download` feature is enabled.
|
|
556
|
+
* @throws Returns [`Error::LanguageNotFound`] if the language is not recognized,
|
|
557
|
+
* or [`Error::ParserSetup`] if the language ABI is incompatible.
|
|
558
|
+
*/
|
|
559
|
+
setLanguage(name: string): void
|
|
560
|
+
/**
|
|
561
|
+
* Parse a UTF-8 source string. Returns `None` if parsing was cancelled
|
|
562
|
+
* or no language is set.
|
|
563
|
+
*/
|
|
564
|
+
parse(source: string): Tree | null
|
|
565
|
+
/**
|
|
566
|
+
* Parse a raw byte slice. Returns `None` if parsing was cancelled or
|
|
567
|
+
* no language is set.
|
|
568
|
+
*/
|
|
569
|
+
parseBytes(source: Uint8Array): Tree | null
|
|
570
|
+
/**
|
|
571
|
+
* Reset internal state. The next call to [`parse`](Self::parse) will
|
|
572
|
+
* not be incremental.
|
|
573
|
+
*/
|
|
574
|
+
reset(): void
|
|
575
|
+
static default(): Parser
|
|
576
576
|
}
|
|
577
577
|
|
|
578
578
|
/** A source position — row + column, zero-indexed. */
|
|
579
579
|
export interface Point {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
580
|
+
/** Zero-indexed row number. */
|
|
581
|
+
readonly row: number
|
|
582
|
+
/** Zero-indexed column number, in UTF-16 code units. */
|
|
583
|
+
readonly column: number
|
|
584
584
|
}
|
|
585
585
|
|
|
586
586
|
/**
|
|
@@ -589,24 +589,24 @@ export interface Point {
|
|
|
589
589
|
* Controls which analysis features are enabled and whether chunking is performed.
|
|
590
590
|
*/
|
|
591
591
|
export interface ProcessConfig {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
592
|
+
/** Language name (required). */
|
|
593
|
+
readonly language?: string
|
|
594
|
+
/** Extract structural items (functions, classes, etc.). Default: true. */
|
|
595
|
+
readonly structure?: boolean
|
|
596
|
+
/** Extract import statements. Default: true. */
|
|
597
|
+
readonly imports?: boolean
|
|
598
|
+
/** Extract export statements. Default: true. */
|
|
599
|
+
readonly exports?: boolean
|
|
600
|
+
/** Extract comments. Default: false. */
|
|
601
|
+
readonly comments?: boolean
|
|
602
|
+
/** Extract docstrings. Default: false. */
|
|
603
|
+
readonly docstrings?: boolean
|
|
604
|
+
/** Extract symbol definitions. Default: false. */
|
|
605
|
+
readonly symbols?: boolean
|
|
606
|
+
/** Include parse diagnostics. Default: false. */
|
|
607
|
+
readonly diagnostics?: boolean
|
|
608
|
+
/** Maximum chunk size in bytes. `None` disables chunking. */
|
|
609
|
+
readonly chunkMaxSize?: number
|
|
610
610
|
}
|
|
611
611
|
|
|
612
612
|
/**
|
|
@@ -630,16 +630,16 @@ export interface ProcessConfig {
|
|
|
630
630
|
* - `chunks` - Chunked code segments (when `config.chunk_max_size` is set)
|
|
631
631
|
*/
|
|
632
632
|
export interface ProcessResult {
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
633
|
+
readonly language?: string
|
|
634
|
+
readonly metrics?: FileMetrics
|
|
635
|
+
readonly structure?: Array<StructureItem>
|
|
636
|
+
readonly imports?: Array<ImportInfo>
|
|
637
|
+
readonly exports?: Array<ExportInfo>
|
|
638
|
+
readonly comments?: Array<CommentInfo>
|
|
639
|
+
readonly docstrings?: Array<DocstringInfo>
|
|
640
|
+
readonly symbols?: Array<SymbolInfo>
|
|
641
|
+
readonly diagnostics?: Array<Diagnostic>
|
|
642
|
+
readonly chunks?: Array<CodeChunk>
|
|
643
643
|
}
|
|
644
644
|
|
|
645
645
|
/**
|
|
@@ -649,25 +649,25 @@ export interface ProcessResult {
|
|
|
649
649
|
* positions (for display and diagnostics).
|
|
650
650
|
*/
|
|
651
651
|
export interface Span {
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
652
|
+
readonly startByte?: number
|
|
653
|
+
readonly endByte?: number
|
|
654
|
+
readonly startLine?: number
|
|
655
|
+
readonly startColumn?: number
|
|
656
|
+
readonly endLine?: number
|
|
657
|
+
readonly endColumn?: number
|
|
658
658
|
}
|
|
659
659
|
|
|
660
660
|
/** A structural item (function, class, struct, etc.) in source code. */
|
|
661
661
|
export interface StructureItem {
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
662
|
+
readonly kind?: StructureKind
|
|
663
|
+
readonly name?: string
|
|
664
|
+
readonly visibility?: string
|
|
665
|
+
readonly span?: Span
|
|
666
|
+
readonly children?: Array<StructureItem>
|
|
667
|
+
readonly decorators?: Array<string>
|
|
668
|
+
readonly docComment?: string
|
|
669
|
+
readonly signature?: string
|
|
670
|
+
readonly bodySpan?: Span
|
|
671
671
|
}
|
|
672
672
|
|
|
673
673
|
/**
|
|
@@ -678,26 +678,26 @@ export interface StructureItem {
|
|
|
678
678
|
* language-specific constructs that do not fit a standard category.
|
|
679
679
|
*/
|
|
680
680
|
export declare enum StructureKind {
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
681
|
+
Function = "Function",
|
|
682
|
+
Method = "Method",
|
|
683
|
+
Class = "Class",
|
|
684
|
+
Struct = "Struct",
|
|
685
|
+
Interface = "Interface",
|
|
686
|
+
Enum = "Enum",
|
|
687
|
+
Module = "Module",
|
|
688
|
+
Trait = "Trait",
|
|
689
|
+
Impl = "Impl",
|
|
690
|
+
Namespace = "Namespace",
|
|
691
|
+
Other = "Other",
|
|
692
692
|
}
|
|
693
693
|
|
|
694
694
|
/** A symbol (variable, function, type, etc.) extracted from source code. */
|
|
695
695
|
export interface SymbolInfo {
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
696
|
+
readonly name?: string
|
|
697
|
+
readonly kind?: SymbolKind
|
|
698
|
+
readonly span?: Span
|
|
699
|
+
readonly typeAnnotation?: string
|
|
700
|
+
readonly doc?: string
|
|
701
701
|
}
|
|
702
702
|
|
|
703
703
|
/**
|
|
@@ -707,46 +707,46 @@ export interface SymbolInfo {
|
|
|
707
707
|
* classes, types, interfaces, enums, and modules.
|
|
708
708
|
*/
|
|
709
709
|
export declare enum SymbolKind {
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
710
|
+
Variable = "Variable",
|
|
711
|
+
Constant = "Constant",
|
|
712
|
+
Function = "Function",
|
|
713
|
+
Class = "Class",
|
|
714
|
+
Type = "Type",
|
|
715
|
+
Interface = "Interface",
|
|
716
|
+
Enum = "Enum",
|
|
717
|
+
Module = "Module",
|
|
718
|
+
Other = "Other",
|
|
719
719
|
}
|
|
720
720
|
|
|
721
721
|
/** A parsed syntax tree. Cheap to clone (refcount bump). */
|
|
722
722
|
export declare class Tree {
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
723
|
+
/** Return the root [`Node`] of this tree. */
|
|
724
|
+
rootNode(): Node
|
|
725
|
+
/** Return a [`TreeCursor`] positioned at the root. */
|
|
726
|
+
walk(): TreeCursor
|
|
727
727
|
}
|
|
728
728
|
|
|
729
729
|
/** A cursor for traversing a [`Tree`]. */
|
|
730
730
|
export declare class TreeCursor {
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
731
|
+
/** Return the [`Node`] at the cursor's current position. */
|
|
732
|
+
node(): Node
|
|
733
|
+
/**
|
|
734
|
+
* Move the cursor to the first child of the current node.
|
|
735
|
+
* Returns `true` if a child existed.
|
|
736
|
+
*/
|
|
737
|
+
gotoFirstChild(): boolean
|
|
738
|
+
/**
|
|
739
|
+
* Move the cursor to the parent of the current node.
|
|
740
|
+
* Returns `true` if a parent existed.
|
|
741
|
+
*/
|
|
742
|
+
gotoParent(): boolean
|
|
743
|
+
/**
|
|
744
|
+
* Move the cursor to the next sibling of the current node.
|
|
745
|
+
* Returns `true` if a sibling existed.
|
|
746
|
+
*/
|
|
747
|
+
gotoNextSibling(): boolean
|
|
748
|
+
/** Return the field name for the current node, if any. */
|
|
749
|
+
fieldName(): string | null
|
|
750
750
|
}
|
|
751
751
|
|
|
752
752
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kreuzberg/tree-sitter-language-pack",
|
|
3
|
-
"version": "1.9.0-rc.
|
|
3
|
+
"version": "1.9.0-rc.23",
|
|
4
4
|
"description": "Pre-compiled tree-sitter grammars for 306 programming languages",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
},
|
|
19
19
|
"files": ["index.js", "index.d.ts", "*.node"],
|
|
20
20
|
"optionalDependencies": {
|
|
21
|
-
"@kreuzberg/tree-sitter-language-pack-linux-x64-gnu": "1.9.0-rc.
|
|
22
|
-
"@kreuzberg/tree-sitter-language-pack-linux-arm64-gnu": "1.9.0-rc.
|
|
23
|
-
"@kreuzberg/tree-sitter-language-pack-linux-x64-musl": "1.9.0-rc.
|
|
24
|
-
"@kreuzberg/tree-sitter-language-pack-linux-arm64-musl": "1.9.0-rc.
|
|
25
|
-
"@kreuzberg/tree-sitter-language-pack-darwin-x64": "1.9.0-rc.
|
|
26
|
-
"@kreuzberg/tree-sitter-language-pack-darwin-arm64": "1.9.0-rc.
|
|
27
|
-
"@kreuzberg/tree-sitter-language-pack-win32-x64-msvc": "1.9.0-rc.
|
|
28
|
-
"@kreuzberg/tree-sitter-language-pack-win32-arm64-msvc": "1.9.0-rc.
|
|
21
|
+
"@kreuzberg/tree-sitter-language-pack-linux-x64-gnu": "1.9.0-rc.23",
|
|
22
|
+
"@kreuzberg/tree-sitter-language-pack-linux-arm64-gnu": "1.9.0-rc.23",
|
|
23
|
+
"@kreuzberg/tree-sitter-language-pack-linux-x64-musl": "1.9.0-rc.23",
|
|
24
|
+
"@kreuzberg/tree-sitter-language-pack-linux-arm64-musl": "1.9.0-rc.23",
|
|
25
|
+
"@kreuzberg/tree-sitter-language-pack-darwin-x64": "1.9.0-rc.23",
|
|
26
|
+
"@kreuzberg/tree-sitter-language-pack-darwin-arm64": "1.9.0-rc.23",
|
|
27
|
+
"@kreuzberg/tree-sitter-language-pack-win32-x64-msvc": "1.9.0-rc.23",
|
|
28
|
+
"@kreuzberg/tree-sitter-language-pack-win32-arm64-msvc": "1.9.0-rc.23"
|
|
29
29
|
},
|
|
30
30
|
"napi": {
|
|
31
31
|
"packageName": "@kreuzberg/tree-sitter-language-pack",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|