on develop help sign in
Ensuring method namespaces are correctly parsed and rendered
32da28aBrendan Hay
gen/src/Gen/Types.hs+6−5
@@ -38,6 +38,7 @@ import Control.Monad.Except
38import Control.Monad.State.Strict
38import Control.Monad.State.Strict
39import Data.Aeson hiding (Array, Bool, String)
39import Data.Aeson hiding (Array, Bool, String)
40import Data.CaseInsensitive (CI)
40import Data.CaseInsensitive (CI)
41+import qualified Data.CaseInsensitive as CI
41import Data.Function (on)
42import Data.Function (on)
42import qualified Data.HashMap.Strict as Map
43import qualified Data.HashMap.Strict as Map
43import qualified Data.HashSet as Set
44import qualified Data.HashSet as Set
@@ -265,16 +266,16 @@ data Memo = Memo
265 }
266 }
266
267
267initial :: Service (Fix Schema) -> Memo
268initial :: Service (Fix Schema) -> Memo
268−initial s = Memo s mempty mempty core mempty mempty mempty
269+initial s = Memo s mempty mempty core mempty reserve mempty
269 where
270 where
271+ -- Types available in Network.Google.Prelude.
270 core = Map.fromList
272 core = Map.fromList
271 [ ("Body", SLit requiredInfo Body)
273 [ ("Body", SLit requiredInfo Body)
272 ]
274 ]
273
275
274−-- reserve :: Flattened -> AST ()
276+ -- Reserved sum constructor names.
275−-- reserve svc = do
277+ reserve = Map.singleton mempty . Set.fromList $
276−-- let bs = Set.fromList $ map (CI.mk . idToText) (_svcSchemas svc)
278+ map (CI.mk . global) (Map.keys (s ^. dSchemas))
277−-- branches %= Map.insert mempty bs
278
279
279makeLenses ''Memo
280makeLenses ''Memo
280
281
gen/src/Gen/Types/Id.hs+2−2
@@ -70,13 +70,13 @@ mname abrv (Suffix suf) (Global g) =
70 , Text.intercalate "." ns -- Action namespace.
70 , Text.intercalate "." ns -- Action namespace.
71 )
71 )
72 where
72 where
73− n = drop 1 (map (upperHead . upperAcronym) ns)
73+ n = drop 1 ns
74
74
75 ns | CI.mk e == CI.mk x = e:xs
75 ns | CI.mk e == CI.mk x = e:xs
76 | otherwise = x:xs
76 | otherwise = x:xs
77 where
77 where
78 e = Text.replace "." "" abrv
78 e = Text.replace "." "" abrv
79− x:xs = g
79+ x:xs = map (upperAcronym . toPascal) g
80
80
81dname, cname :: Global -> Name
81dname, cname :: Global -> Name
82dname = name . Text.unpack . upperHead . global
82dname = name . Text.unpack . upperHead . global