From 0043db65e8c0c8788d58f3389eb0af23fa2c8613 Mon Sep 17 00:00:00 2001 From: Arnaud BOEGLIN Date: Sat, 8 Jun 2024 09:30:46 +0200 Subject: [PATCH] feat: remove cycle check for some language server commands as it was killing performance --- compiler/main/Run/LanguageServer.hs | 39 +++++++++++++++-------------- madlib.cabal | 2 +- package.yaml | 2 +- pkg/package.json | 2 +- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/compiler/main/Run/LanguageServer.hs b/compiler/main/Run/LanguageServer.hs index ab36dc972..5f1f9e7da 100644 --- a/compiler/main/Run/LanguageServer.hs +++ b/compiler/main/Run/LanguageServer.hs @@ -69,18 +69,19 @@ handlers :: State -> Handlers (LspM ()) handlers state = mconcat [ notificationHandler SInitialized $ \_not -> sendNotification SWindowLogMessage (LogMessageParams MtInfo "Madlib server initialized") - , requestHandler STextDocumentHover $ \req responder -> do - let RequestMessage _ _ _ (HoverParams (TextDocumentIdentifier uri) pos@(Position line col) _workDone) = req - maybeHoverInfo <- getHoverInformation state (Loc 0 (line + 1) (col + 1)) (uriToPath uri) - case maybeHoverInfo of - Just info -> do - let ms = HoverContents $ MarkupContent MkMarkdown (T.pack info) - range = Range pos pos - rsp = Hover ms (Just range) - responder (Right $ Just rsp) + , requestHandler STextDocumentHover $ \req responder -> + recordAndPrintDuration "hover" $ do + let RequestMessage _ _ _ (HoverParams (TextDocumentIdentifier uri) pos@(Position line col) _workDone) = req + maybeHoverInfo <- getHoverInformation state (Loc 0 (line + 1) (col + 1)) (uriToPath uri) + case maybeHoverInfo of + Just info -> do + let ms = HoverContents $ MarkupContent MkMarkdown (T.pack info) + range = Range pos pos + rsp = Hover ms (Just range) + responder (Right $ Just rsp) - Nothing -> - return () + Nothing -> + return () , requestHandler STextDocumentDefinition $ \(RequestMessage _ _ _ (DefinitionParams (TextDocumentIdentifier uri) (Position line col) _ _)) responder -> do recordAndPrintDuration "definition" $ do links <- getDefinitionLinks state (Loc 0 (line + 1) (col + 1)) (uriToPath uri) @@ -973,10 +974,10 @@ runLanguageServer = do hoverInfoTask :: Loc -> FilePath -> Rock.Task Query.Query (Maybe String) hoverInfoTask loc path = do - hasCycle <- Rock.fetch $ Query.DetectImportCycle [] path - if hasCycle then - return Nothing - else do + -- hasCycle <- Rock.fetch $ Query.DetectImportCycle [] path + -- if hasCycle then + -- return Nothing + -- else do srcAst <- Rock.fetch $ Query.ParsedAST path (typedAst, _) <- Rock.fetch $ Query.SolvedASTWithEnv path mapM (nodeToHoverInfo path) (findNodeInAst loc srcAst typedAst) @@ -1023,10 +1024,10 @@ findNameInNode node = case node of definitionLocationTask :: Loc -> FilePath -> Rock.Task Query.Query (Maybe (FilePath, Area)) definitionLocationTask loc path = do - hasCycle <- Rock.fetch $ Query.DetectImportCycle [] path - if hasCycle then - return Nothing - else do + -- hasCycle <- Rock.fetch $ Query.DetectImportCycle [] path + -- if hasCycle then + -- return Nothing + -- else do (typedAst, _) <- Rock.fetch $ Query.SolvedASTWithEnv path (canAst, _, _) <- Rock.fetch $ Query.CanonicalizedASTWithEnv path srcAst <- Rock.fetch $ Query.ParsedAST path diff --git a/madlib.cabal b/madlib.cabal index dfa54cea8..17e679c65 100644 --- a/madlib.cabal +++ b/madlib.cabal @@ -5,7 +5,7 @@ cabal-version: 2.0 -- see: https://github.com/sol/hpack name: madlib -version: 0.23.15 +version: 0.23.16 description: Please see the README on GitHub at homepage: https://github.com/madlib-lang/madlib#readme bug-reports: https://github.com/madlib-lang/madlib/issues diff --git a/package.yaml b/package.yaml index b77ffe7c8..32564a662 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: madlib -version: 0.23.15 +version: 0.23.16 github: "madlib-lang/madlib" license: BSD3 author: "Arnaud Boeglin, Brekk Bockrath" diff --git a/pkg/package.json b/pkg/package.json index ee40aebc8..14b23297a 100644 --- a/pkg/package.json +++ b/pkg/package.json @@ -1,6 +1,6 @@ { "name": "@madlib-lang/madlib", - "version": "0.23.15", + "version": "0.23.16", "main": "./src/run.js", "bin": { "madlib": "src/run.js"