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

View File

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