| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | */ |
| 7 | |
| 8 | import type {IGrammar, Registry} from 'vscode-textmate'; |
| 9 | |
| 10 | export default class GrammarStore { |
| 11 | /** |
| 12 | * See `createTextMateRegistry()` in this directory to create a Registry. |
| 13 | */ |
| 14 | constructor(private registry: Registry) {} |
| 15 | |
| 16 | /** |
| 17 | * Load the grammar for `initialScopeName` and all referenced included |
| 18 | * grammars asynchronously. |
| 19 | */ |
| 20 | loadGrammar(initialScopeName: string): Promise<IGrammar | null> { |
| 21 | return this.registry.loadGrammar(initialScopeName); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Returns a lookup array for color ids. |
| 26 | */ |
| 27 | getColorMap(): string[] { |
| 28 | return this.registry.getColorMap(); |
| 29 | } |
| 30 | } |
| 31 | |