import { ALSymbolsBasedWizard } from "./alSymbolsBasedWizard" ; import { AZSymbolInformation } from "../../symbollibraries/azSymbolInformation" ; import { FileBuilder } from "../fileBuilder" ; import { AZSymbolKind } from "../../symbollibraries/azSymbolKind" ; import { ALInterfaceSyntaxBuilder } from "../syntaxbuilders/alInterfaceSyntaxBuilder" ; import { ALInterfaceWizardData } from "../wizards/alInterfaceWizardData" ; import { DevToolsExtensionContext } from "../../devToolsExtensionContext" ; export class ALSymbolsBasedInterfaceWizard extends ALSymbolsBasedWizard { constructor ( context ) { super ( context ) ; } async showWizard ( sourceSymbols ) { if ( sourceSymbols . length == 1 ) await this . showInterfaceWizard ( sourceSymbols [ 0 ] ) ; else await this . showMultiInterfaceWizard ( sourceSymbols ) ; } async showMultiInterfaceWizard ( sourceSymbols ) { if ( ! FileBuilder . checkCrsExtensionFileNamePatternRequired ( ) ) return ; const objType = AZSymbolKind . Interface ; let relativeFileDir = await this . getRelativeFileDir ( objType ) ; for ( let i = 0 ; i < sourceSymbols . length ; i ++ ) { let sourceSymbol = sourceSymbols [ i ] ; let objectName = this . getDefaultInterfaceName ( sourceSymbol ) ; await this . createAndShowNewInterface ( sourceSymbol , objectName , relativeFileDir ) ; } } async showInterfaceWizard ( sourceSymbol ) { if ( ! FileBuilder . checkCrsFileNamePatternRequired ( ) ) return ; const objType = AZSymbolKind . Interface ; let objectName = await this . getObjectName ( "Please enter a name for the new object." , this . getDefaultInterfaceName ( sourceSymbol ) ) ; if ( ! objectName ) return ; let relativeFileDir = await this . getRelativeFileDir ( objType ) ; await this . createAndShowNewInterface ( sourceSymbol , objectName , relativeFileDir ) ; } private async createAndShowNewInterface ( sourceSymbol , objectName , relativeFileDir ) { let fileName = await FileBuilder . getPatternGeneratedFullObjectFileName ( AZSymbolKind . Interface , 0 , objectName ) ; let sourceCode = await this . buildInterfaceAsync ( sourceSymbol , objectName ) ; this . showNewDocument ( sourceCode , fileName , relativeFileDir ) ; } async buildInterfaceAsync ( sourceSymbol , objectName ) { let syntaxBuilder = new ALInterfaceSyntaxBuilder ( this . _toolsExtensionContext ) ; let settings = new ALInterfaceWizardData ( ) ; settings . objectName = objectName ; settings . baseCodeunitName = sourceSymbol . name ; return await syntaxBuilder . buildFromInterfaceWizardDataAsync ( undefined , settings ) ; } private getDefaultInterfaceName ( sourceSymbol ) { return 'I' + sourceSymbol . name . trim ( ) ; } }