@theia/workspace 1.45.1 → 1.46.0-next.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -30
- package/lib/browser/canonical-uri-service.d.ts +11 -11
- package/lib/browser/canonical-uri-service.js +59 -59
- package/lib/browser/diff-service.d.ts +10 -10
- package/lib/browser/diff-service.js +85 -85
- package/lib/browser/index.d.ts +7 -7
- package/lib/browser/index.js +34 -34
- package/lib/browser/quick-open-workspace.d.ts +25 -25
- package/lib/browser/quick-open-workspace.js +137 -137
- package/lib/browser/untitled-workspace-exit-dialog.d.ts +19 -19
- package/lib/browser/untitled-workspace-exit-dialog.js +74 -74
- package/lib/browser/workspace-breadcrumbs-contribution.d.ts +10 -10
- package/lib/browser/workspace-breadcrumbs-contribution.js +66 -66
- package/lib/browser/workspace-commands.d.ts +117 -117
- package/lib/browser/workspace-commands.js +601 -601
- package/lib/browser/workspace-commands.spec.d.ts +1 -1
- package/lib/browser/workspace-commands.spec.js +127 -127
- package/lib/browser/workspace-compare-handler.d.ts +26 -26
- package/lib/browser/workspace-compare-handler.js +66 -66
- package/lib/browser/workspace-delete-handler.d.ts +75 -75
- package/lib/browser/workspace-delete-handler.js +214 -214
- package/lib/browser/workspace-duplicate-handler.d.ts +30 -30
- package/lib/browser/workspace-duplicate-handler.js +86 -86
- package/lib/browser/workspace-frontend-contribution.d.ts +110 -110
- package/lib/browser/workspace-frontend-contribution.js +546 -546
- package/lib/browser/workspace-frontend-contribution.js.map +1 -1
- package/lib/browser/workspace-frontend-module.d.ts +3 -3
- package/lib/browser/workspace-frontend-module.js +91 -91
- package/lib/browser/workspace-input-dialog.d.ts +19 -19
- package/lib/browser/workspace-input-dialog.js +74 -74
- package/lib/browser/workspace-preferences.d.ts +11 -11
- package/lib/browser/workspace-preferences.js +46 -46
- package/lib/browser/workspace-schema-updater.d.ts +34 -34
- package/lib/browser/workspace-schema-updater.js +153 -153
- package/lib/browser/workspace-service.d.ts +184 -184
- package/lib/browser/workspace-service.js +739 -739
- package/lib/browser/workspace-storage-service.d.ts +15 -15
- package/lib/browser/workspace-storage-service.js +80 -80
- package/lib/browser/workspace-trust-preferences.d.ts +21 -21
- package/lib/browser/workspace-trust-preferences.js +65 -65
- package/lib/browser/workspace-trust-service.d.ts +27 -27
- package/lib/browser/workspace-trust-service.js +152 -152
- package/lib/browser/workspace-uri-contribution.d.ts +20 -20
- package/lib/browser/workspace-uri-contribution.js +113 -113
- package/lib/browser/workspace-uri-contribution.spec.d.ts +1 -1
- package/lib/browser/workspace-uri-contribution.spec.js +169 -169
- package/lib/browser/workspace-user-working-directory-provider.d.ts +12 -12
- package/lib/browser/workspace-user-working-directory-provider.js +62 -62
- package/lib/browser/workspace-utils.d.ts +15 -15
- package/lib/browser/workspace-utils.js +54 -54
- package/lib/browser/workspace-variable-contribution.d.ts +23 -23
- package/lib/browser/workspace-variable-contribution.js +237 -237
- package/lib/browser/workspace-window-title-updater.d.ts +7 -7
- package/lib/browser/workspace-window-title-updater.js +57 -57
- package/lib/browser-only/browser-only-workspace-server.d.ts +13 -0
- package/lib/browser-only/browser-only-workspace-server.d.ts.map +1 -0
- package/lib/browser-only/browser-only-workspace-server.js +81 -0
- package/lib/browser-only/browser-only-workspace-server.js.map +1 -0
- package/lib/browser-only/workspace-frontend-only-module.d.ts +4 -0
- package/lib/browser-only/workspace-frontend-only-module.d.ts.map +1 -0
- package/lib/browser-only/workspace-frontend-only-module.js +30 -0
- package/lib/browser-only/workspace-frontend-only-module.js.map +1 -0
- package/lib/common/index.d.ts +3 -3
- package/lib/common/index.js +30 -30
- package/lib/common/test/mock-workspace-server.d.ts +7 -7
- package/lib/common/test/mock-workspace-server.js +35 -35
- package/lib/common/untitled-workspace-service.d.ts +8 -8
- package/lib/common/untitled-workspace-service.js +60 -60
- package/lib/common/workspace-file-service.d.ts +26 -26
- package/lib/common/workspace-file-service.js +71 -71
- package/lib/common/workspace-protocol.d.ts +26 -26
- package/lib/common/workspace-protocol.js +23 -23
- package/lib/node/default-workspace-server.d.ts +65 -65
- package/lib/node/default-workspace-server.js +248 -248
- package/lib/node/default-workspace-server.spec.d.ts +1 -1
- package/lib/node/default-workspace-server.spec.js +85 -85
- package/lib/node/index.d.ts +2 -2
- package/lib/node/index.js +29 -29
- package/lib/node/workspace-backend-module.d.ts +3 -3
- package/lib/node/workspace-backend-module.js +33 -33
- package/package.json +9 -6
- package/src/browser/canonical-uri-service.ts +57 -57
- package/src/browser/diff-service.ts +62 -62
- package/src/browser/index.ts +23 -23
- package/src/browser/quick-open-workspace.ts +112 -112
- package/src/browser/untitled-workspace-exit-dialog.ts +70 -70
- package/src/browser/workspace-breadcrumbs-contribution.ts +56 -56
- package/src/browser/workspace-commands.spec.ts +153 -153
- package/src/browser/workspace-commands.ts +588 -588
- package/src/browser/workspace-compare-handler.ts +56 -56
- package/src/browser/workspace-delete-handler.ts +212 -212
- package/src/browser/workspace-duplicate-handler.ts +75 -75
- package/src/browser/workspace-frontend-contribution.ts +537 -537
- package/src/browser/workspace-frontend-module.ts +118 -118
- package/src/browser/workspace-input-dialog.ts +61 -61
- package/src/browser/workspace-preferences.ts +58 -58
- package/src/browser/workspace-schema-updater.ts +150 -150
- package/src/browser/workspace-service.ts +780 -780
- package/src/browser/workspace-storage-service.ts +67 -67
- package/src/browser/workspace-trust-preferences.ts +76 -76
- package/src/browser/workspace-trust-service.ts +147 -147
- package/src/browser/workspace-uri-contribution.spec.ts +191 -191
- package/src/browser/workspace-uri-contribution.ts +97 -97
- package/src/browser/workspace-user-working-directory-provider.ts +49 -49
- package/src/browser/workspace-utils.ts +45 -45
- package/src/browser/workspace-variable-contribution.ts +222 -222
- package/src/browser/workspace-window-title-updater.ts +45 -45
- package/src/browser-only/browser-only-workspace-server.ts +69 -0
- package/src/browser-only/workspace-frontend-only-module.ts +28 -0
- package/src/common/index.ts +19 -19
- package/src/common/test/mock-workspace-server.ts +29 -29
- package/src/common/untitled-workspace-service.ts +50 -50
- package/src/common/workspace-file-service.ts +72 -72
- package/src/common/workspace-protocol.ts +47 -47
- package/src/node/default-workspace-server.spec.ts +100 -100
- package/src/node/default-workspace-server.ts +244 -244
- package/src/node/index.ts +18 -18
- package/src/node/workspace-backend-module.ts +38 -38
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2018 Ericsson 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
|
-
// *****************************************************************************
|
|
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.WorkspaceUtils = void 0;
|
|
28
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
29
|
-
const workspace_service_1 = require("./workspace-service");
|
|
30
|
-
/**
|
|
31
|
-
* Collection of workspace utility functions
|
|
32
|
-
* @class
|
|
33
|
-
*/
|
|
34
|
-
let WorkspaceUtils = class WorkspaceUtils {
|
|
35
|
-
/**
|
|
36
|
-
* Determine if root directory exists
|
|
37
|
-
* for a given array of URIs
|
|
38
|
-
* @param uris
|
|
39
|
-
*/
|
|
40
|
-
containsRootDirectory(uris) {
|
|
41
|
-
// obtain all roots URIs for a given workspace
|
|
42
|
-
const rootUris = this.workspaceService.tryGetRoots().map(root => root.resource);
|
|
43
|
-
// return true if at least a single URI is a root directory
|
|
44
|
-
return rootUris.some(rootUri => uris.some(uri => uri.isEqualOrParent(rootUri)));
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
__decorate([
|
|
48
|
-
(0, inversify_1.inject)(workspace_service_1.WorkspaceService),
|
|
49
|
-
__metadata("design:type", workspace_service_1.WorkspaceService)
|
|
50
|
-
], WorkspaceUtils.prototype, "workspaceService", void 0);
|
|
51
|
-
WorkspaceUtils = __decorate([
|
|
52
|
-
(0, inversify_1.injectable)()
|
|
53
|
-
], WorkspaceUtils);
|
|
54
|
-
exports.WorkspaceUtils = WorkspaceUtils;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2018 Ericsson 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
|
+
// *****************************************************************************
|
|
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.WorkspaceUtils = void 0;
|
|
28
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
29
|
+
const workspace_service_1 = require("./workspace-service");
|
|
30
|
+
/**
|
|
31
|
+
* Collection of workspace utility functions
|
|
32
|
+
* @class
|
|
33
|
+
*/
|
|
34
|
+
let WorkspaceUtils = class WorkspaceUtils {
|
|
35
|
+
/**
|
|
36
|
+
* Determine if root directory exists
|
|
37
|
+
* for a given array of URIs
|
|
38
|
+
* @param uris
|
|
39
|
+
*/
|
|
40
|
+
containsRootDirectory(uris) {
|
|
41
|
+
// obtain all roots URIs for a given workspace
|
|
42
|
+
const rootUris = this.workspaceService.tryGetRoots().map(root => root.resource);
|
|
43
|
+
// return true if at least a single URI is a root directory
|
|
44
|
+
return rootUris.some(rootUri => uris.some(uri => uri.isEqualOrParent(rootUri)));
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, inversify_1.inject)(workspace_service_1.WorkspaceService),
|
|
49
|
+
__metadata("design:type", workspace_service_1.WorkspaceService)
|
|
50
|
+
], WorkspaceUtils.prototype, "workspaceService", void 0);
|
|
51
|
+
WorkspaceUtils = __decorate([
|
|
52
|
+
(0, inversify_1.injectable)()
|
|
53
|
+
], WorkspaceUtils);
|
|
54
|
+
exports.WorkspaceUtils = WorkspaceUtils;
|
|
55
55
|
//# sourceMappingURL=workspace-utils.js.map
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import URI from '@theia/core/lib/common/uri';
|
|
2
|
-
import { ApplicationShell, NavigatableWidget, WidgetManager } from '@theia/core/lib/browser';
|
|
3
|
-
import { VariableContribution, VariableRegistry } from '@theia/variable-resolver/lib/browser';
|
|
4
|
-
import { WorkspaceService } from './workspace-service';
|
|
5
|
-
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
6
|
-
export declare class WorkspaceVariableContribution implements VariableContribution {
|
|
7
|
-
protected readonly workspaceService: WorkspaceService;
|
|
8
|
-
protected readonly shell: ApplicationShell;
|
|
9
|
-
protected readonly fileService: FileService;
|
|
10
|
-
protected readonly widgetManager: WidgetManager;
|
|
11
|
-
protected currentWidget: NavigatableWidget | undefined;
|
|
12
|
-
protected init(): void;
|
|
13
|
-
protected readonly recentlyVisibleIds: string[];
|
|
14
|
-
protected get recentlyVisible(): NavigatableWidget | undefined;
|
|
15
|
-
protected addRecentlyVisible(widget: NavigatableWidget): void;
|
|
16
|
-
protected removeRecentlyVisible(widget: NavigatableWidget): void;
|
|
17
|
-
protected updateCurrentWidget(): void;
|
|
18
|
-
registerVariables(variables: VariableRegistry): void;
|
|
19
|
-
protected registerWorkspaceRootVariables(variables: VariableRegistry): void;
|
|
20
|
-
getWorkspaceRootUri(uri?: URI | undefined): URI | undefined;
|
|
21
|
-
getResourceUri(): URI | undefined;
|
|
22
|
-
getWorkspaceRelativePath(uri: URI, context?: URI): string | undefined;
|
|
23
|
-
}
|
|
1
|
+
import URI from '@theia/core/lib/common/uri';
|
|
2
|
+
import { ApplicationShell, NavigatableWidget, WidgetManager } from '@theia/core/lib/browser';
|
|
3
|
+
import { VariableContribution, VariableRegistry } from '@theia/variable-resolver/lib/browser';
|
|
4
|
+
import { WorkspaceService } from './workspace-service';
|
|
5
|
+
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
6
|
+
export declare class WorkspaceVariableContribution implements VariableContribution {
|
|
7
|
+
protected readonly workspaceService: WorkspaceService;
|
|
8
|
+
protected readonly shell: ApplicationShell;
|
|
9
|
+
protected readonly fileService: FileService;
|
|
10
|
+
protected readonly widgetManager: WidgetManager;
|
|
11
|
+
protected currentWidget: NavigatableWidget | undefined;
|
|
12
|
+
protected init(): void;
|
|
13
|
+
protected readonly recentlyVisibleIds: string[];
|
|
14
|
+
protected get recentlyVisible(): NavigatableWidget | undefined;
|
|
15
|
+
protected addRecentlyVisible(widget: NavigatableWidget): void;
|
|
16
|
+
protected removeRecentlyVisible(widget: NavigatableWidget): void;
|
|
17
|
+
protected updateCurrentWidget(): void;
|
|
18
|
+
registerVariables(variables: VariableRegistry): void;
|
|
19
|
+
protected registerWorkspaceRootVariables(variables: VariableRegistry): void;
|
|
20
|
+
getWorkspaceRootUri(uri?: URI | undefined): URI | undefined;
|
|
21
|
+
getResourceUri(): URI | undefined;
|
|
22
|
+
getWorkspaceRelativePath(uri: URI, context?: URI): string | undefined;
|
|
23
|
+
}
|
|
24
24
|
//# sourceMappingURL=workspace-variable-contribution.d.ts.map
|
|
@@ -1,238 +1,238 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2018 Red Hat, Inc. 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
|
-
// *****************************************************************************
|
|
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.WorkspaceVariableContribution = void 0;
|
|
28
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
29
|
-
const path_1 = require("@theia/core/lib/common/path");
|
|
30
|
-
const browser_1 = require("@theia/core/lib/browser");
|
|
31
|
-
const workspace_service_1 = require("./workspace-service");
|
|
32
|
-
const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
|
|
33
|
-
let WorkspaceVariableContribution = class WorkspaceVariableContribution {
|
|
34
|
-
constructor() {
|
|
35
|
-
this.recentlyVisibleIds = [];
|
|
36
|
-
}
|
|
37
|
-
init() {
|
|
38
|
-
this.shell.onDidChangeCurrentWidget(() => this.updateCurrentWidget());
|
|
39
|
-
this.widgetManager.onDidCreateWidget(({ widget }) => {
|
|
40
|
-
if (browser_1.NavigatableWidget.is(widget)) {
|
|
41
|
-
widget.onDidChangeVisibility(() => {
|
|
42
|
-
if (widget.isVisible) {
|
|
43
|
-
this.addRecentlyVisible(widget);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
this.removeRecentlyVisible(widget);
|
|
47
|
-
}
|
|
48
|
-
this.updateCurrentWidget();
|
|
49
|
-
});
|
|
50
|
-
widget.onDidDispose(() => {
|
|
51
|
-
this.removeRecentlyVisible(widget);
|
|
52
|
-
this.updateCurrentWidget();
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
for (const widget of this.shell.widgets) {
|
|
57
|
-
if (browser_1.NavigatableWidget.is(widget) && widget.isVisible) {
|
|
58
|
-
this.addRecentlyVisible(widget);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
this.updateCurrentWidget();
|
|
62
|
-
}
|
|
63
|
-
get recentlyVisible() {
|
|
64
|
-
const id = this.recentlyVisibleIds[0];
|
|
65
|
-
const widget = id && this.shell.getWidgetById(id) || undefined;
|
|
66
|
-
if (browser_1.NavigatableWidget.is(widget)) {
|
|
67
|
-
return widget;
|
|
68
|
-
}
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
addRecentlyVisible(widget) {
|
|
72
|
-
this.removeRecentlyVisible(widget);
|
|
73
|
-
this.recentlyVisibleIds.unshift(widget.id);
|
|
74
|
-
}
|
|
75
|
-
removeRecentlyVisible(widget) {
|
|
76
|
-
const index = this.recentlyVisibleIds.indexOf(widget.id);
|
|
77
|
-
if (index !== -1) {
|
|
78
|
-
this.recentlyVisibleIds.splice(index, 1);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
updateCurrentWidget() {
|
|
82
|
-
const { currentWidget } = this.shell;
|
|
83
|
-
if (browser_1.NavigatableWidget.is(currentWidget)) {
|
|
84
|
-
this.currentWidget = currentWidget;
|
|
85
|
-
}
|
|
86
|
-
else if (!this.currentWidget || !this.currentWidget.isVisible) {
|
|
87
|
-
this.currentWidget = this.recentlyVisible;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
registerVariables(variables) {
|
|
91
|
-
this.registerWorkspaceRootVariables(variables);
|
|
92
|
-
variables.registerVariable({
|
|
93
|
-
name: 'file',
|
|
94
|
-
description: 'The path of the currently opened file',
|
|
95
|
-
resolve: () => {
|
|
96
|
-
const uri = this.getResourceUri();
|
|
97
|
-
return uri && this.fileService.fsPath(uri);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
variables.registerVariable({
|
|
101
|
-
name: 'fileBasename',
|
|
102
|
-
description: 'The basename of the currently opened file',
|
|
103
|
-
resolve: () => {
|
|
104
|
-
const uri = this.getResourceUri();
|
|
105
|
-
return uri && uri.path.base;
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
variables.registerVariable({
|
|
109
|
-
name: 'fileBasenameNoExtension',
|
|
110
|
-
description: "The currently opened file's name without extension",
|
|
111
|
-
resolve: () => {
|
|
112
|
-
const uri = this.getResourceUri();
|
|
113
|
-
return uri && uri.path.name;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
variables.registerVariable({
|
|
117
|
-
name: 'fileDirname',
|
|
118
|
-
description: "The name of the currently opened file's directory",
|
|
119
|
-
resolve: () => {
|
|
120
|
-
const uri = this.getResourceUri();
|
|
121
|
-
return uri && uri.path.dir.toString();
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
variables.registerVariable({
|
|
125
|
-
name: 'fileExtname',
|
|
126
|
-
description: 'The extension of the currently opened file',
|
|
127
|
-
resolve: () => {
|
|
128
|
-
const uri = this.getResourceUri();
|
|
129
|
-
return uri && uri.path.ext;
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
registerWorkspaceRootVariables(variables) {
|
|
134
|
-
const scoped = (variable) => ({
|
|
135
|
-
name: variable.name,
|
|
136
|
-
description: variable.description,
|
|
137
|
-
resolve: (context, workspaceRootName) => {
|
|
138
|
-
const workspaceRoot = workspaceRootName && this.workspaceService.tryGetRoots().find(r => r.resource.path.name === workspaceRootName);
|
|
139
|
-
return variable.resolve(workspaceRoot ? workspaceRoot.resource : context);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
variables.registerVariable(scoped({
|
|
143
|
-
name: 'workspaceRoot',
|
|
144
|
-
description: 'The path of the workspace root folder',
|
|
145
|
-
resolve: (context) => {
|
|
146
|
-
const uri = this.getWorkspaceRootUri(context);
|
|
147
|
-
return uri && this.fileService.fsPath(uri);
|
|
148
|
-
}
|
|
149
|
-
}));
|
|
150
|
-
variables.registerVariable(scoped({
|
|
151
|
-
name: 'workspaceFolder',
|
|
152
|
-
description: 'The path of the workspace root folder',
|
|
153
|
-
resolve: (context) => {
|
|
154
|
-
const uri = this.getWorkspaceRootUri(context);
|
|
155
|
-
return uri && this.fileService.fsPath(uri);
|
|
156
|
-
}
|
|
157
|
-
}));
|
|
158
|
-
variables.registerVariable(scoped({
|
|
159
|
-
name: 'workspaceRootFolderName',
|
|
160
|
-
description: 'The name of the workspace root folder',
|
|
161
|
-
resolve: (context) => {
|
|
162
|
-
const uri = this.getWorkspaceRootUri(context);
|
|
163
|
-
return uri && uri.displayName;
|
|
164
|
-
}
|
|
165
|
-
}));
|
|
166
|
-
variables.registerVariable(scoped({
|
|
167
|
-
name: 'workspaceFolderBasename',
|
|
168
|
-
description: 'The name of the workspace root folder',
|
|
169
|
-
resolve: (context) => {
|
|
170
|
-
const uri = this.getWorkspaceRootUri(context);
|
|
171
|
-
return uri && uri.displayName;
|
|
172
|
-
}
|
|
173
|
-
}));
|
|
174
|
-
variables.registerVariable(scoped({
|
|
175
|
-
name: 'cwd',
|
|
176
|
-
description: "The task runner's current working directory on startup",
|
|
177
|
-
resolve: (context) => {
|
|
178
|
-
const uri = this.getWorkspaceRootUri(context);
|
|
179
|
-
return (uri && this.fileService.fsPath(uri)) || '';
|
|
180
|
-
}
|
|
181
|
-
}));
|
|
182
|
-
variables.registerVariable(scoped({
|
|
183
|
-
name: 'relativeFile',
|
|
184
|
-
description: "The currently opened file's path relative to the workspace root",
|
|
185
|
-
resolve: (context) => {
|
|
186
|
-
const uri = this.getResourceUri();
|
|
187
|
-
return uri && this.getWorkspaceRelativePath(uri, context);
|
|
188
|
-
}
|
|
189
|
-
}));
|
|
190
|
-
variables.registerVariable(scoped({
|
|
191
|
-
name: 'relativeFileDirname',
|
|
192
|
-
description: "The current opened file's dirname relative to ${workspaceFolder}",
|
|
193
|
-
resolve: (context) => {
|
|
194
|
-
const uri = this.getResourceUri();
|
|
195
|
-
const relativePath = uri && this.getWorkspaceRelativePath(uri, context);
|
|
196
|
-
return relativePath && new path_1.Path(relativePath).dir.toString();
|
|
197
|
-
}
|
|
198
|
-
}));
|
|
199
|
-
}
|
|
200
|
-
getWorkspaceRootUri(uri = this.getResourceUri()) {
|
|
201
|
-
return this.workspaceService.getWorkspaceRootUri(uri);
|
|
202
|
-
}
|
|
203
|
-
getResourceUri() {
|
|
204
|
-
return this.currentWidget && this.currentWidget.getResourceUri();
|
|
205
|
-
}
|
|
206
|
-
getWorkspaceRelativePath(uri, context) {
|
|
207
|
-
const workspaceRootUri = this.getWorkspaceRootUri(context || uri);
|
|
208
|
-
const path = workspaceRootUri && workspaceRootUri.path.relative(uri.path);
|
|
209
|
-
return path && path.toString();
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
__decorate([
|
|
213
|
-
(0, inversify_1.inject)(workspace_service_1.WorkspaceService),
|
|
214
|
-
__metadata("design:type", workspace_service_1.WorkspaceService)
|
|
215
|
-
], WorkspaceVariableContribution.prototype, "workspaceService", void 0);
|
|
216
|
-
__decorate([
|
|
217
|
-
(0, inversify_1.inject)(browser_1.ApplicationShell),
|
|
218
|
-
__metadata("design:type", browser_1.ApplicationShell)
|
|
219
|
-
], WorkspaceVariableContribution.prototype, "shell", void 0);
|
|
220
|
-
__decorate([
|
|
221
|
-
(0, inversify_1.inject)(file_service_1.FileService),
|
|
222
|
-
__metadata("design:type", file_service_1.FileService)
|
|
223
|
-
], WorkspaceVariableContribution.prototype, "fileService", void 0);
|
|
224
|
-
__decorate([
|
|
225
|
-
(0, inversify_1.inject)(browser_1.WidgetManager),
|
|
226
|
-
__metadata("design:type", browser_1.WidgetManager)
|
|
227
|
-
], WorkspaceVariableContribution.prototype, "widgetManager", void 0);
|
|
228
|
-
__decorate([
|
|
229
|
-
(0, inversify_1.postConstruct)(),
|
|
230
|
-
__metadata("design:type", Function),
|
|
231
|
-
__metadata("design:paramtypes", []),
|
|
232
|
-
__metadata("design:returntype", void 0)
|
|
233
|
-
], WorkspaceVariableContribution.prototype, "init", null);
|
|
234
|
-
WorkspaceVariableContribution = __decorate([
|
|
235
|
-
(0, inversify_1.injectable)()
|
|
236
|
-
], WorkspaceVariableContribution);
|
|
237
|
-
exports.WorkspaceVariableContribution = WorkspaceVariableContribution;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2018 Red Hat, Inc. 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
|
+
// *****************************************************************************
|
|
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.WorkspaceVariableContribution = void 0;
|
|
28
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
29
|
+
const path_1 = require("@theia/core/lib/common/path");
|
|
30
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
31
|
+
const workspace_service_1 = require("./workspace-service");
|
|
32
|
+
const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
|
|
33
|
+
let WorkspaceVariableContribution = class WorkspaceVariableContribution {
|
|
34
|
+
constructor() {
|
|
35
|
+
this.recentlyVisibleIds = [];
|
|
36
|
+
}
|
|
37
|
+
init() {
|
|
38
|
+
this.shell.onDidChangeCurrentWidget(() => this.updateCurrentWidget());
|
|
39
|
+
this.widgetManager.onDidCreateWidget(({ widget }) => {
|
|
40
|
+
if (browser_1.NavigatableWidget.is(widget)) {
|
|
41
|
+
widget.onDidChangeVisibility(() => {
|
|
42
|
+
if (widget.isVisible) {
|
|
43
|
+
this.addRecentlyVisible(widget);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.removeRecentlyVisible(widget);
|
|
47
|
+
}
|
|
48
|
+
this.updateCurrentWidget();
|
|
49
|
+
});
|
|
50
|
+
widget.onDidDispose(() => {
|
|
51
|
+
this.removeRecentlyVisible(widget);
|
|
52
|
+
this.updateCurrentWidget();
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
for (const widget of this.shell.widgets) {
|
|
57
|
+
if (browser_1.NavigatableWidget.is(widget) && widget.isVisible) {
|
|
58
|
+
this.addRecentlyVisible(widget);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
this.updateCurrentWidget();
|
|
62
|
+
}
|
|
63
|
+
get recentlyVisible() {
|
|
64
|
+
const id = this.recentlyVisibleIds[0];
|
|
65
|
+
const widget = id && this.shell.getWidgetById(id) || undefined;
|
|
66
|
+
if (browser_1.NavigatableWidget.is(widget)) {
|
|
67
|
+
return widget;
|
|
68
|
+
}
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
addRecentlyVisible(widget) {
|
|
72
|
+
this.removeRecentlyVisible(widget);
|
|
73
|
+
this.recentlyVisibleIds.unshift(widget.id);
|
|
74
|
+
}
|
|
75
|
+
removeRecentlyVisible(widget) {
|
|
76
|
+
const index = this.recentlyVisibleIds.indexOf(widget.id);
|
|
77
|
+
if (index !== -1) {
|
|
78
|
+
this.recentlyVisibleIds.splice(index, 1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
updateCurrentWidget() {
|
|
82
|
+
const { currentWidget } = this.shell;
|
|
83
|
+
if (browser_1.NavigatableWidget.is(currentWidget)) {
|
|
84
|
+
this.currentWidget = currentWidget;
|
|
85
|
+
}
|
|
86
|
+
else if (!this.currentWidget || !this.currentWidget.isVisible) {
|
|
87
|
+
this.currentWidget = this.recentlyVisible;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
registerVariables(variables) {
|
|
91
|
+
this.registerWorkspaceRootVariables(variables);
|
|
92
|
+
variables.registerVariable({
|
|
93
|
+
name: 'file',
|
|
94
|
+
description: 'The path of the currently opened file',
|
|
95
|
+
resolve: () => {
|
|
96
|
+
const uri = this.getResourceUri();
|
|
97
|
+
return uri && this.fileService.fsPath(uri);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
variables.registerVariable({
|
|
101
|
+
name: 'fileBasename',
|
|
102
|
+
description: 'The basename of the currently opened file',
|
|
103
|
+
resolve: () => {
|
|
104
|
+
const uri = this.getResourceUri();
|
|
105
|
+
return uri && uri.path.base;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
variables.registerVariable({
|
|
109
|
+
name: 'fileBasenameNoExtension',
|
|
110
|
+
description: "The currently opened file's name without extension",
|
|
111
|
+
resolve: () => {
|
|
112
|
+
const uri = this.getResourceUri();
|
|
113
|
+
return uri && uri.path.name;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
variables.registerVariable({
|
|
117
|
+
name: 'fileDirname',
|
|
118
|
+
description: "The name of the currently opened file's directory",
|
|
119
|
+
resolve: () => {
|
|
120
|
+
const uri = this.getResourceUri();
|
|
121
|
+
return uri && uri.path.dir.toString();
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
variables.registerVariable({
|
|
125
|
+
name: 'fileExtname',
|
|
126
|
+
description: 'The extension of the currently opened file',
|
|
127
|
+
resolve: () => {
|
|
128
|
+
const uri = this.getResourceUri();
|
|
129
|
+
return uri && uri.path.ext;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
registerWorkspaceRootVariables(variables) {
|
|
134
|
+
const scoped = (variable) => ({
|
|
135
|
+
name: variable.name,
|
|
136
|
+
description: variable.description,
|
|
137
|
+
resolve: (context, workspaceRootName) => {
|
|
138
|
+
const workspaceRoot = workspaceRootName && this.workspaceService.tryGetRoots().find(r => r.resource.path.name === workspaceRootName);
|
|
139
|
+
return variable.resolve(workspaceRoot ? workspaceRoot.resource : context);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
variables.registerVariable(scoped({
|
|
143
|
+
name: 'workspaceRoot',
|
|
144
|
+
description: 'The path of the workspace root folder',
|
|
145
|
+
resolve: (context) => {
|
|
146
|
+
const uri = this.getWorkspaceRootUri(context);
|
|
147
|
+
return uri && this.fileService.fsPath(uri);
|
|
148
|
+
}
|
|
149
|
+
}));
|
|
150
|
+
variables.registerVariable(scoped({
|
|
151
|
+
name: 'workspaceFolder',
|
|
152
|
+
description: 'The path of the workspace root folder',
|
|
153
|
+
resolve: (context) => {
|
|
154
|
+
const uri = this.getWorkspaceRootUri(context);
|
|
155
|
+
return uri && this.fileService.fsPath(uri);
|
|
156
|
+
}
|
|
157
|
+
}));
|
|
158
|
+
variables.registerVariable(scoped({
|
|
159
|
+
name: 'workspaceRootFolderName',
|
|
160
|
+
description: 'The name of the workspace root folder',
|
|
161
|
+
resolve: (context) => {
|
|
162
|
+
const uri = this.getWorkspaceRootUri(context);
|
|
163
|
+
return uri && uri.displayName;
|
|
164
|
+
}
|
|
165
|
+
}));
|
|
166
|
+
variables.registerVariable(scoped({
|
|
167
|
+
name: 'workspaceFolderBasename',
|
|
168
|
+
description: 'The name of the workspace root folder',
|
|
169
|
+
resolve: (context) => {
|
|
170
|
+
const uri = this.getWorkspaceRootUri(context);
|
|
171
|
+
return uri && uri.displayName;
|
|
172
|
+
}
|
|
173
|
+
}));
|
|
174
|
+
variables.registerVariable(scoped({
|
|
175
|
+
name: 'cwd',
|
|
176
|
+
description: "The task runner's current working directory on startup",
|
|
177
|
+
resolve: (context) => {
|
|
178
|
+
const uri = this.getWorkspaceRootUri(context);
|
|
179
|
+
return (uri && this.fileService.fsPath(uri)) || '';
|
|
180
|
+
}
|
|
181
|
+
}));
|
|
182
|
+
variables.registerVariable(scoped({
|
|
183
|
+
name: 'relativeFile',
|
|
184
|
+
description: "The currently opened file's path relative to the workspace root",
|
|
185
|
+
resolve: (context) => {
|
|
186
|
+
const uri = this.getResourceUri();
|
|
187
|
+
return uri && this.getWorkspaceRelativePath(uri, context);
|
|
188
|
+
}
|
|
189
|
+
}));
|
|
190
|
+
variables.registerVariable(scoped({
|
|
191
|
+
name: 'relativeFileDirname',
|
|
192
|
+
description: "The current opened file's dirname relative to ${workspaceFolder}",
|
|
193
|
+
resolve: (context) => {
|
|
194
|
+
const uri = this.getResourceUri();
|
|
195
|
+
const relativePath = uri && this.getWorkspaceRelativePath(uri, context);
|
|
196
|
+
return relativePath && new path_1.Path(relativePath).dir.toString();
|
|
197
|
+
}
|
|
198
|
+
}));
|
|
199
|
+
}
|
|
200
|
+
getWorkspaceRootUri(uri = this.getResourceUri()) {
|
|
201
|
+
return this.workspaceService.getWorkspaceRootUri(uri);
|
|
202
|
+
}
|
|
203
|
+
getResourceUri() {
|
|
204
|
+
return this.currentWidget && this.currentWidget.getResourceUri();
|
|
205
|
+
}
|
|
206
|
+
getWorkspaceRelativePath(uri, context) {
|
|
207
|
+
const workspaceRootUri = this.getWorkspaceRootUri(context || uri);
|
|
208
|
+
const path = workspaceRootUri && workspaceRootUri.path.relative(uri.path);
|
|
209
|
+
return path && path.toString();
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
__decorate([
|
|
213
|
+
(0, inversify_1.inject)(workspace_service_1.WorkspaceService),
|
|
214
|
+
__metadata("design:type", workspace_service_1.WorkspaceService)
|
|
215
|
+
], WorkspaceVariableContribution.prototype, "workspaceService", void 0);
|
|
216
|
+
__decorate([
|
|
217
|
+
(0, inversify_1.inject)(browser_1.ApplicationShell),
|
|
218
|
+
__metadata("design:type", browser_1.ApplicationShell)
|
|
219
|
+
], WorkspaceVariableContribution.prototype, "shell", void 0);
|
|
220
|
+
__decorate([
|
|
221
|
+
(0, inversify_1.inject)(file_service_1.FileService),
|
|
222
|
+
__metadata("design:type", file_service_1.FileService)
|
|
223
|
+
], WorkspaceVariableContribution.prototype, "fileService", void 0);
|
|
224
|
+
__decorate([
|
|
225
|
+
(0, inversify_1.inject)(browser_1.WidgetManager),
|
|
226
|
+
__metadata("design:type", browser_1.WidgetManager)
|
|
227
|
+
], WorkspaceVariableContribution.prototype, "widgetManager", void 0);
|
|
228
|
+
__decorate([
|
|
229
|
+
(0, inversify_1.postConstruct)(),
|
|
230
|
+
__metadata("design:type", Function),
|
|
231
|
+
__metadata("design:paramtypes", []),
|
|
232
|
+
__metadata("design:returntype", void 0)
|
|
233
|
+
], WorkspaceVariableContribution.prototype, "init", null);
|
|
234
|
+
WorkspaceVariableContribution = __decorate([
|
|
235
|
+
(0, inversify_1.injectable)()
|
|
236
|
+
], WorkspaceVariableContribution);
|
|
237
|
+
exports.WorkspaceVariableContribution = WorkspaceVariableContribution;
|
|
238
238
|
//# sourceMappingURL=workspace-variable-contribution.js.map
|