src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.ts/NotebookModelResolverServiceImpl/resolve
class NotebookModelResolverServiceImpl:	async resolve(arg0: URI | IUntitledNotebookResource, viewType?: string): Promise<IReference<IResolvedNotebookEditorModel>> {
		let resource: URI;
		let hasAssociatedFilePath = false;
		if (URI.isUri(arg0)) {
			resource = arg0;
		} else {
			if (!arg0.untitledResource) {
				const info = this._notebookService.getContributedNotebookType(assertIsDefined(viewType));
				if (!info) {
					throw new Error('UNKNOWN view type: ' + viewType);
				}

				const suffix = NotebookProviderInfo.possibleFileEnding(info.selectors) ?? '';
				for (let counter = 1; ; counter++) {
					const candidate = URI.from({ scheme: Schemas.untitled, path: `Untitled-${counter}${suffix}`, query: viewType });
					if (!this._notebookService.getNotebookTextModel(candidate)) {
						resource = candidate;
						break;
					}
				}
			} else if (arg0.untitledResource.scheme === Schemas.untitled) {
				resource = arg0.untitledResource;
			} else {
				resource = arg0.untitledResource.with({ scheme: Schemas.untitled });
				hasAssociatedFilePath = true;
			}
		}

		if (resource.scheme === CellUri.scheme) {
			throw new Error(`CANNOT open a cell-uri as notebook. Tried with ${resource.toString()}`);
		}

		resource = this._uriIdentService.asCanonicalUri(resource);

		const existingViewType = this._notebookService.getNotebookTextModel(resource)?.viewType;
		if (!viewType) {
			if (existingViewType) {
				viewType = existingViewType;
			} else {
				await this._extensionService.whenInstalledExtensionsRegistered();
				const providers = this._notebookService.getContributedNotebookTypes(resource);
				const exclusiveProvider = providers.find(provider => provider.exclusive);
				viewType = exclusiveProvider?.id || providers[0]?.id;
			}
		}

		if (!viewType) {
			throw new Error(`Missing viewType for '${resource}'`);
		}

		if (existingViewType && existingViewType !== viewType) {

			await this._onWillFailWithConflict.fireAsync({ resource, viewType }, CancellationToken.None);

			// check again, listener should have done cleanup
			const existingViewType2 = this._notebookService.getNotebookTextModel(resource)?.viewType;
			if (existingViewType2 && existingViewType2 !== viewType) {
				throw new Error(`A notebook with view type '${existingViewType2}' already exists for '${resource}', CANNOT create another notebook with view type ${viewType}`);
			}
		}

		const reference = this._data.acquire(resource.toString(), viewType, hasAssociatedFilePath);
		try {
			const model = await reference.object;
			return {
				object: model,
				dispose() { reference.dispose(); }
			};
		} catch (err) {
			reference.dispose();
			throw err;
		}
	}