feat(web)!: remove deprecated functions
This commit is contained in:
parent
d60ef9ad0a
commit
580cd9541a
7 changed files with 8 additions and 94 deletions
|
|
@ -11,7 +11,6 @@
|
|||
"ts_language_symbol_name",
|
||||
"ts_language_symbol_type",
|
||||
"ts_language_name",
|
||||
"ts_language_version",
|
||||
"ts_language_abi_version",
|
||||
"ts_language_metadata_wasm",
|
||||
"ts_language_next_state",
|
||||
|
|
@ -62,8 +61,6 @@
|
|||
"ts_parser_set_language",
|
||||
"ts_parser_set_included_ranges",
|
||||
"ts_parser_included_ranges_wasm",
|
||||
"ts_parser_set_timeout_micros",
|
||||
"ts_parser_timeout_micros",
|
||||
"ts_query_capture_count",
|
||||
"ts_query_capture_name_for_id",
|
||||
"ts_query_captures_wasm",
|
||||
|
|
|
|||
|
|
@ -875,8 +875,7 @@ void ts_query_matches_wasm(
|
|||
uint32_t start_index,
|
||||
uint32_t end_index,
|
||||
uint32_t match_limit,
|
||||
uint32_t max_start_depth,
|
||||
uint64_t timeout_micros
|
||||
uint32_t max_start_depth
|
||||
) {
|
||||
if (!scratch_query_cursor) {
|
||||
scratch_query_cursor = ts_query_cursor_new();
|
||||
|
|
@ -894,7 +893,6 @@ void ts_query_matches_wasm(
|
|||
ts_query_cursor_set_byte_range(scratch_query_cursor, start_index, end_index);
|
||||
ts_query_cursor_set_match_limit(scratch_query_cursor, match_limit);
|
||||
ts_query_cursor_set_max_start_depth(scratch_query_cursor, max_start_depth);
|
||||
ts_query_cursor_set_timeout_micros(scratch_query_cursor, timeout_micros);
|
||||
|
||||
TSQueryCursorOptions options = {.payload = NULL, .progress_callback = query_progress_callback};
|
||||
|
||||
|
|
@ -935,8 +933,7 @@ void ts_query_captures_wasm(
|
|||
uint32_t start_index,
|
||||
uint32_t end_index,
|
||||
uint32_t match_limit,
|
||||
uint32_t max_start_depth,
|
||||
uint64_t timeout_micros
|
||||
uint32_t max_start_depth
|
||||
) {
|
||||
if (!scratch_query_cursor) {
|
||||
scratch_query_cursor = ts_query_cursor_new();
|
||||
|
|
@ -951,7 +948,6 @@ void ts_query_captures_wasm(
|
|||
ts_query_cursor_set_byte_range(scratch_query_cursor, start_index, end_index);
|
||||
ts_query_cursor_set_match_limit(scratch_query_cursor, match_limit);
|
||||
ts_query_cursor_set_max_start_depth(scratch_query_cursor, max_start_depth);
|
||||
ts_query_cursor_set_timeout_micros(scratch_query_cursor, timeout_micros);
|
||||
ts_query_cursor_exec(scratch_query_cursor, self, node);
|
||||
|
||||
unsigned index = 0;
|
||||
|
|
|
|||
7
lib/binding_web/lib/web-tree-sitter.d.ts
generated
vendored
7
lib/binding_web/lib/web-tree-sitter.d.ts
generated
vendored
|
|
@ -56,7 +56,6 @@ interface WasmModule {
|
|||
_memcmp(_0: number, _1: number, _2: number): number;
|
||||
_ts_language_symbol_count(_0: number): number;
|
||||
_ts_language_state_count(_0: number): number;
|
||||
_ts_language_version(_0: number): number;
|
||||
_ts_language_abi_version(_0: number): number;
|
||||
_ts_language_name(_0: number): number;
|
||||
_ts_language_field_count(_0: number): number;
|
||||
|
|
@ -75,8 +74,6 @@ interface WasmModule {
|
|||
_ts_parser_delete(_0: number): void;
|
||||
_ts_parser_reset(_0: number): void;
|
||||
_ts_parser_set_language(_0: number, _1: number): number;
|
||||
_ts_parser_timeout_micros(_0: number): bigint;
|
||||
_ts_parser_set_timeout_micros(_0: number, _1: bigint): void;
|
||||
_ts_parser_set_included_ranges(_0: number, _1: number, _2: number): number;
|
||||
_ts_query_new(_0: number, _1: number, _2: number, _3: number, _4: number): number;
|
||||
_ts_query_delete(_0: number): void;
|
||||
|
|
@ -178,8 +175,8 @@ interface WasmModule {
|
|||
_ts_node_is_extra_wasm(_0: number): number;
|
||||
_ts_node_parse_state_wasm(_0: number): number;
|
||||
_ts_node_next_parse_state_wasm(_0: number): number;
|
||||
_ts_query_matches_wasm(_0: number, _1: number, _2: number, _3: number, _4: number, _5: number, _6: number, _7: number, _8: number, _9: number, _10: bigint): void;
|
||||
_ts_query_captures_wasm(_0: number, _1: number, _2: number, _3: number, _4: number, _5: number, _6: number, _7: number, _8: number, _9: number, _10: bigint): void;
|
||||
_ts_query_matches_wasm(_0: number, _1: number, _2: number, _3: number, _4: number, _5: number, _6: number, _7: number, _8: number, _9: number): void;
|
||||
_ts_query_captures_wasm(_0: number, _1: number, _2: number, _3: number, _4: number, _5: number, _6: number, _7: number, _8: number, _9: number): void;
|
||||
_memset(_0: number, _1: number, _2: number): number;
|
||||
_memcpy(_0: number, _1: number, _2: number): number;
|
||||
_memmove(_0: number, _1: number, _2: number): number;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import { C, INTERNAL, Internal, assertInternal, SIZE_OF_INT, SIZE_OF_SHORT } fro
|
|||
import { LookaheadIterator } from './lookahead_iterator';
|
||||
import { unmarshalLanguageMetadata } from './marshal';
|
||||
import { TRANSFER_BUFFER } from './parser';
|
||||
import { Query } from './query';
|
||||
|
||||
const LANGUAGE_FUNCTION_REGEX = /^tree_sitter_\w+$/;
|
||||
|
||||
|
|
@ -63,14 +62,6 @@ export class Language {
|
|||
return C.UTF8ToString(ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 0.25.0, use {@link Language#abiVersion} instead
|
||||
* Gets the version of the language.
|
||||
*/
|
||||
get version(): number {
|
||||
return C._ts_language_version(this[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ABI version of the language.
|
||||
*/
|
||||
|
|
@ -232,23 +223,6 @@ export class Language {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 0.25.0, call `new` on a {@link Query} instead
|
||||
*
|
||||
* Create a new query from a string containing one or more S-expression
|
||||
* patterns.
|
||||
*
|
||||
* The query is associated with a particular language, and can only be run
|
||||
* on syntax nodes parsed with that language. References to Queries can be
|
||||
* shared between multiple threads.
|
||||
*
|
||||
* @link {@see https://tree-sitter.github.io/tree-sitter/using-parsers/queries}
|
||||
*/
|
||||
query(source: string): Query {
|
||||
console.warn('Language.query is deprecated. Use new Query(language, source) instead.');
|
||||
return new Query(this, source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a language from a WebAssembly module.
|
||||
* The module can be provided as a path to a file or as a buffer.
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ export class Parser {
|
|||
this.language = null;
|
||||
} else if (language.constructor === Language) {
|
||||
address = language[0];
|
||||
const version = C._ts_language_version(address);
|
||||
const version = C._ts_language_abi_version(address);
|
||||
if (version < MIN_COMPATIBLE_VERSION || LANGUAGE_VERSION < version) {
|
||||
throw new Error(
|
||||
`Incompatible language version ${version}. ` +
|
||||
|
|
@ -253,8 +253,8 @@ export class Parser {
|
|||
/**
|
||||
* Instruct the parser to start the next parse from the beginning.
|
||||
*
|
||||
* If the parser previously failed because of a timeout, cancellation,
|
||||
* or callback, then by default, it will resume where it left off on the
|
||||
* If the parser previously failed because of a callback,
|
||||
* then by default, it will resume where it left off on the
|
||||
* next call to {@link Parser#parse} or other parsing functions.
|
||||
* If you don't want to resume, and instead intend to use this parser to
|
||||
* parse some other document, you must call `reset` first.
|
||||
|
|
@ -282,30 +282,6 @@ export class Parser {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 0.25.0, prefer passing a progress callback to {@link Parser#parse}
|
||||
*
|
||||
* Get the duration in microseconds that parsing is allowed to take.
|
||||
*
|
||||
* This is set via {@link Parser#setTimeoutMicros}.
|
||||
*/
|
||||
getTimeoutMicros(): bigint {
|
||||
return C._ts_parser_timeout_micros(this[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 0.25.0, prefer passing a progress callback to {@link Parser#parse}
|
||||
*
|
||||
* Set the maximum duration in microseconds that parsing should be allowed
|
||||
* to take before halting.
|
||||
*
|
||||
* If parsing takes longer than this, it will halt early, returning `null`.
|
||||
* See {@link Parser#parse} for more information.
|
||||
*/
|
||||
setTimeoutMicros(timeout: bigint): void {
|
||||
C._ts_parser_set_timeout_micros(this[0], timeout);
|
||||
}
|
||||
|
||||
/** Set the logging callback that a parser should use during parsing. */
|
||||
setLogger(callback: LogCallback | boolean | null): this {
|
||||
if (!callback) {
|
||||
|
|
|
|||
|
|
@ -50,14 +50,6 @@ export interface QueryOptions {
|
|||
*/
|
||||
maxStartDepth?: number;
|
||||
|
||||
/**
|
||||
* The maximum duration in microseconds that query execution should be allowed to
|
||||
* take before halting.
|
||||
*
|
||||
* If query execution takes longer than this, it will halt early, returning an empty array.
|
||||
*/
|
||||
timeoutMicros?: bigint;
|
||||
|
||||
/**
|
||||
* A function that will be called periodically during the execution of the query to check
|
||||
* if query execution should be cancelled. You can also use this to instrument query execution
|
||||
|
|
@ -116,9 +108,6 @@ export interface QueryCapture {
|
|||
|
||||
/** A match of a {@link Query} to a particular set of {@link Node}s. */
|
||||
export interface QueryMatch {
|
||||
/** @deprecated since version 0.25.0, use `patternIndex` instead. */
|
||||
pattern: number;
|
||||
|
||||
/** The index of the pattern that matched. */
|
||||
patternIndex: number;
|
||||
|
||||
|
|
@ -708,7 +697,6 @@ export class Query {
|
|||
const endIndex = options.endIndex ?? 0;
|
||||
const matchLimit = options.matchLimit ?? 0xFFFFFFFF;
|
||||
const maxStartDepth = options.maxStartDepth ?? 0xFFFFFFFF;
|
||||
const timeoutMicros = options.timeoutMicros ?? 0n;
|
||||
const progressCallback = options.progressCallback;
|
||||
|
||||
if (typeof matchLimit !== 'number') {
|
||||
|
|
@ -744,7 +732,6 @@ export class Query {
|
|||
endIndex,
|
||||
matchLimit,
|
||||
maxStartDepth,
|
||||
timeoutMicros,
|
||||
);
|
||||
|
||||
const rawCount = C.getValue(TRANSFER_BUFFER, 'i32');
|
||||
|
|
@ -765,7 +752,7 @@ export class Query {
|
|||
address = unmarshalCaptures(this, node.tree, address, patternIndex, captures);
|
||||
|
||||
if (this.textPredicates[patternIndex].every((p) => p(captures))) {
|
||||
result[filteredCount] = { pattern: patternIndex, patternIndex, captures };
|
||||
result[filteredCount] = { patternIndex, captures };
|
||||
const setProperties = this.setProperties[patternIndex];
|
||||
result[filteredCount].setProperties = setProperties;
|
||||
const assertedProperties = this.assertedProperties[patternIndex];
|
||||
|
|
@ -803,7 +790,6 @@ export class Query {
|
|||
const endIndex = options.endIndex ?? 0;
|
||||
const matchLimit = options.matchLimit ?? 0xFFFFFFFF;
|
||||
const maxStartDepth = options.maxStartDepth ?? 0xFFFFFFFF;
|
||||
const timeoutMicros = options.timeoutMicros ?? 0n;
|
||||
const progressCallback = options.progressCallback;
|
||||
|
||||
if (typeof matchLimit !== 'number') {
|
||||
|
|
@ -839,7 +825,6 @@ export class Query {
|
|||
endIndex,
|
||||
matchLimit,
|
||||
maxStartDepth,
|
||||
timeoutMicros,
|
||||
);
|
||||
|
||||
const count = C.getValue(TRANSFER_BUFFER, 'i32');
|
||||
|
|
|
|||
|
|
@ -461,17 +461,6 @@ describe('Query', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Set a timeout', () => {
|
||||
it('returns less than the expected matches', { timeout: 10000 }, () => {
|
||||
tree = parser.parse('function foo() while (true) { } }\n'.repeat(1000))!;
|
||||
query = new Query(JavaScript, '(function_declaration name: (identifier) @function)');
|
||||
const matches = query.matches(tree.rootNode, { timeoutMicros: 1000n });
|
||||
expect(matches.length).toBeLessThan(1000);
|
||||
const matches2 = query.matches(tree.rootNode, { timeoutMicros: 0n });
|
||||
expect(matches2).toHaveLength(1000);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Start and end indices for patterns', () => {
|
||||
it('Returns the start and end indices for a pattern', () => {
|
||||
const patterns1 = `
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue