Skip to content

Commit

Permalink
adding progress support
Browse files Browse the repository at this point in the history
  • Loading branch information
weinand committed Mar 13, 2020
1 parent 316dafa commit fa66f93
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 20 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

## 0.40.0
* Exercise progress events: typing "progress" in the REPL starts a sequence of (cancellable) progress events if the clients supports this via the `supportsProgressReporting` client capability.

## 0.38.0
* Exercise the new group feature of output events: 'log(start)' or 'log(startCollapsed)' starts a group, 'log(end)' ends a group.

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
},
"dependencies": {
"await-notify": "1.0.1",
"vscode-debugadapter": "1.39.1"
"vscode-debugadapter": "1.40.0-pre.1"
},
"devDependencies": {
"@types/node": "10.12.12",
"@types/mocha": "5.2.7",
"@types/vscode": "^1.43.0",
"typescript": "3.5.3",
"mocha": "6.2.0",
"vscode-debugadapter-testsupport": "1.40.2",
"vscode-debugadapter-testsupport": "1.40.3-pre.0",
"tslint": "5.18.0",
"vsce": "1.66.0"
},
Expand Down
4 changes: 3 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as Net from 'net';
* The compile time flag 'runMode' controls how the debug adapter is run.
* Please note: the test suite only supports 'external' mode.
*/
const runMode: 'external' | 'server' | 'inline' = 'external';
const runMode: 'external' | 'server' | 'inline' = 'inline';

export function activate(context: vscode.ExtensionContext) {

Expand Down Expand Up @@ -53,12 +53,14 @@ export function activate(context: vscode.ExtensionContext) {
}

// override VS Code's default implementation of the debug hover
/*
vscode.languages.registerEvaluatableExpressionProvider('markdown', {
provideEvaluatableExpression(document: vscode.TextDocument, position: vscode.Position): vscode.ProviderResult<vscode.EvaluatableExpression> {
const wordRange = document.getWordRangeAtPosition(position);
return wordRange ? new vscode.EvaluatableExpression(wordRange) : undefined;
}
});
*/
}

export function deactivate() {
Expand Down
47 changes: 47 additions & 0 deletions src/mockDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Logger, logger,
LoggingDebugSession,
InitializedEvent, TerminatedEvent, StoppedEvent, BreakpointEvent, OutputEvent,
ProgressStartEvent, ProgressUpdateEvent, ProgressEndEvent,
Thread, StackFrame, Scope, Source, Handles, Breakpoint
} from 'vscode-debugadapter';
import { DebugProtocol } from 'vscode-debugprotocol';
Expand Down Expand Up @@ -47,6 +48,10 @@ export class MockDebugSession extends LoggingDebugSession {
private _cancelationTokens = new Map<number, boolean>();
private _isLongrunning = new Map<number, boolean>();

private _reportProgress = false;
private _progressId = 10000;
private _cancelledProgressId: string | undefined = undefined;

/**
* Creates a new debug adapter that is used for one debug session.
* We configure the default implementation of a debug adapter here.
Expand Down Expand Up @@ -103,6 +108,10 @@ export class MockDebugSession extends LoggingDebugSession {
*/
protected initializeRequest(response: DebugProtocol.InitializeResponse, args: DebugProtocol.InitializeRequestArguments): void {

if (args.supportsProgressReporting) {
this._reportProgress = true;
}

// build and return the capabilities of this debug adapter:
response.body = response.body || {};

Expand Down Expand Up @@ -361,6 +370,16 @@ export class MockDebugSession extends LoggingDebugSession {
this.sendEvent(new BreakpointEvent('removed', bp));
reply = `breakpoint deleted`;
}
} else {
const matches = /progress/.exec(args.expression);
if (matches && matches.length === 1) {
if (this._reportProgress) {
reply = `progress started`;
this.progressSequence();
} else {
reply = `frontend doesn't support progress (capability 'supportsProgressReporting' not set)`;
}
}
}
}
}
Expand All @@ -372,6 +391,31 @@ export class MockDebugSession extends LoggingDebugSession {
this.sendResponse(response);
}

private async progressSequence() {

const ID = '' + this._progressId++;

await timeout(100);

const startEvent: DebugProtocol.ProgressStartEvent = new ProgressStartEvent(ID, 'Some debug progress');
startEvent.body.cancellable = true;
this.sendEvent(startEvent);

let endMessage = 'progress ended';

for (let i = 0; i < 100; i++) {
await timeout(500);
this.sendEvent(new ProgressUpdateEvent(ID, `progress: ${i}`));
if (this._cancelledProgressId === ID) {
endMessage = 'progress cancelled';
this._cancelledProgressId = undefined;
}
}
this.sendEvent(new ProgressEndEvent(ID, endMessage));

this._cancelledProgressId = undefined;
}

