addons/shared/textmate-lib/GrammarStore.tsblame
View source
b69ab311/**
b69ab312 * Copyright (c) Meta Platforms, Inc. and affiliates.
b69ab313 *
b69ab314 * This source code is licensed under the MIT license found in the
b69ab315 * LICENSE file in the root directory of this source tree.
b69ab316 */
b69ab317
b69ab318import type {IGrammar, Registry} from 'vscode-textmate';
b69ab319
b69ab3110export default class GrammarStore {
b69ab3111 /**
b69ab3112 * See `createTextMateRegistry()` in this directory to create a Registry.
b69ab3113 */
b69ab3114 constructor(private registry: Registry) {}
b69ab3115
b69ab3116 /**
b69ab3117 * Load the grammar for `initialScopeName` and all referenced included
b69ab3118 * grammars asynchronously.
b69ab3119 */
b69ab3120 loadGrammar(initialScopeName: string): Promise<IGrammar | null> {
b69ab3121 return this.registry.loadGrammar(initialScopeName);
b69ab3122 }
b69ab3123
b69ab3124 /**
b69ab3125 * Returns a lookup array for color ids.
b69ab3126 */
b69ab3127 getColorMap(): string[] {
b69ab3128 return this.registry.getColorMap();
b69ab3129 }
b69ab3130}