1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 00:42:33 +03:00

Merge branch 'master' into optimize-for-large-nested-branches

This commit is contained in:
Rob Rix 2017-06-14 16:56:09 -04:00 committed by GitHub
commit 17f577b3f3
4 changed files with 12 additions and 4 deletions

View File

@ -15,6 +15,7 @@ import Data.String
import Language
import Prologue hiding (readFile)
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as BL
import qualified Data.Text.ICU.Convert as Convert
import qualified Data.Text.ICU.Detect as Detect
import Prelude (fail)
@ -55,8 +56,8 @@ readBlobsFromHandle = fmap toSourceBlobs . readFromHandle
readFromHandle :: FromJSON a => Handle -> IO a
readFromHandle h = do
input <- B.hGetContents h
case decode (toS input) of
input <- BL.hGetContents h
case decode input of
Just d -> pure d
Nothing -> die ("invalid input on " <> show h <> ", expecting JSON")

View File

@ -72,11 +72,11 @@ safeToEnum n | (fromEnum (minBound :: n), fromEnum (maxBound :: n)) `inRange` n
-- | Return a parser for a tree sitter language & document.
documentToTerm :: Language -> Ptr Document -> Source -> IO (Term (Syntax.Syntax Text) (Record DefaultFields))
documentToTerm language document source = do
documentToTerm language document allSource = do
root <- alloca (\ rootPtr -> do
ts_document_root_node_p document rootPtr
peek rootPtr)
toTerm root source
toTerm root (slice (nodeRange root) allSource)
where toTerm :: Node -> Source -> IO (Term (Syntax.Syntax Text) (Record DefaultFields))
toTerm node source = do
name <- peekCString (nodeType node)

View File

@ -94,6 +94,11 @@ spec = parallel $ do
diffTOC diff `shouldBe`
[ JSONSummary "Method" "foo" (sourceSpanBetween (6, 1) (7, 4)) "added" ]
it "properly slices source blob that starts with a newline and has multi-byte chars" $ do
sourceBlobs <- blobsForPaths (both "javascript/starts-with-newline.js" "javascript/starts-with-newline.js")
Just diff <- runTask (diffBlobPair IdentityDiffRenderer sourceBlobs)
diffTOC diff `shouldBe` []
prop "inserts of methods and functions are summarized" $
\name body ->
let diff = programWithInsert name (unListableF body)

View File

@ -0,0 +1,2 @@
//Выберем файлы по нужному пути