From 1c82540aeea7636a6cfd25acfdd28c1029f5669f Mon Sep 17 00:00:00 2001 From: stuebinm Date: Sat, 18 Sep 2021 01:59:00 +0200 Subject: can collect dependencies! There's now a Lint type, which may be either a "true lint" (which is a Hint, which contains some message and level of severity), or a Depends, which indicates that this map depends on some ressource or other (and is otherwise treated as a special info Hint in all other cases) --- lib/CheckMap.hs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib/CheckMap.hs') diff --git a/lib/CheckMap.hs b/lib/CheckMap.hs index 0ff3fae..36cbf9d 100644 --- a/lib/CheckMap.hs +++ b/lib/CheckMap.hs @@ -16,18 +16,20 @@ import qualified Data.Text as T import qualified Data.Vector as V import GHC.Generics (Generic) -import LintWriter (Hint (..), Level (..), - LintResult (..), LintWriter, hint) +import LintWriter (Level (..), Lint (..), + LintResult (..), LintWriter, hint, + lintLevel) import Properties (checkProperty) import Tiled2 (Layer (layerName, layerProperties), Tiledmap (tiledmapLayers), loadTiledmap) -import Util (prettyprint, PrettyPrint (prettyprint)) +import Util (PrettyPrint (prettyprint), + prettyprint) -- | What this linter produces: lints for a single map data MapResult a = MapResult { mapresultLayer :: Maybe (Map Text (LintResult a)) - , mapresultGeneral :: [Hint] + , mapresultGeneral :: [Lint] } deriving (Generic, ToJSON) @@ -83,12 +85,12 @@ showContext ctxt = " (in layer " <> ctxt <> ")\n" -- a wrapper type for that – but I wasn't really in the mood) showResult :: Text -> LintResult a -> Maybe Text showResult ctxt (LintResult res) = case res of - Left hint -> Just $ "ERROR: " <> hintMsg hint <> showContext ctxt - Right (_, []) -> Nothing + Left hint -> Just $ "Fatal: " <> prettyprint hint + Right (_, []) -> Nothing Right (_, hints) -> Just $ T.concat (mapMaybe showHint hints) where -- TODO: make the "log level" configurable - showHint hint = case hintLevel hint of + showHint hint = case lintLevel hint of Info -> Nothing _ -> Just $ prettyprint hint <> ctxtHint ctxtHint = showContext ctxt -- cgit v1.2.3