mirror of
https://github.com/github/semantic.git
synced 2024-11-24 08:54:07 +03:00
Stat node counts of term and diff
This commit is contained in:
parent
0780d675c5
commit
3cd67c0f8d
@ -16,6 +16,7 @@ import Data.ByteString (ByteString)
|
||||
import Data.Diff
|
||||
import Data.Functor.Both as Both
|
||||
import Data.Output
|
||||
import Data.Bifoldable
|
||||
import Data.Record
|
||||
import Data.Syntax.Algebra
|
||||
import Data.Term
|
||||
@ -26,6 +27,7 @@ import qualified Language
|
||||
import Parser
|
||||
import Renderer
|
||||
import Semantic.Task as Task
|
||||
import Semantic.Stat as Stat
|
||||
|
||||
-- This is the primary interface to the Semantic library which provides two
|
||||
-- major classes of functionality: semantic parsing and diffing of source code
|
||||
@ -108,11 +110,12 @@ diffBlobPair renderer blobs = case (renderer, effectiveLanguage) of
|
||||
(Blob { blobPath = path }, _) -> (path, Nothing)
|
||||
syntaxParser = effectiveLanguage >>= parserForLanguage
|
||||
|
||||
run :: Functor syntax => (Blob -> Task (Term syntax ann)) -> (Term syntax ann -> Term syntax ann -> Diff syntax ann ann) -> (Diff syntax ann ann -> output) -> Task output
|
||||
run :: (Foldable syntax, Functor syntax) => (Blob -> Task (Term syntax ann)) -> (Term syntax ann -> Term syntax ann -> Diff syntax ann ann) -> (Diff syntax ann ann -> output) -> Task output
|
||||
run parse diff renderer = do
|
||||
terms <- distributeFor blobs parse
|
||||
time "diff" languageTag $ do
|
||||
diff <- runBothWith (diffTermPair blobs diff) terms
|
||||
writeStat (Stat.count "diff.nodes" (bilength diff) languageTag)
|
||||
render renderer diff
|
||||
where
|
||||
showLanguage = pure . (,) "language" . show
|
||||
|
@ -216,6 +216,7 @@ runParser Options{..} blob@Blob{..} = go
|
||||
for_ (errors term) $ \ err -> do
|
||||
writeStat (Stat.increment "parse.parse_errors" languageTag)
|
||||
writeLog Warning (Error.formatError optionsPrintSource (optionsIsTerminal && optionsEnableColour) blob err) (("tag", "assign") : blobFields)
|
||||
writeStat (Stat.count "parse.nodes" (length term) languageTag)
|
||||
pure term
|
||||
TreeSitterParser tslanguage ->
|
||||
time "parse.tree_sitter_parse" languageTag $
|
||||
|
Loading…
Reference in New Issue
Block a user