import * as vscode from "vscode" ; import * as path from 'path' ; import * as os from 'os' ; import * as nls from 'vscode-nls' ; nls . config ( { messageFormat : nls . MessageFormat . bundle , bundleFormat : nls . BundleFormat . standalone } ) ( ) ; const localize = nls . loadMessageBundle ( ) ; abstract class AbstractDebugAdapterDescriptorFactory implements vscode . DebugAdapterDescriptorFactory { protected readonly context : vscode . ExtensionContext ; constructor ( context ) { this . context = context ; } abstract createDebugAdapterDescriptor ( session , executable ? ) ; } export class CppdbgDebugAdapterDescriptorFactory extends AbstractDebugAdapterDescriptorFactory { public static DEBUG_TYPE : string = "cppdbg" ; constructor ( context ) { super ( context ) ; } async createDebugAdapterDescriptor ( session , executable ? ) { const adapter = "./debugAdapters/bin/OpenDebugAD7" + ( os . platform ( ) === 'win32' ? ".exe" : "" ) ; const command = path . join ( this . context . extensionPath , adapter ) ; return new vscode . DebugAdapterExecutable ( command , [ ] ) ; } } export class CppvsdbgDebugAdapterDescriptorFactory extends AbstractDebugAdapterDescriptorFactory { public static DEBUG_TYPE : string = "cppvsdbg" ; constructor ( context ) { super ( context ) ; } async createDebugAdapterDescriptor ( session , executable ? ) { if ( os . platform ( ) !== 'win32' ) { vscode . window . showErrorMessage ( localize ( "debugger.not.available" , "Debugger type '{0}' is not avaliable for non-Windows machines." , "cppvsdbg" ) ) ; return null ; } else { return new vscode . DebugAdapterExecutable ( path . join ( this . context . extensionPath , './debugAdapters/vsdbg/bin/vsdbg.exe' ) , [ '--interpreter=vscode' , '--extConfigDir=%USERPROFILE%\\.cppvsdbg\\extensions' ] ) ; } } }