From e5ef2f2aa3c6d2cafcdd01e81f0852cb4cd21280 Mon Sep 17 00:00:00 2001 From: Jim Hester Date: Mon, 7 Dec 2020 09:05:03 -0500 Subject: [PATCH 1/3] Add link to R tree sitter grammar --- docs/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/index.md b/docs/index.md index eca3f1a9..1293ec48 100644 --- a/docs/index.md +++ b/docs/index.md @@ -46,6 +46,7 @@ Parsers for these languages are fairly complete: * [Python](https://github.com/tree-sitter/tree-sitter-python) * [Ruby](https://github.com/tree-sitter/tree-sitter-ruby) * [Rust](https://github.com/tree-sitter/tree-sitter-rust) +* [R](https://github.com/r-lib/tree-sitter-r) * [SystemRDL](https://github.com/SystemRDL/tree-sitter-systemrdl) * [TOML](https://github.com/ikatyang/tree-sitter-toml) * [TypeScript](https://github.com/tree-sitter/tree-sitter-typescript) From 0f492e4254aab125d5828ed95a506ddb684c9201 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 11 Dec 2020 13:47:20 -0800 Subject: [PATCH 2/3] Include ts_tree_copy in wasm build Fixes #846 --- lib/binding_web/exports.json | 1 + lib/binding_web/test/tree-test.js | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/binding_web/exports.json b/lib/binding_web/exports.json index 72105158..d0173f3a 100644 --- a/lib/binding_web/exports.json +++ b/lib/binding_web/exports.json @@ -79,6 +79,7 @@ "_ts_query_predicates_for_pattern", "_ts_query_string_count", "_ts_query_string_value_for_id", + "_ts_tree_copy", "_ts_tree_cursor_current_field_id_wasm", "_ts_tree_cursor_current_node_id_wasm", "_ts_tree_cursor_current_node_is_missing_wasm", diff --git a/lib/binding_web/test/tree-test.js b/lib/binding_web/test/tree-test.js index ccb7a830..8c04e63e 100644 --- a/lib/binding_web/test/tree-test.js +++ b/lib/binding_web/test/tree-test.js @@ -323,6 +323,31 @@ describe("Tree", () => { assert(!cursor.gotoParent()); }) }); + + describe(".copy", () => { + it("creates another tree that remains stable if the original tree is edited", () => { + input = 'abc + cde'; + tree = parser.parse(input); + assert.equal( + tree.rootNode.toString(), + "(program (expression_statement (binary_expression left: (identifier) right: (identifier))))" + ); + + const tree2 = tree.copy(); + ([input, edit] = spliceInput(input, 3, 0, '123')); + assert.equal(input, 'abc123 + cde'); + tree.edit(edit); + + const leftNode = tree.rootNode.firstChild.firstChild.firstChild; + const leftNode2 = tree2.rootNode.firstChild.firstChild.firstChild; + const rightNode = tree.rootNode.firstChild.firstChild.lastChild; + const rightNode2 = tree2.rootNode.firstChild.firstChild.lastChild; + assert.equal(leftNode.endIndex, 6) + assert.equal(leftNode2.endIndex, 3) + assert.equal(rightNode.startIndex, 9) + assert.equal(rightNode2.startIndex, 6) + }); + }); }); function spliceInput(input, startIndex, lengthRemoved, newText) { From d6cfe3ed1d7b02363fa62ae1819c16921e8dd861 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 11 Dec 2020 15:57:32 -0800 Subject: [PATCH 3/3] web: 0.18 --- lib/binding_web/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/binding_web/package.json b/lib/binding_web/package.json index 8c61cf75..25aeb862 100644 --- a/lib/binding_web/package.json +++ b/lib/binding_web/package.json @@ -1,6 +1,6 @@ { "name": "web-tree-sitter", - "version": "0.17.1", + "version": "0.18.0", "description": "Tree-sitter bindings for the web", "main": "tree-sitter.js", "types": "tree-sitter-web.d.ts",