Skip to content

Commit

Permalink
more lsp null fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joyfulmantis committed Jul 8, 2023
1 parent d511957 commit 0425469
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions plugins/hls-retrie-plugin/src/Ide/Plugin/Retrie.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ import Control.Monad.Trans.Except (ExceptT (ExceptT),
import Control.Monad.Trans.Maybe
import Control.Monad.Trans.Writer.Strict
import Data.Aeson (FromJSON (..),
ToJSON (..),
Value (Null))
ToJSON (..), Value)
import Data.Bifunctor (second)
import qualified Data.ByteString as BS
import Data.Coerce
Expand Down Expand Up @@ -118,7 +117,7 @@ import Ide.PluginUtils
import Ide.Types
import qualified Language.LSP.Protocol.Lens as L
import Language.LSP.Protocol.Message as LSP
import Language.LSP.Protocol.Types as LSP hiding (Null)
import Language.LSP.Protocol.Types as LSP
import Language.LSP.Server (LspM,
ProgressCancellable (Cancellable),
sendNotification,
Expand Down Expand Up @@ -209,7 +208,7 @@ data RunRetrieParams = RunRetrieParams
runRetrieCmd ::
IdeState ->
RunRetrieParams ->
LspM c (Either ResponseError Value)
LspM c (Either ResponseError (Value |? Null))
runRetrieCmd state RunRetrieParams{originatingFile = uri, ..} =
withIndefiniteProgress description Cancellable $ do
runMaybeT $ do
Expand All @@ -236,7 +235,7 @@ runRetrieCmd state RunRetrieParams{originatingFile = uri, ..} =
["-" <> T.pack (show e) | e <- errors]
lift $ sendRequest SMethod_WorkspaceApplyEdit (ApplyWorkspaceEditParams Nothing edits) (\_ -> pure ())
return ()
return $ Right Null
return $ Right $ InR Null

data RunRetrieInlineThisParams = RunRetrieInlineThisParams
{ inlineIntoThisLocation :: !Location,
Expand All @@ -246,7 +245,7 @@ data RunRetrieInlineThisParams = RunRetrieInlineThisParams
deriving (Eq, Show, Generic, FromJSON, ToJSON)

runRetrieInlineThisCmd :: IdeState
-> RunRetrieInlineThisParams -> LspM c (Either ResponseError Value)
-> RunRetrieInlineThisParams -> LspM c (Either ResponseError (Value |? Null))
runRetrieInlineThisCmd state RunRetrieInlineThisParams{..} = pluginResponse $ do
nfp <- handleMaybe "uri" $ uriToNormalizedFilePath $ toNormalizedUri $ getLocationUri inlineIntoThisLocation
nfpSource <- handleMaybe "sourceUri" $
Expand Down Expand Up @@ -287,7 +286,7 @@ runRetrieInlineThisCmd state RunRetrieInlineThisParams{..} = pluginResponse $ do
, RealSrcSpan intoRange Nothing `GHC.isSubspanOf` replLocation]
lift $ sendRequest SMethod_WorkspaceApplyEdit
(ApplyWorkspaceEditParams Nothing wedit) (\_ -> pure ())
return Null
return $ InR Null

-- Override to skip adding binders to the context, which prevents inlining
-- nested defined functions
Expand Down
2 changes: 1 addition & 1 deletion plugins/hls-tactics-plugin/old/src/Wingman/AbstractLSP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ runContinuation plId cont state (fc, b) = do
res <- c_runCommand cont env args fc b

-- This block returns a maybe error.
fmap (maybe (Right A.Null) Left . coerce . foldMap Last) $
fmap (maybe (Right $ InR Null) Left . coerce . foldMap Last) $
for res $ \case
ErrorMessages errs -> do
traverse_ showUserFacingMessage errs
Expand Down

0 comments on commit 0425469

Please sign in to comment.