Skip to content

Commit bcfb899

Browse files
committed
resolve support works on VSCode (tests need to be redone)
1 parent d404a25 commit bcfb899

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

cabal.project

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ source-repository-package
9595
-- This is needed till lsp makes a release
9696
source-repository-package
9797
type:git
98-
location: https://github.com/haskell/lsp
99-
tag: 98ba7cc91436e93578e9882c7ef18660b5fd4dd4
98+
location: https://github.com/joyfulmantis/lsp
99+
tag: 5919f15f38e06a075590fc03bfe8e329566f691e
100100
subdir: lsp lsp-types lsp-test
101101

102102

plugins/hls-overloaded-record-dot-plugin/src/Ide/Plugin/OverloadedRecordDot.hs

+11-13
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import Control.Monad (replicateM)
1818
import Control.Monad.IO.Class (MonadIO, liftIO)
1919
import Control.Monad.Trans.Class (lift)
2020
import Control.Monad.Trans.Except (ExceptT)
21-
import Data.Aeson (FromJSON, ToJSON, decode,
22-
encode, fromJSON, toJSON)
21+
import Data.Aeson (FromJSON, Result (..),
22+
ToJSON, fromJSON, toJSON)
2323
import Data.Generics (GenericQ, everything,
2424
everythingBut, mkQ)
2525
import qualified Data.IntMap.Strict as IntMap
@@ -148,30 +148,28 @@ instance NFData RecordSelectorExpr where
148148
rnf = rwhnf
149149

150150
data ORDResolveData = ORDRD {
151-
uri :: NormalizedFilePath
151+
uri :: Uri
152152
, uniqueID :: Int
153153
} deriving (Generic, Show)
154154
instance ToJSON ORDResolveData
155155
instance FromJSON ORDResolveData
156156

157-
-- TODO: move the orphans to their packages
158-
instance ToJSON NormalizedFilePath
159-
instance FromJSON NormalizedFilePath
160-
instance ToJSON NormalizedUri
161-
instance FromJSON NormalizedUri
162157
descriptor :: Recorder (WithPriority Log) -> PluginId
163158
-> PluginDescriptor IdeState
164159
descriptor recorder plId = (defaultPluginDescriptor plId)
165160
{ pluginHandlers =
166-
mkPluginHandler SMethod_TextDocumentCodeAction codeActionProvider <> mkPluginHandler SMethod_CodeActionResolve resolveProvider
161+
mkPluginHandler SMethod_TextDocumentCodeAction codeActionProvider
162+
<> mkPluginHandler SMethod_CodeActionResolve resolveProvider
163+
167164
, pluginRules = collectRecSelsRule recorder
168165
}
169166

170167
resolveProvider :: PluginMethodHandler IdeState 'Method_CodeActionResolve
171168
resolveProvider ideState pId ca@(CodeAction _ _ _ _ _ _ _ (Just resData)) =
172169
pluginResponse $ do
173-
case decode . encode $ resData of
174-
Just (ORDRD nfp int) -> do
170+
case fromJSON $ resData of
171+
Success (ORDRD uri int) -> do
172+
nfp <- getNormalizedFilePath uri
175173
CRSR _ crsDetails exts <- collectRecSelResult ideState nfp
176174
pragma <- getFirstPragma pId ideState nfp
177175
let pragmaEdit =
@@ -205,15 +203,15 @@ codeActionProvider ideState pId (CodeActionParams _ _ caDocId caRange _) =
205203
edits _ = []
206204
changes crsM crsD =
207205
case supportsResolve of
208-
Just True -> Just $ WorkspaceEdit
206+
Just False -> Just $ WorkspaceEdit
209207
(Just (Map.singleton (fromNormalizedUri
210208
(normalizedFilePathToUri nfp))
211209
(edits (IntMap.lookup crsM crsD))))
212210
Nothing Nothing
213211
_ -> Nothing
214212
resolveData crsM =
215213
case supportsResolve of
216-
Just True -> Just $ toJSON $ ORDRD nfp crsM
214+
Just True -> Just $ toJSON $ ORDRD (caDocId ^. L.uri) crsM
217215
_ -> Nothing
218216
mkCodeAction crsD crsM = InR CodeAction
219217
{ -- We pass the record selector to the title function, so that

0 commit comments

Comments
 (0)