src/vs/workbench/api/common/extHostLanguageFeatures.ts/InlineCompletionAdapter/provideInlineCompletions
class InlineCompletionAdapter:	public override async provideInlineCompletions(resource: URI, position: IPosition, context: languages.InlineCompletionContext, token: CancellationToken): Promise<extHostProtocol.IdentifiableInlineCompletions | undefined> {
		const doc = this._documents.getDocument(resource);
		const pos = typeConvert.Position.to(position);

		const result = await this._provider.provideInlineCompletionItems(doc, pos, {
			selectedCompletionInfo:
				context.selectedSuggestionInfo
					? {
						range: typeConvert.Range.to(context.selectedSuggestionInfo.range),
						text: context.selectedSuggestionInfo.text,
						isSnippetText: context.selectedSuggestionInfo.isSnippetText,
						completionKind: typeConvert.CompletionItemKind.to(context.selectedSuggestionInfo.completionKind),
					}
					: undefined,
			triggerKind: context.triggerKind
		}, token);

		if (!result) {
			// undefined and null are valid results
			return undefined;
		}

		if (token.isCancellationRequested) {
			// cancelled -> return without further ado, esp no caching
			// of results as they will leak
			return undefined;
		}

		const normalizedResult = isArray(result) ? result : result.items;

		const pid = this._cache.add(normalizedResult);
		let disposableStore: DisposableStore | undefined = undefined;

		return {
			pid,
			items: normalizedResult.map<extHostProtocol.IdentifiableInlineCompletion>((item, idx) => {
				let command: languages.Command | undefined = undefined;
				if (item.command) {
					if (!disposableStore) {
						disposableStore = new DisposableStore();
						this._disposables.set(pid, disposableStore);
					}
					command = this._commands.toInternal(item.command, disposableStore);
				}

				const insertText = item.insertText ?? item.text;
				if (insertText === undefined) {
					throw new Error('text or insertText must be defined');
				}
				return ({
					insertText: typeof insertText === 'string' ? insertText : { snippet: insertText.value },
					range: item.range ? typeConvert.Range.from(item.range) : undefined,
					command,
					idx: idx,
					completeBracketPairs: item.completeBracketPairs
				});
			}),
		};
	}