@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.
- package/README.md +114 -114
- package/lib/browser/common-variable-contribution.d.ts +16 -16
- package/lib/browser/common-variable-contribution.js +161 -161
- package/lib/browser/index.d.ts +3 -3
- package/lib/browser/index.js +21 -21
- package/lib/browser/variable-input-schema.d.ts +2 -2
- package/lib/browser/variable-input-schema.js +130 -130
- package/lib/browser/variable-input.d.ts +20 -20
- package/lib/browser/variable-input.js +2 -2
- package/lib/browser/variable-quick-open-service.d.ts +14 -14
- package/lib/browser/variable-quick-open-service.js +69 -69
- package/lib/browser/variable-resolver-frontend-contribution.d.ts +13 -13
- package/lib/browser/variable-resolver-frontend-contribution.js +53 -53
- package/lib/browser/variable-resolver-frontend-contribution.spec.d.ts +4 -4
- package/lib/browser/variable-resolver-frontend-contribution.spec.js +82 -82
- package/lib/browser/variable-resolver-frontend-module.d.ts +3 -3
- package/lib/browser/variable-resolver-frontend-module.js +37 -37
- package/lib/browser/variable-resolver-service.d.ts +50 -50
- package/lib/browser/variable-resolver-service.js +162 -162
- package/lib/browser/variable-resolver-service.spec.d.ts +1 -1
- package/lib/browser/variable-resolver-service.spec.js +75 -75
- package/lib/browser/variable.d.ts +55 -55
- package/lib/browser/variable.js +73 -73
- package/lib/browser/variable.spec.d.ts +1 -1
- package/lib/browser/variable.spec.js +90 -90
- package/lib/common/variable-types.d.ts +7 -7
- package/lib/common/variable-types.js +17 -17
- package/package.json +4 -4
- 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
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 TypeFox 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
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
18
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
19
|
-
*--------------------------------------------------------------------------------------------*/
|
|
20
|
-
/*
|
|
21
|
-
* copied from
|
|
22
|
-
* https://github.com/microsoft/vscode/blob/0a34756cae4fc67739e60c708b04637089f8bb0d/src/vs/workbench/services/configurationResolver/common/configurationResolver.ts#L41-L63
|
|
23
|
-
*/
|
|
24
|
-
export interface VariablePromptStringInput {
|
|
25
|
-
id: string;
|
|
26
|
-
type: 'promptString';
|
|
27
|
-
description: string;
|
|
28
|
-
default?: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface VariablePickStringInput {
|
|
32
|
-
id: string;
|
|
33
|
-
type: 'pickString';
|
|
34
|
-
description: string;
|
|
35
|
-
options: string[];
|
|
36
|
-
default?: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface VariableCommandInput {
|
|
40
|
-
id: string;
|
|
41
|
-
type: 'command';
|
|
42
|
-
command: string;
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
-
args?: any;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export type VariableInput = VariablePromptStringInput | VariablePickStringInput | VariableCommandInput;
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 TypeFox 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
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
18
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
19
|
+
*--------------------------------------------------------------------------------------------*/
|
|
20
|
+
/*
|
|
21
|
+
* copied from
|
|
22
|
+
* https://github.com/microsoft/vscode/blob/0a34756cae4fc67739e60c708b04637089f8bb0d/src/vs/workbench/services/configurationResolver/common/configurationResolver.ts#L41-L63
|
|
23
|
+
*/
|
|
24
|
+
export interface VariablePromptStringInput {
|
|
25
|
+
id: string;
|
|
26
|
+
type: 'promptString';
|
|
27
|
+
description: string;
|
|
28
|
+
default?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface VariablePickStringInput {
|
|
32
|
+
id: string;
|
|
33
|
+
type: 'pickString';
|
|
34
|
+
description: string;
|
|
35
|
+
options: string[];
|
|
36
|
+
default?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface VariableCommandInput {
|
|
40
|
+
id: string;
|
|
41
|
+
type: 'command';
|
|
42
|
+
command: string;
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
+
args?: any;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type VariableInput = VariablePromptStringInput | VariablePickStringInput | VariableCommandInput;
|
|
@@ -1,62 +1,62 @@
|
|
|
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 { inject, injectable, optional } from '@theia/core/shared/inversify';
|
|
18
|
-
import { MessageService } from '@theia/core/lib/common/message-service';
|
|
19
|
-
import { VariableRegistry, Variable } from './variable';
|
|
20
|
-
import { VariableResolverService } from './variable-resolver-service';
|
|
21
|
-
import { QuickPickItem, QuickInputService } from '@theia/core/lib/browser';
|
|
22
|
-
|
|
23
|
-
@injectable()
|
|
24
|
-
export class VariableQuickOpenService {
|
|
25
|
-
|
|
26
|
-
protected items: Array<QuickPickItem>;
|
|
27
|
-
|
|
28
|
-
@inject(MessageService)
|
|
29
|
-
protected readonly messages: MessageService;
|
|
30
|
-
|
|
31
|
-
@inject(QuickInputService) @optional()
|
|
32
|
-
protected readonly quickInputService: QuickInputService;
|
|
33
|
-
|
|
34
|
-
@inject(VariableResolverService)
|
|
35
|
-
protected readonly variableResolver: VariableResolverService;
|
|
36
|
-
|
|
37
|
-
constructor(
|
|
38
|
-
@inject(VariableRegistry) protected readonly variableRegistry: VariableRegistry
|
|
39
|
-
) { }
|
|
40
|
-
|
|
41
|
-
open(): void {
|
|
42
|
-
this.items = this.variableRegistry.getVariables().map(v => ({
|
|
43
|
-
label: '${' + v.name + '}',
|
|
44
|
-
detail: v.description,
|
|
45
|
-
execute: () => {
|
|
46
|
-
setTimeout(() => this.showValue(v));
|
|
47
|
-
}
|
|
48
|
-
}));
|
|
49
|
-
|
|
50
|
-
this.quickInputService?.showQuickPick(this.items, { placeholder: 'Registered variables' });
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
protected async showValue(variable: Variable): Promise<void> {
|
|
54
|
-
const argument = await this.quickInputService?.input({
|
|
55
|
-
placeHolder: 'Type a variable argument'
|
|
56
|
-
});
|
|
57
|
-
const value = await this.variableResolver.resolve('${' + variable.name + ':' + argument + '}');
|
|
58
|
-
if (typeof value === 'string') {
|
|
59
|
-
this.messages.info(value);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
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 { inject, injectable, optional } from '@theia/core/shared/inversify';
|
|
18
|
+
import { MessageService } from '@theia/core/lib/common/message-service';
|
|
19
|
+
import { VariableRegistry, Variable } from './variable';
|
|
20
|
+
import { VariableResolverService } from './variable-resolver-service';
|
|
21
|
+
import { QuickPickItem, QuickInputService } from '@theia/core/lib/browser';
|
|
22
|
+
|
|
23
|
+
@injectable()
|
|
24
|
+
export class VariableQuickOpenService {
|
|
25
|
+
|
|
26
|
+
protected items: Array<QuickPickItem>;
|
|
27
|
+
|
|
28
|
+
@inject(MessageService)
|
|
29
|
+
protected readonly messages: MessageService;
|
|
30
|
+
|
|
31
|
+
@inject(QuickInputService) @optional()
|
|
32
|
+
protected readonly quickInputService: QuickInputService;
|
|
33
|
+
|
|
34
|
+
@inject(VariableResolverService)
|
|
35
|
+
protected readonly variableResolver: VariableResolverService;
|
|
36
|
+
|
|
37
|
+
constructor(
|
|
38
|
+
@inject(VariableRegistry) protected readonly variableRegistry: VariableRegistry
|
|
39
|
+
) { }
|
|
40
|
+
|
|
41
|
+
open(): void {
|
|
42
|
+
this.items = this.variableRegistry.getVariables().map(v => ({
|
|
43
|
+
label: '${' + v.name + '}',
|
|
44
|
+
detail: v.description,
|
|
45
|
+
execute: () => {
|
|
46
|
+
setTimeout(() => this.showValue(v));
|
|
47
|
+
}
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
this.quickInputService?.showQuickPick(this.items, { placeholder: 'Registered variables' });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
protected async showValue(variable: Variable): Promise<void> {
|
|
54
|
+
const argument = await this.quickInputService?.input({
|
|
55
|
+
placeHolder: 'Type a variable argument'
|
|
56
|
+
});
|
|
57
|
+
const value = await this.variableResolver.resolve('${' + variable.name + ':' + argument + '}');
|
|
58
|
+
if (typeof value === 'string') {
|
|
59
|
+
this.messages.info(value);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -1,98 +1,98 @@
|
|
|
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 { enableJSDOM } from '@theia/core/lib/browser/test/jsdom';
|
|
18
|
-
|
|
19
|
-
let disableJSDOM = enableJSDOM();
|
|
20
|
-
|
|
21
|
-
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
|
|
22
|
-
FrontendApplicationConfigProvider.set({});
|
|
23
|
-
|
|
24
|
-
import * as chai from 'chai';
|
|
25
|
-
import { Container, ContainerModule } from '@theia/core/shared/inversify';
|
|
26
|
-
import { ILogger, bindContributionProvider } from '@theia/core/lib/common';
|
|
27
|
-
import { MockLogger } from '@theia/core/lib/common/test/mock-logger';
|
|
28
|
-
import { VariableContribution, VariableRegistry } from './variable';
|
|
29
|
-
import { VariableQuickOpenService } from './variable-quick-open-service';
|
|
30
|
-
import { VariableResolverFrontendContribution } from './variable-resolver-frontend-contribution';
|
|
31
|
-
|
|
32
|
-
disableJSDOM();
|
|
33
|
-
|
|
34
|
-
const expect = chai.expect;
|
|
35
|
-
|
|
36
|
-
before(() => {
|
|
37
|
-
chai.config.showDiff = true;
|
|
38
|
-
chai.config.includeStack = true;
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
describe('variable-resolver-frontend-contribution', () => {
|
|
42
|
-
|
|
43
|
-
let testContainer: Container;
|
|
44
|
-
let variableRegistry: VariableRegistry;
|
|
45
|
-
|
|
46
|
-
before(() => {
|
|
47
|
-
disableJSDOM = enableJSDOM();
|
|
48
|
-
|
|
49
|
-
testContainer = new Container();
|
|
50
|
-
const module = new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
51
|
-
bindContributionProvider(bind, VariableContribution);
|
|
52
|
-
bind(VariableContribution).toConstantValue(new TestVariableContribution());
|
|
53
|
-
|
|
54
|
-
bind(ILogger).to(MockLogger);
|
|
55
|
-
bind(VariableRegistry).toSelf().inSingletonScope();
|
|
56
|
-
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
-
bind(VariableQuickOpenService).toConstantValue({} as any); // mock VariableQuickOpenService
|
|
59
|
-
|
|
60
|
-
bind(VariableResolverFrontendContribution).toSelf();
|
|
61
|
-
});
|
|
62
|
-
testContainer.load(module);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
after(() => {
|
|
66
|
-
disableJSDOM();
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
beforeEach(() => {
|
|
70
|
-
variableRegistry = testContainer.get<VariableRegistry>(VariableRegistry);
|
|
71
|
-
|
|
72
|
-
const variableRegistrar = testContainer.get(VariableResolverFrontendContribution);
|
|
73
|
-
variableRegistrar.onStart();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('should register all variables from the contribution points', () => {
|
|
77
|
-
const variables = variableRegistry.getVariables();
|
|
78
|
-
expect(variables.length).to.be.equal(2);
|
|
79
|
-
expect(variables[0].name).to.be.equal('file');
|
|
80
|
-
expect(variables[1].name).to.be.equal('lineNumber');
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
export class TestVariableContribution implements VariableContribution {
|
|
85
|
-
|
|
86
|
-
registerVariables(variables: VariableRegistry): void {
|
|
87
|
-
variables.registerVariable({
|
|
88
|
-
name: 'file',
|
|
89
|
-
description: 'Resolves to file name opened in the current editor',
|
|
90
|
-
resolve: () => Promise.resolve('package.json')
|
|
91
|
-
});
|
|
92
|
-
variables.registerVariable({
|
|
93
|
-
name: 'lineNumber',
|
|
94
|
-
description: 'Resolves to current line number',
|
|
95
|
-
resolve: () => Promise.resolve('5')
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
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 { enableJSDOM } from '@theia/core/lib/browser/test/jsdom';
|
|
18
|
+
|
|
19
|
+
let disableJSDOM = enableJSDOM();
|
|
20
|
+
|
|
21
|
+
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
|
|
22
|
+
FrontendApplicationConfigProvider.set({});
|
|
23
|
+
|
|
24
|
+
import * as chai from 'chai';
|
|
25
|
+
import { Container, ContainerModule } from '@theia/core/shared/inversify';
|
|
26
|
+
import { ILogger, bindContributionProvider } from '@theia/core/lib/common';
|
|
27
|
+
import { MockLogger } from '@theia/core/lib/common/test/mock-logger';
|
|
28
|
+
import { VariableContribution, VariableRegistry } from './variable';
|
|
29
|
+
import { VariableQuickOpenService } from './variable-quick-open-service';
|
|
30
|
+
import { VariableResolverFrontendContribution } from './variable-resolver-frontend-contribution';
|
|
31
|
+
|
|
32
|
+
disableJSDOM();
|
|
33
|
+
|
|
34
|
+
const expect = chai.expect;
|
|
35
|
+
|
|
36
|
+
before(() => {
|
|
37
|
+
chai.config.showDiff = true;
|
|
38
|
+
chai.config.includeStack = true;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('variable-resolver-frontend-contribution', () => {
|
|
42
|
+
|
|
43
|
+
let testContainer: Container;
|
|
44
|
+
let variableRegistry: VariableRegistry;
|
|
45
|
+
|
|
46
|
+
before(() => {
|
|
47
|
+
disableJSDOM = enableJSDOM();
|
|
48
|
+
|
|
49
|
+
testContainer = new Container();
|
|
50
|
+
const module = new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
51
|
+
bindContributionProvider(bind, VariableContribution);
|
|
52
|
+
bind(VariableContribution).toConstantValue(new TestVariableContribution());
|
|
53
|
+
|
|
54
|
+
bind(ILogger).to(MockLogger);
|
|
55
|
+
bind(VariableRegistry).toSelf().inSingletonScope();
|
|
56
|
+
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
+
bind(VariableQuickOpenService).toConstantValue({} as any); // mock VariableQuickOpenService
|
|
59
|
+
|
|
60
|
+
bind(VariableResolverFrontendContribution).toSelf();
|
|
61
|
+
});
|
|
62
|
+
testContainer.load(module);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
after(() => {
|
|
66
|
+
disableJSDOM();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
beforeEach(() => {
|
|
70
|
+
variableRegistry = testContainer.get<VariableRegistry>(VariableRegistry);
|
|
71
|
+
|
|
72
|
+
const variableRegistrar = testContainer.get(VariableResolverFrontendContribution);
|
|
73
|
+
variableRegistrar.onStart();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should register all variables from the contribution points', () => {
|
|
77
|
+
const variables = variableRegistry.getVariables();
|
|
78
|
+
expect(variables.length).to.be.equal(2);
|
|
79
|
+
expect(variables[0].name).to.be.equal('file');
|
|
80
|
+
expect(variables[1].name).to.be.equal('lineNumber');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export class TestVariableContribution implements VariableContribution {
|
|
85
|
+
|
|
86
|
+
registerVariables(variables: VariableRegistry): void {
|
|
87
|
+
variables.registerVariable({
|
|
88
|
+
name: 'file',
|
|
89
|
+
description: 'Resolves to file name opened in the current editor',
|
|
90
|
+
resolve: () => Promise.resolve('package.json')
|
|
91
|
+
});
|
|
92
|
+
variables.registerVariable({
|
|
93
|
+
name: 'lineNumber',
|
|
94
|
+
description: 'Resolves to current line number',
|
|
95
|
+
resolve: () => Promise.resolve('5')
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -1,50 +1,50 @@
|
|
|
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, inject, named } from '@theia/core/shared/inversify';
|
|
18
|
-
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
19
|
-
import { Command, CommandContribution, CommandRegistry, ContributionProvider } from '@theia/core/lib/common';
|
|
20
|
-
import { VariableContribution, VariableRegistry } from './variable';
|
|
21
|
-
import { VariableQuickOpenService } from './variable-quick-open-service';
|
|
22
|
-
|
|
23
|
-
export const LIST_VARIABLES: Command = {
|
|
24
|
-
id: 'variable.list',
|
|
25
|
-
label: 'Variable: List All'
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
@injectable()
|
|
29
|
-
export class VariableResolverFrontendContribution implements FrontendApplicationContribution, CommandContribution {
|
|
30
|
-
|
|
31
|
-
constructor(
|
|
32
|
-
@inject(ContributionProvider) @named(VariableContribution)
|
|
33
|
-
protected readonly contributionProvider: ContributionProvider<VariableContribution>,
|
|
34
|
-
@inject(VariableRegistry) protected readonly variableRegistry: VariableRegistry,
|
|
35
|
-
@inject(VariableQuickOpenService) protected readonly variableQuickOpenService: VariableQuickOpenService
|
|
36
|
-
) { }
|
|
37
|
-
|
|
38
|
-
onStart(): void {
|
|
39
|
-
this.contributionProvider.getContributions().forEach(contrib =>
|
|
40
|
-
contrib.registerVariables(this.variableRegistry)
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
registerCommands(commands: CommandRegistry): void {
|
|
45
|
-
commands.registerCommand(LIST_VARIABLES, {
|
|
46
|
-
isEnabled: () => true,
|
|
47
|
-
execute: () => this.variableQuickOpenService.open()
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
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, inject, named } from '@theia/core/shared/inversify';
|
|
18
|
+
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
19
|
+
import { Command, CommandContribution, CommandRegistry, ContributionProvider } from '@theia/core/lib/common';
|
|
20
|
+
import { VariableContribution, VariableRegistry } from './variable';
|
|
21
|
+
import { VariableQuickOpenService } from './variable-quick-open-service';
|
|
22
|
+
|
|
23
|
+
export const LIST_VARIABLES: Command = {
|
|
24
|
+
id: 'variable.list',
|
|
25
|
+
label: 'Variable: List All'
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
@injectable()
|
|
29
|
+
export class VariableResolverFrontendContribution implements FrontendApplicationContribution, CommandContribution {
|
|
30
|
+
|
|
31
|
+
constructor(
|
|
32
|
+
@inject(ContributionProvider) @named(VariableContribution)
|
|
33
|
+
protected readonly contributionProvider: ContributionProvider<VariableContribution>,
|
|
34
|
+
@inject(VariableRegistry) protected readonly variableRegistry: VariableRegistry,
|
|
35
|
+
@inject(VariableQuickOpenService) protected readonly variableQuickOpenService: VariableQuickOpenService
|
|
36
|
+
) { }
|
|
37
|
+
|
|
38
|
+
onStart(): void {
|
|
39
|
+
this.contributionProvider.getContributions().forEach(contrib =>
|
|
40
|
+
contrib.registerVariables(this.variableRegistry)
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
registerCommands(commands: CommandRegistry): void {
|
|
45
|
+
commands.registerCommand(LIST_VARIABLES, {
|
|
46
|
+
isEnabled: () => true,
|
|
47
|
+
execute: () => this.variableQuickOpenService.open()
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -1,40 +1,40 @@
|
|
|
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 { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
|
-
import { bindContributionProvider, CommandContribution } from '@theia/core';
|
|
19
|
-
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
20
|
-
import { VariableRegistry, VariableContribution } from './variable';
|
|
21
|
-
import { VariableQuickOpenService } from './variable-quick-open-service';
|
|
22
|
-
import { VariableResolverFrontendContribution } from './variable-resolver-frontend-contribution';
|
|
23
|
-
import { VariableResolverService } from './variable-resolver-service';
|
|
24
|
-
import { CommonVariableContribution } from './common-variable-contribution';
|
|
25
|
-
|
|
26
|
-
export default new ContainerModule(bind => {
|
|
27
|
-
bind(VariableRegistry).toSelf().inSingletonScope();
|
|
28
|
-
bind(VariableResolverService).toSelf().inSingletonScope();
|
|
29
|
-
bindContributionProvider(bind, VariableContribution);
|
|
30
|
-
|
|
31
|
-
bind(VariableResolverFrontendContribution).toSelf().inSingletonScope();
|
|
32
|
-
for (const identifier of [FrontendApplicationContribution, CommandContribution]) {
|
|
33
|
-
bind(identifier).toService(VariableResolverFrontendContribution);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
bind(VariableQuickOpenService).toSelf().inSingletonScope();
|
|
37
|
-
|
|
38
|
-
bind(CommonVariableContribution).toSelf().inSingletonScope();
|
|
39
|
-
bind(VariableContribution).toService(CommonVariableContribution);
|
|
40
|
-
});
|
|
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 { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
|
+
import { bindContributionProvider, CommandContribution } from '@theia/core';
|
|
19
|
+
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
20
|
+
import { VariableRegistry, VariableContribution } from './variable';
|
|
21
|
+
import { VariableQuickOpenService } from './variable-quick-open-service';
|
|
22
|
+
import { VariableResolverFrontendContribution } from './variable-resolver-frontend-contribution';
|
|
23
|
+
import { VariableResolverService } from './variable-resolver-service';
|
|
24
|
+
import { CommonVariableContribution } from './common-variable-contribution';
|
|
25
|
+
|
|
26
|
+
export default new ContainerModule(bind => {
|
|
27
|
+
bind(VariableRegistry).toSelf().inSingletonScope();
|
|
28
|
+
bind(VariableResolverService).toSelf().inSingletonScope();
|
|
29
|
+
bindContributionProvider(bind, VariableContribution);
|
|
30
|
+
|
|
31
|
+
bind(VariableResolverFrontendContribution).toSelf().inSingletonScope();
|
|
32
|
+
for (const identifier of [FrontendApplicationContribution, CommandContribution]) {
|
|
33
|
+
bind(identifier).toService(VariableResolverFrontendContribution);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
bind(VariableQuickOpenService).toSelf().inSingletonScope();
|
|
37
|
+
|
|
38
|
+
bind(CommonVariableContribution).toSelf().inSingletonScope();
|
|
39
|
+
bind(VariableContribution).toService(CommonVariableContribution);
|
|
40
|
+
});
|