@eclipse-glsp/client 2.6.0-next.5 → 2.6.0-next.7

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 (55) hide show
  1. package/lib/base/messages.json +68 -57
  2. package/lib/base/tool-manager/tool-manager.d.ts +2 -2
  3. package/lib/base/tool-manager/tool-manager.d.ts.map +1 -1
  4. package/lib/base/tool-manager/tool-manager.js +4 -4
  5. package/lib/base/tool-manager/tool-manager.js.map +1 -1
  6. package/lib/features/accessibility/edge-autocomplete/edge-autocomplete-palette.d.ts +1 -1
  7. package/lib/features/accessibility/edge-autocomplete/edge-autocomplete-palette.js +1 -1
  8. package/lib/features/accessibility/keyboard/keyboard-module.d.ts +1 -1
  9. package/lib/features/accessibility/keyboard/keyboard-module.js +1 -1
  10. package/lib/features/accessibility/keyboard-grid/keyboard-grid-search-palette.d.ts +1 -1
  11. package/lib/features/accessibility/keyboard-grid/keyboard-grid-search-palette.js +1 -1
  12. package/lib/features/accessibility/keyboard-grid/keyboard-node-grid.d.ts +1 -1
  13. package/lib/features/accessibility/keyboard-grid/keyboard-node-grid.js +1 -1
  14. package/lib/features/change-bounds/movement-restrictor.d.ts +12 -4
  15. package/lib/features/change-bounds/movement-restrictor.d.ts.map +1 -1
  16. package/lib/features/change-bounds/movement-restrictor.js +44 -17
  17. package/lib/features/change-bounds/movement-restrictor.js.map +1 -1
  18. package/lib/features/context-menu/delete-element-context-menu.d.ts +4 -4
  19. package/lib/features/context-menu/delete-element-context-menu.d.ts.map +1 -1
  20. package/lib/features/context-menu/delete-element-context-menu.js +6 -2
  21. package/lib/features/context-menu/delete-element-context-menu.js.map +1 -1
  22. package/lib/features/context-menu/server-context-menu-provider.d.ts +4 -4
  23. package/lib/features/context-menu/server-context-menu-provider.d.ts.map +1 -1
  24. package/lib/features/context-menu/server-context-menu-provider.js +4 -5
  25. package/lib/features/context-menu/server-context-menu-provider.js.map +1 -1
  26. package/lib/features/copy-paste/copy-paste-context-menu.d.ts +22 -5
  27. package/lib/features/copy-paste/copy-paste-context-menu.d.ts.map +1 -1
  28. package/lib/features/copy-paste/copy-paste-context-menu.js +16 -11
  29. package/lib/features/copy-paste/copy-paste-context-menu.js.map +1 -1
  30. package/lib/features/validation/marker-navigator.d.ts +3 -3
  31. package/lib/features/validation/marker-navigator.d.ts.map +1 -1
  32. package/lib/features/validation/marker-navigator.js +8 -7
  33. package/lib/features/validation/marker-navigator.js.map +1 -1
  34. package/lib/index.d.ts +2 -0
  35. package/lib/index.d.ts.map +1 -1
  36. package/lib/index.js +2 -0
  37. package/lib/index.js.map +1 -1
  38. package/lib/utils/gmodel-util.d.ts +32 -2
  39. package/lib/utils/gmodel-util.d.ts.map +1 -1
  40. package/lib/utils/gmodel-util.js +29 -1
  41. package/lib/utils/gmodel-util.js.map +1 -1
  42. package/package.json +3 -3
  43. package/src/base/messages.json +68 -57
  44. package/src/base/tool-manager/tool-manager.ts +4 -4
  45. package/src/features/accessibility/edge-autocomplete/edge-autocomplete-palette.ts +1 -1
  46. package/src/features/accessibility/keyboard/keyboard-module.ts +1 -1
  47. package/src/features/accessibility/keyboard-grid/keyboard-grid-search-palette.ts +1 -1
  48. package/src/features/accessibility/keyboard-grid/keyboard-node-grid.ts +1 -1
  49. package/src/features/change-bounds/movement-restrictor.ts +72 -19
  50. package/src/features/context-menu/delete-element-context-menu.ts +9 -5
  51. package/src/features/context-menu/server-context-menu-provider.ts +8 -9
  52. package/src/features/copy-paste/copy-paste-context-menu.ts +21 -17
  53. package/src/features/validation/marker-navigator.ts +9 -8
  54. package/src/index.ts +2 -0
  55. package/src/utils/gmodel-util.ts +59 -1
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (c) 2019-2024 EclipseSource and others.
2
+ * Copyright (c) 2019-2025 EclipseSource and others.
3
3
  *
