| 1289 | // src/language.ts |
| 1290 | var LANGUAGE_FUNCTION_REGEX = /^tree_sitter_\w+$/; |
| 1291 | var Language = class _Language { |
| 1292 | static { |
| 1293 | __name(this, "Language"); |
| 1294 | } |
| 1295 | /** @internal */ |
| 1296 | [0] = 0; |
| 1297 | // Internal handle for Wasm |
| 1298 | /** |
| 1299 | * A list of all node types in the language. The index of each type in this |
| 1300 | * array is its node type id. |
| 1301 | */ |
| 1302 | types; |
| 1303 | /** |
| 1304 | * A list of all field names in the language. The index of each field name in |
| 1305 | * this array is its field id. |
| 1306 | */ |
| 1307 | fields; |
| 1308 | /** @internal */ |
| 1309 | constructor(internal, address) { |
| 1310 | assertInternal(internal); |
| 1311 | this[0] = address; |
| 1312 | this.types = new Array(C._ts_language_symbol_count(this[0])); |
| 1313 | for (let i2 = 0, n = this.types.length; i2 < n; i2++) { |
| 1314 | if (C._ts_language_symbol_type(this[0], i2) < 2) { |
| 1315 | this.types[i2] = C.UTF8ToString(C._ts_language_symbol_name(this[0], i2)); |
| 1316 | } |
| 1317 | } |
| 1318 | this.fields = new Array(C._ts_language_field_count(this[0]) + 1); |
| 1319 | for (let i2 = 0, n = this.fields.length; i2 < n; i2++) { |
| 1320 | const fieldName = C._ts_language_field_name_for_id(this[0], i2); |
| 1321 | if (fieldName !== 0) { |
| 1322 | this.fields[i2] = C.UTF8ToString(fieldName); |
| 1323 | } else { |
| 1324 | this.fields[i2] = null; |
| 1325 | } |
| 1326 | } |
| 1327 | } |
| 1328 | /** |
| 1329 | * Gets the name of the language. |
| 1330 | */ |
| 1331 | get name() { |
| 1332 | const ptr = C._ts_language_name(this[0]); |
| 1333 | if (ptr === 0) return null; |
| 1334 | return C.UTF8ToString(ptr); |
| 1335 | } |
| 1336 | /** |
| 1337 | * Gets the ABI version of the language. |
| 1338 | */ |
| 1339 | get abiVersion() { |
| 1340 | return C._ts_language_abi_version(this[0]); |
| 1341 | } |
| 1342 | /** |
| 1343 | * Get the metadata for this language. This information is generated by the |
| 1344 | * CLI, and relies on the language author providing the correct metadata in |
| 1345 | * the language's `tree-sitter.json` file. |
| 1346 | */ |
| 1347 | get metadata() { |
| 1348 | C._ts_language_metadata_wasm(this[0]); |