Skip to content

Commit

Permalink
Fix ImportLens plugin to work with GHC 8.10 (haskell#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ailrun authored and pepeiborra committed Sep 6, 2020
1 parent 6b3290a commit 6bb713a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Ide/Plugin/ImportLens.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
Expand All @@ -8,6 +8,10 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ViewPatterns #-}

#include "ghc-api-version.h"

module Ide.Plugin.ImportLens (descriptor) where
import Control.Monad (forM)
import Data.Aeson (ToJSON)
Expand Down Expand Up @@ -140,7 +144,7 @@ generateLens pId uri minImports (L src imp)
| ImportDecl{ideclHiding = Just (False,_)} <- imp
= return Nothing
-- Qualified case
| ImportDecl{ideclQualified = True} <- imp
| isQualifiedImport imp
= return Nothing
-- No explicit import list
| RealSrcSpan l <- src
Expand Down Expand Up @@ -171,3 +175,12 @@ generateLens pId uri minImports (L src imp)
-- | A helper to run ide actions
runIde :: IdeState -> Action a -> IO a
runIde state = runAction "importLens" state

isQualifiedImport :: ImportDecl a -> Bool
#if MIN_GHC_API_VERSION(8,10,0)
isQualifiedImport ImportDecl{ideclQualified = NotQualified} = False
isQualifiedImport ImportDecl{} = True
#else
isQualifiedImport ImportDecl{ideclQualified} = ideclQualified
#endif
isQualifiedImport _ = False

0 comments on commit 6bb713a

Please sign in to comment.