當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript commands.getCommands方法代碼示例

本文整理匯總了TypeScript中vscode.commands.getCommands方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript commands.getCommands方法的具體用法?TypeScript commands.getCommands怎麽用?TypeScript commands.getCommands使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vscode.commands的用法示例。


在下文中一共展示了commands.getCommands方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: activate

export function activate(context) {

	const commands = vscode.commands.getCommands(true);

	//keybindings.json command-suggestions
	const disposable = vscode.languages.registerCompletionItemProvider({ pattern: '**/keybindings.json' }, {

		provideCompletionItems(document, position, token) {
			const location = getLocation(document.getText(), document.offsetAt(position));
			if (location.path[1] === 'command') {

				const range = document.getWordRangeAtPosition(position) || new vscode.Range(position, position);

				return commands.then(ids => ids.map(id => {
					const item = new vscode.CompletionItem(`"${id}"`);
					item.kind = vscode.CompletionItemKind.Value;
					item.textEdit = {
						range,
						newText: item.label
					};
					return item;
				}));
			}
		}
	});

	context.subscriptions.push(disposable);
}
開發者ID:bobmagicii,項目名稱:vscode,代碼行數:28,代碼來源:extension.ts

示例2: test

 test("\'Generate Build Task command\' is registered", (done) => {
     let cmds = vscode.commands.getCommands(true)
     cmds.then(ids => {
             let containsCmd = ids.indexOf(addBuildScriptCmd)
             assert.notEqual(containsCmd, -1)
             done()
         })
 });
開發者ID:OverlyExcessive,項目名稱:conformity,代碼行數:8,代碼來源:extension.test.ts

示例3: test

 test('Verify that the commands registered by Cordova extension are loaded', () => {
     return vscode.commands.getCommands(true)
     .then((results) => {
         let cordovaCmdsAvailable = results.filter((commandName: string) => {
             return commandName.indexOf("cordova.") > -1
         });
         assert.deepEqual(cordovaCmdsAvailable, ["cordova.build", "cordova.run", "cordova.prepare"])
     });
 });
開發者ID:Paradox-Cascade,項目名稱:vscode-cordova,代碼行數:9,代碼來源:cordova.test.ts

示例4: it

	it("command is available when cursor is inside a test", async () => {
		const editor = await openFile(helloWorldTestMainFile);
		editor.selection = new vs.Selection(positionOf("expect^("), positionOf("^expect("));

		// Allow some time to check, because the flag is flipped in a selection change handler
		await waitForResult(() => cursorIsInTest);

		// Also ensure the command exists.
		const command = (await vs.commands.getCommands(true)).filter((id) => id === "dart.runTestAtCursor");
		assert.ok(command);
	});
開發者ID:DanTup,項目名稱:Dart-Code,代碼行數:11,代碼來源:run_test_at_cursor.test.ts

示例5: test

	test('should register all spell commands', function(done){
		return vscode.commands.getCommands(true).then((commands) => 
		{
			let spellCmds = commands.filter(function (value) {
				return Global.changeLanguageCmdId === value ||
						Global.spellCurrentTextDocumentCmdId === value;
			});
			assert.ok(spellCmds.length === 2, 'missing spell commands');
			done();
		});
	});
開發者ID:silverbulleters,項目名稱:vsc-spellchecker,代碼行數:11,代碼來源:extension.test.ts

示例6: registerKeybindingsCompletions

function registerKeybindingsCompletions(): vscode.Disposable {
	const commands = vscode.commands.getCommands(true);

	return vscode.languages.registerCompletionItemProvider({ pattern: '**/keybindings.json' }, {

		provideCompletionItems(document, position, token) {
			const location = getLocation(document.getText(), document.offsetAt(position));
			if (location.path[1] === 'command') {

				const range = document.getWordRangeAtPosition(position) || new vscode.Range(position, position);
				return commands.then(ids => ids.map(id => newCompletionItem(id, range)));
			}
		}
	});
}
開發者ID:elemongw,項目名稱:vscode,代碼行數:15,代碼來源:extension.ts

示例7: test

    test("all keys have handlers", async () => {
        let pkg = require(__dirname + '/../../package.json');
        assert.ok(pkg);

        let registeredCommands = await vscode.commands.getCommands();
        let keybindings = pkg.contributes.keybindings;
        assert.ok(pkg);

        for (let i = 0; i < keybindings.length; i++) {
            let keybinding = keybindings[i];

            var found = registeredCommands.indexOf(keybinding.command) >= -1;
            assert.ok(found, "Missing handler for key=" + keybinding.key + ". Expected handler=" + keybinding.command);
        }
    });
開發者ID:CoderNumber1,項目名稱:Vim,代碼行數:15,代碼來源:extension.test.ts

示例8: test

  test('all keys have handlers', async () => {
    let registeredCommands = await vscode.commands.getCommands();
    let keybindings = pkg.contributes.keybindings;
    assert.ok(keybindings);

    for (let i = 0; i < keybindings.length; i++) {
      let keybinding = keybindings[i];

      var found = registeredCommands.indexOf(keybinding.command) >= -1;
      assert.ok(
        found,
        'Missing handler for key=' + keybinding.key + '. Expected handler=' + keybinding.command
      );
    }
  });
開發者ID:arussellk,項目名稱:Vim,代碼行數:15,代碼來源:extension.test.ts

示例9: activate

export function activate(context) {

	const commands = vscode.commands.getCommands(true);

	//keybindings.json command-suggestions
	const disposable = vscode.languages.registerCompletionItemProvider({ pattern: '**/keybindings.json' }, {

		provideCompletionItems(document, position, token) {
			const location = getLocation(document.getText(), document.offsetAt(position));
			if (location.path[1] === 'command') {
				return commands.then(ids => ids.map(id => new vscode.CompletionItem(id, vscode.CompletionItemKind.Value)));
			}
		}
	});

	context.subscriptions.push(disposable);
}
開發者ID:1Hgm,項目名稱:vscode,代碼行數:17,代碼來源:extension.ts

示例10: initialize

 public async initialize(): Promise<void> {
   this.map = new Map(
     (await vscode.commands.getCommands(true)).map(x => [x, true] as [string, boolean])
   );
 }
開發者ID:octref,項目名稱:Vim,代碼行數:5,代碼來源:configurationValidator.ts


注:本文中的vscode.commands.getCommands方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。