Skip to content

Commit cc84de6

Browse files
committed
Remove .hls directory magic strings
1 parent 9b2043d commit cc84de6

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import qualified Development.IDE.Spans.AtPoint as AtPoint
3737
import Development.IDE.Types.HscEnvEq (hscEnv)
3838
import Development.IDE.Types.Location
3939
import qualified HieDb
40+
import Ide.Types (hlsDirectory, dependenciesDirectory)
4041
import Language.LSP.Protocol.Types (DocumentHighlight (..),
4142
SymbolInformation (..),
4243
normalizedFilePathToUri,
@@ -116,7 +117,7 @@ lookupMod HieDbWriter{indexQueue} hieFile moduleName uid _boot = MaybeT $ do
116117
-- name and hash of the package the dependency module is
117118
-- found in. The name and hash are both parts of the UnitId.
118119
writeOutDir :: FilePath
119-
writeOutDir = projectRoot </> ".hls" </> "dependencies" </> show uid
120+
writeOutDir = projectRoot </> hlsDirectory </> dependenciesDirectory </> show uid
120121
-- The module name is separated into directories, with the
121122
-- last part of the module name giving the name of the
122123
-- haskell file with a .hs extension.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import HieDb (SourceFile (FakeFile),
2222
lookupPackage,
2323
removeDependencySrcFiles)
2424
import Ide.Logger (Recorder, WithPriority)
25+
import Ide.Types (hlsDirectory)
2526
import Language.LSP.Server (resRootPath)
2627
import System.Directory (doesDirectoryExist)
2728
import System.FilePath ((<.>), (</>))
@@ -46,7 +47,7 @@ indexDependencyHieFiles recorder se hscEnv = do
4647
mHlsDir :: Maybe FilePath
4748
mHlsDir = do
4849
projectDir <- resRootPath =<< lspEnv se
49-
pure $ projectDir </> ".hls"
50+
pure $ projectDir </> hlsDirectory
5051
-- Add the deletion of dependency source files from the
5152
-- HieDb database to the database write queue.
5253
deleteMissingDependencySources :: IO ()

hls-plugin-api/src/Ide/Types.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ module Ide.Types
4747
, PluginNotificationHandlers(..)
4848
, PluginRequestMethod(..)
4949
, SourceFileOrigin(..)
50+
, dependenciesDirectory
51+
, hlsDirectory
5052
, getSourceFileOrigin
5153
, getProcessID, getPid
5254
, installSigUsr1Handler
@@ -296,13 +298,19 @@ data PluginFileType = PluginFileType [SourceFileOrigin] [T.Text]
296298

297299
data SourceFileOrigin = FromProject | FromDependency deriving Eq
298300

301+
hlsDirectory :: FilePath
302+
hlsDirectory = ".hls"
303+
304+
dependenciesDirectory :: FilePath
305+
dependenciesDirectory = "dependencies"
306+
299307
-- | Dependency files are written to the .hls/dependencies directory
300308
-- under the project root.
301309
-- If a file is not in this directory, we assume that it is a
302310
-- project file.
303311
getSourceFileOrigin :: NormalizedFilePath -> SourceFileOrigin
304312
getSourceFileOrigin f =
305-
case [".hls", "dependencies"] `isInfixOf` (splitDirectories file) of
313+
case [hlsDirectory, dependenciesDirectory] `isInfixOf` (splitDirectories file) of
306314
True -> FromDependency
307315
False -> FromProject
308316
where

0 commit comments

Comments
 (0)