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:
commit
17f577b3f3
@ -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")
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
2
test/fixtures/toc/javascript/starts-with-newline.js
vendored
Normal file
2
test/fixtures/toc/javascript/starts-with-newline.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
//Выберем файлы по нужному пути
|
Loading…
Reference in New Issue
Block a user