diff options
Diffstat (limited to '')
-rw-r--r-- | lib/Properties.hs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/Properties.hs b/lib/Properties.hs index 320f132..68cf88a 100644 --- a/lib/Properties.hs +++ b/lib/Properties.hs @@ -13,7 +13,7 @@ import Tiled2 (Layer (..), Property (..), PropertyValue (..), import Util (layerIsEmpty, prettyprint) import LintWriter (LintWriter, complain, dependsOn, forbid, info, - suggest, warn) + suggest, warn, LayerContext) import Paths import Types (Dep (Link, Local, LocalMap, MapLink)) @@ -83,7 +83,7 @@ checkTileset tileset = do -- -- It gets a reference to its own layer since sometimes the presence -- of one property implies the presence or absense of another. -checkLayerProperty :: Layer -> Property -> LintWriter () +checkLayerProperty :: Layer -> Property -> LintWriter LayerContext checkLayerProperty layer p@(Property name value) = case name of "jitsiRoom" -> do uselessEmptyLayer @@ -182,18 +182,18 @@ containsProperty props name = any (\(Property name' _) -> name' == name) props -- | this property is forbidden and should not be used -forbidProperty :: Text -> LintWriter () +forbidProperty :: Text -> LintWriter a forbidProperty name = forbid $ "property " <> prettyprint name <> " should not be used" -- | asserts that this property is a string, and unwraps it -unwrapString :: Property -> (Text -> LintWriter ()) -> LintWriter () +unwrapString :: Property -> (Text -> LintWriter a) -> LintWriter a unwrapString (Property name value) f = case value of StrProp str -> f str _ -> complain $ "type mismatch in property " <> name <> "; should be of type string" -- | same as unwrapString, but also forbids http:// as prefix -unwrapLink :: Property -> (Text -> LintWriter ()) -> LintWriter () +unwrapLink :: Property -> (Text -> LintWriter a) -> LintWriter a unwrapLink (Property name value) f = case value of StrProp str -> if "http://" `isPrefixOf` str then complain "cannot access content via http; either use https or include it locally instead." @@ -201,31 +201,31 @@ unwrapLink (Property name value) f = case value of _ -> complain $ "type mismatch in property " <> name <> "; should be of typ string" -- | asserts that this property is a boolean, and unwraps it -unwrapBool :: Property -> (Bool -> LintWriter ()) -> LintWriter () +unwrapBool :: Property -> (Bool -> LintWriter a) -> LintWriter a unwrapBool (Property name value) f = case value of BoolProp b -> f b _ -> complain $ "type mismatch in property " <> name <> "; should be of type bool" -unwrapPath :: Text -> (RelPath -> LintWriter ()) -> LintWriter () +unwrapPath :: Text -> (RelPath -> LintWriter a) -> LintWriter a unwrapPath str f = case parsePath str of Just path -> f path Nothing -> complain $ "path \"" <> str <> "\" is invalid" -- | just asserts that this is a string -isString :: Property -> LintWriter () +isString :: Property -> LintWriter a isString = flip unwrapString (const $ pure ()) -- | just asserts that this is a boolean -isBool :: Property -> LintWriter () +isBool :: Property -> LintWriter a isBool = flip unwrapBool (const $ pure ()) -- | require some property -requireProperty :: [Property] -> Text -> LintWriter () +requireProperty :: [Property] -> Text -> LintWriter a requireProperty props name = unless (containsProperty props name) $ complain $ "property "<>prettyprint name<>" requires property "<>prettyprint name -- | suggest soem value for another property if that property does not -- also already exist -suggestPropertyValue :: [Property] -> Property -> LintWriter () +suggestPropertyValue :: [Property] -> Property -> LintWriter a suggestPropertyValue props (Property name value) = unless (containsProperty props name) $ suggest $ "set property " <> prettyprint name <> " to " <> prettyprint value |