4
4
  * This program and the accompanying materials are made available under the
5
5
  * terms of the Eclipse Public License v. 2.0 which is available at
@@ -86,6 +86,63 @@ export function getMatchingElements<T>(index: ModelIndexImpl, predicate: ModelFi
86
86
  return Array.from(filter(index, predicate));
87
87
  }
88
88
 
89
+ /**
90
+ * Retrieves an array of all parent elements for the given element that match the given type guard.
91
+ * @param element The {@link GModelElement} for which the parent elements should be retrieved.
92
+ * @param guard The type guard that should be used.
93
+ * @returns An array of all parent elements that match the type guard
94
+ * (correctly casted to also include the additional type of the guard).
95
+ */
96
+ export function getParents<T extends GParentElement>(element: GModelElement, guard: TypeGuard<T>): T[];
97
+ /**
98
+ * Retrieves an array of all parent elements for the given element that match the given {@link ModelFilterPredicate}.
99
+ * @param element The {@link GModelElement} for which the parent elements should be retrieved.
100
+ * @param predicate The filter predicate that should be used.
101
+ * @returns An array of all parent elements that match the filter predicate
102
+ * (correctly casted to also include the additional type of the predicate).
103
+ */
104
+ export function getParents<T>(element: GModelElement, predicate: ModelFilterPredicate<T>): (GParentElement & T)[];
105
+ export function getParents(element: GModelElement, filterPredicate: (parent: GParentElement) => boolean): GParentElement[] {
106
+ const parents: GParentElement[] = [];
107
+ let current: GModelElement | undefined = element;
108
+ while (current instanceof GChildElement) {
109
+ const parent: GParentElement = current.parent;
110
+ if (filterPredicate(parent)) {
111
+ parents.push(parent);
112
+ }
113
+ current = parent;
114
+ }
115
+ return parents;
116
+ }
117
+
118
+ /** * Retrieves an array of all child elements for the given element that match the given type guard.
119
+ * @param element The {@link GModelElement} for which the child elements should be retrieved.
120
+ * @param guard The type guard that should be used.
121
+ * @returns An array of all child elements that match the type guard
122
+ * (correctly casted to also include the additional type of the guard).
123
+ */
124
+ export function getChildren<T extends GChildElement>(element: GModelElement, guard: TypeGuard<T>): T[];
125
+ /** * Retrieves an array of all child elements for the given element that match the given {@link ModelFilterPredicate}.
126
+ * @param element The {@link GModelElement} for which the child elements should be retrieved.
127
+ * @param predicate The filter predicate that should be used.
128
+ * @returns An array of all child elements that match the filter predicate
129
+ * (correctly casted to also include the additional type of the predicate).
130
+ */
131
+ export function getChildren<T>(element: GModelElement, predicate: ModelFilterPredicate<T>): (GChildElement & T)[];
132
+ export function getChildren(element: GModelElement, filterPredicate: (parent: GChildElement) => boolean): GChildElement[] {
133
+ const children: GChildElement[] = [];
134
+ if (element instanceof GParentElement) {
135
+ for (const child of element.children) {
136
+ if (filterPredicate(child)) {
137
+ children.push(child);
138
+ }
139
+ if (child instanceof GParentElement) {
140
+ children.push(...getChildren(child, filterPredicate as any));
141
+ }
142
+ }
143
+ }
144
+ return children;
145
+ }
89
146
  /**
90
147
  * Invokes the given model index to retrieve the corresponding model elements for the given set of ids. Ids that
91
148
  * have no corresponding element in the index will be ignored.
@@ -104,6 +161,7 @@ export function getElements<S extends GModelElement>(index: ModelIndexImpl, elem
104
161
  };
105
162
  return elementsIDs.map(id => index.getById(id)).filter(filterFn);
106
163
  }
164
+
107
165
  /**
108
166
  * Retrieves the amount of currently selected elements in the given {@link ModelIndexImpl}.
109
167
  * @param index The {@link ModelIndexImpl}.