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

Support Go to Definition requests for source file labels in string literals #201

Merged
merged 2 commits into from
Apr 16, 2024

Conversation

withered-magic
Copy link
Owner

@withered-magic withered-magic commented Apr 15, 2024

Adds the equivalent of the functionality described in bazel-contrib/vscode-bazel#380

@withered-magic withered-magic merged commit 0ffcfdb into main Apr 16, 2024
2 checks passed
@withered-magic withered-magic deleted the label-goto-def branch April 16, 2024 00:02
@sluongng
Copy link

hmm does this work?

I tested it with BuildBuddy.git and Bazel.git, both cannot do Go to Def for most target labels. For example:

gazelle_binary(
    name = "bb_gazelle_binary",
    languages = DEFAULT_LANGUAGES + ["@bazel_gazelle//language/bazel/visibility:go_default_library"],
)

trying to "go to def" on "@bazel_gazelle//language/bazel/visibility:go_default_library" would fail.

@withered-magic
Copy link
Owner Author

withered-magic commented Apr 16, 2024

Ah sorry, didn't clarify in the PR that this is specifically for source files, e.g. //path/to/source.cc - I'm planning on following up with goto def for normal labels

@withered-magic withered-magic changed the title Support Go to Definition requests for labels in string literals Support Go to Definition requests for source file labels in string literals Apr 16, 2024
@withered-magic
Copy link
Owner Author

Just updated this PR description to indicate this, and opened #203 to track the remaining functionality!

@sluongng
Copy link

I don't think it works. For example, I tried it on this line https://github.com/buildbuddy-io/buildbuddy/blob/bb4c9d9ff75ace7c549819e40cac080414a6a226/server/buildbuddy_server/BUILD#L71 and it did not open the Go file.

Also I think it's typical to have source syntax in the form of //some/package:local/package/path.ext and/or local/package/path.ext for short.

@withered-magic
Copy link
Owner Author

withered-magic commented Apr 16, 2024

Hmm, for my setup it's working from that file for all the various forms of source syntax that you mentioned:

Screen.Recording.2024-04-16.at.10.44.56.AM.mov

This functionality isn't actually on the latest release yet, are you using a custom build from latest main? The version in the Bazel LSP Client logs should be (the unreleased) v0.1.12:

server: starpls, v0.1.12
server: initializing state and starting event loop

@sluongng
Copy link

ah I built from the latest from main, but I copied the old binary from editors/code/bin/starpls instead of directly from my bazel-out. 😮‍💨

sorry for the noise

@withered-magic
Copy link
Owner Author

withered-magic commented Apr 16, 2024

no worries! i'll follow up on the non-source labels soon

@withered-magic
Copy link
Owner Author

withered-magic commented Apr 19, 2024

Goto def for non-source file labels has been added in #205!

@sluongng
Copy link

Amazing! I love starpls already!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants