src/vs/workbench/api/common/extHostLanguageFeatures.ts/ExtHostLanguageFeatures/_withAdapter
class ExtHostLanguageFeatures:	private _withAdapter<A, R>(handle: number, ctor: { new(...args: any[]): A; }, callback: (adapter: A, extension: IExtensionDescription | undefined) => Promise<R>, fallbackValue: R, allowCancellationError: boolean = false): Promise<R> {
		const data = this._adapter.get(handle);
		if (!data) {
			return Promise.resolve(fallbackValue);
		}

		if (data.adapter instanceof ctor) {
			let t1: number;
			if (data.extension) {
				t1 = Date.now();
				this._logService.trace(`[${data.extension.identifier.value}] INVOKE provider '${(ctor as any).name}'`);
			}
			const p = callback(data.adapter, data.extension);
			const extension = data.extension;
			if (extension) {
				Promise.resolve(p).then(
					() => this._logService.trace(`[${extension.identifier.value}] provider DONE after ${Date.now() - t1}ms`),
					err => {
						const isExpectedError = allowCancellationError && (err instanceof CancellationError);
						if (!isExpectedError) {
							this._logService.error(`[${extension.identifier.value}] provider FAILED`);
							this._logService.error(err);
						}
					}
				);
			}
			return p;
		}
		return Promise.reject(new Error('no adapter found'));
	}