Skip to content

Commit 1ad9897

Browse files
committed
Fix build issues, to enable tests
1 parent a52200a commit 1ad9897

File tree

7 files changed

+30
-51
lines changed

7 files changed

+30
-51
lines changed

frontend/src/messaging.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { vscode } from "./main";
33

44
export function getComlinkChannel(): Endpoint {
55
return {
6-
addEventListener: (type: string, listener: any) => window.addEventListener(type, listener),
7-
removeEventListener: () => { }, // todo window.removeEventListener
8-
postMessage: (object: any) => vscode.postMessage(object),
6+
addEventListener: (type: string, listener: EventListenerOrEventListenerObject) => window.addEventListener(type, listener),
7+
removeEventListener: (type: string, listener: EventListenerOrEventListenerObject, _options?: {}) => window.removeEventListener(type, listener),
8+
postMessage: (object: unknown) => vscode.postMessage(object),
99
};
1010
}

src/debug/callstack-extractor.ts

+1-13
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,6 @@ async function findSymbolForLine(file: Uri, zeroIndexedLine: number) {
3838
}
3939

4040

41-
async function convertScriptLineNumberToFunctionLineNumber(file: Uri, zeroIndexedFileLineNumber: number): Promise<number> {
42-
const documentSymbols = await findSymbolForLine(file, zeroIndexedFileLineNumber);
43-
if (!documentSymbols) {
44-
return zeroIndexedFileLineNumber;
45-
}
46-
const filteredBySymbolType = documentSymbols.filter(symbol => symbol.kind === SymbolKind.Function || symbol.kind === SymbolKind.Method || symbol.kind === SymbolKind.Constructor);
47-
const hasCorrection = filteredBySymbolType.length > 0;
48-
const correctedLine = hasCorrection ? (zeroIndexedFileLineNumber - filteredBySymbolType[0].range.start.line) : zeroIndexedFileLineNumber;
49-
return correctedLine;
50-
}
51-
52-
5341
async function getFunctionLocation(file: Uri, name: string, zeroIndexedLine: number): Promise<Range> {
5442
const documentSymbols = await findSymbolForLine(file, zeroIndexedLine);
5543
const allFunctions = documentSymbols
@@ -125,5 +113,5 @@ async function getCallLocation(frame: DebugProtocol.StackFrame): Promise<CallLoc
125113

126114
export async function getStacktraceInfo(): Promise<StackTraceInfo> {
127115
const stackFrames = await callDebugFunction('stackTrace', { threadId: debug.activeStackItem?.threadId ?? 1 });
128-
return await Promise.all(stackFrames.stackFrames.map((frame, index) => getCallLocation(frame)));
116+
return await Promise.all(stackFrames.stackFrames.map((frame) => getCallLocation(frame)));
129117
}

src/extension.ts

+18-30
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { commands, debug, ExtensionContext, Webview, WebviewPanel, window, workspace } from 'vscode';
1+
import { commands, debug, ExtensionContext, WebviewPanel, window, workspace } from 'vscode';
22
import { ComlinkFrontendApi } from 'shared/src/index';
33
import { getMonacoTheme } from './webview/themes';
44
import { createWebview, getVueFrontendPanelContent } from './webview/content';
@@ -9,40 +9,27 @@ import { FrontendApi } from './debug/frontend-functions';
99

1010
let currentFrontendRpcChannel: Comlink.Remote<ComlinkFrontendApi> | undefined = undefined;
1111

12-
async function updateViewWithStackTrace(_webview: Webview, _context: ExtensionContext) {
12+
async function updateViewWithStackTrace() {
1313
try {
1414
if (!currentFrontendRpcChannel) {
1515
throw new Error("No rpc channel found");
1616
}
1717
const result = await getStacktraceInfo();
1818
await currentFrontendRpcChannel.setStackTrace(result);
1919
} catch (e: unknown) {
20-
// todo remove in release build!
2120
window.showErrorMessage("failed to load stacktrace, due to error, please try to open view again. Error: " + e);
2221
}
2322
}
2423

24+
2525
export async function activate(context: ExtensionContext) {
2626
let currentPanel: WebviewPanel | undefined = undefined;
2727
// started debug session
28-
context.subscriptions.push(debug.onDidStartDebugSession(async (e) => {
29-
if (currentPanel?.webview) {
30-
await updateViewWithStackTrace(currentPanel.webview, context);
31-
}
32-
}));
33-
28+
context.subscriptions.push(debug.onDidStartDebugSession(updateViewWithStackTrace));
3429
// step into, step out, step over, change active stack item, change active debug session, receive custom event
35-
context.subscriptions.push(debug.onDidChangeActiveStackItem(async (e) => {
36-
if (currentPanel?.webview) {
37-
await updateViewWithStackTrace(currentPanel.webview, context);
38-
}
39-
}));
40-
41-
context.subscriptions.push(debug.onDidChangeActiveDebugSession(async (e) => {
42-
if (currentPanel?.webview) {
43-
await updateViewWithStackTrace(currentPanel.webview, context);
44-
}
45-
}));
30+
context.subscriptions.push(debug.onDidChangeActiveStackItem(updateViewWithStackTrace));
31+
// stopped/started/changed debug session
32+
context.subscriptions.push(debug.onDidChangeActiveDebugSession(updateViewWithStackTrace));
4633

4734
workspace.onDidChangeConfiguration(async event => {
4835
if (event.affectsConfiguration('workbench.colorTheme')) {
@@ -51,6 +38,13 @@ export async function activate(context: ExtensionContext) {
5138
}
5239
});
5340

41+
function disposeRpcChannel() {
42+
if (currentFrontendRpcChannel) {
43+
currentFrontendRpcChannel[Comlink.releaseProxy]();
44+
currentFrontendRpcChannel = undefined;
45+
}
46+
}
47+
5448
commands.registerCommand('call-graph.show-call-graph', async () => {
5549
try {
5650
if (!currentPanel?.webview) {
@@ -69,17 +63,11 @@ export async function activate(context: ExtensionContext) {
6963

7064
currentPanel.onDidDispose(() => {
7165
currentPanel = undefined;
72-
if (currentFrontendRpcChannel) {
73-
currentFrontendRpcChannel[Comlink.releaseProxy]();
74-
}
75-
currentFrontendRpcChannel = undefined;
66+
disposeRpcChannel();
7667
});
7768

7869
// release current channel if needed
79-
if (currentFrontendRpcChannel) {
80-
currentFrontendRpcChannel[Comlink.releaseProxy]();
81-
currentFrontendRpcChannel = undefined;
82-
}
70+
disposeRpcChannel();
8371

8472
currentFrontendRpcChannel = Comlink.wrap<ComlinkFrontendApi>(getComlinkChannel(currentPanel.webview, context));
8573

@@ -88,7 +76,7 @@ export async function activate(context: ExtensionContext) {
8876

8977

9078
if (debug.activeDebugSession) {
91-
await updateViewWithStackTrace(currentPanel.webview, context);
79+
await updateViewWithStackTrace();
9280
} else {
9381
window.showWarningMessage('No active debug session, the view will automatically update when a debug session is started');
9482
}
@@ -99,7 +87,7 @@ export async function activate(context: ExtensionContext) {
9987

10088

10189
window.registerWebviewPanelSerializer('graph-visualization', {
102-
deserializeWebviewPanel: async function (webviewPanel: WebviewPanel, state: unknown): Promise<void> {
90+
deserializeWebviewPanel: async (webviewPanel: WebviewPanel, _state: unknown) => {
10391
currentPanel = webviewPanel;
10492
await commands.executeCommand('call-graph.show-call-graph');
10593
}

src/inspect/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { getValueWithEvalMethod } from "./use-eval";
44
import { getValueWithLookupMethod } from "./use-lookup";
55

66
export async function getCurrentValueForPosition(uri: Uri, line: number, column: number, frameId: number): Promise<ValueLookupResult | undefined> {
7-
const evalValue = await getValueWithEvalMethod(uri, line, column, frameId).catch(e => undefined);
7+
const evalValue = await getValueWithEvalMethod(uri, line, column, frameId).catch(() => undefined);
88
if (evalValue) {
99
return evalValue;
1010
}
11-
const lookupValue = await getValueWithLookupMethod(uri, line, column, frameId).catch(e => undefined);
11+
const lookupValue = await getValueWithLookupMethod(uri, line, column, frameId).catch(() => undefined);
1212
return lookupValue;
1313
}

src/inspect/typed-debug.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ export async function getVariablesRecursive(variableRef: number, maxRecursion =
1717
if (maxRecursion <= 0) {
1818
return [];
1919
}
20-
const variablesResponse = await callDebugFunction('variables', { variablesReference: variableRef }).catch(e => ({ variables: [] }));
20+
const variablesResponse = await callDebugFunction('variables', { variablesReference: variableRef }).catch(() => ({ variables: [] }));
2121
const results = await Promise.all(variablesResponse.variables.map(async (variable) => ({
2222
name: variable.name,
2323
value: variable.value,
2424
type: variable.type,
25-
subVariables: await getVariablesRecursive(variable.variablesReference, maxRecursion - 1).catch(e => [])
25+
subVariables: await getVariablesRecursive(variable.variablesReference, maxRecursion - 1).catch(() => [])
2626
} as VariableInfo)));
2727
return results;
2828
}

src/inspect/use-lookup.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ValueLookupResult } from "shared/src";
2-
import { Uri, Position, debug, workspace, DebugSession, window } from "vscode";
2+
import { Uri, Position, debug, workspace, DebugSession } from "vscode";
33
import { callDebugFunction, getVariablesRecursive } from "./typed-debug";
44

55
export async function getValueWithLookupMethod(uri: Uri, line: number, column: number, frameId: number): Promise<ValueLookupResult> {

tsconfig.json

+3
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@
2323
"frontend/**/*", // Exclude the inner project
2424
"shared/**/*", // Exclude the shared project
2525
"node_modules"
26+
],
27+
"include": [
28+
"src/**/*"
2629
]
2730
}

0 commit comments

Comments
 (0)