Skip to content

Commit

Permalink
Uses InlineValuesProvider to get frame id
Browse files Browse the repository at this point in the history
  • Loading branch information
hediet committed Nov 19, 2023
1 parent 1d70b99 commit b66c30b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
8 changes: 8 additions & 0 deletions demos/js/src/demo_stack-frames.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

function test() {
let i = 1;
debugger;
}

let i = 0;
test();
5 changes: 5 additions & 0 deletions extension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 2.6.0

- Improved JS data extractors
- Uses the active stack frame (instead of the top-most) for evaluating expressions

## 2.4.0

- [Ruby support](https://github.com/hediet/vscode-debug-visualizer/pull/159)
Expand Down
4 changes: 2 additions & 2 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"version": "2.6.0",
"license": "GPL-3.0",
"engines": {
"vscode": "^1.79.1"
"vscode": "^1.84.0"
},
"publisher": "hediet",
"keywords": [
Expand Down Expand Up @@ -136,7 +136,7 @@
"@types/express": "^4.17.2",
"@types/serve-static": "^1.13.3",
"@types/node": "^13.7.4",
"@types/vscode": "^1.79.1",
"@types/vscode": "^1.84.0",
"tslint": "^6.1.3",
"typescript": "^5.1.6",
"webpack": "^5.88.1",
Expand Down
19 changes: 18 additions & 1 deletion extension/src/proxies/DebuggerViewProxy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Disposable } from "@hediet/std/disposable";
import { debug, DebugSession } from "vscode";
import { CancellationToken, debug, DebugSession, InlineValue, InlineValueContext, InlineValuesProvider, languages, ProviderResult, Range, TextDocument } from "vscode";
import { observable, action } from "mobx";
import { DebuggerProxy } from "./DebuggerProxy";
import { DebugSessionProxy } from "./DebugSessionProxy";
Expand Down Expand Up @@ -30,6 +30,8 @@ export class DebuggerViewProxy {
})
);
this.updateActiveDebugSession(debug.activeDebugSession);

this.dispose.track(languages.registerInlineValuesProvider('*', new FrameIdGetter(this)));
}

@action
Expand All @@ -39,3 +41,18 @@ export class DebuggerViewProxy {
: undefined;
}
}

export class FrameIdGetter implements InlineValuesProvider {
constructor(
private readonly debuggerViewProxy: DebuggerViewProxy,
) {
}

provideInlineValues(document: TextDocument, viewPort: Range, context: InlineValueContext, token: CancellationToken): ProviderResult<InlineValue[]> {
const a = this.debuggerViewProxy.activeDebugSession;
if (a) {
a['_activeStackFrameId'] = context.frameId;
}
return []
}
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1200,10 +1200,10 @@
dependencies:
source-map "^0.6.1"

"@types/vscode@^1.79.1":
version "1.81.0"
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.81.0.tgz#c27228dd063002e0e00611be70b0497beaa24d39"
integrity sha512-YIaCwpT+O2E7WOMq0eCgBEABE++SX3Yl/O02GoMIF2DO3qAtvw7m6BXFYsxnc6XyzwZgh6/s/UG78LSSombl2w==
"@types/vscode@^1.84.0":
version "1.84.1"
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.84.1.tgz#2e89dc074743737209f1769f7e7762499edaca71"
integrity sha512-DB10vBRLEPA/us7p3gQilU2Tq5HDu6JWTyCpD9qtb7MKWIvJS5In9HU3YgVGCXf/miwHJiY62aXwjtUSMpT8HA==

"@types/webpack-sources@*":
version "3.2.0"
Expand Down

0 comments on commit b66c30b

Please sign in to comment.