1
1
mirror of https://github.com/github/semantic.git synced 2025-01-02 20:41:38 +03:00

Rename Default to DefaultCase

This commit is contained in:
joshvera 2017-01-18 14:06:45 -05:00
parent b3a300f745
commit 7f396dd7b7
6 changed files with 12 additions and 9 deletions

View File

@ -40,6 +40,8 @@ data Category
| Args
-- | A string literal.
| StringLiteral
-- | An integer literal.
| IntegerLiteral
-- | A regex literal.
| Regex
-- | A return statement.
@ -191,7 +193,7 @@ data Category
| EndBlock
| ParameterDecl
-- | A default case in a switch statement.
| Default
| DefaultCase
-- | A type declaration.
| TypeDecl
| PointerTy
@ -328,7 +330,7 @@ instance Listable Category where
\/ cons0 BeginBlock
\/ cons0 EndBlock
\/ cons0 ParameterDecl
\/ cons0 Default
\/ cons0 DefaultCase
\/ cons0 TypeDecl
\/ cons0 PointerTy
\/ cons0 FieldDecl

View File

@ -263,7 +263,7 @@ toTermName source term = case unwrap term of
S.Break expr -> maybe "" toTermName' expr
S.Continue expr -> maybe "" toTermName' expr
S.BlockStatement children -> termNameFromChildren term children
S.Default children -> termNameFromChildren term children
S.DefaultCase children -> termNameFromChildren term children
S.FieldDecl id expr tag -> termNameFromSource id <> (maybe "" (\expr' -> " " <> termNameFromSource expr') expr) <> (maybe "" ((" " <>) . termNameFromSource) tag)
where toTermName' = toTermName source
termNameFromChildren term children = termNameFromRange (unionRangesFrom (range term) (range <$> children))
@ -309,7 +309,7 @@ parentContexts contexts = hsep $ either identifiableDoc annotatableDoc <$> conte
C.When -> "in a" <+> catName c
C.BeginBlock -> "in a" <+> catName c
C.EndBlock -> "in an" <+> catName c
C.Default -> "in a" <+> catName c
C.DefaultCase -> "in a" <+> catName c
C.TypeDecl -> "in the" <+> squotes (termName t) <+> catName c
_ -> "in the" <+> termName t <+> catName c
annotatableDoc (c, t) = "of the" <+> squotes (termName t) <+> catName c
@ -461,7 +461,7 @@ instance HasCategory Category where
C.BeginBlock -> "BEGIN block"
C.EndBlock -> "END block"
C.ParameterDecl -> "parameter declaration"
C.Default -> "default statement"
C.DefaultCase -> "default statement"
C.TypeDecl -> "type declaration"
C.PointerTy -> "pointer type"
C.FieldDecl -> "field declaration"

View File

@ -57,7 +57,7 @@ termConstructor source sourceSpan name range children _ = case name of
toCase clause = case toList (unwrap clause) of
clause' : rest -> case toList (unwrap clause') of
[clause''] -> withCategory Case $ S.Case clause'' rest
[] -> withCategory Default $ S.Default rest
[] -> withCategory DefaultCase $ S.DefaultCase rest
rest -> withCategory Error $ S.Error rest
[] -> withCategory Error $ S.Error [clause]
"parameter_declaration" -> withDefaultInfo $ case children of

View File

@ -147,7 +147,7 @@ syntaxToTermField syntax = case syntax of
S.Continue expr -> [ "expression" .= expr ]
S.BlockStatement c -> childrenFields c
S.ParameterDecl ty field -> [ "type" .= ty ] <> [ "identifier" .= field ]
S.Default c -> childrenFields c
S.DefaultCase c -> childrenFields c
S.TypeDecl id ty -> [ "type" .= ty ] <> [ "identifier" .= id ]
S.FieldDecl id ty tag -> [ "type" .= ty ] <> [ "identifier" .= id ] <> [ "tag" .= tag]
S.Ty ty -> [ "type" .= ty ]

View File

@ -129,7 +129,7 @@ styleName category = "category-" <> case category of
C.BeginBlock -> "begin_block"
C.EndBlock -> "end_block"
C.ParameterDecl -> "parameter_declaration"
C.Default -> "default_statement"
C.DefaultCase -> "default_statement"
C.TypeDecl -> "type_declaration"
C.PointerTy -> "pointer_type"
C.FieldDecl -> "field_declaration"

View File

@ -48,7 +48,7 @@ data Syntax a f
| Switch { switchExpr :: (Maybe f), cases :: [f] }
| Case { caseExpr :: f, caseStatements :: [f] }
-- | A default case in a switch statement.
| Default [f]
| DefaultCase [f]
| Select { cases :: [f] }
| Object { objectTy :: Maybe f, keyValues :: [f] }
-- | A pair in an Object. e.g. foo: bar or foo => bar
@ -163,6 +163,7 @@ instance Listable2 Syntax where
\/ liftCons3 recur (liftTiers recur) (liftTiers recur) FieldDecl
\/ liftCons1 recur Ty
\/ liftCons2 recur recur Send
\/ liftCons1 (liftTiers recur) DefaultCase
instance Listable leaf => Listable1 (Syntax leaf) where
liftTiers = liftTiers2 tiers