Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register InlineValuesProvider to get the frame id #170

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.4.0",
"license": "GPL-3.0",
"engines": {
"vscode": "^1.46.0"
"vscode": "^1.55.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to upgrade the version of vscode since InlineValuesProvider is not introduced in "1.46.0".

},
"publisher": "hediet",
"keywords": [
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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(
Expand All @@ -29,7 +30,8 @@ export class ConfigurableVisualizationSupport
return new ConfiguredVisualizationBackend(
session,
this.debuggerView,
config
config,
this.frameIdGetter
);
}
}
Expand All @@ -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() {
Expand Down
16 changes: 10 additions & 6 deletions extension/src/VisualizationBackend/GenericVisualizationSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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({
Expand All @@ -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
);

Expand Down
15 changes: 9 additions & 6 deletions extension/src/VisualizationBackend/JsVisualizationSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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(
Expand All @@ -51,7 +52,8 @@ export class JsEvaluationEngine implements DebugSessionVisualizationSupport {
return new JsVisualizationBackend(
session,
this.debuggerView,
this.config
this.config,
this.frameIdGetter
);
}
return undefined;
Expand All @@ -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" {
Expand Down Expand Up @@ -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
);

Expand Down
15 changes: 9 additions & 6 deletions extension/src/VisualizationBackend/PyVisualizationSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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(
Expand All @@ -39,7 +40,8 @@ export class PyEvaluationEngine
return new PyVisualizationBackend(
session,
this.debuggerView,
this.config
this.config,
this.frameIdGetter
);
}
return undefined;
Expand All @@ -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" {
Expand All @@ -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
);

Expand Down
15 changes: 9 additions & 6 deletions extension/src/VisualizationBackend/RbVisualizationSupport.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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(
Expand All @@ -24,7 +25,8 @@ export class RbEvaluationEngine implements DebugSessionVisualizationSupport {
return new RbVisualizationBackend(
session,
this.debuggerView,
this.config
this.config,
this.frameIdGetter
);
}
return undefined;
Expand All @@ -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";
Expand All @@ -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({
Expand Down
5 changes: 3 additions & 2 deletions extension/src/VisualizationBackend/VisualizationBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down
58 changes: 33 additions & 25 deletions extension/src/extension.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -77,7 +85,7 @@ export class Extension {
commands.registerCommand(
"vscode-debug-visualizer.new-visualizer",
() => {
this.views.createNew();
views.createNew();
}
)
);
Expand Down Expand Up @@ -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);
}
}
)
Expand Down
Loading