diff options
Diffstat (limited to 'src/HaskellCodeExplorer')
-rw-r--r-- | src/HaskellCodeExplorer/ModuleInfo.hs | 9 | ||||
-rw-r--r-- | src/HaskellCodeExplorer/PackageInfo.hs | 29 |
2 files changed, 18 insertions, 20 deletions
diff --git a/src/HaskellCodeExplorer/ModuleInfo.hs b/src/HaskellCodeExplorer/ModuleInfo.hs index 5aeb6bd..c651945 100644 --- a/src/HaskellCodeExplorer/ModuleInfo.hs +++ b/src/HaskellCodeExplorer/ModuleInfo.hs @@ -28,7 +28,8 @@ import qualified Data.IntervalMap.Strict as IVM import qualified Data.List as L hiding ( span ) import qualified Data.Map.Strict as M -import Data.Maybe ( fromMaybe +import Data.Maybe ( fromJust + , fromMaybe , mapMaybe ) import qualified Data.Set as S @@ -168,7 +169,7 @@ createModuleInfo (fileMap, defSiteMap, moduleNameMap) (flags, unitState, typeche = let globalRdrEnv = tcg_rdr_env . fst . tm_internals_ $ typecheckedModule modInfo = moduleInfo typecheckedModule - (Just (hsGroup, _, _, _)) = renamedSource typecheckedModule + (hsGroup, _, _, _) = fromJust $ renamedSource typecheckedModule exportedNamesSet = S.fromList $ modInfoExportsWithSelectors modInfo -------------------------------------------------------------------------------- -- Preprocessed source @@ -615,8 +616,8 @@ createDeclarations flags hsGroup typeEnv exportedSet transformation = foldAST :: Environment -> TypecheckedModule -> SourceInfo foldAST environment typecheckedModule = let - (Just renamed@(_, importDecls, mbExported, _)) = - renamedSource typecheckedModule + renamed@(_, importDecls, mbExported, _) = + fromJust $ renamedSource typecheckedModule emptyASTState = ASTState IVM.empty IM.empty M.empty emptyTidyEnv Nothing environment [] ASTState {..} = execState diff --git a/src/HaskellCodeExplorer/PackageInfo.hs b/src/HaskellCodeExplorer/PackageInfo.hs index 8e0fbdf..7558fa2 100644 --- a/src/HaskellCodeExplorer/PackageInfo.hs +++ b/src/HaskellCodeExplorer/PackageInfo.hs @@ -286,16 +286,15 @@ createPackageInfo packageDirectoryPath mbDistDirRelativePath sourceCodePreproces ) ([], (HM.empty, HM.empty, HM.empty)) buildComponents - let modId = HCE.id :: HCE.ModuleInfo -> HCE.HaskellModulePath + let modId (HCE.ModuleInfo {..}) = id moduleMap = HM.fromList . map (\modInfo -> (modId modInfo, modInfo)) $ indexedModules references = L.foldl' addReferencesFromModule HM.empty indexedModules - moduleId = HCE.id :: HCE.ModuleInfo -> HCE.HaskellModulePath topLevelIdentifiersTrie = L.foldl' addTopLevelIdentifiersFromModule HCE.emptyTrie - . L.filter (not . isHsBoot . moduleId) + . L.filter (not . isHsBoot . modId) $ indexedModules directoryTree <- liftIO $ buildDirectoryTree packageDirectoryAbsPath @@ -393,11 +392,9 @@ addReferencesFromModule references modInfo@HCE.ModuleInfo {..} = eachIdentifierOccurrence references modInfo - (\occMap lineNumber startCol endCol occ -> - let mbIdExternalId = HCE.externalId =<< maybe - Nothing - (`HM.lookup` idInfoMap) - (HCE.internalId (occ :: HCE.IdentifierOccurrence)) + (\occMap lineNumber startCol endCol (HCE.IdentifierOccurrence {..}) -> + let mbIdExternalId = + HCE.externalId =<< maybe Nothing (`HM.lookup` idInfoMap) internalId idSrcSpan = HCE.IdentifierSrcSpan { modulePath = id , line = lineNumber , startColumn = startCol @@ -452,7 +449,7 @@ indexBuildComponent -> [String] -- ^ Command-line options for GHC -> [String] -- ^ Modules to compile -> LoggingT IO ([HCE.ModuleInfo], ModuleDependencies) -indexBuildComponent sourceCodePreprocessing currentPackageId componentId deps@(fileMap, defSiteMap, modNameMap) srcDirs libSrcDirs options modules +indexBuildComponent sourceCodePreprocessing currentPackageId@HCE.PackageId { name = pkgName } componentId deps@(fileMap, defSiteMap, modNameMap) srcDirs libSrcDirs options modules = do let onError ex = do logErrorN $ T.concat @@ -491,13 +488,13 @@ indexBuildComponent sourceCodePreprocessing currentPackageId componentId deps@(f setTargets targets _ <- load LoadAllTargets modGraph <- getModuleGraph - let topSortMods = flattenSCCs $ filterToposortToModules - (topSortModuleGraph False modGraph Nothing) - buildDir = - addTrailingPathSeparator . normalise . fromMaybe "" . hiDir $ flags' - pathsModuleName = "Paths_" ++ map - (\c -> if c == '-' then '_' else c) - (T.unpack (HCE.name (currentPackageId :: HCE.PackageId))) + let + topSortMods = flattenSCCs $ filterToposortToModules + (topSortModuleGraph False modGraph Nothing) + buildDir = + addTrailingPathSeparator . normalise . fromMaybe "" . hiDir $ flags' + pathsModuleName = + "Paths_" ++ map (\c -> if c == '-' then '_' else c) (T.unpack pkgName) (modSumWithPath, modulesNotFound) <- (\(mods, notFound) -> ( L.reverse |