From 125b63927dd0dbe40ae2c4745ced7520e548968c Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Sun, 20 Feb 2022 01:39:12 +0100 Subject: [PATCH] Improve shadowing detection of mappings --- Models/ThemeConfig/Conversion/Validation.ts | 32 ++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/Models/ThemeConfig/Conversion/Validation.ts b/Models/ThemeConfig/Conversion/Validation.ts index dc17d0d50..5380360d3 100644 --- a/Models/ThemeConfig/Conversion/Validation.ts +++ b/Models/ThemeConfig/Conversion/Validation.ts @@ -248,9 +248,19 @@ export class DetectShadowedMappings extends DesugaringStep TagUtils.Tag(m.if)) + const parsedConditions = json.mappings.map(m => { + const ifTags = TagUtils.Tag(m.if); + if(m.hideInAnswer !== undefined && m.hideInAnswer !== false && m.hideInAnswer !== true){ + let conditionTags = TagUtils.Tag( m.hideInAnswer) + // Merge the condition too! + return new And([conditionTags, ifTags]) + } + return ifTags + }) for (let i = 0; i < json.mappings.length; i++) { - if(json.mappings[i].hideInAnswer === true){ + if(!parsedConditions[i].isUsableAsAnswer()){ + // There is no straightforward way to convert this mapping.if into a properties-object, so we simply skip this one + // Yes, it might be shadowed, but running this check is to difficult right now continue } const keyValues = parsedConditions[i].asChange({}); @@ -259,14 +269,11 @@ export class DetectShadowedMappings extends DesugaringStep { constructor() { super("Various validation on tagRenderingConfigs", - // TODO enable these checks again - // new DetectShadowedMappings(), + new DetectShadowedMappings(), new DetectMappingsWithImages() ); }