diff --git a/ghcide/ghcide.cabal b/ghcide/ghcide.cabal index 2510f04826f..f0bb5a91489 100644 --- a/ghcide/ghcide.cabal +++ b/ghcide/ghcide.cabal @@ -27,11 +27,6 @@ source-repository head type: git location: https://github.com/haskell/ghcide.git -flag ghc-lib - description: build against ghc-lib instead of the ghc package - default: False - manual: True - library default-language: Haskell2010 build-depends: @@ -88,19 +83,10 @@ library vector, bytestring-encoding, opentelemetry >=0.6.1, - heapsize ==0.3.* - if flag(ghc-lib) - build-depends: - ghc-lib >= 8.8, - ghc-lib-parser >= 8.8 - cpp-options: -DGHC_LIB - else - build-depends: + heapsize ==0.3.*, ghc-boot-th, ghc-boot, ghc >= 8.6, - -- These dependencies are used by Development.IDE.Session and are - -- Haskell specific. So don't use them when building with -fghc-lib! ghc-check >=0.5.0.1, ghc-paths, cryptohash-sha1 >=0.11.100 && <0.12, @@ -134,6 +120,7 @@ library hs-source-dirs: src + session-loader include-dirs: include exposed-modules: @@ -162,6 +149,7 @@ library Development.IDE.LSP.Outline Development.IDE.LSP.Protocol Development.IDE.LSP.Server + Development.IDE.Session Development.IDE.Spans.Common Development.IDE.Spans.Documentation Development.IDE.Spans.AtPoint @@ -184,19 +172,6 @@ library Development.IDE.Plugin.Test Development.IDE.Plugin.TypeLenses - -- Unfortunately, we cannot use loadSession with ghc-lib since hie-bios uses - -- the real GHC library and the types are incompatible. Furthermore, when - -- building with ghc-lib we need to make this Haskell agnostic, so no - -- hie-bios! - -- We also put these modules into a separate hs-source-dirs so we can avoid - -- compiling them at all if ghc-lib is not set - if !flag(ghc-lib) - hs-source-dirs: - session-loader - exposed-modules: - Development.IDE.Session - other-modules: - Development.IDE.Session.VersionCheck other-modules: Development.IDE.Core.FileExists Development.IDE.GHC.CPP @@ -206,6 +181,7 @@ library Development.IDE.Plugin.CodeAction.PositionIndexed Development.IDE.Plugin.Completions.Logic Development.IDE.Plugin.HLS.Formatter + Development.IDE.Session.VersionCheck Development.IDE.Types.Action ghc-options: -Wall -Wno-name-shadowing -Wincomplete-uni-patterns @@ -256,8 +232,6 @@ benchmark benchHist yaml executable ghcide - if flag(ghc-lib) - buildable: False default-language: Haskell2010 include-dirs: include @@ -317,8 +291,6 @@ executable ghcide ViewPatterns test-suite ghcide-tests - if flag(ghc-lib) - buildable: False type: exitcode-stdio-1.0 default-language: Haskell2010 build-tool-depends: diff --git a/ghcide/src/Development/IDE/Core/Rules.hs b/ghcide/src/Development/IDE/Core/Rules.hs index fdece3ae2f0..15ba0c0d3f8 100644 --- a/ghcide/src/Development/IDE/Core/Rules.hs +++ b/ghcide/src/Development/IDE/Core/Rules.hs @@ -636,17 +636,7 @@ getDocMapRule = (hscEnv -> hsc, _) <- useWithStale_ GhcSessionDeps file (HAR{refMap=rf}, _) <- useWithStale_ GetHieAst file --- When possible, rely on the haddocks embedded in our interface files --- This creates problems on ghc-lib, see comment on 'getDocumentationTryGhc' -#if !defined(GHC_LIB) - let parsedDeps = [] -#else - deps <- fromMaybe (TransitiveDependencies [] [] []) <$> use GetDependencies file - let tdeps = transitiveModuleDeps deps - parsedDeps <- uses_ GetParsedModule tdeps -#endif - - dkMap <- liftIO $ mkDocMap hsc parsedDeps rf tc + dkMap <- liftIO $ mkDocMap hsc rf tc return ([],Just dkMap) -- | Persistent rule to ensure that hover doesn't block on startup @@ -924,7 +914,6 @@ generateCoreRule = getModIfaceRule :: Rules () getModIfaceRule = defineEarlyCutoff $ \GetModIface f -> do -#if !defined(GHC_LIB) fileOfInterest <- use_ IsFileOfInterest f res@(_,(_,mhmi)) <- case fileOfInterest of IsFOI status -> do @@ -951,13 +940,6 @@ getModIfaceRule = defineEarlyCutoff $ \GetModIface f -> do compiledLinkables <- getCompiledLinkables <$> getIdeGlobalAction liftIO $ modifyVar_ compiledLinkables $ \old -> pure $ extendModuleEnv old mod time pure res -#else - tm <- use_ TypeCheck f - hsc <- hscEnv <$> use_ GhcSessionDeps f - (diags, !hiFile) <- liftIO $ compileToObjCodeIfNeeded hsc Nothing (error "can't compile with ghc-lib") tm - let fp = hiFileFingerPrint <$> hiFile - return (fp, (diags, hiFile)) -#endif getModIfaceWithoutLinkableRule :: Rules () getModIfaceWithoutLinkableRule = defineEarlyCutoff $ \GetModIfaceWithoutLinkable f -> do diff --git a/ghcide/src/Development/IDE/Plugin/Completions.hs b/ghcide/src/Development/IDE/Plugin/Completions.hs index ee1d61fa7fa..47d6947e0df 100644 --- a/ghcide/src/Development/IDE/Plugin/Completions.hs +++ b/ghcide/src/Development/IDE/Plugin/Completions.hs @@ -36,9 +36,6 @@ import Ide.PluginUtils (getClientConfig) import Ide.Types import TcRnDriver (tcRnImportDecls) import Control.Concurrent.Async (concurrently) -#if defined(GHC_LIB) -import Development.IDE.Import.DependencyInformation -#endif descriptor :: PluginId -> PluginDescriptor IdeState descriptor plId = (defaultPluginDescriptor plId) @@ -64,15 +61,6 @@ produceCompletions = do ms <- fmap fst <$> useWithStale GetModSummaryWithoutTimestamps file sess <- fmap fst <$> useWithStale GhcSessionDeps file --- When possible, rely on the haddocks embedded in our interface files --- This creates problems on ghc-lib, see comment on 'getDocumentationTryGhc' -#if !defined(GHC_LIB) - let parsedDeps = [] -#else - deps <- maybe (TransitiveDependencies [] [] []) fst <$> useWithStale GetDependencies file - parsedDeps <- mapMaybe (fmap fst) <$> usesWithStale GetParsedModule (transitiveModuleDeps deps) -#endif - case (ms, sess) of (Just (ms,imps), Just sess) -> do let env = hscEnv sess @@ -81,7 +69,7 @@ produceCompletions = do case (global, inScope) of ((_, Just globalEnv), (_, Just inScopeEnv)) -> do let uri = fromNormalizedUri $ normalizedFilePathToUri file - cdata <- liftIO $ cacheDataProducer uri env (ms_mod ms) globalEnv inScopeEnv imps parsedDeps + cdata <- liftIO $ cacheDataProducer uri env (ms_mod ms) globalEnv inScopeEnv imps return ([], Just cdata) (_diag, _) -> return ([], Nothing) diff --git a/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs b/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs index 4a4990be8f8..06aec292e21 100644 --- a/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs +++ b/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs @@ -294,8 +294,8 @@ mkPragmaCompl label insertText = Nothing Nothing Nothing Nothing Nothing -cacheDataProducer :: Uri -> HscEnv -> Module -> GlobalRdrEnv-> GlobalRdrEnv -> [LImportDecl GhcPs] -> [ParsedModule] -> IO CachedCompletions -cacheDataProducer uri packageState curMod globalEnv inScopeEnv limports deps = do +cacheDataProducer :: Uri -> HscEnv -> Module -> GlobalRdrEnv-> GlobalRdrEnv -> [LImportDecl GhcPs] -> IO CachedCompletions +cacheDataProducer uri packageState curMod globalEnv inScopeEnv limports = do let dflags = hsc_dflags packageState curModName = moduleName curMod @@ -344,7 +344,7 @@ cacheDataProducer uri packageState curMod globalEnv inScopeEnv limports deps = d toCompItem :: Parent -> Module -> ModuleName -> Name -> Maybe (LImportDecl GhcPs) -> IO [CompItem] toCompItem par m mn n imp' = do - docs <- getDocumentationTryGhc packageState curMod deps n + docs <- getDocumentationTryGhc packageState curMod n let (mbParent, originName) = case par of NoParent -> (Nothing, nameOccName n) ParentIs n' -> (Just $ showNameWithoutUniques n', nameOccName n) diff --git a/ghcide/src/Development/IDE/Spans/Documentation.hs b/ghcide/src/Development/IDE/Spans/Documentation.hs index 540ebea44c5..d8139a1d4bb 100644 --- a/ghcide/src/Development/IDE/Spans/Documentation.hs +++ b/ghcide/src/Development/IDE/Spans/Documentation.hs @@ -43,11 +43,10 @@ import HscTypes (HscEnv(hsc_dflags)) mkDocMap :: HscEnv - -> [ParsedModule] -> RefMap a -> TcGblEnv -> IO DocAndKindMap -mkDocMap env sources rm this_mod = +mkDocMap env rm this_mod = do let (_ , DeclDocMap this_docs, _) = extractDocs this_mod d <- foldrM getDocs (mkNameEnv $ M.toList $ fmap (`SpanDocString` SpanDocUris Nothing Nothing) this_docs) names k <- foldrM getType (tcg_type_env this_mod) names @@ -56,7 +55,7 @@ mkDocMap env sources rm this_mod = getDocs n map | maybe True (mod ==) $ nameModule_maybe n = pure map -- we already have the docs in this_docs, or they do not exist | otherwise = do - doc <- getDocumentationTryGhc env mod sources n + doc <- getDocumentationTryGhc env mod n pure $ extendNameEnv map n doc getType n map | isTcOcc $ occName n = do @@ -71,23 +70,21 @@ lookupKind :: HscEnv -> Module -> Name -> IO (Maybe TyThing) lookupKind env mod = fmap (fromRight Nothing) . catchSrcErrors (hsc_dflags env) "span" . lookupName env mod -getDocumentationTryGhc :: HscEnv -> Module -> [ParsedModule] -> Name -> IO SpanDoc -getDocumentationTryGhc env mod deps n = head <$> getDocumentationsTryGhc env mod deps [n] +getDocumentationTryGhc :: HscEnv -> Module -> Name -> IO SpanDoc +getDocumentationTryGhc env mod n = head <$> getDocumentationsTryGhc env mod [n] -getDocumentationsTryGhc :: HscEnv -> Module -> [ParsedModule] -> [Name] -> IO [SpanDoc] --- Interfaces are only generated for GHC >= 8.6. --- In older versions, interface files do not embed Haddocks anyway -getDocumentationsTryGhc env mod sources names = do +getDocumentationsTryGhc :: HscEnv -> Module -> [Name] -> IO [SpanDoc] +getDocumentationsTryGhc env mod names = do res <- catchSrcErrors (hsc_dflags env) "docs" $ getDocsBatch env mod names case res of - Left _ -> mapM mkSpanDocText names + Left _ -> return [] Right res -> zipWithM unwrap res names where unwrap (Right (Just docs, _)) n = SpanDocString docs <$> getUris n unwrap _ n = mkSpanDocText n mkSpanDocText name = - SpanDocText (getDocumentation sources name) <$> getUris name + SpanDocText [] <$> getUris name -- Get the uris to the documentation and source html pages if they exist getUris name = do