import * as vscode from "vscode" ; import { IDebugProvider } from "./debugProvider" ; import { DotNetDebugProvider } from "./dotNetDebugProvider" ; import { GoDebugProvider } from "./goDebugProvider" ; import { JavaDebugProvider } from "./javaDebugProvider" ; import { NodejsDebugProvider } from "./nodejsDebugProvider" ; import { PythonDebugProvider } from "./pythonDebugProvider" ; import { ProcessInfo } from "./debugUtils" ; const supportedProviders = [ new DotNetDebugProvider ( ) , new GoDebugProvider ( ) , new JavaDebugProvider ( ) , new NodejsDebugProvider ( ) , new PythonDebugProvider ( ) ] ; async function showProviderPick ( providers ) { const providerItems = providers . map ( ( provider ) => { return { label : provider . getDebuggerType ( ) , description : "" , provider } ; } ) ; const pickedProvider = await vscode . window . showQuickPick ( providerItems , { placeHolder : "Select the environment" } ) ; if ( ! pickedProvider ) { return undefined ; } return pickedProvider . provider ; } export async function getDebugProvider ( baseImage ? , runningProcesses ? ) { let debugProvider = null ; if ( baseImage ) { debugProvider = supportedProviders . find ( ( provider ) => provider . isSupportedImage ( baseImage ) ) ; } if ( ! debugProvider ) { let candidateProviders ; if ( runningProcesses ) { candidateProviders = [ ] as IDebugProvider [ ] ; for ( const provider of supportedProviders ) { const filteredProcesses = provider . filterSupportedProcesses ( runningProcesses ) ; if ( ! filteredProcesses || filteredProcesses . length > 0 ) { candidateProviders . push ( provider ) ; } } } else { candidateProviders = supportedProviders ; } if ( candidateProviders . length === 1 ) { debugProvider = candidateProviders [ 0 ] ; } else if ( candidateProviders . length > 1 ) { debugProvider = await showProviderPick ( candidateProviders ) ; } else { throw "No valid debuggers were found for the processes currently running on the container." ; } } return debugProvider ; } export function getSupportedDebuggerTypes ( ) { return supportedProviders . map ( ( provider ) => provider . getDebuggerType ( ) ) ; } export function getDebugProviderOfType ( debuggerType ) { return supportedProviders . find ( ( debugProvider ) => debugProvider . getDebuggerType ( ) === debuggerType ) ; }