feat(web)!: remove deprecated functions
This commit is contained in:
parent
d60ef9ad0a
commit
580cd9541a
7 changed files with 8 additions and 94 deletions
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue