diff --git a/bench/Evaluation.hs b/bench/Evaluation.hs index 865c9c034..2c10e8051 100644 --- a/bench/Evaluation.hs +++ b/bench/Evaluation.hs @@ -37,7 +37,7 @@ callGraphProject' :: ( Language.SLanguage lang -> IO (Either String ()) callGraphProject' session proxy path | Just (SomeParser parser) <- parserForLanguage analysisParsers lang = fmap (bimap show (const ())) . runTask session $ do - blob <- readBlobFromFile' (File.fromPath path) + blob <- readBlobFromPath path package <- fmap snd <$> runParse (Duration.fromSeconds 10) (parsePackage parser (Project (Path.toString (Path.takeDirectory path)) [blob] lang [])) modules <- topologicalSort <$> runImportGraphToModules proxy package runCallGraph proxy False modules package diff --git a/src/Data/Blob.hs b/src/Data/Blob.hs index f6c319b90..6559e2c39 100644 --- a/src/Data/Blob.hs +++ b/src/Data/Blob.hs @@ -17,7 +17,7 @@ module Data.Blob , blobPath , decodeBlobs , nullBlob -, sourceBlob +, fromSource , moduleForBlob , noLanguageForBlob , BlobPair @@ -74,8 +74,8 @@ instance FromJSON Blob where nullBlob :: Blob -> Bool nullBlob Blob{..} = Source.null blobSource -sourceBlob :: Path.PartClass.AbsRel ar => Path.File ar -> Language -> Source -> Blob -sourceBlob filepath language source +fromSource :: Path.PartClass.AbsRel ar => Path.File ar -> Language -> Source -> Blob +fromSource filepath language source = Blob source (Analysis.File.File (Path.toAbsRel filepath) (totalSpan source) language) decodeBlobs :: BL.ByteString -> Either String [Blob] diff --git a/test/Parsing/Spec.hs b/test/Parsing/Spec.hs index f55bbb746..e42e79b9e 100644 --- a/test/Parsing/Spec.hs +++ b/test/Parsing/Spec.hs @@ -15,7 +15,7 @@ spec :: Spec spec = do describe "parseToAST" $ do let source = toJSONSource [1 :: Int .. 10000] - let largeBlob = sourceBlob (Path.relFile "large.json") JSON source + let largeBlob = fromSource (Path.relFile "large.json") JSON source it "returns a result when the timeout does not expire" $ do let timeout = fromMicroseconds 0 -- Zero microseconds indicates no timeout diff --git a/test/Semantic/IO/Spec.hs b/test/Semantic/IO/Spec.hs index 192f08da6..fc9f86a20 100644 --- a/test/Semantic/IO/Spec.hs +++ b/test/Semantic/IO/Spec.hs @@ -21,8 +21,8 @@ spec = do readBlobFromFile (File (Path.absRel "/dev/doesnotexist") lowerBound Unknown) `shouldThrow` anyIOException describe "readBlobPairsFromHandle" $ do - let a = sourceBlob (Path.relFile "method.rb") Ruby "def foo; end" - let b = sourceBlob (Path.relFile "method.rb") Ruby "def bar(x); end" + let a = Blob.fromSource (Path.relFile "method.rb") Ruby "def foo; end" + let b = Blob.fromSource (Path.relFile "method.rb") Ruby "def bar(x); end" it "returns blobs for valid JSON encoded diff input" $ do blobs <- blobsFromFilePath "test/fixtures/cli/diff.json" blobs `shouldBe` [Compare a b] @@ -47,7 +47,7 @@ spec = do it "returns blobs for unsupported language" $ do h <- openFileForReading "test/fixtures/cli/diff-unsupported-language.json" blobs <- readBlobPairsFromHandle h - let b' = sourceBlob "test.kt" Unknown "fun main(args: Array) {\nprintln(\"hi\")\n}\n" + let b' = Blob.fromSource "test.kt" Unknown "fun main(args: Array) {\nprintln(\"hi\")\n}\n" blobs `shouldBe` [Insert b'] it "detects language based on filepath for empty language" $ do @@ -70,7 +70,7 @@ spec = do it "returns blobs for valid JSON encoded parse input" $ do h <- openFileForReading "test/fixtures/cli/parse.json" blobs <- readBlobsFromHandle h - let a = sourceBlob "method.rb" Ruby "def foo; end" + let a = Blob.fromSource "method.rb" Ruby "def foo; end" blobs `shouldBe` [a] it "throws on blank input" $ do diff --git a/test/Semantic/Spec.hs b/test/Semantic/Spec.hs index a6ac8cbe8..f36b49e27 100644 --- a/test/Semantic/Spec.hs +++ b/test/Semantic/Spec.hs @@ -17,7 +17,7 @@ setBlobLanguage lang b = b { blobFile = (blobFile b) { fileBody = lang }} spec :: Spec spec = do describe "parseBlob" $ do - let methodsBlob = sourceBlob (Path.relFile "methods.rb") Ruby "def foo\nend\n" + let methodsBlob = Blob.fromSource (Path.relFile "methods.rb") Ruby "def foo\nend\n" it "returns error if given an unknown language (json)" $ do output <- fmap runBuilder . runTaskOrDie . runReader defaultLanguageModes $ parseTermBuilder TermJSONTree [ setBlobLanguage Unknown methodsBlob ]