src/vs/workbench/services/textMate/browser/abstractTextMateService.ts/AbstractTextMateService/_createFactory
class AbstractTextMateService:	private _createFactory(languageId: string): ITokenizationSupportFactory {
		return {
			createTokenizationSupport: async (): Promise<ITokenizationSupport | null> => {
				if (!this._languageService.isRegisteredLanguageId(languageId)) {
					return null;
				}
				if (!this._canCreateGrammarFactory()) {
					return null;
				}
				const encodedLanguageId = this._languageService.languageIdCodec.encodeLanguageId(languageId);

				try {
					const grammarFactory = await this._getOrCreateGrammarFactory();
					if (!grammarFactory.has(languageId)) {
						return null;
					}
					const r = await grammarFactory.createGrammar(languageId, encodedLanguageId);
					if (!r.grammar) {
						return null;
					}
					const tokenization = new TMTokenization(r.grammar, r.initialState, r.containsEmbeddedLanguages);
					tokenization.onDidEncounterLanguage((encodedLanguageId) => {
						if (!this._encounteredLanguages[encodedLanguageId]) {
							const languageId = this._languageService.languageIdCodec.decodeLanguageId(encodedLanguageId);
							this._encounteredLanguages[encodedLanguageId] = true;
							this._onDidEncounterLanguage.fire(languageId);
						}
					});
					return new TMTokenizationSupportWithLineLimit(languageId, encodedLanguageId, tokenization, this._configurationService);
				} catch (err) {
					if (err.message && err.message === missingTMGrammarErrorMessage) {
						// Don't log this error message
						return null;
					}
					onUnexpectedError(err);
					return null;
				}
			}
		};
	}