-
-
Notifications
You must be signed in to change notification settings - Fork 368
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
Split ghcide actions into different descriptors #1857
Conversation
We want descriptors, not providers, so this PR is doing the right thing. I may have said provider where I really meant descriptor. |
@jneira Does the split have the granularity that you expected? It seems fine to me, but it might not be enough to support disabling specific code actions. |
fine with me too, if this pr open the way to disable cas even in small groups we could wait to issues asking for |
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, awesome work @berberman
Out of curiosity I just checked the benchmark results, and they look quite impressive:
|
What happened to memory allocation (for "code actions after edit" bench)? That's quite impressive. |
Previously, we waited all If I'm right, I guess moving |
We also can enable parallelism in each group, but I'm not sure whether the contention will make it worse, given: haskell-language-server/ghcide/src/Development/IDE/Plugin/CodeAction/Args.hs Lines 149 to 157 in a7510a9
|
Do we need that |
But a delayed action will still be enqueued, no? Let's try removing |
After removing
|
So you are saying that we will end up with multiple copies of the same What does the benchmark show, is |
Yes, I think HEAD is the version without |
The numbers in the benchmark look contradictory. Why is userTime 66% in the "code actions" experiment, but 33% higher in the "code actions after edit" exp.? |
I re-run the benchmark CI. It seems that the gap is narrowed, but HEAD is still slightly slower than upstream overall.
|
Based on those results, I would remove the |
I understand your concern, but the situation here is very different, and I'm still a bit worried about the overhead of executing those suggestExtendImport :: ExportsMap -> ParsedSource -> Diagnostic -> [(T.Text, CodeActionKind, Rewrite)] to something like: f :: CodeActionArgs -> IO [(T.Text, CodeActionKind, [TextEdit])]
f CodeActionArgs {..} = do
x <- caaExportsMap
y <- fmap astA <$> caaAnnSource
case y of
Just ps -> do
let results = suggestExtendImport x ps caaDiagnostic
concat
<$> mapM
( \(a, b, c) -> do
d <- caaDf``
e <- fmap annsA <$> caaAnnSource
case (d, e) of
(Just df, Just anns)
| Right edit <- rewriteToEdit df anns c -> pure [(a, b, edit)]
_ -> pure []
)
results
_ -> pure [] where haskell-language-server/ghcide/src/Development/IDE/Plugin/CodeAction/Args.hs Lines 135 to 147 in 204fdcb
As you can see, for N results produced by |
I see what you mean now, thank you for elaborating the argument. I agree that this is a bit different because every provider may execute an Action multiple times. This is odd! |
This PR attempts to split the big code action provider in ghcide. I want to minimize the trivial changes in implementation functions (
suggestExtendImport
,suggestImportDisambiguation
, etc.), so I refactoredDevelopment.IDE.Plugin.CodeAction.Args
to keep the automatic function arguments passing, making it compatible with the old code. However, iiuc the provider should be broken down into different providers, rather than descriptors like this PR does. One of our initial goals is to make those code actions switchable, but providers are anonymous, whereas descriptors have their names, so it's not clear how to generate configuration per provider. Thus this PR introduces some new descriptors for ghcide code actions. This might not be reasonable, but with the abstraction ofCodeActionArgs
, it won't be hard to reorganize them in providers.Now the code actions are grouped blindly and I havn't tested them