Skip to content

Commit b6c4cd9

Browse files
authored
Debugger improvements (#86)
* Bump to 1.7.0 * Bump bzl to 1.2.14 * Remove typescript codelens provider * only start adapter and bazel server if this is a launch config
1 parent cb5155f commit b6c4cd9

File tree

8 files changed

+37
-244
lines changed

8 files changed

+37
-244
lines changed

package-lock.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "bazel-stack-vscode",
33
"displayName": "bazel-stack-vscode",
44
"description": "Bazel Support for Visual Studio Code",
5-
"version": "1.6.0",
5+
"version": "1.7.0",
66
"publisher": "StackBuild",
77
"license": "Apache-2.0",
88
"icon": "stackb-full.png",
@@ -234,7 +234,7 @@
234234
},
235235
"bsv.bzl.server.release": {
236236
"type": "string",
237-
"default": "v1.1.2",
237+
"default": "v1.2.14",
238238
"description": "Bzl release version"
239239
},
240240
"bsv.bzl.server.command": {
@@ -659,7 +659,7 @@
659659
"bazel-explorer": [
660660
{
661661
"id": "bsv.workspace",
662-
"name": "Stack VSCode v1.6.0",
662+
"name": "Stack VSCode v1.7.0",
663663
"icon": "media/bazel-wireframe.svg",
664664
"contextualTitle": "Current Bazel Workspace",
665665
"when": "resourceLangId == bazel"
@@ -821,4 +821,4 @@
821821
"tabWidth": 2,
822822
"arrowParens": "avoid"
823823
}
824-
}
824+
}

src/bezel/codelens.ts

Lines changed: 0 additions & 209 deletions
This file was deleted.

src/bezel/configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ export class BzlSettings extends Settings<BzlConfiguration> {
253253
enabled: config.get<boolean>('enabled', true),
254254
autoLaunch: config.get<boolean>('autoLaunch', true),
255255
downloadBaseURL: config.get<string>('downloadBaseUrl', 'https://get.bzl.io'),
256-
release: config.get<string>('release', 'v1.1.2'),
256+
release: config.get<string>('release', 'v1.2.14'),
257257
executable: normalize(config.get<string>('executable', '')),
258258
address: address,
259259
command: config.get<string[]>('command', ['serve', '--address=${address}']),

src/bezel/debugger.ts

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { isDefined } from 'vscode-common/out/types';
1515

1616
export class StarlarkDebugger
1717
extends LaunchableComponent<StarlarkDebuggerConfiguration>
18-
implements vscode.Disposable, vscode.DebugAdapterDescriptorFactory, vscode.DebugConfigurationProvider {
18+
implements vscode.DebugAdapterDescriptorFactory, vscode.DebugConfigurationProvider {
1919

2020
constructor(
2121
public readonly settings: StarlarkDebuggerSettings,
@@ -171,31 +171,41 @@ export class StarlarkDebugger
171171
* @return The resolved debug configuration or undefined or null.
172172
*/
173173
async resolveDebugConfigurationWithSubstitutedVariables(folder: vscode.WorkspaceFolder | undefined, config: vscode.DebugConfiguration, token?: vscode.CancellationToken): Promise<vscode.DebugConfiguration | undefined> {
174-
let targetLabel = config.targetLabel;
175-
if (!targetLabel) {
176-
targetLabel = await this.handleCommandAskForDebugTargetLabel();
177-
}
178-
if (!targetLabel) {
179-
vscode.window.showInformationMessage('A label for the "bazel build" command is required. Please add it to your launch configuration.');
180-
return;
174+
if (config.request !== 'launch') {
175+
return config
181176
}
182177

178+
//
183179
// launch the debug adapter if it not already running
180+
//
181+
184182
if (this.status !== Status.READY && this.status !== Status.DISABLED) {
185183
// this needs to wait until the thing is actually running!
186184
await this.handleCommandLaunch();
187185
this.restart();
188186
}
189187

190-
// launch the bazel debugger if this is a launch config
191-
if (config.request === 'launch') {
192-
const bazelSettings = await this.bazelSettings.get();
193-
const flags = bazelSettings.starlarkDebugFlags || [];
194-
const extraFlags = config.extraBazelFlags || [];
188+
//
189+
// make sure target label is defined
190+
//
195191

196-
await vscode.commands.executeCommand(CommandName.Invoke,
197-
['build', targetLabel, ...flags, ...extraFlags].filter(arg => isDefined(arg)));
192+
if (!config.targetLabel) {
193+
config.targetLabel = await this.handleCommandAskForDebugTargetLabel();
198194
}
195+
if (!config.targetLabel) {
196+
vscode.window.showInformationMessage('A label for the "bazel build" command is required. Please add it to your launch configuration.');
197+
return;
198+
}
199+
200+
//
201+
// run bazel debug
202+
//
203+
const bazelSettings = await this.bazelSettings.get();
204+
const flags = bazelSettings.starlarkDebugFlags || [];
205+
const extraFlags = config.extraBazelFlags || [];
206+
207+
await vscode.commands.executeCommand(CommandName.Invoke,
208+
['build', config.targetLabel, ...flags, ...extraFlags].filter(arg => isDefined(arg)));
199209

200210
return config;
201211
}

src/bezel/feature.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import * as vscode from 'vscode';
22
import { API } from '../api';
33
import { Bzl } from './bzl';
44
import { BuiltInCommands } from '../constants';
5-
import { Container } from '../container';
6-
import { BazelCodelensProvider } from './codelens';
75
import {
86
SubscriptionSettings,
97
BazelConfiguration,
@@ -147,9 +145,6 @@ export class BzlFeature implements vscode.Disposable {
147145
new StarlarkDebugger(debugSettings, bazelSettings, bzlSettings, workspaceFolder)
148146
));
149147
const codeSearch = this.addComponent(new CodeSearch(codeSearchSettings, bzl));
150-
this.addDisposable(
151-
new BazelCodelensProvider(lspClient, bazelServer, codeSearch, bzl, starlarkDebugger)
152-
);
153148
this.addDisposable(
154149
new BezelWorkspaceView(
155150
lspClient,

src/bezel/lsp.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export class BzlLanguageClient
6464
}
6565

6666
private handleStateChangeEvent(e: StateChangeEvent) {
67+
// console.log('lsp StateChangeEvent new =>', e.newState);
6768
let status = Status.UNKNOWN;
6869
switch (e.newState) {
6970
case State.Starting:
@@ -309,9 +310,7 @@ function createLanguageClient(cfg: LanguageServerConfiguration): LanguageClient
309310
args: cfg.command,
310311
};
311312

312-
// Options to control the language client
313313
let clientOptions: LanguageClientOptions = {
314-
// Register the server for plain text documents
315314
documentSelector: [
316315
{ scheme: 'file', language: 'starlark' },
317316
{ scheme: 'file', language: 'bazel' },
@@ -321,10 +320,8 @@ function createLanguageClient(cfg: LanguageServerConfiguration): LanguageClient
321320
// workspace
322321
fileEvents: vscode.workspace.createFileSystemWatcher('**/BUILD.bazel'),
323322
},
324-
// initializationFailedHandler: err => {
325-
// this.setError(err instanceof Error ? err : new Error(err));
326-
// return false;
327-
// },
323+
progressOnInitialization: true,
324+
initializationOptions: {},
328325
};
329326

330327
const forceDebug = false;

0 commit comments

Comments
 (0)