Skip to content

Commit

Permalink
Using ThemeIcon in more places when refering to the icon for a langua…
Browse files Browse the repository at this point in the history
…ge contribution
  • Loading branch information
Mai-Lapyst committed Sep 17, 2021
1 parent 2d96ea4 commit 80a5369
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/vs/editor/common/services/languagesRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { NULL_LANGUAGE_IDENTIFIER, NULL_MODE_ID } from 'vs/editor/common/modes/n
import { ILanguageExtensionPoint } from 'vs/editor/common/services/modeService';
import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
import { Registry } from 'vs/platform/registry/common/platform';
import { ThemeIcon } from 'vs/platform/theme/common/themeService';

const hasOwnProperty = Object.prototype.hasOwnProperty;

Expand All @@ -26,7 +27,7 @@ export interface IResolvedLanguage {
extensions: string[];
filenames: string[];
configurationFiles: URI[];
icons: string[];
icons: ThemeIcon[];
}

export class LanguagesRegistry extends Disposable {
Expand Down Expand Up @@ -231,7 +232,7 @@ export class LanguagesRegistry extends Disposable {
}

if (lang.icon) {
resolvedLanguage.icons.push(lang.icon);
resolvedLanguage.icons.push({ id: lang.icon });
}
}

Expand Down Expand Up @@ -281,7 +282,7 @@ export class LanguagesRegistry extends Disposable {
return (language.mimetypes[0] || null);
}

public getIconForMode(modeId: string): string | null {
public getIconForMode(modeId: string): ThemeIcon | null {
if (!hasOwnProperty.call(this._languages, modeId)) {
return null;
}
Expand Down
3 changes: 2 additions & 1 deletion src/vs/editor/common/services/modeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Event } from 'vs/base/common/event';
import { URI } from 'vs/base/common/uri';
import { IMode, LanguageId, LanguageIdentifier } from 'vs/editor/common/modes';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { ThemeIcon } from 'vs/platform/theme/common/themeService';

export const IModeService = createDecorator<IModeService>('modeService');

Expand Down Expand Up @@ -40,7 +41,7 @@ export interface IModeService {
getExtensions(alias: string): string[];
getFilenames(alias: string): string[];
getMimeForMode(modeId: string): string | null;
getIconForMode(modeId: string): string | null;
getIconForMode(modeId: string): ThemeIcon | null;
getLanguageName(modeId: string): string | null;
getModeIdForLanguageName(alias: string): string | null;
getModeIdByFilepathOrFirstLine(resource: URI, firstLine?: string): string | null;
Expand Down
3 changes: 2 additions & 1 deletion src/vs/editor/common/services/modeServiceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { NULL_LANGUAGE_IDENTIFIER } from 'vs/editor/common/modes/nullMode';
import { LanguagesRegistry } from 'vs/editor/common/services/languagesRegistry';
import { ILanguageSelection, IModeService } from 'vs/editor/common/services/modeService';
import { firstOrDefault } from 'vs/base/common/arrays';
import { ThemeIcon } from 'vs/platform/theme/common/themeService';

class LanguageSelection implements ILanguageSelection {

Expand Down Expand Up @@ -96,7 +97,7 @@ export class ModeServiceImpl extends Disposable implements IModeService {
return this._registry.getMimeForMode(modeId);
}

public getIconForMode(modeId: string): string | null {
public getIconForMode(modeId: string): ThemeIcon | null {
return this._registry.getIconForMode(modeId);
}

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/services/themes/browser/fileIconThemeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ class FileIconThemeLoader {
}

for (let languageId in selectorByModeIdForMissingLanguages) {
const iconName = modeService.getIconForMode(languageId);
const contribution = getIconRegistry().getIcon(iconName!);
const themeIcon = modeService.getIconForMode(languageId);
const contribution = getIconRegistry().getIcon(themeIcon!.id!);
if (contribution) {
let definition: IconDefaults | null = contribution.defaults;
while (ThemeIcon.isThemeIcon(definition)) {
Expand Down

0 comments on commit 80a5369

Please sign in to comment.