1
1
mirror of https://github.com/github/semantic.git synced 2024-12-18 04:11:48 +03:00

Reorder the parameters for partial application.

This commit is contained in:
Rob Rix 2015-12-14 12:15:28 -05:00
parent 6dbaf9f53a
commit ae047f3012

View File

@ -41,7 +41,7 @@ main = do
(aTerm, bTerm) <- let parse = (parserForType . takeExtension) sourceAPath in do (aTerm, bTerm) <- let parse = (parserForType . takeExtension) sourceAPath in do
aTerm <- parse aContents aTerm <- parse aContents
bTerm <- parse bContents bTerm <- parse bContents
return (replaceLeavesWithWordBranches aTerm aContents, replaceLeavesWithWordBranches bTerm bContents) return (replaceLeavesWithWordBranches aContents aTerm, replaceLeavesWithWordBranches bContents bTerm)
let diff = interpret comparable aTerm bTerm in let diff = interpret comparable aTerm bTerm in
case output arguments of case output arguments of
Unified -> do Unified -> do
@ -61,8 +61,8 @@ parserForType mediaType = maybe P.lineByLineParser parseTreeSitterFile $ case me
".js" -> Just ts_language_javascript ".js" -> Just ts_language_javascript
_ -> Nothing _ -> Nothing
replaceLeavesWithWordBranches :: Term String Info -> String -> Term String Info replaceLeavesWithWordBranches :: String -> Term String Info -> Term String Info
replaceLeavesWithWordBranches term source = replaceIn term replaceLeavesWithWordBranches source term = replaceIn term
where where
replaceIn (info@(Info range lineRange categories) :< syntax) = info :< case syntax of replaceIn (info@(Info range lineRange categories) :< syntax) = info :< case syntax of
Leaf _ | ranges <- rangesOfWordsFrom (start range) (substring range source), length (ranges) > 1 -> Indexed $ makeLeaf lineRange categories <$> ranges Leaf _ | ranges <- rangesOfWordsFrom (start range) (substring range source), length (ranges) > 1 -> Indexed $ makeLeaf lineRange categories <$> ranges