@theia/variable-resolver 1.53.0-next.55 → 1.53.0-next.64
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 +114 -114
- package/package.json +3 -3
- package/src/browser/common-variable-contribution.ts +151 -151
- package/src/browser/index.ts +19 -19
- package/src/browser/variable-input-schema.ts +131 -131
- package/src/browser/variable-input.ts +47 -47
- package/src/browser/variable-quick-open-service.ts +62 -62
- package/src/browser/variable-resolver-frontend-contribution.spec.ts +98 -98
- package/src/browser/variable-resolver-frontend-contribution.ts +50 -50
- package/src/browser/variable-resolver-frontend-module.ts +40 -40
- package/src/browser/variable-resolver-service.spec.ts +83 -83
- package/src/browser/variable-resolver-service.ts +185 -185
- package/src/browser/variable.spec.ts +106 -106
- package/src/browser/variable.ts +111 -111
- package/src/common/variable-types.ts +23 -23
package/src/browser/variable.ts
CHANGED
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable } from '@theia/core/shared/inversify';
|
|
18
|
-
import { Disposable, DisposableCollection, MaybePromise } from '@theia/core';
|
|
19
|
-
import URI from '@theia/core/lib/common/uri';
|
|
20
|
-
import { CommandIdVariables } from '../common/variable-types';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Variable can be used inside of strings using ${variableName} syntax.
|
|
24
|
-
*/
|
|
25
|
-
export interface Variable {
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* A unique name of this variable.
|
|
29
|
-
*/
|
|
30
|
-
readonly name: string;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* A human-readable description of this variable.
|
|
34
|
-
*/
|
|
35
|
-
readonly description?: string;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Resolve to a string value of this variable or
|
|
39
|
-
* `undefined` if variable cannot be resolved.
|
|
40
|
-
* Never reject.
|
|
41
|
-
*/
|
|
42
|
-
resolve(
|
|
43
|
-
context?: URI,
|
|
44
|
-
argument?: string,
|
|
45
|
-
configurationSection?: string,
|
|
46
|
-
commandIdVariables?: CommandIdVariables,
|
|
47
|
-
configuration?: unknown
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
-
): MaybePromise<any>;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export const VariableContribution = Symbol('VariableContribution');
|
|
53
|
-
/**
|
|
54
|
-
* The variable contribution should be implemented to register custom variables.
|
|
55
|
-
*/
|
|
56
|
-
export interface VariableContribution {
|
|
57
|
-
registerVariables(variables: VariableRegistry): void;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* The variable registry manages variables.
|
|
62
|
-
*/
|
|
63
|
-
@injectable()
|
|
64
|
-
export class VariableRegistry implements Disposable {
|
|
65
|
-
|
|
66
|
-
protected readonly variables: Map<string, Variable> = new Map();
|
|
67
|
-
protected readonly toDispose = new DisposableCollection();
|
|
68
|
-
|
|
69
|
-
dispose(): void {
|
|
70
|
-
this.toDispose.dispose();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Register the given variable.
|
|
75
|
-
* Do nothing if a variable is already registered for the given variable name.
|
|
76
|
-
*/
|
|
77
|
-
registerVariable(variable: Variable): Disposable {
|
|
78
|
-
if (this.variables.has(variable.name)) {
|
|
79
|
-
console.warn(`A variables with name ${variable.name} is already registered.`);
|
|
80
|
-
return Disposable.NULL;
|
|
81
|
-
}
|
|
82
|
-
this.variables.set(variable.name, variable);
|
|
83
|
-
const disposable = {
|
|
84
|
-
dispose: () => this.variables.delete(variable.name)
|
|
85
|
-
};
|
|
86
|
-
this.toDispose.push(disposable);
|
|
87
|
-
return disposable;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Return all registered variables.
|
|
92
|
-
*/
|
|
93
|
-
getVariables(): Variable[] {
|
|
94
|
-
return [...this.variables.values()];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Get a variable for the given name or `undefined` if none.
|
|
99
|
-
*/
|
|
100
|
-
getVariable(name: string): Variable | undefined {
|
|
101
|
-
return this.variables.get(name);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Register an array of variables.
|
|
106
|
-
* Do nothing if a variable is already registered for the given variable name.
|
|
107
|
-
*/
|
|
108
|
-
registerVariables(variables: Variable[]): Disposable[] {
|
|
109
|
-
return variables.map(v => this.registerVariable(v));
|
|
110
|
-
}
|
|
111
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
18
|
+
import { Disposable, DisposableCollection, MaybePromise } from '@theia/core';
|
|
19
|
+
import URI from '@theia/core/lib/common/uri';
|
|
20
|
+
import { CommandIdVariables } from '../common/variable-types';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Variable can be used inside of strings using ${variableName} syntax.
|
|
24
|
+
*/
|
|
25
|
+
export interface Variable {
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A unique name of this variable.
|
|
29
|
+
*/
|
|
30
|
+
readonly name: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A human-readable description of this variable.
|
|
34
|
+
*/
|
|
35
|
+
readonly description?: string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Resolve to a string value of this variable or
|
|
39
|
+
* `undefined` if variable cannot be resolved.
|
|
40
|
+
* Never reject.
|
|
41
|
+
*/
|
|
42
|
+
resolve(
|
|
43
|
+
context?: URI,
|
|
44
|
+
argument?: string,
|
|
45
|
+
configurationSection?: string,
|
|
46
|
+
commandIdVariables?: CommandIdVariables,
|
|
47
|
+
configuration?: unknown
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
+
): MaybePromise<any>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const VariableContribution = Symbol('VariableContribution');
|
|
53
|
+
/**
|
|
54
|
+
* The variable contribution should be implemented to register custom variables.
|
|
55
|
+
*/
|
|
56
|
+
export interface VariableContribution {
|
|
57
|
+
registerVariables(variables: VariableRegistry): void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The variable registry manages variables.
|
|
62
|
+
*/
|
|
63
|
+
@injectable()
|
|
64
|
+
export class VariableRegistry implements Disposable {
|
|
65
|
+
|
|
66
|
+
protected readonly variables: Map<string, Variable> = new Map();
|
|
67
|
+
protected readonly toDispose = new DisposableCollection();
|
|
68
|
+
|
|
69
|
+
dispose(): void {
|
|
70
|
+
this.toDispose.dispose();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Register the given variable.
|
|
75
|
+
* Do nothing if a variable is already registered for the given variable name.
|
|
76
|
+
*/
|
|
77
|
+
registerVariable(variable: Variable): Disposable {
|
|
78
|
+
if (this.variables.has(variable.name)) {
|
|
79
|
+
console.warn(`A variables with name ${variable.name} is already registered.`);
|
|
80
|
+
return Disposable.NULL;
|
|
81
|
+
}
|
|
82
|
+
this.variables.set(variable.name, variable);
|
|
83
|
+
const disposable = {
|
|
84
|
+
dispose: () => this.variables.delete(variable.name)
|
|
85
|
+
};
|
|
86
|
+
this.toDispose.push(disposable);
|
|
87
|
+
return disposable;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Return all registered variables.
|
|
92
|
+
*/
|
|
93
|
+
getVariables(): Variable[] {
|
|
94
|
+
return [...this.variables.values()];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Get a variable for the given name or `undefined` if none.
|
|
99
|
+
*/
|
|
100
|
+
getVariable(name: string): Variable | undefined {
|
|
101
|
+
return this.variables.get(name);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Register an array of variables.
|
|
106
|
+
* Do nothing if a variable is already registered for the given variable name.
|
|
107
|
+
*/
|
|
108
|
+
registerVariables(variables: Variable[]): Disposable[] {
|
|
109
|
+
return variables.map(v => this.registerVariable(v));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2022 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Holds variable-names to command id mappings (e.g. Provided by specific plugins / extensions)
|
|
19
|
-
* see "variables": https://code.visualstudio.com/api/references/contribution-points#contributes.debuggers
|
|
20
|
-
*/
|
|
21
|
-
export interface CommandIdVariables {
|
|
22
|
-
[id: string]: string
|
|
23
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2022 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Holds variable-names to command id mappings (e.g. Provided by specific plugins / extensions)
|
|
19
|
+
* see "variables": https://code.visualstudio.com/api/references/contribution-points#contributes.debuggers
|
|
20
|
+
*/
|
|
21
|
+
export interface CommandIdVariables {
|
|
22
|
+
[id: string]: string
|
|
23
|
+
}
|