protected dataBreakpointInfoRequest(response: DebugProtocol.DataBreakpointInfoResponse, args: DebugProtocol.DataBreakpointInfoArguments): void {

response.body = {
Expand Down Expand Up @@ -439,6 +483,9 @@ export class MockDebugSession extends LoggingDebugSession {
if (args.requestId) {
this._cancelationTokens.set(args.requestId, true);
}
if (args.progressId) {
this._cancelledProgressId= args.progressId;
}
}

//---- helpers
Expand Down
34 changes: 17 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
integrity sha512-Pr+6JRiKkfsFvmU/LK68oBRCQeEg36TyAbPhc2xpez24OOZZCuoIhWGTd39VZy6nGafSbxzGouFPTFD/rR1A0A==

"@types/vscode@^1.43.0":
version "1.42.0"
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.42.0.tgz#0ad891a9487e91e34be7c56985058a179031eb76"
integrity sha512-ds6TceMsh77Fs0Mq0Vap6Y72JbGWB8Bay4DrnJlf5d9ui2RSe1wis13oQm+XhguOeH1HUfLGzaDAoupTUtgabw==
version "1.43.0"
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.43.0.tgz#22276e60034c693b33117f1068ffaac0e89522db"
integrity sha512-kIaR9qzd80rJOxePKpCB/mdy00mz8Apt2QA5Y6rdrKFn13QNFNeP3Hzmsf37Bwh/3cS7QjtAeGSK7wSqAU0sYQ==

ansi-colors@3.2.3:
version "3.2.3"
Expand Down Expand Up @@ -1149,25 +1149,25 @@ vsce@1.66.0:
yauzl "^2.3.1"
yazl "^2.2.2"

vscode-debugadapter-testsupport@1.40.2:
version "1.40.2"
resolved "https://registry.yarnpkg.com/vscode-debugadapter-testsupport/-/vscode-debugadapter-testsupport-1.40.2.tgz#701d5bb67fa856feb22c0fcd289b6137451a7c72"
integrity sha512-HN1KoQUtFwCfPz2r1XaOtw3aUPpkgDPPRpLSGjCbOGRYhUJKlnLEwSaq4djVvZsfav6Zfd9QaBoaBNy03eBTvg==
vscode-debugadapter-testsupport@1.40.3-pre.0:
version "1.40.3-pre.0"
resolved "https://registry.yarnpkg.com/vscode-debugadapter-testsupport/-/vscode-debugadapter-testsupport-1.40.3-pre.0.tgz#a87a8fc9e4e0a29550e721560d320654314b10b4"
integrity sha512-T5APveA4v7UAw8asxlzF2mHPP8EV4jpK4QUVj2MVd9gQFZckpl6ZQ72qToiFfxAthXjpE9WVMXQCJauscvce9A==
dependencies:
vscode-debugprotocol "1.39.0"
vscode-debugprotocol "1.40.0-pre.0"

vscode-debugadapter@1.39.1:
version "1.39.1"
resolved "https://registry.yarnpkg.com/vscode-debugadapter/-/vscode-debugadapter-1.39.1.tgz#c5d2565a1f27c95c6d2fc7a893ce94942570dc95"
integrity sha512-+WYpOcY0PiAEBILf6nIwbNVF8ig8gugWTKWhQ7Ds1884JXpVL336pG0xH66Nc1Z1W/KSzuXarm1gtccdwl6PKw==
vscode-debugadapter@1.40.0-pre.1:
version "1.40.0-pre.1"
resolved "https://registry.yarnpkg.com/vscode-debugadapter/-/vscode-debugadapter-1.40.0-pre.1.tgz#25f947d0313f51ef9da370c59d87a6609d08dc57"
integrity sha512-TdipTiDHfg3/4bXJOSG+mSKWqFARZ7TwQLNEdIvenbwppdjJ1t5VOfhHNQ0l5kkxx8Xs29iK1Yf7uPEXu+2nqg==
dependencies:
mkdirp "^0.5.1"
vscode-debugprotocol "1.39.0"
vscode-debugprotocol "1.40.0-pre.0"

vscode-debugprotocol@1.39.0:
version "1.39.0"
resolved "https://registry.yarnpkg.com/vscode-debugprotocol/-/vscode-debugprotocol-1.39.0.tgz#0c639178d0d5ea7de7903b6478b53d2bc0d77461"
integrity sha512-Wkvgtuz90vjtQBcvw9Z+BYa4dA6W+sHwHMpqvJVNmwWSuT3JZdl0XDhZNLqtMXkVF4okxtAe0MmbupPSt+gnAQ==
vscode-debugprotocol@1.40.0-pre.0:
version "1.40.0-pre.0"
resolved "https://registry.yarnpkg.com/vscode-debugprotocol/-/vscode-debugprotocol-1.40.0-pre.0.tgz#54300191649d4b3fa671b83fb6ea25c5f7622ff5"
integrity sha512-2ghen3Pcnxrw2+ZK0HuG/NQqhT0lAHfZodLQinBMWNbApucKva4jjTfUUoU69m39O46J0ENdVQeFTAL2oyy6Zg==

which-module@^2.0.0:
version "2.0.0"
Expand Down

0 comments on commit fa66f93

Please sign in to comment.