Hopefully fix VFS loading (by falling back to loadByURI)

This commit is contained in:
Kirill Andreev 2020-08-24 20:10:00 +04:00
parent da6ca97a9d
commit f2a3f0b579
No known key found for this signature in database
GPG Key ID: CF7DA79DE4785A47
2 changed files with 21 additions and 16 deletions

View File

@ -232,22 +232,27 @@ loadFromVFS
-> J.Uri
-> IO (LIGO Info')
loadFromVFS funs uri = do
Just vf <- Core.getVirtualFileFunc funs $ J.toNormalizedUri uri
let txt = virtualFileText vf
let Just fin = J.uriToFilePath uri
(tree, _) <- parse (Text fin txt)
return $ addLocalScopes tree
Core.getVirtualFileFunc funs
(J.toNormalizedUri uri)
>>= \case
Just vf -> do
let txt = virtualFileText vf
let Just fin = J.uriToFilePath uri
(tree, _) <- parse (Text fin txt)
return $ addLocalScopes tree
Nothing -> do
loadByURI uri
-- loadByURI
-- :: J.Uri
-- -> IO (LIGO Info')
-- loadByURI uri = do
-- case J.uriToFilePath uri of
-- Just fin -> do
-- (tree, _) <- runParserM . recognise =<< toParseTree (Path fin)
-- return $ addLocalScopes tree
-- Nothing -> do
-- error $ "uriToFilePath " ++ show uri ++ " has failed. We all are doomed."
loadByURI
:: J.Uri
-> IO (LIGO Info')
loadByURI uri = do
case J.uriToFilePath uri of
Just fin -> do
(tree, _) <- parse (Path fin)
return $ addLocalScopes tree
Nothing -> do
error $ "uriToFilePath " ++ show uri ++ " has failed. We all are doomed."
collectErrors
:: Core.LspFuncs ()

View File

@ -15,7 +15,7 @@ import ParseTree
-- import Debug.Trace
example :: FilePath
-- example :: FilePath
-- example = "../../../src/test/contracts/address.mligo"
-- example = "../../../src/test/contracts/amount_lambda.mligo"
-- example = "../../../src/test/contracts/attributes.mligo"