From 9d65261669c6c6084df4ff9a7cbac5bfb13d85e8 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 30 Nov 2016 15:31:05 -0600 Subject: [PATCH] Add Break support to DiffSummaries --- src/DiffSummary.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index d6b137dc8..86fc3d91c 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -154,6 +154,7 @@ determiner (LeafInfo "else block" _ _) = "an" determiner (LeafInfo "ensure block" _ _) = "an" determiner (LeafInfo "when block" _ _) = "a" determiner (LeafInfo "anonymous function" _ _) = "an" +determiner (LeafInfo "break statement" _ _) = "a" determiner (BranchInfo bs _ _) = determiner (last bs) determiner _ = "the" @@ -175,6 +176,7 @@ toLeafInfos leaf = pure . flip JSONSummary (sourceSpan leaf) $ case leaf of (LeafInfo cName@"export statement" termName _) -> toDoc termName <+> toDoc cName (LeafInfo cName@"import statement" termName _) -> toDoc termName <+> toDoc cName (LeafInfo cName@"subshell command" termName _) -> toDoc termName <+> toDoc cName + (LeafInfo cName@"break statement" _ _) -> toDoc cName LeafInfo{..} -> squotes (toDoc termName) <+> toDoc categoryName node -> panic $ "Expected a leaf info but got a: " <> show node @@ -249,6 +251,7 @@ toTermName source term = case unwrap term of S.ConditionalAssignment id _ -> toTermName' id S.Negate expr -> toTermName' expr S.Rescue args _ -> intercalate ", " $ toTermName' <$> args + S.Break expr -> toTermName' expr where toTermName' = toTermName source termNameFromChildren term children = termNameFromRange (unionRangesFrom (range term) (range <$> children)) termNameFromSource term = termNameFromRange (range term) @@ -416,6 +419,7 @@ instance HasCategory Category where C.SplatParameter -> "parameter" C.HashSplatParameter -> "parameter" C.BlockParameter -> "parameter" + C.Break -> "break statement" instance HasField fields Category => HasCategory (SyntaxTerm leaf fields) where toCategoryName = toCategoryName . category . extract