Skip to content
  • Matthew Pickering's avatar
    Multi Component (haskell/ghcide#522) · 9837305e
    Matthew Pickering authored
    
    
    * Multi component support
    
    In this commit we add support for loading multiple components into one
    ghcide session.
    
    The current behaviour is that each component is loaded lazily into the
    session. When a file from an unrecognised component is loaded, the
    cradle is consulted again to get a new set of options for the new
    component. This will cause all the currently loaded files to be
    reloaded into a new HscEnv which is shared by all the currently known
    components. The result of this is that functions such as go-to
    definition work between components if they have been loaded into the
    same session but you have to open at least one file from each component
    before it will work.
    
    Only minimal changes are needed to the internals to ghcide to make the
    file searching logic look in include directories for all currently
    loaded components. The main changes are in exe/Main.hs which has been
    heavily rewritten to avoid shake indirections. A global map is created
    which maps a filepath to the HscEnv which should be used to compile it.
    When a new component is created this map is completely refreshed so each
    path maps to a new
    
    Which paths belong to a componenent is determined by the targets listed
    by the cradle. Therefore it is important that each cradle also lists all
    the targets for the cradle. There are some other choices here as well
    which are less accurate such as mapping via include directories  which
    is the aproach that I implemented in haskell-ide-engine.
    
    The commit has been tested so far with cabal and hadrian.
    
    Also deleted the .ghci file which was causing errors during testing and
    seemed broken anyway.
    
    Co-authored-by: default avatarAlan Zimmerman <alan.zimm@gmail.com>
    Co-authored-by: default avatarfendor <power.walross@gmail.com>
    
    * Final tweaks?
    
    * Fix 8.4 build
    
    * Add multi-component test
    
    * Fix hlint
    
    * Add cabal to CI images
    
    * Modify path
    
    * Set PATH in the right place (hopefully)
    
    * Always generate interface files and hie files
    
    * Use correct DynFlags in mkImportDirs
    
    You have to use the DynFlags for the file we are currently compiling to
    get the right packages in the package db so that lookupPackage doesn't
    always fail.
    
    * Revert "Always generate interface files and hie files"
    
    This reverts commit 820aa241890c4498c566e29b0823a803fb2fd297.
    
    * remove traces
    
    * Another test
    
    * lint
    
    * Unset env vars set my stack
    
    * Fix extra-source-files
    
    As usual, stack doesn’t understand Cabal properly and doesn’t seem to
    like ** wildcards so I’ve enumerated it manually.
    
    * Unset env locally
    
    Co-authored-by: default avatarAlan Zimmerman <alan.zimm@gmail.com>
    Co-authored-by: default avatarfendor <power.walross@gmail.com>
    Co-authored-by: default avatarMoritz Kiefer <moritz.kiefer@purelyfunctional.org>
    9837305e