tree_sitter_language_pack 1.8.1 → 1.9.0.pre.rc.2

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.
@@ -1,10 +1,10 @@
1
1
  # This file is auto-generated by alef — DO NOT EDIT.
2
- # alef:hash:d113f70858d98c7a984fcf099853b9c37b45fde94c1174988819b8516cc5d8fc
2
+ # alef:hash:d03129ef3f3d160dfc8a36d61d1a61448aa19b4ab82bd7728bd4a66d095c5cc7
3
3
  # To regenerate: alef generate
4
4
  # To verify freshness: alef verify --exit-code
5
5
  # Issues & docs: https://github.com/kreuzberg-dev/alef
6
6
  # frozen_string_literal: true
7
7
 
8
8
  module TreeSitterLanguagePack
9
- VERSION = '1.8.1'
9
+ VERSION = '1.9.0.pre.rc.2'
10
10
  end
@@ -1,5 +1,5 @@
1
1
  # This file is auto-generated by alef — DO NOT EDIT.
2
- # alef:hash:efdf5956fee9ce2f8507e58e07da47d0d28648f54484df7d7611d6a9272c9792
2
+ # alef:hash:dce0f2e0284f3f3b1b08ac2169c6eeef5ef1360cae2c75f8de2ea6411168295c
3
3
  # To regenerate: alef generate
4
4
  # To verify freshness: alef verify --exit-code
5
5
  # Issues & docs: https://github.com/kreuzberg-dev/alef
data/sig/types.rbs CHANGED
@@ -1,5 +1,5 @@
1
1
  # This file is auto-generated by alef — DO NOT EDIT.
2
- # alef:hash:82d69edc97fafaeafa8b66758fcd6fb121764169c5322d85640bb7e73f8c6817
2
+ # alef:hash:362a6dadeb87c3212c72a0a0b0ea4dfddc7364bd15ea407e93ed4199c4c7f1ee
3
3
  # To regenerate: alef generate
4
4
  # To verify freshness: alef verify --exit-code
5
5
  # Issues & docs: https://github.com/kreuzberg-dev/alef
@@ -8,12 +8,9 @@ module TreeSitterLanguagePack
8
8
 
9
9
  VERSION: String
10
10
 
11
- class Span
12
- # Byte and line/column range in source code.
13
- #
14
- # Represents both byte offsets (for slicing) and human-readable line/column
15
- # positions (for display and diagnostics).
11
+ type json_value = Hash[String, untyped] | Array[untyped] | String | Integer | Float | bool | nil
16
12
 
13
+ class Span
17
14
  attr_accessor start_byte: Integer?
18
15
  attr_accessor end_byte: Integer?
19
16
  attr_accessor start_line: Integer?
@@ -21,29 +18,10 @@ module TreeSitterLanguagePack
21
18
  attr_accessor end_line: Integer?
22
19
  attr_accessor end_column: Integer?
23
20
 
24
- def initialize: (start_byte: Integer, end_byte: Integer, start_line: Integer, start_column: Integer, end_line: Integer, end_column: Integer) -> void
21
+ def initialize: (?start_byte: Integer, ?end_byte: Integer, ?start_line: Integer, ?start_column: Integer, ?end_line: Integer, ?end_column: Integer) -> void
25
22
  end
26
23
 
27
24
  class ProcessResult
28
- # Complete analysis result from processing a source file.
29
- #
30
- # Contains metrics, structural analysis, imports/exports, comments,
31
- # docstrings, symbols, diagnostics, and optionally chunked code segments.
32
- # Fields are populated based on the `ProcessConfig` flags.
33
- #
34
- # # Fields
35
- #
36
- # - `language` - The language used for parsing
37
- # - `metrics` - Always computed: line counts, byte sizes, error counts
38
- # - `structure` - Functions, classes, structs (when `config.structure = true`)
39
- # - `imports` - Import statements (when `config.imports = true`)
40
- # - `exports` - Export statements (when `config.exports = true`)
41
- # - `comments` - Comments (when `config.comments = true`)
42
- # - `docstrings` - Docstrings (when `config.docstrings = true`)
43
- # - `symbols` - Symbol definitions (when `config.symbols = true`)
44
- # - `diagnostics` - Parse errors (when `config.diagnostics = true`)
45
- # - `chunks` - Chunked code segments (when `config.chunk_max_size` is set)
46
-
47
25
  attr_accessor language: String?
