mirror of
https://github.com/haskell/ghcide.git
synced 2024-11-26 12:25:25 +03:00
Compatibility with fbghc (#892)
* Compatibility with fbghc Rather than forking ghcide, we use conditional compilation to build with https://github.com/facebook/fbghc hopefully only until certain changes have been upstreamed. * Reexport DynFlags from Compat.GHC * Add a link to the fbghc repo
This commit is contained in:
parent
00614465fa
commit
f4bfe9c103
@ -59,7 +59,6 @@ import System.Info
|
|||||||
import System.IO
|
import System.IO
|
||||||
|
|
||||||
import GHCi
|
import GHCi
|
||||||
import DynFlags
|
|
||||||
import HscTypes (ic_dflags, hsc_IC, hsc_dflags, hsc_NC)
|
import HscTypes (ic_dflags, hsc_IC, hsc_dflags, hsc_NC)
|
||||||
import Linker
|
import Linker
|
||||||
import Module
|
import Module
|
||||||
|
@ -15,7 +15,6 @@ import Data.List.Extra
|
|||||||
import System.FilePath
|
import System.FilePath
|
||||||
import System.IO.Extra
|
import System.IO.Extra
|
||||||
import Data.Char
|
import Data.Char
|
||||||
import DynFlags
|
|
||||||
import qualified HeaderInfo as Hdr
|
import qualified HeaderInfo as Hdr
|
||||||
import Development.IDE.Types.Diagnostics
|
import Development.IDE.Types.Diagnostics
|
||||||
import Development.IDE.Types.Location
|
import Development.IDE.Types.Location
|
||||||
|
@ -69,7 +69,6 @@ import Language.Haskell.LSP.Types (DocumentHighlight (..))
|
|||||||
|
|
||||||
import qualified GHC.LanguageExtensions as LangExt
|
import qualified GHC.LanguageExtensions as LangExt
|
||||||
import HscTypes hiding (TargetModule, TargetFile)
|
import HscTypes hiding (TargetModule, TargetFile)
|
||||||
import DynFlags (gopt_set, xopt)
|
|
||||||
import GHC.Generics(Generic)
|
import GHC.Generics(Generic)
|
||||||
|
|
||||||
import qualified Development.IDE.Spans.AtPoint as AtPoint
|
import qualified Development.IDE.Spans.AtPoint as AtPoint
|
||||||
@ -527,7 +526,7 @@ getHieAstsRule =
|
|||||||
getHieAstRuleDefinition :: NormalizedFilePath -> HscEnv -> TcModuleResult -> Action (IdeResult HieAstResult)
|
getHieAstRuleDefinition :: NormalizedFilePath -> HscEnv -> TcModuleResult -> Action (IdeResult HieAstResult)
|
||||||
getHieAstRuleDefinition f hsc tmr = do
|
getHieAstRuleDefinition f hsc tmr = do
|
||||||
(diags, masts) <- liftIO $ generateHieAsts hsc tmr
|
(diags, masts) <- liftIO $ generateHieAsts hsc tmr
|
||||||
|
|
||||||
isFoi <- use_ IsFileOfInterest f
|
isFoi <- use_ IsFileOfInterest f
|
||||||
diagsWrite <- case isFoi of
|
diagsWrite <- case isFoi of
|
||||||
IsFOI Modified -> pure []
|
IsFOI Modified -> pure []
|
||||||
@ -535,7 +534,7 @@ getHieAstRuleDefinition f hsc tmr = do
|
|||||||
source <- getSourceFileSource f
|
source <- getSourceFileSource f
|
||||||
liftIO $ writeHieFile hsc (tmrModSummary tmr) (tcg_exports $ tmrTypechecked tmr) asts source
|
liftIO $ writeHieFile hsc (tmrModSummary tmr) (tcg_exports $ tmrTypechecked tmr) asts source
|
||||||
_ -> pure []
|
_ -> pure []
|
||||||
|
|
||||||
let refmap = generateReferencesMap . getAsts <$> masts
|
let refmap = generateReferencesMap . getAsts <$> masts
|
||||||
pure (diags <> diagsWrite, HAR (ms_mod $ tmrModSummary tmr) <$> masts <*> refmap)
|
pure (diags <> diagsWrite, HAR (ms_mod $ tmrModSummary tmr) <$> masts <*> refmap)
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ import Development.IDE.GHC.Compat
|
|||||||
import Packages
|
import Packages
|
||||||
import SysTools
|
import SysTools
|
||||||
import Module
|
import Module
|
||||||
import DynFlags
|
|
||||||
import Panic
|
import Panic
|
||||||
import FileCleanup
|
import FileCleanup
|
||||||
#if MIN_GHC_API_VERSION(8,8,2)
|
#if MIN_GHC_API_VERSION(8,8,2)
|
||||||
|
@ -28,8 +28,6 @@ module Development.IDE.GHC.Compat(
|
|||||||
addBootSuffixLocnOut,
|
addBootSuffixLocnOut,
|
||||||
#endif
|
#endif
|
||||||
hPutStringBuffer,
|
hPutStringBuffer,
|
||||||
includePathsGlobal,
|
|
||||||
includePathsQuote,
|
|
||||||
addIncludePathsQuote,
|
addIncludePathsQuote,
|
||||||
getModuleHash,
|
getModuleHash,
|
||||||
getPackageName,
|
getPackageName,
|
||||||
@ -37,6 +35,7 @@ module Development.IDE.GHC.Compat(
|
|||||||
GHC.ModLocation,
|
GHC.ModLocation,
|
||||||
Module.addBootSuffix,
|
Module.addBootSuffix,
|
||||||
pattern ModLocation,
|
pattern ModLocation,
|
||||||
|
pattern ExposePackage,
|
||||||
HasSrcSpan,
|
HasSrcSpan,
|
||||||
getLoc,
|
getLoc,
|
||||||
upNameCache,
|
upNameCache,
|
||||||
@ -54,6 +53,7 @@ module Development.IDE.GHC.Compat(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
module GHC,
|
module GHC,
|
||||||
|
module DynFlags,
|
||||||
initializePlugins,
|
initializePlugins,
|
||||||
applyPluginsParsedResultAction,
|
applyPluginsParsedResultAction,
|
||||||
module Compat.HieTypes,
|
module Compat.HieTypes,
|
||||||
@ -66,7 +66,8 @@ import LinkerTypes
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
import StringBuffer
|
import StringBuffer
|
||||||
import DynFlags
|
import qualified DynFlags
|
||||||
|
import DynFlags hiding (ExposePackage)
|
||||||
import Fingerprint (Fingerprint)
|
import Fingerprint (Fingerprint)
|
||||||
import qualified Module
|
import qualified Module
|
||||||
import Packages
|
import Packages
|
||||||
@ -271,6 +272,14 @@ applyPluginsParsedResultAction :: HscEnv -> DynFlags -> ModSummary -> ApiAnns ->
|
|||||||
applyPluginsParsedResultAction env dflags ms hpm_annotations parsed = do
|
applyPluginsParsedResultAction env dflags ms hpm_annotations parsed = do
|
||||||
-- Apply parsedResultAction of plugins
|
-- Apply parsedResultAction of plugins
|
||||||
let applyPluginAction p opts = parsedResultAction p opts ms
|
let applyPluginAction p opts = parsedResultAction p opts ms
|
||||||
fmap hpm_module $
|
fmap hpm_module $
|
||||||
runHsc env $ withPlugins dflags applyPluginAction
|
runHsc env $ withPlugins dflags applyPluginAction
|
||||||
(HsParsedModule parsed [] hpm_annotations)
|
(HsParsedModule parsed [] hpm_annotations)
|
||||||
|
|
||||||
|
pattern ExposePackage :: String -> PackageArg -> ModRenaming -> PackageFlag
|
||||||
|
-- https://github.com/facebook/fbghc
|
||||||
|
#ifdef __FACEBOOK_HASKELL__
|
||||||
|
pattern ExposePackage s a mr <- DynFlags.ExposePackage s a _ mr
|
||||||
|
#else
|
||||||
|
pattern ExposePackage s a mr = DynFlags.ExposePackage s a mr
|
||||||
|
#endif
|
||||||
|
@ -68,7 +68,6 @@ import Outputable (showSDocUnsafe, ppr, showSDoc, Outputable)
|
|||||||
import Packages (getPackageConfigMap, lookupPackage')
|
import Packages (getPackageConfigMap, lookupPackage')
|
||||||
import SrcLoc (mkRealSrcLoc)
|
import SrcLoc (mkRealSrcLoc)
|
||||||
import FastString (mkFastString)
|
import FastString (mkFastString)
|
||||||
import DynFlags (emptyFilesToClean, unsafeGlobalDynFlags)
|
|
||||||
import Module (moduleNameSlashes, InstalledUnitId)
|
import Module (moduleNameSlashes, InstalledUnitId)
|
||||||
import OccName (parenSymOcc)
|
import OccName (parenSymOcc)
|
||||||
import RdrName (nameRdrName, rdrNameOcc)
|
import RdrName (nameRdrName, rdrNameOcc)
|
||||||
|
@ -54,7 +54,6 @@ import HscTypes
|
|||||||
import Parser
|
import Parser
|
||||||
import Text.Regex.TDFA (mrAfter, (=~), (=~~))
|
import Text.Regex.TDFA (mrAfter, (=~), (=~~))
|
||||||
import Outputable (ppr, showSDocUnsafe)
|
import Outputable (ppr, showSDocUnsafe)
|
||||||
import DynFlags (xFlags, FlagSpec(..))
|
|
||||||
import GHC.LanguageExtensions.Type (Extension)
|
import GHC.LanguageExtensions.Type (Extension)
|
||||||
import Data.Function
|
import Data.Function
|
||||||
import Control.Arrow ((>>>))
|
import Control.Arrow ((>>>))
|
||||||
@ -172,7 +171,7 @@ suggestAction dflags packageExports ideOptions parsedModule text diag = concat
|
|||||||
, removeRedundantConstraints text diag
|
, removeRedundantConstraints text diag
|
||||||
, suggestAddTypeAnnotationToSatisfyContraints text diag
|
, suggestAddTypeAnnotationToSatisfyContraints text diag
|
||||||
] ++ concat
|
] ++ concat
|
||||||
[ suggestConstraint pm text diag
|
[ suggestConstraint pm text diag
|
||||||
++ suggestNewDefinition ideOptions pm text diag
|
++ suggestNewDefinition ideOptions pm text diag
|
||||||
++ suggestNewImport packageExports pm diag
|
++ suggestNewImport packageExports pm diag
|
||||||
++ suggestDeleteUnusedBinding pm text diag
|
++ suggestDeleteUnusedBinding pm text diag
|
||||||
@ -696,7 +695,7 @@ suggestConstraint parsedModule mContents diag@Diagnostic {..}
|
|||||||
| Just contents <- mContents
|
| Just contents <- mContents
|
||||||
, Just missingConstraint <- findMissingConstraint _message
|
, Just missingConstraint <- findMissingConstraint _message
|
||||||
= let codeAction = if _message =~ ("the type signature for:" :: String)
|
= let codeAction = if _message =~ ("the type signature for:" :: String)
|
||||||
then suggestFunctionConstraint parsedModule
|
then suggestFunctionConstraint parsedModule
|
||||||
else suggestInstanceConstraint contents
|
else suggestInstanceConstraint contents
|
||||||
in codeAction diag missingConstraint
|
in codeAction diag missingConstraint
|
||||||
| otherwise = []
|
| otherwise = []
|
||||||
@ -798,14 +797,14 @@ suggestFunctionConstraint ParsedModule{pm_parsed_source = L _ HsModule{hsmodDecl
|
|||||||
| Just typeSignatureName <- findTypeSignatureName _message
|
| Just typeSignatureName <- findTypeSignatureName _message
|
||||||
= let mExistingConstraints = findExistingConstraints _message
|
= let mExistingConstraints = findExistingConstraints _message
|
||||||
newConstraint = buildNewConstraints missingConstraint mExistingConstraints
|
newConstraint = buildNewConstraints missingConstraint mExistingConstraints
|
||||||
in case findRangeOfContextForFunctionNamed typeSignatureName of
|
in case findRangeOfContextForFunctionNamed typeSignatureName of
|
||||||
Just range -> [(actionTitle missingConstraint typeSignatureName, [TextEdit range newConstraint])]
|
Just range -> [(actionTitle missingConstraint typeSignatureName, [TextEdit range newConstraint])]
|
||||||
Nothing -> []
|
Nothing -> []
|
||||||
| otherwise = []
|
| otherwise = []
|
||||||
where
|
where
|
||||||
findRangeOfContextForFunctionNamed :: T.Text -> Maybe Range
|
findRangeOfContextForFunctionNamed :: T.Text -> Maybe Range
|
||||||
findRangeOfContextForFunctionNamed typeSignatureName = do
|
findRangeOfContextForFunctionNamed typeSignatureName = do
|
||||||
locatedType <- listToMaybe
|
locatedType <- listToMaybe
|
||||||
[ locatedType
|
[ locatedType
|
||||||
| L _ (SigD _ (TypeSig _ identifiers (HsWC _ (HsIB _ locatedType)))) <- hsmodDecls
|
| L _ (SigD _ (TypeSig _ identifiers (HsWC _ (HsIB _ locatedType)))) <- hsmodDecls
|
||||||
, any (`isSameName` T.unpack typeSignatureName) $ fmap unLoc identifiers
|
, any (`isSameName` T.unpack typeSignatureName) $ fmap unLoc identifiers
|
||||||
|
@ -23,7 +23,6 @@ import Name
|
|||||||
import RdrName
|
import RdrName
|
||||||
import Type
|
import Type
|
||||||
import Packages
|
import Packages
|
||||||
import DynFlags
|
|
||||||
#if MIN_GHC_API_VERSION(8,10,0)
|
#if MIN_GHC_API_VERSION(8,10,0)
|
||||||
import Predicate (isDictTy)
|
import Predicate (isDictTy)
|
||||||
import GHC.Platform
|
import GHC.Platform
|
||||||
@ -474,9 +473,9 @@ getCompletions ideOpts CC { allModNamesAsNS, unqualCompls, qualCompls, importabl
|
|||||||
-- The supported languages and extensions
|
-- The supported languages and extensions
|
||||||
languagesAndExts :: [T.Text]
|
languagesAndExts :: [T.Text]
|
||||||
#if MIN_GHC_API_VERSION(8,10,0)
|
#if MIN_GHC_API_VERSION(8,10,0)
|
||||||
languagesAndExts = map T.pack $ DynFlags.supportedLanguagesAndExtensions ( PlatformMini ArchUnknown OSUnknown )
|
languagesAndExts = map T.pack $ GHC.supportedLanguagesAndExtensions ( PlatformMini ArchUnknown OSUnknown )
|
||||||
#else
|
#else
|
||||||
languagesAndExts = map T.pack DynFlags.supportedLanguagesAndExtensions
|
languagesAndExts = map T.pack GHC.supportedLanguagesAndExtensions
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------
|
-- ---------------------------------------------------------------------
|
||||||
|
@ -26,7 +26,6 @@ import GHC.Generics
|
|||||||
|
|
||||||
import GHC
|
import GHC
|
||||||
import Outputable hiding ((<>))
|
import Outputable hiding ((<>))
|
||||||
import DynFlags
|
|
||||||
import ConLike
|
import ConLike
|
||||||
import DataCon
|
import DataCon
|
||||||
import Var
|
import Var
|
||||||
@ -34,6 +33,7 @@ import NameEnv
|
|||||||
|
|
||||||
import qualified Documentation.Haddock.Parser as H
|
import qualified Documentation.Haddock.Parser as H
|
||||||
import qualified Documentation.Haddock.Types as H
|
import qualified Documentation.Haddock.Types as H
|
||||||
|
import Development.IDE.GHC.Compat
|
||||||
import Development.IDE.GHC.Orphans ()
|
import Development.IDE.GHC.Orphans ()
|
||||||
|
|
||||||
type DocMap = NameEnv SpanDoc
|
type DocMap = NameEnv SpanDoc
|
||||||
|
Loading…
Reference in New Issue
Block a user