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