diff --git a/publicodes/source/cyclesLib.ts b/publicodes/source/cyclesLib.ts index 66e5e9c07..c0aaa798a 100644 --- a/publicodes/source/cyclesLib.ts +++ b/publicodes/source/cyclesLib.ts @@ -580,7 +580,15 @@ export function isAnyMechanism( ) } -type RuleDependencies = Array +enum DependencyType { + formule, + replacedBy, + disabledBy +} + +type RuleDependency = [Names, DependencyType] + +type RuleDependencies = Array> export function ruleDepsOfNode( ruleName: Names, @@ -628,14 +636,16 @@ export function ruleDepsOfNode( function ruleDepsOfReference( reference: Reference ): RuleDependencies { - return [reference.dottedName] + return [[reference.dottedName, DependencyType.formule]] } function ruleDepsOfRecalculMech( recalculMech: RecalculMech ): RuleDependencies { const ruleReference = recalculMech.explanation.recalcul.partialReference - return ruleReference === ruleName ? [] : [ruleReference] + return ruleReference === ruleName + ? [] + : [[ruleReference, DependencyType.formule]] } function ruleDepsOfEncadrementMech( @@ -945,9 +955,11 @@ function ruleDepsOfRuleNode( .map(x => ruleDepsOfNode(rule.dottedName, x)) .flat(1) - const isDisabledByDependencies = rule.isDisabledBy.map(x => x.dottedName) - const replacedByDependencies = rule.replacedBy.map( - x => x.referenceNode.dottedName + const isDisabledByDependencies: RuleDependencies = rule.isDisabledBy.map( + x => [x.dottedName, DependencyType.disabledBy] + ) + const replacedByDependencies: RuleDependencies = rule.replacedBy.map( + x => [x.referenceNode.dottedName, DependencyType.replacedBy] ) return [subNodesDeps, isDisabledByDependencies, replacedByDependencies].flat( 1 diff --git a/publicodes/source/parseReference.js b/publicodes/source/parseReference.js index 945a51664..a83c1fff4 100644 --- a/publicodes/source/parseReference.js +++ b/publicodes/source/parseReference.js @@ -33,7 +33,7 @@ export const getApplicableReplacedBy = (contextRuleName, replacedBy) => .filter(({ referenceNode }) => contextRuleName !== referenceNode.dottedName) /** - * Filter-out replacements at runtime. + * Filter-out and apply all possible replacements at runtime. */ const getApplicableReplacements = ( filter,