mirror of
https://github.com/github/semantic.git
synced 2024-12-01 00:33:59 +03:00
Implement the ToC path for Python 🎉
This commit is contained in:
parent
18db448df2
commit
c82487688f
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user