import * as vscode from 'vscode' ; import { commands , ExtensionContext } from 'vscode' ; import { Command } from './common/constant' ; import ServiceManager from './manager/serviceManager' ; import { FileNode } from './node/fileNode' ; import { ParentNode } from './node/parentNode' ; import { Console } from './common/outputChannel' ; import { Util } from './common/util' ; import AbstractNode from './node/abstracNode' ; export function activate ( context ) { const serviceManager = new ServiceManager ( context ) ; context . subscriptions . push ( ... serviceManager . init ( ) , ... initCommand ( { 'ssh.add' : ( ) => serviceManager . provider . save ( ) , 'ssh.edit' : ( parentNode ) => serviceManager . provider . save ( parentNode ) , 'ssh.connection.terminal' : ( parentNode ) => parentNode . openTerminal ( ) , 'ssh.connection.delete' : ( parentNode ) => serviceManager . provider . delete ( parentNode ) , 'ssh.folder.new' : ( parentNode ) => parentNode . newFolder ( ) , 'ssh.file.new' : ( parentNode ) => parentNode . newFile ( ) , 'ssh.host.copy' : ( parentNode ) => parentNode . copyIP ( ) , 'ssh.forward.port' : ( parentNode ) => parentNode . fowardPort ( ) , 'ssh.file.upload' : ( parentNode ) => parentNode . upload ( ) , 'ssh.folder.open' : ( parentNode ) => parentNode . openInTeriminal ( ) , 'ssh.path.copy' : ( node ) => node . copyPath ( ) , 'ssh.socks.port' : ( parentNode ) => parentNode . startSocksProxy ( ) , 'ssh.file.delete' : ( fileNode ) => fileNode . delete ( ) , 'ssh.file.open' : ( fileNode ) => fileNode . open ( ) , 'ssh.file.download' : ( fileNode ) => fileNode . download ( ) , [ Command . REFRESH ] : ( ) => serviceManager . provider . refresh ( ) , } ) ) ; } function commandWrapper ( commandDefinition , command ) { return ( ... args ) => { try { commandDefinition [ command ] ( ... args ) ; } catch ( err ) { Console . log ( err ) ; } } ; } function initCommand ( commandDefinition ) { const dispose = [ ] ; for ( const command in commandDefinition ) { if ( commandDefinition . hasOwnProperty ( command ) ) { dispose . push ( vscode . commands . registerCommand ( command , commandWrapper ( commandDefinition , command ) ) ) ; } } return dispose ; }