48
26
  attr_accessor metrics: FileMetrics?
49
27
  attr_accessor structure: Array[StructureItem]?
@@ -55,12 +33,10 @@ module TreeSitterLanguagePack
55
33
  attr_accessor diagnostics: Array[Diagnostic]?
56
34
  attr_accessor chunks: Array[CodeChunk]?
57
35
 
58
- def initialize: (language: String, metrics: FileMetrics, structure: Array[StructureItem], imports: Array[ImportInfo], exports: Array[ExportInfo], comments: Array[CommentInfo], docstrings: Array[DocstringInfo], symbols: Array[SymbolInfo], diagnostics: Array[Diagnostic], chunks: Array[CodeChunk]) -> void
36
+ def initialize: (?language: String, ?metrics: FileMetrics, ?structure: Array[StructureItem], ?imports: Array[ImportInfo], ?exports: Array[ExportInfo], ?comments: Array[CommentInfo], ?docstrings: Array[DocstringInfo], ?symbols: Array[SymbolInfo], ?diagnostics: Array[Diagnostic], ?chunks: Array[CodeChunk]) -> void
59
37
  end
60
38
 
61
39
  class FileMetrics
62
- # Aggregate metrics for a source file.
63
-
64
40
  attr_accessor total_lines: Integer?
65
41
  attr_accessor code_lines: Integer?
66
42
  attr_accessor comment_lines: Integer?
@@ -70,12 +46,10 @@ module TreeSitterLanguagePack
70
46
  attr_accessor error_count: Integer?
71
47
  attr_accessor max_depth: Integer?
72
48
 
73
- def initialize: (total_lines: Integer, code_lines: Integer, comment_lines: Integer, blank_lines: Integer, total_bytes: Integer, node_count: Integer, error_count: Integer, max_depth: Integer) -> void
49
+ def initialize: (?total_lines: Integer, ?code_lines: Integer, ?comment_lines: Integer, ?blank_lines: Integer, ?total_bytes: Integer, ?node_count: Integer, ?error_count: Integer, ?max_depth: Integer) -> void
74
50
  end
75
51
 
76
52
  class StructureItem
77
- # A structural item (function, class, struct, etc.) in source code.
78
-
79
53
  attr_accessor kind: StructureKind?
80
54
  attr_accessor name: String?
81
55
  attr_accessor visibility: String?
@@ -86,89 +60,73 @@ module TreeSitterLanguagePack
86
60
  attr_accessor signature: String?
87
61
  attr_accessor body_span: Span?
88
62
 
89
- def initialize: (kind: StructureKind, ?name: String, ?visibility: String, span: Span, children: Array[StructureItem], decorators: Array[String], ?doc_comment: String, ?signature: String, ?body_span: Span) -> void
63
+ def initialize: (?kind: StructureKind, ?name: String, ?visibility: String, ?span: Span, ?children: Array[StructureItem], ?decorators: Array[String], ?doc_comment: String, ?signature: String, ?body_span: Span) -> void
90
64
  end
91
65
 
92
66
  class CommentInfo
93
- # A comment extracted from source code.
94
-
95
67
  attr_accessor text: String?
96
68
  attr_accessor kind: CommentKind?
97
69
  attr_accessor span: Span?
98
70
  attr_accessor associated_node: String?
99
71
 
100
- def initialize: (text: String, kind: CommentKind, span: Span, ?associated_node: String) -> void
72
+ def initialize: (?text: String, ?kind: CommentKind, ?span: Span, ?associated_node: String) -> void
101
73
  end
102
74
 
103
75
  class DocstringInfo
