From 262c28f3ab9d3fe15366314883df7b0c6a8131e8 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Fri, 6 Jun 2025 21:57:49 +0000 Subject: [PATCH 01/29] deps(gazelle): Bump rules_go from 0.41.0 to 0.55.0 Bump `rules_go` from 0.41.0 to 0.55.0 Fixes #2956. + Run `go get github.com/bazelbuild/rules_go@v0.55.0` for version bump. + Run `go mod tidy` to clean up stale deps + Run `bazel run //:gazelle_update_repos` + Figure out http_archive hashes and apply them for WORKSPACE users. + Also bump bazel-gazelle to address a warning: + `go get github.com/bazelbuild/bazel-gazelle@v0.40.0` + > Mismatch between versions requested for module > github.com/bazelbuild/bazel-gazelle > Bazel dependency version requested in MODULE.bazel: 0.40.0 > Go module version requested in go.mod: 0.31.1 > Please resolve this mismatch to prevent discrepancies between > native Go and Bazel builds + Update CHANGELOG.md accordingly --- CHANGELOG.md | 2 + MODULE.bazel | 2 +- examples/build_file_generation/WORKSPACE | 6 +- gazelle/MODULE.bazel | 2 +- gazelle/WORKSPACE | 4 +- gazelle/deps.bzl | 214 +++++------------- gazelle/go.mod | 20 +- gazelle/go.sum | 104 ++------- .../testdata/respect_kind_mapping/BUILD.out | 2 +- internal_dev_deps.bzl | 6 +- 10 files changed, 98 insertions(+), 264 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e48e3d4f3d..47a7e91ec4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,8 @@ END_UNRELEASED_TEMPLATE * (py_wheel) py_wheel always creates zip64-capable wheel zips * (providers) (experimental) {obj}`PyInfo.venv_symlinks` replaces `PyInfo.site_packages_symlinks` +* (deps) Upgrade `rules_go` 0.41.0 -> 0.55.0. Note that this might result in a slight + reordering of load statements in gazelle-generated `BUILD(.bazel)` files. {#v0-0-0-fixed} ### Fixed diff --git a/MODULE.bazel b/MODULE.bazel index 144e130c1b..66f0abf384 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -89,7 +89,7 @@ bazel_dep(name = "other", version = "0", dev_dependency = True) # Extra gazelle plugin deps so that WORKSPACE.bzlmod can continue including it for e2e tests. # We use `WORKSPACE.bzlmod` because it is impossible to have dev-only local overrides. -bazel_dep(name = "rules_go", version = "0.41.0", dev_dependency = True, repo_name = "io_bazel_rules_go") +bazel_dep(name = "rules_go", version = "0.55.0", dev_dependency = True, repo_name = "io_bazel_rules_go") bazel_dep(name = "rules_python_gazelle_plugin", version = "0", dev_dependency = True) bazel_dep(name = "gazelle", version = "0.40.0", dev_dependency = True, repo_name = "bazel_gazelle") diff --git a/examples/build_file_generation/WORKSPACE b/examples/build_file_generation/WORKSPACE index 6681ad6861..6cc1e98410 100644 --- a/examples/build_file_generation/WORKSPACE +++ b/examples/build_file_generation/WORKSPACE @@ -20,10 +20,10 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "io_bazel_rules_go", - sha256 = "278b7ff5a826f3dc10f04feaf0b70d48b68748ccd512d7f98bf442077f043fe3", + sha256 = "c6cf9da6668ac84c470c43cbfccb8fdc844ead2b5a8b918e2816d44f2986f644", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip", - "https://github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip", + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.55.0/rules_go-v0.55.0.zip", + "https://github.com/bazelbuild/rules_go/releases/download/v0.55.0/rules_go-v0.55.0.zip", ], ) diff --git a/gazelle/MODULE.bazel b/gazelle/MODULE.bazel index 6bbc74bc61..df04269ec4 100644 --- a/gazelle/MODULE.bazel +++ b/gazelle/MODULE.bazel @@ -6,7 +6,7 @@ module( bazel_dep(name = "bazel_skylib", version = "1.6.1") bazel_dep(name = "rules_python", version = "0.18.0") -bazel_dep(name = "rules_go", version = "0.41.0", repo_name = "io_bazel_rules_go") +bazel_dep(name = "rules_go", version = "0.55.0", repo_name = "io_bazel_rules_go") bazel_dep(name = "gazelle", version = "0.33.0", repo_name = "bazel_gazelle") bazel_dep(name = "rules_cc", version = "0.0.16") diff --git a/gazelle/WORKSPACE b/gazelle/WORKSPACE index ad428b10cd..590742e6e2 100644 --- a/gazelle/WORKSPACE +++ b/gazelle/WORKSPACE @@ -6,8 +6,8 @@ http_archive( name = "io_bazel_rules_go", sha256 = "278b7ff5a826f3dc10f04feaf0b70d48b68748ccd512d7f98bf442077f043fe3", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip", - "https://github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip", + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.55.0/rules_go-v0.55.0.zip", + "https://github.com/bazelbuild/rules_go/releases/download/v0.55.0/rules_go-v0.55.0.zip", ], ) diff --git a/gazelle/deps.bzl b/gazelle/deps.bzl index 7253ef8194..918dad3b7f 100644 --- a/gazelle/deps.bzl +++ b/gazelle/deps.bzl @@ -37,108 +37,55 @@ def gazelle_deps(): def go_deps(): "Fetch go dependencies" - go_repository( - name = "co_honnef_go_tools", - importpath = "honnef.co/go/tools", - sum = "h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs=", - version = "v0.0.0-20190523083050-ea95bdfd59fc", - ) go_repository( name = "com_github_bazelbuild_bazel_gazelle", importpath = "github.com/bazelbuild/bazel-gazelle", - sum = "h1:ROyUyUHzoEdvoOs1e0haxJx1l5EjZX6AOqiKdVlaBbg=", - version = "v0.31.1", + sum = "h1:SAYys3KRG5i3KTgQAvO423bLT1rQMSgqEKReMkM/CW0=", + version = "v0.40.0", ) - go_repository( name = "com_github_bazelbuild_buildtools", build_naming_convention = "go_default_library", importpath = "github.com/bazelbuild/buildtools", - sum = "h1:HTepWP/jhtWTC1gvK0RnvKCgjh4gLqiwaOwGozAXcbw=", - version = "v0.0.0-20231103205921-433ea8554e82", + sum = "h1:FGzENZi+SX9I7h9xvMtRA3rel8hCEfyzSixteBgn7MU=", + version = "v0.0.0-20240918101019-be1c24cc9a44", ) go_repository( name = "com_github_bazelbuild_rules_go", importpath = "github.com/bazelbuild/rules_go", - sum = "h1:JzlRxsFNhlX+g4drDRPhIaU5H5LnI978wdMJ0vK4I+k=", - version = "v0.41.0", + sum = "h1:S8X/b/Oygw/Dtv7NuyW7ht0QwdynMEdXQqYigX5A1KY=", + version = "v0.55.0", ) - go_repository( name = "com_github_bmatcuk_doublestar_v4", importpath = "github.com/bmatcuk/doublestar/v4", sum = "h1:fdDeAqgT47acgwd9bd9HxJRDmc9UAmPpc+2m0CXv75Q=", version = "v4.7.1", ) - - go_repository( - name = "com_github_burntsushi_toml", - importpath = "github.com/BurntSushi/toml", - sum = "h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=", - version = "v0.3.1", - ) - go_repository( - name = "com_github_census_instrumentation_opencensus_proto", - importpath = "github.com/census-instrumentation/opencensus-proto", - sum = "h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=", - version = "v0.2.1", - ) - go_repository( - name = "com_github_chzyer_logex", - importpath = "github.com/chzyer/logex", - sum = "h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=", - version = "v1.1.10", - ) - go_repository( - name = "com_github_chzyer_readline", - importpath = "github.com/chzyer/readline", - sum = "h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=", - version = "v0.0.0-20180603132655-2972be24d48e", - ) - go_repository( - name = "com_github_chzyer_test", - importpath = "github.com/chzyer/test", - sum = "h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=", - version = "v0.0.0-20180213035817-a1ea475d72b1", - ) - go_repository( - name = "com_github_client9_misspell", - importpath = "github.com/client9/misspell", - sum = "h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=", - version = "v0.3.4", - ) go_repository( name = "com_github_davecgh_go_spew", importpath = "github.com/davecgh/go-spew", sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=", version = "v1.1.1", ) - + go_repository( + name = "com_github_dougthor42_go_tree_sitter", + importpath = "github.com/dougthor42/go-tree-sitter", + sum = "h1:b9s96BulIARx0konX36sJ5oZhWvAvjQBBntxp1eUukQ=", + version = "v0.0.0-20241210060307-2737e1d0de6b", + ) go_repository( name = "com_github_emirpasic_gods", importpath = "github.com/emirpasic/gods", sum = "h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=", version = "v1.18.1", ) - go_repository( - name = "com_github_envoyproxy_go_control_plane", - importpath = "github.com/envoyproxy/go-control-plane", - sum = "h1:4cmBvAEBNJaGARUEs3/suWRyfyBfhf7I60WBZq+bv2w=", - version = "v0.9.1-0.20191026205805-5f8ba28d4473", - ) - go_repository( - name = "com_github_envoyproxy_protoc_gen_validate", - importpath = "github.com/envoyproxy/protoc-gen-validate", - sum = "h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=", - version = "v0.1.0", - ) go_repository( name = "com_github_fsnotify_fsnotify", importpath = "github.com/fsnotify/fsnotify", - sum = "h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=", - version = "v1.6.0", + sum = "h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=", + version = "v1.8.0", ) - go_repository( name = "com_github_ghodss_yaml", importpath = "github.com/ghodss/yaml", @@ -146,28 +93,28 @@ def go_deps(): version = "v1.0.0", ) go_repository( - name = "com_github_golang_glog", - importpath = "github.com/golang/glog", - sum = "h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=", - version = "v0.0.0-20160126235308-23def4e6c14b", + name = "com_github_gogo_protobuf", + importpath = "github.com/gogo/protobuf", + sum = "h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=", + version = "v1.3.2", ) go_repository( name = "com_github_golang_mock", importpath = "github.com/golang/mock", - sum = "h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=", - version = "v1.6.0", + sum = "h1:YojYx61/OLFsiv6Rw1Z96LpldJIy31o+UHmwAUMJ6/U=", + version = "v1.7.0-rc.1", ) go_repository( name = "com_github_golang_protobuf", importpath = "github.com/golang/protobuf", - sum = "h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=", - version = "v1.5.2", + sum = "h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=", + version = "v1.5.4", ) go_repository( name = "com_github_google_go_cmp", importpath = "github.com/google/go-cmp", - sum = "h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=", - version = "v0.5.9", + sum = "h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=", + version = "v0.6.0", ) go_repository( name = "com_github_pmezard_go_difflib", @@ -175,19 +122,6 @@ def go_deps(): sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=", version = "v1.0.0", ) - - go_repository( - name = "com_github_prometheus_client_model", - importpath = "github.com/prometheus/client_model", - sum = "h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM=", - version = "v0.0.0-20190812154241-14fe0d1b01d4", - ) - go_repository( - name = "com_github_dougthor42_go_tree_sitter", - importpath = "github.com/dougthor42/go-tree-sitter", - sum = "h1:b9s96BulIARx0konX36sJ5oZhWvAvjQBBntxp1eUukQ=", - version = "v0.0.0-20241210060307-2737e1d0de6b", - ) go_repository( name = "com_github_stretchr_objx", importpath = "github.com/stretchr/objx", @@ -200,19 +134,6 @@ def go_deps(): sum = "h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=", version = "v1.9.0", ) - - go_repository( - name = "com_github_yuin_goldmark", - importpath = "github.com/yuin/goldmark", - sum = "h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=", - version = "v1.4.13", - ) - go_repository( - name = "com_google_cloud_go", - importpath = "cloud.google.com/go", - sum = "h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ=", - version = "v0.26.0", - ) go_repository( name = "in_gopkg_check_v1", importpath = "gopkg.in/check.v1", @@ -231,90 +152,71 @@ def go_deps(): sum = "h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=", version = "v3.0.1", ) - go_repository( name = "net_starlark_go", importpath = "go.starlark.net", sum = "h1:xwwDQW5We85NaTk2APgoN9202w/l0DVGp+GZMfsrh7s=", version = "v0.0.0-20210223155950-e043a3d3c984", ) - go_repository( - name = "org_golang_google_appengine", - importpath = "google.golang.org/appengine", - sum = "h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=", - version = "v1.4.0", - ) go_repository( name = "org_golang_google_genproto", importpath = "google.golang.org/genproto", - sum = "h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=", - version = "v0.0.0-20200526211855-cb27e3aa2013", + sum = "h1:387Y+JbxF52bmesc8kq1NyYIp33dnxCw6eiA7JMsTmw=", + version = "v0.0.0-20250115164207-1a7da9e5054f", ) go_repository( - name = "org_golang_google_grpc", - importpath = "google.golang.org/grpc", - sum = "h1:fPVVDxY9w++VjTZsYvXWqEf9Rqar/e+9zYfxKK+W+YU=", - version = "v1.50.0", - ) - go_repository( - name = "org_golang_google_protobuf", - importpath = "google.golang.org/protobuf", - sum = "h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=", - version = "v1.28.0", + name = "org_golang_google_genproto_googleapis_rpc", + importpath = "google.golang.org/genproto/googleapis/rpc", + sum = "h1:3UsHvIr4Wc2aW4brOaSCmcxh9ksica6fHEr8P1XhkYw=", + version = "v0.0.0-20250106144421-5f5ef82da422", ) go_repository( - name = "org_golang_x_crypto", - importpath = "golang.org/x/crypto", - sum = "h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=", - version = "v0.0.0-20190308221718-c2843e01d9a2", + name = "org_golang_google_grpc", + importpath = "google.golang.org/grpc", + sum = "h1:OgPcDAFKHnH8X3O4WcO4XUc8GRDeKsKReqbQtiCj7N8=", + version = "v1.67.3", ) go_repository( - name = "org_golang_x_exp", - importpath = "golang.org/x/exp", - sum = "h1:c2HOrn5iMezYjSlGPncknSEr/8x5LELb/ilJbXi9DEA=", - version = "v0.0.0-20190121172915-509febef88a4", + name = "org_golang_google_grpc_cmd_protoc_gen_go_grpc", + importpath = "google.golang.org/grpc/cmd/protoc-gen-go-grpc", + sum = "h1:F29+wU6Ee6qgu9TddPgooOdaqsxTMunOoj8KA5yuS5A=", + version = "v1.5.1", ) go_repository( - name = "org_golang_x_lint", - importpath = "golang.org/x/lint", - sum = "h1:XQyxROzUlZH+WIQwySDgnISgOivlhjIEwaQaJEJrrN0=", - version = "v0.0.0-20190313153728-d0100b6bd8b3", + name = "org_golang_google_protobuf", + importpath = "google.golang.org/protobuf", + sum = "h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU=", + version = "v1.36.3", ) go_repository( name = "org_golang_x_mod", importpath = "golang.org/x/mod", - sum = "h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=", - version = "v0.10.0", + sum = "h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM=", + version = "v0.23.0", ) go_repository( name = "org_golang_x_net", importpath = "golang.org/x/net", - sum = "h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=", - version = "v0.10.0", - ) - go_repository( - name = "org_golang_x_oauth2", - importpath = "golang.org/x/oauth2", - sum = "h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=", - version = "v0.0.0-20180821212333-d2e6202438be", + sum = "h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=", + version = "v0.35.0", ) go_repository( name = "org_golang_x_sync", importpath = "golang.org/x/sync", - sum = "h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=", - version = "v0.2.0", + sum = "h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=", + version = "v0.11.0", ) go_repository( name = "org_golang_x_sys", importpath = "golang.org/x/sys", - sum = "h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=", - version = "v0.8.0", + sum = "h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=", + version = "v0.30.0", ) go_repository( name = "org_golang_x_text", importpath = "golang.org/x/text", - sum = "h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=", - version = "v0.3.3", + sum = "h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=", + version = "v0.22.0", ) go_repository( name = "org_golang_x_tools", @@ -322,12 +224,12 @@ def go_deps(): "gazelle:exclude **/testdata/**/*", ], importpath = "golang.org/x/tools", - sum = "h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo=", - version = "v0.9.1", + sum = "h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY=", + version = "v0.30.0", ) go_repository( - name = "org_golang_x_xerrors", - importpath = "golang.org/x/xerrors", - sum = "h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=", - version = "v0.0.0-20200804184101-5ec99f83aff1", + name = "org_golang_x_tools_go_vcs", + importpath = "golang.org/x/tools/go/vcs", + sum = "h1:cOIJqWBl99H1dH5LWizPa+0ImeeJq3t3cJjaeOWUAL4=", + version = "v0.1.0-deprecated", ) diff --git a/gazelle/go.mod b/gazelle/go.mod index 91d27fdd5a..806e6758ea 100644 --- a/gazelle/go.mod +++ b/gazelle/go.mod @@ -1,26 +1,28 @@ module github.com/bazel-contrib/rules_python/gazelle -go 1.19 +go 1.22.0 + +toolchain go1.24.2 require ( - github.com/bazelbuild/bazel-gazelle v0.31.1 - github.com/bazelbuild/buildtools v0.0.0-20231103205921-433ea8554e82 - github.com/bazelbuild/rules_go v0.41.0 + github.com/bazelbuild/bazel-gazelle v0.40.0 + github.com/bazelbuild/buildtools v0.0.0-20240918101019-be1c24cc9a44 + github.com/bazelbuild/rules_go v0.55.0 github.com/bmatcuk/doublestar/v4 v4.7.1 github.com/dougthor42/go-tree-sitter v0.0.0-20241210060307-2737e1d0de6b github.com/emirpasic/gods v1.18.1 github.com/ghodss/yaml v1.0.0 github.com/stretchr/testify v1.9.0 - golang.org/x/sync v0.2.0 + golang.org/x/sync v0.11.0 gopkg.in/yaml.v2 v2.4.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/mod v0.10.0 // indirect - golang.org/x/sys v0.8.0 // indirect - golang.org/x/tools v0.9.1 // indirect + golang.org/x/mod v0.23.0 // indirect + golang.org/x/sys v0.30.0 // indirect + golang.org/x/tools/go/vcs v0.1.0-deprecated // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/gazelle/go.sum b/gazelle/go.sum index 5acd4a6db5..829ab3a062 100644 --- a/gazelle/go.sum +++ b/gazelle/go.sum @@ -1,108 +1,36 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/bazelbuild/bazel-gazelle v0.31.1 h1:ROyUyUHzoEdvoOs1e0haxJx1l5EjZX6AOqiKdVlaBbg= -github.com/bazelbuild/bazel-gazelle v0.31.1/go.mod h1:Ul0pqz50f5wxz0QNzsZ+mrEu4AVAVJZEB5xLnHgIG9c= -github.com/bazelbuild/buildtools v0.0.0-20231103205921-433ea8554e82 h1:HTepWP/jhtWTC1gvK0RnvKCgjh4gLqiwaOwGozAXcbw= -github.com/bazelbuild/buildtools v0.0.0-20231103205921-433ea8554e82/go.mod h1:689QdV3hBP7Vo9dJMmzhoYIyo/9iMhEmHkJcnaPRCbo= -github.com/bazelbuild/rules_go v0.41.0 h1:JzlRxsFNhlX+g4drDRPhIaU5H5LnI978wdMJ0vK4I+k= -github.com/bazelbuild/rules_go v0.41.0/go.mod h1:TMHmtfpvyfsxaqfL9WnahCsXMWDMICTw7XeK9yVb+YU= -github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I= -github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= +github.com/bazelbuild/bazel-gazelle v0.40.0 h1:SAYys3KRG5i3KTgQAvO423bLT1rQMSgqEKReMkM/CW0= +github.com/bazelbuild/bazel-gazelle v0.40.0/go.mod h1:xI42W5YdKQg0g3rj1jZfdW8j1UihNmvb5KwWDdHg2ec= +github.com/bazelbuild/buildtools v0.0.0-20240918101019-be1c24cc9a44 h1:FGzENZi+SX9I7h9xvMtRA3rel8hCEfyzSixteBgn7MU= +github.com/bazelbuild/buildtools v0.0.0-20240918101019-be1c24cc9a44/go.mod h1:PLNUetjLa77TCCziPsz0EI8a6CUxgC+1jgmWv0H25tg= +github.com/bazelbuild/rules_go v0.55.0 h1:S8X/b/Oygw/Dtv7NuyW7ht0QwdynMEdXQqYigX5A1KY= +github.com/bazelbuild/rules_go v0.55.0/go.mod h1:T90Gpyq4HDFlsrvtQa2CBdHNJ2P4rAu/uUTmQbanzf0= github.com/bmatcuk/doublestar/v4 v4.7.1 h1:fdDeAqgT47acgwd9bd9HxJRDmc9UAmPpc+2m0CXv75Q= github.com/bmatcuk/doublestar/v4 v4.7.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dougthor42/go-tree-sitter v0.0.0-20241210060307-2737e1d0de6b h1:b9s96BulIARx0konX36sJ5oZhWvAvjQBBntxp1eUukQ= github.com/dougthor42/go-tree-sitter v0.0.0-20241210060307-2737e1d0de6b/go.mod h1:87UkDyPt18bTH/FvinLc/kj587VNYOdRKZT1la4T8Hg= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -go.starlark.net v0.0.0-20210223155950-e043a3d3c984/go.mod h1:t3mmBBPzAVvK0L0n1drDmrQsJ8FoIx4INCqVMTr/Zo0= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= -golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= -golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= -golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM= +golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= +golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/tools/go/vcs v0.1.0-deprecated h1:cOIJqWBl99H1dH5LWizPa+0ImeeJq3t3cJjaeOWUAL4= +golang.org/x/tools/go/vcs v0.1.0-deprecated/go.mod h1:zUrvATBAvEI9535oC0yWYsLsHIV4Z7g63sNPVMtuBy8= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/gazelle/python/testdata/respect_kind_mapping/BUILD.out b/gazelle/python/testdata/respect_kind_mapping/BUILD.out index 7c5fb0bd20..fa06e2af12 100644 --- a/gazelle/python/testdata/respect_kind_mapping/BUILD.out +++ b/gazelle/python/testdata/respect_kind_mapping/BUILD.out @@ -1,5 +1,5 @@ -load(":mytest.bzl", "my_test") load("@rules_python//python:defs.bzl", "py_library") +load(":mytest.bzl", "my_test") # gazelle:map_kind py_test my_test :mytest.bzl diff --git a/internal_dev_deps.bzl b/internal_dev_deps.bzl index f2b33e279e..390e0e6436 100644 --- a/internal_dev_deps.bzl +++ b/internal_dev_deps.bzl @@ -94,10 +94,10 @@ def rules_python_internal_deps(): # gazelle. Maybe the test should be moved to the `gazelle` workspace? http_archive( name = "io_bazel_rules_go", - sha256 = "278b7ff5a826f3dc10f04feaf0b70d48b68748ccd512d7f98bf442077f043fe3", + sha256 = "c6cf9da6668ac84c470c43cbfccb8fdc844ead2b5a8b918e2816d44f2986f644", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip", - "https://github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip", + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.55.0/rules_go-v0.55.0.zip", + "https://github.com/bazelbuild/rules_go/releases/download/v0.55.0/rules_go-v0.55.0.zip", ], ) From f8e3ffcad115bd67758a28e55e175814c1208280 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Fri, 6 Jun 2025 23:41:38 +0000 Subject: [PATCH 02/29] missed a sha --- gazelle/WORKSPACE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gazelle/WORKSPACE b/gazelle/WORKSPACE index 590742e6e2..2484f5d64e 100644 --- a/gazelle/WORKSPACE +++ b/gazelle/WORKSPACE @@ -4,7 +4,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "io_bazel_rules_go", - sha256 = "278b7ff5a826f3dc10f04feaf0b70d48b68748ccd512d7f98bf442077f043fe3", + sha256 = "c6cf9da6668ac84c470c43cbfccb8fdc844ead2b5a8b918e2816d44f2986f644", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.55.0/rules_go-v0.55.0.zip", "https://github.com/bazelbuild/rules_go/releases/download/v0.55.0/rules_go-v0.55.0.zip", From f0921ebf6c9b55a809d149711e0bcdaa25404732 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Sat, 7 Jun 2025 05:41:35 +0000 Subject: [PATCH 03/29] Bump gazelle to 0.40.0, bump go version to 1.22.0 --- CHANGELOG.md | 11 +++++++++-- examples/build_file_generation/WORKSPACE | 8 ++++---- examples/bzlmod_build_file_generation/MODULE.bazel | 2 +- gazelle/MODULE.bazel | 2 +- gazelle/WORKSPACE | 8 ++++---- internal_dev_deps.bzl | 6 +++--- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47a7e91ec4..9eec6ee522 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,8 +72,15 @@ END_UNRELEASED_TEMPLATE * (py_wheel) py_wheel always creates zip64-capable wheel zips * (providers) (experimental) {obj}`PyInfo.venv_symlinks` replaces `PyInfo.site_packages_symlinks` -* (deps) Upgrade `rules_go` 0.41.0 -> 0.55.0. Note that this might result in a slight - reordering of load statements in gazelle-generated `BUILD(.bazel)` files. +* (deps[gazelle]) Upgrade versions: + * `rules_go` 0.41.0 -> 0.55.0. + * `gazelle`: WORKSPACE and bzlmod versions now match. + * WORKSPACE: 0.31.0 -> 0.40.0 + * bzlmod: 0.33.0 -> 0.40.0 + * go: 1.19.4 -> 1.22.0 + * Note that this might result in a slight reordering of load statements in + gazelle-generated `BUILD(.bazel)` files to match the ordering set by + buildifier. {#v0-0-0-fixed} ### Fixed diff --git a/examples/build_file_generation/WORKSPACE b/examples/build_file_generation/WORKSPACE index 6cc1e98410..8d09933c36 100644 --- a/examples/build_file_generation/WORKSPACE +++ b/examples/build_file_generation/WORKSPACE @@ -30,10 +30,10 @@ http_archive( # Download the bazel_gazelle ruleset. http_archive( name = "bazel_gazelle", - sha256 = "d3fa66a39028e97d76f9e2db8f1b0c11c099e8e01bf363a923074784e451f809", + sha256 = "a80893292ae1d78eaeedd50d1cab98f242a17e3d5741b1b9fb58b5fd9d2d57bc", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.33.0/bazel-gazelle-v0.33.0.tar.gz", - "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.33.0/bazel-gazelle-v0.33.0.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.40.0/bazel-gazelle-v0.40.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.40.0/bazel-gazelle-v0.40.0.tar.gz", ], ) @@ -49,7 +49,7 @@ go_rules_dependencies() # go_rules_dependencies is a function that registers external dependencies # needed by the Go rules. # See: https://github.com/bazelbuild/rules_go/blob/master/go/dependencies.rst#go_rules_dependencies -go_register_toolchains(version = "1.19.4") +go_register_toolchains(version = "1.22.0") # The following call configured the gazelle dependencies, Go environment and Go SDK. gazelle_dependencies() diff --git a/examples/bzlmod_build_file_generation/MODULE.bazel b/examples/bzlmod_build_file_generation/MODULE.bazel index b9b428d365..1aedbc3e6c 100644 --- a/examples/bzlmod_build_file_generation/MODULE.bazel +++ b/examples/bzlmod_build_file_generation/MODULE.bazel @@ -38,7 +38,7 @@ local_path_override( # The following stanza defines the dependency for gazelle # See here https://github.com/bazelbuild/bazel-gazelle/releases/ for the # latest version. -bazel_dep(name = "gazelle", version = "0.30.0", repo_name = "bazel_gazelle") +bazel_dep(name = "gazelle", version = "0.40.0", repo_name = "bazel_gazelle") # The following stanze returns a proxy object representing a module extension; # its methods can be invoked to create module extension tags. diff --git a/gazelle/MODULE.bazel b/gazelle/MODULE.bazel index df04269ec4..aae228b5d9 100644 --- a/gazelle/MODULE.bazel +++ b/gazelle/MODULE.bazel @@ -7,7 +7,7 @@ module( bazel_dep(name = "bazel_skylib", version = "1.6.1") bazel_dep(name = "rules_python", version = "0.18.0") bazel_dep(name = "rules_go", version = "0.55.0", repo_name = "io_bazel_rules_go") -bazel_dep(name = "gazelle", version = "0.33.0", repo_name = "bazel_gazelle") +bazel_dep(name = "gazelle", version = "0.40.0", repo_name = "bazel_gazelle") bazel_dep(name = "rules_cc", version = "0.0.16") local_path_override( diff --git a/gazelle/WORKSPACE b/gazelle/WORKSPACE index 2484f5d64e..dac255ddeb 100644 --- a/gazelle/WORKSPACE +++ b/gazelle/WORKSPACE @@ -13,10 +13,10 @@ http_archive( http_archive( name = "bazel_gazelle", - sha256 = "29d5dafc2a5582995488c6735115d1d366fcd6a0fc2e2a153f02988706349825", + sha256 = "a80893292ae1d78eaeedd50d1cab98f242a17e3d5741b1b9fb58b5fd9d2d57bc", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.31.0/bazel-gazelle-v0.31.0.tar.gz", - "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.31.0/bazel-gazelle-v0.31.0.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.40.0/bazel-gazelle-v0.40.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.40.0/bazel-gazelle-v0.40.0.tar.gz", ], ) @@ -25,7 +25,7 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_depe go_rules_dependencies() -go_register_toolchains(version = "1.19.4") +go_register_toolchains(version = "1.22.0") gazelle_dependencies() diff --git a/internal_dev_deps.bzl b/internal_dev_deps.bzl index 390e0e6436..c803f9e918 100644 --- a/internal_dev_deps.bzl +++ b/internal_dev_deps.bzl @@ -103,10 +103,10 @@ def rules_python_internal_deps(): http_archive( name = "bazel_gazelle", - sha256 = "727f3e4edd96ea20c29e8c2ca9e8d2af724d8c7778e7923a854b2c80952bc405", + sha256 = "a80893292ae1d78eaeedd50d1cab98f242a17e3d5741b1b9fb58b5fd9d2d57bc", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz", - "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.40.0/bazel-gazelle-v0.40.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.40.0/bazel-gazelle-v0.40.0.tar.gz", ], ) From 57ab7b67ddf220ba2badeca63127f1624107be88 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Thu, 12 Jun 2025 03:27:40 +0000 Subject: [PATCH 04/29] Maybe bumping gazelle to 0.42.0 helps? --- gazelle/MODULE.bazel | 2 +- gazelle/WORKSPACE | 8 ++++---- gazelle/deps.bzl | 8 ++++---- gazelle/go.mod | 4 ++-- gazelle/go.sum | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gazelle/MODULE.bazel b/gazelle/MODULE.bazel index aae228b5d9..ac9e26ab6e 100644 --- a/gazelle/MODULE.bazel +++ b/gazelle/MODULE.bazel @@ -7,7 +7,7 @@ module( bazel_dep(name = "bazel_skylib", version = "1.6.1") bazel_dep(name = "rules_python", version = "0.18.0") bazel_dep(name = "rules_go", version = "0.55.0", repo_name = "io_bazel_rules_go") -bazel_dep(name = "gazelle", version = "0.40.0", repo_name = "bazel_gazelle") +bazel_dep(name = "gazelle", version = "0.42.0", repo_name = "bazel_gazelle") bazel_dep(name = "rules_cc", version = "0.0.16") local_path_override( diff --git a/gazelle/WORKSPACE b/gazelle/WORKSPACE index dac255ddeb..80b505a3ec 100644 --- a/gazelle/WORKSPACE +++ b/gazelle/WORKSPACE @@ -13,10 +13,10 @@ http_archive( http_archive( name = "bazel_gazelle", - sha256 = "a80893292ae1d78eaeedd50d1cab98f242a17e3d5741b1b9fb58b5fd9d2d57bc", + sha256 = "5d80e62a70314f39cc764c1c3eaa800c5936c9f1ea91625006227ce4d20cd086", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.40.0/bazel-gazelle-v0.40.0.tar.gz", - "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.40.0/bazel-gazelle-v0.40.0.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.42.0/bazel-gazelle-v0.42.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.42.0/bazel-gazelle-v0.42.0.tar.gz", ], ) @@ -25,7 +25,7 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_depe go_rules_dependencies() -go_register_toolchains(version = "1.22.0") +go_register_toolchains(version = "1.22.9") gazelle_dependencies() diff --git a/gazelle/deps.bzl b/gazelle/deps.bzl index 918dad3b7f..457f71f1a9 100644 --- a/gazelle/deps.bzl +++ b/gazelle/deps.bzl @@ -40,8 +40,8 @@ def go_deps(): go_repository( name = "com_github_bazelbuild_bazel_gazelle", importpath = "github.com/bazelbuild/bazel-gazelle", - sum = "h1:SAYys3KRG5i3KTgQAvO423bLT1rQMSgqEKReMkM/CW0=", - version = "v0.40.0", + sum = "h1:BpkUzE3H2l6buJYFTKgzVMecJimQgWwYud25qVIx0SQ=", + version = "v0.42.0", ) go_repository( name = "com_github_bazelbuild_buildtools", @@ -83,8 +83,8 @@ def go_deps(): go_repository( name = "com_github_fsnotify_fsnotify", importpath = "github.com/fsnotify/fsnotify", - sum = "h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=", - version = "v1.8.0", + sum = "h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=", + version = "v1.7.0", ) go_repository( name = "com_github_ghodss_yaml", diff --git a/gazelle/go.mod b/gazelle/go.mod index 806e6758ea..a8eff54949 100644 --- a/gazelle/go.mod +++ b/gazelle/go.mod @@ -1,11 +1,11 @@ module github.com/bazel-contrib/rules_python/gazelle -go 1.22.0 +go 1.22.9 toolchain go1.24.2 require ( - github.com/bazelbuild/bazel-gazelle v0.40.0 + github.com/bazelbuild/bazel-gazelle v0.42.0 github.com/bazelbuild/buildtools v0.0.0-20240918101019-be1c24cc9a44 github.com/bazelbuild/rules_go v0.55.0 github.com/bmatcuk/doublestar/v4 v4.7.1 diff --git a/gazelle/go.sum b/gazelle/go.sum index 829ab3a062..201e9a826c 100644 --- a/gazelle/go.sum +++ b/gazelle/go.sum @@ -1,5 +1,5 @@ -github.com/bazelbuild/bazel-gazelle v0.40.0 h1:SAYys3KRG5i3KTgQAvO423bLT1rQMSgqEKReMkM/CW0= -github.com/bazelbuild/bazel-gazelle v0.40.0/go.mod h1:xI42W5YdKQg0g3rj1jZfdW8j1UihNmvb5KwWDdHg2ec= +github.com/bazelbuild/bazel-gazelle v0.42.0 h1:BpkUzE3H2l6buJYFTKgzVMecJimQgWwYud25qVIx0SQ= +github.com/bazelbuild/bazel-gazelle v0.42.0/go.mod h1:SRCc60YGZ27y+BqLzQ+nMh249+FyZz7YtX/V2ng+/z4= github.com/bazelbuild/buildtools v0.0.0-20240918101019-be1c24cc9a44 h1:FGzENZi+SX9I7h9xvMtRA3rel8hCEfyzSixteBgn7MU= github.com/bazelbuild/buildtools v0.0.0-20240918101019-be1c24cc9a44/go.mod h1:PLNUetjLa77TCCziPsz0EI8a6CUxgC+1jgmWv0H25tg= github.com/bazelbuild/rules_go v0.55.0 h1:S8X/b/Oygw/Dtv7NuyW7ht0QwdynMEdXQqYigX5A1KY= From 866938df7b3500fd644465484e06a1d96d9eef61 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Thu, 12 Jun 2025 03:48:04 +0000 Subject: [PATCH 05/29] rules_go uses gazelle 0.36 for MODULE, lets try that everywhere --- gazelle/MODULE.bazel | 2 +- gazelle/WORKSPACE | 6 +++--- gazelle/deps.bzl | 4 ++-- gazelle/go.mod | 2 +- gazelle/go.sum | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gazelle/MODULE.bazel b/gazelle/MODULE.bazel index ac9e26ab6e..2af68d51fd 100644 --- a/gazelle/MODULE.bazel +++ b/gazelle/MODULE.bazel @@ -7,7 +7,7 @@ module( bazel_dep(name = "bazel_skylib", version = "1.6.1") bazel_dep(name = "rules_python", version = "0.18.0") bazel_dep(name = "rules_go", version = "0.55.0", repo_name = "io_bazel_rules_go") -bazel_dep(name = "gazelle", version = "0.42.0", repo_name = "bazel_gazelle") +bazel_dep(name = "gazelle", version = "0.36.0", repo_name = "bazel_gazelle") bazel_dep(name = "rules_cc", version = "0.0.16") local_path_override( diff --git a/gazelle/WORKSPACE b/gazelle/WORKSPACE index 80b505a3ec..908fe242aa 100644 --- a/gazelle/WORKSPACE +++ b/gazelle/WORKSPACE @@ -13,10 +13,10 @@ http_archive( http_archive( name = "bazel_gazelle", - sha256 = "5d80e62a70314f39cc764c1c3eaa800c5936c9f1ea91625006227ce4d20cd086", + sha256 = "75df288c4b31c81eb50f51e2e14f4763cb7548daae126817247064637fd9ea62", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.42.0/bazel-gazelle-v0.42.0.tar.gz", - "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.42.0/bazel-gazelle-v0.42.0.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz", ], ) diff --git a/gazelle/deps.bzl b/gazelle/deps.bzl index 457f71f1a9..a6789ea32f 100644 --- a/gazelle/deps.bzl +++ b/gazelle/deps.bzl @@ -40,8 +40,8 @@ def go_deps(): go_repository( name = "com_github_bazelbuild_bazel_gazelle", importpath = "github.com/bazelbuild/bazel-gazelle", - sum = "h1:BpkUzE3H2l6buJYFTKgzVMecJimQgWwYud25qVIx0SQ=", - version = "v0.42.0", + sum = "h1:n41ODckCkU9D2BEwBxYN+xu5E92Vd0gaW6QmsIW9l00=", + version = "v0.36.0", ) go_repository( name = "com_github_bazelbuild_buildtools", diff --git a/gazelle/go.mod b/gazelle/go.mod index a8eff54949..34a5f85498 100644 --- a/gazelle/go.mod +++ b/gazelle/go.mod @@ -5,7 +5,7 @@ go 1.22.9 toolchain go1.24.2 require ( - github.com/bazelbuild/bazel-gazelle v0.42.0 + github.com/bazelbuild/bazel-gazelle v0.36.0 github.com/bazelbuild/buildtools v0.0.0-20240918101019-be1c24cc9a44 github.com/bazelbuild/rules_go v0.55.0 github.com/bmatcuk/doublestar/v4 v4.7.1 diff --git a/gazelle/go.sum b/gazelle/go.sum index 201e9a826c..6394696bab 100644 --- a/gazelle/go.sum +++ b/gazelle/go.sum @@ -1,5 +1,5 @@ -github.com/bazelbuild/bazel-gazelle v0.42.0 h1:BpkUzE3H2l6buJYFTKgzVMecJimQgWwYud25qVIx0SQ= -github.com/bazelbuild/bazel-gazelle v0.42.0/go.mod h1:SRCc60YGZ27y+BqLzQ+nMh249+FyZz7YtX/V2ng+/z4= +github.com/bazelbuild/bazel-gazelle v0.36.0 h1:n41ODckCkU9D2BEwBxYN+xu5E92Vd0gaW6QmsIW9l00= +github.com/bazelbuild/bazel-gazelle v0.36.0/go.mod h1:5wGHbkRpDUdz4LxREtPYwXstrWfnkV+oDmOuxNAxW1s= github.com/bazelbuild/buildtools v0.0.0-20240918101019-be1c24cc9a44 h1:FGzENZi+SX9I7h9xvMtRA3rel8hCEfyzSixteBgn7MU= github.com/bazelbuild/buildtools v0.0.0-20240918101019-be1c24cc9a44/go.mod h1:PLNUetjLa77TCCziPsz0EI8a6CUxgC+1jgmWv0H25tg= github.com/bazelbuild/rules_go v0.55.0 h1:S8X/b/Oygw/Dtv7NuyW7ht0QwdynMEdXQqYigX5A1KY= From c9a4dc8f390d812fef73e6c216f47bd02a40a852 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Thu, 12 Jun 2025 03:50:59 +0000 Subject: [PATCH 06/29] rules_go uses gazelle 0.39.1 for WORKSPACE, try that? --- gazelle/WORKSPACE | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gazelle/WORKSPACE b/gazelle/WORKSPACE index 908fe242aa..3a9670c352 100644 --- a/gazelle/WORKSPACE +++ b/gazelle/WORKSPACE @@ -13,10 +13,10 @@ http_archive( http_archive( name = "bazel_gazelle", - sha256 = "75df288c4b31c81eb50f51e2e14f4763cb7548daae126817247064637fd9ea62", + sha256 = "b760f7fe75173886007f7c2e616a21241208f3d90e8657dc65d36a771e916b6a", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz", - "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.39.1/bazel-gazelle-v0.39.1.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.39.1/bazel-gazelle-v0.39.1.tar.gz", ], ) From da71e067eb03b2b6ddd7211e00a5d8d15dc86b26 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Thu, 12 Jun 2025 03:55:13 +0000 Subject: [PATCH 07/29] Trying various bazel_gazelle versions locally. Ended up on 0.36 for WORKSPACE + 0.31, 0.32 errored out with the golang_x_tools//go/vcs issue from before + 0.33, 0.34, 0.35 have the wrong load sorting. --- gazelle/WORKSPACE | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gazelle/WORKSPACE b/gazelle/WORKSPACE index 3a9670c352..908fe242aa 100644 --- a/gazelle/WORKSPACE +++ b/gazelle/WORKSPACE @@ -13,10 +13,10 @@ http_archive( http_archive( name = "bazel_gazelle", - sha256 = "b760f7fe75173886007f7c2e616a21241208f3d90e8657dc65d36a771e916b6a", + sha256 = "75df288c4b31c81eb50f51e2e14f4763cb7548daae126817247064637fd9ea62", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.39.1/bazel-gazelle-v0.39.1.tar.gz", - "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.39.1/bazel-gazelle-v0.39.1.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz", ], ) From bdfeb78e6f7400d131ba8e64e84270f748ad6e28 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Thu, 19 Jun 2025 10:14:48 -0700 Subject: [PATCH 08/29] call gazelle_dependencies According to https://github.com/bazel-contrib/bazel-gazelle/issues/1654 we need to call the gazelle_dependencies macro in WORKSPACE. We already do that in gazelle/WORKSPACE but it's not in the root WORKSPACE. Maybe we have to do it there, too... --- gazelle/deps.bzl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gazelle/deps.bzl b/gazelle/deps.bzl index a6789ea32f..dffa106b3e 100644 --- a/gazelle/deps.bzl +++ b/gazelle/deps.bzl @@ -16,6 +16,7 @@ load("@bazel_gazelle//:deps.bzl", _go_repository = "go_repository") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") def go_repository(name, **kwargs): if name not in native.existing_rules(): @@ -33,6 +34,7 @@ def python_stdlib_list_deps(): def gazelle_deps(): go_deps() + gazelle_dependencies() python_stdlib_list_deps() def go_deps(): From bdfc03567e78d8475d5db52bd90a0ed172f7d47c Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Thu, 19 Jun 2025 10:53:16 -0700 Subject: [PATCH 09/29] Also add go rules deps --- gazelle/deps.bzl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gazelle/deps.bzl b/gazelle/deps.bzl index dffa106b3e..8bbf3b371f 100644 --- a/gazelle/deps.bzl +++ b/gazelle/deps.bzl @@ -17,6 +17,7 @@ load("@bazel_gazelle//:deps.bzl", _go_repository = "go_repository") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") def go_repository(name, **kwargs): if name not in native.existing_rules(): @@ -34,6 +35,7 @@ def python_stdlib_list_deps(): def gazelle_deps(): go_deps() + go_rules_dependencies() gazelle_dependencies() python_stdlib_list_deps() From 09414884b6da379805201f25727f68d207b9bfab Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Thu, 19 Jun 2025 11:00:00 -0700 Subject: [PATCH 10/29] Buildifier cleanup --- gazelle/deps.bzl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gazelle/deps.bzl b/gazelle/deps.bzl index 8bbf3b371f..42130aba20 100644 --- a/gazelle/deps.bzl +++ b/gazelle/deps.bzl @@ -14,10 +14,9 @@ "This file managed by `bazel run //:gazelle_update_repos`" -load("@bazel_gazelle//:deps.bzl", _go_repository = "go_repository") +load("@bazel_gazelle//:deps.bzl", "gazell_dependencies", _go_repository = "go_repository") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") -load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") +load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies") def go_repository(name, **kwargs): if name not in native.existing_rules(): From fd7fd51f73dabb04d89914c1eeba6512bc4d9616 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Thu, 19 Jun 2025 11:27:17 -0700 Subject: [PATCH 11/29] typo >_< --- gazelle/deps.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gazelle/deps.bzl b/gazelle/deps.bzl index 42130aba20..7e429a9e18 100644 --- a/gazelle/deps.bzl +++ b/gazelle/deps.bzl @@ -14,7 +14,7 @@ "This file managed by `bazel run //:gazelle_update_repos`" -load("@bazel_gazelle//:deps.bzl", "gazell_dependencies", _go_repository = "go_repository") +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", _go_repository = "go_repository") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies") From 2306ff492d1b246984a3c215832565e7d2f68a99 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Thu, 19 Jun 2025 11:34:41 -0700 Subject: [PATCH 12/29] fixup some version mismatches --- MODULE.bazel | 2 +- examples/build_file_generation/WORKSPACE | 6 +++--- internal_dev_deps.bzl | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 8d9a55e35a..84205600cb 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -92,7 +92,7 @@ bazel_dep(name = "another_module", version = "0", dev_dependency = True) # We use `WORKSPACE.bzlmod` because it is impossible to have dev-only local overrides. bazel_dep(name = "rules_go", version = "0.55.0", dev_dependency = True, repo_name = "io_bazel_rules_go") bazel_dep(name = "rules_python_gazelle_plugin", version = "0", dev_dependency = True) -bazel_dep(name = "gazelle", version = "0.40.0", dev_dependency = True, repo_name = "bazel_gazelle") +bazel_dep(name = "gazelle", version = "0.36.0", dev_dependency = True, repo_name = "bazel_gazelle") internal_dev_deps = use_extension( "//python/private:internal_dev_deps.bzl", diff --git a/examples/build_file_generation/WORKSPACE b/examples/build_file_generation/WORKSPACE index 8d09933c36..7d17a11dbf 100644 --- a/examples/build_file_generation/WORKSPACE +++ b/examples/build_file_generation/WORKSPACE @@ -30,10 +30,10 @@ http_archive( # Download the bazel_gazelle ruleset. http_archive( name = "bazel_gazelle", - sha256 = "a80893292ae1d78eaeedd50d1cab98f242a17e3d5741b1b9fb58b5fd9d2d57bc", + sha256 = "75df288c4b31c81eb50f51e2e14f4763cb7548daae126817247064637fd9ea62", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.40.0/bazel-gazelle-v0.40.0.tar.gz", - "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.40.0/bazel-gazelle-v0.40.0.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz", ], ) diff --git a/internal_dev_deps.bzl b/internal_dev_deps.bzl index 32fb7f9474..4d5559df4e 100644 --- a/internal_dev_deps.bzl +++ b/internal_dev_deps.bzl @@ -108,10 +108,10 @@ def rules_python_internal_deps(): http_archive( name = "bazel_gazelle", - sha256 = "a80893292ae1d78eaeedd50d1cab98f242a17e3d5741b1b9fb58b5fd9d2d57bc", + sha256 = "75df288c4b31c81eb50f51e2e14f4763cb7548daae126817247064637fd9ea62", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.40.0/bazel-gazelle-v0.40.0.tar.gz", - "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.40.0/bazel-gazelle-v0.40.0.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz", ], ) From 992ee8627425de17d4863046210f6af85a923ae5 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Thu, 19 Jun 2025 11:57:15 -0700 Subject: [PATCH 13/29] Well that definitely didn't work. Revert "fixup some version mismatches" This reverts commit 2306ff492d1b246984a3c215832565e7d2f68a99. --- MODULE.bazel | 2 +- examples/build_file_generation/WORKSPACE | 6 +++--- internal_dev_deps.bzl | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 84205600cb..8d9a55e35a 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -92,7 +92,7 @@ bazel_dep(name = "another_module", version = "0", dev_dependency = True) # We use `WORKSPACE.bzlmod` because it is impossible to have dev-only local overrides. bazel_dep(name = "rules_go", version = "0.55.0", dev_dependency = True, repo_name = "io_bazel_rules_go") bazel_dep(name = "rules_python_gazelle_plugin", version = "0", dev_dependency = True) -bazel_dep(name = "gazelle", version = "0.36.0", dev_dependency = True, repo_name = "bazel_gazelle") +bazel_dep(name = "gazelle", version = "0.40.0", dev_dependency = True, repo_name = "bazel_gazelle") internal_dev_deps = use_extension( "//python/private:internal_dev_deps.bzl", diff --git a/examples/build_file_generation/WORKSPACE b/examples/build_file_generation/WORKSPACE index 7d17a11dbf..8d09933c36 100644 --- a/examples/build_file_generation/WORKSPACE +++ b/examples/build_file_generation/WORKSPACE @@ -30,10 +30,10 @@ http_archive( # Download the bazel_gazelle ruleset. http_archive( name = "bazel_gazelle", - sha256 = "75df288c4b31c81eb50f51e2e14f4763cb7548daae126817247064637fd9ea62", + sha256 = "a80893292ae1d78eaeedd50d1cab98f242a17e3d5741b1b9fb58b5fd9d2d57bc", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz", - "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.40.0/bazel-gazelle-v0.40.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.40.0/bazel-gazelle-v0.40.0.tar.gz", ], ) diff --git a/internal_dev_deps.bzl b/internal_dev_deps.bzl index 4d5559df4e..32fb7f9474 100644 --- a/internal_dev_deps.bzl +++ b/internal_dev_deps.bzl @@ -108,10 +108,10 @@ def rules_python_internal_deps(): http_archive( name = "bazel_gazelle", - sha256 = "75df288c4b31c81eb50f51e2e14f4763cb7548daae126817247064637fd9ea62", + sha256 = "a80893292ae1d78eaeedd50d1cab98f242a17e3d5741b1b9fb58b5fd9d2d57bc", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz", - "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.40.0/bazel-gazelle-v0.40.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.40.0/bazel-gazelle-v0.40.0.tar.gz", ], ) From 2ada90685ad30a68bb5455741128940fa200c400 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Sat, 21 Jun 2025 22:25:49 -0700 Subject: [PATCH 14/29] GCO_ENABLED=1 --- .bazelci/presubmit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 7e9d4dea53..73d155f849 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -159,6 +159,7 @@ tasks: - "--enable_workspace" - "--keep_going" - "--build_tag_filters=-integration-test" + - "--action_env=GCO_ENABLED=1" test_targets: - "--" - "..." From 7aa087543ef0f31ea86adfccaee4517fcc1e9229 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Sun, 22 Jun 2025 14:49:47 -0700 Subject: [PATCH 15/29] Spell 'cgo' correctly... --- .bazelci/presubmit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 73d155f849..862e8787f4 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -159,7 +159,7 @@ tasks: - "--enable_workspace" - "--keep_going" - "--build_tag_filters=-integration-test" - - "--action_env=GCO_ENABLED=1" + - "--action_env=CGO_ENABLED=1" test_targets: - "--" - "..." From c36a4e6667ad8d7de2f4f8d23970f308182c91ab Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Sun, 22 Jun 2025 15:22:23 -0700 Subject: [PATCH 16/29] different cgo --- .bazelci/presubmit.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 862e8787f4..67b7ed558e 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -159,7 +159,6 @@ tasks: - "--enable_workspace" - "--keep_going" - "--build_tag_filters=-integration-test" - - "--action_env=CGO_ENABLED=1" test_targets: - "--" - "..." @@ -240,6 +239,8 @@ tasks: integration_test_build_file_generation_windows_workspace: <<: *reusable_build_test_all <<: *common_workspace_flags + build_flags: + - "--action_env=CGO_ENABLED=1" name: "examples/build_file_generation: Windows, workspace" working_directory: examples/build_file_generation platform: windows @@ -339,6 +340,8 @@ tasks: integration_test_bzlmod_build_file_generation_windows: <<: *reusable_build_test_all # coverage is not supported on Windows + build_flags: + - "--action_env=CGO_ENABLED=1" name: "examples/bzlmod_build_file_generateion: Windows" working_directory: examples/bzlmod_build_file_generation platform: windows From 2d6889c5bfe4c4446eb013db2888cb1f4ccd5a1d Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Sun, 22 Jun 2025 15:35:40 -0700 Subject: [PATCH 17/29] test env cgo --- .bazelci/presubmit.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 67b7ed558e..f84aa549c9 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -241,6 +241,8 @@ tasks: <<: *common_workspace_flags build_flags: - "--action_env=CGO_ENABLED=1" + test_flags: + - "--test_env=CGO_ENABLED=1" name: "examples/build_file_generation: Windows, workspace" working_directory: examples/build_file_generation platform: windows @@ -342,6 +344,8 @@ tasks: # coverage is not supported on Windows build_flags: - "--action_env=CGO_ENABLED=1" + test_flags: + - "--test_env=CGO_ENABLED=1" name: "examples/bzlmod_build_file_generateion: Windows" working_directory: examples/bzlmod_build_file_generation platform: windows From cfb5e62b283abb1efbad4c07afc22765e9d8c61c Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Sun, 22 Jun 2025 20:47:15 -0700 Subject: [PATCH 18/29] Revert CGO stuff --- .bazelci/presubmit.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index f84aa549c9..7e9d4dea53 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -239,10 +239,6 @@ tasks: integration_test_build_file_generation_windows_workspace: <<: *reusable_build_test_all <<: *common_workspace_flags - build_flags: - - "--action_env=CGO_ENABLED=1" - test_flags: - - "--test_env=CGO_ENABLED=1" name: "examples/build_file_generation: Windows, workspace" working_directory: examples/build_file_generation platform: windows @@ -342,10 +338,6 @@ tasks: integration_test_bzlmod_build_file_generation_windows: <<: *reusable_build_test_all # coverage is not supported on Windows - build_flags: - - "--action_env=CGO_ENABLED=1" - test_flags: - - "--test_env=CGO_ENABLED=1" name: "examples/bzlmod_build_file_generateion: Windows" working_directory: examples/bzlmod_build_file_generation platform: windows From 73a2f5d378ab48bb1c0655d372d88ba9cc76b6e7 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Sun, 6 Jul 2025 04:10:02 +0000 Subject: [PATCH 19/29] Back to smacker/go-tree-sitter --- gazelle/MODULE.bazel | 2 +- gazelle/deps.bzl | 12 ++++++------ gazelle/go.mod | 2 +- gazelle/go.sum | 4 ++-- gazelle/python/BUILD.bazel | 4 ++-- gazelle/python/file_parser.go | 8 ++------ 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/gazelle/MODULE.bazel b/gazelle/MODULE.bazel index 2af68d51fd..c1ad653f35 100644 --- a/gazelle/MODULE.bazel +++ b/gazelle/MODULE.bazel @@ -21,9 +21,9 @@ use_repo( go_deps, "com_github_bazelbuild_buildtools", "com_github_bmatcuk_doublestar_v4", - "com_github_dougthor42_go_tree_sitter", "com_github_emirpasic_gods", "com_github_ghodss_yaml", + "com_github_smacker_go_tree_sitter", "com_github_stretchr_testify", "in_gopkg_yaml_v2", "org_golang_x_sync", diff --git a/gazelle/deps.bzl b/gazelle/deps.bzl index 7e429a9e18..22807ad39a 100644 --- a/gazelle/deps.bzl +++ b/gazelle/deps.bzl @@ -71,12 +71,6 @@ def go_deps(): sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=", version = "v1.1.1", ) - go_repository( - name = "com_github_dougthor42_go_tree_sitter", - importpath = "github.com/dougthor42/go-tree-sitter", - sum = "h1:b9s96BulIARx0konX36sJ5oZhWvAvjQBBntxp1eUukQ=", - version = "v0.0.0-20241210060307-2737e1d0de6b", - ) go_repository( name = "com_github_emirpasic_gods", importpath = "github.com/emirpasic/gods", @@ -125,6 +119,12 @@ def go_deps(): sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=", version = "v1.0.0", ) + go_repository( + name = "com_github_smacker_go_tree_sitter", + importpath = "github.com/smacker/go-tree-sitter", + sum = "h1:6C8qej6f1bStuePVkLSFxoU22XBS165D3klxlzRg8F4=", + version = "v0.0.0-20240827094217-dd81d9e9be82", + ) go_repository( name = "com_github_stretchr_objx", importpath = "github.com/stretchr/objx", diff --git a/gazelle/go.mod b/gazelle/go.mod index 34a5f85498..637e8f689b 100644 --- a/gazelle/go.mod +++ b/gazelle/go.mod @@ -9,9 +9,9 @@ require ( github.com/bazelbuild/buildtools v0.0.0-20240918101019-be1c24cc9a44 github.com/bazelbuild/rules_go v0.55.0 github.com/bmatcuk/doublestar/v4 v4.7.1 - github.com/dougthor42/go-tree-sitter v0.0.0-20241210060307-2737e1d0de6b github.com/emirpasic/gods v1.18.1 github.com/ghodss/yaml v1.0.0 + github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82 github.com/stretchr/testify v1.9.0 golang.org/x/sync v0.11.0 gopkg.in/yaml.v2 v2.4.0 diff --git a/gazelle/go.sum b/gazelle/go.sum index 6394696bab..3bcd8ad947 100644 --- a/gazelle/go.sum +++ b/gazelle/go.sum @@ -8,8 +8,6 @@ github.com/bmatcuk/doublestar/v4 v4.7.1 h1:fdDeAqgT47acgwd9bd9HxJRDmc9UAmPpc+2m0 github.com/bmatcuk/doublestar/v4 v4.7.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dougthor42/go-tree-sitter v0.0.0-20241210060307-2737e1d0de6b h1:b9s96BulIARx0konX36sJ5oZhWvAvjQBBntxp1eUukQ= -github.com/dougthor42/go-tree-sitter v0.0.0-20241210060307-2737e1d0de6b/go.mod h1:87UkDyPt18bTH/FvinLc/kj587VNYOdRKZT1la4T8Hg= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= @@ -18,6 +16,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82 h1:6C8qej6f1bStuePVkLSFxoU22XBS165D3klxlzRg8F4= +github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82/go.mod h1:xe4pgH49k4SsmkQq5OT8abwhWmnzkhpgnXeekbx2efw= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM= diff --git a/gazelle/python/BUILD.bazel b/gazelle/python/BUILD.bazel index eb2d72e5eb..e4e7f04d5f 100644 --- a/gazelle/python/BUILD.bazel +++ b/gazelle/python/BUILD.bazel @@ -39,11 +39,11 @@ go_library( "@bazel_gazelle//rule:go_default_library", "@com_github_bazelbuild_buildtools//build:go_default_library", "@com_github_bmatcuk_doublestar_v4//:doublestar", - "@com_github_dougthor42_go_tree_sitter//:go-tree-sitter", - "@com_github_dougthor42_go_tree_sitter//python", "@com_github_emirpasic_gods//lists/singlylinkedlist", "@com_github_emirpasic_gods//sets/treeset", "@com_github_emirpasic_gods//utils", + "@com_github_smacker_go_tree_sitter//:go-tree-sitter", + "@com_github_smacker_go_tree_sitter//python", "@org_golang_x_sync//errgroup", ], ) diff --git a/gazelle/python/file_parser.go b/gazelle/python/file_parser.go index c147984fc3..4ebd26192e 100644 --- a/gazelle/python/file_parser.go +++ b/gazelle/python/file_parser.go @@ -22,8 +22,8 @@ import ( "path/filepath" "strings" - sitter "github.com/dougthor42/go-tree-sitter" - "github.com/dougthor42/go-tree-sitter/python" + sitter "github.com/smacker/go-tree-sitter" + "github.com/smacker/go-tree-sitter/python" ) const ( @@ -115,10 +115,6 @@ func (p *FileParser) parseMain(ctx context.Context, node *sitter.Node) bool { a, b = b, a } if a.Type() == sitterNodeTypeIdentifier && a.Content(p.code) == "__name__" && - // at github.com/dougthor42/go-tree-sitter@latest (after v0.0.0-20240422154435-0628b34cbf9c we used) - // "__main__" is the second child of b. But now, it isn't. - // we cannot use the latest go-tree-sitter because of the top level reference in scanner.c. - // https://github.com/dougthor42/go-tree-sitter/blob/04d6b33fe138a98075210f5b770482ded024dc0f/python/scanner.c#L1 b.Type() == sitterNodeTypeString && string(p.code[b.StartByte()+1:b.EndByte()-1]) == "__main__" { return true } From 3ab53d0a3101715c8ab9ee7f822ebb61b6fe3e87 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Sun, 6 Jul 2025 04:53:58 +0000 Subject: [PATCH 20/29] Drop go to 1.19 to match smacker --- examples/build_file_generation/WORKSPACE | 2 +- gazelle/WORKSPACE | 2 +- gazelle/go.mod | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/build_file_generation/WORKSPACE b/examples/build_file_generation/WORKSPACE index 8d09933c36..50510dfa69 100644 --- a/examples/build_file_generation/WORKSPACE +++ b/examples/build_file_generation/WORKSPACE @@ -49,7 +49,7 @@ go_rules_dependencies() # go_rules_dependencies is a function that registers external dependencies # needed by the Go rules. # See: https://github.com/bazelbuild/rules_go/blob/master/go/dependencies.rst#go_rules_dependencies -go_register_toolchains(version = "1.22.0") +go_register_toolchains(version = "1.19.4") # The following call configured the gazelle dependencies, Go environment and Go SDK. gazelle_dependencies() diff --git a/gazelle/WORKSPACE b/gazelle/WORKSPACE index 908fe242aa..06ef8918d5 100644 --- a/gazelle/WORKSPACE +++ b/gazelle/WORKSPACE @@ -25,7 +25,7 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_depe go_rules_dependencies() -go_register_toolchains(version = "1.22.9") +go_register_toolchains(version = "1.19.4") gazelle_dependencies() diff --git a/gazelle/go.mod b/gazelle/go.mod index 637e8f689b..9bf48b68e4 100644 --- a/gazelle/go.mod +++ b/gazelle/go.mod @@ -1,6 +1,6 @@ module github.com/bazel-contrib/rules_python/gazelle -go 1.22.9 +go 1.19 toolchain go1.24.2 From 611faa5cbb909e91fe91333f3c153a01deba5497 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Sun, 6 Jul 2025 05:09:10 +0000 Subject: [PATCH 21/29] Revert "Drop go to 1.19 to match smacker" This reverts commit 3ab53d0a3101715c8ab9ee7f822ebb61b6fe3e87. --- examples/build_file_generation/WORKSPACE | 2 +- gazelle/WORKSPACE | 2 +- gazelle/go.mod | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/build_file_generation/WORKSPACE b/examples/build_file_generation/WORKSPACE index 50510dfa69..8d09933c36 100644 --- a/examples/build_file_generation/WORKSPACE +++ b/examples/build_file_generation/WORKSPACE @@ -49,7 +49,7 @@ go_rules_dependencies() # go_rules_dependencies is a function that registers external dependencies # needed by the Go rules. # See: https://github.com/bazelbuild/rules_go/blob/master/go/dependencies.rst#go_rules_dependencies -go_register_toolchains(version = "1.19.4") +go_register_toolchains(version = "1.22.0") # The following call configured the gazelle dependencies, Go environment and Go SDK. gazelle_dependencies() diff --git a/gazelle/WORKSPACE b/gazelle/WORKSPACE index 06ef8918d5..908fe242aa 100644 --- a/gazelle/WORKSPACE +++ b/gazelle/WORKSPACE @@ -25,7 +25,7 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_depe go_rules_dependencies() -go_register_toolchains(version = "1.19.4") +go_register_toolchains(version = "1.22.9") gazelle_dependencies() diff --git a/gazelle/go.mod b/gazelle/go.mod index 9bf48b68e4..637e8f689b 100644 --- a/gazelle/go.mod +++ b/gazelle/go.mod @@ -1,6 +1,6 @@ module github.com/bazel-contrib/rules_python/gazelle -go 1.19 +go 1.22.9 toolchain go1.24.2 From 406e3d55ce3de19848ef2c901c6d0f0932080573 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Sun, 6 Jul 2025 05:14:00 +0000 Subject: [PATCH 22/29] official tree-sitter --- gazelle/MODULE.bazel | 3 +- gazelle/go.mod | 10 ++++--- gazelle/go.sum | 34 +++++++++++++++++++--- gazelle/python/BUILD.bazel | 7 ++--- gazelle/python/file_parser.go | 53 +++++++++++++++++------------------ gazelle/python/parser.go | 2 +- 6 files changed, 67 insertions(+), 42 deletions(-) diff --git a/gazelle/MODULE.bazel b/gazelle/MODULE.bazel index c1ad653f35..7521ab48c7 100644 --- a/gazelle/MODULE.bazel +++ b/gazelle/MODULE.bazel @@ -23,8 +23,9 @@ use_repo( "com_github_bmatcuk_doublestar_v4", "com_github_emirpasic_gods", "com_github_ghodss_yaml", - "com_github_smacker_go_tree_sitter", "com_github_stretchr_testify", + "com_github_tree_sitter_go_tree_sitter", + "com_github_tree_sitter_tree_sitter_python", "in_gopkg_yaml_v2", "org_golang_x_sync", ) diff --git a/gazelle/go.mod b/gazelle/go.mod index 637e8f689b..4b507d5200 100644 --- a/gazelle/go.mod +++ b/gazelle/go.mod @@ -1,8 +1,8 @@ module github.com/bazel-contrib/rules_python/gazelle -go 1.22.9 +go 1.23 -toolchain go1.24.2 +toolchain go1.24.4 require ( github.com/bazelbuild/bazel-gazelle v0.36.0 @@ -11,8 +11,9 @@ require ( github.com/bmatcuk/doublestar/v4 v4.7.1 github.com/emirpasic/gods v1.18.1 github.com/ghodss/yaml v1.0.0 - github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82 - github.com/stretchr/testify v1.9.0 + github.com/stretchr/testify v1.10.0 + github.com/tree-sitter/go-tree-sitter v0.25.0 + github.com/tree-sitter/tree-sitter-python v0.23.6 golang.org/x/sync v0.11.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -20,6 +21,7 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.6.0 // indirect + github.com/mattn/go-pointer v0.0.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/mod v0.23.0 // indirect golang.org/x/sys v0.30.0 // indirect diff --git a/gazelle/go.sum b/gazelle/go.sum index 3bcd8ad947..08038ff983 100644 --- a/gazelle/go.sum +++ b/gazelle/go.sum @@ -14,12 +14,38 @@ github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0= +github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82 h1:6C8qej6f1bStuePVkLSFxoU22XBS165D3klxlzRg8F4= -github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82/go.mod h1:xe4pgH49k4SsmkQq5OT8abwhWmnzkhpgnXeekbx2efw= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/tree-sitter/go-tree-sitter v0.25.0 h1:sx6kcg8raRFCvc9BnXglke6axya12krCJF5xJ2sftRU= +github.com/tree-sitter/go-tree-sitter v0.25.0/go.mod h1:r77ig7BikoZhHrrsjAnv8RqGti5rtSyvDHPzgTPsUuU= +github.com/tree-sitter/tree-sitter-c v0.23.4 h1:nBPH3FV07DzAD7p0GfNvXM+Y7pNIoPenQWBpvM++t4c= +github.com/tree-sitter/tree-sitter-c v0.23.4/go.mod h1:MkI5dOiIpeN94LNjeCp8ljXN/953JCwAby4bClMr6bw= +github.com/tree-sitter/tree-sitter-cpp v0.23.4 h1:LaWZsiqQKvR65yHgKmnaqA+uz6tlDJTJFCyFIeZU/8w= +github.com/tree-sitter/tree-sitter-cpp v0.23.4/go.mod h1:doqNW64BriC7WBCQ1klf0KmJpdEvfxyXtoEybnBo6v8= +github.com/tree-sitter/tree-sitter-embedded-template v0.23.2 h1:nFkkH6Sbe56EXLmZBqHHcamTpmz3TId97I16EnGy4rg= +github.com/tree-sitter/tree-sitter-embedded-template v0.23.2/go.mod h1:HNPOhN0qF3hWluYLdxWs5WbzP/iE4aaRVPMsdxuzIaQ= +github.com/tree-sitter/tree-sitter-go v0.23.4 h1:yt5KMGnTHS+86pJmLIAZMWxukr8W7Ae1STPvQUuNROA= +github.com/tree-sitter/tree-sitter-go v0.23.4/go.mod h1:Jrx8QqYN0v7npv1fJRH1AznddllYiCMUChtVjxPK040= +github.com/tree-sitter/tree-sitter-html v0.23.2 h1:1UYDV+Yd05GGRhVnTcbP58GkKLSHHZwVaN+lBZV11Lc= +github.com/tree-sitter/tree-sitter-html v0.23.2/go.mod h1:gpUv/dG3Xl/eebqgeYeFMt+JLOY9cgFinb/Nw08a9og= +github.com/tree-sitter/tree-sitter-java v0.23.5 h1:J9YeMGMwXYlKSP3K4Us8CitC6hjtMjqpeOf2GGo6tig= +github.com/tree-sitter/tree-sitter-java v0.23.5/go.mod h1:NRKlI8+EznxA7t1Yt3xtraPk1Wzqh3GAIC46wxvc320= +github.com/tree-sitter/tree-sitter-javascript v0.23.1 h1:1fWupaRC0ArlHJ/QJzsfQ3Ibyopw7ZfQK4xXc40Zveo= +github.com/tree-sitter/tree-sitter-javascript v0.23.1/go.mod h1:lmGD1EJdCA+v0S1u2fFgepMg/opzSg/4pgFym2FPGAs= +github.com/tree-sitter/tree-sitter-json v0.24.8 h1:tV5rMkihgtiOe14a9LHfDY5kzTl5GNUYe6carZBn0fQ= +github.com/tree-sitter/tree-sitter-json v0.24.8/go.mod h1:F351KK0KGvCaYbZ5zxwx/gWWvZhIDl0eMtn+1r+gQbo= +github.com/tree-sitter/tree-sitter-php v0.23.11 h1:iHewsLNDmznh8kgGyfWfujsZxIz1YGbSd2ZTEM0ZiP8= +github.com/tree-sitter/tree-sitter-php v0.23.11/go.mod h1:T/kbfi+UcCywQfUNAJnGTN/fMSUjnwPXA8k4yoIks74= +github.com/tree-sitter/tree-sitter-python v0.23.6 h1:qHnWFR5WhtMQpxBZRwiaU5Hk/29vGju6CVtmvu5Haas= +github.com/tree-sitter/tree-sitter-python v0.23.6/go.mod h1:cpdthSy/Yoa28aJFBscFHlGiU+cnSiSh1kuDVtI8YeM= +github.com/tree-sitter/tree-sitter-ruby v0.23.1 h1:T/NKHUA+iVbHM440hFx+lzVOzS4dV6z8Qw8ai+72bYo= +github.com/tree-sitter/tree-sitter-ruby v0.23.1/go.mod h1:kUS4kCCQloFcdX6sdpr8p6r2rogbM6ZjTox5ZOQy8cA= +github.com/tree-sitter/tree-sitter-rust v0.23.2 h1:6AtoooCW5GqNrRpfnvl0iUhxTAZEovEmLKDbyHlfw90= +github.com/tree-sitter/tree-sitter-rust v0.23.2/go.mod h1:hfeGWic9BAfgTrc7Xf6FaOAguCFJRo3RBbs7QJ6D7MI= golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM= golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= diff --git a/gazelle/python/BUILD.bazel b/gazelle/python/BUILD.bazel index e4e7f04d5f..e5255c4184 100644 --- a/gazelle/python/BUILD.bazel +++ b/gazelle/python/BUILD.bazel @@ -29,7 +29,6 @@ go_library( importpath = "github.com/bazel-contrib/rules_python/gazelle/python", visibility = ["//visibility:public"], deps = [ - "//manifest", "//pythonconfig", "@bazel_gazelle//config:go_default_library", "@bazel_gazelle//label:go_default_library", @@ -37,13 +36,13 @@ go_library( "@bazel_gazelle//repo:go_default_library", "@bazel_gazelle//resolve:go_default_library", "@bazel_gazelle//rule:go_default_library", - "@com_github_bazelbuild_buildtools//build:go_default_library", + "@com_github_bazelbuild_buildtools//build", "@com_github_bmatcuk_doublestar_v4//:doublestar", "@com_github_emirpasic_gods//lists/singlylinkedlist", "@com_github_emirpasic_gods//sets/treeset", "@com_github_emirpasic_gods//utils", - "@com_github_smacker_go_tree_sitter//:go-tree-sitter", - "@com_github_smacker_go_tree_sitter//python", + "@com_github_tree_sitter_go_tree_sitter//:go-tree-sitter", + "@com_github_tree_sitter_tree_sitter_python//bindings/go", "@org_golang_x_sync//errgroup", ], ) diff --git a/gazelle/python/file_parser.go b/gazelle/python/file_parser.go index 4ebd26192e..037d9b7c09 100644 --- a/gazelle/python/file_parser.go +++ b/gazelle/python/file_parser.go @@ -22,8 +22,8 @@ import ( "path/filepath" "strings" - sitter "github.com/smacker/go-tree-sitter" - "github.com/smacker/go-tree-sitter/python" + sitter "github.com/tree-sitter/go-tree-sitter" + python "github.com/tree-sitter/tree-sitter-python/bindings/go" ) const ( @@ -61,12 +61,9 @@ func NewFileParser() *FileParser { // It prints a warning if parsing fails. func ParseCode(code []byte, path string) (*sitter.Node, error) { parser := sitter.NewParser() - parser.SetLanguage(python.GetLanguage()) + parser.SetLanguage(sitter.NewLanguage(python.Language())) - tree, err := parser.ParseCtx(context.Background(), nil, code) - if err != nil { - return nil, err - } + tree := parser.Parse(code, nil) root := tree.RootNode() if !root.HasError() { @@ -82,16 +79,16 @@ func ParseCode(code []byte, path string) (*sitter.Node, error) { return root, nil } - for i := 0; i < int(root.ChildCount()); i++ { + for i := uint(0); i < root.ChildCount(); i++ { child := root.Child(i) if child.IsError() { // Example logs: // gazelle: Parse error at {Row:1 Column:0}: // def search_one_more_level[T](): - log.Printf("Parse error at %+v:\n%+v", child.StartPoint(), child.Content(code)) + log.Printf("Parse error at %+v:\n%+v", child.StartPosition(), child.Utf8Text(code)) // Log the internal tree-sitter representation of what was parsed. Eg: // gazelle: The above was parsed as: (ERROR (identifier) (call function: (list (identifier)) arguments: (argument_list))) - log.Printf("The above was parsed as: %v", child.String()) + log.Printf("The above was parsed as: %v", child.Kind()) } } @@ -101,21 +98,21 @@ func ParseCode(code []byte, path string) (*sitter.Node, error) { // parseMain returns true if the python file has an `if __name__ == "__main__":` block, // which is a common idiom for python scripts/binaries. func (p *FileParser) parseMain(ctx context.Context, node *sitter.Node) bool { - for i := 0; i < int(node.ChildCount()); i++ { + for i := uint(0); i < node.ChildCount(); i++ { if err := ctx.Err(); err != nil { return false } child := node.Child(i) - if child.Type() == sitterNodeTypeIfStatement && - child.Child(1).Type() == sitterNodeTypeComparisonOperator && child.Child(1).Child(1).Type() == "==" { + if child.Kind() == sitterNodeTypeIfStatement && + child.Child(1).Kind() == sitterNodeTypeComparisonOperator && child.Child(1).Child(1).Kind() == "==" { statement := child.Child(1) a, b := statement.Child(0), statement.Child(2) // convert "'__main__' == __name__" to "__name__ == '__main__'" - if b.Type() == sitterNodeTypeIdentifier { + if b.Kind() == sitterNodeTypeIdentifier { a, b = b, a } - if a.Type() == sitterNodeTypeIdentifier && a.Content(p.code) == "__name__" && - b.Type() == sitterNodeTypeString && string(p.code[b.StartByte()+1:b.EndByte()-1]) == "__main__" { + if a.Kind() == sitterNodeTypeIdentifier && a.Utf8Text(p.code) == "__name__" && + b.Kind() == sitterNodeTypeString && string(p.code[b.StartByte()+1:b.EndByte()-1]) == "__main__" { return true } } @@ -126,18 +123,18 @@ func (p *FileParser) parseMain(ctx context.Context, node *sitter.Node) bool { // parseImportStatement parses a node for an import statement, returning a `module` and a boolean // representing if the parse was OK or not. func parseImportStatement(node *sitter.Node, code []byte) (module, bool) { - switch node.Type() { + switch node.Kind() { case sitterNodeTypeDottedName: return module{ - Name: node.Content(code), - LineNumber: node.StartPoint().Row + 1, + Name: node.Utf8Text(code), + LineNumber: node.StartPosition().Row + 1, }, true case sitterNodeTypeAliasedImport: return parseImportStatement(node.Child(0), code) case sitterNodeTypeWildcardImport: return module{ Name: "*", - LineNumber: node.StartPoint().Row + 1, + LineNumber: node.StartPosition().Row + 1, }, true } return module{}, false @@ -147,8 +144,8 @@ func parseImportStatement(node *sitter.Node, code []byte) (module, bool) { // an import statement. It updates FileParser.output.Modules with the `module` that the // import represents. func (p *FileParser) parseImportStatements(node *sitter.Node) bool { - if node.Type() == sitterNodeTypeImportStatement { - for j := 1; j < int(node.ChildCount()); j++ { + if node.Kind() == sitterNodeTypeImportStatement { + for j := uint(1); j < node.ChildCount(); j++ { m, ok := parseImportStatement(node.Child(j), p.code) if !ok { continue @@ -159,12 +156,12 @@ func (p *FileParser) parseImportStatements(node *sitter.Node) bool { } p.output.Modules = append(p.output.Modules, m) } - } else if node.Type() == sitterNodeTypeImportFromStatement { - from := node.Child(1).Content(p.code) + } else if node.Kind() == sitterNodeTypeImportFromStatement { + from := node.Child(1).Utf8Text(p.code) if strings.HasPrefix(from, ".") { return true } - for j := 3; j < int(node.ChildCount()); j++ { + for j := uint(3); j < node.ChildCount(); j++ { m, ok := parseImportStatement(node.Child(j), p.code) if !ok { continue @@ -183,8 +180,8 @@ func (p *FileParser) parseImportStatements(node *sitter.Node) bool { // parseComments parses a node for comments, returning true if the node is a comment. // It updates FileParser.output.Comments with the parsed comment. func (p *FileParser) parseComments(node *sitter.Node) bool { - if node.Type() == sitterNodeTypeComment { - p.output.Comments = append(p.output.Comments, comment(node.Content(p.code))) + if node.Kind() == sitterNodeTypeComment { + p.output.Comments = append(p.output.Comments, comment(node.Utf8Text(p.code))) return true } return false @@ -200,7 +197,7 @@ func (p *FileParser) parse(ctx context.Context, node *sitter.Node) { if node == nil { return } - for i := 0; i < int(node.ChildCount()); i++ { + for i := uint(0); i < node.ChildCount(); i++ { if err := ctx.Err(); err != nil { return } diff --git a/gazelle/python/parser.go b/gazelle/python/parser.go index 1b2a90dddf..6b1d99c9b2 100644 --- a/gazelle/python/parser.go +++ b/gazelle/python/parser.go @@ -152,7 +152,7 @@ type module struct { // statements. Name string `json:"name"` // The line number where the import happened. - LineNumber uint32 `json:"lineno"` + LineNumber uint `json:"lineno"` // The path to the module file relative to the Bazel workspace root. Filepath string `json:"filepath"` // If this was a from import, e.g. from foo import bar, From indicates the module From b7e3913e6714c9b61abf311f0f940cac19e67b8d Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Sun, 6 Jul 2025 06:21:17 +0000 Subject: [PATCH 23/29] Revert "official tree-sitter" This reverts commit 406e3d55ce3de19848ef2c901c6d0f0932080573. --- gazelle/MODULE.bazel | 3 +- gazelle/go.mod | 10 +++---- gazelle/go.sum | 34 +++------------------- gazelle/python/BUILD.bazel | 7 +++-- gazelle/python/file_parser.go | 53 ++++++++++++++++++----------------- gazelle/python/parser.go | 2 +- 6 files changed, 42 insertions(+), 67 deletions(-) diff --git a/gazelle/MODULE.bazel b/gazelle/MODULE.bazel index 7521ab48c7..c1ad653f35 100644 --- a/gazelle/MODULE.bazel +++ b/gazelle/MODULE.bazel @@ -23,9 +23,8 @@ use_repo( "com_github_bmatcuk_doublestar_v4", "com_github_emirpasic_gods", "com_github_ghodss_yaml", + "com_github_smacker_go_tree_sitter", "com_github_stretchr_testify", - "com_github_tree_sitter_go_tree_sitter", - "com_github_tree_sitter_tree_sitter_python", "in_gopkg_yaml_v2", "org_golang_x_sync", ) diff --git a/gazelle/go.mod b/gazelle/go.mod index 4b507d5200..637e8f689b 100644 --- a/gazelle/go.mod +++ b/gazelle/go.mod @@ -1,8 +1,8 @@ module github.com/bazel-contrib/rules_python/gazelle -go 1.23 +go 1.22.9 -toolchain go1.24.4 +toolchain go1.24.2 require ( github.com/bazelbuild/bazel-gazelle v0.36.0 @@ -11,9 +11,8 @@ require ( github.com/bmatcuk/doublestar/v4 v4.7.1 github.com/emirpasic/gods v1.18.1 github.com/ghodss/yaml v1.0.0 - github.com/stretchr/testify v1.10.0 - github.com/tree-sitter/go-tree-sitter v0.25.0 - github.com/tree-sitter/tree-sitter-python v0.23.6 + github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82 + github.com/stretchr/testify v1.9.0 golang.org/x/sync v0.11.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -21,7 +20,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/mattn/go-pointer v0.0.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/mod v0.23.0 // indirect golang.org/x/sys v0.30.0 // indirect diff --git a/gazelle/go.sum b/gazelle/go.sum index 08038ff983..3bcd8ad947 100644 --- a/gazelle/go.sum +++ b/gazelle/go.sum @@ -14,38 +14,12 @@ github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0= -github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/tree-sitter/go-tree-sitter v0.25.0 h1:sx6kcg8raRFCvc9BnXglke6axya12krCJF5xJ2sftRU= -github.com/tree-sitter/go-tree-sitter v0.25.0/go.mod h1:r77ig7BikoZhHrrsjAnv8RqGti5rtSyvDHPzgTPsUuU= -github.com/tree-sitter/tree-sitter-c v0.23.4 h1:nBPH3FV07DzAD7p0GfNvXM+Y7pNIoPenQWBpvM++t4c= -github.com/tree-sitter/tree-sitter-c v0.23.4/go.mod h1:MkI5dOiIpeN94LNjeCp8ljXN/953JCwAby4bClMr6bw= -github.com/tree-sitter/tree-sitter-cpp v0.23.4 h1:LaWZsiqQKvR65yHgKmnaqA+uz6tlDJTJFCyFIeZU/8w= -github.com/tree-sitter/tree-sitter-cpp v0.23.4/go.mod h1:doqNW64BriC7WBCQ1klf0KmJpdEvfxyXtoEybnBo6v8= -github.com/tree-sitter/tree-sitter-embedded-template v0.23.2 h1:nFkkH6Sbe56EXLmZBqHHcamTpmz3TId97I16EnGy4rg= -github.com/tree-sitter/tree-sitter-embedded-template v0.23.2/go.mod h1:HNPOhN0qF3hWluYLdxWs5WbzP/iE4aaRVPMsdxuzIaQ= -github.com/tree-sitter/tree-sitter-go v0.23.4 h1:yt5KMGnTHS+86pJmLIAZMWxukr8W7Ae1STPvQUuNROA= -github.com/tree-sitter/tree-sitter-go v0.23.4/go.mod h1:Jrx8QqYN0v7npv1fJRH1AznddllYiCMUChtVjxPK040= -github.com/tree-sitter/tree-sitter-html v0.23.2 h1:1UYDV+Yd05GGRhVnTcbP58GkKLSHHZwVaN+lBZV11Lc= -github.com/tree-sitter/tree-sitter-html v0.23.2/go.mod h1:gpUv/dG3Xl/eebqgeYeFMt+JLOY9cgFinb/Nw08a9og= -github.com/tree-sitter/tree-sitter-java v0.23.5 h1:J9YeMGMwXYlKSP3K4Us8CitC6hjtMjqpeOf2GGo6tig= -github.com/tree-sitter/tree-sitter-java v0.23.5/go.mod h1:NRKlI8+EznxA7t1Yt3xtraPk1Wzqh3GAIC46wxvc320= -github.com/tree-sitter/tree-sitter-javascript v0.23.1 h1:1fWupaRC0ArlHJ/QJzsfQ3Ibyopw7ZfQK4xXc40Zveo= -github.com/tree-sitter/tree-sitter-javascript v0.23.1/go.mod h1:lmGD1EJdCA+v0S1u2fFgepMg/opzSg/4pgFym2FPGAs= -github.com/tree-sitter/tree-sitter-json v0.24.8 h1:tV5rMkihgtiOe14a9LHfDY5kzTl5GNUYe6carZBn0fQ= -github.com/tree-sitter/tree-sitter-json v0.24.8/go.mod h1:F351KK0KGvCaYbZ5zxwx/gWWvZhIDl0eMtn+1r+gQbo= -github.com/tree-sitter/tree-sitter-php v0.23.11 h1:iHewsLNDmznh8kgGyfWfujsZxIz1YGbSd2ZTEM0ZiP8= -github.com/tree-sitter/tree-sitter-php v0.23.11/go.mod h1:T/kbfi+UcCywQfUNAJnGTN/fMSUjnwPXA8k4yoIks74= -github.com/tree-sitter/tree-sitter-python v0.23.6 h1:qHnWFR5WhtMQpxBZRwiaU5Hk/29vGju6CVtmvu5Haas= -github.com/tree-sitter/tree-sitter-python v0.23.6/go.mod h1:cpdthSy/Yoa28aJFBscFHlGiU+cnSiSh1kuDVtI8YeM= -github.com/tree-sitter/tree-sitter-ruby v0.23.1 h1:T/NKHUA+iVbHM440hFx+lzVOzS4dV6z8Qw8ai+72bYo= -github.com/tree-sitter/tree-sitter-ruby v0.23.1/go.mod h1:kUS4kCCQloFcdX6sdpr8p6r2rogbM6ZjTox5ZOQy8cA= -github.com/tree-sitter/tree-sitter-rust v0.23.2 h1:6AtoooCW5GqNrRpfnvl0iUhxTAZEovEmLKDbyHlfw90= -github.com/tree-sitter/tree-sitter-rust v0.23.2/go.mod h1:hfeGWic9BAfgTrc7Xf6FaOAguCFJRo3RBbs7QJ6D7MI= +github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82 h1:6C8qej6f1bStuePVkLSFxoU22XBS165D3klxlzRg8F4= +github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82/go.mod h1:xe4pgH49k4SsmkQq5OT8abwhWmnzkhpgnXeekbx2efw= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM= golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= diff --git a/gazelle/python/BUILD.bazel b/gazelle/python/BUILD.bazel index e5255c4184..e4e7f04d5f 100644 --- a/gazelle/python/BUILD.bazel +++ b/gazelle/python/BUILD.bazel @@ -29,6 +29,7 @@ go_library( importpath = "github.com/bazel-contrib/rules_python/gazelle/python", visibility = ["//visibility:public"], deps = [ + "//manifest", "//pythonconfig", "@bazel_gazelle//config:go_default_library", "@bazel_gazelle//label:go_default_library", @@ -36,13 +37,13 @@ go_library( "@bazel_gazelle//repo:go_default_library", "@bazel_gazelle//resolve:go_default_library", "@bazel_gazelle//rule:go_default_library", - "@com_github_bazelbuild_buildtools//build", + "@com_github_bazelbuild_buildtools//build:go_default_library", "@com_github_bmatcuk_doublestar_v4//:doublestar", "@com_github_emirpasic_gods//lists/singlylinkedlist", "@com_github_emirpasic_gods//sets/treeset", "@com_github_emirpasic_gods//utils", - "@com_github_tree_sitter_go_tree_sitter//:go-tree-sitter", - "@com_github_tree_sitter_tree_sitter_python//bindings/go", + "@com_github_smacker_go_tree_sitter//:go-tree-sitter", + "@com_github_smacker_go_tree_sitter//python", "@org_golang_x_sync//errgroup", ], ) diff --git a/gazelle/python/file_parser.go b/gazelle/python/file_parser.go index 037d9b7c09..4ebd26192e 100644 --- a/gazelle/python/file_parser.go +++ b/gazelle/python/file_parser.go @@ -22,8 +22,8 @@ import ( "path/filepath" "strings" - sitter "github.com/tree-sitter/go-tree-sitter" - python "github.com/tree-sitter/tree-sitter-python/bindings/go" + sitter "github.com/smacker/go-tree-sitter" + "github.com/smacker/go-tree-sitter/python" ) const ( @@ -61,9 +61,12 @@ func NewFileParser() *FileParser { // It prints a warning if parsing fails. func ParseCode(code []byte, path string) (*sitter.Node, error) { parser := sitter.NewParser() - parser.SetLanguage(sitter.NewLanguage(python.Language())) + parser.SetLanguage(python.GetLanguage()) - tree := parser.Parse(code, nil) + tree, err := parser.ParseCtx(context.Background(), nil, code) + if err != nil { + return nil, err + } root := tree.RootNode() if !root.HasError() { @@ -79,16 +82,16 @@ func ParseCode(code []byte, path string) (*sitter.Node, error) { return root, nil } - for i := uint(0); i < root.ChildCount(); i++ { + for i := 0; i < int(root.ChildCount()); i++ { child := root.Child(i) if child.IsError() { // Example logs: // gazelle: Parse error at {Row:1 Column:0}: // def search_one_more_level[T](): - log.Printf("Parse error at %+v:\n%+v", child.StartPosition(), child.Utf8Text(code)) + log.Printf("Parse error at %+v:\n%+v", child.StartPoint(), child.Content(code)) // Log the internal tree-sitter representation of what was parsed. Eg: // gazelle: The above was parsed as: (ERROR (identifier) (call function: (list (identifier)) arguments: (argument_list))) - log.Printf("The above was parsed as: %v", child.Kind()) + log.Printf("The above was parsed as: %v", child.String()) } } @@ -98,21 +101,21 @@ func ParseCode(code []byte, path string) (*sitter.Node, error) { // parseMain returns true if the python file has an `if __name__ == "__main__":` block, // which is a common idiom for python scripts/binaries. func (p *FileParser) parseMain(ctx context.Context, node *sitter.Node) bool { - for i := uint(0); i < node.ChildCount(); i++ { + for i := 0; i < int(node.ChildCount()); i++ { if err := ctx.Err(); err != nil { return false } child := node.Child(i) - if child.Kind() == sitterNodeTypeIfStatement && - child.Child(1).Kind() == sitterNodeTypeComparisonOperator && child.Child(1).Child(1).Kind() == "==" { + if child.Type() == sitterNodeTypeIfStatement && + child.Child(1).Type() == sitterNodeTypeComparisonOperator && child.Child(1).Child(1).Type() == "==" { statement := child.Child(1) a, b := statement.Child(0), statement.Child(2) // convert "'__main__' == __name__" to "__name__ == '__main__'" - if b.Kind() == sitterNodeTypeIdentifier { + if b.Type() == sitterNodeTypeIdentifier { a, b = b, a } - if a.Kind() == sitterNodeTypeIdentifier && a.Utf8Text(p.code) == "__name__" && - b.Kind() == sitterNodeTypeString && string(p.code[b.StartByte()+1:b.EndByte()-1]) == "__main__" { + if a.Type() == sitterNodeTypeIdentifier && a.Content(p.code) == "__name__" && + b.Type() == sitterNodeTypeString && string(p.code[b.StartByte()+1:b.EndByte()-1]) == "__main__" { return true } } @@ -123,18 +126,18 @@ func (p *FileParser) parseMain(ctx context.Context, node *sitter.Node) bool { // parseImportStatement parses a node for an import statement, returning a `module` and a boolean // representing if the parse was OK or not. func parseImportStatement(node *sitter.Node, code []byte) (module, bool) { - switch node.Kind() { + switch node.Type() { case sitterNodeTypeDottedName: return module{ - Name: node.Utf8Text(code), - LineNumber: node.StartPosition().Row + 1, + Name: node.Content(code), + LineNumber: node.StartPoint().Row + 1, }, true case sitterNodeTypeAliasedImport: return parseImportStatement(node.Child(0), code) case sitterNodeTypeWildcardImport: return module{ Name: "*", - LineNumber: node.StartPosition().Row + 1, + LineNumber: node.StartPoint().Row + 1, }, true } return module{}, false @@ -144,8 +147,8 @@ func parseImportStatement(node *sitter.Node, code []byte) (module, bool) { // an import statement. It updates FileParser.output.Modules with the `module` that the // import represents. func (p *FileParser) parseImportStatements(node *sitter.Node) bool { - if node.Kind() == sitterNodeTypeImportStatement { - for j := uint(1); j < node.ChildCount(); j++ { + if node.Type() == sitterNodeTypeImportStatement { + for j := 1; j < int(node.ChildCount()); j++ { m, ok := parseImportStatement(node.Child(j), p.code) if !ok { continue @@ -156,12 +159,12 @@ func (p *FileParser) parseImportStatements(node *sitter.Node) bool { } p.output.Modules = append(p.output.Modules, m) } - } else if node.Kind() == sitterNodeTypeImportFromStatement { - from := node.Child(1).Utf8Text(p.code) + } else if node.Type() == sitterNodeTypeImportFromStatement { + from := node.Child(1).Content(p.code) if strings.HasPrefix(from, ".") { return true } - for j := uint(3); j < node.ChildCount(); j++ { + for j := 3; j < int(node.ChildCount()); j++ { m, ok := parseImportStatement(node.Child(j), p.code) if !ok { continue @@ -180,8 +183,8 @@ func (p *FileParser) parseImportStatements(node *sitter.Node) bool { // parseComments parses a node for comments, returning true if the node is a comment. // It updates FileParser.output.Comments with the parsed comment. func (p *FileParser) parseComments(node *sitter.Node) bool { - if node.Kind() == sitterNodeTypeComment { - p.output.Comments = append(p.output.Comments, comment(node.Utf8Text(p.code))) + if node.Type() == sitterNodeTypeComment { + p.output.Comments = append(p.output.Comments, comment(node.Content(p.code))) return true } return false @@ -197,7 +200,7 @@ func (p *FileParser) parse(ctx context.Context, node *sitter.Node) { if node == nil { return } - for i := uint(0); i < node.ChildCount(); i++ { + for i := 0; i < int(node.ChildCount()); i++ { if err := ctx.Err(); err != nil { return } diff --git a/gazelle/python/parser.go b/gazelle/python/parser.go index 6b1d99c9b2..1b2a90dddf 100644 --- a/gazelle/python/parser.go +++ b/gazelle/python/parser.go @@ -152,7 +152,7 @@ type module struct { // statements. Name string `json:"name"` // The line number where the import happened. - LineNumber uint `json:"lineno"` + LineNumber uint32 `json:"lineno"` // The path to the module file relative to the Bazel workspace root. Filepath string `json:"filepath"` // If this was a from import, e.g. from foo import bar, From indicates the module From 68494247d8e42d33e9c3c2331caf8d24342cb635 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Sun, 6 Jul 2025 06:22:51 +0000 Subject: [PATCH 24/29] 1.21.x seems to be a sweet spot, at least locally. But will it work on Windows?? --- examples/build_file_generation/WORKSPACE | 2 +- gazelle/WORKSPACE | 2 +- gazelle/go.mod | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/build_file_generation/WORKSPACE b/examples/build_file_generation/WORKSPACE index 8d09933c36..5e9fb919d8 100644 --- a/examples/build_file_generation/WORKSPACE +++ b/examples/build_file_generation/WORKSPACE @@ -49,7 +49,7 @@ go_rules_dependencies() # go_rules_dependencies is a function that registers external dependencies # needed by the Go rules. # See: https://github.com/bazelbuild/rules_go/blob/master/go/dependencies.rst#go_rules_dependencies -go_register_toolchains(version = "1.22.0") +go_register_toolchains(version = "1.21.12") # The following call configured the gazelle dependencies, Go environment and Go SDK. gazelle_dependencies() diff --git a/gazelle/WORKSPACE b/gazelle/WORKSPACE index 908fe242aa..6ae917d4b6 100644 --- a/gazelle/WORKSPACE +++ b/gazelle/WORKSPACE @@ -25,7 +25,7 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_depe go_rules_dependencies() -go_register_toolchains(version = "1.22.9") +go_register_toolchains(version = "1.21.12") gazelle_dependencies() diff --git a/gazelle/go.mod b/gazelle/go.mod index 637e8f689b..041183d13d 100644 --- a/gazelle/go.mod +++ b/gazelle/go.mod @@ -1,6 +1,6 @@ module github.com/bazel-contrib/rules_python/gazelle -go 1.22.9 +go 1.21.12 toolchain go1.24.2 From 252ade193b30b5b93820504a8c780e4501c4d94a Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Sun, 6 Jul 2025 06:36:13 +0000 Subject: [PATCH 25/29] Revert "1.21.x seems to be a sweet spot, at least locally. But will it work on Windows??" This reverts commit 68494247d8e42d33e9c3c2331caf8d24342cb635. --- examples/build_file_generation/WORKSPACE | 2 +- gazelle/WORKSPACE | 2 +- gazelle/go.mod | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/build_file_generation/WORKSPACE b/examples/build_file_generation/WORKSPACE index 5e9fb919d8..8d09933c36 100644 --- a/examples/build_file_generation/WORKSPACE +++ b/examples/build_file_generation/WORKSPACE @@ -49,7 +49,7 @@ go_rules_dependencies() # go_rules_dependencies is a function that registers external dependencies # needed by the Go rules. # See: https://github.com/bazelbuild/rules_go/blob/master/go/dependencies.rst#go_rules_dependencies -go_register_toolchains(version = "1.21.12") +go_register_toolchains(version = "1.22.0") # The following call configured the gazelle dependencies, Go environment and Go SDK. gazelle_dependencies() diff --git a/gazelle/WORKSPACE b/gazelle/WORKSPACE index 6ae917d4b6..908fe242aa 100644 --- a/gazelle/WORKSPACE +++ b/gazelle/WORKSPACE @@ -25,7 +25,7 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_depe go_rules_dependencies() -go_register_toolchains(version = "1.21.12") +go_register_toolchains(version = "1.22.9") gazelle_dependencies() diff --git a/gazelle/go.mod b/gazelle/go.mod index 041183d13d..637e8f689b 100644 --- a/gazelle/go.mod +++ b/gazelle/go.mod @@ -1,6 +1,6 @@ module github.com/bazel-contrib/rules_python/gazelle -go 1.21.12 +go 1.22.9 toolchain go1.24.2 From b0da025e70989d16568056e8d8205ae386451d89 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Sun, 6 Jul 2025 06:40:27 +0000 Subject: [PATCH 26/29] Reapply "official tree-sitter" and fix it up. Doesn't work locally. This reverts commit b7e3913e6714c9b61abf311f0f940cac19e67b8d. --- gazelle/MODULE.bazel | 3 +- gazelle/deps.bzl | 94 ++++++++++++++++++++++++++++++++--- gazelle/go.mod | 10 ++-- gazelle/go.sum | 34 +++++++++++-- gazelle/python/BUILD.bazel | 7 ++- gazelle/python/file_parser.go | 53 ++++++++++---------- gazelle/python/parser.go | 2 +- 7 files changed, 153 insertions(+), 50 deletions(-) diff --git a/gazelle/MODULE.bazel b/gazelle/MODULE.bazel index c1ad653f35..7521ab48c7 100644 --- a/gazelle/MODULE.bazel +++ b/gazelle/MODULE.bazel @@ -23,8 +23,9 @@ use_repo( "com_github_bmatcuk_doublestar_v4", "com_github_emirpasic_gods", "com_github_ghodss_yaml", - "com_github_smacker_go_tree_sitter", "com_github_stretchr_testify", + "com_github_tree_sitter_go_tree_sitter", + "com_github_tree_sitter_tree_sitter_python", "in_gopkg_yaml_v2", "org_golang_x_sync", ) diff --git a/gazelle/deps.bzl b/gazelle/deps.bzl index 22807ad39a..11decad025 100644 --- a/gazelle/deps.bzl +++ b/gazelle/deps.bzl @@ -113,18 +113,18 @@ def go_deps(): sum = "h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=", version = "v0.6.0", ) + go_repository( + name = "com_github_mattn_go_pointer", + importpath = "github.com/mattn/go-pointer", + sum = "h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0=", + version = "v0.0.1", + ) go_repository( name = "com_github_pmezard_go_difflib", importpath = "github.com/pmezard/go-difflib", sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=", version = "v1.0.0", ) - go_repository( - name = "com_github_smacker_go_tree_sitter", - importpath = "github.com/smacker/go-tree-sitter", - sum = "h1:6C8qej6f1bStuePVkLSFxoU22XBS165D3klxlzRg8F4=", - version = "v0.0.0-20240827094217-dd81d9e9be82", - ) go_repository( name = "com_github_stretchr_objx", importpath = "github.com/stretchr/objx", @@ -134,8 +134,86 @@ def go_deps(): go_repository( name = "com_github_stretchr_testify", importpath = "github.com/stretchr/testify", - sum = "h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=", - version = "v1.9.0", + sum = "h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=", + version = "v1.10.0", + ) + go_repository( + name = "com_github_tree_sitter_go_tree_sitter", + importpath = "github.com/tree-sitter/go-tree-sitter", + sum = "h1:sx6kcg8raRFCvc9BnXglke6axya12krCJF5xJ2sftRU=", + version = "v0.25.0", + ) + go_repository( + name = "com_github_tree_sitter_tree_sitter_c", + importpath = "github.com/tree-sitter/tree-sitter-c", + sum = "h1:nBPH3FV07DzAD7p0GfNvXM+Y7pNIoPenQWBpvM++t4c=", + version = "v0.23.4", + ) + go_repository( + name = "com_github_tree_sitter_tree_sitter_cpp", + importpath = "github.com/tree-sitter/tree-sitter-cpp", + sum = "h1:LaWZsiqQKvR65yHgKmnaqA+uz6tlDJTJFCyFIeZU/8w=", + version = "v0.23.4", + ) + go_repository( + name = "com_github_tree_sitter_tree_sitter_embedded_template", + importpath = "github.com/tree-sitter/tree-sitter-embedded-template", + sum = "h1:nFkkH6Sbe56EXLmZBqHHcamTpmz3TId97I16EnGy4rg=", + version = "v0.23.2", + ) + go_repository( + name = "com_github_tree_sitter_tree_sitter_go", + importpath = "github.com/tree-sitter/tree-sitter-go", + sum = "h1:yt5KMGnTHS+86pJmLIAZMWxukr8W7Ae1STPvQUuNROA=", + version = "v0.23.4", + ) + go_repository( + name = "com_github_tree_sitter_tree_sitter_html", + importpath = "github.com/tree-sitter/tree-sitter-html", + sum = "h1:1UYDV+Yd05GGRhVnTcbP58GkKLSHHZwVaN+lBZV11Lc=", + version = "v0.23.2", + ) + go_repository( + name = "com_github_tree_sitter_tree_sitter_java", + importpath = "github.com/tree-sitter/tree-sitter-java", + sum = "h1:J9YeMGMwXYlKSP3K4Us8CitC6hjtMjqpeOf2GGo6tig=", + version = "v0.23.5", + ) + go_repository( + name = "com_github_tree_sitter_tree_sitter_javascript", + importpath = "github.com/tree-sitter/tree-sitter-javascript", + sum = "h1:1fWupaRC0ArlHJ/QJzsfQ3Ibyopw7ZfQK4xXc40Zveo=", + version = "v0.23.1", + ) + go_repository( + name = "com_github_tree_sitter_tree_sitter_json", + importpath = "github.com/tree-sitter/tree-sitter-json", + sum = "h1:tV5rMkihgtiOe14a9LHfDY5kzTl5GNUYe6carZBn0fQ=", + version = "v0.24.8", + ) + go_repository( + name = "com_github_tree_sitter_tree_sitter_php", + importpath = "github.com/tree-sitter/tree-sitter-php", + sum = "h1:iHewsLNDmznh8kgGyfWfujsZxIz1YGbSd2ZTEM0ZiP8=", + version = "v0.23.11", + ) + go_repository( + name = "com_github_tree_sitter_tree_sitter_python", + importpath = "github.com/tree-sitter/tree-sitter-python", + sum = "h1:qHnWFR5WhtMQpxBZRwiaU5Hk/29vGju6CVtmvu5Haas=", + version = "v0.23.6", + ) + go_repository( + name = "com_github_tree_sitter_tree_sitter_ruby", + importpath = "github.com/tree-sitter/tree-sitter-ruby", + sum = "h1:T/NKHUA+iVbHM440hFx+lzVOzS4dV6z8Qw8ai+72bYo=", + version = "v0.23.1", + ) + go_repository( + name = "com_github_tree_sitter_tree_sitter_rust", + importpath = "github.com/tree-sitter/tree-sitter-rust", + sum = "h1:6AtoooCW5GqNrRpfnvl0iUhxTAZEovEmLKDbyHlfw90=", + version = "v0.23.2", ) go_repository( name = "in_gopkg_check_v1", diff --git a/gazelle/go.mod b/gazelle/go.mod index 637e8f689b..4b507d5200 100644 --- a/gazelle/go.mod +++ b/gazelle/go.mod @@ -1,8 +1,8 @@ module github.com/bazel-contrib/rules_python/gazelle -go 1.22.9 +go 1.23 -toolchain go1.24.2 +toolchain go1.24.4 require ( github.com/bazelbuild/bazel-gazelle v0.36.0 @@ -11,8 +11,9 @@ require ( github.com/bmatcuk/doublestar/v4 v4.7.1 github.com/emirpasic/gods v1.18.1 github.com/ghodss/yaml v1.0.0 - github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82 - github.com/stretchr/testify v1.9.0 + github.com/stretchr/testify v1.10.0 + github.com/tree-sitter/go-tree-sitter v0.25.0 + github.com/tree-sitter/tree-sitter-python v0.23.6 golang.org/x/sync v0.11.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -20,6 +21,7 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.6.0 // indirect + github.com/mattn/go-pointer v0.0.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/mod v0.23.0 // indirect golang.org/x/sys v0.30.0 // indirect diff --git a/gazelle/go.sum b/gazelle/go.sum index 3bcd8ad947..08038ff983 100644 --- a/gazelle/go.sum +++ b/gazelle/go.sum @@ -14,12 +14,38 @@ github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0= +github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82 h1:6C8qej6f1bStuePVkLSFxoU22XBS165D3klxlzRg8F4= -github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82/go.mod h1:xe4pgH49k4SsmkQq5OT8abwhWmnzkhpgnXeekbx2efw= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/tree-sitter/go-tree-sitter v0.25.0 h1:sx6kcg8raRFCvc9BnXglke6axya12krCJF5xJ2sftRU= +github.com/tree-sitter/go-tree-sitter v0.25.0/go.mod h1:r77ig7BikoZhHrrsjAnv8RqGti5rtSyvDHPzgTPsUuU= +github.com/tree-sitter/tree-sitter-c v0.23.4 h1:nBPH3FV07DzAD7p0GfNvXM+Y7pNIoPenQWBpvM++t4c= +github.com/tree-sitter/tree-sitter-c v0.23.4/go.mod h1:MkI5dOiIpeN94LNjeCp8ljXN/953JCwAby4bClMr6bw= +github.com/tree-sitter/tree-sitter-cpp v0.23.4 h1:LaWZsiqQKvR65yHgKmnaqA+uz6tlDJTJFCyFIeZU/8w= +github.com/tree-sitter/tree-sitter-cpp v0.23.4/go.mod h1:doqNW64BriC7WBCQ1klf0KmJpdEvfxyXtoEybnBo6v8= +github.com/tree-sitter/tree-sitter-embedded-template v0.23.2 h1:nFkkH6Sbe56EXLmZBqHHcamTpmz3TId97I16EnGy4rg= +github.com/tree-sitter/tree-sitter-embedded-template v0.23.2/go.mod h1:HNPOhN0qF3hWluYLdxWs5WbzP/iE4aaRVPMsdxuzIaQ= +github.com/tree-sitter/tree-sitter-go v0.23.4 h1:yt5KMGnTHS+86pJmLIAZMWxukr8W7Ae1STPvQUuNROA= +github.com/tree-sitter/tree-sitter-go v0.23.4/go.mod h1:Jrx8QqYN0v7npv1fJRH1AznddllYiCMUChtVjxPK040= +github.com/tree-sitter/tree-sitter-html v0.23.2 h1:1UYDV+Yd05GGRhVnTcbP58GkKLSHHZwVaN+lBZV11Lc= +github.com/tree-sitter/tree-sitter-html v0.23.2/go.mod h1:gpUv/dG3Xl/eebqgeYeFMt+JLOY9cgFinb/Nw08a9og= +github.com/tree-sitter/tree-sitter-java v0.23.5 h1:J9YeMGMwXYlKSP3K4Us8CitC6hjtMjqpeOf2GGo6tig= +github.com/tree-sitter/tree-sitter-java v0.23.5/go.mod h1:NRKlI8+EznxA7t1Yt3xtraPk1Wzqh3GAIC46wxvc320= +github.com/tree-sitter/tree-sitter-javascript v0.23.1 h1:1fWupaRC0ArlHJ/QJzsfQ3Ibyopw7ZfQK4xXc40Zveo= +github.com/tree-sitter/tree-sitter-javascript v0.23.1/go.mod h1:lmGD1EJdCA+v0S1u2fFgepMg/opzSg/4pgFym2FPGAs= +github.com/tree-sitter/tree-sitter-json v0.24.8 h1:tV5rMkihgtiOe14a9LHfDY5kzTl5GNUYe6carZBn0fQ= +github.com/tree-sitter/tree-sitter-json v0.24.8/go.mod h1:F351KK0KGvCaYbZ5zxwx/gWWvZhIDl0eMtn+1r+gQbo= +github.com/tree-sitter/tree-sitter-php v0.23.11 h1:iHewsLNDmznh8kgGyfWfujsZxIz1YGbSd2ZTEM0ZiP8= +github.com/tree-sitter/tree-sitter-php v0.23.11/go.mod h1:T/kbfi+UcCywQfUNAJnGTN/fMSUjnwPXA8k4yoIks74= +github.com/tree-sitter/tree-sitter-python v0.23.6 h1:qHnWFR5WhtMQpxBZRwiaU5Hk/29vGju6CVtmvu5Haas= +github.com/tree-sitter/tree-sitter-python v0.23.6/go.mod h1:cpdthSy/Yoa28aJFBscFHlGiU+cnSiSh1kuDVtI8YeM= +github.com/tree-sitter/tree-sitter-ruby v0.23.1 h1:T/NKHUA+iVbHM440hFx+lzVOzS4dV6z8Qw8ai+72bYo= +github.com/tree-sitter/tree-sitter-ruby v0.23.1/go.mod h1:kUS4kCCQloFcdX6sdpr8p6r2rogbM6ZjTox5ZOQy8cA= +github.com/tree-sitter/tree-sitter-rust v0.23.2 h1:6AtoooCW5GqNrRpfnvl0iUhxTAZEovEmLKDbyHlfw90= +github.com/tree-sitter/tree-sitter-rust v0.23.2/go.mod h1:hfeGWic9BAfgTrc7Xf6FaOAguCFJRo3RBbs7QJ6D7MI= golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM= golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= diff --git a/gazelle/python/BUILD.bazel b/gazelle/python/BUILD.bazel index e4e7f04d5f..e5255c4184 100644 --- a/gazelle/python/BUILD.bazel +++ b/gazelle/python/BUILD.bazel @@ -29,7 +29,6 @@ go_library( importpath = "github.com/bazel-contrib/rules_python/gazelle/python", visibility = ["//visibility:public"], deps = [ - "//manifest", "//pythonconfig", "@bazel_gazelle//config:go_default_library", "@bazel_gazelle//label:go_default_library", @@ -37,13 +36,13 @@ go_library( "@bazel_gazelle//repo:go_default_library", "@bazel_gazelle//resolve:go_default_library", "@bazel_gazelle//rule:go_default_library", - "@com_github_bazelbuild_buildtools//build:go_default_library", + "@com_github_bazelbuild_buildtools//build", "@com_github_bmatcuk_doublestar_v4//:doublestar", "@com_github_emirpasic_gods//lists/singlylinkedlist", "@com_github_emirpasic_gods//sets/treeset", "@com_github_emirpasic_gods//utils", - "@com_github_smacker_go_tree_sitter//:go-tree-sitter", - "@com_github_smacker_go_tree_sitter//python", + "@com_github_tree_sitter_go_tree_sitter//:go-tree-sitter", + "@com_github_tree_sitter_tree_sitter_python//bindings/go", "@org_golang_x_sync//errgroup", ], ) diff --git a/gazelle/python/file_parser.go b/gazelle/python/file_parser.go index 4ebd26192e..037d9b7c09 100644 --- a/gazelle/python/file_parser.go +++ b/gazelle/python/file_parser.go @@ -22,8 +22,8 @@ import ( "path/filepath" "strings" - sitter "github.com/smacker/go-tree-sitter" - "github.com/smacker/go-tree-sitter/python" + sitter "github.com/tree-sitter/go-tree-sitter" + python "github.com/tree-sitter/tree-sitter-python/bindings/go" ) const ( @@ -61,12 +61,9 @@ func NewFileParser() *FileParser { // It prints a warning if parsing fails. func ParseCode(code []byte, path string) (*sitter.Node, error) { parser := sitter.NewParser() - parser.SetLanguage(python.GetLanguage()) + parser.SetLanguage(sitter.NewLanguage(python.Language())) - tree, err := parser.ParseCtx(context.Background(), nil, code) - if err != nil { - return nil, err - } + tree := parser.Parse(code, nil) root := tree.RootNode() if !root.HasError() { @@ -82,16 +79,16 @@ func ParseCode(code []byte, path string) (*sitter.Node, error) { return root, nil } - for i := 0; i < int(root.ChildCount()); i++ { + for i := uint(0); i < root.ChildCount(); i++ { child := root.Child(i) if child.IsError() { // Example logs: // gazelle: Parse error at {Row:1 Column:0}: // def search_one_more_level[T](): - log.Printf("Parse error at %+v:\n%+v", child.StartPoint(), child.Content(code)) + log.Printf("Parse error at %+v:\n%+v", child.StartPosition(), child.Utf8Text(code)) // Log the internal tree-sitter representation of what was parsed. Eg: // gazelle: The above was parsed as: (ERROR (identifier) (call function: (list (identifier)) arguments: (argument_list))) - log.Printf("The above was parsed as: %v", child.String()) + log.Printf("The above was parsed as: %v", child.Kind()) } } @@ -101,21 +98,21 @@ func ParseCode(code []byte, path string) (*sitter.Node, error) { // parseMain returns true if the python file has an `if __name__ == "__main__":` block, // which is a common idiom for python scripts/binaries. func (p *FileParser) parseMain(ctx context.Context, node *sitter.Node) bool { - for i := 0; i < int(node.ChildCount()); i++ { + for i := uint(0); i < node.ChildCount(); i++ { if err := ctx.Err(); err != nil { return false } child := node.Child(i) - if child.Type() == sitterNodeTypeIfStatement && - child.Child(1).Type() == sitterNodeTypeComparisonOperator && child.Child(1).Child(1).Type() == "==" { + if child.Kind() == sitterNodeTypeIfStatement && + child.Child(1).Kind() == sitterNodeTypeComparisonOperator && child.Child(1).Child(1).Kind() == "==" { statement := child.Child(1) a, b := statement.Child(0), statement.Child(2) // convert "'__main__' == __name__" to "__name__ == '__main__'" - if b.Type() == sitterNodeTypeIdentifier { + if b.Kind() == sitterNodeTypeIdentifier { a, b = b, a } - if a.Type() == sitterNodeTypeIdentifier && a.Content(p.code) == "__name__" && - b.Type() == sitterNodeTypeString && string(p.code[b.StartByte()+1:b.EndByte()-1]) == "__main__" { + if a.Kind() == sitterNodeTypeIdentifier && a.Utf8Text(p.code) == "__name__" && + b.Kind() == sitterNodeTypeString && string(p.code[b.StartByte()+1:b.EndByte()-1]) == "__main__" { return true } } @@ -126,18 +123,18 @@ func (p *FileParser) parseMain(ctx context.Context, node *sitter.Node) bool { // parseImportStatement parses a node for an import statement, returning a `module` and a boolean // representing if the parse was OK or not. func parseImportStatement(node *sitter.Node, code []byte) (module, bool) { - switch node.Type() { + switch node.Kind() { case sitterNodeTypeDottedName: return module{ - Name: node.Content(code), - LineNumber: node.StartPoint().Row + 1, + Name: node.Utf8Text(code), + LineNumber: node.StartPosition().Row + 1, }, true case sitterNodeTypeAliasedImport: return parseImportStatement(node.Child(0), code) case sitterNodeTypeWildcardImport: return module{ Name: "*", - LineNumber: node.StartPoint().Row + 1, + LineNumber: node.StartPosition().Row + 1, }, true } return module{}, false @@ -147,8 +144,8 @@ func parseImportStatement(node *sitter.Node, code []byte) (module, bool) { // an import statement. It updates FileParser.output.Modules with the `module` that the // import represents. func (p *FileParser) parseImportStatements(node *sitter.Node) bool { - if node.Type() == sitterNodeTypeImportStatement { - for j := 1; j < int(node.ChildCount()); j++ { + if node.Kind() == sitterNodeTypeImportStatement { + for j := uint(1); j < node.ChildCount(); j++ { m, ok := parseImportStatement(node.Child(j), p.code) if !ok { continue @@ -159,12 +156,12 @@ func (p *FileParser) parseImportStatements(node *sitter.Node) bool { } p.output.Modules = append(p.output.Modules, m) } - } else if node.Type() == sitterNodeTypeImportFromStatement { - from := node.Child(1).Content(p.code) + } else if node.Kind() == sitterNodeTypeImportFromStatement { + from := node.Child(1).Utf8Text(p.code) if strings.HasPrefix(from, ".") { return true } - for j := 3; j < int(node.ChildCount()); j++ { + for j := uint(3); j < node.ChildCount(); j++ { m, ok := parseImportStatement(node.Child(j), p.code) if !ok { continue @@ -183,8 +180,8 @@ func (p *FileParser) parseImportStatements(node *sitter.Node) bool { // parseComments parses a node for comments, returning true if the node is a comment. // It updates FileParser.output.Comments with the parsed comment. func (p *FileParser) parseComments(node *sitter.Node) bool { - if node.Type() == sitterNodeTypeComment { - p.output.Comments = append(p.output.Comments, comment(node.Content(p.code))) + if node.Kind() == sitterNodeTypeComment { + p.output.Comments = append(p.output.Comments, comment(node.Utf8Text(p.code))) return true } return false @@ -200,7 +197,7 @@ func (p *FileParser) parse(ctx context.Context, node *sitter.Node) { if node == nil { return } - for i := 0; i < int(node.ChildCount()); i++ { + for i := uint(0); i < node.ChildCount(); i++ { if err := ctx.Err(); err != nil { return } diff --git a/gazelle/python/parser.go b/gazelle/python/parser.go index 1b2a90dddf..6b1d99c9b2 100644 --- a/gazelle/python/parser.go +++ b/gazelle/python/parser.go @@ -152,7 +152,7 @@ type module struct { // statements. Name string `json:"name"` // The line number where the import happened. - LineNumber uint32 `json:"lineno"` + LineNumber uint `json:"lineno"` // The path to the module file relative to the Bazel workspace root. Filepath string `json:"filepath"` // If this was a from import, e.g. from foo import bar, From indicates the module From 20741ea3b10a5274696d50686d082d7a59b38302 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Mon, 7 Jul 2025 23:01:42 +0000 Subject: [PATCH 27/29] Revert "Reapply "official tree-sitter" and fix it up. Doesn't work locally." This reverts commit b0da025e70989d16568056e8d8205ae386451d89. --- gazelle/MODULE.bazel | 3 +- gazelle/deps.bzl | 94 +++-------------------------------- gazelle/go.mod | 10 ++-- gazelle/go.sum | 34 ++----------- gazelle/python/BUILD.bazel | 7 +-- gazelle/python/file_parser.go | 53 ++++++++++---------- gazelle/python/parser.go | 2 +- 7 files changed, 50 insertions(+), 153 deletions(-) diff --git a/gazelle/MODULE.bazel b/gazelle/MODULE.bazel index 7521ab48c7..c1ad653f35 100644 --- a/gazelle/MODULE.bazel +++ b/gazelle/MODULE.bazel @@ -23,9 +23,8 @@ use_repo( "com_github_bmatcuk_doublestar_v4", "com_github_emirpasic_gods", "com_github_ghodss_yaml", + "com_github_smacker_go_tree_sitter", "com_github_stretchr_testify", - "com_github_tree_sitter_go_tree_sitter", - "com_github_tree_sitter_tree_sitter_python", "in_gopkg_yaml_v2", "org_golang_x_sync", ) diff --git a/gazelle/deps.bzl b/gazelle/deps.bzl index 11decad025..22807ad39a 100644 --- a/gazelle/deps.bzl +++ b/gazelle/deps.bzl @@ -113,18 +113,18 @@ def go_deps(): sum = "h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=", version = "v0.6.0", ) - go_repository( - name = "com_github_mattn_go_pointer", - importpath = "github.com/mattn/go-pointer", - sum = "h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0=", - version = "v0.0.1", - ) go_repository( name = "com_github_pmezard_go_difflib", importpath = "github.com/pmezard/go-difflib", sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=", version = "v1.0.0", ) + go_repository( + name = "com_github_smacker_go_tree_sitter", + importpath = "github.com/smacker/go-tree-sitter", + sum = "h1:6C8qej6f1bStuePVkLSFxoU22XBS165D3klxlzRg8F4=", + version = "v0.0.0-20240827094217-dd81d9e9be82", + ) go_repository( name = "com_github_stretchr_objx", importpath = "github.com/stretchr/objx", @@ -134,86 +134,8 @@ def go_deps(): go_repository( name = "com_github_stretchr_testify", importpath = "github.com/stretchr/testify", - sum = "h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=", - version = "v1.10.0", - ) - go_repository( - name = "com_github_tree_sitter_go_tree_sitter", - importpath = "github.com/tree-sitter/go-tree-sitter", - sum = "h1:sx6kcg8raRFCvc9BnXglke6axya12krCJF5xJ2sftRU=", - version = "v0.25.0", - ) - go_repository( - name = "com_github_tree_sitter_tree_sitter_c", - importpath = "github.com/tree-sitter/tree-sitter-c", - sum = "h1:nBPH3FV07DzAD7p0GfNvXM+Y7pNIoPenQWBpvM++t4c=", - version = "v0.23.4", - ) - go_repository( - name = "com_github_tree_sitter_tree_sitter_cpp", - importpath = "github.com/tree-sitter/tree-sitter-cpp", - sum = "h1:LaWZsiqQKvR65yHgKmnaqA+uz6tlDJTJFCyFIeZU/8w=", - version = "v0.23.4", - ) - go_repository( - name = "com_github_tree_sitter_tree_sitter_embedded_template", - importpath = "github.com/tree-sitter/tree-sitter-embedded-template", - sum = "h1:nFkkH6Sbe56EXLmZBqHHcamTpmz3TId97I16EnGy4rg=", - version = "v0.23.2", - ) - go_repository( - name = "com_github_tree_sitter_tree_sitter_go", - importpath = "github.com/tree-sitter/tree-sitter-go", - sum = "h1:yt5KMGnTHS+86pJmLIAZMWxukr8W7Ae1STPvQUuNROA=", - version = "v0.23.4", - ) - go_repository( - name = "com_github_tree_sitter_tree_sitter_html", - importpath = "github.com/tree-sitter/tree-sitter-html", - sum = "h1:1UYDV+Yd05GGRhVnTcbP58GkKLSHHZwVaN+lBZV11Lc=", - version = "v0.23.2", - ) - go_repository( - name = "com_github_tree_sitter_tree_sitter_java", - importpath = "github.com/tree-sitter/tree-sitter-java", - sum = "h1:J9YeMGMwXYlKSP3K4Us8CitC6hjtMjqpeOf2GGo6tig=", - version = "v0.23.5", - ) - go_repository( - name = "com_github_tree_sitter_tree_sitter_javascript", - importpath = "github.com/tree-sitter/tree-sitter-javascript", - sum = "h1:1fWupaRC0ArlHJ/QJzsfQ3Ibyopw7ZfQK4xXc40Zveo=", - version = "v0.23.1", - ) - go_repository( - name = "com_github_tree_sitter_tree_sitter_json", - importpath = "github.com/tree-sitter/tree-sitter-json", - sum = "h1:tV5rMkihgtiOe14a9LHfDY5kzTl5GNUYe6carZBn0fQ=", - version = "v0.24.8", - ) - go_repository( - name = "com_github_tree_sitter_tree_sitter_php", - importpath = "github.com/tree-sitter/tree-sitter-php", - sum = "h1:iHewsLNDmznh8kgGyfWfujsZxIz1YGbSd2ZTEM0ZiP8=", - version = "v0.23.11", - ) - go_repository( - name = "com_github_tree_sitter_tree_sitter_python", - importpath = "github.com/tree-sitter/tree-sitter-python", - sum = "h1:qHnWFR5WhtMQpxBZRwiaU5Hk/29vGju6CVtmvu5Haas=", - version = "v0.23.6", - ) - go_repository( - name = "com_github_tree_sitter_tree_sitter_ruby", - importpath = "github.com/tree-sitter/tree-sitter-ruby", - sum = "h1:T/NKHUA+iVbHM440hFx+lzVOzS4dV6z8Qw8ai+72bYo=", - version = "v0.23.1", - ) - go_repository( - name = "com_github_tree_sitter_tree_sitter_rust", - importpath = "github.com/tree-sitter/tree-sitter-rust", - sum = "h1:6AtoooCW5GqNrRpfnvl0iUhxTAZEovEmLKDbyHlfw90=", - version = "v0.23.2", + sum = "h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=", + version = "v1.9.0", ) go_repository( name = "in_gopkg_check_v1", diff --git a/gazelle/go.mod b/gazelle/go.mod index 4b507d5200..637e8f689b 100644 --- a/gazelle/go.mod +++ b/gazelle/go.mod @@ -1,8 +1,8 @@ module github.com/bazel-contrib/rules_python/gazelle -go 1.23 +go 1.22.9 -toolchain go1.24.4 +toolchain go1.24.2 require ( github.com/bazelbuild/bazel-gazelle v0.36.0 @@ -11,9 +11,8 @@ require ( github.com/bmatcuk/doublestar/v4 v4.7.1 github.com/emirpasic/gods v1.18.1 github.com/ghodss/yaml v1.0.0 - github.com/stretchr/testify v1.10.0 - github.com/tree-sitter/go-tree-sitter v0.25.0 - github.com/tree-sitter/tree-sitter-python v0.23.6 + github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82 + github.com/stretchr/testify v1.9.0 golang.org/x/sync v0.11.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -21,7 +20,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/mattn/go-pointer v0.0.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/mod v0.23.0 // indirect golang.org/x/sys v0.30.0 // indirect diff --git a/gazelle/go.sum b/gazelle/go.sum index 08038ff983..3bcd8ad947 100644 --- a/gazelle/go.sum +++ b/gazelle/go.sum @@ -14,38 +14,12 @@ github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0= -github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/tree-sitter/go-tree-sitter v0.25.0 h1:sx6kcg8raRFCvc9BnXglke6axya12krCJF5xJ2sftRU= -github.com/tree-sitter/go-tree-sitter v0.25.0/go.mod h1:r77ig7BikoZhHrrsjAnv8RqGti5rtSyvDHPzgTPsUuU= -github.com/tree-sitter/tree-sitter-c v0.23.4 h1:nBPH3FV07DzAD7p0GfNvXM+Y7pNIoPenQWBpvM++t4c= -github.com/tree-sitter/tree-sitter-c v0.23.4/go.mod h1:MkI5dOiIpeN94LNjeCp8ljXN/953JCwAby4bClMr6bw= -github.com/tree-sitter/tree-sitter-cpp v0.23.4 h1:LaWZsiqQKvR65yHgKmnaqA+uz6tlDJTJFCyFIeZU/8w= -github.com/tree-sitter/tree-sitter-cpp v0.23.4/go.mod h1:doqNW64BriC7WBCQ1klf0KmJpdEvfxyXtoEybnBo6v8= -github.com/tree-sitter/tree-sitter-embedded-template v0.23.2 h1:nFkkH6Sbe56EXLmZBqHHcamTpmz3TId97I16EnGy4rg= -github.com/tree-sitter/tree-sitter-embedded-template v0.23.2/go.mod h1:HNPOhN0qF3hWluYLdxWs5WbzP/iE4aaRVPMsdxuzIaQ= -github.com/tree-sitter/tree-sitter-go v0.23.4 h1:yt5KMGnTHS+86pJmLIAZMWxukr8W7Ae1STPvQUuNROA= -github.com/tree-sitter/tree-sitter-go v0.23.4/go.mod h1:Jrx8QqYN0v7npv1fJRH1AznddllYiCMUChtVjxPK040= -github.com/tree-sitter/tree-sitter-html v0.23.2 h1:1UYDV+Yd05GGRhVnTcbP58GkKLSHHZwVaN+lBZV11Lc= -github.com/tree-sitter/tree-sitter-html v0.23.2/go.mod h1:gpUv/dG3Xl/eebqgeYeFMt+JLOY9cgFinb/Nw08a9og= -github.com/tree-sitter/tree-sitter-java v0.23.5 h1:J9YeMGMwXYlKSP3K4Us8CitC6hjtMjqpeOf2GGo6tig= -github.com/tree-sitter/tree-sitter-java v0.23.5/go.mod h1:NRKlI8+EznxA7t1Yt3xtraPk1Wzqh3GAIC46wxvc320= -github.com/tree-sitter/tree-sitter-javascript v0.23.1 h1:1fWupaRC0ArlHJ/QJzsfQ3Ibyopw7ZfQK4xXc40Zveo= -github.com/tree-sitter/tree-sitter-javascript v0.23.1/go.mod h1:lmGD1EJdCA+v0S1u2fFgepMg/opzSg/4pgFym2FPGAs= -github.com/tree-sitter/tree-sitter-json v0.24.8 h1:tV5rMkihgtiOe14a9LHfDY5kzTl5GNUYe6carZBn0fQ= -github.com/tree-sitter/tree-sitter-json v0.24.8/go.mod h1:F351KK0KGvCaYbZ5zxwx/gWWvZhIDl0eMtn+1r+gQbo= -github.com/tree-sitter/tree-sitter-php v0.23.11 h1:iHewsLNDmznh8kgGyfWfujsZxIz1YGbSd2ZTEM0ZiP8= -github.com/tree-sitter/tree-sitter-php v0.23.11/go.mod h1:T/kbfi+UcCywQfUNAJnGTN/fMSUjnwPXA8k4yoIks74= -github.com/tree-sitter/tree-sitter-python v0.23.6 h1:qHnWFR5WhtMQpxBZRwiaU5Hk/29vGju6CVtmvu5Haas= -github.com/tree-sitter/tree-sitter-python v0.23.6/go.mod h1:cpdthSy/Yoa28aJFBscFHlGiU+cnSiSh1kuDVtI8YeM= -github.com/tree-sitter/tree-sitter-ruby v0.23.1 h1:T/NKHUA+iVbHM440hFx+lzVOzS4dV6z8Qw8ai+72bYo= -github.com/tree-sitter/tree-sitter-ruby v0.23.1/go.mod h1:kUS4kCCQloFcdX6sdpr8p6r2rogbM6ZjTox5ZOQy8cA= -github.com/tree-sitter/tree-sitter-rust v0.23.2 h1:6AtoooCW5GqNrRpfnvl0iUhxTAZEovEmLKDbyHlfw90= -github.com/tree-sitter/tree-sitter-rust v0.23.2/go.mod h1:hfeGWic9BAfgTrc7Xf6FaOAguCFJRo3RBbs7QJ6D7MI= +github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82 h1:6C8qej6f1bStuePVkLSFxoU22XBS165D3klxlzRg8F4= +github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82/go.mod h1:xe4pgH49k4SsmkQq5OT8abwhWmnzkhpgnXeekbx2efw= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM= golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= diff --git a/gazelle/python/BUILD.bazel b/gazelle/python/BUILD.bazel index e5255c4184..e4e7f04d5f 100644 --- a/gazelle/python/BUILD.bazel +++ b/gazelle/python/BUILD.bazel @@ -29,6 +29,7 @@ go_library( importpath = "github.com/bazel-contrib/rules_python/gazelle/python", visibility = ["//visibility:public"], deps = [ + "//manifest", "//pythonconfig", "@bazel_gazelle//config:go_default_library", "@bazel_gazelle//label:go_default_library", @@ -36,13 +37,13 @@ go_library( "@bazel_gazelle//repo:go_default_library", "@bazel_gazelle//resolve:go_default_library", "@bazel_gazelle//rule:go_default_library", - "@com_github_bazelbuild_buildtools//build", + "@com_github_bazelbuild_buildtools//build:go_default_library", "@com_github_bmatcuk_doublestar_v4//:doublestar", "@com_github_emirpasic_gods//lists/singlylinkedlist", "@com_github_emirpasic_gods//sets/treeset", "@com_github_emirpasic_gods//utils", - "@com_github_tree_sitter_go_tree_sitter//:go-tree-sitter", - "@com_github_tree_sitter_tree_sitter_python//bindings/go", + "@com_github_smacker_go_tree_sitter//:go-tree-sitter", + "@com_github_smacker_go_tree_sitter//python", "@org_golang_x_sync//errgroup", ], ) diff --git a/gazelle/python/file_parser.go b/gazelle/python/file_parser.go index 037d9b7c09..4ebd26192e 100644 --- a/gazelle/python/file_parser.go +++ b/gazelle/python/file_parser.go @@ -22,8 +22,8 @@ import ( "path/filepath" "strings" - sitter "github.com/tree-sitter/go-tree-sitter" - python "github.com/tree-sitter/tree-sitter-python/bindings/go" + sitter "github.com/smacker/go-tree-sitter" + "github.com/smacker/go-tree-sitter/python" ) const ( @@ -61,9 +61,12 @@ func NewFileParser() *FileParser { // It prints a warning if parsing fails. func ParseCode(code []byte, path string) (*sitter.Node, error) { parser := sitter.NewParser() - parser.SetLanguage(sitter.NewLanguage(python.Language())) + parser.SetLanguage(python.GetLanguage()) - tree := parser.Parse(code, nil) + tree, err := parser.ParseCtx(context.Background(), nil, code) + if err != nil { + return nil, err + } root := tree.RootNode() if !root.HasError() { @@ -79,16 +82,16 @@ func ParseCode(code []byte, path string) (*sitter.Node, error) { return root, nil } - for i := uint(0); i < root.ChildCount(); i++ { + for i := 0; i < int(root.ChildCount()); i++ { child := root.Child(i) if child.IsError() { // Example logs: // gazelle: Parse error at {Row:1 Column:0}: // def search_one_more_level[T](): - log.Printf("Parse error at %+v:\n%+v", child.StartPosition(), child.Utf8Text(code)) + log.Printf("Parse error at %+v:\n%+v", child.StartPoint(), child.Content(code)) // Log the internal tree-sitter representation of what was parsed. Eg: // gazelle: The above was parsed as: (ERROR (identifier) (call function: (list (identifier)) arguments: (argument_list))) - log.Printf("The above was parsed as: %v", child.Kind()) + log.Printf("The above was parsed as: %v", child.String()) } } @@ -98,21 +101,21 @@ func ParseCode(code []byte, path string) (*sitter.Node, error) { // parseMain returns true if the python file has an `if __name__ == "__main__":` block, // which is a common idiom for python scripts/binaries. func (p *FileParser) parseMain(ctx context.Context, node *sitter.Node) bool { - for i := uint(0); i < node.ChildCount(); i++ { + for i := 0; i < int(node.ChildCount()); i++ { if err := ctx.Err(); err != nil { return false } child := node.Child(i) - if child.Kind() == sitterNodeTypeIfStatement && - child.Child(1).Kind() == sitterNodeTypeComparisonOperator && child.Child(1).Child(1).Kind() == "==" { + if child.Type() == sitterNodeTypeIfStatement && + child.Child(1).Type() == sitterNodeTypeComparisonOperator && child.Child(1).Child(1).Type() == "==" { statement := child.Child(1) a, b := statement.Child(0), statement.Child(2) // convert "'__main__' == __name__" to "__name__ == '__main__'" - if b.Kind() == sitterNodeTypeIdentifier { + if b.Type() == sitterNodeTypeIdentifier { a, b = b, a } - if a.Kind() == sitterNodeTypeIdentifier && a.Utf8Text(p.code) == "__name__" && - b.Kind() == sitterNodeTypeString && string(p.code[b.StartByte()+1:b.EndByte()-1]) == "__main__" { + if a.Type() == sitterNodeTypeIdentifier && a.Content(p.code) == "__name__" && + b.Type() == sitterNodeTypeString && string(p.code[b.StartByte()+1:b.EndByte()-1]) == "__main__" { return true } } @@ -123,18 +126,18 @@ func (p *FileParser) parseMain(ctx context.Context, node *sitter.Node) bool { // parseImportStatement parses a node for an import statement, returning a `module` and a boolean // representing if the parse was OK or not. func parseImportStatement(node *sitter.Node, code []byte) (module, bool) { - switch node.Kind() { + switch node.Type() { case sitterNodeTypeDottedName: return module{ - Name: node.Utf8Text(code), - LineNumber: node.StartPosition().Row + 1, + Name: node.Content(code), + LineNumber: node.StartPoint().Row + 1, }, true case sitterNodeTypeAliasedImport: return parseImportStatement(node.Child(0), code) case sitterNodeTypeWildcardImport: return module{ Name: "*", - LineNumber: node.StartPosition().Row + 1, + LineNumber: node.StartPoint().Row + 1, }, true } return module{}, false @@ -144,8 +147,8 @@ func parseImportStatement(node *sitter.Node, code []byte) (module, bool) { // an import statement. It updates FileParser.output.Modules with the `module` that the // import represents. func (p *FileParser) parseImportStatements(node *sitter.Node) bool { - if node.Kind() == sitterNodeTypeImportStatement { - for j := uint(1); j < node.ChildCount(); j++ { + if node.Type() == sitterNodeTypeImportStatement { + for j := 1; j < int(node.ChildCount()); j++ { m, ok := parseImportStatement(node.Child(j), p.code) if !ok { continue @@ -156,12 +159,12 @@ func (p *FileParser) parseImportStatements(node *sitter.Node) bool { } p.output.Modules = append(p.output.Modules, m) } - } else if node.Kind() == sitterNodeTypeImportFromStatement { - from := node.Child(1).Utf8Text(p.code) + } else if node.Type() == sitterNodeTypeImportFromStatement { + from := node.Child(1).Content(p.code) if strings.HasPrefix(from, ".") { return true } - for j := uint(3); j < node.ChildCount(); j++ { + for j := 3; j < int(node.ChildCount()); j++ { m, ok := parseImportStatement(node.Child(j), p.code) if !ok { continue @@ -180,8 +183,8 @@ func (p *FileParser) parseImportStatements(node *sitter.Node) bool { // parseComments parses a node for comments, returning true if the node is a comment. // It updates FileParser.output.Comments with the parsed comment. func (p *FileParser) parseComments(node *sitter.Node) bool { - if node.Kind() == sitterNodeTypeComment { - p.output.Comments = append(p.output.Comments, comment(node.Utf8Text(p.code))) + if node.Type() == sitterNodeTypeComment { + p.output.Comments = append(p.output.Comments, comment(node.Content(p.code))) return true } return false @@ -197,7 +200,7 @@ func (p *FileParser) parse(ctx context.Context, node *sitter.Node) { if node == nil { return } - for i := uint(0); i < node.ChildCount(); i++ { + for i := 0; i < int(node.ChildCount()); i++ { if err := ctx.Err(); err != nil { return } diff --git a/gazelle/python/parser.go b/gazelle/python/parser.go index 6b1d99c9b2..1b2a90dddf 100644 --- a/gazelle/python/parser.go +++ b/gazelle/python/parser.go @@ -152,7 +152,7 @@ type module struct { // statements. Name string `json:"name"` // The line number where the import happened. - LineNumber uint `json:"lineno"` + LineNumber uint32 `json:"lineno"` // The path to the module file relative to the Bazel workspace root. Filepath string `json:"filepath"` // If this was a from import, e.g. from foo import bar, From indicates the module From 7cc2698e0d0fa8350cd5a896dcb00d46e4b73df8 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Mon, 7 Jul 2025 23:21:09 +0000 Subject: [PATCH 28/29] http_archive for smacker/go-tree-sitter --- gazelle/MODULE.bazel | 11 +++- gazelle/deps.bzl | 9 ++-- gazelle/internal/smacker_BUILD.bazel | 80 ++++++++++++++++++++++++++++ gazelle/python/BUILD.bazel | 2 +- 4 files changed, 96 insertions(+), 6 deletions(-) create mode 100644 gazelle/internal/smacker_BUILD.bazel diff --git a/gazelle/MODULE.bazel b/gazelle/MODULE.bazel index c1ad653f35..7beb1f70a7 100644 --- a/gazelle/MODULE.bazel +++ b/gazelle/MODULE.bazel @@ -23,12 +23,21 @@ use_repo( "com_github_bmatcuk_doublestar_v4", "com_github_emirpasic_gods", "com_github_ghodss_yaml", - "com_github_smacker_go_tree_sitter", "com_github_stretchr_testify", "in_gopkg_yaml_v2", "org_golang_x_sync", ) +http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "com_github_smacker_go_tree_sitter", + build_file = "//:internal/smacker_BUILD.bazel", + integrity = "sha256-4AkDY4Rh5Auu9Kwzhj5XYSirMLlhmd6ClMWo/r0kmu4=", + strip_prefix = "go-tree-sitter-dd81d9e9be82a8cac96ed1d50c7389c5f1997c02", + url = "https://github.com/smacker/go-tree-sitter/archive/dd81d9e9be82a8cac96ed1d50c7389c5f1997c02.zip", +) + python_stdlib_list = use_extension("//python:extensions.bzl", "python_stdlib_list") use_repo( python_stdlib_list, diff --git a/gazelle/deps.bzl b/gazelle/deps.bzl index 22807ad39a..8db97bbe20 100644 --- a/gazelle/deps.bzl +++ b/gazelle/deps.bzl @@ -119,11 +119,12 @@ def go_deps(): sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=", version = "v1.0.0", ) - go_repository( + http_archive( name = "com_github_smacker_go_tree_sitter", - importpath = "github.com/smacker/go-tree-sitter", - sum = "h1:6C8qej6f1bStuePVkLSFxoU22XBS165D3klxlzRg8F4=", - version = "v0.0.0-20240827094217-dd81d9e9be82", + build_file = "//:internal/smacker_BUILD.bazel", + integrity = "sha256-4AkDY4Rh5Auu9Kwzhj5XYSirMLlhmd6ClMWo/r0kmu4=", + strip_prefix = "go-tree-sitter-dd81d9e9be82a8cac96ed1d50c7389c5f1997c02", + url = "https://github.com/smacker/go-tree-sitter/archive/dd81d9e9be82a8cac96ed1d50c7389c5f1997c02.zip", ) go_repository( name = "com_github_stretchr_objx", diff --git a/gazelle/internal/smacker_BUILD.bazel b/gazelle/internal/smacker_BUILD.bazel new file mode 100644 index 0000000000..3ec96760e8 --- /dev/null +++ b/gazelle/internal/smacker_BUILD.bazel @@ -0,0 +1,80 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +filegroup( + name = "common_libs", + srcs = [ + "alloc.h", + "api.h", + "array.h", + ], + visibility = [":__subpackages__"], +) + +go_library( + name = "go-tree-sitter", + srcs = [ + "alloc.c", + "alloc.h", + "api.h", + "array.h", + "atomic.h", + "bindings.c", + "bindings.go", + "bindings.h", + "bits.h", + "clock.h", + "error_costs.h", + "get_changed_ranges.c", + "get_changed_ranges.h", + "host.h", + "iter.go", + "language.c", + "language.h", + "length.h", + "lexer.c", + "lexer.h", + "node.c", + "parser.c", + "parser.h", + "point.h", + "ptypes.h", + "query.c", + "reduce_action.h", + "reusable_node.h", + "stack.c", + "stack.h", + "subtree.c", + "subtree.h", + "test_grammar.go", + "tree.c", + "tree.h", + "tree_cursor.c", + "tree_cursor.h", + "umachine.h", + "unicode.h", + "urename.h", + "utf.h", + "utf16.h", + "utf8.h", + "wasm_store.c", + "wasm_store.h", + ], + cgo = True, + importpath = "github.com/smacker/go-tree-sitter", + visibility = ["//visibility:public"], +) + +go_library( + name = "python", + srcs = [ + "python/binding.go", + "python/parser.c", + "python/parser.h", + "python/scanner.c", + ":common_libs", + ], + cgo = True, + importpath = "github.com/smacker/go-tree-sitter/python", + visibility = ["//visibility:public"], + deps = [":go-tree-sitter"], +) diff --git a/gazelle/python/BUILD.bazel b/gazelle/python/BUILD.bazel index e4e7f04d5f..8e8216ddd4 100644 --- a/gazelle/python/BUILD.bazel +++ b/gazelle/python/BUILD.bazel @@ -43,7 +43,7 @@ go_library( "@com_github_emirpasic_gods//sets/treeset", "@com_github_emirpasic_gods//utils", "@com_github_smacker_go_tree_sitter//:go-tree-sitter", - "@com_github_smacker_go_tree_sitter//python", + "@com_github_smacker_go_tree_sitter//:python", "@org_golang_x_sync//errgroup", ], ) From 27aaec49ea476ba0a4ce0e9b5341c23551c3075e Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Tue, 8 Jul 2025 00:48:11 +0000 Subject: [PATCH 29/29] hmm... --- gazelle/MODULE.bazel | 2 +- gazelle/deps.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gazelle/MODULE.bazel b/gazelle/MODULE.bazel index 7beb1f70a7..697e589c8d 100644 --- a/gazelle/MODULE.bazel +++ b/gazelle/MODULE.bazel @@ -32,7 +32,7 @@ http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "ht http_archive( name = "com_github_smacker_go_tree_sitter", - build_file = "//:internal/smacker_BUILD.bazel", + build_file = "@rules_python_gazelle_plugin//:internal/smacker_BUILD.bazel", integrity = "sha256-4AkDY4Rh5Auu9Kwzhj5XYSirMLlhmd6ClMWo/r0kmu4=", strip_prefix = "go-tree-sitter-dd81d9e9be82a8cac96ed1d50c7389c5f1997c02", url = "https://github.com/smacker/go-tree-sitter/archive/dd81d9e9be82a8cac96ed1d50c7389c5f1997c02.zip", diff --git a/gazelle/deps.bzl b/gazelle/deps.bzl index 8db97bbe20..d1ec94c37f 100644 --- a/gazelle/deps.bzl +++ b/gazelle/deps.bzl @@ -121,7 +121,7 @@ def go_deps(): ) http_archive( name = "com_github_smacker_go_tree_sitter", - build_file = "//:internal/smacker_BUILD.bazel", + build_file = "@rules_python_gazelle_plugin//:internal/smacker_BUILD.bazel", integrity = "sha256-4AkDY4Rh5Auu9Kwzhj5XYSirMLlhmd6ClMWo/r0kmu4=", strip_prefix = "go-tree-sitter-dd81d9e9be82a8cac96ed1d50c7389c5f1997c02", url = "https://github.com/smacker/go-tree-sitter/archive/dd81d9e9be82a8cac96ed1d50c7389c5f1997c02.zip", pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy