mirror of
https://github.com/github/semantic.git
synced 2024-11-28 10:15:55 +03:00
Add runRubyDiff
This commit is contained in:
parent
f5b149a137
commit
74c0bb63ac
@ -18,6 +18,9 @@ import Semantic.IO (noLanguageForBlob)
|
||||
import Semantic.Telemetry as Stat
|
||||
import Semantic.Task as Task
|
||||
import Serializing.Format
|
||||
import qualified Language.TypeScript.Assignment as TypeScript
|
||||
import qualified Language.Ruby.Assignment as Ruby
|
||||
import qualified Language.JSON.Assignment as JSON
|
||||
|
||||
runDiff :: (Member Distribute effs, Member (Exc SomeException) effs, Member (Lift IO) effs, Member Task effs, Member Telemetry effs) => DiffRenderer output -> [BlobPair] -> Eff effs Builder
|
||||
runDiff ToCDiffRenderer = withParsedBlobPairs (decorate . declarationAlgebra) (render . renderToCDiff) >=> serialize JSON
|
||||
@ -26,6 +29,27 @@ runDiff SExpressionDiffRenderer = withParsedBlobPairs (const pure) (const (seria
|
||||
runDiff ShowDiffRenderer = withParsedBlobPairs (const pure) (const (serialize Show))
|
||||
runDiff DOTDiffRenderer = withParsedBlobPairs (const pure) (const (render renderTreeGraph)) >=> serialize (DOT (diffStyle "diffs"))
|
||||
|
||||
runRubyDiff :: (Member Telemetry effs, Member (Lift IO) effs, Member Distribute effs, Member Task effs) => [BlobPair] -> Eff effs [Diff (Sum Ruby.Syntax) () ()]
|
||||
runRubyDiff = flip distributeFor (\ (blobs :: BlobPair) -> do
|
||||
terms <- distributeFor blobs (\blob -> parse rubyParser blob)
|
||||
diffs <- (diffTerms blobs) terms
|
||||
pure (bimap (const ()) (const ()) diffs))
|
||||
where
|
||||
diffTerms blobs terms = time "diff" languageTag $ do
|
||||
diff <- diff (runJoin terms)
|
||||
diff <$ writeStat (Stat.count "diff.nodes" (bilength diff) languageTag)
|
||||
where languageTag = languageTagForBlobPair blobs
|
||||
|
||||
-- runTypeScriptDiff :: (Member Distribute effs, Member Task effs) => [BlobPair] -> Eff effs [Term (Sum TypeScript.Syntax) ()]
|
||||
-- runTypeScriptDiff = flip distributeFor (\ blob -> do
|
||||
-- term <- parse typescriptParser blob
|
||||
-- pure diffs)
|
||||
--
|
||||
-- runJSONDiff :: (Member Distribute effs, Member Task effs) => [BlobPair] -> Eff effs [Term (Sum JSON.Syntax) ()]
|
||||
-- runJSONDiff = flip distributeFor (\ blob -> do
|
||||
-- term <- parse jsonParser blob
|
||||
-- pure (() <$ term))
|
||||
|
||||
data SomeTermPair typeclasses ann where
|
||||
SomeTermPair :: ApplyAll typeclasses syntax => Join These (Term syntax ann) -> SomeTermPair typeclasses ann
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user