/**
 *****************************************
 * Created by edonet@163.com
 * Created on 2020-08-16 10:34:32
 *****************************************
 */ 'use strict' ; /**
 *****************************************
 * 加载依赖
 *****************************************
 */ import * as vscode from 'vscode' ; import variable from './helpers/variable' ; /**
 *****************************************
 * 变量名
 *****************************************
 */ export const variableMap = { file : 1 , fileBasename : 1 , fileBasenameNoExtension : 1 , fileDirname : 1 , fileExtname : 1 , lineNumber : 1 , lineNumbers : 1 , columnNumber : 1 , columnNumbers : 1 , selectedText : 1 , selectedTextList : 1 , selectedTextSection : 1 , selectedPosition : 1 , selectedPositionList : 1 , selectedLocation : 1 , selectedLocationList : 1 , relativeFile : 1 , workspaceFolder : 1 , workspaceFolderBasename : 1 , homedir : 1 , tmpdir : 1 , platform : 1 , } ; /**
 *****************************************
 * 变量类型
 *****************************************
 */ export type VariableScope = keyof typeof variableMap ; /**
 *****************************************
 * 存取器
 *****************************************
 */ export default class Accessor { private $variable = variable ( ) ; env ( scope ) { return this . $variable . env ( ) [ scope . toUpperCase ( ) ] || '' ; } config < T = unknown > ( scope ) { return this . $variable . config ( ) . get ( scope ) ; } package < T = unknown > ( scope ) { return this . $variable . package ( ) [ scope ] as T ; } variable ( scope ) { return variableMap [ scope ] === 1 ? this . $variable [ scope ] ( ) : '' ; } command ( name ) { return this . $variable . commands ( ) [ name ] || name ; } commands ( ) { return this . $variable . commands ( ) ; } input ( value ) { return vscode . window . showInputBox ( { placeHolder : value && `default: "${ value }"` } ) ; } }