on develop help sign in
Adding renaming/replacement of prefix special characters
commit6cffe095d63f8deeb415f005f2965b6ee5f36668 authorBrendan Hay <brendan.g.hay@gmail.com> dateSat 19 Mar 2016, 10:09 (11 years ago) parent6e886fe
3 files changed+11−6
gen/src/Gen/AST/Solve.hs+2−2 gen/src/Gen/Text.hs+8 gen/src/Gen/Types/Schema.hs+1−4
gen/src/Gen/AST/Solve.hs+2−2
@@ -196,8 +196,8 @@ overlap :: (Eq a, Hashable a) => Set a -> Set a -> Bool
196196overlap xs ys = not . Set.null $ Set.intersection xs ys
197197
198198acronymPrefixes :: Global -> [CI Text]
199−acronymPrefixes (global -> g) = filter (/= full) $
200− map CI.mk (xs ++ map suffix ys ++ zs)
199+acronymPrefixes (global -> renameSpecial -> g) =
200+ filter (/= full) $ map CI.mk (xs ++ map suffix ys ++ zs)
201201 where
202202 -- Take the next char
203203 suffix x = Text.snoc x c
gen/src/Gen/Text.hs+8
@@ -88,6 +88,14 @@ renameBranch t
8888 , (">=", "GreaterEqual")
8989 ]
9090
91+renameSpecial :: Text -> Text
92+renameSpecial t =
93+ case Text.uncons t of
94+ Nothing -> t
95+ Just (x, xs)
96+ | separator x -> renameSpecial xs
97+ | otherwise -> t
98+
9199separator :: Char -> Bool
92100separator x =
93101 x == '\\'
gen/src/Gen/Types/Schema.hs+1−4
@@ -31,7 +31,6 @@ import Data.Aeson hiding (Array, Bool, Object, String)
3131import qualified Data.Aeson as A
3232import Data.Aeson.TH
3333import Data.Aeson.Types (Parser)
34−import Data.Foldable (foldMap)
3534import Data.Function (on)
3635import qualified Data.HashMap.Strict as Map
3736import Data.Maybe
@@ -439,12 +438,10 @@ serviceName = Text.unpack . (<> "Service") . toCamel . _sCanonicalName
439438
440439scopeName :: Service a -> Text -> String
441440scopeName s k = Text.unpack . toCamel $
442− case parts of
441+ case filter (not . url) (Text.split (== '/') k) of
443442 [] -> _sCanonicalName s <> "AllScope"
444443 xs -> foldMap upperHead xs <> "Scope"
445444 where
446− parts = filter (not . url) (Text.split (== '/') k)
447−
448445 url x = Text.null x
449446 || Text.isPrefixOf "http" x
450447 || Text.isPrefixOf "www" x