1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 14:21:31 +03:00

Merge pull request #914 from github/formatting

Make function formatting consistent in Renderer.JSON.hs
This commit is contained in:
Rick Winfrey 2016-12-05 10:18:48 -08:00 committed by GitHub
commit a60e7aa268

View File

@ -66,7 +66,11 @@ instance (ToJSON (Record fields), ToJSON leaf, HasField fields Category, HasFiel
toEncoding term | toEncoding term |
(info :< syntax) <- runCofree term = pairs $ mconcat (termFields info syntax) (info :< syntax) <- runCofree term = pairs $ mconcat (termFields info syntax)
lineFields :: (ToJSON leaf, ToJSON (Record fields), HasField fields Category, HasField fields Range) => KeyValue kv => Int -> SplitSyntaxDiff leaf fields -> Range -> [kv] lineFields :: (ToJSON leaf, ToJSON (Record fields), HasField fields Category, HasField fields Range, KeyValue kv) =>
Int ->
SplitSyntaxDiff leaf fields ->
Range ->
[kv]
lineFields n term range = [ "number" .= n lineFields n term range = [ "number" .= n
, "terms" .= [ term ] , "terms" .= [ term ]
, "range" .= range , "range" .= range
@ -79,7 +83,9 @@ termFields :: (ToJSON recur, KeyValue kv, HasField fields Category, HasField fie
[kv] [kv]
termFields info syntax = "range" .= characterRange info : "category" .= category info : syntaxToTermField syntax termFields info syntax = "range" .= characterRange info : "category" .= category info : syntaxToTermField syntax
patchFields :: (ToJSON (Record fields), ToJSON leaf, KeyValue kv, HasField fields Category, HasField fields Range) => SplitPatch (SyntaxTerm leaf fields) -> [kv] patchFields :: (ToJSON (Record fields), ToJSON leaf, KeyValue kv, HasField fields Category, HasField fields Range) =>
SplitPatch (SyntaxTerm leaf fields) ->
[kv]
patchFields patch = case patch of patchFields patch = case patch of
SplitInsert term -> fields "insert" term SplitInsert term -> fields "insert" term
SplitDelete term -> fields "delete" term SplitDelete term -> fields "delete" term
@ -88,7 +94,9 @@ patchFields patch = case patch of
fields kind term | fields kind term |
(info :< syntax) <- runCofree term = "patch" .= T.pack kind : termFields info syntax (info :< syntax) <- runCofree term = "patch" .= T.pack kind : termFields info syntax
syntaxToTermField :: (ToJSON recur, KeyValue kv) => Syntax leaf recur -> [kv] syntaxToTermField :: (ToJSON recur, KeyValue kv) =>
Syntax leaf recur ->
[kv]
syntaxToTermField syntax = case syntax of syntaxToTermField syntax = case syntax of
Leaf _ -> [] Leaf _ -> []
Indexed c -> childrenFields c Indexed c -> childrenFields c