Skip to content

Commit 3431ba2

Browse files
committed
[ fix ] Send HighlightingInfos to the frontend instead of holding it back
1 parent 0a12d2f commit 3431ba2

File tree

5 files changed

+8
-53
lines changed

5 files changed

+8
-53
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## v0.1.4 - 2021-10-04
9+
10+
### Fixed
11+
- Resume sending HighlightingInfos to agda-mode
12+
813
## v0.1.3 - 2021-10-04
914

1015
### Fixed

agda-language-server.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cabal-version: 1.12
55
-- see: https://github.com/sol/hpack
66

77
name: agda-language-server
8-
version: 0.1.1
8+
version: 0.1.4
99
synopsis: An implementation of language server protocal (LSP) for Agda 2.
1010
description: Please see the README on GitHub at <https://github.com/banacorn/agda-language-server#readme>
1111
category: Development

package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: agda-language-server
2-
version: 0.1.3
2+
version: 0.1.4
33
github: "banacorn/agda-language-server"
44
license: MIT
55
author: "Ting-Gian LUA"

src/Monad.hs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ data Env = Env
2828
, envResponseChan :: Chan Response
2929
, envResponseController :: ResponseController
3030
, envDevMode :: Bool
31-
, envHighlightingInfos :: IORef [HighlightingInfo]
3231
}
3332

3433
createInitEnv :: Bool -> IO Env
@@ -39,7 +38,6 @@ createInitEnv devMode =
3938
<*> newChan
4039
<*> ResponseController.new
4140
<*> pure devMode
42-
<*> newIORef []
4341

4442
--------------------------------------------------------------------------------
4543

@@ -87,27 +85,4 @@ signalCommandFinish = do
8785

8886
-- | Sends a Response to the client via "envResponseChan"
8987
sendResponse :: (Monad m, MonadIO m) => Env -> Response -> TCMT m ()
90-
sendResponse env response = do
91-
case response of
92-
-- NOTE: highlighting-releated reponses are intercepted for later use of semantic highlighting
93-
ResponseHighlightingInfoDirect (HighlightingInfos _ highlightingInfos) -> do
94-
appendHighlightingInfos env highlightingInfos
95-
ResponseHighlightingInfoIndirect{} -> return ()
96-
ResponseClearHighlightingTokenBased{} -> removeHighlightingInfos env
97-
ResponseClearHighlightingNotOnlyTokenBased{} -> removeHighlightingInfos env
98-
-- other kinds of responses
99-
_ -> liftIO $ writeChan (envResponseChan env) response
100-
101-
-- | Get highlighting informations
102-
getHighlightingInfos :: (Monad m, MonadIO m) => ServerM m [HighlightingInfo]
103-
getHighlightingInfos = do
104-
ref <- asks envHighlightingInfos
105-
liftIO (readIORef ref)
106-
107-
appendHighlightingInfos :: (Monad m, MonadIO m) => Env -> [HighlightingInfo] -> TCMT m ()
108-
appendHighlightingInfos env highlightingInfos =
109-
liftIO (modifyIORef' (envHighlightingInfos env) (<> highlightingInfos))
110-
111-
removeHighlightingInfos :: (Monad m, MonadIO m) => Env -> TCMT m ()
112-
removeHighlightingInfos env =
113-
liftIO (writeIORef (envHighlightingInfos env) [])
88+
sendResponse env response = liftIO $ writeChan (envResponseChan env) response

src/Server/Handler.hs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -113,31 +113,6 @@ onHover uri pos = do
113113
(pack typeString)
114114
return $ Just $ LSP.Hover content (Just range)
115115

116-
onHighlight
117-
:: LSP.Uri
118-
-> ServerM (LspM ()) (Either LSP.ResponseError (Maybe LSP.SemanticTokens))
119-
onHighlight uri = do
120-
result <- LSP.getVirtualFile (LSP.toNormalizedUri uri)
121-
case result of
122-
Nothing -> return $ Right Nothing
123-
Just file -> do
124-
let source = VFS.virtualFileText file
125-
let legend = LSP.SemanticTokensLegend
126-
(LSP.List LSP.knownSemanticTokenTypes)
127-
(LSP.List LSP.knownSemanticTokenModifiers)
128-
129-
highlightingInfos <- getHighlightingInfos
130-
-- writeLog $ "[Handler] Semantic Highlighting " <> Text.pack (show highlightingInfos)
131-
let tokens = LSP.makeSemanticTokens
132-
legend
133-
(map fromHighlightingInfo highlightingInfos)
134-
-- writeLog $ "[Handler] Semantic Highlighting " <> Text.pack (show highlightingInfos)
135-
writeLog $ "[Handler][Highlighting] length " <> Text.pack
136-
(show (length $ map fromHighlightingInfo highlightingInfos))
137-
case tokens of
138-
Left t -> return $ Left $ LSP.ResponseError LSP.InternalError t Nothing
139-
Right tokens' -> return $ Right $ Just tokens'
140-
141116
--------------------------------------------------------------------------------
142117
-- Helper functions for converting stuff to SemanticTokenAbsolute
143118

0 commit comments

Comments
 (0)