本文整理匯總了TypeScript中vs/editor/common/modes.CompletionProviderRegistry類的典型用法代碼示例。如果您正苦於以下問題:TypeScript CompletionProviderRegistry類的具體用法?TypeScript CompletionProviderRegistry怎麽用?TypeScript CompletionProviderRegistry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了CompletionProviderRegistry類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('only from', function () {
const foo: any = {
triggerCharacters: [],
provideCompletionItems() {
return {
currentWord: '',
incomplete: false,
suggestions: [{
label: 'jjj',
type: 'property',
insertText: 'jjj'
}]
};
}
};
const registration = CompletionProviderRegistry.register({ pattern: 'bar/path', scheme: 'foo' }, foo);
provideSuggestionItems(model, new Position(1, 1), undefined, [foo]).then(items => {
registration.dispose();
assert.equal(items.length, 1);
assert.ok(items[0].provider === foo);
});
});
示例2: setup
setup(function () {
model = TextModel.createFromString('FOO\nbar\BAR\nfoo', undefined, undefined, URI.parse('foo:bar/path'));
registration = CompletionProviderRegistry.register({ pattern: 'bar/path', scheme: 'foo' }, {
provideCompletionItems(_doc, pos) {
return {
incomplete: false,
suggestions: [{
label: 'aaa',
kind: CompletionItemKind.Snippet,
insertText: 'aaa',
range: Range.fromPositions(pos)
}, {
label: 'zzz',
kind: CompletionItemKind.Snippet,
insertText: 'zzz',
range: Range.fromPositions(pos)
}, {
label: 'fff',
kind: CompletionItemKind.Property,
insertText: 'fff',
range: Range.fromPositions(pos)
}]
};
}
});
});
示例3: registerCompletionItemProvider
export function registerCompletionItemProvider(languageId: string, provider: modes.CompletionItemProvider): IDisposable {
return modes.CompletionProviderRegistry.register(languageId, provider);
}