Skip to content

Commit d873ddf

Browse files
committed
fix!: include unscoped variables in getVariables
1 parent 2a2efe1 commit d873ddf

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

lib/base/VariableResolver.js

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,21 @@ import { getParents } from './util/elementsUtil';
1616
/**
1717
* @typedef {AdditionalVariable} ProcessVariable
1818
* @property {Array<ModdleElement>} origin
19-
* @property {ModdleElement} scope
19+
* @property {ModdleElement} [scope]
2020
* @property {Array<Object>} provider
2121
*/
2222

2323
/**
2424
* Base Class that handles additional variable extractors, variable parsing and caching.
2525
*/
2626
export class BaseVariableResolver {
27-
2827
constructor(eventBus, bpmnjs) {
2928
this.providers = [];
3029
this._eventBus = eventBus;
3130
this._bpmnjs = bpmnjs;
3231

3332
this.rawVariables = new CachedValue(this._generateRawVariables.bind(this));
34-
this._allParsedVariables = new CachedValue(async () => {
33+
this.parsedVariables = new CachedValue(async () => {
3534

3635
const rawVariables = await this.getRawVariables();
3736
const context = { variables: rawVariables };
@@ -40,17 +39,6 @@ export class BaseVariableResolver {
4039

4140
return context.variables;
4241
});
43-
this.parsedVariables = new CachedValue(async () => {
44-
const allParsed = await this._allParsedVariables.get();
45-
46-
// Filter out variables with no scope (e.g. consumed variable markers)
47-
const filtered = {};
48-
for (const key in allParsed) {
49-
filtered[key] = allParsed[key].filter(v => v.scope);
50-
}
51-
52-
return filtered;
53-
});
5442

5543
eventBus.on([ 'commandStack.changed', 'diagram.clear', 'import.done', 'variables.changed' ], () => {
5644
this.invalidateCache();
@@ -112,7 +100,6 @@ export class BaseVariableResolver {
112100
*/
113101
invalidateCache() {
114102
this.rawVariables.invalidate();
115-
this._allParsedVariables.invalidate();
116103
this.parsedVariables.invalidate();
117104
}
118105

@@ -338,11 +325,7 @@ export class BaseVariableResolver {
338325
* @returns {Promise<Array<AvailableVariable>>}
339326
*/
340327
async getConsumedVariablesForElement(element) {
341-
const allVariablesByRoot = await this._allParsedVariables.get()
342-
.catch(() => {
343-
return {};
344-
});
345-
328+
const allVariablesByRoot = await this.parsedVariables.get();
346329
const allVariables = Object.values(allVariablesByRoot).flat();
347330

348331
return allVariables.filter(v =>

0 commit comments

Comments
 (0)