• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript vscode.commands类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中vscode.commands的典型用法代码示例。如果您正苦于以下问题:TypeScript commands类的具体用法?TypeScript commands怎么用?TypeScript commands使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了commands类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: showNodeMCUToolbox

/**
 * 
 */
function showNodeMCUToolbox() {
	vscode.commands.executeCommand('vscode.previewHtml', DeviceInfoContentProvider.uri, vscode.ViewColumn.One, 'NodeMCU Toolbox').then((success) => {}, (reason) => {
		vscode.window.showErrorMessage(reason);
	});
}
开发者ID:fduman,项目名称:vscode-nodemcu,代码行数:8,代码来源:extension.ts


示例2: assert

 }).then(editor => {
     assert(vscode.window.activeTextEditor, 'No active editor');
     textEditor = editor;
     return vscode.commands.executeCommand('python.sortImports');
 }).then(() => {
开发者ID:,项目名称:,代码行数:5,代码来源:


示例3: activate

export function activate(context: vscode.ExtensionContext) {


    // Use the console to output diagnostic information (console.log) and errors (console.error)
    // This line of code will only be executed once when your extension is activated


    var openurl = require('open');
    var fs = require('fs');
    var GitHubApi = require("github4");

    var github = new GitHubApi({
        version: "3.0.0"
    });




    var disposable = vscode.commands.registerCommand('extension.updateSettings', async () => {
        var en: envir.Environment = new envir.Environment(context);
        var common: commons.Commons = new commons.Commons(en);
        var myGi: myGit.GithubService = null;

        async function Init() {

            vscode.window.setStatusBarMessage("Checking for Github Token and GIST.", 2000);
            var syncSetting: Setting = await common.InitSettings();
            if (syncSetting.Token == null || syncSetting.Token == "") {
                openurl("https://github.com/settings/tokens");
                await common.GetTokenAndSave(syncSetting).then(function (saved: boolean) {
                    if (saved) {
                        Init();
                        return;
                    }
                    else {
                        vscode.window.showErrorMessage("TOKEN NOT SAVED");
                        return;
                    }
                }, function (err: any) {
                    console.error(err);
                    vscode.window.showErrorMessage(common.ERROR_MESSAGE);
                    return;
                });
            }
            else {
                myGi = new myGit.GithubService(syncSetting.Token);
                vscode.window.setStatusBarMessage("Uploading / Updating Your Settings In Github.", 3000);
                await startGitProcess(syncSetting);
                return;
            }
        }


        async function startGitProcess(sett: Setting) {

            if (sett.Token != null) {
                var allSettingFiles = new Array<File>();
                vscode.window.setStatusBarMessage("Reading Settings and Extensions.", 1000);
                await fileManager.FileManager.FileExists(en.FILE_SETTING).then(async function (fileExists: boolean) {
                    if (fileExists) {
                        await fileManager.FileManager.ReadFile(en.FILE_SETTING).then(function (settings: string) {
                            if (settings) {
                                var fileName = en.FILE_SETTING_NAME;
                                var filePath = en.FILE_SETTING;
                                var fileContent = settings;
                                var file: File = new File(fileName, fileContent, filePath);
                                allSettingFiles.push(file);
                            }
                        });
                    }
                });

                await fileManager.FileManager.FileExists(en.FILE_LAUNCH).then(async function (fileExists: boolean) {
                    if (fileExists) {
                        await fileManager.FileManager.ReadFile(en.FILE_LAUNCH).then(function (launch: string) {
                            if (launch) {
                                var fileName = en.FILE_LAUNCH_NAME;
                                var filePath = en.FILE_LAUNCH;
                                var fileContent = launch;
                                var file: File = new File(fileName, fileContent, filePath);
                                allSettingFiles.push(file);
                            }
                        });
                    }
                });

                var destinationKeyBinding : string = "";
                if (en.OsType == OsType.Mac) {
                    destinationKeyBinding = en.FILE_KEYBINDING_MAC;
                }
                else{
                    destinationKeyBinding = en.FILE_KEYBINDING_DEFAULT;
                }

                await fileManager.FileManager.FileExists(en.FILE_KEYBINDING).then(async function (fileExists: boolean) {
                    if (fileExists) {
                        await fileManager.FileManager.ReadFile(en.FILE_KEYBINDING).then(function (keybinding: string) {
                            if (keybinding) {
                                var fileName = destinationKeyBinding;
                                var filePath = en.FILE_KEYBINDING;
//.........这里部分代码省略.........
开发者ID:massimocode,项目名称:code-settings-sync,代码行数:101,代码来源:extension.ts


示例4: constructor

	constructor(context: vs.ExtensionContext, analyzer: Analyzer) {
		context.subscriptions.push(vs.commands.registerCommand("dart.openAnalyzerDiagnostics", async () => {
			const res = await analyzer.diagnosticGetServerPort();
			openInBrowser(`http://localhost:${res.port}/`);
		}));
	}
开发者ID:DanTup,项目名称:Dart-Code,代码行数:6,代码来源:analyzer.ts


示例5: test

	test('showQuickPick, accept first', async function () {
		const pick = window.showQuickPick(['eins', 'zwei', 'drei']);
		await new Promise(resolve => setTimeout(resolve, 10)); // Allow UI to update.
		await commands.executeCommand('workbench.action.acceptSelectedQuickOpenItem');
		assert.equal(await pick, 'eins');
	});
开发者ID:donaldpipowitch,项目名称:vscode,代码行数:6,代码来源:window.test.ts


示例6: create

export function create(client: ITypescriptServiceClient, isOpen: (path: string) => Promise<boolean>, memento: vscode.Memento) {

	const toDispose: vscode.Disposable[] = [];
	const projectHinted: { [k: string]: boolean } = Object.create(null);

	const projectHintIgnoreList = memento.get<string[]>('projectHintIgnoreList', []);
	for (let path of projectHintIgnoreList) {
		if (path === null) {
			path = undefined;
		}
		projectHinted[path] = true;
	}

	let currentHint: Hint;
	let item = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, Number.MIN_VALUE);
	item.command = 'js.projectStatus.command';
	toDispose.push(vscode.commands.registerCommand('js.projectStatus.command', () => {
		let {message, options} = currentHint;
		return vscode.window.showInformationMessage(message, ...options).then(selection => {
			if (selection) {
				return selection.execute();
			}
		});
	}));

	toDispose.push(vscode.workspace.onDidChangeTextDocument(e => {
		delete projectHinted[e.document.fileName];
	}));

	function onEditor(editor: vscode.TextEditor): void {
		if (!editor
			|| !vscode.languages.match(selector, editor.document)
			|| !client.asAbsolutePath(editor.document.uri)) {

			item.hide();
			return;
		}

		const file = client.asAbsolutePath(editor.document.uri);
		isOpen(file).then(value => {
			if (!value) {
				return;
			}

			return client.execute('projectInfo', { file, needFileNameList: true }).then(res => {

				let {configFileName, fileNames} = res.body;

				if (projectHinted[configFileName] === true) {
					return;
				}

				if (!configFileName && vscode.workspace.rootPath) {
					exists(join(vscode.workspace.rootPath, 'jsconfig.json'), exists => {
						// don't hint if there is a global jsconfig-file. We can get here due
						// to TypeScript bugs or jsconfig configurations
						if (exists) {
							return;
						}
						currentHint = {
							message: localize('hintCreate', "Create a jsconfig.json to enable richer IntelliSense and code navigation across the entire workspace."),
							options: [{
								title: localize('ignore.cmdCreate', 'Ignore'),
								execute: () => {
									client.logTelemetry('js.hintProjectCreation.ignored');
									projectHinted[configFileName] = true;
									projectHintIgnoreList.push(configFileName);
									memento.update('projectHintIgnoreList', projectHintIgnoreList);
									item.hide();
								}
							}, {
								title: localize('cmdCreate', "Create jsconfig.json"),
								execute: () => {
									client.logTelemetry('js.hintProjectCreation.accepted');
									projectHinted[configFileName] = true;
									item.hide();

									return vscode.workspace.openTextDocument(vscode.Uri.parse('untitled:' + encodeURIComponent(join(vscode.workspace.rootPath, 'jsconfig.json'))))
										.then(doc => vscode.window.showTextDocument(doc, vscode.ViewColumn.Three))
										.then(editor => editor.edit(builder => builder.insert(new vscode.Position(0, 0), defaultConfig)));
								}
							}]
						};
						item.text = '$(light-bulb)';
						item.tooltip = localize('hintCreate.tooltip', "Create a jsconfig.json to enable richer IntelliSense and code navigation across the entire workspace.");
						item.color = '#A5DF3B';
						item.show();
						client.logTelemetry('js.hintProjectCreation');
					});

				} else if (fileNames.length > fileLimit) {

					let largeRoots = computeLargeRoots(configFileName, fileNames).map(f => `'/${f}/'`).join(', ');

					currentHint = {
						message: largeRoots.length > 0
							? localize('hintExclude', "For better performance exclude folders with many files, like: {0}", largeRoots)
							: localize('hintExclude.generic', "For better performance exclude folders with many files."),
						options: [{
							title: localize('open', "Configure Excludes"),
//.........这里部分代码省略.........
开发者ID:elemongw,项目名称:vscode,代码行数:101,代码来源:projectStatus.ts


示例7: executeCommandWithCount

 private executeCommandWithCount(count: number, command: string) {
   for (let i = 0; i < count; i++) {
     vscode.commands.executeCommand(command);
   }
 }
开发者ID:iivvoo,项目名称:Vim,代码行数:5,代码来源:tab.ts


示例8: before

	before("run 'flutter clean'", () => vs.commands.executeCommand("_flutter.clean", fsPath(flutterHelloWorldFolder)));
开发者ID:DanTup,项目名称:Dart-Code,代码行数:1,代码来源:flutter_run.test.ts


示例9: activate

export function activate(context: vscode.ExtensionContext): void {
	const outputChannel: vscode.OutputChannel = null;

	// Supported languages
	const supportedDocuments: vscode.DocumentSelector = [
		{ language: 'css', scheme: 'file' },
		{ language: 'postcss', scheme: 'file' },
		{ language: 'scss', scheme: 'file' },
		{ language: 'less', scheme: 'file' }
	];

	// For plugin command: "postcssSorting.execute"
	const command = vscode.commands.registerTextEditorCommand('postcssSorting.execute', (textEditor) => {
		// Prevent run command without active TextEditor
		if (!vscode.window.activeTextEditor) {
			return null;
		}

		const document = textEditor.document;

		const workspaceFolder = vscode.workspace.getWorkspaceFolder(document.uri);
		const workspaceUri = workspaceFolder ? workspaceFolder.uri : null;
		const settings = settingsManager.getSettings(workspaceUri);

		use(settings, document, null)
			.then((result) => {
				if (!result) {
					return;
				}

				textEditor.edit((editBuilder) => {
					editBuilder.replace(result.range, result.css);
				});
			})
			.catch((err) => utils.output(outputChannel, err, settings.showErrorMessages));
	});

	// For commands: "Format Document" and "Format Selection"
	const format = vscode.languages.registerDocumentRangeFormattingEditProvider(supportedDocuments, {
		provideDocumentRangeFormattingEdits(document: vscode.TextDocument, range: vscode.Range): vscode.ProviderResult<vscode.TextEdit[]> {
			// Prevent run command without active TextEditor
			if (!vscode.window.activeTextEditor) {
				return null;
			}

			const workspaceFolder = vscode.workspace.getWorkspaceFolder(document.uri);
			const workspaceUri = workspaceFolder ? workspaceFolder.uri : null;
			const settings = settingsManager.getSettings(workspaceUri);

			return use(settings, document, range)
				.catch((err) => utils.output(outputChannel, err, settings.showErrorMessages))
				.then((result) => {
					if (!result) {
						return;
					}

					return [vscode.TextEdit.replace(result.range, result.css)];
				});
		}
	});

	// Subscriptions
	context.subscriptions.push(command);
	context.subscriptions.push(format);
}
开发者ID:mrmlnc,项目名称:vscode-postcss-sorting,代码行数:65,代码来源:extension.ts


示例10: activate

export function activate(context: vscode.ExtensionContext) {
    ExtensionServer.getInstance().start();
    performVersionsCheck(context);

    let runCommand = (project: ns.NSProject, options: string[]) => {
        if (vscode.workspace.rootPath === undefined) {
            vscode.window.showErrorMessage('No workspace opened.');
            return;
        }

        vscode.window.showQuickPick(options)
        .then(target => {
            if(target == undefined) {
                return; // e.g. if the user presses escape button
            }

            // Move the selected option to be the first element in order to keep the last selected option at the top of the list
            options.splice(options.indexOf(target), 1);
            options.unshift(target);

            // Show output channel
            let runChannel: vscode.OutputChannel = vscode.window.createOutputChannel(`Run on ${project.platform()}`);
            runChannel.clear();
            runChannel.show(vscode.ViewColumn.Two);

            // Execute run command
            let emulator: boolean = (target === 'emulator');
            AnalyticsService.getInstance().runRunCommand(project.platform(), emulator);
            return project.run(emulator)
            .then(tnsProcess => {
                tnsProcess.on('error', err => {
                    vscode.window.showErrorMessage('Unexpected error executing NativeScript Run command.');
                });
                tnsProcess.stderr.on('data', data => {
                    runChannel.append(data);
                });
                tnsProcess.stdout.on('data', data => {
                    runChannel.append(data);
                });
                tnsProcess.on('exit', exitCode => {
                    tnsProcess.stdout.removeAllListeners('data');
                    tnsProcess.stderr.removeAllListeners('data');
                });
                tnsProcess.on('close', exitCode => {
                    runChannel.hide();
                });
            });
        });
    };

    let iosRunOptions = ['device', 'emulator'];
    let runIosCommand = vscode.commands.registerCommand('nativescript.runIos', () => {
        return runCommand(new ns.IosProject(vscode.workspace.rootPath), iosRunOptions);
    });

    let androidRunOptions = ['device', 'emulator'];
    let runAndroidCommand = vscode.commands.registerCommand('nativescript.runAndroid', () => {
        return runCommand(new ns.AndroidProject(vscode.workspace.rootPath), androidRunOptions);
    });

    context.subscriptions.push(runIosCommand);
    context.subscriptions.push(runAndroidCommand);
}
开发者ID:bundyo,项目名称:nativescript-vscode-extension,代码行数:63,代码来源:main.ts



注:本文中的vscode.commands类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap