Conversation
|
Tests? |
| liftIO $ atomically $ | ||
| unGetTQueue indexQueue $ \withHieDb -> withHieDb $ \db -> do | ||
| HieDb.addSrcFile db hieFile writeOutPath False | ||
| putMVar completionToken () |
There was a problem hiding this comment.
This should be outside the withHieDb retry block
| ms -> foldr1 (</>) ms | ||
| breakOnDot :: FilePath -> [FilePath] | ||
| breakOnDot = words . map replaceDotWithSpace | ||
| replaceDotWithSpace :: Char -> Char |
There was a problem hiding this comment.
See Language.Haskell.Syntax.Module.Name.moduleNameSlashes
| HAR | ||
| (Compat.hie_module hieFile) | ||
| (Compat.hie_asts hieFile) | ||
| mempty |
There was a problem hiding this comment.
we can fill in the RefMap using Compat.generateReferencesMap
| (libraryDir : _) -> libraryDir | ||
| hieDir :: FilePath | ||
| hieDir = pkgLibDir </> "extra-compilation-artifacts" | ||
| modIfaces <- mapMaybeM loadModIface modules |
There was a problem hiding this comment.
why do we need to load .hi files here?
| mkModule (unitInfoId package) moduleName | ||
| -- When module is re-exported from another package, | ||
| -- the origin module is represented by value in Just | ||
| makeModule (_, Just otherPackageMod) = otherPackageMod |
There was a problem hiding this comment.
modules from other packages won't have a .hie file in the extra-compilation directory of the package under consideration, so we can just skip them from the list.
| let hiePath :: NormalizedFilePath | ||
| hiePath = toNormalizedFilePath' $ | ||
| hieDir </> toFilePath (moduleName $ mi_module modIface) ++ ".hie" | ||
| hieCheck <- checkHieFile recorder se "newHscEnvEqWithImportPaths" hiePath |
There was a problem hiding this comment.
we might want to be less granular with the HieAlreadyIndexed check - each package can contain hundreds/thousands of modules, and we don't want to check all these modules on every startup.
It's also wasteful because once we successfully index a whole unit/package we can assume that it doesn't change. So maybe we need to only check if a package has been indexed rather than checking for each file in the package.
This might require another table in hiedb to keep track of the packages we have indexed.
| ) | ||
| tmr <- fst <$> ( | ||
| handleMaybeM "Unable to TypeCheck" | ||
| case Shake.getSourceFileOrigin nfp of |
There was a problem hiding this comment.
We have pluginFileType in PluginDescriptor which specifies which filetypes plugins want to handle. We should extend this concept to extend to specifying whether plugins want to handle FromDependency files.
|
|
||
| getSourceFileOrigin :: NormalizedFilePath -> SourceFileOrigin | ||
| getSourceFileOrigin f = | ||
| case isInfixOf ".hls/dependencies" (show f) of |
There was a problem hiding this comment.
isInfixOf and show are the wrong functions to use here.
You probably want to inspect the path using functions from System.FilePath and use fromNormalizedFilePath to convert NormalizedFilePath to FilePath.
| deleteMissingDependencySources :: IO () | ||
| deleteMissingDependencySources = do | ||
| completionToken <- newEmptyMVar | ||
| atomically $ unGetTQueue (indexQueue $ hiedbWriter se) $ |
There was a problem hiding this comment.
I don't think we want unGetTQueue here.
3c686d9 to
68edc00
Compare
|
|
||
| getSourceFileOrigin :: NormalizedFilePath -> SourceFileOrigin | ||
| getSourceFileOrigin f = | ||
| case [".hls", "dependencies"] `isInfixOf` (splitDirectories file) of |
There was a problem hiding this comment.
@wz1000 What do you think of this? It still uses isInfixOf but not show. I don't see any predicate in System.FilePath that is like isInfixOf but for directories being contained in a FilePath.
This reverts commit 80b9a96.
0c7a635 to
9a4b009
Compare
| newHscEnvEqWithImportPaths envImportPaths recorder se hscEnv deps = do | ||
|
|
||
| let dflags = hsc_dflags hscEnv | ||
| indexDependencyHieFiles |
There was a problem hiding this comment.
We probably want to do this asynchronously.
| pure $ projectDir </> ".hls" | ||
| deleteMissingDependencySources :: IO () | ||
| deleteMissingDependencySources = do | ||
| completionToken <- newEmptyMVar |
There was a problem hiding this comment.
I don't think we need to wait for this to complete, we can just queue it up
| lookupPackage db unit | ||
| case moduleRows of | ||
| [] -> traverse_ (indexModuleHieFile hieDir) modules | ||
| _ -> return () |
There was a problem hiding this comment.
comments explaining that we have already indexed the package
| (evaluate . force . Just $ listVisibleModuleNames hscEnv) | ||
|
|
||
| return HscEnvEq{..} | ||
| where |
There was a problem hiding this comment.
I think we probably want to move this code to another module.
| -- for any reason. | ||
| -- See the function `lookupMod` in Development.IDE.Core.Actions | ||
| -- for where dependency files get created and indexed in hiedb. | ||
| fileExists <- liftIO $ doesFileExist src |
There was a problem hiding this comment.
I don't think we need to do this, as long as we check for .hls on startup.
|
Closed as per request by @nlander on Matrix |
For users using cabal HEAD, enables indexing of dependency HIE files so that the source can be written out on calls to gotoDefinition.