當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript vscode-emmet-helper.getEmmetCompletionParticipants函數代碼示例

本文整理匯總了TypeScript中vscode-emmet-helper.getEmmetCompletionParticipants函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getEmmetCompletionParticipants函數的具體用法?TypeScript getEmmetCompletionParticipants怎麽用?TypeScript getEmmetCompletionParticipants使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了getEmmetCompletionParticipants函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: assertCompletions

	function assertCompletions(syntax: string, value: string, expectedProposal: string | null, expectedProposalDoc: string | null): void {
		const offset = value.indexOf('|');
		value = value.substr(0, offset) + value.substr(offset + 1);

		const workspace = {
			settings: {},
			folders: [{ name: 'test', uri: 'test://test' }]
		};

		const document = TextDocument.create('test://test/test.' + syntax, syntax, 0, value);
		const position = document.positionAt(offset);
		const documentRegions = getLanguageModelCache<embeddedSupport.HTMLDocumentRegions>(10, 60, document => embeddedSupport.getDocumentRegions(htmlLanguageService, document));
		const mode = syntax === 'html' ? getHTMLMode(htmlLanguageService, workspace) : getCSSMode(documentRegions, workspace);

		const emmetCompletionList = CompletionList.create([], false);
		const emmetParticipant = getEmmetCompletionParticipants(document, position, document.languageId, {}, emmetCompletionList);

		const list = mode.doComplete!(document, position, {}, [emmetParticipant]);
		assert.ok(list);
		assert.ok(emmetCompletionList);

		let actualLabels = emmetCompletionList.items.map(c => c.label).sort();
		let actualDocs = emmetCompletionList.items.map(c => c.documentation).sort();
		if (expectedProposal && expectedProposalDoc) {
			assert.ok(actualLabels.indexOf(expectedProposal) !== -1, value + ': Not found:' + expectedProposal + ' is ' + actualLabels.join(', '));
			assert.ok(actualDocs.indexOf(expectedProposalDoc) !== -1, value + ': Not found:' + expectedProposalDoc + ' is ' + actualDocs.join(', '));
		} else {
			assert.ok(!emmetCompletionList.items.length && !emmetCompletionList.isIncomplete, value + ': No proposals expected, but was ' + actualLabels.join(', '));
		}

	}
開發者ID:costincaraivan,項目名稱:vscode,代碼行數:31,代碼來源:emmet.test.ts

示例2: assertCompletions

	function assertCompletions(syntax: string, value: string, expectedProposal: string, expectedProposalDoc: string): void {
		const offset = value.indexOf('|');
		value = value.substr(0, offset) + value.substr(offset + 1);

		const document = TextDocument.create('test://test/test.' + syntax, syntax, 0, value);
		const position = document.positionAt(offset);
		const emmetCompletionList: CompletionList = {
			isIncomplete: true,
			items: undefined
		}
		const languageService = syntax === 'scss' ? scssLanguageService : cssLanguageService;
		languageService.setCompletionParticipants([getEmmetCompletionParticipants(document, position, document.languageId, {}, emmetCompletionList)])
		const stylesheet = languageService.parseStylesheet(document);
		const list = languageService.doComplete!(document, position, stylesheet);

		assert.ok(list);
		assert.ok(emmetCompletionList)

		if (expectedProposal && expectedProposalDoc) {
			let actualLabels = (emmetCompletionList!.items || []).map(c => c.label).sort();
			let actualDocs = (emmetCompletionList!.items || []).map(c => c.documentation).sort();
			assert.ok(actualLabels.indexOf(expectedProposal) !== -1, 'Not found:' + expectedProposal + ' is ' + actualLabels.join(', '));
			assert.ok(actualDocs.indexOf(expectedProposalDoc) !== -1, 'Not found:' + expectedProposalDoc + ' is ' + actualDocs.join(', '));
		} else {
			assert.ok(!emmetCompletionList || !emmetCompletionList.items);
		}
	}
開發者ID:sameer-coder,項目名稱:vscode,代碼行數:27,代碼來源:emmet.test.ts

示例3: assertCompletions

	function assertCompletions(syntax: string, value: string, expectedProposal: string, expectedProposalDoc: string): void {
		const offset = value.indexOf('|');
		value = value.substr(0, offset) + value.substr(offset + 1);

		const document = TextDocument.create('test://test/test.' + syntax, syntax, 0, value);
		const position = document.positionAt(offset);
		const documentRegions = getLanguageModelCache<embeddedSupport.HTMLDocumentRegions>(10, 60, document => embeddedSupport.getDocumentRegions(htmlLanguageService, document));
		const mode = syntax == 'html' ? getHTMLMode(htmlLanguageService) : getCSSMode(documentRegions);
		const emmetCompletionList: CompletionList = {
			isIncomplete: true,
			items: undefined
		}
		mode.setCompletionParticipants([getEmmetCompletionParticipants(document, position, document.languageId, {}, emmetCompletionList)])

		const list = mode.doComplete!(document, position);
		assert.ok(list);
		assert.ok(emmetCompletionList)


		if (expectedProposal && expectedProposalDoc) {
			let actualLabels = emmetCompletionList!.items.map(c => c.label).sort();
			let actualDocs = emmetCompletionList!.items.map(c => c.documentation).sort();
			assert.ok(actualLabels.indexOf(expectedProposal) !== -1, 'Not found:' + expectedProposal + ' is ' + actualLabels.join(', '));
			assert.ok(actualDocs.indexOf(expectedProposalDoc) !== -1, 'Not found:' + expectedProposalDoc + ' is ' + actualDocs.join(', '));
		} else {
			assert.ok(!emmetCompletionList || !emmetCompletionList.items);
		}

	}
開發者ID:sameer-coder,項目名稱:vscode,代碼行數:29,代碼來源:emmet.test.ts


注:本文中的vscode-emmet-helper.getEmmetCompletionParticipants函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。