Skip to content

Commit 70bf7a0

Browse files
committed
chore: migrate from github.com/smacker/go-tree-sitter to github.com/tree-sitter/go-tree-sitter
1 parent f8a7402 commit 70bf7a0

File tree

10 files changed

+228
-47
lines changed

10 files changed

+228
-47
lines changed

gazelle/MODULE.bazel

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,25 @@ local_path_override(
1717

1818
go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
1919
go_deps.from_file(go_mod = "//:go.mod")
20+
go_deps.module_override(
21+
patches = ["//patches:go-tree-sitter-cc_library.patch"],
22+
path = "github.com/tree-sitter/go-tree-sitter",
23+
patch_strip = 1,
24+
)
25+
go_deps.module_override(
26+
path = "github.com/tree-sitter/tree-sitter-python",
27+
patches = ["//patches:tree-sitter-python-cc_library.patch"],
28+
patch_strip = 1,
29+
)
2030
use_repo(
2131
go_deps,
2232
"com_github_bazelbuild_buildtools",
2333
"com_github_bmatcuk_doublestar_v4",
24-
"com_github_smacker_go_tree_sitter",
2534
"com_github_emirpasic_gods",
2635
"com_github_ghodss_yaml",
2736
"com_github_stretchr_testify",
37+
"com_github_tree_sitter_go_tree_sitter",
38+
"com_github_tree_sitter_tree_sitter_python",
2839
"in_gopkg_yaml_v2",
2940
"org_golang_x_sync",
3041
)

gazelle/deps.bzl

Lines changed: 96 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ def go_deps():
169169
sum = "h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=",
170170
version = "v0.5.9",
171171
)
172+
go_repository(
173+
name = "com_github_mattn_go_pointer",
174+
importpath = "github.com/mattn/go-pointer",
175+
sum = "h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0=",
176+
version = "v0.0.1",
177+
)
178+
172179
go_repository(
173180
name = "com_github_pmezard_go_difflib",
174181
importpath = "github.com/pmezard/go-difflib",
@@ -182,12 +189,7 @@ def go_deps():
182189
sum = "h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM=",
183190
version = "v0.0.0-20190812154241-14fe0d1b01d4",
184191
)
185-
go_repository(
186-
name = "com_github_smacker_go_tree_sitter",
187-
importpath = "github.com/smacker/go-tree-sitter",
188-
sum = "h1:6C8qej6f1bStuePVkLSFxoU22XBS165D3klxlzRg8F4=",
189-
version = "v0.0.0-20240827094217-dd81d9e9be82",
190-
)
192+
191193
go_repository(
192194
name = "com_github_stretchr_objx",
193195
importpath = "github.com/stretchr/objx",
@@ -197,8 +199,94 @@ def go_deps():
197199
go_repository(
198200
name = "com_github_stretchr_testify",
199201
importpath = "github.com/stretchr/testify",
200-
sum = "h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=",
201-
version = "v1.9.0",
202+
sum = "h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=",
203+
version = "v1.10.0",
204+
)
205+
go_repository(
206+
name = "com_github_tree_sitter_go_tree_sitter",
207+
importpath = "github.com/tree-sitter/go-tree-sitter",
208+
sum = "h1:sx6kcg8raRFCvc9BnXglke6axya12krCJF5xJ2sftRU=",
209+
version = "v0.25.0",
210+
patches = [
211+
"//patches:go-tree-sitter-cc_library.patch", # keep
212+
],
213+
patch_strip = 1, # keep
214+
)
215+
go_repository(
216+
name = "com_github_tree_sitter_tree_sitter_c",
217+
importpath = "github.com/tree-sitter/tree-sitter-c",
218+
sum = "h1:nBPH3FV07DzAD7p0GfNvXM+Y7pNIoPenQWBpvM++t4c=",
219+
version = "v0.23.4",
220+
)
221+
go_repository(
222+
name = "com_github_tree_sitter_tree_sitter_cpp",
223+
importpath = "github.com/tree-sitter/tree-sitter-cpp",
224+
sum = "h1:LaWZsiqQKvR65yHgKmnaqA+uz6tlDJTJFCyFIeZU/8w=",
225+
version = "v0.23.4",
226+
)
227+
go_repository(
228+
name = "com_github_tree_sitter_tree_sitter_embedded_template",
229+
importpath = "github.com/tree-sitter/tree-sitter-embedded-template",
230+
sum = "h1:nFkkH6Sbe56EXLmZBqHHcamTpmz3TId97I16EnGy4rg=",
231+
version = "v0.23.2",
232+
)
233+
go_repository(
234+
name = "com_github_tree_sitter_tree_sitter_go",
235+
importpath = "github.com/tree-sitter/tree-sitter-go",
236+
sum = "h1:yt5KMGnTHS+86pJmLIAZMWxukr8W7Ae1STPvQUuNROA=",
237+
version = "v0.23.4",
238+
)
239+
go_repository(
240+
name = "com_github_tree_sitter_tree_sitter_html",
241+
importpath = "github.com/tree-sitter/tree-sitter-html",
242+
sum = "h1:1UYDV+Yd05GGRhVnTcbP58GkKLSHHZwVaN+lBZV11Lc=",
243+
version = "v0.23.2",
244+
)
245+
go_repository(
246+
name = "com_github_tree_sitter_tree_sitter_java",
247+
importpath = "github.com/tree-sitter/tree-sitter-java",
248+
sum = "h1:J9YeMGMwXYlKSP3K4Us8CitC6hjtMjqpeOf2GGo6tig=",
249+
version = "v0.23.5",
250+
)
251+
go_repository(
252+
name = "com_github_tree_sitter_tree_sitter_javascript",
253+
importpath = "github.com/tree-sitter/tree-sitter-javascript",
254+
sum = "h1:1fWupaRC0ArlHJ/QJzsfQ3Ibyopw7ZfQK4xXc40Zveo=",
255+
version = "v0.23.1",
256+
)
257+
go_repository(
258+
name = "com_github_tree_sitter_tree_sitter_json",
259+
importpath = "github.com/tree-sitter/tree-sitter-json",
260+
sum = "h1:tV5rMkihgtiOe14a9LHfDY5kzTl5GNUYe6carZBn0fQ=",
261+
version = "v0.24.8",
262+
)
263+
go_repository(
264+
name = "com_github_tree_sitter_tree_sitter_php",
265+
importpath = "github.com/tree-sitter/tree-sitter-php",
266+
sum = "h1:iHewsLNDmznh8kgGyfWfujsZxIz1YGbSd2ZTEM0ZiP8=",
267+
version = "v0.23.11",
268+
)
269+
go_repository(
270+
name = "com_github_tree_sitter_tree_sitter_python",
271+
importpath = "github.com/tree-sitter/tree-sitter-python",
272+
sum = "h1:qHnWFR5WhtMQpxBZRwiaU5Hk/29vGju6CVtmvu5Haas=",
273+
version = "v0.23.6",
274+
patches = [
275+
"//patches:tree-sitter-python-cc_library.patch", # keep
276+
],
277+
patch_strip = 1, # keep
278+
)
279+
go_repository(
280+
name = "com_github_tree_sitter_tree_sitter_ruby",
281+
importpath = "github.com/tree-sitter/tree-sitter-ruby",
282+
sum = "h1:T/NKHUA+iVbHM440hFx+lzVOzS4dV6z8Qw8ai+72bYo=",
283+
version = "v0.23.1",
284+
)
285+
go_repository(
286+
name = "com_github_tree_sitter_tree_sitter_rust",
287+
importpath = "github.com/tree-sitter/tree-sitter-rust",
288+
sum = "h1:6AtoooCW5GqNrRpfnvl0iUhxTAZEovEmLKDbyHlfw90=",
289+
version = "v0.23.2",
202290
)
203291

204292
go_repository(

gazelle/go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@ require (
99
github.com/bmatcuk/doublestar/v4 v4.7.1
1010
github.com/emirpasic/gods v1.18.1
1111
github.com/ghodss/yaml v1.0.0
12-
github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82
13-
github.com/stretchr/testify v1.9.0
12+
github.com/stretchr/testify v1.10.0
13+
github.com/tree-sitter/go-tree-sitter v0.25.0
14+
github.com/tree-sitter/tree-sitter-python v0.23.6
1415
golang.org/x/sync v0.2.0
1516
gopkg.in/yaml.v2 v2.4.0
1617
)
1718

1819
require (
1920
github.com/davecgh/go-spew v1.1.1 // indirect
2021
github.com/google/go-cmp v0.5.9 // indirect
22+
github.com/mattn/go-pointer v0.0.1 // indirect
2123
github.com/pmezard/go-difflib v1.0.0 // indirect
2224
golang.org/x/mod v0.10.0 // indirect
2325
golang.org/x/sys v0.8.0 // indirect

gazelle/go.sum

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,39 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
4040
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
4141
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
4242
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
43+
github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0=
44+
github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc=
4345
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4446
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
4547
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
46-
github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82 h1:6C8qej6f1bStuePVkLSFxoU22XBS165D3klxlzRg8F4=
47-
github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82/go.mod h1:xe4pgH49k4SsmkQq5OT8abwhWmnzkhpgnXeekbx2efw=
48-
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
49-
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
48+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
49+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
50+
github.com/tree-sitter/go-tree-sitter v0.25.0 h1:sx6kcg8raRFCvc9BnXglke6axya12krCJF5xJ2sftRU=
51+
github.com/tree-sitter/go-tree-sitter v0.25.0/go.mod h1:r77ig7BikoZhHrrsjAnv8RqGti5rtSyvDHPzgTPsUuU=
52+
github.com/tree-sitter/tree-sitter-c v0.23.4 h1:nBPH3FV07DzAD7p0GfNvXM+Y7pNIoPenQWBpvM++t4c=
53+
github.com/tree-sitter/tree-sitter-c v0.23.4/go.mod h1:MkI5dOiIpeN94LNjeCp8ljXN/953JCwAby4bClMr6bw=
54+
github.com/tree-sitter/tree-sitter-cpp v0.23.4 h1:LaWZsiqQKvR65yHgKmnaqA+uz6tlDJTJFCyFIeZU/8w=
55+
github.com/tree-sitter/tree-sitter-cpp v0.23.4/go.mod h1:doqNW64BriC7WBCQ1klf0KmJpdEvfxyXtoEybnBo6v8=
56+
github.com/tree-sitter/tree-sitter-embedded-template v0.23.2 h1:nFkkH6Sbe56EXLmZBqHHcamTpmz3TId97I16EnGy4rg=
57+
github.com/tree-sitter/tree-sitter-embedded-template v0.23.2/go.mod h1:HNPOhN0qF3hWluYLdxWs5WbzP/iE4aaRVPMsdxuzIaQ=
58+
github.com/tree-sitter/tree-sitter-go v0.23.4 h1:yt5KMGnTHS+86pJmLIAZMWxukr8W7Ae1STPvQUuNROA=
59+
github.com/tree-sitter/tree-sitter-go v0.23.4/go.mod h1:Jrx8QqYN0v7npv1fJRH1AznddllYiCMUChtVjxPK040=
60+
github.com/tree-sitter/tree-sitter-html v0.23.2 h1:1UYDV+Yd05GGRhVnTcbP58GkKLSHHZwVaN+lBZV11Lc=
61+
github.com/tree-sitter/tree-sitter-html v0.23.2/go.mod h1:gpUv/dG3Xl/eebqgeYeFMt+JLOY9cgFinb/Nw08a9og=
62+
github.com/tree-sitter/tree-sitter-java v0.23.5 h1:J9YeMGMwXYlKSP3K4Us8CitC6hjtMjqpeOf2GGo6tig=
63+
github.com/tree-sitter/tree-sitter-java v0.23.5/go.mod h1:NRKlI8+EznxA7t1Yt3xtraPk1Wzqh3GAIC46wxvc320=
64+
github.com/tree-sitter/tree-sitter-javascript v0.23.1 h1:1fWupaRC0ArlHJ/QJzsfQ3Ibyopw7ZfQK4xXc40Zveo=
65+
github.com/tree-sitter/tree-sitter-javascript v0.23.1/go.mod h1:lmGD1EJdCA+v0S1u2fFgepMg/opzSg/4pgFym2FPGAs=
66+
github.com/tree-sitter/tree-sitter-json v0.24.8 h1:tV5rMkihgtiOe14a9LHfDY5kzTl5GNUYe6carZBn0fQ=
67+
github.com/tree-sitter/tree-sitter-json v0.24.8/go.mod h1:F351KK0KGvCaYbZ5zxwx/gWWvZhIDl0eMtn+1r+gQbo=
68+
github.com/tree-sitter/tree-sitter-php v0.23.11 h1:iHewsLNDmznh8kgGyfWfujsZxIz1YGbSd2ZTEM0ZiP8=
69+
github.com/tree-sitter/tree-sitter-php v0.23.11/go.mod h1:T/kbfi+UcCywQfUNAJnGTN/fMSUjnwPXA8k4yoIks74=
70+
github.com/tree-sitter/tree-sitter-python v0.23.6 h1:qHnWFR5WhtMQpxBZRwiaU5Hk/29vGju6CVtmvu5Haas=
71+
github.com/tree-sitter/tree-sitter-python v0.23.6/go.mod h1:cpdthSy/Yoa28aJFBscFHlGiU+cnSiSh1kuDVtI8YeM=
72+
github.com/tree-sitter/tree-sitter-ruby v0.23.1 h1:T/NKHUA+iVbHM440hFx+lzVOzS4dV6z8Qw8ai+72bYo=
73+
github.com/tree-sitter/tree-sitter-ruby v0.23.1/go.mod h1:kUS4kCCQloFcdX6sdpr8p6r2rogbM6ZjTox5ZOQy8cA=
74+
github.com/tree-sitter/tree-sitter-rust v0.23.2 h1:6AtoooCW5GqNrRpfnvl0iUhxTAZEovEmLKDbyHlfw90=
75+
github.com/tree-sitter/tree-sitter-rust v0.23.2/go.mod h1:hfeGWic9BAfgTrc7Xf6FaOAguCFJRo3RBbs7QJ6D7MI=
5076
go.starlark.net v0.0.0-20210223155950-e043a3d3c984/go.mod h1:t3mmBBPzAVvK0L0n1drDmrQsJ8FoIx4INCqVMTr/Zo0=
5177
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
5278
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=

gazelle/patches/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exports_files(glob(["*.patch"]))
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
diff --git a/BUILD.bazel b/BUILD.bazel
2+
index 37704d1..b6d17a8 100755
3+
--- a/BUILD.bazel
4+
+++ b/BUILD.bazel
5+
@@ -1,5 +1,12 @@
6+
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
7+
8+
+cc_library(
9+
+ name = "clib",
10+
+ hdrs = glob(["src/**/*.h", "src/**/*.c", "include/**/*.h"]),
11+
+ includes = ["include", "src"],
12+
+ visibility = ["//:__subpackages__"],
13+
+)
14+
+
15+
go_library(
16+
name = "go-tree-sitter",
17+
srcs = [
18+
@@ -22,6 +30,7 @@ go_library(
19+
"tree_sitter.go",
20+
],
21+
cgo = True,
22+
+ cdeps = ["//:clib"],
23+
copts = ["-Iinclude -Isrc -std=c11 -D_POSIX_C_SOURCE=200112L -D_DEFAULT_SOURCE"],
24+
importpath = "github.com/tree-sitter/go-tree-sitter",
25+
visibility = ["//visibility:public"],
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
diff --git a/BUILD.bazel b/BUILD.bazel
2+
index e69de29..1f5d973 100644
3+
--- a/BUILD.bazel
4+
+++ b/BUILD.bazel
5+
@@ -0,0 +1,11 @@
6+
+filegroup(
7+
+ name = "csrcs",
8+
+ srcs = glob(["src/**/*.h"]),
9+
+ visibility = ["//visibility:public"],
10+
+)
11+
+
12+
+cc_library(
13+
+ name = "clib",
14+
+ hdrs = ["src/parser.c", "src/scanner.c"] + glob(["src/tree_sitter/*.h"]),
15+
+ visibility = ["//bindings/go:__subpackages__"],
16+
+)
17+
diff --git a/bindings/go/BUILD.bazel b/bindings/go/BUILD.bazel
18+
index f3e5232..cec7083 100644
19+
--- a/bindings/go/BUILD.bazel
20+
+++ b/bindings/go/BUILD.bazel
21+
@@ -2,9 +2,10 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
22+
23+
go_library(
24+
name = "go",
25+
- srcs = ["binding.go"],
26+
+ srcs = ["binding.go", "//:csrcs"],
27+
cgo = True,
28+
copts = ["-std=c11 -fPIC"],
29+
+ cdeps = ["//:clib"],
30+
importpath = "github.com/tree-sitter/tree-sitter-python/bindings/go",
31+
visibility = ["//visibility:public"],
32+
)

gazelle/python/BUILD.bazel

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ go_library(
2929
importpath = "github.com/bazel-contrib/rules_python/gazelle/python",
3030
visibility = ["//visibility:public"],
3131
deps = [
32-
"//manifest",
3332
"//pythonconfig",
3433
"@bazel_gazelle//config:go_default_library",
3534
"@bazel_gazelle//label:go_default_library",
@@ -42,8 +41,8 @@ go_library(
4241
"@com_github_emirpasic_gods//lists/singlylinkedlist",
4342
"@com_github_emirpasic_gods//sets/treeset",
4443
"@com_github_emirpasic_gods//utils",
45-
"@com_github_smacker_go_tree_sitter//:go-tree-sitter",
46-
"@com_github_smacker_go_tree_sitter//python",
44+
"@com_github_tree_sitter_go_tree_sitter//:go-tree-sitter",
45+
"@com_github_tree_sitter_tree_sitter_python//bindings/go",
4746
"@org_golang_x_sync//errgroup",
4847
],
4948
)

0 commit comments

Comments
 (0)