Skip to content

Commit

Permalink
Merge pull request #1807 from microsoft/connor4312/wasm-14
Browse files Browse the repository at this point in the history
feat: prompt to install extension on wasm step
  • Loading branch information
connor4312 committed Sep 20, 2023
2 parents d9d52b4 + ed66fe3 commit ccabc8c
Show file tree
Hide file tree
Showing 21 changed files with 836 additions and 213 deletions.
33 changes: 26 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
"@types/ws": "^8.5.3",
"@typescript-eslint/eslint-plugin": "^5.17.0",
"@typescript-eslint/parser": "^5.17.0",
"@vscode/dwarf-debugging": "^0.0.2",
"@vscode/test-electron": "^2.2.3",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
Expand Down
18 changes: 18 additions & 0 deletions src/adapter/dwarf/dwarfModuleProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

export const IDwarfModuleProvider = Symbol('IDwarfModuleProvider');

export interface IDwarfModuleProvider {
/**
* Loads the dwarf module if it exists.
*/
load(): Promise<typeof import('@vscode/dwarf-debugging') | undefined>;

/**
* Prompts the user to install the dwarf module (called if the module is
* not installed.)
*/
prompt(): void;
}
40 changes: 40 additions & 0 deletions src/adapter/dwarf/dwarfModuleProviderImpl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

import type * as dwf from '@vscode/dwarf-debugging';
import * as l10n from '@vscode/l10n';
import { inject, injectable } from 'inversify';
import Dap from '../../dap/api';
import { IDapApi } from '../../dap/connection';
import { IDwarfModuleProvider } from './dwarfModuleProvider';

const name = '@vscode/dwarf-debugging';

@injectable()
export class DwarfModuleProvider implements IDwarfModuleProvider {
private didPrompt = false;

constructor(@inject(IDapApi) private readonly dap: Dap.Api) {}

public async load(): Promise<typeof dwf | undefined> {
try {
return await import(name);
} catch {
return undefined;
}
}

public prompt() {
if (!this.didPrompt) {
this.didPrompt = true;
this.dap.output({
output: l10n.t(
'You may install the `{}` module via npm for enhanced WebAssembly debugging',
name,
),
category: 'console',
});
}
}
}
Loading

0 comments on commit ccabc8c

Please sign in to comment.