本文整理汇总了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);
}
示例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()
})
});
示例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"])
});
});
示例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);
});
示例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();
});
});
示例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)));
}
}
});
}
示例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);
}
});
示例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
);
}
});
示例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);
}
示例10: initialize
public async initialize(): Promise<void> {
this.map = new Map(
(await vscode.commands.getCommands(true)).map(x => [x, true] as [string, boolean])
);
}