This repository has been archived by the owner on Jul 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add vscode binding for the solidity dap
- Loading branch information
1 parent
8bdd02c
commit 7b1de7b
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import * as path from 'path'; | ||
import { | ||
debug, | ||
window, | ||
DebugAdapterDescriptorFactory, | ||
DebugSession, | ||
DebugAdapterExecutable, | ||
DebugAdapterDescriptor, | ||
ExtensionContext, | ||
OutputChannel, | ||
ProviderResult, | ||
} from 'vscode'; | ||
import * as os from 'os'; | ||
|
||
let outputChannel: OutputChannel; | ||
|
||
export function registerDebugger(context: ExtensionContext) { | ||
outputChannel = window.createOutputChannel('SolidityDebugger'); | ||
|
||
context.subscriptions.push( | ||
debug.registerDebugAdapterDescriptorFactory('solidity', new SolidityDebugAdapterDescriptorFactory(context)), | ||
debug.onDidTerminateDebugSession(() => { | ||
outputChannel.appendLine(`Debug session ended.`); | ||
}), | ||
); | ||
} | ||
|
||
export class SolidityDebugAdapterDescriptorFactory implements DebugAdapterDescriptorFactory { | ||
context: ExtensionContext; | ||
|
||
constructor(context: ExtensionContext) { | ||
this.context = context; | ||
} | ||
|
||
async createDebugAdapterDescriptor( | ||
_session: DebugSession, | ||
_executable: DebugAdapterExecutable, | ||
): Promise<ProviderResult<DebugAdapterDescriptor>> { | ||
const serverBinary = this.context.asAbsolutePath( | ||
path.join('dist', | ||
os.platform().startsWith("win") ? 'foundry-dap-server.exe' : 'foundry-dap-server') | ||
); | ||
|
||
if (!serverBinary) { | ||
throw new Error('Could not find Solidity debugger server'); | ||
} | ||
|
||
return new DebugAdapterExecutable(serverBinary, []); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters