@theia/variable-resolver 1.48.1 → 1.48.2

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
@@ -1,83 +1,83 @@
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
- exports.TestVariableContribution = void 0;
19
- const jsdom_1 = require("@theia/core/lib/browser/test/jsdom");
20
- let disableJSDOM = (0, jsdom_1.enableJSDOM)();
21
- const frontend_application_config_provider_1 = require("@theia/core/lib/browser/frontend-application-config-provider");
22
- frontend_application_config_provider_1.FrontendApplicationConfigProvider.set({});
23
- const chai = require("chai");
24
- const inversify_1 = require("@theia/core/shared/inversify");
25
- const common_1 = require("@theia/core/lib/common");
26
- const mock_logger_1 = require("@theia/core/lib/common/test/mock-logger");
27
- const variable_1 = require("./variable");
28
- const variable_quick_open_service_1 = require("./variable-quick-open-service");
29
- const variable_resolver_frontend_contribution_1 = require("./variable-resolver-frontend-contribution");
30
- disableJSDOM();
31
- const expect = chai.expect;
32
- before(() => {
33
- chai.config.showDiff = true;
34
- chai.config.includeStack = true;
35
- });
36
- describe('variable-resolver-frontend-contribution', () => {
37
- let testContainer;
38
- let variableRegistry;
39
- before(() => {
40
- disableJSDOM = (0, jsdom_1.enableJSDOM)();
41
- testContainer = new inversify_1.Container();
42
- const module = new inversify_1.ContainerModule((bind, unbind, isBound, rebind) => {
43
- (0, common_1.bindContributionProvider)(bind, variable_1.VariableContribution);
44
- bind(variable_1.VariableContribution).toConstantValue(new TestVariableContribution());
45
- bind(common_1.ILogger).to(mock_logger_1.MockLogger);
46
- bind(variable_1.VariableRegistry).toSelf().inSingletonScope();
47
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
- bind(variable_quick_open_service_1.VariableQuickOpenService).toConstantValue({}); // mock VariableQuickOpenService
49
- bind(variable_resolver_frontend_contribution_1.VariableResolverFrontendContribution).toSelf();
50
- });
51
- testContainer.load(module);
52
- });
53
- after(() => {
54
- disableJSDOM();
55
- });
56
- beforeEach(() => {
57
- variableRegistry = testContainer.get(variable_1.VariableRegistry);
58
- const variableRegistrar = testContainer.get(variable_resolver_frontend_contribution_1.VariableResolverFrontendContribution);
59
- variableRegistrar.onStart();
60
- });
61
- it('should register all variables from the contribution points', () => {
62
- const variables = variableRegistry.getVariables();
63
- expect(variables.length).to.be.equal(2);
64
- expect(variables[0].name).to.be.equal('file');
65
- expect(variables[1].name).to.be.equal('lineNumber');
66
- });
67
- });
68
- class TestVariableContribution {
69
- registerVariables(variables) {
70
- variables.registerVariable({
71
- name: 'file',
72
- description: 'Resolves to file name opened in the current editor',
73
- resolve: () => Promise.resolve('package.json')
74
- });
75
- variables.registerVariable({
76
- name: 'lineNumber',
77
- description: 'Resolves to current line number',
78
- resolve: () => Promise.resolve('5')
79
- });
80
- }
81
- }
82
- exports.TestVariableContribution = TestVariableContribution;
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
+ exports.TestVariableContribution = void 0;
19
+ const jsdom_1 = require("@theia/core/lib/browser/test/jsdom");
20
+ let disableJSDOM = (0, jsdom_1.enableJSDOM)();
21
+ const frontend_application_config_provider_1 = require("@theia/core/lib/browser/frontend-application-config-provider");
22
+ frontend_application_config_provider_1.FrontendApplicationConfigProvider.set({});
23
+ const chai = require("chai");
24
+ const inversify_1 = require("@theia/core/shared/inversify");
25
+ const common_1 = require("@theia/core/lib/common");
26
+ const mock_logger_1 = require("@theia/core/lib/common/test/mock-logger");
27
+ const variable_1 = require("./variable");
28
+ const variable_quick_open_service_1 = require("./variable-quick-open-service");
29
+ const variable_resolver_frontend_contribution_1 = require("./variable-resolver-frontend-contribution");
30
+ disableJSDOM();
31
+ const expect = chai.expect;
32
+ before(() => {
33
+ chai.config.showDiff = true;
34
+ chai.config.includeStack = true;
35
+ });
36
+ describe('variable-resolver-frontend-contribution', () => {
37
+ let testContainer;
38
+ let variableRegistry;
39
+ before(() => {
40
+ disableJSDOM = (0, jsdom_1.enableJSDOM)();
41
+ testContainer = new inversify_1.Container();
42
+ const module = new inversify_1.ContainerModule((bind, unbind, isBound, rebind) => {
43
+ (0, common_1.bindContributionProvider)(bind, variable_1.VariableContribution);
44
+ bind(variable_1.VariableContribution).toConstantValue(new TestVariableContribution());
45
+ bind(common_1.ILogger).to(mock_logger_1.MockLogger);
46
+ bind(variable_1.VariableRegistry).toSelf().inSingletonScope();
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+ bind(variable_quick_open_service_1.VariableQuickOpenService).toConstantValue({}); // mock VariableQuickOpenService
49
+ bind(variable_resolver_frontend_contribution_1.VariableResolverFrontendContribution).toSelf();
50
+ });
51
+ testContainer.load(module);
52
+ });
53
+ after(() => {
54
+ disableJSDOM();
55
+ });
56
+ beforeEach(() => {
57
+ variableRegistry = testContainer.get(variable_1.VariableRegistry);
58
+ const variableRegistrar = testContainer.get(variable_resolver_frontend_contribution_1.VariableResolverFrontendContribution);
59
+ variableRegistrar.onStart();
60
+ });
61
+ it('should register all variables from the contribution points', () => {
62
+ const variables = variableRegistry.getVariables();
63
+ expect(variables.length).to.be.equal(2);
64
+ expect(variables[0].name).to.be.equal('file');
65
+ expect(variables[1].name).to.be.equal('lineNumber');
66
+ });
67
+ });
68
+ class TestVariableContribution {
69
+ registerVariables(variables) {
70
+ variables.registerVariable({
71
+ name: 'file',
72
+ description: 'Resolves to file name opened in the current editor',
73
+ resolve: () => Promise.resolve('package.json')
74
+ });
75
+ variables.registerVariable({
76
+ name: 'lineNumber',
77
+ description: 'Resolves to current line number',
78
+ resolve: () => Promise.resolve('5')
79
+ });
80
+ }
81
+ }
82
+ exports.TestVariableContribution = TestVariableContribution;
83
83
  //# sourceMappingURL=variable-resolver-frontend-contribution.spec.js.map
