1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.ResourceContextKey = void 0;
|
19 | const tslib_1 = require("tslib");
|
20 | const inversify_1 = require("inversify");
|
21 | const context_key_service_1 = require("./context-key-service");
|
22 | const language_service_1 = require("./language-service");
|
23 | let ResourceContextKey = class ResourceContextKey {
|
24 | init() {
|
25 | this.resource = this.contextKeyService.createKey('resource', undefined);
|
26 | this.resourceSchemeKey = this.contextKeyService.createKey('resourceScheme', undefined);
|
27 | this.resourceFileName = this.contextKeyService.createKey('resourceFilename', undefined);
|
28 | this.resourceExtname = this.contextKeyService.createKey('resourceExtname', undefined);
|
29 | this.resourceLangId = this.contextKeyService.createKey('resourceLangId', undefined);
|
30 | this.resourceDirName = this.contextKeyService.createKey('resourceDirName', undefined);
|
31 | this.resourcePath = this.contextKeyService.createKey('resourcePath', undefined);
|
32 | this.resourceSet = this.contextKeyService.createKey('resourceSet', false);
|
33 | }
|
34 | get() {
|
35 | return this.resource.get();
|
36 | }
|
37 | set(resourceUri) {
|
38 | this.resource.set(resourceUri === null || resourceUri === void 0 ? void 0 : resourceUri.toString());
|
39 | this.resourceSchemeKey.set(resourceUri === null || resourceUri === void 0 ? void 0 : resourceUri.scheme);
|
40 | this.resourceFileName.set(resourceUri === null || resourceUri === void 0 ? void 0 : resourceUri.path.base);
|
41 | this.resourceExtname.set(resourceUri === null || resourceUri === void 0 ? void 0 : resourceUri.path.ext);
|
42 | this.resourceLangId.set(resourceUri && this.getLanguageId(resourceUri));
|
43 | this.resourceDirName.set(resourceUri === null || resourceUri === void 0 ? void 0 : resourceUri.path.dir.fsPath());
|
44 | this.resourcePath.set(resourceUri === null || resourceUri === void 0 ? void 0 : resourceUri.path.fsPath());
|
45 | this.resourceSet.set(Boolean(resourceUri));
|
46 | }
|
47 | getLanguageId(uri) {
|
48 | if (uri) {
|
49 | for (const language of this.languages.languages) {
|
50 | if (language.extensions.has(uri.path.ext)) {
|
51 | return language.id;
|
52 | }
|
53 | }
|
54 | }
|
55 | return undefined;
|
56 | }
|
57 | };
|
58 | (0, tslib_1.__decorate)([
|
59 | (0, inversify_1.inject)(language_service_1.LanguageService),
|
60 | (0, tslib_1.__metadata)("design:type", language_service_1.LanguageService)
|
61 | ], ResourceContextKey.prototype, "languages", void 0);
|
62 | (0, tslib_1.__decorate)([
|
63 | (0, inversify_1.inject)(context_key_service_1.ContextKeyService),
|
64 | (0, tslib_1.__metadata)("design:type", Object)
|
65 | ], ResourceContextKey.prototype, "contextKeyService", void 0);
|
66 | (0, tslib_1.__decorate)([
|
67 | (0, inversify_1.postConstruct)(),
|
68 | (0, tslib_1.__metadata)("design:type", Function),
|
69 | (0, tslib_1.__metadata)("design:paramtypes", []),
|
70 | (0, tslib_1.__metadata)("design:returntype", void 0)
|
71 | ], ResourceContextKey.prototype, "init", null);
|
72 | ResourceContextKey = (0, tslib_1.__decorate)([
|
73 | (0, inversify_1.injectable)()
|
74 | ], ResourceContextKey);
|
75 | exports.ResourceContextKey = ResourceContextKey;
|
76 |
|
\ | No newline at end of file |