104
- # A docstring extracted from source code.
105
-
106
76
  attr_accessor text: String?
107
77
  attr_accessor format: DocstringFormat?
108
78
  attr_accessor span: Span?
109
79
  attr_accessor associated_item: String?
110
80
  attr_accessor parsed_sections: Array[DocSection]?
111
81
 
112
- def initialize: (text: String, format: DocstringFormat, span: Span, ?associated_item: String, parsed_sections: Array[DocSection]) -> void
82
+ def initialize: (?text: String, ?format: DocstringFormat, ?span: Span, ?associated_item: String, ?parsed_sections: Array[DocSection]) -> void
113
83
  end
114
84
 
115
85
  class DocSection
116
- # A section within a docstring (e.g., Args, Returns, Raises).
117
-
118
86
  attr_accessor kind: String?
119
87
  attr_accessor name: String?
120
88
  attr_accessor description: String?
121
89
 
122
- def initialize: (kind: String, ?name: String, description: String) -> void
90
+ def initialize: (?kind: String, ?name: String, ?description: String) -> void
123
91
  end
124
92
 
125
93
  class ImportInfo
126
- # An import statement extracted from source code.
127
-
128
94
  attr_accessor source: String?
129
95
  attr_accessor items: Array[String]?
130
96
  attr_accessor alias: String?
131
97
  attr_accessor is_wildcard: bool?
132
98
  attr_accessor span: Span?
133
99
 
134
- def initialize: (source: String, items: Array[String], ?alias: String, is_wildcard: bool, span: Span) -> void
100
+ def initialize: (?source: String, ?items: Array[String], ?alias: String, ?is_wildcard: bool, ?span: Span) -> void
135
101
  end
136
102
 
137
103
  class ExportInfo
138
- # An export statement extracted from source code.
139
-
140
104
  attr_accessor name: String?
141
105
  attr_accessor kind: ExportKind?
142
106
  attr_accessor span: Span?
143
107
 
144
- def initialize: (name: String, kind: ExportKind, span: Span) -> void
108
+ def initialize: (?name: String, ?kind: ExportKind, ?span: Span) -> void
145
109
  end
146
110
 
147
111
  class SymbolInfo
148
- # A symbol (variable, function, type, etc.) extracted from source code.
149
-
150
112
  attr_accessor name: String?
151
113
  attr_accessor kind: SymbolKind?
152
114
  attr_accessor span: Span?
153
115
  attr_accessor type_annotation: String?
154
116
  attr_accessor doc: String?
155
117
 
156
- def initialize: (name: String, kind: SymbolKind, span: Span, ?type_annotation: String, ?doc: String) -> void
118
+ def initialize: (?name: String, ?kind: SymbolKind, ?span: Span, ?type_annotation: String, ?doc: String) -> void
157
119
  end
158
120
 
159
121
  class Diagnostic
160
- # A diagnostic (syntax error, missing node, etc.) from parsing.
161
-
162
122
  attr_accessor message: String?
163
123
  attr_accessor severity: DiagnosticSeverity?
164
124
  attr_accessor span: Span?
165
125
 
166
- def initialize: (message: String, severity: DiagnosticSeverity, span: Span) -> void
126
+ def initialize: (?message: String, ?severity: DiagnosticSeverity, ?span: Span) -> void
167
127
  end
168
128
 
169
129
  class CodeChunk
170
- # A chunk of source code with rich metadata.
171
-
172
130
  attr_accessor content: String?
173
131
  attr_accessor start_byte: Integer?
174
132
  attr_accessor end_byte: Integer?
@@ -176,12 +134,10 @@ module TreeSitterLanguagePack
176
134
  attr_accessor end_line: Integer?
177
135
  attr_accessor metadata: ChunkContext?
178
136
 
179
- def initialize: (content: String, start_byte: Integer, end_byte: Integer, start_line: Integer, end_line: Integer, metadata: ChunkContext) -> void
137
+ def initialize: (?content: String, ?start_byte: Integer, ?end_byte: Integer, ?start_line: Integer, ?end_line: Integer, ?metadata: ChunkContext) -> void
180
138
  end