@@ -1,4 +1,4 @@
1
- import { ContainerModule } from '@theia/core/shared/inversify';
2
- declare const _default: ContainerModule;
3
- export default _default;
1
+ import { ContainerModule } from '@theia/core/shared/inversify';
2
+ declare const _default: ContainerModule;
3
+ export default _default;
4
4
  //# sourceMappingURL=variable-resolver-frontend-module.d.ts.map
@@ -1,38 +1,38 @@
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 inversify_1 = require("@theia/core/shared/inversify");
19
- const core_1 = require("@theia/core");
20
- const browser_1 = require("@theia/core/lib/browser");
21
- const variable_1 = require("./variable");
22
- const variable_quick_open_service_1 = require("./variable-quick-open-service");
23
- const variable_resolver_frontend_contribution_1 = require("./variable-resolver-frontend-contribution");
24
- const variable_resolver_service_1 = require("./variable-resolver-service");
25
- const common_variable_contribution_1 = require("./common-variable-contribution");
26
- exports.default = new inversify_1.ContainerModule(bind => {
27
- bind(variable_1.VariableRegistry).toSelf().inSingletonScope();
28
- bind(variable_resolver_service_1.VariableResolverService).toSelf().inSingletonScope();
29
- (0, core_1.bindContributionProvider)(bind, variable_1.VariableContribution);
30
- bind(variable_resolver_frontend_contribution_1.VariableResolverFrontendContribution).toSelf().inSingletonScope();
31
- for (const identifier of [browser_1.FrontendApplicationContribution, core_1.CommandContribution]) {
32
- bind(identifier).toService(variable_resolver_frontend_contribution_1.VariableResolverFrontendContribution);
33
- }
34
- bind(variable_quick_open_service_1.VariableQuickOpenService).toSelf().inSingletonScope();
35
- bind(common_variable_contribution_1.CommonVariableContribution).toSelf().inSingletonScope();
36
- bind(variable_1.VariableContribution).toService(common_variable_contribution_1.CommonVariableContribution);
37
- });
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 inversify_1 = require("@theia/core/shared/inversify");
19
+ const core_1 = require("@theia/core");
20
+ const browser_1 = require("@theia/core/lib/browser");
21
+ const variable_1 = require("./variable");
22
+ const variable_quick_open_service_1 = require("./variable-quick-open-service");
23
+ const variable_resolver_frontend_contribution_1 = require("./variable-resolver-frontend-contribution");
24
+ const variable_resolver_service_1 = require("./variable-resolver-service");
25
+ const common_variable_contribution_1 = require("./common-variable-contribution");
26
+ exports.default = new inversify_1.ContainerModule(bind => {
27
+ bind(variable_1.VariableRegistry).toSelf().inSingletonScope();
28
+ bind(variable_resolver_service_1.VariableResolverService).toSelf().inSingletonScope();
29
+ (0, core_1.bindContributionProvider)(bind, variable_1.VariableContribution);
30
+ bind(variable_resolver_frontend_contribution_1.VariableResolverFrontendContribution).toSelf().inSingletonScope();
31
+ for (const identifier of [browser_1.FrontendApplicationContribution, core_1.CommandContribution]) {
32
+ bind(identifier).toService(variable_resolver_frontend_contribution_1.VariableResolverFrontendContribution);
33
+ }
34
+ bind(variable_quick_open_service_1.VariableQuickOpenService).toSelf().inSingletonScope();
35
+ bind(common_variable_contribution_1.CommonVariableContribution).toSelf().inSingletonScope();
36
+ bind(variable_1.VariableContribution).toService(common_variable_contribution_1.CommonVariableContribution);
37
+ });
38
38
  //# sourceMappingURL=variable-resolver-frontend-module.js.map
