From 7d4e6affc260fad5290be3dc0cf9713a82284417 Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 8 Aug 2016 15:23:08 -0400 Subject: [PATCH 1/2] Output error text from source --- src/DiffSummary.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index 001cd79d3..f616349d3 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -63,7 +63,7 @@ toTermName source term = case unwrap term of S.Object kvs -> "{" <> intercalate ", " (toTermName' <$> kvs) <> "}" S.Pair a b -> toTermName' a <> ": " <> toTermName' b S.Return expr -> maybe "empty" toTermName' expr - S.Error span _ -> displayStartEndPos span + S.Error _ _ -> termNameFromSource term S.For _ _ -> termNameFromChildren term S.While expr _ -> toTermName' expr S.DoWhile _ expr -> toTermName' expr From 12f2300fa9803b8c1ae3fa895bce2e5c310589f2 Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 8 Aug 2016 15:28:09 -0400 Subject: [PATCH 2/2] Print the error term when printing ErrorInfos --- src/DiffSummary.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index f616349d3..5c4b21239 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -23,7 +23,7 @@ import Source data DiffInfo = LeafInfo { categoryName :: Text, termName :: Text } | BranchInfo { branches :: [ DiffInfo ], categoryName :: Text, branchType :: Branch } - | ErrorInfo { errorSpan :: SourceSpan, categoryName :: Text } + | ErrorInfo { errorSpan :: SourceSpan, termName :: Text } deriving (Eq, Show) toTermName :: (HasCategory leaf, HasField fields Category, HasField fields Range) => Source Char -> Term leaf (Record fields) -> Text @@ -152,7 +152,7 @@ instance (Eq a, Arbitrary a) => Arbitrary (DiffSummary a) where instance P.Pretty DiffInfo where pretty LeafInfo{..} = squotes (string $ toSL termName) <+> (string $ toSL categoryName) pretty BranchInfo{..} = mconcat $ punctuate (string "," <> space) (pretty <$> branches) - pretty ErrorInfo{..} = "syntax error at" <+> (string . toSL $ displayStartEndPos errorSpan) <+> "in" <+> (string . toSL $ spanName errorSpan) + pretty ErrorInfo{..} = squotes (string $ toSL termName) <+> "at" <+> (string . toSL $ displayStartEndPos errorSpan) <+> "in" <+> (string . toSL $ spanName errorSpan) annotatedSummaries :: DiffSummary DiffInfo -> [Text] annotatedSummaries DiffSummary{..} = show . (P.<> maybeParentContext parentAnnotations) <$> summaries patch @@ -231,7 +231,7 @@ termToDiffInfo blob term = case unwrap term of -- use the term name of the operator identifier when we have that production value. Until then, I'm using a placeholder value -- to indicate where that value should be when constructing DiffInfos. Commented cs leaf -> BranchInfo (termToDiffInfo' <$> cs <> maybeToList leaf) (toCategoryName term) BCommented - S.Error sourceSpan _ -> ErrorInfo sourceSpan (toCategoryName term) + S.Error sourceSpan _ -> ErrorInfo sourceSpan (toTermName' term) _ -> LeafInfo (toCategoryName term) (toTermName' term) where toTermName' = toTermName blob termToDiffInfo' = termToDiffInfo blob