1
>
/*---------------------------------------------------------------------------------------------
modesRegistry.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import * as nls from '../../../nls.js';
7
>
import { Emitter, Event } from '../../../base/common/event.js';
8
>
import { ILanguageExtensionPoint } from './language.js';
9
>
import { Registry } from '../../../platform/registry/common/platform.js';
10
>
import { Disposable, IDisposable } from '../../../base/common/lifecycle.js';
11
>
import { Mimes } from '../../../base/common/mime.js';
12
>
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from '../../../platform/configuration/common/configurationRegistry.js';
13
>
14
>
// Define extension point ids
15
>
export const Extensions = {
16
>
ModesRegistry: 'editor.modesRegistry'
17
>
};
18
>
19
>
export class EditorModesRegistry extends Disposable {
20
>
21
>
private readonly _languages: ILanguageExtensionPoint[];
22
>
23
>
private readonly _onDidChangeLanguages = this._register(new Emitter<void>());
24
>
public readonly onDidChangeLanguages: Event<void> = this._onDidChangeLanguages.event;
25
>
26
>
constructor() {
27
>
super();
28
>
this._languages = [];
29
>
}
30
>
31
>
public registerLanguage(def: ILanguageExtensionPoint): IDisposable {
32
>
this._languages.push(def);
33
>
this._onDidChangeLanguages.fire(undefined);
34
>
return {
35
>
dispose: () => {
36
for (let i = 0, len = this._languages.length; i < len; i++) {
37
if (this._languages[i] === def) {