本文整理汇总了TypeScript中vs/editor/contrib/snippet/common/snippet.CodeSnippet.fromInternal方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CodeSnippet.fromInternal方法的具体用法?TypeScript CodeSnippet.fromInternal怎么用?TypeScript CodeSnippet.fromInternal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/contrib/snippet/common/snippet.CodeSnippet
的用法示例。
在下文中一共展示了CodeSnippet.fromInternal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: snippetTest
snippetTest((editor, cursor, codeSnippet, snippetController) => {
editor.setSelections([
new Selection(2, 7, 2, 7),
]);
codeSnippet = CodeSnippet.fromInternal('xo{{}}r');
snippetController.run(codeSnippet, 1, 0, false);
assert.equal(editor.getSelections().length, 1);
assert.ok(editor.getSelection().equalsRange({ startLineNumber: 2, startColumn: 8, endColumn: 8, endLineNumber: 2 }));
});
示例2: withMockCodeEditor
withMockCodeEditor(lines, {}, (editor, cursor) => {
editor.getModel().updateOptions({
insertSpaces: false
});
let snippetController = editor.registerAndInstantiateContribution<TestSnippetController>(TestSnippetController);
let codeSnippet = CodeSnippet.fromInternal([
'for (var {{index}}; {{index}} < {{array}}.length; {{index}}++) {',
'\tvar element = {{array}}[{{index}}];',
'\t{{}}',
'}'
].join('\n'));
cb(editor, cursor, codeSnippet, snippetController);
snippetController.dispose();
});
示例3: assertInternalAndTextmate
function assertInternalAndTextmate(internal: string, textmate: string, callback: (snippet: CodeSnippet) => any) {
callback(CodeSnippet.fromInternal(internal));
callback(CodeSnippet.fromTextmate(textmate));
}