-
Notifications
You must be signed in to change notification settings - Fork 193
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
DSLD needs a better auto-formatting for DSL builder pattern #603
Comments
I think you could get |
At the moment I think named arguments/parameters are not automatically added when a method proposal is selected. They were kind of bolted on afterwards as proposals within the argument list expression. As for |
Note: If you type and {
|
} |
Regarding |
Regarding having to type |
To simply DSLD api change, I think it will make sense to combine all necessary options into one, e.g. isBuilder: (true | false) An attempt to pick this method from the auto-complete menu would result into desirable state (regardless of Eclipse Content Assist preferences):
|
Before deciding on a final API, have you tried to implement any of the proposed changes? I suggest tackling them separately and when you have all the necessary parts, you could provide switchability from the DSLD API if still required. For trailing Closure completion, if completion of the and {
|
}```
Or does the trailing brace stay on the line of the caret? I understand you want 100% the newline scenario, but I find myself wanting a single-line closure as much as a multi-line one. So it's hard for me to accept always producing the multi-line version when the single-line should be convertible to the multi-line with just one keystroke. |
After choosing and(Closure) proposal it looks like this: The entire closure with brackets is selected and the editor is in the refactoring mode. So in order to bring it to desired state one has to:
Is there any better way? |
Oh that's right. So the issue that I ran into when last I made changes was argument guessing. When that mode is enabled, the choices for a closure argument need to replace the literal If you hit Tab, is there a tab stop for just "it"? Or what about Esc? I thought I set the exit position for the linked mode to cover the "it" param. Basically linked mode lets you set a sequence of selections that can be navigated with tab (or other trigger characters like a comma) and exiting linked mode (usually with a semicolon or Enter keypress) takes you to the API-set exit position. Closure literal insertion is probably the messiest part of the areas you mentioned for improvement. You have to deal with names vs literals, trailing as a special case, "it" or not "it", and formatter preferences for brace position and spacing before and after braces. And params and the "->" could be inserted as well. I'd say try and see if you can get the named arguments to be inserted when the proposal is applied as a first step. We could look into the Closure stuff after. |
There is a summary of the many combinations of content assist options near the end of #410 (see the embedded table images). Typing |
"Place trailing closure arguments after closing parenthesis" preference
"Place trailing closure arguments after closing parenthesis" preference defaults to checked Other concerns will be addressed as individual issues. |
Consider the following typical DSL representing a search query:
Assume
and(Closure block)
method is proposed by the contribution block and the method does not contain required params besides trailing closure.A much preferred state after autocompletion would be:
For a method with required parameters (e.g.
method name: and, namedParams:[score:float]
), desired autocompletion would look like this:Even when Eclipse Content Assist preferences set to "Use closure literals for closure arguments" and "Place trailing closure args after closing parens", the best that could be achieved today is
Desired formatting rules are DSLD-specific, so I propose to add more formatting flags for the "method" tag in the contribution block. We already have noParens which is a good start but it is not sufficient.
We need at least four more options:
I have not investigated how hard this will be to implement, just fishing if this is a sound proposal.
The text was updated successfully, but these errors were encountered: