From f1c810346f91e3aec47de4943fa923bc7f63d720 Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Wed, 11 Nov 2020 17:36:29 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20Ajoute=20un=20attribut=20"?= =?UTF-8?q?dependencies"=20sur=20les=20r=C3=A8gles=20pars=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publicodes/source/parseReference.ts | 19 +++++++++++++++++-- publicodes/source/parseRule.tsx | 1 + publicodes/source/types/index.ts | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/publicodes/source/parseReference.ts b/publicodes/source/parseReference.ts index a6625fa87..cb5c0ff74 100644 --- a/publicodes/source/parseReference.ts +++ b/publicodes/source/parseReference.ts @@ -18,8 +18,23 @@ export const parseReference = ( const parsedRule = parsedRules[dottedName] || - // the 'inversion numérique' formula should not exist. The instructions to the evaluation should be enough to infer that an inversion is necessary (assuming it is possible, the client decides this) + // TODO: The 'inversion numérique' formula should not exist. The instructions to + // the evaluation should be enough to infer that an inversion is necessary + // (assuming it is possible, the client decides this) #767 (!inInversionFormula && parseRule(rules, dottedName, parsedRules)) + + const contextRuleName = rule.dottedName + if ( + // TODO: At this point in the code, the parsedRule value should never be the + // string "being parsed", this is a ordering problem. + parsedRule !== 'being parsed' && + parsedRule !== false && + rule.dottedName && + !contextRuleName.startsWith('[evaluation]') + ) { + rule.dependencies?.add(dottedName) + } + const unit = parsedRule.unit return { nodeKind: 'reference', @@ -28,7 +43,7 @@ export const parseReference = ( category: 'reference', partialReference, dottedName, - explanation: { ...parsedRule, filter, contextRuleName: rule.dottedName }, + explanation: { ...parsedRule, filter, contextRuleName }, unit } } diff --git a/publicodes/source/parseRule.tsx b/publicodes/source/parseRule.tsx index a732c17d4..1bcc39925 100644 --- a/publicodes/source/parseRule.tsx +++ b/publicodes/source/parseRule.tsx @@ -78,6 +78,7 @@ export default function( summary: rawRule['résumé'], unit, parentDependencies, + dependencies: new Set(), defaultValue: rawRule['par défaut'] } diff --git a/publicodes/source/types/index.ts b/publicodes/source/types/index.ts index 94ef9b148..940ec8804 100644 --- a/publicodes/source/types/index.ts +++ b/publicodes/source/types/index.ts @@ -40,6 +40,7 @@ export type ParsedRule = Rule & { formule?: any explanation?: any isDisabledBy: Array + dependencies: Set replacedBy: Array<{ whiteListedNames: Array blackListedNames: Array