@theia/variable-resolver 1.48.1 → 1.48.3

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.
Files changed (41) hide show
  1. package/README.md +114 -114
  2. package/lib/browser/common-variable-contribution.d.ts +16 -16
  3. package/lib/browser/common-variable-contribution.js +161 -161
  4. package/lib/browser/index.d.ts +3 -3
  5. package/lib/browser/index.js +21 -21
  6. package/lib/browser/variable-input-schema.d.ts +2 -2
  7. package/lib/browser/variable-input-schema.js +130 -130
  8. package/lib/browser/variable-input.d.ts +20 -20
  9. package/lib/browser/variable-input.js +2 -2
  10. package/lib/browser/variable-quick-open-service.d.ts +14 -14
  11. package/lib/browser/variable-quick-open-service.js +69 -69
  12. package/lib/browser/variable-resolver-frontend-contribution.d.ts +13 -13
  13. package/lib/browser/variable-resolver-frontend-contribution.js +53 -53
  14. package/lib/browser/variable-resolver-frontend-contribution.spec.d.ts +4 -4
  15. package/lib/browser/variable-resolver-frontend-contribution.spec.js +82 -82
  16. package/lib/browser/variable-resolver-frontend-module.d.ts +3 -3
  17. package/lib/browser/variable-resolver-frontend-module.js +37 -37
  18. package/lib/browser/variable-resolver-service.d.ts +50 -50
  19. package/lib/browser/variable-resolver-service.js +162 -162
  20. package/lib/browser/variable-resolver-service.spec.d.ts +1 -1
  21. package/lib/browser/variable-resolver-service.spec.js +75 -75
  22. package/lib/browser/variable.d.ts +55 -55
  23. package/lib/browser/variable.js +73 -73
  24. package/lib/browser/variable.spec.d.ts +1 -1
  25. package/lib/browser/variable.spec.js +90 -90
  26. package/lib/common/variable-types.d.ts +7 -7
  27. package/lib/common/variable-types.js +17 -17
  28. package/package.json +4 -4
  29. package/src/browser/common-variable-contribution.ts +151 -151
  30. package/src/browser/index.ts +19 -19
  31. package/src/browser/variable-input-schema.ts +131 -131
  32. package/src/browser/variable-input.ts +47 -47
  33. package/src/browser/variable-quick-open-service.ts +62 -62
  34. package/src/browser/variable-resolver-frontend-contribution.spec.ts +98 -98
  35. package/src/browser/variable-resolver-frontend-contribution.ts +50 -50
  36. package/src/browser/variable-resolver-frontend-module.ts +40 -40
  37. package/src/browser/variable-resolver-service.spec.ts +83 -83
  38. package/src/browser/variable-resolver-service.ts +185 -185
  39. package/src/browser/variable.spec.ts +106 -106
  40. package/src/browser/variable.ts +111 -111
  41. package/src/common/variable-types.ts +23 -23
