extensions/typescript-language-features/src/typeScriptServiceClientHost.ts/TypeScriptServiceClientHost/findLanguage
class TypeScriptServiceClientHost:	private async findLanguage(resource: vscode.Uri): Promise<LanguageProvider | undefined> {
		try {
			// First try finding language just based on the resource.
			// This is not strictly correct but should be in the vast majority of cases
			// (except when someone goes and maps `.js` to `typescript` or something...)
			for (const language of this.languages) {
				if (language.handlesUri(resource)) {
					return language;
				}
			}

			// If that doesn't work, fallback to using a text document language mode.
			// This is not ideal since we have to open the document but should always
			// be correct
			const doc = await vscode.workspace.openTextDocument(resource);
			return this.languages.find(language => language.handlesDocument(doc));
		} catch {
			return undefined;
		}
	}