From f2a3f0b579d5334ad898358bf07bbcf14cdffbf3 Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Mon, 24 Aug 2020 20:10:00 +0400 Subject: [PATCH] Hopefully fix VFS loading (by falling back to loadByURI) --- tools/lsp/squirrel/app/Main.hs | 35 +++++++++++--------- tools/lsp/squirrel/src/AST/Camligo/Parser.hs | 2 +- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/tools/lsp/squirrel/app/Main.hs b/tools/lsp/squirrel/app/Main.hs index bd161e104..1fe17a3da 100644 --- a/tools/lsp/squirrel/app/Main.hs +++ b/tools/lsp/squirrel/app/Main.hs @@ -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 () diff --git a/tools/lsp/squirrel/src/AST/Camligo/Parser.hs b/tools/lsp/squirrel/src/AST/Camligo/Parser.hs index 3bfbfbf7c..331f044d6 100644 --- a/tools/lsp/squirrel/src/AST/Camligo/Parser.hs +++ b/tools/lsp/squirrel/src/AST/Camligo/Parser.hs @@ -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"