-
Notifications
You must be signed in to change notification settings - Fork 97
Typecheck entire project on Initial Load and typecheck reverse dependencies of a file on saving #688
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly good to me!
liftIO $ do | ||
(log $ "Got Reverse dependencies for" ++ show nfp ++ ": " ++ show revs) | ||
`catch` \(e :: SomeException) -> log (show e) | ||
print (length revs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
liftIO $ do | |
(log $ "Got Reverse dependencies for" ++ show nfp ++ ": " ++ show revs) | |
`catch` \(e :: SomeException) -> log (show e) | |
print (length revs) |
22f7e4b
to
582247c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
A few comments:
First on the UX:
-
I personally prefer having changes propagate to other files immediately. I realize this is not everyone's preference and I’m fine with having both as an option and could be convinced as to what we want the default to be but I don’t want to lose that functionality completely.
-
I sometimes have a large project that is known to be in a broken state but I only care about some files. By typechecking everything on startup, I get a ton of errors for files I deliberately didn’t open and on very large projects it also slows things down unnecessarily. Not quite sure how to fix that. A CLi flag for switching between the two modes doesn’t seem like a great UX.
-
What happens if I dynamically add new files? Especially in DAML that is pretty common and something that worked fine so far. It isn’t clear to me if this still works (we should add a test for it).
As for the implementation, my primary concern is around the location of this logic.
The function for setting up sessions is now responsible for modifying knownFilesVar
and there is no clear documentation around when and how it can and must modify this. Not quite sure how much we can do here API wise to make this better but least we should have some documentation on optGhcSession
.
I’d also like to see some tests for this.
modules Only propagate changes to parent modules when saving Typecheck files when they are opened, don't TC FOI Add known files rule Don't save ifaces for files with defered errors Co-authored-by: Zubin Duggal <[email protected]>
We can use the LSP configuration request for these
Should work fine on adding files, but it will show diagnostics if you delete files. I've modified the iface tests to check the functionality added by this module. |
Added the ability to configure the behavior added by this patch, see the readme for details |
src/Development/IDE/Core/Rules.hs
Outdated
@@ -500,6 +502,25 @@ typeCheckRule = define $ \TypeCheck file -> do | |||
-- for files of interest on every keystroke | |||
typeCheckRuleDefinition hsc pm SkipGenerationOfInterfaceFiles | |||
|
|||
data GetKnownFiles = GetKnownFiles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to host GetKnownFiles
in RuleTypes
? It could be useful in plugins
* Use targets to filter located imports * Remove import paths from the GHC session Otherwise GHC will prioritize source files found in the import path
Co-authored-by: Pepe Iborra <[email protected]>
* Really disable expensive checkParents * Add an option to check parents on close
This closes #216 |
…encies of a file on saving (haskell/ghcide#688) * Add new command to GetModuleGraph for a session and propate changes to modules Only propagate changes to parent modules when saving Typecheck files when they are opened, don't TC FOI Add known files rule Don't save ifaces for files with defered errors Co-authored-by: Zubin Duggal <[email protected]> * Add configuration for parent typechecking * hlint ignore * Use targets to filter located imports (haskell/ghcide#10) * Use targets to filter located imports * Remove import paths from the GHC session Otherwise GHC will prioritize source files found in the import path * Update session-loader/Development/IDE/Session.hs Co-authored-by: Pepe Iborra <[email protected]> * Add session-loader to hie.yaml (haskell/ghcide#714) * move known files rule to RuleTypes * Disable checkParents on open and close document (haskell/ghcide#12) * Really disable expensive checkParents * Add an option to check parents on close Co-authored-by: Matthew Pickering <[email protected]> Co-authored-by: Pepe Iborra <[email protected]> Co-authored-by: Luke Lau <[email protected]>
…encies of a file on saving (haskell/ghcide#688) * Add new command to GetModuleGraph for a session and propate changes to modules Only propagate changes to parent modules when saving Typecheck files when they are opened, don't TC FOI Add known files rule Don't save ifaces for files with defered errors Co-authored-by: Zubin Duggal <[email protected]> * Add configuration for parent typechecking * hlint ignore * Use targets to filter located imports (haskell/ghcide#10) * Use targets to filter located imports * Remove import paths from the GHC session Otherwise GHC will prioritize source files found in the import path * Update session-loader/Development/IDE/Session.hs Co-authored-by: Pepe Iborra <[email protected]> * Add session-loader to hie.yaml (haskell/ghcide#714) * move known files rule to RuleTypes * Disable checkParents on open and close document (haskell/ghcide#12) * Really disable expensive checkParents * Add an option to check parents on close Co-authored-by: Matthew Pickering <[email protected]> Co-authored-by: Pepe Iborra <[email protected]> Co-authored-by: Luke Lau <[email protected]>
…encies of a file on saving (haskell/ghcide#688) * Add new command to GetModuleGraph for a session and propate changes to modules Only propagate changes to parent modules when saving Typecheck files when they are opened, don't TC FOI Add known files rule Don't save ifaces for files with defered errors Co-authored-by: Zubin Duggal <[email protected]> * Add configuration for parent typechecking * hlint ignore * Use targets to filter located imports (haskell/ghcide#10) * Use targets to filter located imports * Remove import paths from the GHC session Otherwise GHC will prioritize source files found in the import path * Update session-loader/Development/IDE/Session.hs Co-authored-by: Pepe Iborra <[email protected]> * Add session-loader to hie.yaml (haskell/ghcide#714) * move known files rule to RuleTypes * Disable checkParents on open and close document (haskell/ghcide#12) * Really disable expensive checkParents * Add an option to check parents on close Co-authored-by: Matthew Pickering <[email protected]> Co-authored-by: Pepe Iborra <[email protected]> Co-authored-by: Luke Lau <[email protected]>
It is useful to show diagnostics for all files in a project when it is initially loaded.
It is also useful to propagate changes we make in one file to other files which depend on the file we have changed. We only trigger this on saves to avoid annoying users with a barrage of errors, which is also helpful for IDE speed and responsiveness as we don't want to potentially recompile the entire project on every keystroke.
This reduces dependence on
kick
, as we can precisely target the files we need to reload.Also fixed a bug where we would cache the iface of a file that compiled due to
-fdefer-type-errors
. Due to this, on subsequent runs ofghcide
, we would not get diagnostics for those files. This is also essential to make the parent type-checking stuff work as expected.