UNPKG

3.11 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2023 EclipseSource and others.
4//
5// This program and the accompanying materials are made available under the
6// terms of the Eclipse Public License v. 2.0 which is available at
7// http://www.eclipse.org/legal/epl-2.0.
8//
9// This Source Code may also be made available under the following Secondary
10// Licenses when the conditions for such availability set forth in the Eclipse
11// Public License v. 2.0 are satisfied: GNU General Public License, version 2
12// with the GNU Classpath Exception which is available at
13// https://www.gnu.org/software/classpath/license.html.
14//
15// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16// *****************************************************************************
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.LanguageIconLabelProvider = void 0;
19const tslib_1 = require("tslib");
20const inversify_1 = require("inversify");
21const common_1 = require("../common");
22const icon_theme_service_1 = require("./icon-theme-service");
23const language_service_1 = require("./language-service");
24let LanguageIconLabelProvider = class LanguageIconLabelProvider {
25 constructor() {
26 this.onDidChangeEmitter = new common_1.Emitter();
27 }
28 init() {
29 this.languageService.onDidChangeIcon(() => this.fireDidChange());
30 }
31 canHandle(element) {
32 const current = this.iconThemeService.getDefinition(this.iconThemeService.current);
33 return (current === null || current === void 0 ? void 0 : current.showLanguageModeIcons) === true && this.languageService.getIcon(element) ? Number.MAX_SAFE_INTEGER : 0;
34 }
35 getIcon(element) {
36 const language = this.languageService.detectLanguage(element);
37 return this.languageService.getIcon(language.id);
38 }
39 get onDidChange() {
40 return this.onDidChangeEmitter.event;
41 }
42 fireDidChange() {
43 this.onDidChangeEmitter.fire({
44 affects: element => this.canHandle(element) > 0
45 });
46 }
47};
48(0, tslib_1.__decorate)([
49 (0, inversify_1.inject)(icon_theme_service_1.IconThemeService),
50 (0, tslib_1.__metadata)("design:type", icon_theme_service_1.IconThemeService)
51], LanguageIconLabelProvider.prototype, "iconThemeService", void 0);
52(0, tslib_1.__decorate)([
53 (0, inversify_1.inject)(language_service_1.LanguageService),
54 (0, tslib_1.__metadata)("design:type", language_service_1.LanguageService)
55], LanguageIconLabelProvider.prototype, "languageService", void 0);
56(0, tslib_1.__decorate)([
57 (0, inversify_1.postConstruct)(),
58 (0, tslib_1.__metadata)("design:type", Function),
59 (0, tslib_1.__metadata)("design:paramtypes", []),
60 (0, tslib_1.__metadata)("design:returntype", void 0)
61], LanguageIconLabelProvider.prototype, "init", null);
62LanguageIconLabelProvider = (0, tslib_1.__decorate)([
63 (0, inversify_1.injectable)()
64], LanguageIconLabelProvider);
65exports.LanguageIconLabelProvider = LanguageIconLabelProvider;
66//# sourceMappingURL=language-icon-provider.js.map
\No newline at end of file