package/README.md CHANGED
@@ -1,114 +1,114 @@
1
- <div align='center'>
2
-
3
- <br />
4
-
5
- <img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
6
-
7
- <h2>ECLIPSE THEIA - VARIABLE-RESOLVER EXTENSION</h2>
8
-
9
- <hr />
10
-
11
- </div>
12
-
13
- ## Description
14
-
15
- The `@theia/variable-resolved` extension provides variable substitution mechanism inside of strings using `${variableName}` syntax.
16
-
17
- ### Variable Contribution Point
18
- Extension provides a hook that allows any extensions to contribute its own variables.
19
- Here's the example of contributing two variables:
20
- - `${file}` - returns the name of the file opened in the current editor
21
- - `${lineNumber}` - returns the current line number in the current file
22
-
23
- ```typescript
24
- @injectable()
25
- export class EditorVariableContribution implements VariableContribution {
26
-
27
- constructor(
28
- @inject(EditorManager) protected readonly editorManager: EditorManager
29
- ) { }
30
-
31
- registerVariables(variables: VariableRegistry): void {
32
- variables.registerVariable({
33
- name: 'file',
34
- description: 'The name of the file opened in the current editor',
35
- resolve: () => {
36
- const currentEditor = this.getCurrentEditor();
37
- if (currentEditor) {
38
- return currentEditor.uri.displayName;
39
- }
40
- return undefined;
41
- }
42
- });
43
- variables.registerVariable({
44
- name: 'lineNumber',
45
- description: 'The current line number in the current file',
46
- resolve: () => {
47
- const currentEditor = this.getCurrentEditor();
48
- if (currentEditor) {
49
- return `${currentEditor.cursor.line + 1}`;
50
- }
51
- return undefined;
52
- }
53
- });
54
- }
55
-
56
- protected getCurrentEditor(): TextEditor | undefined {
57
- const currentEditor = this.editorManager.currentEditor;
58
- if (currentEditor) {
59
- return currentEditor.editor;
60
- }
61
- return undefined;
62
- }
63
- }
64
- ```
65
-
66
- Note that a Variable is resolved to `MaybePromise<string | undefined>` which means that it can be resolved synchronously or within a Promise.
67
-
68
- ### Using the Variable Resolver Service
69
-
70
- There's the example of how one can use Variable Resolver Service in its own plugin:
71
- ```typescript
72
- @injectable()
73
- export class MyService {
74
-
75
- constructor(
76
- @inject(VariableResolverService) protected readonly variableResolver: VariableResolverService
77
- ) { }
78
-
79
- async resolve(): Promise<void> {
80
- const text = 'cursor is in file ${file} on line ${lineNumber}';
81
- const resolved = await this.variableResolver.resolve(text);
82
- console.log(resolved);
83
- }
84
- }
85
- ```
86
-
87
- If `package.json` file is currently opened and cursor is on line 5 then the following output will be logged to the console:
88
- ```
89
- cursor is in file package.json on line 5
90
- ```
91
-
92
- ## Additional Information
93
-
94
- - [API documentation for `@theia/variable-resolver`](https://eclipse-theia.github.io/theia/docs/next/modules/variable_resolver.html)
95
- - [Theia - GitHub](https://github.com/eclipse-theia/theia)
96
- - [Theia - Website](https://theia-ide.org/)
97
-
98
- ## License
99
-
100
- - [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
101
- - [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
102
-
103
- ## Trademark
104
- "Theia" is a trademark of the Eclipse Foundation
105
- https://www.eclipse.org/theia
106
-
107
-
108
- # Theia - Variable Resolver Extension
109
-
110
- The extension
111
-
112
- ## License
113
- - [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
114
- - [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
1
+ <div align='center'>
2
+
3
+ <br />
4
+
5
+ <img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
6
+
7
+ <h2>ECLIPSE THEIA - VARIABLE-RESOLVER EXTENSION</h2>
8
+
9
+ <hr />
10
+
11
+ </div>
12
+
13
+ ## Description
14
+
15
+ The `@theia/variable-resolved` extension provides variable substitution mechanism inside of strings using `${variableName}` syntax.
16
+
17
+ ### Variable Contribution Point
18
+ Extension provides a hook that allows any extensions to contribute its own variables.
19
+ Here's the example of contributing two variables:
20
+ - `${file}` - returns the name of the file opened in the current editor
21
+ - `${lineNumber}` - returns the current line number in the current file
22
+
23
+ ```typescript
24
+ @injectable()
25
+ export class EditorVariableContribution implements VariableContribution {
26
+
27
+ constructor(
28
+ @inject(EditorManager) protected readonly editorManager: EditorManager
29
+ ) { }
30
+
31
+ registerVariables(variables: VariableRegistry): void {
32
+ variables.registerVariable({
33
+ name: 'file',
34
+ description: 'The name of the file opened in the current editor',
35
+ resolve: () => {
36
+ const currentEditor = this.getCurrentEditor();
37
+ if (currentEditor) {
38
+ return currentEditor.uri.displayName;
39
+ }
40
+ return undefined;
41
+ }
42
+ });
43
+ variables.registerVariable({
44
+ name: 'lineNumber',
45
+ description: 'The current line number in the current file',
46
+ resolve: () => {
47
+ const currentEditor = this.getCurrentEditor();
48
+ if (currentEditor) {
49
+ return `${currentEditor.cursor.line + 1}`;
50
+ }
51
+ return undefined;
52
+ }
53
+ });
54
+ }
55
+
56
+ protected getCurrentEditor(): TextEditor | undefined {
57
+ const currentEditor = this.editorManager.currentEditor;
58
+ if (currentEditor) {
59
+ return currentEditor.editor;
60
+ }
61
+ return undefined;
62
+ }
63
+ }
64
+ ```
65
+
66
+ Note that a Variable is resolved to `MaybePromise<string | undefined>` which means that it can be resolved synchronously or within a Promise.
67
+
68
+ ### Using the Variable Resolver Service
69
+
70
+ There's the example of how one can use Variable Resolver Service in its own plugin:
71
+ ```typescript
72
+ @injectable()
73
+ export class MyService {
74
+
75
+ constructor(
76
+ @inject(VariableResolverService) protected readonly variableResolver: VariableResolverService
77
+ ) { }
78
+
79
+ async resolve(): Promise<void> {
80
+ const text = 'cursor is in file ${file} on line ${lineNumber}';
81
+ const resolved = await this.variableResolver.resolve(text);
82
+ console.log(resolved);
83
+ }
84
+ }
85
+ ```
86
+
87
+ If `package.json` file is currently opened and cursor is on line 5 then the following output will be logged to the console:
88
+ ```
89
+ cursor is in file package.json on line 5
90
+ ```
91
+
92
+ ## Additional Information
93
+
94
+ - [API documentation for `@theia/variable-resolver`](https://eclipse-theia.github.io/theia/docs/next/modules/variable_resolver.html)
95
+ - [Theia - GitHub](https://github.com/eclipse-theia/theia)
96
+ - [Theia - Website](https://theia-ide.org/)
97
+
98
+ ## License
99
+
100
+ - [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
101
+ - [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
102
+
103
+ ## Trademark
104
+ "Theia" is a trademark of the Eclipse Foundation
105
+ https://www.eclipse.org/theia
106
+
107
+
108
+ # Theia - Variable Resolver Extension
109
+
110
+ The extension
111
+
112
+ ## License
113
+ - [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
114
+ - [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
@@ -1,17 +1,17 @@
1
- import { VariableContribution, VariableRegistry } from './variable';
2
- import { ApplicationServer } from '@theia/core/lib/common/application-protocol';
3
- import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
4
- import { CommandService } from '@theia/core/lib/common/command';
5
- import { PreferenceService } from '@theia/core/lib/browser/preferences/preference-service';
6
- import { ResourceContextKey } from '@theia/core/lib/browser/resource-context-key';
7
- import { QuickInputService } from '@theia/core/lib/browser';
8
- export declare class CommonVariableContribution implements VariableContribution {
9
- protected readonly env: EnvVariablesServer;
10
- protected readonly commands: CommandService;
11
- protected readonly preferences: PreferenceService;
12
- protected readonly resourceContextKey: ResourceContextKey;
13
- protected readonly quickInputService: QuickInputService;
14
- protected readonly appServer: ApplicationServer;
15
- registerVariables(variables: VariableRegistry): Promise<void>;
16
- }
1
+ import { VariableContribution, VariableRegistry } from './variable';
2
+ import { ApplicationServer } from '@theia/core/lib/common/application-protocol';
3
+ import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
4
+ import { CommandService } from '@theia/core/lib/common/command';
5
+ import { PreferenceService } from '@theia/core/lib/browser/preferences/preference-service';
6
+ import { ResourceContextKey } from '@theia/core/lib/browser/resource-context-key';
7
+ import { QuickInputService } from '@theia/core/lib/browser';
8
+ export declare class CommonVariableContribution implements VariableContribution {
9
+ protected readonly env: EnvVariablesServer;
10
+ protected readonly commands: CommandService;
11
+ protected readonly preferences: PreferenceService;
12
+ protected readonly resourceContextKey: ResourceContextKey;
13
+ protected readonly quickInputService: QuickInputService;
14
+ protected readonly appServer: ApplicationServer;
15
+ registerVariables(variables: VariableRegistry): Promise<void>;
16
+ }
17
17
  //# sourceMappingURL=common-variable-contribution.d.ts.map
@@ -1,162 +1,162 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2019 TypeFox 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
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.CommonVariableContribution = void 0;
19
- const tslib_1 = require("tslib");
20
- const inversify_1 = require("@theia/core/shared/inversify");
21
- const application_protocol_1 = require("@theia/core/lib/common/application-protocol");
22
- const env_variables_1 = require("@theia/core/lib/common/env-variables");
23
- const command_1 = require("@theia/core/lib/common/command");
24
- const os_1 = require("@theia/core/lib/common/os");
25
- const preference_service_1 = require("@theia/core/lib/browser/preferences/preference-service");
26
- const resource_context_key_1 = require("@theia/core/lib/browser/resource-context-key");
27
- const browser_1 = require("@theia/core/lib/browser");
28
- const cancellation_1 = require("@theia/core/lib/common/cancellation");
29
- const uri_1 = require("@theia/core/lib/common/uri");
30
- let CommonVariableContribution = class CommonVariableContribution {
31
- async registerVariables(variables) {
32
- const execPath = await this.env.getExecPath();
33
- variables.registerVariable({
34
- name: 'execPath',
35
- resolve: () => execPath
36
- });
37
- variables.registerVariable({
38
- name: 'pathSeparator',
39
- resolve: () => os_1.OS.backend.isWindows ? '\\' : '/'
40
- });
41
- variables.registerVariable({
42
- name: 'env',
43
- resolve: async (_, envVariableName) => {
44
- const envVariable = envVariableName && await this.env.getValue(envVariableName);
45
- const envValue = envVariable && envVariable.value;
46
- return envValue || '';
47
- }
48
- });
49
- variables.registerVariable({
50
- name: 'config',
51
- resolve: (resourceUri = new uri_1.default(this.resourceContextKey.get()), preferenceName) => {
52
- if (!preferenceName) {
53
- return undefined;
54
- }
55
- return this.preferences.get(preferenceName, undefined, resourceUri && resourceUri.toString());
56
- }
57
- });
58
- variables.registerVariable({
59
- name: 'command',
60
- resolve: async (contextUri, commandId, configurationSection, commandIdVariables, configuration) => {
61
- if (commandId) {
62
- if (commandIdVariables === null || commandIdVariables === void 0 ? void 0 : commandIdVariables[commandId]) {
63
- commandId = commandIdVariables[commandId];
64
- }
65
- const result = await this.commands.executeCommand(commandId, configuration);
66
- // eslint-disable-next-line no-null/no-null
67
- if (result === null) {
68
- throw (0, cancellation_1.cancelled)();
69
- }
70
- return result;
71
- }
72
- }
73
- });
74
- variables.registerVariable({
75
- name: 'input',
76
- resolve: async (resourceUri = new uri_1.default(this.resourceContextKey.get()), variable, section) => {
77
- var _a, _b;
78
- if (!variable || !section) {
79
- return undefined;
80
- }
81
- const configuration = this.preferences.get(section, undefined, resourceUri && resourceUri.toString());
82
- const inputs = !!configuration && 'inputs' in configuration ? configuration.inputs : undefined;
83
- const input = Array.isArray(inputs) && inputs.find(item => !!item && item.id === variable);
84
- if (!input) {
85
- return undefined;
86
- }
87
- if (input.type === 'promptString') {
88
- if (typeof input.description !== 'string') {
89
- return undefined;
90
- }
91
- return (_a = this.quickInputService) === null || _a === void 0 ? void 0 : _a.input({
92
- prompt: input.description,
93
- value: input.default
94
- });
95
- }
96
- if (input.type === 'pickString') {
97
- if (typeof input.description !== 'string' || !Array.isArray(input.options)) {
98
- return undefined;
99
- }
100
- const elements = [];
101
- for (const option of input.options) {
102
- if (typeof option !== 'string') {
103
- return undefined;
104
- }
105
- if (option === input.default) {
106
- elements.unshift({
107
- description: 'Default',
108
- label: option,
109
- value: option
110
- });
111
- }
112
- else {
113
- elements.push({
114
- label: option,
115
- value: option
116
- });
117
- }
118
- }
119
- const selectedPick = await ((_b = this.quickInputService) === null || _b === void 0 ? void 0 : _b.showQuickPick(elements, { placeholder: input.description }));
120
- return selectedPick === null || selectedPick === void 0 ? void 0 : selectedPick.value;
121
- }
122
- if (input.type === 'command') {
123
- if (typeof input.command !== 'string') {
124
- return undefined;
125
- }
126
- return this.commands.executeCommand(input.command, input.args);
127
- }
128
- return undefined;
129
- }
130
- });
131
- }
132
- };
133
- (0, tslib_1.__decorate)([
134
- (0, inversify_1.inject)(env_variables_1.EnvVariablesServer),
135
- (0, tslib_1.__metadata)("design:type", Object)
136
- ], CommonVariableContribution.prototype, "env", void 0);
137
- (0, tslib_1.__decorate)([
138
- (0, inversify_1.inject)(command_1.CommandService),
139
- (0, tslib_1.__metadata)("design:type", Object)
140
- ], CommonVariableContribution.prototype, "commands", void 0);
141
- (0, tslib_1.__decorate)([
142
- (0, inversify_1.inject)(preference_service_1.PreferenceService),
143
- (0, tslib_1.__metadata)("design:type", Object)
144
- ], CommonVariableContribution.prototype, "preferences", void 0);
145
- (0, tslib_1.__decorate)([
146
- (0, inversify_1.inject)(resource_context_key_1.ResourceContextKey),
147
- (0, tslib_1.__metadata)("design:type", resource_context_key_1.ResourceContextKey)
148
- ], CommonVariableContribution.prototype, "resourceContextKey", void 0);
149
- (0, tslib_1.__decorate)([
150
- (0, inversify_1.inject)(browser_1.QuickInputService),
151
- (0, inversify_1.optional)(),
152
- (0, tslib_1.__metadata)("design:type", Object)
153
- ], CommonVariableContribution.prototype, "quickInputService", void 0);
154
- (0, tslib_1.__decorate)([
155
- (0, inversify_1.inject)(application_protocol_1.ApplicationServer),
156
- (0, tslib_1.__metadata)("design:type", Object)
157
- ], CommonVariableContribution.prototype, "appServer", void 0);
158
- CommonVariableContribution = (0, tslib_1.__decorate)([
159
- (0, inversify_1.injectable)()
160
- ], CommonVariableContribution);
161
- exports.CommonVariableContribution = CommonVariableContribution;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2019 TypeFox 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
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.CommonVariableContribution = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const inversify_1 = require("@theia/core/shared/inversify");
21
+ const application_protocol_1 = require("@theia/core/lib/common/application-protocol");
22
+ const env_variables_1 = require("@theia/core/lib/common/env-variables");
23
+ const command_1 = require("@theia/core/lib/common/command");
24
+ const os_1 = require("@theia/core/lib/common/os");
25
+ const preference_service_1 = require("@theia/core/lib/browser/preferences/preference-service");
26
+ const resource_context_key_1 = require("@theia/core/lib/browser/resource-context-key");
27
+ const browser_1 = require("@theia/core/lib/browser");
28
+ const cancellation_1 = require("@theia/core/lib/common/cancellation");
29
+ const uri_1 = require("@theia/core/lib/common/uri");
30
+ let CommonVariableContribution = class CommonVariableContribution {
31
+ async registerVariables(variables) {
32
+ const execPath = await this.env.getExecPath();
33
+ variables.registerVariable({
34
+ name: 'execPath',
35
+ resolve: () => execPath
36
+ });
37
+ variables.registerVariable({
38
+ name: 'pathSeparator',
39
+ resolve: () => os_1.OS.backend.isWindows ? '\\' : '/'
40
+ });
41
+ variables.registerVariable({
42
+ name: 'env',
43
+ resolve: async (_, envVariableName) => {
44
+ const envVariable = envVariableName && await this.env.getValue(envVariableName);
45
+ const envValue = envVariable && envVariable.value;
46
+ return envValue || '';
47
+ }
48
+ });
49
+ variables.registerVariable({
50
+ name: 'config',
51
+ resolve: (resourceUri = new uri_1.default(this.resourceContextKey.get()), preferenceName) => {
52
+ if (!preferenceName) {
53
+ return undefined;
54
+ }
55
+ return this.preferences.get(preferenceName, undefined, resourceUri && resourceUri.toString());
56
+ }
57
+ });
58
+ variables.registerVariable({
59
+ name: 'command',
60
+ resolve: async (contextUri, commandId, configurationSection, commandIdVariables, configuration) => {
61
+ if (commandId) {
62
+ if (commandIdVariables === null || commandIdVariables === void 0 ? void 0 : commandIdVariables[commandId]) {
63
+ commandId = commandIdVariables[commandId];
64
+ }
65
+ const result = await this.commands.executeCommand(commandId, configuration);
66
+ // eslint-disable-next-line no-null/no-null
67
+ if (result === null) {
68
+ throw (0, cancellation_1.cancelled)();
69
+ }
70
+ return result;
71
+ }
72
+ }
73
+ });
74
+ variables.registerVariable({
75
+ name: 'input',
76
+ resolve: async (resourceUri = new uri_1.default(this.resourceContextKey.get()), variable, section) => {
77
+ var _a, _b;
78
+ if (!variable || !section) {
79
+ return undefined;
80
+ }
81
+ const configuration = this.preferences.get(section, undefined, resourceUri && resourceUri.toString());
82
+ const inputs = !!configuration && 'inputs' in configuration ? configuration.inputs : undefined;
83
+ const input = Array.isArray(inputs) && inputs.find(item => !!item && item.id === variable);
84
+ if (!input) {
85
+ return undefined;
86
+ }
87
+ if (input.type === 'promptString') {
88
+ if (typeof input.description !== 'string') {
89
+ return undefined;
90
+ }
91
+ return (_a = this.quickInputService) === null || _a === void 0 ? void 0 : _a.input({
92
+ prompt: input.description,
93
+ value: input.default
94
+ });
95
+ }
96
+ if (input.type === 'pickString') {
97
+ if (typeof input.description !== 'string' || !Array.isArray(input.options)) {
98
+ return undefined;
99
+ }
100
+ const elements = [];
101
+ for (const option of input.options) {
102
+ if (typeof option !== 'string') {
103
+ return undefined;
104
+ }
105
+ if (option === input.default) {
106
+ elements.unshift({
107
+ description: 'Default',
108
+ label: option,
109
+ value: option
110
+ });
111
+ }
112
+ else {
113
+ elements.push({
114
+ label: option,
115
+ value: option
116
+ });
117
+ }
118
+ }
119
+ const selectedPick = await ((_b = this.quickInputService) === null || _b === void 0 ? void 0 : _b.showQuickPick(elements, { placeholder: input.description }));
120
+ return selectedPick === null || selectedPick === void 0 ? void 0 : selectedPick.value;
121
+ }
122
+ if (input.type === 'command') {
123
+ if (typeof input.command !== 'string') {
124
+ return undefined;
125
+ }
126
+ return this.commands.executeCommand(input.command, input.args);
127
+ }
128
+ return undefined;
129
+ }
130
+ });
131
+ }
132
+ };
133
+ (0, tslib_1.__decorate)([
134
+ (0, inversify_1.inject)(env_variables_1.EnvVariablesServer),
135
+ (0, tslib_1.__metadata)("design:type", Object)
136
+ ], CommonVariableContribution.prototype, "env", void 0);
137
+ (0, tslib_1.__decorate)([
138
+ (0, inversify_1.inject)(command_1.CommandService),
139
+ (0, tslib_1.__metadata)("design:type", Object)
140
+ ], CommonVariableContribution.prototype, "commands", void 0);
141
+ (0, tslib_1.__decorate)([
142
+ (0, inversify_1.inject)(preference_service_1.PreferenceService),
143
+ (0, tslib_1.__metadata)("design:type", Object)
144
+ ], CommonVariableContribution.prototype, "preferences", void 0);
145
+ (0, tslib_1.__decorate)([
146
+ (0, inversify_1.inject)(resource_context_key_1.ResourceContextKey),
147
+ (0, tslib_1.__metadata)("design:type", resource_context_key_1.ResourceContextKey)
148
+ ], CommonVariableContribution.prototype, "resourceContextKey", void 0);
149
+ (0, tslib_1.__decorate)([
150
+ (0, inversify_1.inject)(browser_1.QuickInputService),
151
+ (0, inversify_1.optional)(),
152
+ (0, tslib_1.__metadata)("design:type", Object)
153
+ ], CommonVariableContribution.prototype, "quickInputService", void 0);
154
+ (0, tslib_1.__decorate)([
155
+ (0, inversify_1.inject)(application_protocol_1.ApplicationServer),
156
+ (0, tslib_1.__metadata)("design:type", Object)
157
+ ], CommonVariableContribution.prototype, "appServer", void 0);
158
+ CommonVariableContribution = (0, tslib_1.__decorate)([
159
+ (0, inversify_1.injectable)()
160
+ ], CommonVariableContribution);
161
+ exports.CommonVariableContribution = CommonVariableContribution;
162
162
  //# sourceMappingURL=common-variable-contribution.js.map
@@ -1,4 +1,4 @@
1
- export * from './variable';
2
- export * from './variable-quick-open-service';
3
- export * from './variable-resolver-service';
1
+ export * from './variable';
2
+ export * from './variable-quick-open-service';
3
+ export * from './variable-resolver-service';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,22 +1,22 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
18
- const tslib_1 = require("tslib");
19
- (0, tslib_1.__exportStar)(require("./variable"), exports);
20
- (0, tslib_1.__exportStar)(require("./variable-quick-open-service"), exports);
21
- (0, tslib_1.__exportStar)(require("./variable-resolver-service"), exports);
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
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const tslib_1 = require("tslib");
19
+ (0, tslib_1.__exportStar)(require("./variable"), exports);
20
+ (0, tslib_1.__exportStar)(require("./variable-quick-open-service"), exports);
21
+ (0, tslib_1.__exportStar)(require("./variable-resolver-service"), exports);
22
22
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,3 @@
1
- import { IJSONSchema } from '@theia/core/lib/common/json-schema';
2
- export declare const inputsSchema: IJSONSchema;
1
+ import { IJSONSchema } from '@theia/core/lib/common/json-schema';
2
+ export declare const inputsSchema: IJSONSchema;
3
3
  //# sourceMappingURL=variable-input-schema.d.ts.map