Skip to content

Commit

Permalink
Debugger improvements (#86)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
pcj authored Nov 27, 2021
1 parent cb5155f commit b6c4cd9
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 244 deletions.
5 changes: 3 additions & 2 deletions package-lock.json

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

8 changes: 4 additions & 4 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": "1.6.0",
"version": "1.7.0",
"publisher": "StackBuild",
"license": "Apache-2.0",
"icon": "stackb-full.png",
Expand Down Expand Up @@ -234,7 +234,7 @@
},
"bsv.bzl.server.release": {
"type": "string",
"default": "v1.1.2",
"default": "v1.2.14",
"description": "Bzl release version"
},
"bsv.bzl.server.command": {
Expand Down Expand Up @@ -659,7 +659,7 @@
"bazel-explorer": [
{
"id": "bsv.workspace",
"name": "Stack VSCode v1.6.0",
"name": "Stack VSCode v1.7.0",
"icon": "media/bazel-wireframe.svg",
"contextualTitle": "Current Bazel Workspace",
"when": "resourceLangId == bazel"
Expand Down Expand Up @@ -821,4 +821,4 @@
"tabWidth": 2,
"arrowParens": "avoid"
}
}
}
209 changes: 0 additions & 209 deletions src/bezel/codelens.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/bezel/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export class BzlSettings extends Settings<BzlConfiguration> {
enabled: config.get<boolean>('enabled', true),
autoLaunch: config.get<boolean>('autoLaunch', true),
downloadBaseURL: config.get<string>('downloadBaseUrl', 'https://get.bzl.io'),
release: config.get<string>('release', 'v1.1.2'),
release: config.get<string>('release', 'v1.2.14'),
executable: normalize(config.get<string>('executable', '')),
address: address,
command: config.get<string[]>('command', ['serve', '--address=${address}']),
Expand Down
40 changes: 25 additions & 15 deletions src/bezel/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { isDefined } from 'vscode-common/out/types';

export class StarlarkDebugger
extends LaunchableComponent<StarlarkDebuggerConfiguration>
implements vscode.Disposable, vscode.DebugAdapterDescriptorFactory, vscode.DebugConfigurationProvider {
implements vscode.DebugAdapterDescriptorFactory, vscode.DebugConfigurationProvider {

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

//
// launch the debug adapter if it not already running
//

if (this.status !== Status.READY && this.status !== Status.DISABLED) {
// this needs to wait until the thing is actually running!
await this.handleCommandLaunch();
this.restart();
}

// launch the bazel debugger if this is a launch config
if (config.request === 'launch') {
const bazelSettings = await this.bazelSettings.get();
const flags = bazelSettings.starlarkDebugFlags || [];
const extraFlags = config.extraBazelFlags || [];
//
// make sure target label is defined
//

await vscode.commands.executeCommand(CommandName.Invoke,
['build', targetLabel, ...flags, ...extraFlags].filter(arg => isDefined(arg)));
if (!config.targetLabel) {
config.targetLabel = await this.handleCommandAskForDebugTargetLabel();
}
if (!config.targetLabel) {
vscode.window.showInformationMessage('A label for the "bazel build" command is required. Please add it to your launch configuration.');
return;
}

//
// run bazel debug
//
const bazelSettings = await this.bazelSettings.get();
const flags = bazelSettings.starlarkDebugFlags || [];
const extraFlags = config.extraBazelFlags || [];

await vscode.commands.executeCommand(CommandName.Invoke,
['build', config.targetLabel, ...flags, ...extraFlags].filter(arg => isDefined(arg)));

return config;
}
Expand Down
5 changes: 0 additions & 5 deletions src/bezel/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import * as vscode from 'vscode';
import { API } from '../api';
import { Bzl } from './bzl';
import { BuiltInCommands } from '../constants';
import { Container } from '../container';
import { BazelCodelensProvider } from './codelens';
import {
SubscriptionSettings,
BazelConfiguration,
Expand Down Expand Up @@ -147,9 +145,6 @@ export class BzlFeature implements vscode.Disposable {
new StarlarkDebugger(debugSettings, bazelSettings, bzlSettings, workspaceFolder)
));
const codeSearch = this.addComponent(new CodeSearch(codeSearchSettings, bzl));
this.addDisposable(
new BazelCodelensProvider(lspClient, bazelServer, codeSearch, bzl, starlarkDebugger)
);
this.addDisposable(
new BezelWorkspaceView(
lspClient,
Expand Down
9 changes: 3 additions & 6 deletions src/bezel/lsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class BzlLanguageClient
}

private handleStateChangeEvent(e: StateChangeEvent) {
// console.log('lsp StateChangeEvent new =>', e.newState);
let status = Status.UNKNOWN;
switch (e.newState) {
case State.Starting:
Expand Down Expand Up @@ -309,9 +310,7 @@ function createLanguageClient(cfg: LanguageServerConfiguration): LanguageClient
args: cfg.command,
};

// Options to control the language client
let clientOptions: LanguageClientOptions = {
// Register the server for plain text documents
documentSelector: [
{ scheme: 'file', language: 'starlark' },
{ scheme: 'file', language: 'bazel' },
Expand All @@ -321,10 +320,8 @@ function createLanguageClient(cfg: LanguageServerConfiguration): LanguageClient
// workspace
fileEvents: vscode.workspace.createFileSystemWatcher('**/BUILD.bazel'),
},
// initializationFailedHandler: err => {
// this.setError(err instanceof Error ? err : new Error(err));
// return false;
// },
progressOnInitialization: true,
initializationOptions: {},
};

const forceDebug = false;
Expand Down
Loading

0 comments on commit b6c4cd9

Please sign in to comment.