@eclipse-glsp/client 2.3.0-next.318 → 2.3.0-next.320
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/lib/base/action-handler-registry.d.ts +10 -1
- package/lib/base/action-handler-registry.d.ts.map +1 -1
- package/lib/base/action-handler-registry.js +40 -2
- package/lib/base/action-handler-registry.js.map +1 -1
- package/lib/base/default.module.d.ts.map +1 -1
- package/lib/base/default.module.js +5 -0
- package/lib/base/default.module.js.map +1 -1
- package/lib/base/feedback/feedback-action-dispatcher.d.ts +28 -1
- package/lib/base/feedback/feedback-action-dispatcher.d.ts.map +1 -1
- package/lib/base/feedback/feedback-action-dispatcher.js +23 -1
- package/lib/base/feedback/feedback-action-dispatcher.js.map +1 -1
- package/lib/base/feedback/feedback-command.d.ts +8 -3
- package/lib/base/feedback/feedback-command.d.ts.map +1 -1
- package/lib/base/feedback/feedback-command.js +13 -2
- package/lib/base/feedback/feedback-command.js.map +1 -1
- package/lib/base/feedback/index.d.ts +1 -0
- package/lib/base/feedback/index.d.ts.map +1 -1
- package/lib/base/feedback/index.js +1 -0
- package/lib/base/feedback/index.js.map +1 -1
- package/lib/base/feedback/set-model-command.d.ts +25 -0
- package/lib/base/feedback/set-model-command.d.ts.map +1 -0
- package/lib/base/feedback/set-model-command.js +65 -0
- package/lib/base/feedback/set-model-command.js.map +1 -0
- package/lib/base/feedback/update-model-command.d.ts +17 -6
- package/lib/base/feedback/update-model-command.d.ts.map +1 -1
- package/lib/base/feedback/update-model-command.js +8 -28
- package/lib/base/feedback/update-model-command.js.map +1 -1
- package/lib/base/ranked.d.ts +10 -0
- package/lib/base/ranked.d.ts.map +1 -1
- package/lib/base/ranked.js +6 -0
- package/lib/base/ranked.js.map +1 -1
- package/lib/base/selection-service.spec.js +4 -0
- package/lib/base/selection-service.spec.js.map +1 -1
- package/lib/features/bounds/set-bounds-feedback-command.d.ts +1 -1
- package/lib/features/bounds/set-bounds-feedback-command.d.ts.map +1 -1
- package/lib/features/bounds/set-bounds-feedback-command.js +2 -1
- package/lib/features/bounds/set-bounds-feedback-command.js.map +1 -1
- package/lib/features/hints/type-hint-provider.d.ts +17 -2
- package/lib/features/hints/type-hint-provider.d.ts.map +1 -1
- package/lib/features/hints/type-hint-provider.js +12 -12
- package/lib/features/hints/type-hint-provider.js.map +1 -1
- package/lib/features/validation/validate.d.ts +20 -2
- package/lib/features/validation/validate.d.ts.map +1 -1
- package/lib/features/validation/validate.js +13 -10
- package/lib/features/validation/validate.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/contribution-provider.d.ts +27 -0
- package/lib/utils/contribution-provider.d.ts.map +1 -0
- package/lib/utils/contribution-provider.js +56 -0
- package/lib/utils/contribution-provider.js.map +1 -0
- package/package.json +3 -3
- package/src/base/action-handler-registry.ts +41 -2
- package/src/base/default.module.ts +7 -0
- package/src/base/feedback/feedback-action-dispatcher.ts +49 -1
- package/src/base/feedback/feedback-command.ts +15 -4
- package/src/base/feedback/index.ts +2 -0
- package/src/base/feedback/set-model-command.ts +45 -0
- package/src/base/feedback/update-model-command.ts +8 -45
- package/src/base/ranked.ts +14 -0
- package/src/base/selection-service.spec.ts +7 -1
- package/src/features/bounds/set-bounds-feedback-command.ts +2 -1
- package/src/features/hints/type-hint-provider.ts +5 -5
- package/src/features/validation/validate.ts +18 -11
- package/src/utils/contribution-provider.ts +65 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*******************************************************************************
|
|
2
|
+
* Copyright (C) 2017 TypeFox and others.
|
|
3
|
+
* Modifications: (c) 2024 EclipseSource 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
|
+
// eslint-disable-next-line max-len
|
|
18
|
+
// based on https://github.com/eclipse-theia/theia/blob/9ff0cedff1d591b0eb4be97a05f6d992789d0a24/packages/core/src/common/contribution-provider.ts
|
|
19
|
+
|
|
20
|
+
import { BindingContext, TYPES } from '@eclipse-glsp/sprotty';
|
|
21
|
+
import { interfaces } from 'inversify';
|
|
22
|
+
|
|
23
|
+
export interface IContributionProvider<T extends object> {
|
|
24
|
+
/**
|
|
25
|
+
* @param recursive `true` if the contributions should be collected from the parent containers as well. Otherwise, `false`.
|
|
26
|
+
* It is `false` by default.
|
|
27
|
+
*/
|
|
28
|
+
getContributions(recursive?: boolean): T[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class ContainerBasedContributionProvider<T extends object> implements IContributionProvider<T> {
|
|
32
|
+
protected services: T[] | undefined;
|
|
33
|
+
|
|
34
|
+
constructor(
|
|
35
|
+
protected readonly serviceIdentifier: interfaces.ServiceIdentifier<T>,
|
|
36
|
+
protected readonly container: interfaces.Container
|
|
37
|
+
) {}
|
|
38
|
+
|
|
39
|
+
getContributions(recursive?: boolean): T[] {
|
|
40
|
+
if (this.services === undefined) {
|
|
41
|
+
const currentServices: T[] = [];
|
|
42
|
+
let currentContainer: interfaces.Container | undefined = this.container;
|
|
43
|
+
while (currentContainer !== undefined) {
|
|
44
|
+
if (currentContainer.isBound(this.serviceIdentifier)) {
|
|
45
|
+
try {
|
|
46
|
+
currentServices.push(...currentContainer.getAll(this.serviceIdentifier));
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error(error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
currentContainer = recursive === true && currentContainer.parent ? currentContainer.parent : undefined;
|
|
52
|
+
}
|
|
53
|
+
this.services = currentServices;
|
|
54
|
+
}
|
|
55
|
+
return this.services;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function bindContributionProvider(context: Pick<BindingContext, 'bind'> | interfaces.Bind, id: symbol): void {
|
|
60
|
+
const bind = typeof context === 'object' ? context.bind.bind(context) : context;
|
|
61
|
+
bind(TYPES.IContributionProvider)
|
|
62
|
+
.toDynamicValue(ctx => new ContainerBasedContributionProvider(id, ctx.container))
|
|
63
|
+
.inSingletonScope()
|
|
64
|
+
.whenTargetNamed(id);
|
|
65
|
+
}
|