tree-sitter
Advanced tools
Comparing version 0.20.5 to 0.20.6
94
index.js
@@ -23,16 +23,33 @@ let binding; | ||
get() { | ||
return unmarshalNode(rootNode.call(this), this); | ||
} | ||
/* | ||
Due to a race condition arising from Jest's worker pool, "this" | ||
has no knowledge of the native extension if the extension has not | ||
yet loaded when multiple Jest tests are being run simultaneously. | ||
If the extension has correctly loaded, "this" should be an instance | ||
of the class whose prototype we are acting on (in this case, Tree). | ||
Furthermore, the race condition sometimes results in the function in | ||
question being undefined even when the context is correct, so we also | ||
perform a null function check. | ||
*/ | ||
if (this instanceof Tree && rootNode) { | ||
return unmarshalNode(rootNode.call(this), this); | ||
} | ||
}, | ||
// Jest worker pool may attempt to override property due to race condition, | ||
// we don't want to error on this | ||
configurable: true | ||
}); | ||
Tree.prototype.edit = function(arg) { | ||
edit.call( | ||
this, | ||
arg.startPosition.row, arg.startPosition.column, | ||
arg.oldEndPosition.row, arg.oldEndPosition.column, | ||
arg.newEndPosition.row, arg.newEndPosition.column, | ||
arg.startIndex, | ||
arg.oldEndIndex, | ||
arg.newEndIndex | ||
); | ||
if (this instanceof Tree && edit) { | ||
edit.call( | ||
this, | ||
arg.startPosition.row, arg.startPosition.column, | ||
arg.oldEndPosition.row, arg.oldEndPosition.column, | ||
arg.newEndPosition.row, arg.newEndPosition.column, | ||
arg.startIndex, | ||
arg.oldEndIndex, | ||
arg.newEndIndex | ||
); | ||
} | ||
}; | ||
@@ -260,3 +277,5 @@ | ||
Parser.prototype.setLanguage = function(language) { | ||
setLanguage.call(this, language); | ||
if (this instanceof Parser && setLanguage) { | ||
setLanguage.call(this, language); | ||
} | ||
this[languageSymbol] = language; | ||
@@ -282,9 +301,11 @@ if (!language.nodeSubclasses) { | ||
} | ||
const tree = parse.call( | ||
this, | ||
input, | ||
oldTree, | ||
bufferSize, | ||
includedRanges | ||
); | ||
const tree = this instanceof Parser && parse | ||
? parse.call( | ||
this, | ||
input, | ||
oldTree, | ||
bufferSize, | ||
includedRanges) | ||
: undefined; | ||
if (tree) { | ||
@@ -307,16 +328,25 @@ tree.input = treeInput | ||
get() { | ||
return unmarshalNode(currentNode.call(this), this.tree); | ||
} | ||
if (this instanceof TreeCursor && currentNode) { | ||
return unmarshalNode(currentNode.call(this), this.tree); | ||
} | ||
}, | ||
configurable: true | ||
}, | ||
startPosition: { | ||
get() { | ||
startPosition.call(this); | ||
return unmarshalPoint(); | ||
} | ||
if (this instanceof TreeCursor && startPosition) { | ||
startPosition.call(this); | ||
return unmarshalPoint(); | ||
} | ||
}, | ||
configurable: true | ||
}, | ||
endPosition: { | ||
get() { | ||
endPosition.call(this); | ||
return unmarshalPoint(); | ||
} | ||
if (this instanceof TreeCursor && endPosition) { | ||
endPosition.call(this); | ||
return unmarshalPoint(); | ||
} | ||
}, | ||
configurable: true | ||
}, | ||
@@ -326,3 +356,4 @@ nodeText: { | ||
return this.tree.getText(this) | ||
} | ||
}, | ||
configurable: true | ||
} | ||
@@ -333,3 +364,5 @@ }); | ||
marshalNode(node); | ||
reset.call(this); | ||
if (this instanceof TreeCursor && reset) { | ||
reset.call(this); | ||
} | ||
} | ||
@@ -637,2 +670,5 @@ | ||
function marshalNode(node) { | ||
if (!(node.tree instanceof Tree)){ | ||
throw new TypeError("SyntaxNode must belong to a Tree") | ||
} | ||
const {nodeTransferArray} = binding; | ||
@@ -639,0 +675,0 @@ for (let i = 0; i < NODE_FIELD_COUNT; i++) { |
{ | ||
"name": "tree-sitter", | ||
"version": "0.20.5", | ||
"version": "0.20.6", | ||
"description": "Incremental parsers for node", | ||
@@ -18,18 +18,14 @@ "author": "Max Brunsfeld", | ||
"dependencies": { | ||
"nan": "^2.17.0", | ||
"nan": "^2.18.0", | ||
"prebuild-install": "^7.1.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.3.1", | ||
"chai": "^4.3.7", | ||
"@types/node": "^20.5.9", | ||
"chai": "^4.3.8", | ||
"jest": "^24.0.0", | ||
"mocha": "^8.4.0", | ||
"node-gyp": "^9.4.0", | ||
"prebuild": "^11.0.4", | ||
"prebuild": "^12.0.0", | ||
"tree-sitter-javascript": "https://github.com/tree-sitter/tree-sitter-javascript.git#master" | ||
}, | ||
"overrides": { | ||
"prebuild": { | ||
"node-gyp": "$node-gyp" | ||
} | ||
}, | ||
"scripts": { | ||
@@ -40,4 +36,4 @@ "install": "prebuild-install || node-gyp rebuild", | ||
"prebuild:upload": "prebuild --upload-all", | ||
"test": "mocha" | ||
"test": "mocha && jest" | ||
} | ||
} |
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
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
630808
76
1007
7
Updatednan@^2.18.0