@@ -18,8 +18,8 @@ import Control.Monad (replicateM)
18
18
import Control.Monad.IO.Class (MonadIO , liftIO )
19
19
import Control.Monad.Trans.Class (lift )
20
20
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 )
23
23
import Data.Generics (GenericQ , everything ,
24
24
everythingBut , mkQ )
25
25
import qualified Data.IntMap.Strict as IntMap
@@ -148,30 +148,28 @@ instance NFData RecordSelectorExpr where
148
148
rnf = rwhnf
149
149
150
150
data ORDResolveData = ORDRD {
151
- uri :: NormalizedFilePath
151
+ uri :: Uri
152
152
, uniqueID :: Int
153
153
} deriving (Generic , Show )
154
154
instance ToJSON ORDResolveData
155
155
instance FromJSON ORDResolveData
156
156
157
- -- TODO: move the orphans to their packages
158
- instance ToJSON NormalizedFilePath
159
- instance FromJSON NormalizedFilePath
160
- instance ToJSON NormalizedUri
161
- instance FromJSON NormalizedUri
162
157
descriptor :: Recorder (WithPriority Log ) -> PluginId
163
158
-> PluginDescriptor IdeState
164
159
descriptor recorder plId = (defaultPluginDescriptor plId)
165
160
{ pluginHandlers =
166
- mkPluginHandler SMethod_TextDocumentCodeAction codeActionProvider <> mkPluginHandler SMethod_CodeActionResolve resolveProvider
161
+ mkPluginHandler SMethod_TextDocumentCodeAction codeActionProvider
162
+ <> mkPluginHandler SMethod_CodeActionResolve resolveProvider
163
+
167
164
, pluginRules = collectRecSelsRule recorder
168
165
}
169
166
170
167
resolveProvider :: PluginMethodHandler IdeState 'Method_CodeActionResolve
171
168
resolveProvider ideState pId ca@ (CodeAction _ _ _ _ _ _ _ (Just resData)) =
172
169
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
175
173
CRSR _ crsDetails exts <- collectRecSelResult ideState nfp
176
174
pragma <- getFirstPragma pId ideState nfp
177
175
let pragmaEdit =
@@ -205,15 +203,15 @@ codeActionProvider ideState pId (CodeActionParams _ _ caDocId caRange _) =
205
203
edits _ = []
206
204
changes crsM crsD =
207
205
case supportsResolve of
208
- Just True -> Just $ WorkspaceEdit
206
+ Just False -> Just $ WorkspaceEdit
209
207
(Just (Map. singleton (fromNormalizedUri
210
208
(normalizedFilePathToUri nfp))
211
209
(edits (IntMap. lookup crsM crsD))))
212
210
Nothing Nothing
213
211
_ -> Nothing
214
212
resolveData crsM =
215
213
case supportsResolve of
216
- Just True -> Just $ toJSON $ ORDRD nfp crsM
214
+ Just True -> Just $ toJSON $ ORDRD (caDocId ^. L. uri) crsM
217
215
_ -> Nothing
218
216
mkCodeAction crsD crsM = InR CodeAction
219
217
{ -- We pass the record selector to the title function, so that
0 commit comments