@@ -1,51 +1,51 @@
1
- import { VariableRegistry } from './variable';
2
- import URI from '@theia/core/lib/common/uri';
3
- import { CommandIdVariables } from '../common/variable-types';
4
- export interface VariableResolveOptions {
5
- context?: URI;
6
- /**
7
- * Used for resolving inputs, see https://code.visualstudio.com/docs/editor/variables-reference#_input-variables
8
- */
9
- configurationSection?: string;
10
- commandIdVariables?: CommandIdVariables;
11
- configuration?: unknown;
12
- }
13
- /**
14
- * The variable resolver service should be used to resolve variables in strings.
15
- */
16
- export declare class VariableResolverService {
17
- protected static VAR_REGEXP: RegExp;
18
- protected readonly variableRegistry: VariableRegistry;
19
- /**
20
- * Resolve the variables in the given string array.
21
- * @param value The array of data to resolve variables in.
22
- * @param options Options of the variable resolution.
23
- * @returns Promise to array with variables resolved. Never rejects.
24
- *
25
- * @deprecated since 1.28.0 use {@link resolve} instead.
26
- */
27
- resolveArray(value: string[], options?: VariableResolveOptions): Promise<string[] | undefined>;
28
- /**
29
- * Resolve the variables for all strings found in the object and nested objects.
30
- * @param value Data to resolve variables in.
31
- * @param options Options of the variable resolution
32
- * @returns Promise to object with variables resolved. Returns `undefined` if a variable resolution was cancelled.
33
- */
34
- resolve<T>(value: T, options?: VariableResolveOptions): Promise<T | undefined>;
35
- protected doResolve(value: any, context: VariableResolverService.Context): Promise<any>;
36
- protected doResolveObject(obj: object, context: VariableResolverService.Context): Promise<object>;
37
- protected doResolveArray(values: Array<Object | undefined>, context: VariableResolverService.Context): Promise<Array<Object | undefined>>;
38
- protected doResolveString(value: string, context: VariableResolverService.Context): Promise<string>;
39
- protected resolveVariables(value: string, context: VariableResolverService.Context): Promise<void>;
40
- }
41
- export declare namespace VariableResolverService {
42
- class Context {
43
- protected readonly variableRegistry: VariableRegistry;
44
- protected readonly options: VariableResolveOptions;
45
- protected readonly resolved: Map<string, string | undefined>;
46
- constructor(variableRegistry: VariableRegistry, options: VariableResolveOptions);
47
- get(name: string): string | undefined;
48
- resolve(name: string): Promise<void>;
49
- }
50
- }
1
+ import { VariableRegistry } from './variable';
2
+ import URI from '@theia/core/lib/common/uri';
3
+ import { CommandIdVariables } from '../common/variable-types';
4
+ export interface VariableResolveOptions {
5
+ context?: URI;
6
+ /**
7
+ * Used for resolving inputs, see https://code.visualstudio.com/docs/editor/variables-reference#_input-variables
8
+ */
9
+ configurationSection?: string;
10
+ commandIdVariables?: CommandIdVariables;
11
+ configuration?: unknown;
12
+ }
13
+ /**
14
+ * The variable resolver service should be used to resolve variables in strings.
15
+ */
16
+ export declare class VariableResolverService {
17
+ protected static VAR_REGEXP: RegExp;
18
+ protected readonly variableRegistry: VariableRegistry;
19
+ /**
20
+ * Resolve the variables in the given string array.
21
+ * @param value The array of data to resolve variables in.
22
+ * @param options Options of the variable resolution.
23
+ * @returns Promise to array with variables resolved. Never rejects.
24
+ *
25
+ * @deprecated since 1.28.0 use {@link resolve} instead.
26
+ */
27
+ resolveArray(value: string[], options?: VariableResolveOptions): Promise<string[] | undefined>;
28
+ /**
29
+ * Resolve the variables for all strings found in the object and nested objects.
30
+ * @param value Data to resolve variables in.
31
+ * @param options Options of the variable resolution
32
+ * @returns Promise to object with variables resolved. Returns `undefined` if a variable resolution was cancelled.
33
+ */
34
+ resolve<T>(value: T, options?: VariableResolveOptions): Promise<T | undefined>;
35
+ protected doResolve(value: any, context: VariableResolverService.Context): Promise<any>;
36
+ protected doResolveObject(obj: object, context: VariableResolverService.Context): Promise<object>;
37
+ protected doResolveArray(values: Array<Object | undefined>, context: VariableResolverService.Context): Promise<Array<Object | undefined>>;
38
+ protected doResolveString(value: string, context: VariableResolverService.Context): Promise<string>;
39
+ protected resolveVariables(value: string, context: VariableResolverService.Context): Promise<void>;
40
+ }
41
+ export declare namespace VariableResolverService {
42
+ class Context {
43
+ protected readonly variableRegistry: VariableRegistry;
44
+ protected readonly options: VariableResolveOptions;
45
+ protected readonly resolved: Map<string, string | undefined>;
46
+ constructor(variableRegistry: VariableRegistry, options: VariableResolveOptions);
47
+ get(name: string): string | undefined;
48
+ resolve(name: string): Promise<void>;
49
+ }
50
+ }
51
51
  //# sourceMappingURL=variable-resolver-service.d.ts.map