import * as vscode from 'vscode' ; import { AzExtTreeDataProvider , AzExtTreeItem } from 'vscode-azureextensionui' ; import { ext } from '../extensionVariables' ; import { localize } from '../localize' ; import { getWorkspaceSetting } from '../utils/settings' ; import { AppSource , IDeployContext } from './IDeployContext' ; param arg1 param arg2 export async function getDeployNode < T extends AzExtTreeItem > ( context , tree , arg1 , arg2 , expectedContextValue ) { let node ; if ( arg1 instanceof AzExtTreeItem ) { node = arg1 ; context . appSource = AppSource . tree ; } else if ( typeof arg2 === 'string' && arg2 ) { node = await tree . findTreeItem ( arg2 , context ) ; if ( ! node ) { throw new Error ( localize ( 'noMatchingApp' , 'Failed to find app matching id "{0}".' , arg2 ) ) ; } context . appSource = AppSource . api ; } else { const defaultAppId = getWorkspaceSetting ( context . defaultAppSetting , ext . prefix , context . workspaceFolder . uri . fsPath ) ; if ( defaultAppId && defaultAppId . toLowerCase ( ) !== 'none' ) { node = await tree . findTreeItem ( defaultAppId , context ) ; if ( node ) { context . appSource = AppSource . setting ; } else { ext . outputChannel . appendLog ( localize ( 'appFromSettingNotFound' , 'WARNING: Failed to find app matching setting "{0}.{1}" with id "{2}"' , ext . prefix , context . defaultAppSetting , defaultAppId ) ) ; } } if ( ! node ) { const newNodes = [ ] ; const disposable = tree . onTreeItemCreate ( newNode => { newNodes . push ( newNode ) ; } ) ; try { node = await tree . showTreeItemPicker < AzExtTreeItem > ( expectedContextValue , context ) ; } finally { disposable . dispose ( ) ; } context . isNewApp = newNodes . some ( newNode => node && newNode . fullId === node . fullId ) ; context . appSource = AppSource . nodePicker ; } } context . telemetry . properties . appSource = context . appSource ; context . telemetry . properties . isNewApp = String ( ! ! context . isNewApp ) ; return < T > node ; }