Skip to content

Commit

Permalink
fix a regression introduced in finos#1543
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannan authored and Yannan committed Oct 12, 2022
1 parent 240875e commit eecb3e9
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 46 deletions.
7 changes: 7 additions & 0 deletions .changeset/slimy-feet-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@finos/legend-application-studio': major
'@finos/legend-extension-store-service-store': major
'@finos/legend-graph': major
---

**BREAKING CHANGE:** Make multiplicity's upper bound and lower bond `readonly`.
5 changes: 5 additions & 0 deletions .changeset/swift-lies-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-query-builder': patch
---

Fix a regression introduced in ([#1543](https://github.com/finos/legend-studio/pull/1543)) about updating cached multiplcities in place.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ import {
observe_TaggedValue,
observe_Constraint,
observe_GenericType,
observe_Multiplicity,
observe_Type,
observe_Unit,
observe_RawLambda,
Expand Down Expand Up @@ -194,7 +193,7 @@ export const property_setGenericType = action(
);
export const property_setMultiplicity = action(
(_property: Property | DerivedProperty, value: Multiplicity): void => {
_property.multiplicity = observe_Multiplicity(value);
_property.multiplicity = value;
},
);
export const stereotypeReference_setValue = action(
Expand Down Expand Up @@ -356,7 +355,7 @@ export const function_setReturnType = action(
);
export const function_setReturnMultiplicity = action(
(_func: ConcreteFunctionDefinition, val: Multiplicity): void => {
_func.returnMultiplicity = observe_Multiplicity(val);
_func.returnMultiplicity = val;
},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
type Multiplicity,
type RawVariableExpression,
type Type,
observe_Multiplicity,
observe_Type,
} from '@finos/legend-graph';
import { action } from 'mobx';
Expand All @@ -34,6 +33,6 @@ export const rawVariableExpression_setType = action(
);
export const rawVariableExpression_setMultiplicity = action(
(target: RawVariableExpression, value: Multiplicity): void => {
target.multiplicity = observe_Multiplicity(value);
target.multiplicity = value;
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
skipObservedWithContext,
observe_PackageableElementReference,
observe_Abstract_Connection,
observe_Multiplicity,
observe_Abstract_InstanceSetImplementation,
observe_RawLambda,
observe_ExternalFormatData,
Expand Down Expand Up @@ -359,9 +358,6 @@ export const observe_LocalMappingProperty = skipObserved(
multiplicity: observable,
hashCode: computed,
});

observe_Multiplicity(metamodel.multiplicity);

return metamodel;
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { CORE_HASH_STRUCTURE } from '../../../../../graph/Core_HashUtils.js';
import { hashArray, type Hashable } from '@finos/legend-shared';

export class Multiplicity implements Hashable {
lowerBound: number;
upperBound?: number | undefined;
readonly lowerBound: number;
readonly upperBound?: number | undefined;

constructor(lowerBound: number, upperBound: number | undefined) {
this.lowerBound = lowerBound;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
} from 'mobx';
import type { PackageableElement } from '../../../graph/metamodel/pure/packageableElements/PackageableElement.js';
import type { PackageableElementReference } from '../../../graph/metamodel/pure/packageableElements/PackageableElementReference.js';
import type { Multiplicity } from '../../../graph/metamodel/pure/packageableElements/domain/Multiplicity.js';
import type { InferableValue } from '../../../graph/metamodel/pure/InferableValue.js';
import type { PureGraphManagerPlugin } from '../../PureGraphManagerPlugin.js';

Expand Down Expand Up @@ -77,15 +76,6 @@ export const observe_PackageableElementReference = skipObserved(
}),
);

export const observe_Multiplicity = skipObserved(
(metamodel: Multiplicity): Multiplicity =>
makeObservable(metamodel, {
lowerBound: observable,
upperBound: observable,
hashCode: computed,
}),
);

export const observe_Abstract_InferableValue = <T, V>(
metamodel: InferableValue<T, V>,
): void => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ import {
observe_PackageableElementReference,
skipObserved,
skipObservedWithContext,
observe_Multiplicity,
} from './CoreObserverHelper.js';
import {
observe_EnumValueReference,
Expand Down Expand Up @@ -167,7 +166,6 @@ export const observe_LocalMappingPropertyInfo = skipObserved(
});

observe_PackageableElementReference(metamodel.localMappingPropertyType);
observe_Multiplicity(metamodel.localMappingPropertyMultiplicity);

return metamodel;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import {
} from '../../../graph/metamodel/pure/packageableElements/section/Section.js';
import type { SectionIndex } from '../../../graph/metamodel/pure/packageableElements/section/SectionIndex.js';
import {
observe_Multiplicity,
observe_Abstract_PackageableElement,
observe_PackageableElementReference,
skipObserved,
Expand Down Expand Up @@ -336,7 +335,6 @@ export const observe_Property = skipObserved(
});

observe_GenericTypeReference(metamodel.genericType);
observe_Multiplicity(metamodel.multiplicity);
metamodel.stereotypes.forEach(observe_StereotypeReference);
metamodel.taggedValues.forEach(observe_TaggedValue);

Expand All @@ -357,7 +355,6 @@ export const observe_DerivedProperty = skipObserved(
});

observe_GenericTypeReference(metamodel.genericType);
observe_Multiplicity(metamodel.multiplicity);
metamodel.stereotypes.forEach(observe_StereotypeReference);
metamodel.taggedValues.forEach(observe_TaggedValue);

Expand Down Expand Up @@ -466,7 +463,6 @@ export const observe_ConcreteFunctionDefinition = skipObserved(

metamodel.parameters.forEach(observe_RawVariableExpression);
observe_PackageableElementReference(metamodel.returnType);
observe_Multiplicity(metamodel.returnMultiplicity);
metamodel.stereotypes.forEach(observe_StereotypeReference);
metamodel.taggedValues.forEach(observe_TaggedValue);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import type {
import type { RawVariableExpression } from '../../../graph/metamodel/pure/rawValueSpecification/RawVariableExpression.js';
import {
observe_PackageableElementReference,
observe_Multiplicity,
skipObserved,
skipObservedWithContext,
type ObserverContext,
Expand All @@ -41,7 +40,6 @@ export const observe_RawPrimitiveInstanceValue = skipObserved(
});

observe_PackageableElementReference(metamodel.type);
observe_Multiplicity(metamodel.multiplicity);

return metamodel;
},
Expand All @@ -65,7 +63,6 @@ export const observe_RawVariableExpression = skipObserved(
});

observe_PackageableElementReference(metamodel.type);
observe_Multiplicity(metamodel.multiplicity);

return metamodel;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ import {
type ObserverContext,
skipObservedWithContext,
skipObserved,
observe_Multiplicity,
observe_PackageableElementReference,
} from './CoreObserverHelper.js';
import {
Expand All @@ -81,7 +80,6 @@ const observe_Abstract_ValueSpecification = (
if (metamodel.genericType) {
observe_GenericTypeReference(metamodel.genericType);
}
observe_Multiplicity(metamodel.multiplicity);
};

export const observe_VariableExpression = skipObserved(
Expand Down Expand Up @@ -266,7 +264,6 @@ const observe_FunctionType = skipObserved(
metamodel.parameters.forEach((parameter) =>
observe_VariableExpression(parameter),
);
observe_Multiplicity(metamodel.returnMultiplicity);

return metamodel;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ const VariableExpressionEditor = observer(
event,
) => {
lambdaParameterState.changeMultiplicity(
varState,
parseInt(event.target.value),
multiplity.upperBound,
);
Expand All @@ -133,6 +134,7 @@ const VariableExpressionEditor = observer(
!isNaN(parseInt(value, 10))
) {
lambdaParameterState.changeMultiplicity(
varState,
multiplity.lowerBound,
value === MULTIPLICITY_INFINITE || value === ''
? undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ import {
import { makeObservable, observable, action, computed } from 'mobx';
import { generateVariableExpressionMockValue } from './ValueSpecificationEditorHelper.js';
import {
multiplicity_setLowerBound,
multiplicity_setUpperBound,
valueSpecification_setGenericType,
valueSpecification_setMultiplicity,
} from './ValueSpecificationModifierHelper.js';

export enum PARAMETER_SUBMIT_ACTION {
Expand Down Expand Up @@ -158,6 +157,7 @@ export class LambdaParameterState implements Hashable {
}

changeMultiplicity(
variableExpression: VariableExpression,
lowerBound: number,
uppderBound: number | undefined,
): void {
Expand All @@ -166,8 +166,10 @@ export class LambdaParameterState implements Hashable {
current.lowerBound !== lowerBound ||
current.upperBound !== uppderBound
) {
multiplicity_setLowerBound(current, lowerBound);
multiplicity_setUpperBound(current, uppderBound);
valueSpecification_setMultiplicity(
variableExpression,
this.graph.getMultiplicity(lowerBound, uppderBound),
);
this.mockParameterValue();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,9 @@ export const valueSpecification_setGenericType = action(
},
);

export const multiplicity_setLowerBound = action(
(target: Multiplicity, val: number): void => {
target.lowerBound = val;
},
);

export const multiplicity_setUpperBound = action(
(target: Multiplicity, val: number | undefined): void => {
target.upperBound = val;
export const valueSpecification_setMultiplicity = action(
(target: ValueSpecification, val: Multiplicity): void => {
target.multiplicity = val;
},
);

Expand Down

0 comments on commit eecb3e9

Please sign in to comment.