Cycles: isDisabledBy & replacedBy
parent
5fcc7500c9
commit
655b9bf314
|
@ -21,8 +21,8 @@ describe('DottedNames graph', () => {
|
|||
|
||||
expect(
|
||||
cycles,
|
||||
`\nThe following rules have cycles:\n\t- ${cycles
|
||||
.map(x => x[0])
|
||||
`\nThe cycles have been found in the rules dependencies graph:\n\t- ${cycles
|
||||
.map((x, idx) => '#' + idx + ':\n\t\t- ' + x.join('\n\t\t- '))
|
||||
.join('\n\t- ')}\n\n`
|
||||
).to.be.an('array').that.is.empty
|
||||
})
|
||||
|
|
|
@ -41,7 +41,6 @@ export function isCondRuleProp(node: ASTNode): node is CondRuleProp {
|
|||
return isRuleProp(node) && (node as CondRuleProp).rulePropType === 'cond'
|
||||
}
|
||||
|
||||
// [XXX] - What about 'rend non applicable'? Unclear what to do in this case, it seems it would create a graph edge in the contrary sense?
|
||||
type ApplicableSi = CondRuleProp & {
|
||||
dottedName: 'applicable si'
|
||||
explanation: ASTNode
|
||||
|
@ -942,10 +941,17 @@ function ruleDepsOfRuleNode<Names extends string>(
|
|||
rule['applicable si'],
|
||||
rule['non applicable si']
|
||||
].filter(x => x !== undefined) as Array<ASTNode>
|
||||
const dependenciesLists = subNodes.map(x =>
|
||||
ruleDepsOfNode<Names>(rule.dottedName, x)
|
||||
const subNodesDeps = subNodes
|
||||
.map(x => ruleDepsOfNode<Names>(rule.dottedName, x))
|
||||
.flat(1)
|
||||
|
||||
const isDisabledByDependencies = rule.isDisabledBy.map(x => x.dottedName)
|
||||
const replacedByDependencies = rule.replacedBy.map(
|
||||
x => x.referenceNode.dottedName
|
||||
)
|
||||
return [subNodesDeps, isDisabledByDependencies, replacedByDependencies].flat(
|
||||
1
|
||||
)
|
||||
return dependenciesLists.flat(1)
|
||||
}
|
||||
|
||||
export function buildRulesDependencies<Names extends string>(
|
||||
|
|
|
@ -50,8 +50,8 @@ export type ParsedRule<Name extends string = string> = Rule & {
|
|||
formule?: any
|
||||
evaluate?: Function
|
||||
explanation?: any
|
||||
isDisabledBy?: Array<any>
|
||||
replacedBy?: Array<any>
|
||||
isDisabledBy: Array<any>
|
||||
replacedBy: Array<any>
|
||||
rulePropType?: string
|
||||
jsx?: Function
|
||||
cotisation?: Partial<{
|
||||
|
|
Loading…
Reference in New Issue