181
139
 
182
140
  class ChunkContext
183
- # Metadata for a single chunk of source code.
184
-
185
141
  attr_accessor language: String?
186
142
  attr_accessor chunk_index: Integer?
187
143
  attr_accessor total_chunks: Integer?
@@ -192,50 +148,25 @@ module TreeSitterLanguagePack
192
148
  attr_accessor docstrings: Array[DocstringInfo]?
193
149
  attr_accessor has_error_nodes: bool?
194
150
 
195
- def initialize: (language: String, chunk_index: Integer, total_chunks: Integer, node_types: Array[String], context_path: Array[String], symbols_defined: Array[String], comments: Array[CommentInfo], docstrings: Array[DocstringInfo], has_error_nodes: bool) -> void
151
+ def initialize: (?language: String, ?chunk_index: Integer, ?total_chunks: Integer, ?node_types: Array[String], ?context_path: Array[String], ?symbols_defined: Array[String], ?comments: Array[CommentInfo], ?docstrings: Array[DocstringInfo], ?has_error_nodes: bool) -> void
196
152
  end
197
153
 
198
154
  class PackConfig
199
- # Configuration for the tree-sitter language pack.
200
- #
201
- # Controls cache directory and which languages to pre-download.
202
- # Can be loaded from a TOML file, constructed programmatically,
203
- # or passed as a dict/object from language bindings.
204
- #
205
- # # Example
206
- #
207
- # ```no_run
208
- # use tree_sitter_language_pack::PackConfig;
209
- #
210
- # let config = PackConfig {
211
- # cache_dir: None,
212
- # languages: Some(vec!["python".to_string(), "rust".to_string()]),
213
- # groups: None,
214
- # };
215
- # ```
216
-
217
155
  attr_accessor cache_dir: String?
218
156
  attr_accessor languages: Array[String]?
219
157
  attr_accessor groups: Array[String]?
220
158
 
221
159
  def initialize: (?cache_dir: String, ?languages: Array[String], ?groups: Array[String]) -> void
222
- def self.from_toml_file: (String path) -> PackConfig
223
- def self.discover: () -> PackConfig?
224
160
  end
225
161
 
226
162
  class Point
227
- # A source position — row + column, zero-indexed.
228
-
229
163
  attr_reader row: Integer
230
164
  attr_reader column: Integer
231
165
 
232
166
  def initialize: (row: Integer, column: Integer) -> void
233
- def self.from: (Point p) -> Point
234
167
  end
235
168
 
236
169
  class ByteRange
237
- # A byte range — start (inclusive) to end (exclusive).
238
-
239
170
  attr_reader start: Integer
240
171
  attr_reader end: Integer
241
172
 
@@ -243,20 +174,6 @@ module TreeSitterLanguagePack
243
174
  end
244
175
 
245
176
  class Parser
246
- # A tree-sitter parser configured for one language at a time.
247
- #
248
- # # Example
249
- #
250
- # ```no_run
251
- # use tree_sitter_language_pack::Parser;
252
- #
253
- # let mut parser = Parser::new();
254
- # parser.set_language("python")?;
255
- # let tree = parser.parse("def hello(): pass").expect("parse failed");
256
- # assert_eq!(tree.root_node().kind(), "module");
257
- # # Ok::<(), tree_sitter_language_pack::Error>(())
258
- # ```
259
-
260
177
  def set_language: (String name) -> void
261
178
  def parse: (String source) -> Tree?
262
179
  def parse_bytes: (String source) -> Tree?
@@ -265,18 +182,11 @@ module TreeSitterLanguagePack
265
182
  end
266
183
 
267
184
  class Tree
268
- # A parsed syntax tree. Cheap to clone (refcount bump).
269
-
270
185
  def root_node: () -> Node
271
186
  def walk: () -> TreeCursor
272
187
  end
273
188
 
274
189
  class Node
