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