Develop with Pleasure
Is there a small feature missing from IDEA that would make your life happier, would make you sing IDEA's "Develop with Pleasure" motto? Please use this thread to highlight that missing feature or two in the issue database so we can all take a look & vote, especially long-standing features that were overlooked and risk being overlooked forever.
Thanks,
Jon
请先登录再写评论。
I have experimented extensively with the available formatting options and have gotten IDEA as close as I believe it can get, but that's not really what any of these complaints are about.
By "regenerates ... imports" I mean that clearly the imports as present in the source code are replaced and in the process of doing so, they are reformatted.
As for code modifications causing a reformatting, two things come to mind:
1) Why?
2) Why does the effect extend outside the affected program text?
I'm aware that whitespace in a JavaDoc comment won't affect the rendering of the resulting HTML, but I read my comments a lot more in the Java source code than I do in the JavaDocs.
I'm just playing devil's advocate here to get you to examine and explain your reasons for the complaints you've made, so that JetBrains has a clear idea of what you want and why you want it. I think that makes it more likely for them to consider implementing your requests.
If you could describe what code-styling you are unable to achieve with the settings available in IDEA, perhaps that can be improved.
Sure, but why does that bother you? If they're properly formatted afterwards, what difference does it make?
1. Replacing the variable name 'foo' with 'zomgHugeAssVariableNameThatsJustTooDamnBig' affects the layout of the code and thus the code should be reformatted so that it still looks neat after the code modification.
2. That I can't adequately explain. I suspect it has something to do with the reformat being applied to the enclosing code block.
Me too. This is something that I would like to see, including other Javadoc formatting improvements such as rewrapping/reflowing text to fit the right margin.
I'm very vertically oriented, if you will. That is, I like a lot of columnar alignment and I tend to spread things out over many lines. E.g., I put a newline between each modifier, the type and the name of a method (indentation omitted here):
public
static
void
doSomething(int howManyTimes)
{
// ...
}
As for the imports, they're not "properly formatted." If they were, I wouldn't say anything. But in keeping with my desire for columnar alignment, I put three tabs after "import" and one after "import static". After IDEA gratuitously regenerates all the import statements, there is only a single space after "import" or "import static".
As for reformatting code after a renaming, nothing IDEA generates fits my description of "neat," since it always smashes everything together with a bare minimum of whitespace allowable to make the program text parse correctly. In the case where one pastes code from another file and imports must be added, it gratuitously reformats the pasted code, even though nothing within it needs to change at all!
I consider all these things very heavy-handed and undesirable.
Randall Schulz
There is an editor option Editor->Paste->Reformat with choices None, Indent Block, Indent Each Line, Reformat Block. I forgot what the default is, Reformat Block ?
Mine is set on "Indent Block." According to the Help text:
"Indent Block - The pasted code block is positioned at the proper indentation level, according to the current Code Style Settings, but its inner structure is not changed."
This is not consistent with what I'm seeing. It appears to behave more like "Reformat Block":
"Reformat Block - The pasted code block is reformatted according to the current Code Style Settings."
Randall Schulz
Randall Schulz wrote:
I agree and have always wanted this when using CamelCase. If you want
to change the last fragment of a word you currently have to press left
arrow after selecting the last fragment as the space is included. It's
been this way for so long clearly any changes would need to be optional
for the user.
Cheers,
N.
This was once a very good thread, focused on suggesting fixes to jetbrain, and apparently very useful, because jetbrains was actively reading it. May I suggest you move these code-formatting related discussions to a diffferent thread?
I put them here because they are explicitly my response to the feedback that Jon Steelman originally solicited. In particular, these issues really diminish the how pleasurable it is for me to use IDEA. No one else has suggested this is off-topic and several, including Jon, have contributed to refining or clarifying the issue.
What's the problem?
And finally we come to the meat of it :)
This is the sort of detail that I believe JetBrains is looking for when they ask for feedback. Hopefully they can take your requirements into consideration and improve the code-styling facilities in a future version.
To be honest, I don't think there's much that can be done about it until they support your code-style. IDEA is designed and written with the implicit assumption that your code-style is correctly defined. It just doesn't have the option to not format your code when it makes changes.
Randall - I haven't followed this closely but make sure you capture the "meat of it" as Gordon says in the JIRA issue(s).
Jon
Well, fair enough, I suppose, though it's not exactly what I wanted to hear, of course.
I assume the internal form in which code (fragments) are manipulated is not text but some kind of AST, probably decorated with lots of symbol table annotations and whatnot.
Obviously, this is the only way to write an IDE that does the things IDEA does. I've always believed that it should / would / will be possible to write code formatters (to effect the reverse transformation from AST back to program text) that satisfy any programmer's stylistic wishes. And I'll readily admit my preferences are unusual, perhaps even baroque.
Perhaps the thing to move toward is a formatting language for specifying how to turn the internal representation of code into text. Then weirdos like me can just deal with this ourselves. Plus, a large chunk of the preferences UI can be turned into a tool the synthesizes the formatter code according to the selected style options. That formatter code can be used as-is or tweaked if it's close but not quite right.
Anyway, for the time being, perhaps I can work with the author of Tabifier. At first I thought it would do what I want, but as extensive as its columnar formatting capabilities are, they still miss the mark a bit for me.
Randall Schulz
I noticed that you're watching those two issues. Do you think they're not complete or clear enough as I originally wrote them and copied them here (above)?
RRS
+1