mirror of
https://github.com/github/semantic.git
synced 2024-12-21 22:01:46 +03:00
Merge branch 'strictness' into profiling-improvements
This commit is contained in:
commit
ffa4462aab
@ -4,15 +4,15 @@ import Diff
|
|||||||
import Range
|
import Range
|
||||||
import Parser
|
import Parser
|
||||||
import Syntax
|
import Syntax
|
||||||
import Term
|
|
||||||
import TreeSitter
|
import TreeSitter
|
||||||
import Control.Comonad.Cofree
|
import Control.Comonad.Cofree
|
||||||
|
import Data.Foldable
|
||||||
|
|
||||||
parserForType :: String -> Parser
|
parserForType :: String -> Parser
|
||||||
parserForType mediaType = maybe lineByLineParser parseTreeSitterFile $ languageForType mediaType
|
parserForType mediaType = maybe lineByLineParser parseTreeSitterFile $ languageForType mediaType
|
||||||
|
|
||||||
lineByLineParser :: Parser
|
lineByLineParser :: Parser
|
||||||
lineByLineParser input = return . root . Indexed $ case foldl annotateLeaves ([], 0) lines of
|
lineByLineParser input = return . root . Indexed $ case foldl' annotateLeaves ([], 0) lines of
|
||||||
(leaves, _) -> leaves
|
(leaves, _) -> leaves
|
||||||
where
|
where
|
||||||
lines = Prelude.lines input
|
lines = Prelude.lines input
|
||||||
|
@ -33,7 +33,7 @@ unified diff before after = do
|
|||||||
|
|
||||||
unifiedRange :: Range -> [([Chunk String], Maybe Range)] -> String -> [Chunk String]
|
unifiedRange :: Range -> [([Chunk String], Maybe Range)] -> String -> [Chunk String]
|
||||||
unifiedRange range children source = out <> (pure . chunk $ substring Range { start = previous, end = end range } source) where
|
unifiedRange range children source = out <> (pure . chunk $ substring Range { start = previous, end = end range } source) where
|
||||||
(out, previous) = foldl accumulateContext ([], start range) children
|
(out, previous) = foldl' accumulateContext ([], start range) children
|
||||||
accumulateContext (out, previous) (child, Just range) = (mconcat [ out, pure . chunk $ substring Range { start = previous, end = start range } source, child ], end range)
|
accumulateContext (out, previous) (child, Just range) = (mconcat [ out, pure . chunk $ substring Range { start = previous, end = start range } source, child ], end range)
|
||||||
accumulateContext (out, previous) (child, _) = (out <> child, previous)
|
accumulateContext (out, previous) (child, _) = (out <> child, previous)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user