diff --git a/extension/package.json b/extension/package.json index 0b19efc..54a461f 100644 --- a/extension/package.json +++ b/extension/package.json @@ -7,7 +7,7 @@ "version": "2.4.0", "license": "GPL-3.0", "engines": { - "vscode": "^1.46.0" + "vscode": "^1.55.0" }, "publisher": "hediet", "keywords": [ @@ -138,7 +138,7 @@ "@types/express": "^4.17.2", "@types/serve-static": "^1.13.3", "@types/node": "^13.7.4", - "@types/vscode": "1.46.0", + "@types/vscode": "1.55.0", "tslint": "^6.0.0", "typescript": "^3.8.2", "webpack": "^4.41.6", diff --git a/extension/src/VisualizationBackend/ConfigurableVisualizationSupport.ts b/extension/src/VisualizationBackend/ConfigurableVisualizationSupport.ts index 921ede9..e34ac4f 100644 --- a/extension/src/VisualizationBackend/ConfigurableVisualizationSupport.ts +++ b/extension/src/VisualizationBackend/ConfigurableVisualizationSupport.ts @@ -7,7 +7,7 @@ import { import { Config, DebugAdapterConfig } from "../Config"; import { GenericVisualizationBackend } from "./GenericVisualizationSupport"; import { registerUpdateReconciler, hotClass } from "@hediet/node-reload"; -import { DebuggerViewProxy } from "../proxies/DebuggerViewProxy"; +import { DebuggerViewProxy, FrameIdGetter } from "../proxies/DebuggerViewProxy"; registerUpdateReconciler(module); @@ -16,7 +16,8 @@ export class ConfigurableVisualizationSupport implements DebugSessionVisualizationSupport { constructor( private readonly config: Config, - private readonly debuggerView: DebuggerViewProxy + private readonly debuggerView: DebuggerViewProxy, + private readonly frameIdGetter: FrameIdGetter ) {} createBackend( @@ -29,7 +30,8 @@ export class ConfigurableVisualizationSupport return new ConfiguredVisualizationBackend( session, this.debuggerView, - config + config, + this.frameIdGetter ); } } @@ -38,9 +40,10 @@ class ConfiguredVisualizationBackend extends GenericVisualizationBackend { constructor( debugSession: DebugSessionProxy, debuggerView: DebuggerViewProxy, - private readonly config: DebugAdapterConfig + private readonly config: DebugAdapterConfig, + frameIdGetter: FrameIdGetter ) { - super(debugSession, debuggerView); + super(debugSession, debuggerView, frameIdGetter); } protected getContext() { diff --git a/extension/src/VisualizationBackend/GenericVisualizationSupport.ts b/extension/src/VisualizationBackend/GenericVisualizationSupport.ts index 3f44e89..54b5dd8 100644 --- a/extension/src/VisualizationBackend/GenericVisualizationSupport.ts +++ b/extension/src/VisualizationBackend/GenericVisualizationSupport.ts @@ -14,19 +14,22 @@ import { import { parseEvaluationResultFromGenericDebugAdapter } from "./parseEvaluationResultFromGenericDebugAdapter"; import { FormattedMessage } from "../webviewContract"; import { hotClass, registerUpdateReconciler } from "@hediet/node-reload"; -import { DebuggerViewProxy } from "../proxies/DebuggerViewProxy"; +import { DebuggerViewProxy, FrameIdGetter } from "../proxies/DebuggerViewProxy"; registerUpdateReconciler(module); @hotClass(module) export class GenericVisualizationSupport implements DebugSessionVisualizationSupport { - constructor(private readonly debuggerView: DebuggerViewProxy) {} + constructor( + private readonly debuggerView: DebuggerViewProxy, + private readonly frameIdGetter: FrameIdGetter + ) {} createBackend( session: DebugSessionProxy ): VisualizationBackend | undefined { - return new GenericVisualizationBackend(session, this.debuggerView); + return new GenericVisualizationBackend(session, this.debuggerView, this.frameIdGetter); } } @@ -35,9 +38,10 @@ export class GenericVisualizationBackend extends VisualizationBackendBase { constructor( debugSession: DebugSessionProxy, - debuggerView: DebuggerViewProxy + debuggerView: DebuggerViewProxy, + frameIdGetter: FrameIdGetter ) { - super(debugSession, debuggerView); + super(debugSession, debuggerView, frameIdGetter); } public async getVisualizationData({ @@ -47,7 +51,7 @@ export class GenericVisualizationBackend extends VisualizationBackendBase { | { kind: "data"; result: DataExtractionResult } | { kind: "error"; message: FormattedMessage } > { - const frameId = this.debuggerView.getActiveStackFrameId( + const frameId = this.frameIdGetter.frameId || this.debuggerView.getActiveStackFrameId( this.debugSession ); diff --git a/extension/src/VisualizationBackend/JsVisualizationSupport.ts b/extension/src/VisualizationBackend/JsVisualizationSupport.ts index 0abd123..04af9ee 100644 --- a/extension/src/VisualizationBackend/JsVisualizationSupport.ts +++ b/extension/src/VisualizationBackend/JsVisualizationSupport.ts @@ -10,7 +10,7 @@ import { existsSync, readFileSync, watch } from "fs"; import { observable, reaction } from "mobx"; import { window, workspace } from "vscode"; import { Config } from "../Config"; -import { DebuggerViewProxy } from "../proxies/DebuggerViewProxy"; +import { DebuggerViewProxy, FrameIdGetter } from "../proxies/DebuggerViewProxy"; import { DebugSessionProxy } from "../proxies/DebugSessionProxy"; import { FormattedMessage } from "../webviewContract"; import { @@ -29,7 +29,8 @@ registerUpdateReconciler(module); export class JsEvaluationEngine implements DebugSessionVisualizationSupport { constructor( private readonly debuggerView: DebuggerViewProxy, - private readonly config: Config + private readonly config: Config, + private readonly frameIdGetter: FrameIdGetter ) {} createBackend( @@ -51,7 +52,8 @@ export class JsEvaluationEngine implements DebugSessionVisualizationSupport { return new JsVisualizationBackend( session, this.debuggerView, - this.config + this.config, + this.frameIdGetter ); } return undefined; @@ -65,9 +67,10 @@ class JsVisualizationBackend extends VisualizationBackendBase { constructor( debugSession: DebugSessionProxy, debuggerView: DebuggerViewProxy, - private readonly config: Config + private readonly config: Config, + frameIdGetter: FrameIdGetter ) { - super(debugSession, debuggerView); + super(debugSession, debuggerView, frameIdGetter); } private getContext(): "copy" | "repl" { @@ -112,7 +115,7 @@ class JsVisualizationBackend extends VisualizationBackendBase { | { kind: "not-initialized" } > { try { - const frameId = this.debuggerView.getActiveStackFrameId( + const frameId = this.frameIdGetter.frameId || this.debuggerView.getActiveStackFrameId( this.debugSession ); diff --git a/extension/src/VisualizationBackend/PyVisualizationSupport.ts b/extension/src/VisualizationBackend/PyVisualizationSupport.ts index 3682b32..aa2e840 100644 --- a/extension/src/VisualizationBackend/PyVisualizationSupport.ts +++ b/extension/src/VisualizationBackend/PyVisualizationSupport.ts @@ -15,7 +15,7 @@ import { Config } from "../Config"; import { parseEvaluationResultFromGenericDebugAdapter } from "./parseEvaluationResultFromGenericDebugAdapter"; import { FormattedMessage } from "../webviewContract"; import { hotClass, registerUpdateReconciler } from "@hediet/node-reload"; -import { DebuggerViewProxy } from "../proxies/DebuggerViewProxy"; +import { DebuggerViewProxy, FrameIdGetter } from "../proxies/DebuggerViewProxy"; registerUpdateReconciler(module); @@ -24,7 +24,8 @@ export class PyEvaluationEngine implements DebugSessionVisualizationSupport { constructor( private readonly debuggerView: DebuggerViewProxy, - private readonly config: Config + private readonly config: Config, + private readonly frameIdGetter: FrameIdGetter ) { } createBackend( @@ -39,7 +40,8 @@ export class PyEvaluationEngine return new PyVisualizationBackend( session, this.debuggerView, - this.config + this.config, + this.frameIdGetter ); } return undefined; @@ -52,9 +54,10 @@ export class PyVisualizationBackend extends VisualizationBackendBase { constructor( debugSession: DebugSessionProxy, debuggerView: DebuggerViewProxy, - private readonly config: Config + private readonly config: Config, + frameIdGetter: FrameIdGetter ) { - super(debugSession, debuggerView); + super(debugSession, debuggerView, frameIdGetter); } protected getContext(): "watch" | "repl" { @@ -69,7 +72,7 @@ export class PyVisualizationBackend extends VisualizationBackendBase { | { kind: "data"; result: DataExtractionResult } | { kind: "error"; message: FormattedMessage } > { - const frameId = this.debuggerView.getActiveStackFrameId( + const frameId = this.frameIdGetter.frameId || this.debuggerView.getActiveStackFrameId( this.debugSession ); diff --git a/extension/src/VisualizationBackend/RbVisualizationSupport.ts b/extension/src/VisualizationBackend/RbVisualizationSupport.ts index 434cede..fd321bb 100644 --- a/extension/src/VisualizationBackend/RbVisualizationSupport.ts +++ b/extension/src/VisualizationBackend/RbVisualizationSupport.ts @@ -1,7 +1,7 @@ import { DataExtractionResult, DataResult } from "@hediet/debug-visualizer-data-extraction"; import { hotClass, registerUpdateReconciler } from "@hediet/node-reload"; import { Config } from "../Config"; -import { DebuggerViewProxy } from "../proxies/DebuggerViewProxy"; +import { DebuggerViewProxy, FrameIdGetter } from "../proxies/DebuggerViewProxy"; import { DebugSessionProxy } from "../proxies/DebugSessionProxy"; import { FormattedMessage } from "../webviewContract"; import { DebugSessionVisualizationSupport, GetVisualizationDataArgs, VisualizationBackend, VisualizationBackendBase } from "./VisualizationBackend"; @@ -12,7 +12,8 @@ registerUpdateReconciler(module); export class RbEvaluationEngine implements DebugSessionVisualizationSupport { constructor( private readonly debuggerView: DebuggerViewProxy, - private readonly config: Config + private readonly config: Config, + private readonly frameIdGetter: FrameIdGetter ) { } createBackend( @@ -24,7 +25,8 @@ export class RbEvaluationEngine implements DebugSessionVisualizationSupport { return new RbVisualizationBackend( session, this.debuggerView, - this.config + this.config, + this.frameIdGetter ); } return undefined; @@ -36,9 +38,10 @@ class RbVisualizationBackend extends VisualizationBackendBase { constructor( debugSession: DebugSessionProxy, debuggerView: DebuggerViewProxy, - private readonly config: Config + private readonly config: Config, + frameIdGetter: FrameIdGetter ) { - super(debugSession, debuggerView) + super(debugSession, debuggerView, frameIdGetter) } private readonly defaultContext = "repl"; @@ -63,7 +66,7 @@ class RbVisualizationBackend extends VisualizationBackendBase { try { if (expression.length === 0) throw new Error("No extractors"); - const frameId = this.debuggerView.getActiveStackFrameId( + const frameId = this.frameIdGetter.frameId || this.debuggerView.getActiveStackFrameId( this.debugSession ); const initialReply = await this.debugSession.evaluate({ diff --git a/extension/src/VisualizationBackend/VisualizationBackend.ts b/extension/src/VisualizationBackend/VisualizationBackend.ts index 4c0c509..2ac3a39 100644 --- a/extension/src/VisualizationBackend/VisualizationBackend.ts +++ b/extension/src/VisualizationBackend/VisualizationBackend.ts @@ -6,7 +6,7 @@ import { Disposable } from "@hediet/std/disposable"; import { DebugSessionProxy } from "../proxies/DebugSessionProxy"; import { CompletionItem, FormattedMessage } from "../webviewContract"; import { reaction } from "mobx"; -import { DebuggerViewProxy } from "../proxies/DebuggerViewProxy"; +import { DebuggerViewProxy, FrameIdGetter } from "../proxies/DebuggerViewProxy"; import { EventEmitter, EventSource } from "@hediet/std/events"; export interface DebugSessionVisualizationSupport { @@ -44,7 +44,8 @@ export abstract class VisualizationBackendBase implements VisualizationBackend { constructor( protected readonly debugSession: DebugSessionProxy, - protected readonly debuggerView: DebuggerViewProxy + protected readonly debuggerView: DebuggerViewProxy, + protected readonly frameIdGetter: FrameIdGetter ) { this.dispose.track({ dispose: reaction( diff --git a/extension/src/extension.ts b/extension/src/extension.ts index fb6deb2..0bb3bed 100644 --- a/extension/src/extension.ts +++ b/extension/src/extension.ts @@ -1,4 +1,4 @@ -import { window, ExtensionContext, commands } from "vscode"; +import { window, ExtensionContext, commands, languages } from "vscode"; import { Disposable } from "@hediet/std/disposable"; import { enableHotReload, @@ -16,7 +16,7 @@ import { InternalWebviewManager } from "./webview/InternalWebviewManager"; import { WebviewServer } from "./webview/WebviewServer"; import { Config } from "./Config"; import { DebuggerProxy } from "./proxies/DebuggerProxy"; -import { DebuggerViewProxy } from "./proxies/DebuggerViewProxy"; +import { DebuggerViewProxy, FrameIdGetter } from "./proxies/DebuggerViewProxy"; import { VisualizationWatchModelImpl } from "./VisualizationWatchModel"; import { ComposedVisualizationSupport, @@ -45,28 +45,36 @@ export class Extension { new DebuggerViewProxy(this.debugger) ); - public readonly dataSource = new VisualizationWatchModelImpl( - new DispatchingVisualizationBackend( - new ComposedVisualizationSupport([ - new ConfigurableVisualizationSupport( - this.config, - this.debuggerView - ), - new JsEvaluationEngine(this.debuggerView, this.config), - new PyEvaluationEngine(this.debuggerView, this.config), - new RbEvaluationEngine(this.debuggerView, this.config), - new GenericVisualizationSupport(this.debuggerView), - ]), - this.debuggerView - ) - ); + constructor() { + const frameIdGetter = new FrameIdGetter(); - private readonly server = new WebviewServer(this.dataSource, this.config); - private readonly views = this.dispose.track( - new InternalWebviewManager(this.server, this.config) - ); + this.dispose.track( + languages.registerInlineValuesProvider("*", frameIdGetter) + ); + + const dataSource = new VisualizationWatchModelImpl( + new DispatchingVisualizationBackend( + new ComposedVisualizationSupport([ + new ConfigurableVisualizationSupport( + this.config, + this.debuggerView, + frameIdGetter + ), + new JsEvaluationEngine(this.debuggerView, this.config, frameIdGetter), + new PyEvaluationEngine(this.debuggerView, this.config, frameIdGetter), + new RbEvaluationEngine(this.debuggerView, this.config, frameIdGetter), + new GenericVisualizationSupport(this.debuggerView, frameIdGetter), + ]), + this.debuggerView + ) + ); + + const server = new WebviewServer(dataSource, this.config); + + const views = this.dispose.track( + new InternalWebviewManager(server, this.config) + ); - constructor() { if (getReloadCount(module) > 0) { const i = this.dispose.track(window.createStatusBarItem()); i.text = "reload" + getReloadCount(module); @@ -77,7 +85,7 @@ export class Extension { commands.registerCommand( "vscode-debug-visualizer.new-visualizer", () => { - this.views.createNew(); + views.createNew(); } ) ); @@ -117,14 +125,14 @@ export class Extension { return; } - const connections = [...this.server.connections.values()]; + const connections = [...server.connections.values()]; const latestConnection = connections[connections.length - 1]; if (latestConnection) { latestConnection.setExpression(selectedText); } else { - this.views.createNew(selectedText); + views.createNew(selectedText); } } ) diff --git a/extension/src/proxies/DebuggerViewProxy.ts b/extension/src/proxies/DebuggerViewProxy.ts index 6087374..f8ee033 100644 --- a/extension/src/proxies/DebuggerViewProxy.ts +++ b/extension/src/proxies/DebuggerViewProxy.ts @@ -1,5 +1,5 @@ import { Disposable } from "@hediet/std/disposable"; -import { debug, DebugSession } from "vscode"; +import { CancellationToken, debug, DebugSession, InlineValue, InlineValueContext, InlineValuesProvider, ProviderResult, Range, TextDocument } from "vscode"; import { observable, action } from "mobx"; import { DebuggerProxy } from "./DebuggerProxy"; import { DebugSessionProxy } from "./DebugSessionProxy"; @@ -39,3 +39,15 @@ export class DebuggerViewProxy { : undefined; } } + +export class FrameIdGetter implements InlineValuesProvider, CurFrameIdGetter { + frameId: number | undefined; + provideInlineValues(document: TextDocument, viewPort: Range, context: InlineValueContext, token: CancellationToken): ProviderResult { + this.frameId = context.frameId; + return [] + } +} + +interface CurFrameIdGetter { + readonly frameId: number | undefined; +} diff --git a/yarn.lock b/yarn.lock index 9a2dbea..5c231fc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -994,10 +994,10 @@ dependencies: source-map "^0.6.1" -"@types/vscode@1.46.0": - version "1.46.0" - resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.46.0.tgz#53f2075986e901ed25cd1ec5f3ffa5db84a111b3" - integrity sha512-8m9wPEB2mcRqTWNKs9A9Eqs8DrQZt0qNFO8GkxBOnyW6xR//3s77SoMgb/nY1ctzACsZXwZj3YRTDsn4bAoaUw== +"@types/vscode@1.55.0": + version "1.55.0" + resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.55.0.tgz#58cfbebbd32b3e374e07e7858b1fd0e92b1a1d2b" + integrity sha512-49hysH7jneTQoSC8TWbAi7nKK9Lc5osQNjmDHVosrcU8o3jecD9GrK0Qyul8q4aGPSXRfNGqIp9CBdb13akETg== "@types/webpack-sources@*": version "0.1.6"