当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript CodeSnippet.convertExternalSnippet方法代码示例

本文整理汇总了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));
	});
开发者ID:13572293130,项目名称:vscode,代码行数:32,代码来源:snippet.test.ts

示例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');
	});
开发者ID:1Hgm,项目名称:vscode,代码行数:16,代码来源:snippet.test.ts


注:本文中的vs/editor/contrib/snippet/common/snippet.CodeSnippet.convertExternalSnippet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。