From 7b76badabaaef215618ae67a84c4ff33c4b8b450 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Thu, 23 Dec 2021 22:14:34 +0100 Subject: correct recognision of entrypoints in sublayers also, the recursive check layer function slowly approaches something like readability! --- lib/CheckMap.hs | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'lib/CheckMap.hs') diff --git a/lib/CheckMap.hs b/lib/CheckMap.hs index 04f3264..63b264a 100644 --- a/lib/CheckMap.hs +++ b/lib/CheckMap.hs @@ -61,6 +61,7 @@ instance ToJSON MapResult where [ "layer" .= CollectedLints (fmap getName <$> mapresultLayer res) , "tileset" .= CollectedLints (fmap getName <$> mapresultTileset res) , "general" .= mapresultGeneral res + , "offers" .= mapresultProvides res ] newtype CollectedLints = CollectedLints (Map Hint [Text]) @@ -143,22 +144,26 @@ checkLayerRec config depth layers = (runLintWriter config parent depth checkLayer,[]) -- this is a group layer. Fun! Just sublayers -> - let - -- before linting, append the group's top-level name to that of sublayers - results = take (length sublayers) - $ checkLayerRec config depth $ sublayers - <&> \l -> l { layerName = layerName parent <> "/" <> layerName l } - -- get the original sublayer names - names = fmap layerName sublayers - -- pass the adjusted sublayers on to linting the parent layer, - -- but restore the actual names of sublayers - result = runLintWriter config - (parent { layerLayers = Just - $ zipWith (\n l -> (resultToAdjusted l) { layerName = n }) - names results - } - ) depth checkLayer - in (result,results) + (parentResult, subresults) + where + -- Lintresults for sublayers with adjusted names + subresults :: [LintResult Layer] + subresults = + take (length sublayers) + . fmap (fmap (\l -> l { layerName = layerName parent <> "/" <> layerName l } )) + $ subresults' + + -- Lintresults for sublayers and subsublayers etc. + subresults' = + checkLayerRec config depth + $ sublayers + + -- lintresult for the parent layer + parentResult = runLintWriter config parentAdjusted depth (checkLayer) + + -- the parent layer with adjusted sublayers + parentAdjusted = + parent { layerLayers = Just (fmap resultToAdjusted subresults') } -- cgit v1.2.3