本文整理汇总了TypeScript中vs/editor/contrib/snippet/common/snippet.CodeSnippet.convertExternalSnippet方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CodeSnippet.convertExternalSnippet方法的具体用法?TypeScript CodeSnippet.convertExternalSnippet怎么用?TypeScript CodeSnippet.convertExternalSnippet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/contrib/snippet/common/snippet.CodeSnippet
的用法示例。
在下文中一共展示了CodeSnippet.convertExternalSnippet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('bug #17487:[snippets] four backslashes are required to get one backslash in the inserted text', () => {
var external = [
'\\begin{${1:enumerate}}',
'\t$0',
'\\end{$1}'
].join('\n');
var internal = CodeSnippet.convertExternalSnippet(external, ExternalSnippetType.TextMateSnippet);
assert.equal(internal, [
'\\begin\\{{{1:enumerate}}\\}',
'\t{{}}',
'\\end\\{{{1:}}\\}'
].join('\n'));
var snippet = new CodeSnippet(internal);
assert.deepEqual(snippet.lines, [
'\\begin{enumerate}',
'\t',
'\\end{enumerate}'
]);
assert.equal(snippet.placeHolders.length, 2);
assert.equal(snippet.placeHolders[0].id, '1');
assert.equal(snippet.placeHolders[0].occurences.length, 2);
assert.deepEqual(snippet.placeHolders[0].occurences[0], new Range(1, 8, 1, 17));
assert.deepEqual(snippet.placeHolders[0].occurences[1], new Range(3, 6, 3, 15));
assert.equal(snippet.placeHolders[1].id, '');
assert.equal(snippet.placeHolders[1].occurences.length, 1);
assert.deepEqual(snippet.placeHolders[1].occurences[0], new Range(2, 2, 2, 2));
});
示例2: test
test('Support tab stop order wich does not affect named variable id\'s', () => {
let external = '${first}-${2}-${second}-${1}';
let internal = CodeSnippet.convertExternalSnippet(external, ExternalSnippetType.TextMateSnippet);
assert.equal(internal, '{{first}}-{{2:}}-{{second}}-{{1:}}');
let snippet = new CodeSnippet(internal);
assert.deepEqual(snippet.lines, ['first--second-']);
assert.equal(snippet.placeHolders.length, 4);
assert.equal(snippet.placeHolders[0].id, 'first');
assert.equal(snippet.placeHolders[1].id, 'second');
assert.equal(snippet.placeHolders[2].id, '1');
assert.equal(snippet.placeHolders[3].id, '2');
});