Implement 'Attempt to fill hole' code action#431
Conversation
|
What do you think about converting it in github "draft" until is ready to review (to enforce the WIP tag)? |
|
@pepeiborra this is ready for review when you have some time :) |
| import SrcLoc | ||
|
|
||
|
|
||
| -- TODO(sandy): Consolidate this with LocalBindings |
There was a problem hiding this comment.
It would be nice if you made a PR on ghcide for this
There was a problem hiding this comment.
Done (I think)
| case splitTyConApp_maybe $ unCType t of | ||
| Nothing -> throwError $ GoalMismatch "destruct" g | ||
| Just (tc, apps) -> do | ||
| let dcs = tyConDataCons tc |
There was a problem hiding this comment.
Are these DataCons in scope? Are they even known to be exported?
There was a problem hiding this comment.
Neither. I don't think the first is important; other plugins can suggest the import.
That being said, preventing unexported datacons from being generated is more interesting, Is there an easy way we can check that?
| = take 1 | ||
| . fmap toLower | ||
| . filterReplace isSymbol 's' | ||
| . filterReplace isPunctuation 'p' |
There was a problem hiding this comment.
replacing symbols and punctuation like this doesn't really need like it will lead to good names.
There was a problem hiding this comment.
No, but without it we run into problems giving names for type operators; it's really hard to come up with a name for a tycon called (:<!>), eg.
| (tcmod, _) <- MaybeT $ runIde state $ useWithStale TypeCheck nfp | ||
| let span = rangeToRealSrcSpan (fromNormalizedFilePath nfp) range' | ||
| -- TODO(sandy): unclear if this span is correct; might be | ||
| -- pointing to the wrong version of the file |
There was a problem hiding this comment.
fix this TODO by applying the position mapping returned by useWithStale
| { ts_skolems :: [TyVar] | ||
| , ts_unifier :: TCvSubst | ||
| , ts_used_vals :: Set OccName | ||
| } |
There was a problem hiding this comment.
These should all probably be strict fields
pepeiborra
left a comment
There was a problem hiding this comment.
I'm not really qualified to review this, but the ghcide and perf bits look fine to me. Can't wait to play with the new features!
|
Merged! |
|
Thanks!! |
|
(Raised on IRC, but repeating) This PR makes the |
|
Submodules strike again! The reference should be pointed to haskell/ghcide#845 |
|
* Add ModLocation to Import type * Add ModuleNames to dependency information With @adamse * Clarify ModLocation assumption * Add a comment on use of rwhnf * newtype ArtifactsLocation Co-authored-by: Marcelo Lazaroni <[email protected]>
This PR brings in the new version of refinery in order to implement the
Attempt to fill holecode action. This action will use the tactic machinery to try to synthesize a term that matches the type of the hole.