@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.
Files changed (64) hide show
  1. package/lib/base/action-handler-registry.d.ts +10 -1
  2. package/lib/base/action-handler-registry.d.ts.map +1 -1
  3. package/lib/base/action-handler-registry.js +40 -2
  4. package/lib/base/action-handler-registry.js.map +1 -1
  5. package/lib/base/default.module.d.ts.map +1 -1
  6. package/lib/base/default.module.js +5 -0
  7. package/lib/base/default.module.js.map +1 -1
  8. package/lib/base/feedback/feedback-action-dispatcher.d.ts +28 -1
  9. package/lib/base/feedback/feedback-action-dispatcher.d.ts.map +1 -1
  10. package/lib/base/feedback/feedback-action-dispatcher.js +23 -1
  11. package/lib/base/feedback/feedback-action-dispatcher.js.map +1 -1
  12. package/lib/base/feedback/feedback-command.d.ts +8 -3
  13. package/lib/base/feedback/feedback-command.d.ts.map +1 -1
  14. package/lib/base/feedback/feedback-command.js +13 -2
  15. package/lib/base/feedback/feedback-command.js.map +1 -1
  16. package/lib/base/feedback/index.d.ts +1 -0
  17. package/lib/base/feedback/index.d.ts.map +1 -1
  18. package/lib/base/feedback/index.js +1 -0
  19. package/lib/base/feedback/index.js.map +1 -1
  20. package/lib/base/feedback/set-model-command.d.ts +25 -0
  21. package/lib/base/feedback/set-model-command.d.ts.map +1 -0
  22. package/lib/base/feedback/set-model-command.js +65 -0
  23. package/lib/base/feedback/set-model-command.js.map +1 -0
  24. package/lib/base/feedback/update-model-command.d.ts +17 -6
  25. package/lib/base/feedback/update-model-command.d.ts.map +1 -1
  26. package/lib/base/feedback/update-model-command.js +8 -28
  27. package/lib/base/feedback/update-model-command.js.map +1 -1
  28. package/lib/base/ranked.d.ts +10 -0
  29. package/lib/base/ranked.d.ts.map +1 -1
  30. package/lib/base/ranked.js +6 -0
  31. package/lib/base/ranked.js.map +1 -1
  32. package/lib/base/selection-service.spec.js +4 -0
  33. package/lib/base/selection-service.spec.js.map +1 -1
  34. package/lib/features/bounds/set-bounds-feedback-command.d.ts +1 -1
  35. package/lib/features/bounds/set-bounds-feedback-command.d.ts.map +1 -1
  36. package/lib/features/bounds/set-bounds-feedback-command.js +2 -1
  37. package/lib/features/bounds/set-bounds-feedback-command.js.map +1 -1
  38. package/lib/features/hints/type-hint-provider.d.ts +17 -2
  39. package/lib/features/hints/type-hint-provider.d.ts.map +1 -1
  40. package/lib/features/hints/type-hint-provider.js +12 -12
  41. package/lib/features/hints/type-hint-provider.js.map +1 -1
  42. package/lib/features/validation/validate.d.ts +20 -2
  43. package/lib/features/validation/validate.d.ts.map +1 -1
  44. package/lib/features/validation/validate.js +13 -10
  45. package/lib/features/validation/validate.js.map +1 -1
  46. package/lib/tsconfig.tsbuildinfo +1 -1
  47. package/lib/utils/contribution-provider.d.ts +27 -0
  48. package/lib/utils/contribution-provider.d.ts.map +1 -0
  49. package/lib/utils/contribution-provider.js +56 -0
  50. package/lib/utils/contribution-provider.js.map +1 -0
  51. package/package.json +3 -3
  52. package/src/base/action-handler-registry.ts +41 -2
  53. package/src/base/default.module.ts +7 -0
  54. package/src/base/feedback/feedback-action-dispatcher.ts +49 -1
  55. package/src/base/feedback/feedback-command.ts +15 -4
  56. package/src/base/feedback/index.ts +2 -0
  57. package/src/base/feedback/set-model-command.ts +45 -0
  58. package/src/base/feedback/update-model-command.ts +8 -45
  59. package/src/base/ranked.ts +14 -0
  60. package/src/base/selection-service.spec.ts +7 -1
  61. package/src/features/bounds/set-bounds-feedback-command.ts +2 -1
  62. package/src/features/hints/type-hint-provider.ts +5 -5
  63. package/src/features/validation/validate.ts +18 -11
  64. 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
+ }