-
-
Notifications
You must be signed in to change notification settings - Fork 390
Implement explicit fixity in ghcide #2973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -203,6 +205,51 @@ gotoDefinition | |||
gotoDefinition withHieDb getHieFile ideOpts imports srcSpans pos | |||
= lift $ locationsAtPoint withHieDb getHieFile ideOpts imports pos srcSpans | |||
|
|||
fixityAtPoint :: HieAstResult -> HiFileResult -> HscEnv -> Position -> IO (Maybe (Maybe Range, [T.Text])) |
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.
I think it wouldn't be crazy to make atPoint
run in MonadIO m
: almost every other function in here does.
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.
A little crazy to make a pure function to impure?😉
The pain point to making fixity query be impure is runTcInteractive
, I feel it may have a pure method here, worth trying.
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.
Sure, that's generally bad, but most everything here has to run in some monad because it's doing stuff with the GHC API. It's a nice coincidence that atPoint
didn't need it, but I don't think it's fundamental.
Irrelative. |
, hoverTest "signature" (Position 35 2) "infixr 9 `>>>:`" | ||
, hoverTest "operator" (Position 36 2) "infixr 9 `>>>:`" | ||
, hoverTest "escape" (Position 39 2) "infixl 3 `~\\:`" | ||
-- It will cause error like: "Failed to load interface for \8216Fixity\8217\nIt is not a module in the current program, or in any known package." |
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.
Get fixity from locally defined module failed because something like Failed to load interface for \8216Fixity\8217\nIt is not a module in the current program, or in any known package.
It is strange.
It's a trivial case and I think we have an available function even without this.
@@ -61,9 +61,24 @@ getAtPoint file pos = runMaybeT $ do | |||
(hf, mapping) <- useE GetHieAst file | |||
env <- hscEnv . fst <$> useE GhcSession file | |||
dkMap <- lift $ maybe (DKMap mempty mempty) fst <$> runMaybeT (useE GetDocMap file) | |||
tcGblEnv <- tmrTypechecked . fst <$> useE TypeCheck file |
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.
Using TypeCheck
here is bad. It will make ghcide hovers slower, and it will break the ability to get hover information at cold startup from the local cache.
Now, if fixity was in a plugin, it would still create all the problems above since his-plugin-api
collects all the results before sending the response. But one can:
- Disable the fixity plugin
- Implement partial responses
I think this is a blocker. Workarounds:
- Extract back to a plugin
- Introduce a new build rule for fixity information, and give it a persistent implementation with
addPersistentRule
. The persistent implementation can return some placeholder or you can cache the fixity info in hiedb if desired.
Implemented in #2941. |
This is a substitute for #2941, which implement in ghcide.
Due to
AtPoint.atPoint
is a pure function, I insert the fixity inCore/Action.hs
as an entrance.