Skip to content

Commit 59292ee

Browse files
committed
Rename getFileContents to getFileModTimeContents
1 parent 579780a commit 59292ee

File tree

15 files changed

+28
-28
lines changed

15 files changed

+28
-28
lines changed

ghcide/src/Development/IDE.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Development.IDE.Core.Actions as X (getAtPoint,
1010
getDefinition,
1111
getTypeDefinition)
1212
import Development.IDE.Core.FileExists as X (getFileExists)
13-
import Development.IDE.Core.FileStore as X (getFileContents)
13+
import Development.IDE.Core.FileStore as X (getFileModTimeContents)
1414
import Development.IDE.Core.IdeConfiguration as X (IdeConfiguration (..),
1515
isWorkspaceFile)
1616
import Development.IDE.Core.OfInterest as X (getFilesOfInterestUntracked)

ghcide/src/Development/IDE/Core/FileStore.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{-# LANGUAGE TypeFamilies #-}
44

55
module Development.IDE.Core.FileStore(
6-
getFileContents,
6+
getFileModTimeContents,
77
getVersionedTextDoc,
88
setFileModified,
99
setSomethingModified,
@@ -192,8 +192,8 @@ getFileContentsImpl file = do
192192

193193
-- | Returns the modification time and the contents.
194194
-- For VFS paths, the modification time is the current time.
195-
getFileContents :: NormalizedFilePath -> Action (UTCTime, Maybe Rope)
196-
getFileContents f = do
195+
getFileModTimeContents :: NormalizedFilePath -> Action (UTCTime, Maybe Rope)
196+
getFileModTimeContents f = do
197197
(fv, contents) <- use_ GetFileContents f
198198
modTime <- case modificationTime fv of
199199
Just t -> pure t

ghcide/src/Development/IDE/Core/PluginUtils.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ mkFormattingHandlers f = mkPluginHandler SMethod_TextDocumentFormatting ( provid
189189
provider :: forall m. FormattingMethod m => SMethod m -> PluginMethodHandler IdeState m
190190
provider m ide _pid params
191191
| Just nfp <- LSP.uriToNormalizedFilePath $ LSP.toNormalizedUri uri = do
192-
contentsMaybe <- liftIO $ runAction "mkFormattingHandlers" ide $ fmap snd $ getFileContents nfp
192+
contentsMaybe <- liftIO $ runAction "mkFormattingHandlers" ide $ fmap snd $ getFileModTimeContents nfp
193193
case contentsMaybe of
194194
Just contents -> do
195195
let (typ, mtoken) = case m of

ghcide/src/Development/IDE/Core/Rules.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ import Data.Typeable (cast)
9999
import Development.IDE.Core.Compile
100100
import Development.IDE.Core.FileExists hiding (Log,
101101
LogShake)
102-
import Development.IDE.Core.FileStore (getFileContents,
102+
import Development.IDE.Core.FileStore (getFileModTimeContents,
103103
getModTime)
104104
import Development.IDE.Core.IdeConfiguration
105105
import Development.IDE.Core.OfInterest hiding (Log,
@@ -221,7 +221,7 @@ toIdeResult = either (, Nothing) (([],) . Just)
221221
-- TODO: return text --> return rope
222222
getSourceFileSource :: NormalizedFilePath -> Action BS.ByteString
223223
getSourceFileSource nfp = do
224-
(_, msource) <- getFileContents nfp
224+
(_, msource) <- getFileModTimeContents nfp
225225
case msource of
226226
Nothing -> liftIO $ BS.readFile (fromNormalizedFilePath nfp)
227227
Just source -> pure $ T.encodeUtf8 $ Rope.toText source
@@ -862,7 +862,7 @@ getModSummaryRule displayTHWarning recorder = do
862862
session' <- hscEnv <$> use_ GhcSession f
863863
modify_dflags <- getModifyDynFlags dynFlagsModifyGlobal
864864
let session = hscSetFlags (modify_dflags $ hsc_dflags session') session'
865-
(modTime, mFileContent) <- getFileContents f
865+
(modTime, mFileContent) <- getFileModTimeContents f
866866
let fp = fromNormalizedFilePath f
867867
modS <- liftIO $ runExceptT $
868868
getModSummaryFromImports session fp modTime (textToStringBuffer . Rope.toText <$> mFileContent)

ghcide/src/Development/IDE/Plugin/Completions.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import qualified Data.HashSet as Set
1919
import Data.Maybe
2020
import qualified Data.Text as T
2121
import Development.IDE.Core.Compile
22-
import Development.IDE.Core.FileStore (getFileContents)
22+
import Development.IDE.Core.FileStore (getFileModTimeContents)
2323
import Development.IDE.Core.PluginUtils
2424
import Development.IDE.Core.PositionMapping
2525
import Development.IDE.Core.RuleTypes
@@ -167,7 +167,7 @@ getCompletionsLSP ide plId
167167
,_position=position
168168
,_context=completionContext} = ExceptT $ do
169169
contentsMaybe <-
170-
liftIO $ runAction "Completion" ide $ maybe (pure Nothing) (fmap snd . getFileContents) $ uriToNormalizedFilePath $ toNormalizedUri uri
170+
liftIO $ runAction "Completion" ide $ maybe (pure Nothing) (fmap snd . getFileModTimeContents) $ uriToNormalizedFilePath $ toNormalizedUri uri
171171
fmap Right $ case (contentsMaybe, uriToFilePath' uri) of
172172
(Just cnts, Just path) -> do
173173
let npath = toNormalizedFilePath' path

ghcide/src/Development/IDE/Spans/Pragmas.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Data.Text (Text, pack)
1717
import qualified Data.Text as Text
1818
import Data.Text.Utf16.Rope.Mixed (Rope)
1919
import qualified Data.Text.Utf16.Rope.Mixed as Rope
20-
import Development.IDE (srcSpanToRange, IdeState, NormalizedFilePath, GhcSession (..), getFileContents, hscEnv, runAction)
20+
import Development.IDE (srcSpanToRange, IdeState, NormalizedFilePath, GhcSession (..), getFileModTimeContents, hscEnv, runAction)
2121
import Development.IDE.GHC.Compat
2222
import Development.IDE.GHC.Compat.Util
2323
import qualified Language.LSP.Protocol.Types as LSP
@@ -58,7 +58,7 @@ insertNewPragma (NextPragmaInfo nextPragmaLine _) newPragma = LSP.TextEdit prag
5858
getFirstPragma :: MonadIO m => PluginId -> IdeState -> NormalizedFilePath -> ExceptT PluginError m NextPragmaInfo
5959
getFirstPragma (PluginId pId) state nfp = do
6060
(hscEnv -> hsc_dflags -> sessionDynFlags, _) <- runActionE (T.unpack pId <> ".GhcSession") state $ useWithStaleE GhcSession nfp
61-
(_, fileContents) <- liftIO $ runAction (T.unpack pId <> ".GetFileContents") state $ getFileContents nfp
61+
(_, fileContents) <- liftIO $ runAction (T.unpack pId <> ".GetFileContents") state $ getFileModTimeContents nfp
6262
pure $ getNextPragmaInfo sessionDynFlags fileContents
6363

6464
-- Pre-declaration comments parser -----------------------------------------------------

plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ completion :: Recorder (WithPriority Log) -> PluginMethodHandler IdeState 'LSP.M
321321
completion recorder ide _ complParams = do
322322
let (TextDocumentIdentifier uri) = complParams ^. JL.textDocument
323323
position = complParams ^. JL.position
324-
mContents <- liftIO $ runAction "cabal-plugin.getFileContents" ide $ maybe (pure Nothing) (fmap snd . getFileContents) $ uriToNormalizedFilePath $ toNormalizedUri uri
324+
mContents <- liftIO $ runAction "cabal-plugin.getFileModTimeContents" ide $ maybe (pure Nothing) (fmap snd . getFileModTimeContents) $ uriToNormalizedFilePath $ toNormalizedUri uri
325325
case (,) <$> mContents <*> uriToFilePath' uri of
326326
Just (cnts, path) -> do
327327
-- We decide on `useWithStale` here, since `useWithStaleFast` often leads to the wrong completions being suggested.

plugins/hls-class-plugin/src/Ide/Plugin/Class/Utils.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ insertPragmaIfNotPresent state nfp pragma = do
6565
(hscEnv -> hsc_dflags -> sessionDynFlags, _) <- runActionE "classplugin.insertPragmaIfNotPresent.GhcSession" state
6666
$ useWithStaleE GhcSession nfp
6767
(_, fileContents) <- liftIO $ runAction "classplugin.insertPragmaIfNotPresent.GetFileContents" state
68-
$ getFileContents nfp
68+
$ getFileModTimeContents nfp
6969
(pm, _) <- runActionE "classplugin.insertPragmaIfNotPresent.GetParsedModuleWithComments" state
7070
$ useWithStaleE GetParsedModuleWithComments nfp
7171
let exts = getExtensions pm

plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import Data.Text (Text)
4242
import qualified Data.Text as T
4343
import qualified Data.Text.Utf16.Rope.Mixed as Rope
4444
import Data.Typeable (Typeable)
45-
import Development.IDE.Core.FileStore (getFileContents)
45+
import Development.IDE.Core.FileStore (getFileModTimeContents)
4646
import Development.IDE.Core.Rules (IdeState,
4747
runAction)
4848
import Development.IDE.Core.RuleTypes (LinkableResult (linkableHomeMod),
@@ -304,8 +304,8 @@ moduleText state uri = do
304304
contents <-
305305
handleMaybeM (PluginInternalError "mdlText") $
306306
liftIO $
307-
runAction "eval.getFileContents" state $
308-
maybe (pure Nothing) (fmap snd . getFileContents) $ uriToNormalizedFilePath $ toNormalizedUri uri
307+
runAction "eval.getFileModTimeContents" state $
308+
maybe (pure Nothing) (fmap snd . getFileModTimeContents) $ uriToNormalizedFilePath $ toNormalizedUri uri
309309
pure $ Rope.toText contents
310310

311311
testsBySection :: [Section] -> [(Section, EvalId, Test)]

plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ type instance RuleResult GetHlintDiagnostics = ()
193193
-- | This rule is recomputed when:
194194
-- | - A file has been edited via
195195
-- | - `getIdeas` -> `getParsedModule` in any case
196-
-- | - `getIdeas` -> `getFileContents` if the hls ghc does not match the hlint default ghc
196+
-- | - `getIdeas` -> `getFileModTimeContents` if the hls ghc does not match the hlint default ghc
197197
-- | - The client settings have changed, to honour the `hlintOn` setting, via `getClientConfigAction`
198198
-- | - The hlint specific settings have changed, via `getHlintSettingsRule`
199199
rules :: Recorder (WithPriority Log) -> PluginId -> Rules ()
@@ -307,7 +307,7 @@ getIdeas recorder nfp = do
307307
then return Nothing
308308
else do
309309
flags' <- setExtensions flags
310-
(_, contents) <- getFileContents nfp
310+
(_, contents) <- getFileModTimeContents nfp
311311
let fp = fromNormalizedFilePath nfp
312312
let contents' = T.unpack . Rope.toText <$> contents
313313
Just <$> liftIO (parseModuleEx flags' fp contents')
@@ -521,7 +521,7 @@ applyHint recorder ide nfp mhint verTxtDocId =
521521
let commands = map ideaRefactoring ideas'
522522
logWith recorder Debug $ LogGeneratedIdeas nfp commands
523523
let fp = fromNormalizedFilePath nfp
524-
(_, fmap Rope.toText -> mbOldContent) <- liftIO $ runAction' $ getFileContents nfp
524+
(_, fmap Rope.toText -> mbOldContent) <- liftIO $ runAction' $ getFileModTimeContents nfp
525525
oldContent <- maybe (liftIO $ fmap T.decodeUtf8 (BS.readFile fp)) return mbOldContent
526526
modsum <- liftIO $ runAction' $ use_ GetModSummary nfp
527527
let dflags = ms_hspp_opts $ msrModSummary modsum

0 commit comments

Comments
 (0)