當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。