tree-sitter
Advanced tools
Comparing version 0.21.1 to 0.22.0
38
index.js
@@ -264,2 +264,7 @@ const binding = require('node-gyp-build')(__dirname); | ||
fieldNameForNamedChild(namedChildIndex) { | ||
marshalNode(this); | ||
return NodeMethods.fieldNameForNamedChild(this.tree, namedChildIndex); | ||
} | ||
childrenForFieldName(fieldName) { | ||
@@ -285,2 +290,7 @@ marshalNode(this); | ||
childWithDescendant(descendant) { | ||
marshalNodes([this, descendant]); | ||
return unmarshalNode(NodeMethods.childWithDescendant(this.tree, descendant.tree), this.tree); | ||
} | ||
namedDescendantForIndex(start, end) { | ||
@@ -550,3 +560,3 @@ marshalNode(this); | ||
: nodes.some(text => test(text, isPositive)) | ||
}); | ||
}); | ||
break; | ||
@@ -587,3 +597,3 @@ | ||
); | ||
stringValues = []; | ||
const stringValues = []; | ||
for (let k = THIRD; k < 2 * stepsLength; k += 2) { | ||
@@ -626,3 +636,4 @@ if (steps[k] !== PREDICATE_STEP_TYPE.STRING) throw new Error( | ||
matchLimit = 0xFFFFFFFF, | ||
maxStartDepth = 0xFFFFFFFF | ||
maxStartDepth = 0xFFFFFFFF, | ||
timeoutMicros = 0 | ||
} = {} | ||
@@ -634,3 +645,3 @@ ) { | ||
endPosition.row, endPosition.column, | ||
startIndex, endIndex, matchLimit, maxStartDepth | ||
startIndex, endIndex, matchLimit, maxStartDepth, timeoutMicros | ||
); | ||
@@ -677,3 +688,4 @@ const nodes = unmarshalNodes(returnedNodes, node.tree); | ||
matchLimit = 0xFFFFFFFF, | ||
maxStartDepth = 0xFFFFFFFF | ||
maxStartDepth = 0xFFFFFFFF, | ||
timeoutMicros = 0, | ||
} = {} | ||
@@ -685,3 +697,3 @@ ) { | ||
endPosition.row, endPosition.column, | ||
startIndex, endIndex, matchLimit, maxStartDepth | ||
startIndex, endIndex, matchLimit, maxStartDepth, timeoutMicros | ||
); | ||
@@ -821,12 +833,18 @@ const nodes = unmarshalNodes(returnedNodes, node.tree); | ||
function marshalNode(node) { | ||
if (!(node.tree instanceof Tree)){ | ||
function marshalNode(node, offset = 0) { | ||
if (!(node.tree instanceof Tree)) { | ||
throw new TypeError("SyntaxNode must belong to a Tree") | ||
} | ||
const {nodeTransferArray} = binding; | ||
const { nodeTransferArray } = binding; | ||
for (let i = 0; i < NODE_FIELD_COUNT; i++) { | ||
nodeTransferArray[i] = node[i]; | ||
nodeTransferArray[offset * NODE_FIELD_COUNT + i] = node[i]; | ||
} | ||
} | ||
function marshalNodes(nodes) { | ||
for (let i = 0, { length } = nodes; i < length; i++) { | ||
marshalNode(nodes[i], i); | ||
} | ||
} | ||
function unmarshalPoint() { | ||
@@ -833,0 +851,0 @@ return {row: pointTransferArray[0], column: pointTransferArray[1]}; |
{ | ||
"name": "tree-sitter", | ||
"version": "0.21.1", | ||
"version": "0.22.0", | ||
"description": "Incremental parsers for node", | ||
@@ -32,22 +32,22 @@ "author": "Max Brunsfeld", | ||
"dependencies": { | ||
"node-addon-api": "^8.0.0", | ||
"node-gyp-build": "^4.8.0" | ||
"node-addon-api": "^8.2.1", | ||
"node-gyp-build": "^4.8.2" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.11.30", | ||
"chai": "^4.3.10", | ||
"jest": "^29.7.0", | ||
"mocha": "^8.4.0", | ||
"node-gyp": "^10.0.1", | ||
"prebuildify": "^6.0.0", | ||
"@types/node": "^22.7.8", | ||
"@types/tmp": "^0.2.6", | ||
"glob": "^11.0.0", | ||
"node-gyp": "^10.2.0", | ||
"prebuildify": "^6.0.1", | ||
"tmp": "^0.2.3", | ||
"tree-sitter-c": "github:amaanq/tree-sitter-c#napi", | ||
"tree-sitter-embedded-template": "github:tree-sitter/tree-sitter-embedded-template#napi", | ||
"tree-sitter-html": "github:amaanq/tree-sitter-html#napi", | ||
"tree-sitter-java": "github:amaanq/tree-sitter-java#napi", | ||
"tree-sitter-javascript": "github:amaanq/tree-sitter-javascript#napi", | ||
"tree-sitter-json": "github:tree-sitter/tree-sitter-json#napi", | ||
"tree-sitter-python": "github:amaanq/tree-sitter-python#napi", | ||
"tree-sitter-ruby": "github:tree-sitter/tree-sitter-ruby#napi", | ||
"tree-sitter-rust": "github:amaanq/tree-sitter-rust#napi" | ||
"tree-sitter-c": "^0.23.1", | ||
"tree-sitter-embedded-template": "^0.23.0", | ||
"tree-sitter-html": "^0.23.0", | ||
"tree-sitter-java": "^0.23.2", | ||
"tree-sitter-javascript": "^0.23.0", | ||
"tree-sitter-json": "^0.23.0", | ||
"tree-sitter-php": "^0.23.4", | ||
"tree-sitter-python": "^0.23.2", | ||
"tree-sitter-ruby": "^0.23.0", | ||
"tree-sitter-rust": "^0.23.0" | ||
}, | ||
@@ -57,4 +57,6 @@ "scripts": { | ||
"build": "prebuildify --napi --strip", | ||
"build_x64": "prebuildify --napi --strip --arch x64", | ||
"build_arm64": "prebuildify --napi --strip --arch arm64", | ||
"rebuild": "node-gyp rebuild", | ||
"test": "mocha && jest" | ||
"test": "node -e \"require('child_process').spawnSync('node', ['--test', ...require('glob').sync('test/**/*.js')], {stdio:'inherit'})\"" | ||
}, | ||
@@ -61,0 +63,0 @@ "publishConfig": { |
declare module "tree-sitter" { | ||
class Parser { | ||
parse(input: string | Parser.Input, oldTree?: Parser.Tree, options?: Parser.Options): Parser.Tree; | ||
parse(input: string | Parser.Input, oldTree?: Parser.Tree | null, options?: Parser.Options): Parser.Tree; | ||
getIncludedRanges(): Parser.Range[]; | ||
@@ -11,3 +11,3 @@ getTimeoutMicros(): number; | ||
getLogger(): Parser.Logger; | ||
setLogger(logFunc?: Parser.Logger | false | null): void; | ||
setLogger(logFunc?: Parser.Logger | string | false | null): void; | ||
printDotGraphs(enabled?: boolean, fd?: number): void; | ||
@@ -49,3 +49,3 @@ } | ||
export interface Input { | ||
(index: number, position?: Point): string | null; | ||
(index: number, position?: Point): string | null | undefined | {}; | ||
} | ||
@@ -94,2 +94,3 @@ | ||
fieldNameForChild(childIndex: number): string | null; | ||
fieldNameForNamedChild(namedChildIndex: number): string | null; | ||
childrenForFieldName(fieldName: string): Array<SyntaxNode>; | ||
@@ -100,2 +101,3 @@ childrenForFieldId(fieldId: number): Array<SyntaxNode>; | ||
childWithDescendant(descendant: SyntaxNode): SyntaxNode | null; | ||
descendantForIndex(index: number): SyntaxNode; | ||
@@ -150,5 +152,6 @@ descendantForIndex(startIndex: number, endIndex: number): SyntaxNode; | ||
walk(): TreeCursor; | ||
getText(node: SyntaxNode): string; | ||
getChangedRanges(other: Tree): Range[]; | ||
getIncludedRanges(): Range[]; | ||
getEditedRange(other: Tree): Range; | ||
getEditedRange(): Range; | ||
printDotGraph(fd?: number): void; | ||
@@ -159,3 +162,2 @@ } | ||
name: string; | ||
text?: string; | ||
node: SyntaxNode; | ||
@@ -170,2 +172,5 @@ setProperties?: { [prop: string]: string | null }; | ||
captures: QueryCapture[]; | ||
setProperties?: { [prop: string]: string | null }; | ||
assertedProperties?: { [prop: string]: string | null }; | ||
refutedProperties?: { [prop: string]: string | null }; | ||
} | ||
@@ -180,2 +185,3 @@ | ||
maxStartDepth?: number; | ||
timeoutMicros?: number; | ||
}; | ||
@@ -205,9 +211,11 @@ | ||
startIndexForPattern(patternIndex: number): number; | ||
endIndexForPattern(patternIndex: number): number; | ||
didExceedMatchLimit(): boolean; | ||
} | ||
export class LookaheadIterable { | ||
export class LookaheadIterator { | ||
readonly currentTypeId: number; | ||
readonly currentType: string; | ||
constructor(language: any, state: number); | ||
reset(language: any, stateId: number): boolean; | ||
@@ -214,0 +222,0 @@ resetState(stateId: number): boolean; |
@@ -19,6 +19,7 @@ "calloc", | ||
"strcmp", | ||
"strlen", | ||
"strncat", | ||
"strncmp", | ||
"strlen", | ||
"strncpy", | ||
"towlower", | ||
"towupper", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3739346
976
8
Updatednode-addon-api@^8.2.1
Updatednode-gyp-build@^4.8.2