@@ -28,9 +28,9 @@ import Data.Maybe (listToMaybe)
28
28
import Data.String (IsString )
29
29
import Data.Text (Text )
30
30
import qualified Data.Text as T
31
- import Development.IDE (GetParsedModule (GetParsedModule ),
31
+ import Development.IDE (hscEnvWithImportPaths , GetParsedModule (GetParsedModule ),
32
32
GhcSession (GhcSession ),
33
- HscEnvEq ( hscEnv ) , IdeState ,
33
+ HscEnvEq , IdeState ,
34
34
List (.. ), NormalizedFilePath ,
35
35
Position (Position ), Range (Range ),
36
36
evalGhcEnv , realSrcSpanToRange ,
@@ -39,12 +39,9 @@ import Development.IDE (GetParsedModule (GetParsedModule),
39
39
import Development.IDE.Plugin (getPid )
40
40
import GHC (DynFlags (importPaths ),
41
41
GenLocated (L ),
42
- GhcMonad (getSession ),
43
42
HsModule (hsmodName ),
44
43
ParsedModule (pm_parsed_source ),
45
- SrcSpan (RealSrcSpan ), unLoc )
46
- import GhcPlugins (HscEnv (hsc_IC ),
47
- InteractiveContext (ic_dflags ))
44
+ SrcSpan (RealSrcSpan ), unLoc ,getSessionDynFlags )
48
45
import Ide.Types (CommandFunction , CommandId (.. ),
49
46
PluginCommand (.. ),
50
47
PluginDescriptor (.. ),
@@ -124,11 +121,10 @@ actions convert lsp state uri = do
124
121
pathModuleName :: IdeState -> NormalizedFilePath -> String -> IO (Maybe Text )
125
122
pathModuleName state nfp fp = do
126
123
session :: HscEnvEq <- runAction " ModuleName.ghcSession" state $ use_ GhcSession nfp
127
- paths <- evalGhcEnv (hscEnv session) $ do
128
- env <- getSession
129
- let df = ic_dflags . hsc_IC $ env
130
- return $ importPaths df
124
+
125
+ paths <- evalGhcEnv (hscEnvWithImportPaths session) $ importPaths <$> getSessionDynFlags
131
126
out [" import paths" ,show paths]
127
+
132
128
let maybePrefix = listToMaybe . filter (`isPrefixOf` fp) $ paths
133
129
out [" prefix" ,show maybePrefix]
134
130
let maybeMdlName = (\ prefix -> replace " /" " ." . drop (length prefix+ 1 ) $ dropExtension fp) <$> maybePrefix
@@ -158,5 +154,5 @@ asTextEdits :: Action -> [TextEdit]
158
154
asTextEdits Action {.. } = [TextEdit aRange aCode]
159
155
160
156
out :: [String ] -> IO ()
161
- -- out = print . unwords . ("Plugin ModuleName " :)
162
- out _ = return ()
157
+ out = print . unwords . (" Plugin ModuleName " : )
158
+ -- out _ = return ()
0 commit comments