Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDE indexing broken for go_proto_library with custom compilers #7010

Open
H5-O5 opened this issue Nov 19, 2024 · 2 comments
Open

IDE indexing broken for go_proto_library with custom compilers #7010

H5-O5 opened this issue Nov 19, 2024 · 2 comments
Labels
awaiting-maintainer Awaiting review from Bazel team on issues lang: go Go rules integration product: GoLand GoLand plugin type: bug

Comments

@H5-O5
Copy link

H5-O5 commented Nov 19, 2024

Description of the bug:

Hi everyone, I wonder if someone could help me with this issue:

I have custom proto plugins, and my BUILD file looks like this:

load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

proto_library(
    name = "cache_proto",
    srcs = [
        "cache_api.proto",
        "cache_service.proto",
    ],
    visibility = ["//visibility:public"],
    deps = [
        "@com_google_protobuf//:any_proto",
    ],
)

go_proto_library(
    name = "cache_go_proto",
    importpath = "my.example.com/proj/cachepb",
    proto = ":cache_proto",
    visibility = ["//visibility:public"],
)

go_proto_library(
    name = "cache_go_proto_my_plugin",
    compilers = [
        "@my_plugin_repo//foo:my_plugin",
    ],
    importpath = "my.example.com/proj/cachepb/cacheservice",
    proto = ":cache_proto",
    visibility = ["//visibility:public"],
    deps = [
        ":cache_go_proto",
    ],
)

where my_plugin will generate some codes in a different importpath. bazel build is happy (that is, if a target depends on cache_go_proto_my_plugin, it can successfully use the import path without a problem). But GoLand with bazel plugin would only index my.example.com/proj/cachepb but not my.example.com/proj/cachepb/cacheservice.

Interestingly, GoLand shows the import as green text with red wavy underline showing unused import. If I type cacheservice, it pops up completion entries correctly. But if you write foo := cacheservice.SomeFunc(), the SomeFunc() is marked as red. You can't jump to SomeFunc and foo.<TAB> doesn't work.

What could be the problem and how can I debug this?

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Creating an MWE is not easy. Let's see if there are things I could try before I create an MWE.

Which Intellij IDE are you using? Please provide the specific version.

#GO-243.21565.208

What programming languages and tools are you using? Please provide specific versions.

No response

What Bazel plugin version are you using?

tried latest stable version and DEV version

Have you found anything relevant by searching the web?

Nope

Any other information, logs, or outputs that you want to share?

No response

@H5-O5 H5-O5 added awaiting-maintainer Awaiting review from Bazel team on issues type: bug labels Nov 19, 2024
@tpasternak
Copy link
Collaborator

Cc @iliakondratev

@sgowroji sgowroji added product: GoLand GoLand plugin lang: go Go rules integration labels Nov 20, 2024
@H5-O5
Copy link
Author

H5-O5 commented Nov 20, 2024

I got an update for this:

It seems that the problem is due to // + build ignore. That is:

Let's say @my_plugin_repo//foo:my_plugin claims 6 files, but the protoc-plugin only generates 4 files. The missing 2 files will be generated by "rules_go" containing

// +build ignore

package ignore

Then, getPackageName somehow recognizes this, and return "ignore" as package name.

For the official rules, the package name would be basename(importpath), which is cachepb in this case.

I hacked getPackageName to return basename(importpath) and everything seems to work now. I haven't fully tested it but this is promising.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-maintainer Awaiting review from Bazel team on issues lang: go Go rules integration product: GoLand GoLand plugin type: bug
Projects
Status: Untriaged
Development

No branches or pull requests

3 participants