Jump to Definition (Go to definition) is provided for
BUILD file labels (typically, this is mapped to the keyboard shortcut
Jump to definition has the following “best-effort” semantics:
- If the label represents a source file (e.g.
//:main.go), open at the beginning of the file.
- If the label represents a rule (e.g.
//:myrule), open the
BUILDfile at the corresponding rule definition.
- If the rule cannot be found within the
BUILDfile, no action is taken.
- If the label is in an external workspace (e.g.
@foo//:bar), open the file/rule in the external workspace
foo. This behavior requires that the bazel server for the repository be running.
Jump-to-label has a variant that, rather than opening the
BUILD file at the target, copies the label to the clipboard. This can be triggered by the
Bazel: Copy Label to Clipboard command menu item, the (right-click) context menu while inside a
BUILD file, or via the keybinding (by default