Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## 0.6.3 (Mon Oct 25 2020)

- Integrate gostarlark go to definition for bazel labels
- Improve "last run" semantics for build
- Regenerate protos with 0.6.0-pre17
- Added "copy to clipboard" command for output file paths


## 0.6.2 (Mon Oct 19 2020)

- Codesearch improvements
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# bazel-stack-vscode

Bazel Support for Visual Studio Code.
[Bazel](https://bazel.build) Support for Visual Studio Code.

<table><tr>
<td style="width: 120px; text-align: center"><img src="https://upload.wikimedia.org/wikipedia/en/thumb/7/7d/Bazel_logo.svg/240px-Bazel_logo.svg.png" height="120"/></td>
Expand All @@ -25,7 +25,8 @@ Bazel Support for Visual Studio Code.
- hover to get [bazel rule & starlark function
reference](#Hover-Symbols-to-Get-Inline-Documentation) (via Starlark
Language Server)

- [go to definition](https://stackb.github.io/bazel-stack-vscode/jumping) for bazel labels

- `bazelrc` files (`*.bazelrc`):
- syntax highlighting
- hover to get [flag reference](#Hover-Flags-to-Get-Inline-Documentation) & links to bazel docs / bazel codesearch
Expand All @@ -44,6 +45,10 @@ Bazel Support for Visual Studio Code.

![1-lint](https://user-images.githubusercontent.com/50580/89370514-227cc300-d69e-11ea-8784-266e9756e8ec.gif)

### Go To Definition for Bazel Labels

![jtd](https://user-images.githubusercontent.com/50580/97131325-78935c80-1709-11eb-86d5-a6c96d47bab8.gif)

### Hover Symbols to Get Inline Documentation

![1-rulehover](https://user-images.githubusercontent.com/50580/89370355-c31eb300-d69d-11ea-8fc6-eeff04641dd0.gif)
Expand Down
2 changes: 1 addition & 1 deletion docs/exploring.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: default
title: Exploring
permalink: /exploring
nav_order: 9
nav_order: 11
---

## Exploring
Expand Down
2 changes: 1 addition & 1 deletion docs/formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: default
title: Formatting
permalink: /formatting
nav_order: 3
nav_order: 4
---

## Formatting
Expand Down
29 changes: 29 additions & 0 deletions docs/jumping.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
layout: default
title: Jumping
permalink: /jumping
nav_order: 6
---

## Jump to Definition

<p></p>

**Jump to Definition** (Go to definition) is provided for `BUILD` file labels
(typically, this is mapped to the keyboard shortcut `F12`).

The starlark string literal at the current cursor position is used to
locate the target file.

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 `BUILD` file at
the corresponding rule definition.
- If the rule cannot be found within the `BUILD` file, 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.

![jtd](https://user-images.githubusercontent.com/50580/97131325-78935c80-1709-11eb-86d5-a6c96d47bab8.gif)
2 changes: 1 addition & 1 deletion docs/launching.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: default
title: Launching
permalink: /launching
nav_order: 5
nav_order: 7
---

## Launching
Expand Down
2 changes: 1 addition & 1 deletion docs/linting.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: default
title: Linting
permalink: /linting
nav_order: 4
nav_order: 5
---

## Linting
Expand Down
2 changes: 1 addition & 1 deletion docs/navigating/navigating.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: default
title: Navigating
permalink: /navigating
nav_order: 6
nav_order: 8
has_children: true
---

Expand Down
2 changes: 1 addition & 1 deletion docs/remoting.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: default
title: Remoting
permalink: /remoting
nav_order: 8
nav_order: 10
---

## Remoting
Expand Down
2 changes: 1 addition & 1 deletion docs/searching.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: default
title: Searching
permalink: /searching
nav_order: 5
nav_order: 9
---

## Codesearch
Expand Down
2 changes: 1 addition & 1 deletion docs/subscribing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: default
title: Subscribing
permalink: /subscribing
nav_order: 1
nav_order: 2
---

## Subscribing
Expand Down
2 changes: 1 addition & 1 deletion docs/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: default
title: Syntax Highlighting
permalink: /syntax
nav_order: 2
nav_order: 3
---

## Syntax Highlighting
Expand Down
26 changes: 9 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 22 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "bazel-stack-vscode",
"displayName": "bazel-stack-vscode",
"description": "Bazel Support for Visual Studio Code",
"version": "0.6.2",
"version": "0.6.3",
"publisher": "StackBuild",
"license": "Apache-2.0",
"icon": "stackb-full.png",
Expand All @@ -26,6 +26,7 @@
"onCommand:bsv.bzl.account.refresh",
"onCommand:bsv.bzl.bep.action.stdout",
"onCommand:bsv.bzl.bep.event.output",
"onCommand:bsv.bzl.bep.file.clippy",
"onCommand:bsv.bzl.bep.file.download",
"onCommand:bsv.bzl.bep.file.save",
"onCommand:bsv.bzl.bep.started.explore",
Expand Down Expand Up @@ -100,21 +101,21 @@
"type": "string",
"description": "Path to a pre-installed LSP executable\n\n> if set, this prevents downloading a LSP binary from github"
},
"bsv.starlark.lsp.github-release": {
"type": "string",
"default": "0.3.5",
"description": "The github release tag of the starlark-lsp release to download"
},
"bsv.starlark.lsp.github-owner": {
"type": "string",
"default": "stackb",
"description": "The github owner for the starlark.lsp repository"
},
"bsv.starlark.lsp.github-repo": {
"type": "string",
"default": "bazel-stack-vscode",
"default": "bzl",
"description": "The github repo name for the starlark-lsp repository"
},
"bsv.starlark.lsp.github-release": {
"type": "string",
"default": "0.9.4",
"description": "The github release tag of the starlark-lsp release to download"
},
"bsv.starlark.lsp.server.command": {
"type": "array",
"description": "The command (and optional arguments) to start the lsp server.",
Expand Down Expand Up @@ -187,7 +188,7 @@
},
"bsv.bzl.server.github-release": {
"type": "string",
"default": "0.9.3",
"default": "0.9.4",
"description": "The github release tag of the bzl release to download"
},
"bsv.bzl.server.github-owner": {
Expand Down Expand Up @@ -544,6 +545,12 @@
"command": "bsv.bzl.bep.event.output",
"title": "Show test.log",
"icon": "$(output)"
},
{
"category": "Bzl",
"command": "bsv.bzl.bep.file.clippy",
"title": "Copy file path to clipboard",
"icon": "$(clippy)"
}
],
"keybindings": [
Expand Down Expand Up @@ -704,7 +711,7 @@
{
"command": "bsv.bzl.bep.event.output",
"when": "false"
}
}
],
"view/title": [
{
Expand Down Expand Up @@ -883,6 +890,11 @@
"command": "bsv.bzl.bep.event.output",
"when": "view == bsv.bzl.bep && viewItem == testResult",
"group": "inline@0"
},
{
"command": "bsv.bzl.bep.file.clippy",
"when": "view == bsv.bzl.bep && viewItem == file",
"group": "inline@0"
}
]
},
Expand Down Expand Up @@ -1122,7 +1134,7 @@
},
"dependencies": {
"@grpc/grpc-js": "1.1.1",
"@grpc/proto-loader": "0.6.0-pre14",
"@grpc/proto-loader": "0.6.0-pre17",
"@octokit/rest": "18.0.3",
"bazel-stack-vscode-api": "^1.2.2",
"card-validator": "8.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/bzl/bzlclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class BzlClient extends GRPCClient implements BzlCodesearch {
}

async waitForReady(seconds: number = 3): Promise<Metadata> {
return this.getMetadata(false, seconds);
return this.getMetadata(true, seconds);
}

protected handleErrorUnavailable(err: grpc.ServiceError): grpc.ServiceError {
Expand Down
1 change: 1 addition & 0 deletions src/bzl/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export enum CommandName {
BEPStartedExplore = 'bsv.bzl.bep.started.explore',
BEPFileDownload = 'bsv.bzl.bep.file.download',
BEPFileSave = 'bsv.bzl.bep.file.save',
BEPFileClippy = 'bsv.bzl.bep.file.clippy',

RepositoryExplore = 'bsv.bzl.repository.explore',
RepositorySelect = 'bsv.bzl.repository.select',
Expand Down
2 changes: 2 additions & 0 deletions src/bzl/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ export class BzlFeature implements IExtensionFeature, vscode.Disposable {
const server = this.server = this.add(new BzlServerProcess(cfg.executable, cfg.command));
server.start();
await server.onReady();
console.debug(`Started bzl (${cfg.executable})`);

return this.tryConnectServer(cfg, attempts);
}

Expand Down
15 changes: 14 additions & 1 deletion src/bzl/view/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ export class BuildEventProtocolView extends BzlClientTreeDataProvider<BazelBuild
}

registerCommands() {
// super.registerCommands(); // explicitly skipped as we don't need a 'refresh' command
super.registerCommands();
this.addCommand(CommandName.BEPActionStderr, this.handleCommandActionStderr);
this.addCommand(CommandName.BEPActionStdout, this.handleCommandActionStdout);
this.addCommand(CommandName.BEPActionOutput, this.handleCommandPrimaryOutputFile);
this.addCommand(CommandName.BEPStartedExplore, this.handleCommandStartedExplore);
this.addCommand(CommandName.BEPFileDownload, this.handleCommandFileDownload);
this.addCommand(CommandName.BEPFileSave, this.handleCommandFileSave);
this.addCommand(CommandName.BEPFileClippy, this.handleCommandFileClippy);
}

async handleCommandFileDownload(item: FileItem): Promise<void> {
Expand All @@ -73,6 +74,18 @@ export class BuildEventProtocolView extends BzlClientTreeDataProvider<BazelBuild
vscode.commands.executeCommand(BuiltInCommands.Open, vscode.Uri.parse(`${client.httpURL()}${response.uri}`));
}

async handleCommandFileClippy(item: FileItem): Promise<void> {
if (!item.file.uri) {
return;
}
const fsPath = vscode.Uri.parse(item.file.uri).fsPath;
vscode.window.setStatusBarMessage(
`"${fsPath}" copied to clipboard`,
3000
);
return vscode.env.clipboard.writeText(fsPath);
}

async handleCommandFileSave(item: FileItem): Promise<void> {
const client = this.client;
if (!client) {
Expand Down
Loading