diff --git a/src/Category.hs b/src/Category.hs index 57848ead4..94cf4812b 100644 --- a/src/Category.hs +++ b/src/Category.hs @@ -159,6 +159,8 @@ data Category | HashSplatParameter -- | A block parameter, e.g. def foo(&block) in Ruby. | BlockParameter + -- | A float literal. + | FloatLiteral deriving (Eq, Generic, Ord, Show) -- Instances @@ -187,6 +189,7 @@ instance Arbitrary Category where , pure StringLiteral , pure IntegerLiteral , pure NumberLiteral + , pure FloatLiteral , pure Regex , pure Return , pure SymbolLiteral diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index d6b137dc8..3187f6734 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -147,6 +147,7 @@ prefixWithPatch patch constructor = prefixWithThe (patchToPrefix patch) determiner :: DiffInfo -> Doc determiner (LeafInfo "number" _ _) = "" determiner (LeafInfo "integer" _ _) = "" +determiner (LeafInfo "float" _ _) = "" determiner (LeafInfo "boolean" _ _) = "" determiner (LeafInfo "begin statement" _ _) = "a" determiner (LeafInfo "select statement" _ _) = "a" @@ -163,6 +164,7 @@ toLeafInfos BranchInfo{..} = branches >>= toLeafInfos toLeafInfos HideInfo = [] toLeafInfos leaf = pure . flip JSONSummary (sourceSpan leaf) $ case leaf of (LeafInfo "number" termName _) -> squotes $ toDoc termName + (LeafInfo "float" termName _) -> squotes $ toDoc termName (LeafInfo "integer" termName _) -> squotes $ toDoc termName (LeafInfo "boolean" termName _) -> squotes $ toDoc termName (LeafInfo "anonymous function" termName _) -> toDoc termName <+> "function" @@ -361,6 +363,7 @@ instance HasCategory Category where Identifier -> "identifier" IntegerLiteral -> "integer" NumberLiteral -> "number" + FloatLiteral -> "float" Other s -> s C.Pair -> "pair" C.Params -> "params" diff --git a/src/Language/Go.hs b/src/Language/Go.hs index bd09a6164..69e0205b2 100644 --- a/src/Language/Go.hs +++ b/src/Language/Go.hs @@ -44,6 +44,7 @@ termConstructor source sourceSpan name range children = case name of clauses' <- withDefaultInfo $ S.Indexed clauses withDefaultInfo $ S.Switch clauses' cases where isCaseClause = (== Case) . category . extract + "assignment_statement" -> toVarAssignment children "type_switch_statement" -> case Prologue.break isCaseClause children of (clauses, cases) -> do @@ -72,6 +73,7 @@ termConstructor source sourceSpan name range children = case name of [id] -> S.FunctionCall id [] rest -> S.Error rest "const_declaration" -> toConsts children + "const_spec" -> toConsts children "func_literal" -> withDefaultInfo $ case children of [params, _, body] -> S.AnonymousFunction (toList $ unwrap params) (toList $ unwrap body) rest -> S.Error rest @@ -124,15 +126,18 @@ termConstructor source sourceSpan name range children = case name of _ -> withCategory Error (S.Error list) toConsts constSpecs = do - assignments' <- sequenceA $ toVarAssignment <$> constSpecs + assignments' <- sequenceA $ constSpecToVarAssignment <$> constSpecs withDefaultInfo (S.Indexed assignments') - toVarAssignment constSpec = - case toList (unwrap constSpec) of + constSpecToVarAssignment = toVarAssignment . toList . unwrap + toVarAssignment = \case [idList, expressionList] -> do - assignments' <- sequenceA $ zipWith (\id expr -> withDefaultInfo $ S.VarAssignment id expr) (toList $ unwrap idList) (toList $ unwrap expressionList) + assignments' <- sequenceA $ zipWith (\id expr -> + withDefaultInfo $ S.VarAssignment id expr) + (toList $ unwrap idList) (toList $ unwrap expressionList) withDefaultInfo (S.Indexed assignments') [idList, _, expressionList] -> do - assignments' <- sequenceA $ zipWith (\id expr -> withDefaultInfo $ S.VarAssignment id expr) (toList $ unwrap idList) (toList $ unwrap expressionList) + assignments' <- sequenceA $ zipWith (\id expr -> + withDefaultInfo $ S.VarAssignment id expr) (toList $ unwrap idList) (toList $ unwrap expressionList) withDefaultInfo (S.Indexed assignments') [idList] -> do varDecls <- mapM (withDefaultInfo . S.VarDecl) (toList $ unwrap idList) @@ -155,6 +160,7 @@ categoryForGoName :: Text -> Category categoryForGoName = \case "identifier" -> Identifier "int_literal" -> NumberLiteral + "float_literal" -> FloatLiteral "comment" -> Comment "return_statement" -> Return "interpreted_string_literal" -> StringLiteral diff --git a/src/Language/JavaScript.hs b/src/Language/JavaScript.hs index e036d2162..970750e7a 100644 --- a/src/Language/JavaScript.hs +++ b/src/Language/JavaScript.hs @@ -140,6 +140,7 @@ categoryForJavaScriptProductionName name = case name of "string" -> StringLiteral "integer" -> IntegerLiteral "number" -> NumberLiteral + "float" -> FloatLiteral "symbol" -> SymbolLiteral "array" -> ArrayLiteral "function" -> Function diff --git a/src/Language/Ruby.hs b/src/Language/Ruby.hs index d1141e831..223a76dcb 100644 --- a/src/Language/Ruby.hs +++ b/src/Language/Ruby.hs @@ -164,7 +164,7 @@ categoryForRubyName = \case "elsif_block" -> Elsif "ensure_block" -> Ensure "ERROR" -> Error - "float" -> NumberLiteral + "float" -> FloatLiteral "for_statement" -> For "formal_parameters" -> Params "function_call" -> FunctionCall diff --git a/src/Renderer/Split.hs b/src/Renderer/Split.hs index 0095d0632..a0fdae002 100644 --- a/src/Renderer/Split.hs +++ b/src/Renderer/Split.hs @@ -43,6 +43,7 @@ styleName category = "category-" <> case category of SymbolLiteral -> "symbol" IntegerLiteral -> "integer" NumberLiteral -> "number" + FloatLiteral -> "float" C.Comment -> "comment" C.FunctionCall -> "function_call" C.Function -> "function"