-
Notifications
You must be signed in to change notification settings - Fork 206
Add different Contexts for Module, import etc... #1375
Conversation
7160f52
to
2060ad0
Compare
@@ -13,27 +15,86 @@ import Haskell.Ide.Engine.PluginUtils | |||
-- smarter code completion | |||
data Context = TypeContext | |||
| ValueContext | |||
| ModuleContext String | |||
| ImportContext String | |||
| ImportListContext String |
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.
What other information is relevant? List of imported symbols?
Do we have to be careful to not clone the GHC/ghc-lib/haskell-src-exts API, since we would duplicate the efforts?
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.
Instead of trying to anticipate every possible use-case, I would leave it like that and required context information should be added as needed.
| Just ctx <- everything (<|>) (Nothing `mkQ` go `extQ` goInline) decl | ||
= Just ctx | ||
|
||
| Just ctx <- asum $ map importGo imports |
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 restrained myself to use everything
here, since we do not wish to traverse every info in import lists, this seemed to be more efficient to me, but I do not understand Data
enough, if it actually does what I would expect it to.
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.
Now uses something
which is the same as everything (<|>)
afaik.
go (L (GHC.RealSrcSpan r) GHC.DerivD {}) | ||
| pos `isInsideRange` r = Just DerivingContext | ||
| otherwise = Nothing | ||
go (L (GHC.RealSrcSpan r) (GHC.TyClD _ GHC.ClassDecl {})) |
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.
How should we handle GHC AST version differences?
A quick work around would be, to add another pattern synonym to Compat
.
However, it seems like this would grow out of control quickly. Should we rather use something more version independent, such as ghc-lib or haskell-src-exts?
Only keep contexts that I have a specific use-case in mind for. |
2b9fc88
to
a127d55
Compare
Add more Contexts for the function
getContext
.Goal: Provide information with the Contexts that otherwise need to be reparsed or are simply not available for completions.
So far, this pr provides context for the module header
module Foo.Bar where
, export list from the module and imports.Currently, the performance may take a hit when there are a lot of imports, but I dont know what 'a lot' might be.
Also, adds tests for the different contexts.
PR aims to not change the existing completion system but rather expand available contexts.
Completion system should be changed in a different PR.
Contexts that are planned to be implemented here:
[x] Class declaration[x] Instance declaration[ ] Language pragma (Seems impossible?)