275
- # A single syntax node within a [`Tree`].
276
- #
277
- # Nodes hold a strong reference to their parent tree so they remain valid
278
- # regardless of how the tree is moved or stored at the FFI boundary.
279
-
280
190
  def clone: () -> Node
281
191
  def kind: () -> String
282
192
  def kind_id: () -> Integer
@@ -301,8 +211,6 @@ module TreeSitterLanguagePack
301
211
  end
302
212
 
303
213
  class TreeCursor
304
- # A cursor for traversing a [`Tree`].
305
-
306
214
  def node: () -> Node
307
215
  def goto_first_child: () -> bool
308
216
  def goto_parent: () -> bool
@@ -311,25 +219,6 @@ module TreeSitterLanguagePack
311
219
  end
312
220
 
313
221
  class ProcessConfig
314
- # Configuration for the `process()` function.
315
- #
316
- # Controls which analysis features are enabled and whether chunking is performed.
317
- #
318
- # # Examples
319
- #
320
- # ```
321
- # use tree_sitter_language_pack::ProcessConfig;
322
- #
323
- # // Defaults: structure + imports + exports enabled
324
- # let config = ProcessConfig::new("python");
325
- #
326
- # // With chunking
327
- # let config = ProcessConfig::new("python").with_chunking(1000);
328
- #
329
- # // Everything enabled
330
- # let config = ProcessConfig::new("python").all();
331
- # ```
332
-
333
222
  attr_accessor language: String?
334
223
  attr_accessor structure: bool?
335
224
  attr_accessor imports: bool?
@@ -340,7 +229,7 @@ module TreeSitterLanguagePack
340
229
  attr_accessor diagnostics: bool?
341
230
  attr_accessor chunk_max_size: Integer?
342
231
 
343
- def initialize: (language: String, structure: bool, imports: bool, exports: bool, comments: bool, docstrings: bool, symbols: bool, diagnostics: bool, ?chunk_max_size: Integer) -> void
232
+ def initialize: (?language: String, ?structure: bool, ?imports: bool, ?exports: bool, ?comments: bool, ?docstrings: bool, ?symbols: bool, ?diagnostics: bool, ?chunk_max_size: Integer) -> void
344
233
  def with_chunking: (Integer max_size) -> ProcessConfig
345
234
  def all: () -> ProcessConfig
346
235
  def minimal: () -> ProcessConfig
@@ -348,124 +237,43 @@ module TreeSitterLanguagePack
348
237
  end
349
238
 
350
239
  class LanguageRegistry
351
- # Thread-safe registry of tree-sitter language parsers.
352
- #
353
- # Manages both statically compiled and dynamically loaded language grammars.
354
- # Use [`LanguageRegistry::new()`] for the default registry, or access the
355
- # global instance via the module-level convenience functions
356
- # (`get_language`, `available_languages`, etc.).
357
- #
358
- # # Example
359
- #
360
- # ```no_run
361
- # use tree_sitter_language_pack::{LanguageRegistry, ProcessConfig};
362
- #
363
- # let registry = LanguageRegistry::new();
364
- # let langs = registry.available_languages();
365
- # println!("Available: {:?}", langs);
366
- #
367
- # let config = ProcessConfig::new("python").all();
368
- # let result = registry.process("def hello(): pass", &config).unwrap();
369
- # println!("Structure: {:?}", result.structure);
370
- # ```
371
-
372
- def add_extra_libs_dir: (String dir) -> void
373
240
  def get_language: (String name) -> Language
374
241
  def available_languages: () -> Array[String]
375
242
  def has_language: (String name) -> bool
376
243
  def language_count: () -> Integer
377
244
  def process: (String source, ProcessConfig config) -> ProcessResult
378
- def self.with_libs_dir: (String libs_dir) -> LanguageRegistry
379
245
  def self.default: () -> LanguageRegistry
380
246
  end
381
247
 
