import * as vscode from 'vscode' ; import { Reporter } from '../util/Reporter' ; import { FabricDebugConfigurationProvider } from './FabricDebugConfigurationProvider' ; import { UserInputUtil } from '../commands/UserInputUtil' ; export class FabricJavaDebugConfigurationProvider extends FabricDebugConfigurationProvider { public async provideDebugConfigurations ( ) { return [ { type : 'fabric:java' , request : 'launch' , name : 'Debug Smart Contract' , mainClass : 'org.hyperledger.fabric.contract.ContractRouter' } ] ; } protected async getChaincodeNameAndVersion ( ) { const name = await UserInputUtil . showInputBox ( 'Enter a name for your Java package' ) ; if ( ! name ) { return ; } const version = await UserInputUtil . showInputBox ( 'Enter a version for your Java package' ) ; return { name , version } ; } protected async resolveDebugConfigurationInner ( folder , config ) { config . type = 'java' ; if ( ! config . request ) { config . request = 'launch' ; } if ( ! config . cwd ) { config . cwd = folder . uri . fsPath ; } if ( ! config . args ) { config . args = [ ] ; } if ( ! config . args . includes ( '--peer.address' ) ) { const peerAddress = await this . getChaincodeAddress ( ) ; if ( ! peerAddress ) { return ; } config . args . push ( '--peer.address' , peerAddress ) ; } Reporter . instance ( ) . sendTelemetryEvent ( 'Smart Contract Debugged' , { language : 'Java' } ) ; return config ; } }