Skip to content

Commit

Permalink
feat: remove cycle check for some language server commands as it was …
Browse files Browse the repository at this point in the history
…killing performance
  • Loading branch information
aboeglin committed Jun 8, 2024
1 parent 6aa89bc commit 0043db6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
39 changes: 20 additions & 19 deletions compiler/main/Run/LanguageServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion madlib.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/madlib-lang/madlib#readme>
homepage: https://github.com/madlib-lang/madlib#readme
bug-reports: https://github.com/madlib-lang/madlib/issues
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pkg/package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 0043db6

Please sign in to comment.