本文整理匯總了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');
});