diff --git a/src/Semantic.hs b/src/Semantic.hs index 98979fc18..78204d5ba 100644 --- a/src/Semantic.hs +++ b/src/Semantic.hs @@ -11,11 +11,15 @@ import Algorithm hiding (diff) import Data.Align.Generic (GAlign) import Data.Functor.Both as Both import Data.Functor.Classes (Eq1, Show1) +import Data.Functor.Union +import Data.Proxy import Data.Record +import qualified Data.Syntax.Declaration as Declaration import Diff import Info import Interpreter import qualified Language +import qualified Language.Python.Syntax as Python import Patch import Parser import Prologue @@ -55,6 +59,7 @@ diffBlobPairs renderer = fmap toS . distributeFoldMap (diffBlobPair renderer) . -- | A task to parse a pair of 'SourceBlob's, diff them, and render the 'Diff'. diffBlobPair :: DiffRenderer output -> Both SourceBlob -> Task output diffBlobPair renderer blobs = case (renderer, effectiveLanguage) of + (ToCDiffRenderer, Just Language.Python) -> run (\ source -> parse pythonParser source >>= decorate (declarationAlgebra (Proxy :: Proxy Python.Error) source) . hoistCofree (weaken . weaken :: Union fs a -> Union (Declaration.Function ': Declaration.Method ': fs) a)) diffLinearly (renderToC blobs) (ToCDiffRenderer, _) -> run (\ source -> parse syntaxParser source >>= decorate (syntaxDeclarationAlgebra source)) diffTerms (renderToC blobs) (JSONDiffRenderer, Just Language.Python) -> run (parse pythonParser) diffLinearly (renderJSONDiff blobs) (JSONDiffRenderer, _) -> run (decorate identifierAlgebra <=< parse syntaxParser) diffTerms (renderJSONDiff blobs)