Open davidmorgan opened 7 years ago
I don't believe that implementation is coming from the analysis server.
Yep, Generate menu is not backed by the Analysis Server. YouTrack issue is welcome.
Thanks. Filed https://youtrack.jetbrains.com/issue/WEB-25934
@alexander-doroshko This would be a good candidate for which to add support to the analysis server. As Dart moves forward, this is exactly the kind of thing it would be nice to have supported internally.
@bwilkerson Cool! So, this is what we have in the Generate menu, not backed by the server:
I assume that these are context sensitive. That is, that if the cursor is with a class the generated code applies to the enclosing class (except for the last item, which I assume is the copyright at the top of the file).
If so, I think we'll want a request to get code generation suggestions that takes the file and offset and returns a list of source file edits. Or maybe a list of lists so that we can retain the separator?
Copyright is an IntelliJ's multilingual feature, this is not something Analysis Server should care about :). Others are context-sensitive, that's true.
takes the file and offset and returns a list of source file edits
I'm afraid the task is more complex. Probably we'll have to handle each action separately, as we do with refactorings. All of them are expected to show a specific dialog to get more user input. For example, constructor generator allows to select which fields to initialize:
This is a dialog for Override Methods:
Ah, I didn't realize how much this functionality is doing. Yes, an API similar to that for refactoring would be needed, which makes this a bigger task than I'd originally anticipated. I still think we should do it; I'll see how soon I can start putting together a proposal that we can iterate on.
Repro:
Right click in the class and choose Generate->Implement Methods, choose all of them, press okay. Output is wrong for methods that take a function, e.g.:
should be
interestingly, if you trigger the same generation by a different path, Ctrl+Enter and choose suggestion "generate 38 missing overrides", the generated code is correct.