languagesRegistry.ts ×23

Frontier kind: Code frontier

unlabeled · c_eb085d75e364

548 tests · 9125 LOC · 44 files · introduces 0 tests · 99 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
24 ranges99 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1264 ranges9125 lines · 44 files · Browse complete extent
All tests (intent)
548 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 99 introduced LOC across 24 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/services/languagesRegistry.ts 96 introduced LOC · 23 ranges

Open complete file

48
49 public register(language: string): void {
50 > if (this._languageToLanguageId.has(language)) { languagesRegistry.ts
51 return;
52 }
53 const languageId = this._nextLanguageId++;
54 this._register(language, languageId);
56
57 public encodeLanguageId(languageId: string): LanguageId {
80
81 constructor(useModesRegistry = true, warnOnOverwrite = false) {
82 > super(); languagesRegistry.ts
83 > LanguagesRegistry.instanceCount++;
84 >
85 > this._warnOnOverwrite = warnOnOverwrite;
86 > this.languageIdCodec = new LanguageIdCodec();
87 > this._dynamicLanguages = [];
88 > this._languages = {};
89 > this._mimeTypesMap = {};
90 > this._nameMap = {};
91 > this._lowercaseNameMap = {};
92 >
93 > if (useModesRegistry) {
94 this._initializeFromRegistry();
95 this._register(ModesRegistry.onDidChangeLanguages((m) => {
97 }));
98 }
100
101 override dispose() {
102 > LanguagesRegistry.instanceCount--; languagesRegistry.ts
103 > super.dispose();
104 > }
105
106 public setDynamicLanguages(def: ILanguageExtensionPoint[]): void {
125
126 _registerLanguages(desc: ILanguageExtensionPoint[]): void {
128 > for (const d of desc) {
129 > this._registerLanguage(d);
130 > }
131 >
132 > // Rebuild fast path maps
133 > this._mimeTypesMap = {};
134 > this._nameMap = {};
135 > this._lowercaseNameMap = {};
136 > Object.keys(this._languages).forEach((langId) => {
137 > const language = this._languages[langId];
138 > if (language.name) {
139 this._nameMap[language.name] = language.identifier;
140 }
141 > language.aliases.forEach((alias) => { languagesRegistry.ts
142 > this._lowercaseNameMap[alias.toLowerCase()] = language.identifier;
143 > });
144 > language.mimetypes.forEach((mimetype) => {
145 > this._mimeTypesMap[mimetype] = language.identifier;
146 > });
147 > });
148 >
149 > Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerOverrideIdentifiers(this.getRegisteredLanguageIds());
150 >
151 > this._onDidChange.fire();
152 > }
153
154 private _registerLanguage(lang: ILanguageExtensionPoint): void {
155 > const langId = lang.id; languagesRegistry.ts
156 >
157 > let resolvedLanguage: IResolvedLanguage;
158 > if (hasOwnProperty.call(this._languages, langId)) {
159 resolvedLanguage = this._languages[langId];
160 > } else { languagesRegistry.ts
161 > this.languageIdCodec.register(langId);
162 > resolvedLanguage = {
163 > identifier: langId,
164 > name: null,
165 > mimetypes: [],
166 > aliases: [],
167 > extensions: [],
168 > filenames: [],
169 > configurationFiles: [],
170 > icons: []
171 > };
172 > this._languages[langId] = resolvedLanguage;
173 > }
174 >
175 > this._mergeLanguage(resolvedLanguage, lang);
176 > }
177
178 private _mergeLanguage(resolvedLanguage: IResolvedLanguage, lang: ILanguageExtensionPoint): void {
179 > const langId = lang.id; languagesRegistry.ts
180 >
181 > let primaryMime: string | null = null;
182 >
183 > if (Array.isArray(lang.mimetypes) && lang.mimetypes.length > 0) {
184 resolvedLanguage.mimetypes.push(...lang.mimetypes);
185 primaryMime = lang.mimetypes[0];
186 }
188 > if (!primaryMime) {
189 primaryMime = `text/x-${langId}`;
190 resolvedLanguage.mimetypes.push(primaryMime);
191 }
193 > if (Array.isArray(lang.extensions)) {
194 if (lang.configuration) {
195 // insert first as this appears to be the 'primary' language definition
202 }
203 }
205 > if (Array.isArray(lang.filenames)) {
206 for (const filename of lang.filenames) {
207 registerPlatformLanguageAssociation({ id: langId, mime: primaryMime, filename: filename }, this._warnOnOverwrite);
209 }
210 }
212 > if (Array.isArray(lang.filenamePatterns)) {
213 for (const filenamePattern of lang.filenamePatterns) {
214 registerPlatformLanguageAssociation({ id: langId, mime: primaryMime, filepattern: filenamePattern }, this._warnOnOverwrite);
215 }
216 }
218 > if (typeof lang.firstLine === 'string' && lang.firstLine.length > 0) {
219 let firstLineRegexStr = lang.firstLine;
220 if (firstLineRegexStr.charAt(0) !== '^') {
231 }
232 }
234 > resolvedLanguage.aliases.push(langId);
235 >
236 > let langAliases: Array<string | null> | null = null;
237 > if (typeof lang.aliases !== 'undefined' && Array.isArray(lang.aliases)) {
238 if (lang.aliases.length === 0) {
239 // signal that this language should not get a name
243 }
244 }
246 > if (langAliases !== null) {
247 for (const langAlias of langAliases) {
248 if (!langAlias || langAlias.length === 0) {
252 }
253 }
255 > const containsAliases = (langAliases !== null && langAliases.length > 0);
256 > if (containsAliases && langAliases![0] === null) {
257 // signal that this language should not get a name
258 > } else { languagesRegistry.ts
259 const bestName = (containsAliases ? langAliases![0] : null) || langId;
260 if (containsAliases || !resolvedLanguage.name) {
262 }
263 }
265 > if (lang.configuration) {
266 resolvedLanguage.configurationFiles.push(lang.configuration);
267 }
269 > if (lang.icon) {
270 resolvedLanguage.icons.push(lang.icon);
271 }
273
274 public isRegisteredLanguageId(languageId: string | null | undefined): boolean {
280
281 public getRegisteredLanguageIds(): string[] {
282 > return Object.keys(this._languages); languagesRegistry.ts
283 > }
284
285 public getSortedRegisteredLanguageNames(): ILanguageNameIdPair[] {
src/vs/platform/configuration/common/configurationRegistry.ts 3 introduced LOC · 1 range

Open complete file

668
669 public registerOverrideIdentifiers(overrideIdentifiers: string[]): void {
670 > this.doRegisterOverrideIdentifiers(overrideIdentifiers); configurationRegistry.ts
671 > this._onDidSchemaChange.fire();
672 > }
673
674 private doRegisterOverrideIdentifiers(overrideIdentifiers: string[]) {