382
- class ParserManifest
383
- # Manifest describing available parser downloads for a specific version.
384
-
385
- attr_reader version: String
386
- attr_reader platforms: Hash[String, PlatformBundle]
387
- attr_reader languages: Hash[String, LanguageInfo]
388
- attr_reader groups: Hash[String, Array[String]]
389
-
390
- def initialize: (version: String, platforms: Hash[String, PlatformBundle], languages: Hash[String, LanguageInfo], groups: Hash[String, Array[String]]) -> void
391
- end
392
-
393
- class PlatformBundle
394
- attr_reader url: String
395
- attr_reader sha256: String
396
- attr_reader size: Integer
397
-
398
- def initialize: (url: String, sha256: String, size: Integer) -> void
399
- end
400
-
401
- class LanguageInfo
402
- attr_reader group: String
403
- attr_reader size: Integer
404
-
405
- def initialize: (group: String, size: Integer) -> void
406
- end
407
-
408
248
  class DownloadManager
409
- # Manages downloading and caching of pre-built parser shared libraries.
410
-
411
- def cache_dir: () -> String
412
249
  def installed_languages: () -> Array[String]
413
- def ensure_languages: (Array[String] names) -> void
414
- def ensure_group: (String group) -> void
415
- def lib_path: (String name) -> String
416
- def fetch_manifest: () -> ParserManifest
417
250
  def download_all_best_effort: () -> Integer
418
251
  def clean_cache: () -> void
419
252
  def self.new: (String version) -> DownloadManager
420
253
  def self.with_cache_dir: (String version, String cache_dir) -> DownloadManager
421
- def self.default_cache_dir: (String version) -> String
422
254
  end
423
255
 
424
256
  class Language
425
257
  end
426
258
 
427
259
  class StructureKind
428
- # The kind of structural item found in source code.
429
- #
430
- # Categorizes top-level and nested declarations such as functions, classes,
431
- # structs, enums, traits, and more. Use [`Other`](StructureKind::Other) for
432
- # language-specific constructs that do not fit a standard category.
433
260
  end
434
261
 
435
262
  class CommentKind
436
- # The kind of a comment found in source code.
437
- #
438
- # Distinguishes between single-line comments, block (multi-line) comments,
439
- # and documentation comments.
440
263
  type value = :line | :block | :doc
441
264
  end
442
265
 
443
266
  class DocstringFormat
444
- # The format of a docstring extracted from source code.
445
- #
446
- # Identifies the docstring convention used, which varies by language
447
- # (e.g., Python triple-quoted strings, JSDoc, Rustdoc `///` comments).
448
267
  end
449
268
 
450
269
  class ExportKind
451
- # The kind of an export statement found in source code.
452
- #
453
- # Covers named exports, default exports, and re-exports from other modules.
454
270
  type value = :named | :default | :re_export
455
271
  end
456
272
 
457
273
  class SymbolKind
458
- # The kind of a symbol definition found in source code.
459
- #
460
- # Categorizes symbol definitions such as variables, constants, functions,
461
- # classes, types, interfaces, enums, and modules.
462
274
  end
463
275
 
464
276
  class DiagnosticSeverity
465
- # Severity level of a diagnostic produced during parsing.
466
- #
467
- # Used to classify parse errors, warnings, and informational messages
468
- # found in the syntax tree.
469
277
  type value = :error | :warning | :info
470
278
  end
471
279
 
@@ -503,6 +311,8 @@ module TreeSitterLanguagePack
503
311
 
504
312
  def self.download_all: () -> Integer
505
313
 
314
+ def self.download_group: (String name) -> Integer
315
+
506
316
  def self.manifest_languages: () -> Array[String]
507
317
 
508
318
  def self.downloaded_languages: () -> Array[String]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tree_sitter_language_pack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.9.0.pre.rc.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kreuzberg Team
@@ -23,6 +23,20 @@ dependencies:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
25
  version: '0.9'
26
+ - !ruby/object:Gem::Dependency
27
+ name: sorbet-runtime
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.5'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.5'
26
40
  description: Pre-compiled tree-sitter grammars for 305 programming languages
27
41
  executables: []
28
42
  extensions: